Some basic framework for PCI(e) enumeration

This commit is contained in:
Mark
2020-01-27 17:53:57 +02:00
parent 7920c4dba1
commit 6a95990b68
6 changed files with 314 additions and 29 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
#pragma once
#include "sys/amd64/hw/pci/pci.h"
struct ahci_registers;
struct pci_device;
struct ahci_fis_reg_h2d {
uint8_t type;
@@ -26,7 +26,7 @@ struct ahci_fis_reg_h2d {
};
struct ahci_controller {
// pci_addr_t addr;
struct pci_device *pci_dev;
uintptr_t abar_phys;
struct ahci_registers *regs;
};
+8
View File
@@ -10,14 +10,22 @@
#define PCI_CONFIG_INFO 0x0C
#define PCI_CONFIG_BAR(n) (0x10 + (n) * 4)
#define PCI_CONFIG_SUBSYSTEM 0x2C
#define PCI_CONFIG_CAPABILITIES 0x34
#define PCI_CONFIG_IRQ 0x3C
#define PCI_CONFIG_BRIDGE 0x18
#define PCI_ID(vnd, dev) (((uint32_t) (vnd)) | ((uint32_t) (dev) << 16))
struct pci_device;
typedef void (*pci_driver_func_t)(struct pci_device *dev);
void pci_init(void);
void pci_add_root_bus(uint8_t n);
uint32_t pci_config_read_dword(struct pci_device *dev, uint16_t off);
void pci_add_class_driver(uint32_t full_class, pci_driver_func_t func);
// pcidb.c
const char *pci_class_string(uint16_t full_class);