Compare commits

...

2 Commits

Author SHA1 Message Date
6ce4864fd3 CE help format
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m58s
2026-03-10 22:16:29 +01:00
47ea9eb632 PCI IDE check if BAR is IO 2026-03-10 22:15:24 +01:00
2 changed files with 29 additions and 4 deletions

View File

@@ -334,6 +334,7 @@ static void help (struct context* context) {
cprintf (context, "terminfo\n");
cprintf (context, "cls\n");
cprintf (context, "mkvol <volume> <filesystem> <device>\n");
cprintf (context, "format <device> <filesystem>\n");
cprintf (context, "quit\n");
}

View File

@@ -54,6 +54,14 @@ static void ide_make_device (struct ide_probe probe) {
}
bool pci_ide_init (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);
if (pci_cmd != 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);
@@ -62,8 +70,16 @@ bool pci_ide_init (struct pci_info pci_info) {
uint16_t pcmd, pctrl, scmd, sctrl;
if ((progif & 0x01)) {
pcmd = (uint16_t)(pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR0) & 0xFFFC);
pctrl = (uint16_t)(pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR1) & 0xFFFC);
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");
return false;
}
pcmd = (uint16_t)(bar0 & 0xFFFC);
pctrl = (uint16_t)(bar1 & 0xFFFC);
if (pctrl)
pctrl += 2;
@@ -73,8 +89,16 @@ bool pci_ide_init (struct pci_info pci_info) {
}
if ((progif & 0x04)) {
scmd = (uint16_t)(pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR2) & 0xFFFC);
sctrl = (uint16_t)(pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR3) & 0xFFFC);
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");
return false;
}
scmd = (uint16_t)(bar2 & 0xFFFC);
sctrl = (uint16_t)(bar3 & 0xFFFC);
if (sctrl)
sctrl += 2;