ableos/sysdata/programs/a_serial_driver/src/main.hb
koniifer f7b970eaf0 hexadecimal support!!
remove fb_driver_stresstest, move examples back to fb_driver, update hblang, update Cargo.lock
2024-09-01 22:29:42 +01:00

48 lines
908 B
Plaintext

stn := @use("../../../libraries/stn/src/lib.hb");
.{log, string, memory, buffer} := stn
serial_print := fn(ptr: ^u8): void {
letter := 0
loop if *ptr == 0 break else {
letter = *ptr
memory.outb(0xF803, letter)
ptr += 1
}
return
}
serial_println := fn(ptr: ^u8): void {
serial_print(ptr)
memory.outb(0xF803, 12)
memory.outb(0xF803, 13)
return
}
main := fn(): int {
// This must be done first and foremost to prevent racing
a := buffer.create("XNumber\0")
serial_println("Starting Serial Driver.\0")
mem := memory.request_page(1)
loop {
ptr := @eca(int, 4, a, mem, 0x1000)
if ptr == 0 {
serial_println("No message\0")
}
if ptr > 0 {
serial_println("Yes message\0")
serial_println(mem)
break
}
}
// Note that the first byte is reserved, pad accordingly.
b := buffer.search("XNumber\0")
if a == b {
serial_println("Stopping Serial Driver.\0")
}
return 0
}