Device IRQs WIP
This commit is contained in:
@@ -3,12 +3,15 @@
|
||||
#include <device/idedrv.h>
|
||||
#include <device/pci.h>
|
||||
#include <device/pci_info.h>
|
||||
#include <device/partitions.h>
|
||||
#include <devices.h>
|
||||
#include <libk/fieldsizeof.h>
|
||||
#include <libk/lengthof.h>
|
||||
#include <libk/printf.h>
|
||||
#include <libk/std.h>
|
||||
#include <sys/debug.h>
|
||||
#include <proc/proc.h>
|
||||
#include <proc/reschedule.h>
|
||||
|
||||
static atomic_int ide_counter = 0;
|
||||
|
||||
@@ -27,7 +30,7 @@ static const char* progif_msg[] = {
|
||||
"PCI native mode controller, supports both channels switched to ISA compatibility mode, supports bus mastering",
|
||||
};
|
||||
|
||||
static void ide_make_device (struct ide_probe probe) {
|
||||
static void ide_make_device (struct proc* proc, struct reschedule_ctx* rctx, struct ide_probe probe) {
|
||||
DEBUG ("Found IDE drive: io=%x ctrl=%x no=%u sector=%zu count=%zu\n", probe.io, probe.ctrl,
|
||||
probe.devno, probe.sector_size, probe.sector_count);
|
||||
|
||||
@@ -49,14 +52,16 @@ static void ide_make_device (struct ide_probe probe) {
|
||||
.io = probe.io,
|
||||
.ctrl = probe.ctrl,
|
||||
.devno = probe.devno,
|
||||
.primscnd = probe.primscnd,
|
||||
};
|
||||
device_create (device_key, ops, lengthof (ops), &idedrv_init, &idedrv_fini, &init);
|
||||
struct device* ide = device_create (device_key, ops, lengthof (ops), &idedrv_init, &idedrv_fini, &init, proc, rctx);
|
||||
device_probe_partitions (proc, rctx, ide);
|
||||
}
|
||||
|
||||
bool pci_ide_init (struct pci_info pci_info) {
|
||||
bool pci_ide_init (struct proc* proc, struct reschedule_ctx* rctx, struct pci_info pci_info) {
|
||||
uint16_t pci_cmd = pci_read16 (pci_info.bus, pci_info.slot, pci_info.func, PCI_COMMAND);
|
||||
|
||||
uint16_t new_cmd = pci_cmd | (1 << 0);
|
||||
uint16_t new_cmd = (pci_cmd | (1 << 0)) & ~(1 << 10);
|
||||
|
||||
if (pci_cmd != new_cmd) {
|
||||
pci_write16 (pci_info.bus, pci_info.slot, pci_info.func, PCI_COMMAND, new_cmd);
|
||||
@@ -116,11 +121,13 @@ bool pci_ide_init (struct pci_info pci_info) {
|
||||
if (cmd == 0)
|
||||
continue;
|
||||
|
||||
probe.primscnd = i + 1;
|
||||
|
||||
for (size_t dev = 0; dev < 2; dev++) {
|
||||
ide_probe (cmd, ctrl, dev, &probe);
|
||||
|
||||
if ((probe.flags & IDE_PROBE_AVAIL))
|
||||
ide_make_device (probe);
|
||||
ide_make_device (proc, rctx, probe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user