kv2: initialize memory manager, early pci devices

Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
This commit is contained in:
Michael Shaw 2026-05-12 02:59:37 -04:00
commit a252a3f8e9
58 changed files with 1270 additions and 505 deletions

View file

@ -329,13 +329,16 @@ typedef volatile struct {
} PACKED hbafis_t;
struct sata_device {
struct pci_device *controller;
uint8_t port;
struct ahci_host {
struct pci_device *device;
hbamem_t *abar;
};
struct sata_device {
struct ahci_host *host;
uint8_t port;
size_t sector_size;
size_t sector_count;
hbamem_t *abar;
};
int ahci_access_sectors(struct sata_device *dev, paddr_t lba, uint16_t count, paddr_t buf, bool write);

24
include/drivers/block.h Normal file
View file

@ -0,0 +1,24 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _BLOCK_H_
#define _BLOCK_H_
#include <kernel/device.h>
struct block_device;
struct block_ops {
ssize_t (*read)(struct block_device *dev, char *buf, size_t offset, size_t n);
ssize_t (*write)(struct block_device *dev, char *buf, size_t offset, size_t n);
};
struct block_device {
char *name;
dev_t dev;
size_t size;
size_t block_size;
struct block_ops ops;
};
ssize_t block_read(struct block_device *dev, char *buf, size_t offset, size_t n);
ssize_t block_write(struct block_device *dev, char *buf, size_t offset, size_t n);
#endif /* _BLOCK_H_ */

View file

@ -4,16 +4,39 @@
#include <kernel/common.h>
#include <lib/list.h>
struct pci_host {
vaddr_t base;
u16 segment_group;
u8 start_bus;
u8 end_bus;
};
struct pci_device {
u64 class;
u64 vendor;
u8 bus;
u8 slot;
u8 func;
struct pci_host *host;
u16 class_major;
u16 class_minor;
u16 vendor;
u16 device_id;
u8 bus;
u8 slot;
u8 func;
paddr_t bar0;
paddr_t bar1;
paddr_t bar2;
paddr_t bar3;
} PACKED;
paddr_t bar4;
paddr_t bar5;
};
void pci_register_host(struct pci_host *host);
void pci_init();
u32 pci_config_read(struct pci_host *host, u32 bus, u32 slot, u32 func, u32 offset);
void pci_config_write(struct pci_host *host, u32 bus, u32 slot, u32 func, u32 offset, u32 val);
size_t pci_find_device(u16 minor, u16 major, list_t *out);
#endif /* _PCI_H_ */

View file

@ -4,8 +4,6 @@
#include <kernel/device.h>
#define DEV_CLASS_TTY 0x01
struct tty_serial_ops {
void (*serial_putchar)(struct tty *tty, char c);
char (*serial_getchar)(struct tty *tty);
@ -13,15 +11,13 @@ struct tty_serial_ops {
struct tty {
dev_t dev;
dev_t serial_device;
void *serial_device_private;
void *priv;
struct tty_serial_ops *serial_ops;
};
void tty_layer_init();
struct tty *tty_create(const char *name, dev_t serial_device);
struct tty *tty_create(const char *name, void *priv);
void tty_putchar(struct tty *tty, char c);
char tty_getchar(struct tty *tty);
void tty_write(struct tty *tty, const char *s);