feat: rank drivers at compile time
This commit is contained in:
@@ -671,10 +671,9 @@ uint8_t ide_access(uint8_t direction, uint8_t drive, uint32_t lba, uint8_t numse
|
||||
return result;
|
||||
}
|
||||
|
||||
PCI_DRIVER(
|
||||
PCI_DRIVER(900) = {
|
||||
.name = "pci-ide",
|
||||
.description = "Default PCI IDE Driver",
|
||||
.rank = 10000, // let other block_dev_drivers precede if they can
|
||||
.validatable = true,
|
||||
.initialisable = true,
|
||||
.match.class = PCI_CLASS_MASS_STORAGE,
|
||||
@@ -683,5 +682,5 @@ PCI_DRIVER(
|
||||
.mask.subclass = true,
|
||||
.validate = ide_pci_validate,
|
||||
.initialize = ide_pci_initialize,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#ifdef ENABLE_PCIPP
|
||||
|
||||
#include <drivers/pci_devices.h>
|
||||
#include <libc/sort.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -192,21 +191,6 @@ void pci_check_bus(uint8_t bus) {
|
||||
}
|
||||
}
|
||||
|
||||
int pci_driver_compare(const void* a, const void* b) {
|
||||
int rank_a = ((struct pci_driver *) a)->rank;
|
||||
int rank_b = ((struct pci_driver *) b)->rank;
|
||||
if (rank_a > rank_b) {
|
||||
return 1;
|
||||
} else if (rank_a < rank_b) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pci_sort_drivers() {
|
||||
qsort(DRIVER(0), NUM_DRIVERS, sizeof(struct pci_driver), pci_driver_compare);
|
||||
}
|
||||
|
||||
void pci_scan() {
|
||||
if (last_pci_device_index != 0) {
|
||||
k_panics("Can only scan once!");
|
||||
@@ -385,16 +369,15 @@ void pci_init_bar(pci_device *device, uint8_t bar_index) {
|
||||
}
|
||||
|
||||
// internal drivers
|
||||
PCI_DRIVER(
|
||||
PCI_DRIVER(0) = {
|
||||
.name = "pci-secondary-bus",
|
||||
.description = "A PCI bus connected to the primary bus",
|
||||
.rank = 0, // internal driver for PCI bus
|
||||
.match.class = PCI_CLASS_BRIDGE,
|
||||
.match.subclass = PCI_SUB_CLASS_PCI_PCI_BRIDGE_4,
|
||||
.mask.class = true,
|
||||
.mask.subclass = true,
|
||||
.direct_use = true,
|
||||
.use = pci_secondary_bus_use,
|
||||
);
|
||||
};
|
||||
|
||||
// todo https://wiki.osdev.org/Universal_Serial_Bus if i dare
|
||||
@@ -96,7 +96,6 @@ typedef uint8_t (*pci_driver_initialize)(pci_device *);
|
||||
struct pci_driver {
|
||||
const char *name;
|
||||
const char *description;
|
||||
uint16_t rank;
|
||||
struct {
|
||||
uint8_t class;
|
||||
uint8_t subclass;
|
||||
@@ -121,7 +120,7 @@ struct pci_driver {
|
||||
pci_driver_initialize initialize;
|
||||
} __attribute__((__aligned__(STRUCT_ALIGNMENT)));
|
||||
|
||||
#define PCI_DRIVER(data...) GENERIC_DRIVER(pci_driver, data)
|
||||
#define PCI_DRIVER(order) GENERIC_DRIVER(pci_driver, order)
|
||||
|
||||
typedef struct {
|
||||
uint32_t address;
|
||||
@@ -223,8 +222,6 @@ void pci_pretty_print();
|
||||
|
||||
#endif
|
||||
|
||||
void pci_sort_drivers();
|
||||
|
||||
void pci_init_drivers();
|
||||
|
||||
void pci_scan();
|
||||
|
||||
Reference in New Issue
Block a user