swissChili | 5fe85a1 | 2021-05-31 08:10:27 -0700 | [diff] [blame] | 1 | #include <dri/ide/ide.h> |
| 2 | #include <task.h> |
| 3 | #include <alloc.h> |
swissChili | 1b83922 | 2021-06-03 13:54:40 -0700 | [diff] [blame] | 4 | #include <log.h> |
swissChili | 5fe85a1 | 2021-05-31 08:10:27 -0700 | [diff] [blame] | 5 | |
| 6 | struct ide_thread_data |
| 7 | { |
| 8 | struct pci_device dev; |
| 9 | uchar bus, slot, func; |
| 10 | }; |
| 11 | |
| 12 | bool ide_supports(struct pci_device *dev) |
| 13 | { |
| 14 | return dev->class == 1 && dev->subclass == 1; |
| 15 | } |
| 16 | |
| 17 | void ide_thread(struct ide_thread_data *data) |
| 18 | { |
| 19 | kprintf("IDE driver thread starting: device=0x%x\n", data->dev.device_id); |
| 20 | } |
| 21 | |
| 22 | void ide_init(struct pci_device dev, uchar bus, uchar slot, uchar func) |
| 23 | { |
| 24 | struct ide_thread_data *data = malloc(sizeof(struct ide_thread_data)); |
| 25 | data->dev = dev; |
| 26 | data->bus = bus; |
| 27 | data->slot = slot; |
| 28 | data->func = func; |
| 29 | |
swissChili | 1b83922 | 2021-06-03 13:54:40 -0700 | [diff] [blame] | 30 | spawn_thread(TASK_FUNCTION(ide_thread), data); |
swissChili | 5fe85a1 | 2021-05-31 08:10:27 -0700 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | void ide_register() |
| 34 | { |
| 35 | struct pci_device_driver dri = |
| 36 | { |
| 37 | .supports = ide_supports, |
| 38 | .init = ide_init, |
| 39 | .generic_name = "IDE Controller", |
| 40 | }; |
| 41 | |
| 42 | pci_register_device_driver(dri); |
| 43 | } |