Detect ATA driver via PCI

This commit is contained in:
2025-11-18 23:28:45 +01:00
parent 88f9d0e3d4
commit ecfe1a7eae
8 changed files with 58 additions and 68 deletions

View File

@ -106,67 +106,6 @@ uint64_t ata_probesize_bytes(uint16_t iobase, uint16_t ctrlbase, int devno) {
}
}
void ata_probe(void) {
uint64_t probesize;
probesize = ata_probesize_bytes(0x1F0, 0x3F6, ATA_MASTER);
if (probesize > 0) {
char hs[20];
LOG("ata", "found ATA primary bus master, size = %s\n", human_size(probesize, hs, sizeof(hs)));
AtaSdInitExtra extra = {
.devno = ATA_MASTER,
.capacity = probesize,
.iobase = 0x1F0,
.ctrlbase = 0x3F6,
};
storedev_create(STOREDEV_ATASD, "atasd0m", (void *)&extra);
}
probesize = ata_probesize_bytes(0x1F0, 0x3F6, ATA_SLAVE);
if (probesize > 0) {
char hs[20];
LOG("ata", "found ATA primary bus slave, size = %s\n", human_size(probesize, hs, sizeof(hs)));
AtaSdInitExtra extra = {
.devno = ATA_SLAVE,
.capacity = probesize,
.iobase = 0x1F0,
.ctrlbase = 0x3F6,
};
storedev_create(STOREDEV_ATASD, "atasd0s", (void *)&extra);
}
probesize = ata_probesize_bytes(0x170, 0x376, ATA_MASTER);
if (probesize > 0) {
char hs[20];
LOG("ata", "found ATA secondary bus master, size = %s\n", human_size(probesize, hs, sizeof(hs)));
AtaSdInitExtra extra = {
.devno = ATA_MASTER,
.capacity = probesize,
.iobase = 0x170,
.ctrlbase = 0x376,
};
storedev_create(STOREDEV_ATASD, "atasd1m", (void *)&extra);
}
probesize = ata_probesize_bytes(0x170, 0x376, ATA_SLAVE);
if (probesize > 0) {
char hs[20];
LOG("ata", "found ATA secondary bus slave, size = %s\n", human_size(probesize, hs, sizeof(hs)));
AtaSdInitExtra extra = {
.devno = ATA_SLAVE,
.capacity = probesize,
.iobase = 0x170,
.ctrlbase = 0x376,
};
storedev_create(STOREDEV_ATASD, "atasd1s", (void *)&extra);
}
}
void ata_setup(uint16_t iobase, uint16_t ctrlbase, int devno, uint16_t sectors, uint64_t lba) {
io_out8(ctrlbase, 0x02);