1
0
Fork 0
forked from AbleOS/ableos

filling out the ide_select_drive function

This commit is contained in:
Able 2024-12-04 03:58:23 -06:00
parent 559f25bb4e
commit 36d50f6b38

View file

@ -16,6 +16,10 @@ main := fn(): int {
ATA_PRIMARY := @as(u8, @intcast(0x0)) ATA_PRIMARY := @as(u8, @intcast(0x0))
ATA_PRIMARY_IO := @as(u8, @intcast(0x1F0)) ATA_PRIMARY_IO := @as(u8, @intcast(0x1F0))
ATA_SECONDARY := @as(u8, @intcast(0x1))
ATA_SECONDARY_IO := @as(u8, @intcast(0x170))
ATA_REG_HDDEVSEL := @as(u8, @intcast(0x6)) ATA_REG_HDDEVSEL := @as(u8, @intcast(0x6))
ATA_MASTER := @as(u8, @intcast(0x0)) ATA_MASTER := @as(u8, @intcast(0x0))
@ -24,16 +28,16 @@ IDE := struct {}
ide_select_drive := fn(bus: u8, i: u8): void { ide_select_drive := fn(bus: u8, i: u8): void {
if bus == ATA_PRIMARY { if bus == ATA_PRIMARY {
if i == ATA_MASTER { if i == ATA_MASTER {
// BUG: Causes qemu to crash log.info("Primary ATA selected\0")
// memory.outb(ATA_PRIMARY_IO + ATA_REG_HDDEVSEL, 0xA0) memory.outb(ATA_PRIMARY_IO + ATA_REG_HDDEVSEL, 0xA0)
} else { } else {
// outportb(ATA_PRIMARY_IO + ATA_REG_HDDEVSEL, 0xB0); memory.outb(ATA_PRIMARY_IO + ATA_REG_HDDEVSEL, 0xB0)
} }
} else { } else {
if i == ATA_MASTER { if i == ATA_MASTER {
// outportb(ATA_SECONDARY_IO + ATA_REG_HDDEVSEL, 0xA0); memory.outb(ATA_SECONDARY_IO + ATA_REG_HDDEVSEL, 0xA0)
} else { } else {
// outportb(ATA_SECONDARY_IO + ATA_REG_HDDEVSEL, 0xB0) memory.outb(ATA_SECONDARY_IO + ATA_REG_HDDEVSEL, 0xB0)
} }
} }
} }
@ -41,6 +45,7 @@ ide_select_drive := fn(bus: u8, i: u8): void {
identify := fn(bus: u8, drive: u8): bool { identify := fn(bus: u8, drive: u8): bool {
io := 0 io := 0
// BUG: Causes qemu to crash
ide_select_drive(bus, drive) ide_select_drive(bus, drive)
if bus == ATA_PRIMARY { if bus == ATA_PRIMARY {
io = ATA_PRIMARY_IO io = ATA_PRIMARY_IO
@ -56,6 +61,7 @@ ata_probe := fn(): void {
ATA := struct { ATA := struct {
new := fn(): void { new := fn(): void {
ata_probe() log.info("Checking for ATA Drives.\0")
// ata_probe()
} }
} }