feat: used linker to link pci drivers
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
#define MASK_BAR_IOSPACE 0xFFFFFFFC
|
||||
#define MASK_BAR_MEMSPACE 0xFFFFFFF0
|
||||
|
||||
const pci_driver pci_internal_secondary_bus = {
|
||||
const struct pci_driver pci_internal_secondary_bus = {
|
||||
.name = "pci-secondary-bus",
|
||||
.description = "A PCI bus connected to the primary bus",
|
||||
.order = 0,
|
||||
@@ -45,23 +45,16 @@ const pci_driver pci_internal_secondary_bus = {
|
||||
.initialize = NULL,
|
||||
};
|
||||
|
||||
const pci_driver *pci_drivers[MAX_PCI_DRIVERS];
|
||||
//const pci_driver *pci_drivers[MAX_PCI_DRIVERS];
|
||||
extern struct pci_driver __start_pci_drivers[];
|
||||
extern struct pci_driver __stop_pci_drivers[];
|
||||
#define NUM_DRIVERS ((size_t)(__stop_pci_drivers - __start_pci_drivers))
|
||||
#define DRIVER(i) ((__start_pci_drivers) + (i))
|
||||
int last_pci_device_index = 0;
|
||||
pci_device pci_devices[MAX_PCI_DEVICES];
|
||||
|
||||
void pci_check_bus(uint8_t bus);
|
||||
|
||||
uint32_t pci_register_driver(const pci_driver *pci_driver) {
|
||||
for (int i = 0; i < MAX_PCI_DRIVERS; ++i) {
|
||||
if (pci_drivers[i] != NULL) {
|
||||
continue;
|
||||
}
|
||||
pci_drivers[i] = pci_driver;
|
||||
return PCI_REGISTER_OK;
|
||||
}
|
||||
return PCI_REGISTER_ERR_FULL;
|
||||
}
|
||||
|
||||
uint32_t pci_config_address(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset) {
|
||||
return PCI_CONFIG_ENABLE
|
||||
| ((uint32_t) bus << PCI_CONFIG_SHIFT_BUS_NUMBER)
|
||||
@@ -141,23 +134,23 @@ void pci_pick_driver(pci_device *device) {
|
||||
}
|
||||
|
||||
// use normal drivers
|
||||
for (int i = 0; i < MAX_PCI_DRIVERS; ++i) {
|
||||
if (pci_drivers[i] == NULL) {
|
||||
for (int i = 0; i < NUM_DRIVERS; ++i) {
|
||||
// if (DRIVER(i) == NULL) {
|
||||
// continue;
|
||||
// }
|
||||
if (device->class != DRIVER(i)->pci_class) {
|
||||
continue;
|
||||
}
|
||||
if (device->class != pci_drivers[i]->pci_class) {
|
||||
if (DRIVER(i)->pci_use_subclass && device->subclass != DRIVER(i)->pci_subclass) {
|
||||
continue;
|
||||
}
|
||||
if (pci_drivers[i]->pci_use_subclass && device->subclass != pci_drivers[i]->pci_subclass) {
|
||||
if (!DRIVER(i)->validatable) {
|
||||
continue;
|
||||
}
|
||||
if (!pci_drivers[i]->validatable) {
|
||||
if (DRIVER(i)->validate(device) != PCI_VALIDATE_OK) {
|
||||
continue;
|
||||
}
|
||||
if (pci_drivers[i]->validate(device) != PCI_VALIDATE_OK) {
|
||||
continue;
|
||||
}
|
||||
device->pci_driver = pci_drivers[i];
|
||||
device->pci_driver = DRIVER(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user