Add ATA PIO IRQ handler, documentation
Still WIP, doesn't look like IRQ handler works yet.
diff --git a/src/kernel/dri/ide/ide.c b/src/kernel/dri/ide/ide.c
index 0025970..de4144c 100644
--- a/src/kernel/dri/ide/ide.c
+++ b/src/kernel/dri/ide/ide.c
@@ -1,59 +1,65 @@
-#include <dri/ide/ide.h>
-#include <task.h>
#include <alloc.h>
+#include <dri/ata_pio/ata_pio.h>
+#include <dri/ide/ide.h>
#include <log.h>
+#include <task.h>
struct ide_thread_data
{
- struct pci_device dev;
- uchar bus, slot, func;
+ struct pci_device dev;
+ uchar bus, slot, func;
};
bool ide_supports(struct pci_device *dev)
{
- return dev->class == 1 && dev->subclass == 1;
+ return dev->class == 1 && dev->subclass == 1;
}
void ide_print_device(struct ide_device *dev)
{
- kprintf(INFO "<ide-device dma=%b>", dev->supports_dma);
+ kprintf(INFO "<ide-device dma=%b>\n", dev->supports_dma);
}
void ide_thread(struct ide_thread_data *data)
{
- kprintf(DEBUG "IDE driver thread starting: device=0x%x\n", data->dev.device_id);
+ struct ide_device dev;
- struct ide_device dev;
+ uchar p = data->dev.prog_if;
+ dev.channel_mode[0] = p & 1;
+ dev.channel_mode_modifiable[0] = p & (1 << 1);
+ dev.channel_mode[1] = p & (1 << 2);
+ dev.channel_mode_modifiable[1] = p & (1 << 3);
+ dev.supports_dma = p & (1 << 7);
- uchar p = data->dev.prog_if;
- dev.channel_mode[0] = p & 1;
- dev.channel_mode_modifiable[0] = p & (1 << 1);
- dev.channel_mode[1] = p & (1 << 2);
- dev.channel_mode_modifiable[1] = p & (1 << 3);
- dev.supports_dma = p & (1 << 7);
+ ide_print_device(&dev);
- ide_print_device(&dev);
+ // TODO: pass ATA PIO driver information about the IDE device (i.e. what
+ // ports to use)
+ init_ata_pio();
+
+ kprintf(OKAY "Set up ATA PIO\n");
+
+ free(data);
}
void ide_init(struct pci_device dev, uchar bus, uchar slot, uchar func)
{
- struct ide_thread_data *data = malloc(sizeof(struct ide_thread_data));
- data->dev = dev;
- data->bus = bus;
- data->slot = slot;
- data->func = func;
+ struct ide_thread_data *data = malloc(sizeof(struct ide_thread_data));
+ data->dev = dev;
+ data->bus = bus;
+ data->slot = slot;
+ data->func = func;
- spawn_thread(TASK_FUNCTION(ide_thread), data);
+ ide_thread(data);
}
void ide_register()
{
- struct pci_device_driver dri =
- {
- .supports = ide_supports,
- .init = ide_init,
- .generic_name = "IDE Controller",
- };
+ struct pci_device_driver dri = {
+ .supports = ide_supports,
+ .init = ide_init,
+ .generic_name = "IDE Controller",
+ };
- pci_register_device_driver(dri);
+ pci_register_device_driver(dri);
}