Skip to content

Commit

Permalink
Make PCI bus initialization code more generic
Browse files Browse the repository at this point in the history
Register PCI bus to io_bus at x86-64 architecutre specific code.
  • Loading branch information
yanjiew1 committed Jun 17, 2023
1 parent bba4a1f commit 5b23e25
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/arch/x86/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ int vm_arch_cpu_init(vm_t *v)

int vm_arch_init_platform_device(vm_t *v)
{
pci_init(&v->pci, &v->io_bus);
pci_init(&v->pci);
bus_register_dev(&v->io_bus, &v->pci.pci_addr_dev);
bus_register_dev(&v->io_bus, &v->pci.pci_bus_dev);
if (serial_init(&v->serial, &v->io_bus))
return throw_err("Failed to init UART device");
virtio_blk_init(&v->virtio_blk_dev);
Expand Down
4 changes: 1 addition & 3 deletions src/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,11 @@ void pci_dev_register(struct pci_dev *dev)
#define PCI_CONFIG_ADDR 0xCF8
#define PCI_CONFIG_DATA 0xCFC

void pci_init(struct pci *pci, struct bus *io_bus)
void pci_init(struct pci *pci)
{
dev_init(&pci->pci_addr_dev, PCI_CONFIG_ADDR, sizeof(uint32_t), pci,
pci_address_io);
dev_init(&pci->pci_bus_dev, PCI_CONFIG_DATA, sizeof(uint32_t), pci,
pci_data_io);
bus_init(&pci->pci_bus);
bus_register_dev(io_bus, &pci->pci_addr_dev);
bus_register_dev(io_bus, &pci->pci_bus_dev);
}
2 changes: 1 addition & 1 deletion src/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ void pci_dev_init(struct pci_dev *dev,
struct pci *pci,
struct bus *io_bus,
struct bus *mmio_bus);
void pci_init();
void pci_init(struct pci *pci);

0 comments on commit 5b23e25

Please sign in to comment.