feat: reworked driver pci setup

This commit is contained in:
2021-02-04 21:02:14 +01:00
parent 706147c123
commit dc8a0444f9
4 changed files with 149 additions and 75 deletions

View File

@@ -6,14 +6,39 @@
#include <types.h>
#include <kprint.h>
#include <drivers/pci.h>
#include <libc/stdbool.h>
const char* ide_pci_driver_name = "pci-ide";
void ide_handle_pci_device(u8 bus, u8 slot, u8 func) {
u8 ide_pci_validate(const pci_device *device);
u8 ide_pci_initialize(const pci_device *device);
const pci_driver ide_pci_driver = {
.name = "pci-ide",
.description = "Default PCI IDE Driver",
.order = 0xFF, // let other drivers precede if they can
.pci_use_subclass = true,
.pci_class = PCI_CLASS_MASS_STORAGE,
.pci_subclass = PCI_SUB_CLASS_IDE,
.validate = ide_pci_validate,
.initialize = ide_pci_initialize,
};
u8 ide_pci_validate(const pci_device *device) {
if (device->class != PCI_CLASS_MASS_STORAGE
|| device->subclass != PCI_SUB_CLASS_IDE) {
return PCI_VALIDATE_FAIL;
}
// todo other validations
return PCI_VALIDATE_OK;
}
u8 ide_pci_initialize(const pci_device *device) {
kprint("IDE registered");
// todo
return PCI_VALIDATE_OK;
}
void ide_register() {
pci_register_driver(PCI_CLASS_MASS_STORAGE, PCI_SUB_CLASS_IDE, PCI_FLAG_USE_SUBCLASS, ide_handle_pci_device, ide_pci_driver_name);
pci_register_driver(&ide_pci_driver);
}