forked from koniifer/ableos
let's just use strings for now
This commit is contained in:
parent
1f4fce0f66
commit
a8d38e04c4
|
@ -13,7 +13,7 @@ use {
|
|||
|
||||
pub fn handler(vm: &mut Vm) {
|
||||
let ecall_number = vm.registers[2].cast::<u64>();
|
||||
log::info!("eca called :pensive:");
|
||||
// log::info!("eca called :pensive:");
|
||||
// debug!("Ecall number {:?}", ecall_number);
|
||||
//info!("Register dump: {:?}", vm.registers);
|
||||
|
||||
|
|
|
@ -17,14 +17,32 @@ release_page := fn(ptr: ^u8, page_count: u8): void {
|
|||
return @eca(void, 3, 2, msg, 12)
|
||||
}
|
||||
|
||||
// outb := fn(addr: u16, value: u8): void {
|
||||
// msg := [u8; 5].(1, 0, @as(u8, addr & 0xFF), @as(u8, addr >> 8 & 0xFF), value)
|
||||
// return @eca(void, 3, 3, &msg, 5)
|
||||
// }
|
||||
|
||||
// inb := fn(addr: u16): u8 {
|
||||
// msg := [u8; 4].(0, 0, @as(u8, addr & 0xFF), @as(u8, addr >> 8 & 0xFF))
|
||||
// return @eca(u8, 3, 3, &msg, 4)
|
||||
// }
|
||||
|
||||
outb := fn(addr: u16, value: u8): void {
|
||||
msg := [u8; 5].(1, 0, @as(u8, addr & 0xFF), @as(u8, addr >> 8 & 0xFF), value)
|
||||
return @eca(void, 3, 3, &msg, 5)
|
||||
msg := "\0\0\0\0\0";
|
||||
*@as(^u8, msg) = @as(u8, 1);
|
||||
*@as(^u8, msg + 1) = @as(u8, 0);
|
||||
*@as(^u16, @bitcast(msg + 2)) = addr;
|
||||
*@as(^u8, msg + 4) = value
|
||||
@eca(void, 3, 3, msg, 5)
|
||||
return
|
||||
}
|
||||
|
||||
inb := fn(addr: u16): u8 {
|
||||
msg := [u8; 4].(0, 0, @as(u8, addr & 0xFF), @as(u8, addr >> 8 & 0xFF))
|
||||
return @eca(u8, 3, 3, &msg, 4)
|
||||
msg := "\0\0\0\0";
|
||||
*@as(^u8, msg) = @as(u8, 0);
|
||||
*@as(^u8, msg + 1) = @as(u8, 0);
|
||||
*@as(^u16, @bitcast(msg + 2)) = addr
|
||||
return @eca(u8, 3, 3, msg, 4)
|
||||
}
|
||||
|
||||
outl := fn(addr: u16, value: u32): void {
|
||||
|
|
|
@ -6,31 +6,28 @@ send_byte := fn(byte: u8): u8 {
|
|||
}
|
||||
|
||||
main := fn(): int {
|
||||
memory.outb(96, 238)
|
||||
// memory.inb(96)
|
||||
|
||||
// send_byte(238)
|
||||
// log.info("PS/2 Driver Loaded\0")
|
||||
// if send_byte(238) == 238 {
|
||||
// log.info("PS/2 Keyboard Echoed\0")
|
||||
// }
|
||||
// a := 0
|
||||
// a += 1
|
||||
// if send_byte(244) == 250 {
|
||||
// log.info("Enabled scanning\0")
|
||||
// }
|
||||
// buf := buffer.create("XKeyboard\0")
|
||||
// ptr := memory.request_page(1)
|
||||
// prev_input := 250
|
||||
// loop {
|
||||
// input := memory.inb(96)
|
||||
// if input == prev_input {
|
||||
// continue
|
||||
// }
|
||||
// prev_input = input
|
||||
// keycode_str := string.display_int(input, ptr)
|
||||
// log.info(string.display_int(input, ptr))
|
||||
// buffer.send_message(keycode_str, buf)
|
||||
// }
|
||||
send_byte(238)
|
||||
log.info("PS/2 Driver Loaded\0")
|
||||
if send_byte(238) == 238 {
|
||||
log.info("PS/2 Keyboard Echoed\0")
|
||||
}
|
||||
a := 0
|
||||
a += 1
|
||||
if send_byte(244) == 250 {
|
||||
log.info("Enabled scanning\0")
|
||||
}
|
||||
buf := buffer.create("XKeyboard\0")
|
||||
ptr := memory.request_page(1)
|
||||
prev_input := 250
|
||||
loop {
|
||||
input := memory.inb(96)
|
||||
if input == prev_input {
|
||||
continue
|
||||
}
|
||||
prev_input = input
|
||||
keycode_str := string.display_int(input, ptr)
|
||||
log.info(string.display_int(input, ptr))
|
||||
buffer.send_message(keycode_str, buf)
|
||||
}
|
||||
return 0
|
||||
}
|
Loading…
Reference in a new issue