1
0
Fork 0
forked from AbleOS/ableos
ableos/sysdata/libraries/stn/src/memory.hb

64 lines
1.5 KiB
Plaintext
Raw Normal View History

2024-07-07 08:35:07 -05:00
request_page := fn(page_count: u8): ^u8 {
2024-07-19 08:53:45 -05:00
msg := "\{00}\{01}xxxxxxxx\0"
msg_page_count := msg + 1;
*msg_page_count = page_count
return @eca(^u8, 3, 2, msg, 12)
2024-07-07 08:35:07 -05:00
}
release_page := fn(ptr: ^u8, page_count: u8): void {
2024-07-19 08:53:45 -05:00
msg := "\{01}\{00}xxxxxxxx\0"
2024-07-07 08:35:07 -05:00
2024-07-19 08:53:45 -05:00
msg_page_count := msg + 1;
*msg_page_count = page_count
2024-07-07 08:35:07 -05:00
2024-07-19 08:53:45 -05:00
msg_ptr := @as(^^u8, @bitcast(msg + 2));
*msg_ptr = ptr
return @eca(void, 3, 2, msg, 12)
2024-07-23 19:37:43 -05:00
}
2024-09-16 14:45:19 -05:00
// 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 {
2024-09-16 14:45:19 -05:00
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 {
2024-09-16 14:45:19 -05:00
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 {
msg := "\0\0\0\0\0\0\0\0";
2024-09-13 16:41:31 -05:00
*@as(^u8, msg) = @as(u8, 1);
*@as(^u8, msg + 1) = @as(u8, 2);
*@as(^u16, @bitcast(msg + 2)) = addr;
*@as(^u32, @bitcast(msg + 4)) = value
@eca(void, 3, 3, msg, 8)
2024-07-23 19:37:43 -05:00
return
}
inl := fn(addr: u16): u32 {
2024-07-23 19:37:43 -05:00
msg := "\0\0\0\0";
2024-09-13 16:41:31 -05:00
*@as(^u8, msg) = @as(u8, 0);
*@as(^u8, msg + 1) = @as(u8, 2);
*@as(^u16, @bitcast(msg + 2)) = addr
return @eca(u32, 3, 3, msg, 4)
2024-07-20 12:54:58 -05:00
}