Compare commits
No commits in common. "6af68994d8acd79aaf7d779e89825d80f1ea7c60" and "e688fdf4f0a3c96c05e06e8add2fa915698de478" have entirely different histories.
6af68994d8
...
e688fdf4f0
|
@ -455,8 +455,7 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> {
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
com.args([
|
com.args([
|
||||||
"-bios", &ovmf_path.change_context(Error::OvmfFetch)?,
|
"-bios", &ovmf_path.change_context(Error::OvmfFetch)?,
|
||||||
//"-hda", "target/disk.img",
|
"-drive", "file=target/disk.img,format=raw",
|
||||||
"-drive", "file=target/disk.img,index=0,if=ide,format=raw",
|
|
||||||
"-device", "vmware-svga",
|
"-device", "vmware-svga",
|
||||||
// "-serial", "stdio",
|
// "-serial", "stdio",
|
||||||
"-m", "2G",
|
"-m", "2G",
|
||||||
|
|
|
@ -2,121 +2,73 @@
|
||||||
.{inb, outb} := memory
|
.{inb, outb} := memory
|
||||||
|
|
||||||
regs := @use("regs.hb");
|
regs := @use("regs.hb");
|
||||||
.{ATA_PRIMARY_IO, ATA_PRIMARY_DEVCTL, ATA_SECONDARY_DEVCTL, ATA_REG_STAT, ATA_SR_ERR, ATA_SR_BSY, ATA_SR_DF, ATA_SR_DRQ} := regs
|
.{ATA_PRIMARY_COMM_REGSTAT, ATA_PRIMARY_DRIVE_HEAD, ATA_PRIMARY_SECCOUNT, ATA_PRIMARY_LBA_LO, ATA_PRIMARY_LBA_MID, ATA_PRIMARY_LBA_HI, STAT_BSY} := regs
|
||||||
|
|
||||||
sloop := fn(i: u8): void {
|
|
||||||
// idx := 0xFFFFFFF
|
|
||||||
// loop {
|
|
||||||
// if idx == 0 {
|
|
||||||
// break
|
|
||||||
// } else {
|
|
||||||
// idx -= 1
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
sloop := fn(): void {
|
||||||
|
idx := 0xFFFFFFF
|
||||||
loop {
|
loop {
|
||||||
if i == 0 {
|
if idx == 0 {
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
a := inb(ATA_SECONDARY_DEVCTL)
|
idx -= 1
|
||||||
|
|
||||||
i -= 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// identify := fn(): u8 {
|
identify := fn(): u8 {
|
||||||
// a := inb(ATA_PRIMARY_COMM_REGSTAT)
|
a := inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
// outb(ATA_PRIMARY_DRIVE_HEAD, 0xA0)
|
outb(ATA_PRIMARY_DRIVE_HEAD, 0xA0)
|
||||||
// log.info("Primary drive head set.\0")
|
log.info("Primary drive head set.\0")
|
||||||
|
|
||||||
// a = inb(ATA_PRIMARY_COMM_REGSTAT)
|
a = inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
// outb(ATA_PRIMARY_SECCOUNT, 0)
|
outb(ATA_PRIMARY_SECCOUNT, 0)
|
||||||
// a = inb(ATA_PRIMARY_COMM_REGSTAT)
|
a = inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
// outb(ATA_PRIMARY_LBA_LO, 0)
|
outb(ATA_PRIMARY_LBA_LO, 0)
|
||||||
// a = inb(ATA_PRIMARY_COMM_REGSTAT)
|
a = inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
// outb(ATA_PRIMARY_LBA_MID, 0)
|
outb(ATA_PRIMARY_LBA_MID, 0)
|
||||||
// a = inb(ATA_PRIMARY_COMM_REGSTAT)
|
a = inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
// outb(ATA_PRIMARY_LBA_HI, 0)
|
outb(ATA_PRIMARY_LBA_HI, 0)
|
||||||
// a = inb(ATA_PRIMARY_COMM_REGSTAT)
|
a = inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
// outb(ATA_PRIMARY_COMM_REGSTAT, 0xEC)
|
outb(ATA_PRIMARY_COMM_REGSTAT, 0xEC)
|
||||||
// outb(ATA_PRIMARY_COMM_REGSTAT, 0xE7)
|
outb(ATA_PRIMARY_COMM_REGSTAT, 0xE7)
|
||||||
|
|
||||||
// status := inb(ATA_PRIMARY_COMM_REGSTAT)
|
status := inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
// log.info("Waiting for status.\0")
|
log.info("Waiting for status.\0")
|
||||||
// loop {
|
|
||||||
// if (status & STAT_BSY) == 0 {
|
|
||||||
// log.info("Status got.\0")
|
|
||||||
// break
|
|
||||||
// } else {
|
|
||||||
// sloop()
|
|
||||||
// }
|
|
||||||
// status = inb(ATA_PRIMARY_COMM_REGSTAT)
|
|
||||||
// }
|
|
||||||
// if status == 0 {
|
|
||||||
// log.error("No drive detected.\0")
|
|
||||||
|
|
||||||
// return 0
|
|
||||||
// }
|
|
||||||
// log.info("Status indicates presence of a drive. Polling while STAT_BSY... \0")
|
|
||||||
// loop {
|
|
||||||
// if (status & STAT_BSY) == 0 {
|
|
||||||
// log.info("Status got.\0")
|
|
||||||
// break
|
|
||||||
// } else {
|
|
||||||
// sloop()
|
|
||||||
// }
|
|
||||||
// status = inb(ATA_PRIMARY_COMM_REGSTAT)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// mid := inb(ATA_PRIMARY_LBA_MID)
|
|
||||||
// hi := inb(ATA_PRIMARY_LBA_HI)
|
|
||||||
|
|
||||||
// if (mid | hi) == 0 {
|
|
||||||
// log.error("The drive is not ATA. (Who knows what it is.)\0")
|
|
||||||
// return 0
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return 0
|
|
||||||
// }
|
|
||||||
|
|
||||||
drive_reset := fn(): void {
|
|
||||||
log.warn("Drive resetting.\0")
|
|
||||||
outb(ATA_PRIMARY_DEVCTL, 0x4)
|
|
||||||
sloop(4)
|
|
||||||
outb(ATA_PRIMARY_DEVCTL, 0x0)
|
|
||||||
}
|
|
||||||
|
|
||||||
poll := fn(): u8 {
|
|
||||||
sloop(4)
|
|
||||||
status := 0
|
|
||||||
// busy loop waiting for status
|
|
||||||
loop {
|
loop {
|
||||||
status = inb(ATA_PRIMARY_IO + ATA_REG_STAT)
|
if (status & STAT_BSY) == 0 {
|
||||||
if (status & ATA_SR_BSY) == 0 {
|
log.info("Status got.\0")
|
||||||
break
|
break
|
||||||
|
} else {
|
||||||
|
sloop()
|
||||||
}
|
}
|
||||||
|
status = inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
|
}
|
||||||
|
if status == 0 {
|
||||||
|
log.error("No drive detected.\0")
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
log.info("Status indicates presence of a drive. Polling while STAT_BSY... \0")
|
||||||
|
loop {
|
||||||
|
if (status & STAT_BSY) == 0 {
|
||||||
|
log.info("Status got.\0")
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
sloop()
|
||||||
|
}
|
||||||
|
status = inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
status = inb(ATA_PRIMARY_IO + ATA_REG_STAT)
|
mid := inb(ATA_PRIMARY_LBA_MID)
|
||||||
if (status & ATA_SR_DF) == 0 {
|
hi := inb(ATA_PRIMARY_LBA_HI)
|
||||||
log.error("ATA PRIMARY DRIVE FAULT\0")
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status & ATA_SR_ERR) == 0 {
|
if (mid | hi) == 0 {
|
||||||
log.error("ATA PRIMARY ERR\0")
|
log.error("The drive is not ATA. (Who knows what it is.)\0")
|
||||||
return 2
|
return 0
|
||||||
}
|
|
||||||
|
|
||||||
if (status & ATA_SR_DRQ) == 0 {
|
|
||||||
log.error("ATA PRIMARY DRQ\0")
|
|
||||||
return 3
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
// shuts down ableOS
|
// shuts down ableOS
|
||||||
// outb(0xF400, 0)
|
// outb(0xF400, 0)
|
||||||
|
@ -125,10 +77,7 @@ main := fn(): int {
|
||||||
b := inb(0x4700)
|
b := inb(0x4700)
|
||||||
|
|
||||||
// c := buffer.search("XNumber\0")
|
// c := buffer.search("XNumber\0")
|
||||||
// c := identify()
|
c := identify()
|
||||||
|
|
||||||
d := drive_reset()
|
|
||||||
e := poll()
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
|
@ -1,35 +1,23 @@
|
||||||
// $ATA_PRIMARY_DATA := @intcast(0x1F0)
|
$ATA_PRIMARY_DATA := @intcast(0x1F0)
|
||||||
// $ATA_PRIMARY_ERR := @intcast(0x1F1)
|
$ATA_PRIMARY_ERR := @intcast(0x1F1)
|
||||||
// $ATA_PRIMARY_SECCOUNT := @intcast(0x1F2)
|
$ATA_PRIMARY_SECCOUNT := @intcast(0x1F2)
|
||||||
// $ATA_PRIMARY_LBA_LO := @intcast(0x1F3)
|
$ATA_PRIMARY_LBA_LO := @intcast(0x1F3)
|
||||||
// $ATA_PRIMARY_LBA_MID := @intcast(0x1F4)
|
$ATA_PRIMARY_LBA_MID := @intcast(0x1F4)
|
||||||
// $ATA_PRIMARY_LBA_HI := @intcast(0x1F5)
|
$ATA_PRIMARY_LBA_HI := @intcast(0x1F5)
|
||||||
// $ATA_PRIMARY_DRIVE_HEAD := @intcast(0x1F6)
|
$ATA_PRIMARY_DRIVE_HEAD := @intcast(0x1F6)
|
||||||
// $ATA_PRIMARY_COMM_REGSTAT := @intcast(0x1F7)
|
$ATA_PRIMARY_COMM_REGSTAT := @intcast(0x1F7)
|
||||||
// $ATA_PRIMARY_ALTSTAT_DCR := @intcast(0x3F6)
|
$ATA_PRIMARY_ALTSTAT_DCR := @intcast(0x3F6)
|
||||||
|
|
||||||
$ATA_PRIMARY_IO := @intcast(0x1F0)
|
// Indicates an error occurred. Send a new command to clear it
|
||||||
|
STAT_ERR := 1 << 0
|
||||||
$ATA_PRIMARY_DEVCTL := @intcast(0x3F6)
|
// Set when the drive has PIO data to transfer, or is ready to accept PIO data.
|
||||||
$ATA_SECONDARY_DEVCTL := @intcast(0x3F6)
|
STAT_DRQ := 1 << 3
|
||||||
|
// Overlapped Mode Service Request.
|
||||||
$ATA_REG_STAT := @intcast(0x7)
|
STAT_SRV := 1 << 4
|
||||||
|
// Drive Fault Error (does not set ERR).
|
||||||
// // Indicates an error occurred. Send a new command to clear it
|
STAT_DF := 1 << 5
|
||||||
// STAT_ERR := 1 << 0
|
// Bit is clear when drive is spun down, or after an error. Set otherwise.
|
||||||
// // Set when the drive has PIO data to transfer, or is ready to accept PIO data.
|
STAT_RDY := 1 << 6
|
||||||
// STAT_DRQ := 1 << 3
|
// Indicates the drive is preparing to send/receive data (wait for it to clear).
|
||||||
// // Overlapped Mode Service Request.
|
// In case of 'hang' (it never clears), do a software reset.
|
||||||
// STAT_SRV := 1 << 4
|
STAT_BSY := 1 << 7
|
||||||
// // Drive Fault Error (does not set ERR).
|
|
||||||
// STAT_DF := 1 << 5
|
|
||||||
// // Bit is clear when drive is spun down, or after an error. Set otherwise.
|
|
||||||
// STAT_RDY := 1 << 6
|
|
||||||
// // Indicates the drive is preparing to send/receive data (wait for it to clear).
|
|
||||||
// // In case of 'hang' (it never clears), do a software reset.
|
|
||||||
// STAT_BSY := 1 << 7
|
|
||||||
|
|
||||||
$ATA_SR_BSY := 0x80
|
|
||||||
$ATA_SR_DF := 0x20
|
|
||||||
$ATA_SR_DRQ := 0x8
|
|
||||||
$ATA_SR_ERR := 0x1
|
|
|
@ -28,8 +28,8 @@ path = "boot:///render_example.hbf"
|
||||||
[boot.limine.ableos.modules.sunset_server]
|
[boot.limine.ableos.modules.sunset_server]
|
||||||
path = "boot:///sunset_server.hbf"
|
path = "boot:///sunset_server.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.ps2_mouse_driver]
|
[boot.limine.ableos.modules.ps2_mouse_driver]
|
||||||
# path = "boot:///ps2_mouse_driver.hbf"
|
path = "boot:///ps2_mouse_driver.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
||||||
# path = "boot:///ps2_keyboard_driver.hbf"
|
# path = "boot:///ps2_keyboard_driver.hbf"
|
||||||
|
|
Loading…
Reference in a new issue