1
0
Fork 0
forked from koniifer/ableos

begin work for fb_driver interface

create hardware rng buffer & stn.random.uint_64 (currently weird)
move examples out of fb_driver (currently broken)
remove literal kernel panic from `info!("AHHH")`
re-implement stn.buffer.send_message()
This commit is contained in:
koniifer 2024-08-29 21:37:49 +01:00
parent 9100b3ce44
commit ad85f82be3
16 changed files with 70 additions and 10 deletions

View file

@ -131,6 +131,10 @@ pub fn handler(vm: &mut Vm) {
_ => {}
}
}
// source of rng
4 => {
vm.registers[1] = hbvm::value::Value(crate::arch::hardware_random_u64());
}
buffer_id => {
let mut buffs = IPC_BUFFERS.lock();
match buffs.get_mut(&buffer_id) {
@ -167,7 +171,7 @@ pub fn handler(vm: &mut Vm) {
if buffs.get_mut(&buffer_id).is_some() {
buff = buffs.get_mut(&buffer_id).unwrap();
} else {
info!("AHHH");
// info!("AHHH");
vm.registers[1] = hbvm::value::Value(0);
return;
}
@ -205,7 +209,6 @@ pub fn handler(vm: &mut Vm) {
vm.registers[3] = x
}
}
// 5
_ => {
log::error!("Syscall unknown {:?}{:?}", ecall_number, vm.registers);
}

View file

@ -0,0 +1 @@
software := @use("rel:software.hb")

View file

@ -0,0 +1,16 @@
.{buffer} := @use("../../stn/src/lib.hb")
test := fn(): int {
buffer_id := buffer.search("XGraphics\0")
msg := "\0"
buffer.send_message(msg, buffer_id)
return 0
}
put_pixel := fn(): int {
return 0
}
sync := fn(): int {
return 0
}

View file

@ -4,8 +4,7 @@ receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u
return @eca(^u8, 4, buffer_id, memory_map_location, length)
}
send_message := fn(buffer_id: int): void {
message := "Hello there\0"
send_message := fn(message: ^u8, buffer_id: int): void {
message_length := string.length(message)
@eca(i32, 3, buffer_id, message, message_length)
return

View file

@ -3,3 +3,4 @@ log := @use("rel:log.hb")
memory := @use("rel:memory.hb")
buffer := @use("rel:buffer.hb")
math := @use("rel:math.hb")
random := @use("rel:random.hb")

View file

@ -0,0 +1,8 @@
uint_64 := fn(min: uint, max: uint): uint {
rng := @eca(uint, 3, 4)
if min != 0 | max != 0 {
return rng % (max - min + 1) + min
}
return rng
}

View file

@ -1,7 +1,20 @@
// change "lines.hb" to another example to see it onscreen
example := @use("examples/lines.hb").example
.{log, memory, string, buffer} := @use("../../../libraries/stn/src/lib.hb");
.{front_buffer_ptr, screenidx, ColorBGRA, Point} := @use("./lib.hb")
main := fn(): int {
example()
buffer_id := buffer.create("XGraphics\0")
memmap := memory.request_page(1)
x := 0
loop {
msg := buffer.receive_message(buffer_id, memmap, 0)
if msg != 0 {
log.info("Hello, Framebuffer!\0")
}
loop if x == 4096 {
*(memmap + x) = 0
x += 1
}
x = 0
}
return 0
}

View file

@ -0,0 +1,11 @@
[package]
name = "fb_driver_stresstest"
authors = ["aurlex"]
[dependants.libraries]
[dependants.binaries]
hblang.version = "1.0.0"
[build]
command = "hblang src/main.hb"

View file

@ -0,0 +1,6 @@
.{test, put_pixel, sync} := @use("../../../libraries/render/src/lib.hb").software
main := fn(): int {
test()
return 0
}

View file

@ -19,16 +19,18 @@ resolution = "1024x768x24"
# [boot.limine.ableos.modules.tests]
# path = "boot:///tests.hbf"
[boot.limine.ableos.modules.a_serial_driver]
path = "boot:///a_serial_driver.hbf"
[boot.limine.ableos.modules.diskio_driver]
path = "boot:///diskio_driver.hbf"
[boot.limine.ableos.modules.fb_driver]
path = "boot:///fb_driver.hbf"
[boot.limine.ableos.modules.serial_driver_test]
path = "boot:///serial_driver_test.hbf"
[boot.limine.ableos.modules.fb_driver_stresstest]
path = "boot:///fb_driver_stresstest.hbf"