feat: reformatted driver code and linkage. Some optimizations
This commit is contained in:
@@ -322,34 +322,6 @@ unsigned char ide_print_error(unsigned int drive, unsigned char err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
uint8_t ide_pci_validate(const pci_device *device);
|
||||
|
||||
uint8_t ide_pci_initialize(pci_device *device);
|
||||
|
||||
PCI_DRIVER(
|
||||
.name = "pci-ide",
|
||||
.description = "Default PCI IDE Driver",
|
||||
.order = 0xFF, // let other block_dev_drivers precede if they can
|
||||
.pci_use_subclass = true,
|
||||
.validatable = true,
|
||||
.initialisable = true,
|
||||
.pci_class = PCI_CLASS_MASS_STORAGE,
|
||||
.pci_subclass = PCI_SUB_CLASS_IDE,
|
||||
|
||||
.validate = ide_pci_validate,
|
||||
.initialize = ide_pci_initialize,
|
||||
);
|
||||
|
||||
uint8_t ide_pci_validate(const pci_device *device) {
|
||||
if (device->class != PCI_CLASS_MASS_STORAGE
|
||||
|| device->subclass != PCI_SUB_CLASS_IDE
|
||||
|| (device->programInterface != 0x8A && device->programInterface != 0x80)) {
|
||||
return PCI_VALIDATE_FAIL;
|
||||
}
|
||||
// todo other validations
|
||||
return PCI_VALIDATE_OK;
|
||||
}
|
||||
|
||||
void ide_fix_bar(bar_info *bar, uint32_t default_address, uint32_t size) {
|
||||
if (bar->address == 0x0) {
|
||||
// no need to actually write ti back
|
||||
@@ -365,6 +337,7 @@ bool ide_pci_init_channels(pci_device *device) {
|
||||
pci_config_write_byte(device->bus, device->slot, device->func, PCI_CONFIG_INTERRUPT_LINE, 0xFE);
|
||||
if (pci_config_read_byte(device->bus, device->slot, device->func, PCI_CONFIG_INTERRUPT_LINE) == 0xFE) {
|
||||
#ifdef IDE_ENABLE_INTERRUPT
|
||||
#error "Interrupt not supported"
|
||||
k_panics("NOT SUPPORTED");
|
||||
#else
|
||||
pci_config_write_byte(device->bus, device->slot, device->func, PCI_CONFIG_INTERRUPT_LINE,
|
||||
@@ -399,7 +372,8 @@ bool ide_pci_init_channels(pci_device *device) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t ide_block_dev_access(const block_device *device, uint8_t direction, uint32_t lba, uint8_t sectors, void *target) {
|
||||
uint8_t
|
||||
ide_block_dev_access(const block_device *device, uint8_t direction, uint32_t lba, uint8_t sectors, void *target) {
|
||||
ide_block_device_info *info = device->device_info;
|
||||
uint8_t result = ide_access(direction, info->device_number, lba, sectors, target);
|
||||
if (result != 0) {
|
||||
@@ -436,7 +410,17 @@ void ide_register_block_devices() {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ide_pci_initialize(pci_device *device) {
|
||||
uint8_t used ide_pci_validate(const pci_device *device) {
|
||||
if (device->class != PCI_CLASS_MASS_STORAGE
|
||||
|| device->subclass != PCI_SUB_CLASS_IDE
|
||||
|| (device->programInterface != 0x8A && device->programInterface != 0x80)) {
|
||||
return PCI_VALIDATE_FAIL;
|
||||
}
|
||||
// todo other validations
|
||||
return PCI_VALIDATE_OK;
|
||||
}
|
||||
|
||||
uint8_t used ide_pci_initialize(pci_device *device) {
|
||||
|
||||
if (!ide_pci_init_channels(device)) {
|
||||
return PCI_INIT_FAIL;
|
||||
@@ -686,3 +670,18 @@ uint8_t ide_access(uint8_t direction, uint8_t drive, uint32_t lba, uint8_t numse
|
||||
mutex_release(ide_lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
PCI_DRIVER(
|
||||
.name = "pci-ide",
|
||||
.description = "Default PCI IDE Driver",
|
||||
.order = 0xFF, // let other block_dev_drivers precede if they can
|
||||
.pci_use_subclass = true,
|
||||
.validatable = true,
|
||||
.initialisable = true,
|
||||
.pci_class = PCI_CLASS_MASS_STORAGE,
|
||||
.pci_subclass = PCI_SUB_CLASS_IDE,
|
||||
|
||||
.validate = ide_pci_validate,
|
||||
.initialize = ide_pci_initialize,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user