From ad85f82be32b519ad23be83526f25dd20e7609a5 Mon Sep 17 00:00:00 2001 From: koniifer <> Date: Thu, 29 Aug 2024 21:37:49 +0100 Subject: [PATCH] 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() --- kernel/src/holeybytes/ecah.rs | 7 +++++-- sysdata/libraries/render/src/lib.hb | 1 + sysdata/libraries/render/src/software.hb | 16 ++++++++++++++++ sysdata/libraries/stn/src/buffer.hb | 3 +-- sysdata/libraries/stn/src/lib.hb | 3 ++- sysdata/libraries/stn/src/random.hb | 8 ++++++++ sysdata/programs/fb_driver/src/main.hb | 19 ++++++++++++++++--- .../programs/fb_driver_stresstest/meta.toml | 11 +++++++++++ .../src/examples/amogus.hb | 0 .../src/examples/colors.hb | 0 .../src/examples/front_buffer.hb | 0 .../src/examples/lines.hb | 0 .../src/examples/square.hb | 0 .../src/examples/strobe.hb | 0 .../programs/fb_driver_stresstest/src/main.hb | 6 ++++++ sysdata/system_config.toml | 6 ++++-- 16 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 sysdata/libraries/render/src/lib.hb create mode 100644 sysdata/libraries/render/src/software.hb create mode 100644 sysdata/libraries/stn/src/random.hb create mode 100644 sysdata/programs/fb_driver_stresstest/meta.toml rename sysdata/programs/{fb_driver => fb_driver_stresstest}/src/examples/amogus.hb (100%) rename sysdata/programs/{fb_driver => fb_driver_stresstest}/src/examples/colors.hb (100%) rename sysdata/programs/{fb_driver => fb_driver_stresstest}/src/examples/front_buffer.hb (100%) rename sysdata/programs/{fb_driver => fb_driver_stresstest}/src/examples/lines.hb (100%) rename sysdata/programs/{fb_driver => fb_driver_stresstest}/src/examples/square.hb (100%) rename sysdata/programs/{fb_driver => fb_driver_stresstest}/src/examples/strobe.hb (100%) create mode 100644 sysdata/programs/fb_driver_stresstest/src/main.hb diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 2937205..5da4a8d 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -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); } diff --git a/sysdata/libraries/render/src/lib.hb b/sysdata/libraries/render/src/lib.hb new file mode 100644 index 0000000..0ef7121 --- /dev/null +++ b/sysdata/libraries/render/src/lib.hb @@ -0,0 +1 @@ +software := @use("rel:software.hb") \ No newline at end of file diff --git a/sysdata/libraries/render/src/software.hb b/sysdata/libraries/render/src/software.hb new file mode 100644 index 0000000..37966bc --- /dev/null +++ b/sysdata/libraries/render/src/software.hb @@ -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 +} \ No newline at end of file diff --git a/sysdata/libraries/stn/src/buffer.hb b/sysdata/libraries/stn/src/buffer.hb index 1f5bb17..ad93061 100644 --- a/sysdata/libraries/stn/src/buffer.hb +++ b/sysdata/libraries/stn/src/buffer.hb @@ -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 diff --git a/sysdata/libraries/stn/src/lib.hb b/sysdata/libraries/stn/src/lib.hb index ff45c3b..fa4414b 100644 --- a/sysdata/libraries/stn/src/lib.hb +++ b/sysdata/libraries/stn/src/lib.hb @@ -2,4 +2,5 @@ string := @use("rel:string.hb") log := @use("rel:log.hb") memory := @use("rel:memory.hb") buffer := @use("rel:buffer.hb") -math := @use("rel:math.hb") \ No newline at end of file +math := @use("rel:math.hb") +random := @use("rel:random.hb") \ No newline at end of file diff --git a/sysdata/libraries/stn/src/random.hb b/sysdata/libraries/stn/src/random.hb new file mode 100644 index 0000000..df1f297 --- /dev/null +++ b/sysdata/libraries/stn/src/random.hb @@ -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 +} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/main.hb b/sysdata/programs/fb_driver/src/main.hb index 0068d1f..fafa1e7 100644 --- a/sysdata/programs/fb_driver/src/main.hb +++ b/sysdata/programs/fb_driver/src/main.hb @@ -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 } \ No newline at end of file diff --git a/sysdata/programs/fb_driver_stresstest/meta.toml b/sysdata/programs/fb_driver_stresstest/meta.toml new file mode 100644 index 0000000..9df4beb --- /dev/null +++ b/sysdata/programs/fb_driver_stresstest/meta.toml @@ -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" diff --git a/sysdata/programs/fb_driver/src/examples/amogus.hb b/sysdata/programs/fb_driver_stresstest/src/examples/amogus.hb similarity index 100% rename from sysdata/programs/fb_driver/src/examples/amogus.hb rename to sysdata/programs/fb_driver_stresstest/src/examples/amogus.hb diff --git a/sysdata/programs/fb_driver/src/examples/colors.hb b/sysdata/programs/fb_driver_stresstest/src/examples/colors.hb similarity index 100% rename from sysdata/programs/fb_driver/src/examples/colors.hb rename to sysdata/programs/fb_driver_stresstest/src/examples/colors.hb diff --git a/sysdata/programs/fb_driver/src/examples/front_buffer.hb b/sysdata/programs/fb_driver_stresstest/src/examples/front_buffer.hb similarity index 100% rename from sysdata/programs/fb_driver/src/examples/front_buffer.hb rename to sysdata/programs/fb_driver_stresstest/src/examples/front_buffer.hb diff --git a/sysdata/programs/fb_driver/src/examples/lines.hb b/sysdata/programs/fb_driver_stresstest/src/examples/lines.hb similarity index 100% rename from sysdata/programs/fb_driver/src/examples/lines.hb rename to sysdata/programs/fb_driver_stresstest/src/examples/lines.hb diff --git a/sysdata/programs/fb_driver/src/examples/square.hb b/sysdata/programs/fb_driver_stresstest/src/examples/square.hb similarity index 100% rename from sysdata/programs/fb_driver/src/examples/square.hb rename to sysdata/programs/fb_driver_stresstest/src/examples/square.hb diff --git a/sysdata/programs/fb_driver/src/examples/strobe.hb b/sysdata/programs/fb_driver_stresstest/src/examples/strobe.hb similarity index 100% rename from sysdata/programs/fb_driver/src/examples/strobe.hb rename to sysdata/programs/fb_driver_stresstest/src/examples/strobe.hb diff --git a/sysdata/programs/fb_driver_stresstest/src/main.hb b/sysdata/programs/fb_driver_stresstest/src/main.hb new file mode 100644 index 0000000..a5d32cb --- /dev/null +++ b/sysdata/programs/fb_driver_stresstest/src/main.hb @@ -0,0 +1,6 @@ +.{test, put_pixel, sync} := @use("../../../libraries/render/src/lib.hb").software + +main := fn(): int { + test() + return 0 +} \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index f0539ef..7c2f3a8 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -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" \ No newline at end of file