2024-09-13 16:41:31 -05:00
|
|
|
.{memory, buffer} := @use("../../../libraries/stn/src/lib.hb")
|
2024-05-23 16:59:17 -05:00
|
|
|
|
2024-08-12 08:15:50 -05:00
|
|
|
serial_print := fn(ptr: ^u8): void {
|
|
|
|
letter := 0
|
|
|
|
loop if *ptr == 0 break else {
|
|
|
|
letter = *ptr
|
2024-09-01 16:29:42 -05:00
|
|
|
memory.outb(0xF803, letter)
|
2024-08-12 08:15:50 -05:00
|
|
|
ptr += 1
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
serial_println := fn(ptr: ^u8): void {
|
|
|
|
serial_print(ptr)
|
2024-09-01 16:29:42 -05:00
|
|
|
memory.outb(0xF803, 12)
|
|
|
|
memory.outb(0xF803, 13)
|
2024-08-12 08:15:50 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
main := fn(): int {
|
2024-08-12 08:21:31 -05:00
|
|
|
// This must be done first and foremost to prevent racing
|
|
|
|
a := buffer.create("XNumber\0")
|
2024-08-12 08:15:50 -05:00
|
|
|
serial_println("Starting Serial Driver.\0")
|
2024-08-12 08:21:31 -05:00
|
|
|
|
2024-08-19 13:13:58 -05:00
|
|
|
mem := memory.request_page(1)
|
|
|
|
|
|
|
|
loop {
|
2024-09-01 16:29:42 -05:00
|
|
|
ptr := @eca(int, 4, a, mem, 0x1000)
|
2024-08-19 13:13:58 -05:00
|
|
|
if ptr == 0 {
|
|
|
|
serial_println("No message\0")
|
|
|
|
}
|
|
|
|
if ptr > 0 {
|
|
|
|
serial_println("Yes message\0")
|
|
|
|
serial_println(mem)
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-12 08:15:50 -05:00
|
|
|
// Note that the first byte is reserved, pad accordingly.
|
|
|
|
b := buffer.search("XNumber\0")
|
2024-08-12 08:21:31 -05:00
|
|
|
|
2024-08-12 08:15:50 -05:00
|
|
|
if a == b {
|
|
|
|
serial_println("Stopping Serial Driver.\0")
|
|
|
|
}
|
2024-08-19 13:13:58 -05:00
|
|
|
|
2024-08-12 08:15:50 -05:00
|
|
|
return 0
|
2024-05-23 16:59:17 -05:00
|
|
|
}
|