Change formatting rules
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 2m7s
Build documentation / build-and-deploy (push) Successful in 39s

This commit is contained in:
2026-04-24 01:54:48 +02:00
parent 34f7809a2d
commit c8fb575bdd
208 changed files with 6310 additions and 6339 deletions

View File

@@ -32,13 +32,13 @@ 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 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);
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);
char device_key[fieldsizeof (struct device, key)];
snprintf (device_key, sizeof (device_key), "ide%d", ide_counter++);
char device_key[fieldsizeof(struct device, key)];
snprintf(device_key, sizeof(device_key), "ide%d", ide_counter++);
device_op_func_t ops[] = {
[XDRV_GET_SIZE] = &idedrv_get_size,
@@ -60,33 +60,33 @@ static void ide_make_device (struct proc* proc, struct reschedule_ctx* rctx,
.irqs_support = probe.irqs_support,
};
struct device* ide = device_create (DEVICE_TYPE_DRIVE, device_key, ops, lengthof (ops),
&idedrv_init, &idedrv_fini, &init, proc, rctx);
device_probe_partitions (proc, rctx, ide);
struct device* ide = device_create(DEVICE_TYPE_DRIVE, device_key, ops, lengthof(ops),
&idedrv_init, &idedrv_fini, &init, proc, rctx);
device_probe_partitions(proc, rctx, ide);
}
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);
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) | (1 << 2)) & ~(1 << 10);
if (pci_cmd != new_cmd) {
pci_write16 (pci_info.bus, pci_info.slot, pci_info.func, PCI_COMMAND, new_cmd);
pci_write16(pci_info.bus, pci_info.slot, pci_info.func, PCI_COMMAND, new_cmd);
}
struct ide_probe probe;
uint8_t progif = pci_read8 (pci_info.bus, pci_info.slot, pci_info.func, PCI_PROG_IF);
DEBUG ("progif: %s\n", progif_msg[progif]);
uint8_t progif = pci_read8(pci_info.bus, pci_info.slot, pci_info.func, PCI_PROG_IF);
DEBUG("progif: %s\n", progif_msg[progif]);
uint16_t pcmd, pctrl, scmd, sctrl;
if ((progif & 0x01)) {
uint32_t bar0 = pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR0);
uint32_t bar1 = pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR1);
uint32_t bar0 = pci_read32(pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR0);
uint32_t bar1 = pci_read32(pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR1);
if (!(bar0 & PCI_BAR_IO) || !(bar1 & PCI_BAR_IO)) {
DEBUG ("Non IO BARs not supported\n");
DEBUG("Non IO BARs not supported\n");
return false;
}
@@ -101,11 +101,11 @@ bool pci_ide_init (struct proc* proc, struct reschedule_ctx* rctx, struct pci_in
}
if ((progif & 0x04)) {
uint32_t bar2 = pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR2);
uint32_t bar3 = pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR3);
uint32_t bar2 = pci_read32(pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR2);
uint32_t bar3 = pci_read32(pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR3);
if (!(bar2 & PCI_BAR_IO) || !(bar3 & PCI_BAR_IO)) {
DEBUG ("Non IO BARs not supported\n");
DEBUG("Non IO BARs not supported\n");
return false;
}
@@ -126,28 +126,28 @@ bool pci_ide_init (struct proc* proc, struct reschedule_ctx* rctx, struct pci_in
} else {
irqs_support = true;
if (!pci_msi_init (pci_info.bus, pci_info.slot, pci_info.func, INTR_IDE_DRIVE_PRIM,
thiscpu->lapic_id)) {
ioapic_route_irq (INTR_IDE_DRIVE_PRIM, 14, 0, thiscpu->lapic_id);
ioapic_route_irq (INTR_IDE_DRIVE_SCND, 15, 0, thiscpu->lapic_id);
DEBUG ("Fallback to IOAPIC interrupt routing\n");
if (!pci_msi_init(pci_info.bus, pci_info.slot, pci_info.func, INTR_IDE_DRIVE_PRIM,
thiscpu->lapic_id)) {
ioapic_route_irq(INTR_IDE_DRIVE_PRIM, 14, 0, thiscpu->lapic_id);
ioapic_route_irq(INTR_IDE_DRIVE_SCND, 15, 0, thiscpu->lapic_id);
DEBUG("Fallback to IOAPIC interrupt routing\n");
}
}
DEBUG ("pcmd=%x, pctrl=%x\n", pcmd, pctrl);
DEBUG ("scmd=%x, sctrl=%x\n", scmd, sctrl);
DEBUG ("IRQ support=%d\n", irqs_support);
DEBUG("pcmd=%x, pctrl=%x\n", pcmd, pctrl);
DEBUG("scmd=%x, sctrl=%x\n", scmd, sctrl);
DEBUG("IRQ support=%d\n", irqs_support);
uint16_t channels[2][3] = {{pcmd, pctrl, INTR_IDE_DRIVE_PRIM},
{scmd, sctrl, INTR_IDE_DRIVE_SCND}};
for (size_t i = 0; i < lengthof (channels); i++) {
for (size_t i = 0; i < lengthof(channels); i++) {
uint16_t cmd = channels[i][0];
uint16_t ctrl = channels[i][1];
uint8_t irq = channels[i][2];
for (size_t dev = 0; dev < 2; dev++) {
ide_probe (cmd, ctrl, dev, &probe);
ide_probe(cmd, ctrl, dev, &probe);
probe.ctrl = ctrl;
probe.io = cmd;
@@ -155,7 +155,7 @@ bool pci_ide_init (struct proc* proc, struct reschedule_ctx* rctx, struct pci_in
probe.irqs_support = irqs_support;
if ((probe.flags & IDE_PROBE_AVAIL))
ide_make_device (proc, rctx, probe);
ide_make_device(proc, rctx, probe);
}
}