feat: reformatted driver code and linkage. Some optimizations
This commit is contained in:
@@ -46,10 +46,10 @@ const struct pci_driver pci_internal_secondary_bus = {
|
||||
};
|
||||
|
||||
//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))
|
||||
extern struct pci_driver __start_pci_driver[];
|
||||
extern struct pci_driver __stop_pci_driver[];
|
||||
#define NUM_DRIVERS ((size_t)(__stop_pci_driver - __start_pci_driver))
|
||||
#define DRIVER(i) ((__start_pci_driver) + (i))
|
||||
int last_pci_device_index = 0;
|
||||
pci_device pci_devices[MAX_PCI_DEVICES];
|
||||
|
||||
@@ -126,18 +126,20 @@ uint8_t pci_get_header_type(uint8_t bus, uint8_t slot, uint8_t func) {
|
||||
void pci_pick_driver(pci_device *device) {
|
||||
// check special drivers
|
||||
// PCI Secondary bus
|
||||
if (device->class == pci_internal_secondary_bus.pci_class && device->subclass == pci_internal_secondary_bus.pci_subclass) {
|
||||
uint8_t secondary_bus = pci_config_read_byte(device->bus, device->slot, device->func, PCI_CONFIG_SECONDARY_BUS_NUMBER);
|
||||
if (device->class == pci_internal_secondary_bus.pci_class &&
|
||||
device->subclass == pci_internal_secondary_bus.pci_subclass) {
|
||||
uint8_t secondary_bus = pci_config_read_byte(device->bus, device->slot, device->func,
|
||||
PCI_CONFIG_SECONDARY_BUS_NUMBER);
|
||||
device->pci_driver = &pci_internal_secondary_bus;
|
||||
pci_check_bus(secondary_bus);
|
||||
return;
|
||||
}
|
||||
|
||||
// use normal drivers
|
||||
for (int i = 0; i < NUM_DRIVERS; ++i) {
|
||||
// if (DRIVER(i) == NULL) {
|
||||
// continue;
|
||||
// }
|
||||
for (size_t i = 0; i < NUM_DRIVERS; ++i) {
|
||||
if (DRIVER(i) == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (device->class != DRIVER(i)->pci_class) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user