From ad85f82be32b519ad23be83526f25dd20e7609a5 Mon Sep 17 00:00:00 2001 From: koniifer <> Date: Thu, 29 Aug 2024 21:37:49 +0100 Subject: [PATCH 01/12] 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 From 0d3641e199bad25892761145ccf719ab980fe27e Mon Sep 17 00:00:00 2001 From: Talha Qamar Date: Fri, 26 Jul 2024 18:29:12 +0500 Subject: [PATCH 02/12] just getting started --- sysdata/programs/ps2_driver/README.md | 3 +++ sysdata/programs/ps2_driver/src/controller.hb | 0 sysdata/programs/ps2_driver/src/keyboard.hb | 0 sysdata/programs/ps2_driver/src/main.hb | 2 ++ 4 files changed, 5 insertions(+) create mode 100644 sysdata/programs/ps2_driver/README.md create mode 100644 sysdata/programs/ps2_driver/src/controller.hb create mode 100644 sysdata/programs/ps2_driver/src/keyboard.hb create mode 100644 sysdata/programs/ps2_driver/src/main.hb diff --git a/sysdata/programs/ps2_driver/README.md b/sysdata/programs/ps2_driver/README.md new file mode 100644 index 0000000..96840d1 --- /dev/null +++ b/sysdata/programs/ps2_driver/README.md @@ -0,0 +1,3 @@ +# PS/2 Driver +This program is a simple driver to read keypresses from a PS/2 Keyboard +Also will contain an abstraction for the PS/2 controller in general so the Mouse code will probably also live here...maybe diff --git a/sysdata/programs/ps2_driver/src/controller.hb b/sysdata/programs/ps2_driver/src/controller.hb new file mode 100644 index 0000000..e69de29 diff --git a/sysdata/programs/ps2_driver/src/keyboard.hb b/sysdata/programs/ps2_driver/src/keyboard.hb new file mode 100644 index 0000000..e69de29 diff --git a/sysdata/programs/ps2_driver/src/main.hb b/sysdata/programs/ps2_driver/src/main.hb new file mode 100644 index 0000000..b5b3a7e --- /dev/null +++ b/sysdata/programs/ps2_driver/src/main.hb @@ -0,0 +1,2 @@ +main:= fn(): int { +} From 161529753698f2020ead4fd6f87e36b40e71e415 Mon Sep 17 00:00:00 2001 From: Talha Qamar Date: Fri, 30 Aug 2024 18:03:12 +0500 Subject: [PATCH 03/12] Detecting keypresses --- sysdata/libraries/stn/src/buffer.hb | 4 +--- sysdata/programs/ps2_driver/meta.toml | 11 +++++++++ sysdata/programs/ps2_driver/src/main.hb | 31 ++++++++++++++++++++++++- sysdata/system_config.toml | 2 ++ 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 sysdata/programs/ps2_driver/meta.toml diff --git a/sysdata/libraries/stn/src/buffer.hb b/sysdata/libraries/stn/src/buffer.hb index 1f5bb17..f6e6779 100644 --- a/sysdata/libraries/stn/src/buffer.hb +++ b/sysdata/libraries/stn/src/buffer.hb @@ -4,9 +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" - message_length := string.length(message) +send_message := fn(buffer_id: int, message: ^u8, message_length: int): void { @eca(i32, 3, buffer_id, message, message_length) return } diff --git a/sysdata/programs/ps2_driver/meta.toml b/sysdata/programs/ps2_driver/meta.toml new file mode 100644 index 0000000..0a2d770 --- /dev/null +++ b/sysdata/programs/ps2_driver/meta.toml @@ -0,0 +1,11 @@ +[package] +name = "ps2_driver" +authors = ["Talha Qamar"] + +[dependants.libraries] + +[dependants.binaries] +hblang.version = "1.0.0" + +[build] +command = "hblang src/main.hb" diff --git a/sysdata/programs/ps2_driver/src/main.hb b/sysdata/programs/ps2_driver/src/main.hb index b5b3a7e..3f09a8e 100644 --- a/sysdata/programs/ps2_driver/src/main.hb +++ b/sysdata/programs/ps2_driver/src/main.hb @@ -1,2 +1,31 @@ -main:= fn(): int { +.{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb") + +send_byte := fn(byte: u8): u8 { + memory.outb(0, 96, byte) + input := memory.inb(0, 96) + return input } + +main := fn(): int { + log.info("PS/2 Driver Loaded\0") + if send_byte(238) == 238 { + log.info("PS/2 Keyboard Echoed\0") + } + if send_byte(244) == 250 { + log.info("Enabled scanning\0") + } + buf := buffer.create() + ptr := memory.request_page(1) + prev_input := 250 + loop { + input := memory.inb(0, 96) + if input == prev_input { + continue + } + prev_input = input + keycode_str := string.display_int(input, ptr) + log.info(string.display_int(buf)) + buffer.send_message(buf, keycode_str, string.length(keycode_str)) + } + return 0 +} \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index f0539ef..b9668e4 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -22,6 +22,8 @@ resolution = "1024x768x24" [boot.limine.ableos.modules.a_serial_driver] path = "boot:///a_serial_driver.hbf" +[boot.limine.ableos.modules.ps2_driver] + path = "boot:///ps2_driver.hbf" [boot.limine.ableos.modules.diskio_driver] path = "boot:///diskio_driver.hbf" From 12ee3a9b87c2a01adce5cb965ebeb58ceb54b22d Mon Sep 17 00:00:00 2001 From: koniifer <> Date: Fri, 30 Aug 2024 16:22:13 +0100 Subject: [PATCH 04/12] fix random implement hardware_random_u32 implement math.max, alter math.min remove unneeded dependencies from fb_driver --- kernel/src/arch/x86_64/mod.rs | 27 ++++++++++++++++++++++++++ kernel/src/holeybytes/ecah.rs | 2 +- sysdata/libraries/stn/src/math.hb | 11 +++++++++-- sysdata/libraries/stn/src/random.hb | 4 ++-- sysdata/programs/fb_driver/src/main.hb | 3 +-- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/kernel/src/arch/x86_64/mod.rs b/kernel/src/arch/x86_64/mod.rs index a67a7ed..7437b1e 100644 --- a/kernel/src/arch/x86_64/mod.rs +++ b/kernel/src/arch/x86_64/mod.rs @@ -226,6 +226,33 @@ pub fn hardware_random_u64() -> u64 { } } +pub fn hardware_random_u32() -> u32 { + use {log::trace, rdrand::RdRand}; + let gen = RdRand::new(); + match gen { + Ok(gen) => { + let ret = gen.try_next_u32().unwrap(); + trace!("Random {}", ret); + return ret; + } + Err(err) => { + warn!("RDRand not supported."); + // Try rdseed + let gen = RdSeed::new(); + match gen { + Ok(gen) => { + let ret = gen.try_next_u32().unwrap(); + trace!("Random {}", ret); + return ret; + } + Err(err) => { + panic!("Neither RDRand or RDSeed are supported") + } + } + } + } +} + pub fn get_edid() {} pub fn register_dump() { diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 5da4a8d..516ae2d 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -133,7 +133,7 @@ pub fn handler(vm: &mut Vm) { } // source of rng 4 => { - vm.registers[1] = hbvm::value::Value(crate::arch::hardware_random_u64()); + vm.registers[1] = hbvm::value::Value(crate::arch::hardware_random_u32() as u64); } buffer_id => { let mut buffs = IPC_BUFFERS.lock(); diff --git a/sysdata/libraries/stn/src/math.hb b/sysdata/libraries/stn/src/math.hb index 2fd1d02..94ee78a 100644 --- a/sysdata/libraries/stn/src/math.hb +++ b/sysdata/libraries/stn/src/math.hb @@ -1,7 +1,14 @@ +SIZEOF_INT := 31 + abs := fn(x: int): int { - mask := x >> 31 + mask := x >> SIZEOF_INT return (x ^ mask) - mask } min := fn(a: int, b: int): int { - return b + (a - b & a - b >> 31) + c := a - b + return b + (c & c >> SIZEOF_INT) +} +max := fn(a: int, b: int): int { + c := a - b + return a - (c & c >> SIZEOF_INT) } \ No newline at end of file diff --git a/sysdata/libraries/stn/src/random.hb b/sysdata/libraries/stn/src/random.hb index df1f297..dbff80a 100644 --- a/sysdata/libraries/stn/src/random.hb +++ b/sysdata/libraries/stn/src/random.hb @@ -1,5 +1,5 @@ -uint_64 := fn(min: uint, max: uint): uint { - rng := @eca(uint, 3, 4) +integer := fn(min: int, max: int): int { + rng := @eca(int, 3, 4) if min != 0 | max != 0 { return rng % (max - min + 1) + min diff --git a/sysdata/programs/fb_driver/src/main.hb b/sysdata/programs/fb_driver/src/main.hb index fafa1e7..8893c76 100644 --- a/sysdata/programs/fb_driver/src/main.hb +++ b/sysdata/programs/fb_driver/src/main.hb @@ -1,5 +1,4 @@ -.{log, memory, string, buffer} := @use("../../../libraries/stn/src/lib.hb"); -.{front_buffer_ptr, screenidx, ColorBGRA, Point} := @use("./lib.hb") +.{log, memory, string, buffer} := @use("../../../libraries/stn/src/lib.hb") main := fn(): int { buffer_id := buffer.create("XGraphics\0") From 8577920d901910030cb76069d5221bdb98ea9090 Mon Sep 17 00:00:00 2001 From: koniifer Date: Sat, 31 Aug 2024 15:38:15 +0100 Subject: [PATCH 05/12] port ecah changes from svga_driver branch --- kernel/src/arch/x86_64/pci/mod.rs | 7 +- kernel/src/holeybytes/ecah.rs | 95 +++++++++++++++----- kernel/src/logger.rs | 6 +- sysdata/libraries/stn/src/memory.hb | 42 ++++++--- sysdata/programs/a_serial_driver/src/main.hb | 6 +- sysdata/programs/diskio_driver/src/main.hb | 6 +- sysdata/programs/fb_driver/src/color.hb | 2 +- sysdata/programs/ps2_driver/src/main.hb | 8 +- 8 files changed, 125 insertions(+), 47 deletions(-) diff --git a/kernel/src/arch/x86_64/pci/mod.rs b/kernel/src/arch/x86_64/pci/mod.rs index 5e2bbe7..b02c183 100644 --- a/kernel/src/arch/x86_64/pci/mod.rs +++ b/kernel/src/arch/x86_64/pci/mod.rs @@ -12,7 +12,8 @@ use crate::alloc::string::ToString; /// Enumerate PCI devices and run initialisation routines on ones we support pub fn init(device_tree: &mut DeviceTree) { - device_tree.devices + device_tree + .devices .insert("Unidentified PCI".to_string(), alloc::vec![]); let mut devices = alloc::vec![]; @@ -23,6 +24,7 @@ pub fn init(device_tree: &mut DeviceTree) { let id = device_info.device_id.id; use Vendor::*; let (dev_type, dev_name) = match (vendor, id) { + (VMWareInc, 1029) => ("GPUs", "SVGAII PCI GPU"), (Qemu, 4369) => ("GPUs", "QEMU VGA"), (VirtIO, 4176) => ("GPUs", "VirtIO PCI GPU"), (CirrusLogic, 184) => ("GPUs", "Cirrus SVGA"), //GD 5446? @@ -269,8 +271,7 @@ impl Display for Vendor { use core::fmt::Display; -use x86_64::instructions::port::Port; -use crate::device_tree::DeviceTree; +use {crate::device_tree::DeviceTree, x86_64::instructions::port::Port}; #[allow(non_camel_case_types, dead_code)] #[derive(Debug, Clone, Copy, PartialEq)] diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 516ae2d..d0202cf 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -86,47 +86,98 @@ pub fn handler(vm: &mut Vm) { Ok(_) => {} Err(_) => {} } - // } 3 => { unsafe fn x86_in(address: u16) -> u8 { x86_64::instructions::port::Port::new(address).read() } + unsafe fn x86_in_16(address: u16) -> u16 { + x86_64::instructions::port::Port::new(address).read() + } + unsafe fn x86_in_32(address: u16) -> u32 { + x86_64::instructions::port::Port::new(address).read() + } unsafe fn x86_out(address: u16, value: u8) { x86_64::instructions::port::Port::new(address).write(value); } + unsafe fn x86_out_16(address: u16, value: u16) { + x86_64::instructions::port::Port::new(address).write(value); + } + unsafe fn x86_out_32(address: u16, value: u32) { + x86_64::instructions::port::Port::new(address).write(value); + } let mut msg_vec = block_read(mem_addr, length); let msg_type = msg_vec[0]; msg_vec.remove(0); match msg_type { - 0 => { - let mut addr = msg_vec[0] as u16; + // XY\0\0V + // X = 0: Read, 1: Write + // Y = 0: 8bit, 1: 16bit, 2: 32bit + // \0 = Port + // V = Value + 0 => 'wow: { + // info!("inb"); + let size = match msg_vec[0] { + 0 => 1, + 1 => 2, + 2 => 4, + _ => { + error!("Tried to write more than 32 bits"); + break 'wow; + } + }; msg_vec.remove(0); - let addr2 = msg_vec[0] as u16; + let addr = ((msg_vec[0] as u16) << 8) + msg_vec[1] as u16; msg_vec.remove(0); - - addr = ((addr) << 8) | addr2; - - let value = unsafe { x86_in(addr) }; - + msg_vec.remove(0); + let value = unsafe { + match size { + 1 => x86_in(addr) as u64, + 2 => x86_in_16(addr) as u64, + 4 => x86_in_32(addr) as u64, + _ => panic!("how?"), + } + }; + msg_vec.clear(); trace!("Read the value {} from address {}", value, addr); - vm.registers[1] = hbvm::value::Value(value as u64); + vm.registers[1] = hbvm::value::Value(value); } - 1 => { - let mut addr = msg_vec[0] as u16; + 1 => 'wow: { + let size = match msg_vec[0] { + 0 => 1, + 1 => 2, + 2 => 4, + _ => { + error!("Tried to write more than 32 bits"); + break 'wow; + } + }; msg_vec.remove(0); - - let addr2 = msg_vec[0] as u16; + let addr = ((msg_vec[0] as u16) << 8) + msg_vec[1] as u16; msg_vec.remove(0); - - addr = ((addr) << 8) | addr2; - - let value = msg_vec[0]; msg_vec.remove(0); - trace!("Setting the address {} to {}", addr, value); - unsafe { x86_out(addr, value) }; + trace!("Setting address {}", addr); + unsafe { + match size { + 1 => x86_out(addr, msg_vec[0]), + 2 => x86_out_16( + addr, + core::mem::transmute::<[u8; 2], u16>( + msg_vec[0..2].try_into().unwrap(), + ), + ), + 4 => x86_out_32( + addr, + core::mem::transmute::<[u8; 4], u32>( + msg_vec[0..4].try_into().unwrap(), + ), + ), + _ => panic!("How?"), + } + } + msg_vec.clear(); } _ => {} } @@ -147,7 +198,7 @@ pub fn handler(vm: &mut Vm) { msg_vec.push(value); } buff.push(msg_vec.clone()); - info!( + debug!( "Message {:?} has been sent to Buffer({})", msg_vec, buffer_id ); @@ -191,7 +242,7 @@ pub fn handler(vm: &mut Vm) { } } - info!("Recieve {:?} from Buffer({})", msg, buffer_id); + debug!("Recieve {:?} from Buffer({})", msg, buffer_id); } } 5 => { diff --git a/kernel/src/logger.rs b/kernel/src/logger.rs index 3431775..b403fa9 100644 --- a/kernel/src/logger.rs +++ b/kernel/src/logger.rs @@ -9,7 +9,11 @@ use { pub fn init() -> Result<(), SetLoggerError> { log::set_logger(&crate::logger::Logger)?; - log::set_max_level(log::LevelFilter::Debug); + if cfg!(debug_assertions) { + log::set_max_level(log::LevelFilter::Debug); + } else { + log::set_max_level(log::LevelFilter::Info); + } Lazy::force(&TERMINAL_LOGGER); diff --git a/sysdata/libraries/stn/src/memory.hb b/sysdata/libraries/stn/src/memory.hb index fbbe80c..5e70120 100644 --- a/sysdata/libraries/stn/src/memory.hb +++ b/sysdata/libraries/stn/src/memory.hb @@ -17,19 +17,41 @@ release_page := fn(ptr: ^u8, page_count: u8): void { return @eca(void, 3, 2, msg, 12) } -outb := fn(addr_high: u8, addr_low: u8, value: u8): void { - msg := "\0\0\0\0"; +outb := fn(addr: u16, value: u8): void { + msg := "\0\0\0\0\0"; *msg = 1; - *(msg + 1) = addr_high; - *(msg + 2) = addr_low; - *(msg + 3) = value - @eca(void, 3, 3, msg, 4) + *(msg + 1) = 0; + *@as(^u16, @bitcast(msg + 2)) = addr; + *(msg + 4) = value + @eca(void, 3, 3, msg, 5) return } -inb := fn(addr_high: u8, addr_low: u8): u8 { +inb := fn(addr: u16): u8 { msg := "\0\0\0\0"; - *(msg + 1) = addr_high; - *(msg + 2) = addr_low - return @eca(u8, 3, 3, msg, 3) + *msg = 0; + *(msg + 1) = 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"; + *msg = 1; + *(msg + 1) = 2; + *@as(^u16, @bitcast(msg + 2)) = addr; + *(msg + 4) = value >> 24 & 255; + *(msg + 5) = value >> 16 & 255; + *(msg + 6) = value >> 8 & 255; + *(msg + 7) = value & 255 + @eca(void, 3, 3, msg, 8) + return +} + +inl := fn(addr: u16): u32 { + msg := "\0\0\0\0"; + *msg = 0; + *(msg + 1) = 2; + *@as(^u16, @bitcast(msg + 2)) = addr + return @eca(u32, 3, 3, msg, 4) } \ No newline at end of file diff --git a/sysdata/programs/a_serial_driver/src/main.hb b/sysdata/programs/a_serial_driver/src/main.hb index 6ec614e..5a96acd 100644 --- a/sysdata/programs/a_serial_driver/src/main.hb +++ b/sysdata/programs/a_serial_driver/src/main.hb @@ -5,7 +5,7 @@ serial_print := fn(ptr: ^u8): void { letter := 0 loop if *ptr == 0 break else { letter = *ptr - memory.outb(3, 248, letter) + memory.outb(63491, letter) ptr += 1 } return @@ -13,8 +13,8 @@ serial_print := fn(ptr: ^u8): void { serial_println := fn(ptr: ^u8): void { serial_print(ptr) - memory.outb(3, 248, 12) - memory.outb(3, 248, 13) + memory.outb(63491, 12) + memory.outb(63491, 13) return } diff --git a/sysdata/programs/diskio_driver/src/main.hb b/sysdata/programs/diskio_driver/src/main.hb index f8c3517..05e5ff2 100644 --- a/sysdata/programs/diskio_driver/src/main.hb +++ b/sysdata/programs/diskio_driver/src/main.hb @@ -3,10 +3,10 @@ stn := @use("../../../libraries/stn/src/lib.hb"); main := fn(): int { // shuts down ableOS - //memory.outb(0, 244, 0) + //memory.outb(62464, 0) - a := memory.inb(0, 70) - b := memory.inb(0, 71) + a := memory.inb(17920) + b := memory.inb(18176) c := buffer.search("XNumber\0") diff --git a/sysdata/programs/fb_driver/src/color.hb b/sysdata/programs/fb_driver/src/color.hb index 51bbf14..281f25d 100644 --- a/sysdata/programs/fb_driver/src/color.hb +++ b/sysdata/programs/fb_driver/src/color.hb @@ -19,7 +19,7 @@ LIGHTBLUE := ColorBGRA.{b: 255, g: 0, r: 0, a: 255} LIGHTMAGENTA := ColorBGRA.{b: 255, g: 0, r: 255, a: 255} LIGHTCYAN := ColorBGRA.{b: 255, g: 255, r: 0, a: 255} -// i have no clue if this works. please don't me ask how it works. -aurlex +// i have no clue if this works. please don't me ask how it works. -koniifer blend := fn(fg: ColorBGRA, bg: ColorBGRA): ColorBGRA { s := fg + bg m := s - ((fg ^ bg) & 16843008) & 16843008 diff --git a/sysdata/programs/ps2_driver/src/main.hb b/sysdata/programs/ps2_driver/src/main.hb index 33be926..04e7892 100644 --- a/sysdata/programs/ps2_driver/src/main.hb +++ b/sysdata/programs/ps2_driver/src/main.hb @@ -1,8 +1,8 @@ .{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb") send_byte := fn(byte: u8): u8 { - memory.outb(0, 96, byte) - return memory.inb(0, 96) + memory.outb(24576, byte) + return memory.inb(24576) } main := fn(): int { @@ -17,13 +17,13 @@ main := fn(): int { ptr := memory.request_page(1) prev_input := 250 loop { - input := memory.inb(0, 96) + input := memory.inb(24576) if input == prev_input { continue } prev_input = input keycode_str := string.display_int(input, ptr) - log.info(string.display_int(buf)) + log.info(string.display_int(input, ptr)) buffer.send_message(keycode_str, buf) } return 0 From c752028c73e61dd017fea5c7f27801be8bcb636d Mon Sep 17 00:00:00 2001 From: koniifer Date: Sat, 31 Aug 2024 19:34:14 +0100 Subject: [PATCH 06/12] fix ecah.rs, implement -d, --debuginfo to print debug info in serial (requires recompilation) --- kernel/src/holeybytes/ecah.rs | 15 +++++++-------- repbuild/src/main.rs | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index d0202cf..8571363 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -129,7 +129,7 @@ pub fn handler(vm: &mut Vm) { }; msg_vec.remove(0); - let addr = ((msg_vec[0] as u16) << 8) + msg_vec[1] as u16; + let addr = ((msg_vec[0] as u16) << 8) | msg_vec[1] as u16; msg_vec.remove(0); msg_vec.remove(0); let value = unsafe { @@ -155,7 +155,7 @@ pub fn handler(vm: &mut Vm) { } }; msg_vec.remove(0); - let addr = ((msg_vec[0] as u16) << 8) + msg_vec[1] as u16; + let addr = ((msg_vec[0] as u16) << 8) | msg_vec[1] as u16; msg_vec.remove(0); msg_vec.remove(0); trace!("Setting address {}", addr); @@ -164,15 +164,14 @@ pub fn handler(vm: &mut Vm) { 1 => x86_out(addr, msg_vec[0]), 2 => x86_out_16( addr, - core::mem::transmute::<[u8; 2], u16>( - msg_vec[0..2].try_into().unwrap(), - ), + ((msg_vec[0] as u16) << 8) | msg_vec[1] as u16, ), 4 => x86_out_32( addr, - core::mem::transmute::<[u8; 4], u32>( - msg_vec[0..4].try_into().unwrap(), - ), + ((msg_vec[0] as u32) << 24) + | ((msg_vec[1] as u32) << 16) + | ((msg_vec[2] as u32) << 8) + | (msg_vec[3] as u32), ), _ => panic!("How?"), } diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index af09c6d..8eb4835 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -22,10 +22,13 @@ fn main() -> Result<(), Error> { match args.next().as_deref() { Some("build" | "b") => { let mut release = false; + let mut debuginfo = false; let mut target = Target::X86_64; for arg in args { if arg == "-r" || arg == "--release" { release = true; + } else if arg == "-d" || arg == "--debuginfo" { + debuginfo = true; } else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" { target = Target::Riscv64Virt; } else if arg == "arm64" || arg == "aarch64" || arg == "aarch64-virt" { @@ -35,14 +38,17 @@ fn main() -> Result<(), Error> { } } - build(release, target).change_context(Error::Build) + build(release, target, debuginfo).change_context(Error::Build) } Some("run" | "r") => { let mut release = false; + let mut debuginfo = false; let mut target = Target::X86_64; for arg in args { if arg == "-r" || arg == "--release" { release = true; + } else if arg == "-d" || arg == "--debuginfo" { + debuginfo = true; } else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" { target = Target::Riscv64Virt; } else if arg == "arm64" || arg == "aarch64" || arg == "aarch64-virt" { @@ -52,7 +58,7 @@ fn main() -> Result<(), Error> { } } - build(release, target)?; + build(release, target, debuginfo)?; run(release, target) } Some("help" | "h") => { @@ -270,7 +276,7 @@ fn copy_file_to_img(fpath: &str, fs: &FileSystem) { .expect("Copy failed"); } -fn build(release: bool, target: Target) -> Result<(), Error> { +fn build(release: bool, target: Target, debuginfo: bool) -> Result<(), Error> { let fs = get_fs().change_context(Error::Io)?; let mut com = Command::new("cargo"); com.current_dir("kernel"); @@ -278,6 +284,9 @@ fn build(release: bool, target: Target) -> Result<(), Error> { if release { com.arg("-r"); } + if debuginfo { + com.env("RUSTFLAGS", "-Cdebug-assertions=true"); + } if target == Target::Riscv64Virt { com.args(["--target", "targets/riscv64-virt-ableos.json"]); From f7b970eaf0c76c3c9bd79c07a2a7ebdf620dfe89 Mon Sep 17 00:00:00 2001 From: koniifer Date: Sun, 1 Sep 2024 22:29:42 +0100 Subject: [PATCH 07/12] hexadecimal support!! remove fb_driver_stresstest, move examples back to fb_driver, update hblang, update Cargo.lock --- Cargo.lock | 592 ++++++++++-------- kernel/Cargo.toml | 2 +- sysdata/libraries/stn/src/memory.hb | 8 +- sysdata/programs/a_serial_driver/src/main.hb | 8 +- sysdata/programs/diskio_driver/src/main.hb | 6 +- sysdata/programs/fb_driver/src/color.hb | 4 +- .../src/examples/amogus.hb | 0 .../src/examples/colors.hb | 2 +- .../src/examples/front_buffer.hb | 0 .../src/examples/lines.hb | 0 .../src/examples/square.hb | 0 .../src/examples/strobe.hb | 0 sysdata/programs/fb_driver/src/lib.hb | 19 +- sysdata/programs/fb_driver/src/main.hb | 17 +- .../programs/fb_driver_stresstest/meta.toml | 11 - .../programs/fb_driver_stresstest/src/main.hb | 6 - sysdata/programs/ps2_driver/src/main.hb | 12 +- sysdata/system_config.toml | 3 - 18 files changed, 348 insertions(+), 342 deletions(-) rename sysdata/programs/{fb_driver_stresstest => fb_driver}/src/examples/amogus.hb (100%) rename sysdata/programs/{fb_driver_stresstest => fb_driver}/src/examples/colors.hb (96%) rename sysdata/programs/{fb_driver_stresstest => fb_driver}/src/examples/front_buffer.hb (100%) rename sysdata/programs/{fb_driver_stresstest => fb_driver}/src/examples/lines.hb (100%) rename sysdata/programs/{fb_driver_stresstest => fb_driver}/src/examples/square.hb (100%) rename sysdata/programs/{fb_driver_stresstest => fb_driver}/src/examples/strobe.hb (100%) delete mode 100644 sysdata/programs/fb_driver_stresstest/meta.toml delete mode 100644 sysdata/programs/fb_driver_stresstest/src/main.hb diff --git a/Cargo.lock b/Cargo.lock index 77c8bf6..8a4f12e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -47,14 +47,14 @@ dependencies = [ "cfg-if", "once_cell", "version_check", - "zerocopy 0.7.34", + "zerocopy 0.7.35", ] [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "android-tzdata" @@ -73,15 +73,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "az" @@ -91,9 +91,9 @@ checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -106,9 +106,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "beef" @@ -136,15 +136,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" @@ -154,17 +154,17 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cc" -version = "1.0.83" +version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" dependencies = [ - "libc", + "shlex", ] [[package]] @@ -175,16 +175,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -192,7 +192,7 @@ name = "clparse" version = "0.1.0" source = "git+https://git.ablecorp.us/ableos/ableos_userland#6c38f2b2f1f7f04b43a8def709de1da98cb5fba1" dependencies = [ - "hashbrown 0.14.2", + "hashbrown 0.14.5", "log", "toml 0.5.9", ] @@ -205,9 +205,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -215,40 +215,36 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "crossbeam-queue" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" dependencies = [ - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version", - "syn 1.0.109", + "syn", ] [[package]] @@ -283,13 +279,19 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "error-stack" version = "0.4.1" @@ -329,51 +331,51 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-io", @@ -386,9 +388,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -397,15 +399,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "h2" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -431,9 +433,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash 0.8.11", "allocator-api2", @@ -442,17 +444,17 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#9af7bf559f139937529ea7747cd275ed163fb1fa" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#cbe6f98dff9960e6b070173f35cf54434b0262f6" [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#e494785f93dad2722ebd9e5d81c2bcb3c471cc07" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#cbe6f98dff9960e6b070173f35cf54434b0262f6" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#9af7bf559f139937529ea7747cd275ed163fb1fa" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#cbe6f98dff9960e6b070173f35cf54434b0262f6" dependencies = [ "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -460,7 +462,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#9af7bf559f139937529ea7747cd275ed163fb1fa" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#cbe6f98dff9960e6b070173f35cf54434b0262f6" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -468,22 +470,22 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#e494785f93dad2722ebd9e5d81c2bcb3c471cc07" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#cbe6f98dff9960e6b070173f35cf54434b0262f6" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)", ] [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "http" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -492,9 +494,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -503,9 +505,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -515,9 +517,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -530,7 +532,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2", "tokio", "tower-service", "tracing", @@ -553,9 +555,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -576,9 +578,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -586,12 +588,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ - "autocfg", - "hashbrown 0.12.3", + "equivalent", + "hashbrown 0.14.5", ] [[package]] @@ -602,15 +604,15 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] @@ -624,7 +626,7 @@ dependencies = [ "crossbeam-queue", "derive_more", "embedded-graphics", - "hashbrown 0.14.2", + "hashbrown 0.14.5", "hbvm 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)", "kiam", "limine", @@ -655,20 +657,21 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "limine" -version = "0.1.11" -source = "git+https://github.com/limine-bootloader/limine-rs#4394419fe347901a9308a8956df16454a4b87b02" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02034f8f6b3e7bf050f310fbaf6db0018b8e54b75598d0a4c97172054752fede" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -676,9 +679,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "logos" @@ -701,7 +704,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax", - "syn 2.0.38", + "syn", ] [[package]] @@ -715,9 +718,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "micromath" @@ -733,75 +736,66 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.9" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ + "hermit-abi", "libc", "wasi", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" -version = "0.32.1" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -811,18 +805,18 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -844,9 +838,9 @@ dependencies = [ [[package]] name = "rdrand" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e233b642160555c1aa1ff7a78443c6139342f411b6fa6602af2ebbfee9e166bb" +checksum = "d92195228612ac8eed47adbc2ed0f04e513a4ccb98175b6f2bd04d963b533655" dependencies = [ "rand_core", ] @@ -872,9 +866,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.22" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64", "bytes", @@ -898,6 +892,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", "tokio", "tokio-rustls", @@ -912,38 +907,39 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.5" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if", "getrandom", "libc", "spin", "untrusted", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] [[package]] name = "rustls" -version = "0.21.8" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", @@ -953,9 +949,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ "base64", ] @@ -972,15 +968,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "sbi" @@ -1006,37 +1002,38 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.20" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.190" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.190" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn", ] [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1053,6 +1050,12 @@ dependencies = [ "serde", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "slab" version = "0.4.9" @@ -1064,22 +1067,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.10" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "winapi", -] - -[[package]] -name = "socket2" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" -dependencies = [ - "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1099,9 +1092,9 @@ checksum = "a6aa20b89aec46e0bffbb8756e089beb4c43bbec53d0667de34212f048bdab10" [[package]] name = "syn" -version = "1.0.109" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -1109,15 +1102,10 @@ dependencies = [ ] [[package]] -name = "syn" -version = "2.0.38" +name = "sync_wrapper" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "system-configuration" @@ -1142,9 +1130,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -1157,18 +1145,17 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "pin-project-lite", - "socket2 0.5.5", - "windows-sys", + "socket2", + "windows-sys 0.52.0", ] [[package]] @@ -1183,16 +1170,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -1215,9 +1201,9 @@ dependencies = [ [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -1240,9 +1226,9 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "uart_16550" @@ -1257,9 +1243,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -1269,9 +1255,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] @@ -1284,9 +1270,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -1295,9 +1281,9 @@ dependencies = [ [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "versioning" @@ -1315,7 +1301,7 @@ checksum = "42299957c6f61af586fe3eae398c16ec07f33a02579fa1d41ae96156ce437029" dependencies = [ "bitflags 1.3.2", "log", - "zerocopy 0.6.5", + "zerocopy 0.6.6", ] [[package]] @@ -1341,34 +1327,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.38", + "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", @@ -1378,9 +1365,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1388,28 +1375,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", @@ -1417,39 +1404,17 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.2" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1458,7 +1423,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -1467,13 +1441,29 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -1482,42 +1472,90 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winreg" version = "0.50.0" @@ -1525,7 +1563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ "cfg-if", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1543,12 +1581,12 @@ dependencies = [ [[package]] name = "x86_64" -version = "0.14.11" +version = "0.14.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b835097a84e4457323331ec5d6eb23d096066cbfb215d54096dcb4b2e85f500" +checksum = "96cb6fd45bfeab6a5055c5bffdb08768bd0c069f1d946debe585bbb380a7c062" dependencies = [ "bit_field", - "bitflags 2.4.1", + "bitflags 2.6.0", "rustversion", "volatile", ] @@ -1563,41 +1601,41 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96f8f25c15a0edc9b07eb66e7e6e97d124c0505435c382fde1ab7ceb188aa956" +checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" dependencies = [ "byteorder", - "zerocopy-derive 0.6.5", + "zerocopy-derive 0.6.6", ] [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive 0.7.34", + "zerocopy-derive 0.7.35", ] [[package]] name = "zerocopy-derive" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "855e0f6af9cd72b87d8a6c586f3cb583f5cdcc62c2c80869d8cd7e96fdf7ee20" +checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn", ] diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index d1beff8..27c8c8b 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -19,7 +19,7 @@ kiam = "0.1.1" [dependencies.limine] version = "0.1" -git = "https://github.com/limine-bootloader/limine-rs" +#git = "https://github.com/limine-bootloader/limine-rs" [dependencies.crossbeam-queue] version = "0.3" diff --git a/sysdata/libraries/stn/src/memory.hb b/sysdata/libraries/stn/src/memory.hb index 5e70120..54ca26d 100644 --- a/sysdata/libraries/stn/src/memory.hb +++ b/sysdata/libraries/stn/src/memory.hb @@ -40,10 +40,10 @@ outl := fn(addr: u16, value: u32): void { *msg = 1; *(msg + 1) = 2; *@as(^u16, @bitcast(msg + 2)) = addr; - *(msg + 4) = value >> 24 & 255; - *(msg + 5) = value >> 16 & 255; - *(msg + 6) = value >> 8 & 255; - *(msg + 7) = value & 255 + *(msg + 4) = value >> 24 & 0xFF; + *(msg + 5) = value >> 16 & 0xFF; + *(msg + 6) = value >> 8 & 0xFF; + *(msg + 7) = value & 0xFF @eca(void, 3, 3, msg, 8) return } diff --git a/sysdata/programs/a_serial_driver/src/main.hb b/sysdata/programs/a_serial_driver/src/main.hb index 5a96acd..c98054f 100644 --- a/sysdata/programs/a_serial_driver/src/main.hb +++ b/sysdata/programs/a_serial_driver/src/main.hb @@ -5,7 +5,7 @@ serial_print := fn(ptr: ^u8): void { letter := 0 loop if *ptr == 0 break else { letter = *ptr - memory.outb(63491, letter) + memory.outb(0xF803, letter) ptr += 1 } return @@ -13,8 +13,8 @@ serial_print := fn(ptr: ^u8): void { serial_println := fn(ptr: ^u8): void { serial_print(ptr) - memory.outb(63491, 12) - memory.outb(63491, 13) + memory.outb(0xF803, 12) + memory.outb(0xF803, 13) return } @@ -26,7 +26,7 @@ main := fn(): int { mem := memory.request_page(1) loop { - ptr := @eca(int, 4, a, mem, 4096) + ptr := @eca(int, 4, a, mem, 0x1000) if ptr == 0 { serial_println("No message\0") } diff --git a/sysdata/programs/diskio_driver/src/main.hb b/sysdata/programs/diskio_driver/src/main.hb index 05e5ff2..dd0ddf2 100644 --- a/sysdata/programs/diskio_driver/src/main.hb +++ b/sysdata/programs/diskio_driver/src/main.hb @@ -3,10 +3,10 @@ stn := @use("../../../libraries/stn/src/lib.hb"); main := fn(): int { // shuts down ableOS - //memory.outb(62464, 0) + //memory.outb(0xF400, 0) - a := memory.inb(17920) - b := memory.inb(18176) + a := memory.inb(0x4600) + b := memory.inb(0x4700) c := buffer.search("XNumber\0") diff --git a/sysdata/programs/fb_driver/src/color.hb b/sysdata/programs/fb_driver/src/color.hb index 281f25d..802c127 100644 --- a/sysdata/programs/fb_driver/src/color.hb +++ b/sysdata/programs/fb_driver/src/color.hb @@ -22,6 +22,6 @@ LIGHTCYAN := ColorBGRA.{b: 255, g: 255, r: 0, a: 255} // i have no clue if this works. please don't me ask how it works. -koniifer blend := fn(fg: ColorBGRA, bg: ColorBGRA): ColorBGRA { s := fg + bg - m := s - ((fg ^ bg) & 16843008) & 16843008 - return (m >> 8 | 16777216 * (s < fg)) * 255 | s - m + m := s - ((fg ^ bg) & 0x1010100) & 0x1010100 + return (m >> 8 | 0x1000000 * (s < fg)) * 0xFF | s - m } \ No newline at end of file diff --git a/sysdata/programs/fb_driver_stresstest/src/examples/amogus.hb b/sysdata/programs/fb_driver/src/examples/amogus.hb similarity index 100% rename from sysdata/programs/fb_driver_stresstest/src/examples/amogus.hb rename to sysdata/programs/fb_driver/src/examples/amogus.hb diff --git a/sysdata/programs/fb_driver_stresstest/src/examples/colors.hb b/sysdata/programs/fb_driver/src/examples/colors.hb similarity index 96% rename from sysdata/programs/fb_driver_stresstest/src/examples/colors.hb rename to sysdata/programs/fb_driver/src/examples/colors.hb index a20f5ff..1d29d04 100644 --- a/sysdata/programs/fb_driver_stresstest/src/examples/colors.hb +++ b/sysdata/programs/fb_driver/src/examples/colors.hb @@ -12,7 +12,7 @@ example := fn(): void { color := ColorBGRA.(0, 255, 0, 255) /* have to explicitly say 0 is a u8, or we do something crazy to the colors. looks like a compiler bug */ - n := @as(i8, @as(u8, 0)) - 1 + n := @as(u8, 0) - 1 loop { clear(buffer, color) present(buffer) diff --git a/sysdata/programs/fb_driver_stresstest/src/examples/front_buffer.hb b/sysdata/programs/fb_driver/src/examples/front_buffer.hb similarity index 100% rename from sysdata/programs/fb_driver_stresstest/src/examples/front_buffer.hb rename to sysdata/programs/fb_driver/src/examples/front_buffer.hb diff --git a/sysdata/programs/fb_driver_stresstest/src/examples/lines.hb b/sysdata/programs/fb_driver/src/examples/lines.hb similarity index 100% rename from sysdata/programs/fb_driver_stresstest/src/examples/lines.hb rename to sysdata/programs/fb_driver/src/examples/lines.hb diff --git a/sysdata/programs/fb_driver_stresstest/src/examples/square.hb b/sysdata/programs/fb_driver/src/examples/square.hb similarity index 100% rename from sysdata/programs/fb_driver_stresstest/src/examples/square.hb rename to sysdata/programs/fb_driver/src/examples/square.hb diff --git a/sysdata/programs/fb_driver_stresstest/src/examples/strobe.hb b/sysdata/programs/fb_driver/src/examples/strobe.hb similarity index 100% rename from sysdata/programs/fb_driver_stresstest/src/examples/strobe.hb rename to sysdata/programs/fb_driver/src/examples/strobe.hb diff --git a/sysdata/programs/fb_driver/src/lib.hb b/sysdata/programs/fb_driver/src/lib.hb index ddfc3e4..c4d86f3 100644 --- a/sysdata/programs/fb_driver/src/lib.hb +++ b/sysdata/programs/fb_driver/src/lib.hb @@ -5,9 +5,10 @@ FB_WIDTH := 1024 FB_HEIGHT := 768 FB_PIXELS := FB_WIDTH * FB_HEIGHT FB_BYTES := FB_PIXELS << 2 -// actual enforced max copy size is (1 << 16) - 1, but this was faster -MAX_COPY_SIZE := 6144 +// actual enforced max copy size is 0xFFFF, but this was faster +MAX_COPY_SIZE := 0x1800 // see stn.math.min, cant use here due to compiler bug (reg id leaked) +// COPY_PIXELS := math.min(MAX_COPY_SIZE, FB_BYTES) >> 2 COPY_PIXELS := MAX_COPY_SIZE + (FB_BYTES - MAX_COPY_SIZE & FB_BYTES - MAX_COPY_SIZE >> 31) >> 2 PARTITIONS := FB_PIXELS / COPY_PIXELS TOTAL_PAGES := 1 + FB_BYTES >> 12 @@ -17,12 +18,12 @@ Point := struct {x: int, y: int} Transform := struct {width: int, height: int} Rect := struct {p1: Point, p2: Point} -front_buffer_ptr := @as(^ColorBGRA, @bitcast(18446603339442421760)) +front_buffer_ptr := @as(^ColorBGRA, @bitcast(0xFFFF8000C0000000)) front_buffer_copy := @as(^[ColorBGRA; COPY_PIXELS], @bitcast(front_buffer_ptr)) get_front_buffer := fn(): Buffer { // trying to return front_buffer_ptr or front_buffer_copy causes reg id leak - return Buffer.{write: @as(^ColorBGRA, @bitcast(18446603339442421760)), copy: @as(^[ColorBGRA; COPY_PIXELS], @bitcast(18446603339442421760))} + return Buffer.{write: @as(^ColorBGRA, @bitcast(0xFFFF8000C0000000)), copy: @as(^[ColorBGRA; COPY_PIXELS], @bitcast(0xFFFF8000C0000000))} } /* this is separate to create_raw_buffer because returning a Buffer from create_raw_buffer causes reg id leak */ @@ -36,18 +37,18 @@ create_buffer := fn(): Buffer { create_raw_buffer := fn(): ^ColorBGRA { // helps to trace allocation bugs log.info("Creating buffer. This will allocate.\0") - if TOTAL_PAGES <= 255 { + if TOTAL_PAGES <= 0xFF { return @bitcast(memory.request_page(TOTAL_PAGES)) } ptr := memory.request_page(255) - remaining := TOTAL_PAGES - 255 + remaining := TOTAL_PAGES - 0xFF loop if remaining <= 0 break else { - if remaining < 255 { + if remaining < 0xFF { memory.request_page(remaining) } else { - memory.request_page(255) + memory.request_page(0xFF) } - remaining -= 255 + remaining -= 0xFF } return @bitcast(ptr) } diff --git a/sysdata/programs/fb_driver/src/main.hb b/sysdata/programs/fb_driver/src/main.hb index 8893c76..ab3726b 100644 --- a/sysdata/programs/fb_driver/src/main.hb +++ b/sysdata/programs/fb_driver/src/main.hb @@ -1,19 +1,6 @@ -.{log, memory, string, buffer} := @use("../../../libraries/stn/src/lib.hb") +.{example} := @use("./examples/colors.hb") main := fn(): int { - 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 - } + example() 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 deleted file mode 100644 index 9df4beb..0000000 --- a/sysdata/programs/fb_driver_stresstest/meta.toml +++ /dev/null @@ -1,11 +0,0 @@ -[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_stresstest/src/main.hb b/sysdata/programs/fb_driver_stresstest/src/main.hb deleted file mode 100644 index a5d32cb..0000000 --- a/sysdata/programs/fb_driver_stresstest/src/main.hb +++ /dev/null @@ -1,6 +0,0 @@ -.{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/programs/ps2_driver/src/main.hb b/sysdata/programs/ps2_driver/src/main.hb index 04e7892..bec3e3d 100644 --- a/sysdata/programs/ps2_driver/src/main.hb +++ b/sysdata/programs/ps2_driver/src/main.hb @@ -1,23 +1,23 @@ .{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb") send_byte := fn(byte: u8): u8 { - memory.outb(24576, byte) - return memory.inb(24576) + memory.outb(0x6000, byte) + return memory.inb(0x6000) } main := fn(): int { log.info("PS/2 Driver Loaded\0") - if send_byte(238) == 238 { + if send_byte(0xEE) == 0xEE { log.info("PS/2 Keyboard Echoed\0") } - if send_byte(244) == 250 { + if send_byte(0xF4) == 0xFA { log.info("Enabled scanning\0") } buf := buffer.create("XKeyboard\0") ptr := memory.request_page(1) - prev_input := 250 + prev_input := 0xFA loop { - input := memory.inb(24576) + input := memory.inb(0x6000) if input == prev_input { continue } diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 8c8850c..2d19bf8 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -34,6 +34,3 @@ 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 From 19992595fc42d797fe94e22728fde3f6daf23cd9 Mon Sep 17 00:00:00 2001 From: koniifer Date: Mon, 2 Sep 2024 01:04:00 +0100 Subject: [PATCH 08/12] update hblang to latest git remove old ps/2 driver remove defunct time driver clean up stuff i promise im done fiddling with ecah.rs and memory.hb --- Cargo.lock | 10 +++---- kernel/src/holeybytes/ecah.rs | 18 +++-------- sysdata/libraries/render/src/lib.hb | 1 - sysdata/libraries/render/src/software.hb | 16 ---------- sysdata/libraries/stn/src/memory.hb | 5 +--- sysdata/programs/fb_driver/src/lib.hb | 6 +--- sysdata/programs/ps2_driver/README.md | 3 -- sysdata/programs/ps2_driver/meta.toml | 11 ------- sysdata/programs/ps2_driver/src/controller.hb | 0 sysdata/programs/ps2_driver/src/keyboard.hb | 0 sysdata/programs/ps2_driver/src/main.hb | 30 ------------------- .../programs/serial_driver_test/src/main.hb | 5 +--- sysdata/programs/tests/src/main.hb | 3 +- sysdata/programs/time_driver/meta.toml | 11 ------- sysdata/programs/time_driver/src/main.hb | 22 -------------- sysdata/system_config.toml | 3 -- 16 files changed, 13 insertions(+), 131 deletions(-) delete mode 100644 sysdata/libraries/render/src/lib.hb delete mode 100644 sysdata/libraries/render/src/software.hb delete mode 100644 sysdata/programs/ps2_driver/README.md delete mode 100644 sysdata/programs/ps2_driver/meta.toml delete mode 100644 sysdata/programs/ps2_driver/src/controller.hb delete mode 100644 sysdata/programs/ps2_driver/src/keyboard.hb delete mode 100644 sysdata/programs/ps2_driver/src/main.hb delete mode 100644 sysdata/programs/time_driver/meta.toml delete mode 100644 sysdata/programs/time_driver/src/main.hb diff --git a/Cargo.lock b/Cargo.lock index 8a4f12e..5bfd9b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -444,17 +444,17 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#cbe6f98dff9960e6b070173f35cf54434b0262f6" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#641be15703153386fef1a6b083a7e00c85414df9" [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#cbe6f98dff9960e6b070173f35cf54434b0262f6" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#641be15703153386fef1a6b083a7e00c85414df9" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#cbe6f98dff9960e6b070173f35cf54434b0262f6" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#641be15703153386fef1a6b083a7e00c85414df9" dependencies = [ "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -462,7 +462,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#cbe6f98dff9960e6b070173f35cf54434b0262f6" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#641be15703153386fef1a6b083a7e00c85414df9" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -470,7 +470,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#cbe6f98dff9960e6b070173f35cf54434b0262f6" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#641be15703153386fef1a6b083a7e00c85414df9" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)", ] diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 8571363..548ddeb 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -111,13 +111,7 @@ pub fn handler(vm: &mut Vm) { let msg_type = msg_vec[0]; msg_vec.remove(0); match msg_type { - // XY\0\0V - // X = 0: Read, 1: Write - // Y = 0: 8bit, 1: 16bit, 2: 32bit - // \0 = Port - // V = Value 0 => 'wow: { - // info!("inb"); let size = match msg_vec[0] { 0 => 1, 1 => 2, @@ -128,8 +122,7 @@ pub fn handler(vm: &mut Vm) { } }; msg_vec.remove(0); - - let addr = ((msg_vec[0] as u16) << 8) | msg_vec[1] as u16; + let addr = u16::from_le_bytes(msg_vec[0..2].try_into().unwrap()); msg_vec.remove(0); msg_vec.remove(0); let value = unsafe { @@ -155,7 +148,7 @@ pub fn handler(vm: &mut Vm) { } }; msg_vec.remove(0); - let addr = ((msg_vec[0] as u16) << 8) | msg_vec[1] as u16; + let addr = u16::from_le_bytes(msg_vec[0..2].try_into().unwrap()); msg_vec.remove(0); msg_vec.remove(0); trace!("Setting address {}", addr); @@ -164,14 +157,11 @@ pub fn handler(vm: &mut Vm) { 1 => x86_out(addr, msg_vec[0]), 2 => x86_out_16( addr, - ((msg_vec[0] as u16) << 8) | msg_vec[1] as u16, + u16::from_le_bytes(msg_vec[0..2].try_into().unwrap()), ), 4 => x86_out_32( addr, - ((msg_vec[0] as u32) << 24) - | ((msg_vec[1] as u32) << 16) - | ((msg_vec[2] as u32) << 8) - | (msg_vec[3] as u32), + u32::from_le_bytes(msg_vec[0..4].try_into().unwrap()), ), _ => panic!("How?"), } diff --git a/sysdata/libraries/render/src/lib.hb b/sysdata/libraries/render/src/lib.hb deleted file mode 100644 index 0ef7121..0000000 --- a/sysdata/libraries/render/src/lib.hb +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 37966bc..0000000 --- a/sysdata/libraries/render/src/software.hb +++ /dev/null @@ -1,16 +0,0 @@ -.{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/memory.hb b/sysdata/libraries/stn/src/memory.hb index 54ca26d..0d25d87 100644 --- a/sysdata/libraries/stn/src/memory.hb +++ b/sysdata/libraries/stn/src/memory.hb @@ -40,10 +40,7 @@ outl := fn(addr: u16, value: u32): void { *msg = 1; *(msg + 1) = 2; *@as(^u16, @bitcast(msg + 2)) = addr; - *(msg + 4) = value >> 24 & 0xFF; - *(msg + 5) = value >> 16 & 0xFF; - *(msg + 6) = value >> 8 & 0xFF; - *(msg + 7) = value & 0xFF + *@as(^u32, @bitcast(msg + 4)) = value @eca(void, 3, 3, msg, 8) return } diff --git a/sysdata/programs/fb_driver/src/lib.hb b/sysdata/programs/fb_driver/src/lib.hb index c4d86f3..02c88c5 100644 --- a/sysdata/programs/fb_driver/src/lib.hb +++ b/sysdata/programs/fb_driver/src/lib.hb @@ -7,9 +7,7 @@ FB_PIXELS := FB_WIDTH * FB_HEIGHT FB_BYTES := FB_PIXELS << 2 // actual enforced max copy size is 0xFFFF, but this was faster MAX_COPY_SIZE := 0x1800 -// see stn.math.min, cant use here due to compiler bug (reg id leaked) -// COPY_PIXELS := math.min(MAX_COPY_SIZE, FB_BYTES) >> 2 -COPY_PIXELS := MAX_COPY_SIZE + (FB_BYTES - MAX_COPY_SIZE & FB_BYTES - MAX_COPY_SIZE >> 31) >> 2 +COPY_PIXELS := math.min(MAX_COPY_SIZE, FB_BYTES) >> 2 PARTITIONS := FB_PIXELS / COPY_PIXELS TOTAL_PAGES := 1 + FB_BYTES >> 12 @@ -35,8 +33,6 @@ create_buffer := fn(): Buffer { return buffer } create_raw_buffer := fn(): ^ColorBGRA { - // helps to trace allocation bugs - log.info("Creating buffer. This will allocate.\0") if TOTAL_PAGES <= 0xFF { return @bitcast(memory.request_page(TOTAL_PAGES)) } diff --git a/sysdata/programs/ps2_driver/README.md b/sysdata/programs/ps2_driver/README.md deleted file mode 100644 index 96840d1..0000000 --- a/sysdata/programs/ps2_driver/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# PS/2 Driver -This program is a simple driver to read keypresses from a PS/2 Keyboard -Also will contain an abstraction for the PS/2 controller in general so the Mouse code will probably also live here...maybe diff --git a/sysdata/programs/ps2_driver/meta.toml b/sysdata/programs/ps2_driver/meta.toml deleted file mode 100644 index 0a2d770..0000000 --- a/sysdata/programs/ps2_driver/meta.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "ps2_driver" -authors = ["Talha Qamar"] - -[dependants.libraries] - -[dependants.binaries] -hblang.version = "1.0.0" - -[build] -command = "hblang src/main.hb" diff --git a/sysdata/programs/ps2_driver/src/controller.hb b/sysdata/programs/ps2_driver/src/controller.hb deleted file mode 100644 index e69de29..0000000 diff --git a/sysdata/programs/ps2_driver/src/keyboard.hb b/sysdata/programs/ps2_driver/src/keyboard.hb deleted file mode 100644 index e69de29..0000000 diff --git a/sysdata/programs/ps2_driver/src/main.hb b/sysdata/programs/ps2_driver/src/main.hb deleted file mode 100644 index bec3e3d..0000000 --- a/sysdata/programs/ps2_driver/src/main.hb +++ /dev/null @@ -1,30 +0,0 @@ -.{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb") - -send_byte := fn(byte: u8): u8 { - memory.outb(0x6000, byte) - return memory.inb(0x6000) -} - -main := fn(): int { - log.info("PS/2 Driver Loaded\0") - if send_byte(0xEE) == 0xEE { - log.info("PS/2 Keyboard Echoed\0") - } - if send_byte(0xF4) == 0xFA { - log.info("Enabled scanning\0") - } - buf := buffer.create("XKeyboard\0") - ptr := memory.request_page(1) - prev_input := 0xFA - loop { - input := memory.inb(0x6000) - 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 -} \ No newline at end of file diff --git a/sysdata/programs/serial_driver_test/src/main.hb b/sysdata/programs/serial_driver_test/src/main.hb index c1f6761..da3b881 100644 --- a/sysdata/programs/serial_driver_test/src/main.hb +++ b/sysdata/programs/serial_driver_test/src/main.hb @@ -1,7 +1,4 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); -.{string, memory, buffer} := stn - -frame_buffer := @as(^u8, @bitcast(18446603339442421760)) +.{string, memory, buffer} := @use("../../../libraries/stn/src/lib.hb") log_info := fn(): void { a := buffer.search("XNumber\0") diff --git a/sysdata/programs/tests/src/main.hb b/sysdata/programs/tests/src/main.hb index a8dbc78..bf07899 100644 --- a/sysdata/programs/tests/src/main.hb +++ b/sysdata/programs/tests/src/main.hb @@ -1,5 +1,4 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); -.{log, string, memory, buffer} := stn +.{log, string, memory, buffer} := @use("../../../libraries/stn/src/lib.hb") service_search := fn(): void { a := "\{01}\0" diff --git a/sysdata/programs/time_driver/meta.toml b/sysdata/programs/time_driver/meta.toml deleted file mode 100644 index 84cc97e..0000000 --- a/sysdata/programs/time_driver/meta.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "time_driver" -authors = ["SamBuckley"] - -[dependants.libraries] - -[dependants.binaries] -hblang.version = "1.0.0" - -[build] -command = "hblang src/main.hb" diff --git a/sysdata/programs/time_driver/src/main.hb b/sysdata/programs/time_driver/src/main.hb deleted file mode 100644 index 45e752b..0000000 --- a/sysdata/programs/time_driver/src/main.hb +++ /dev/null @@ -1,22 +0,0 @@ -stn := @use("../../../libraries/stn/src/lib.hb") -log := stn.log -mem := stn.memory -s := stn.string -page := 0 - -main := fn(): void { - page += mem.request_page(1) - port_str := "\0\0\{47}\0" - a := @eca(u8, 3, 3, port_str, 4) - - n := 5000000 - loop { - if n == 0 break - n -= 1 - stack_reclamation_edge_case := 0 - } - td := s.display_int(a, page) - log.debug(td) - - return -} \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 2d19bf8..ee0625c 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -23,9 +23,6 @@ resolution = "1024x768x24" [boot.limine.ableos.modules.a_serial_driver] path = "boot:///a_serial_driver.hbf" -[boot.limine.ableos.modules.ps2_driver] -path = "boot:///ps2_driver.hbf" - [boot.limine.ableos.modules.diskio_driver] path = "boot:///diskio_driver.hbf" From e3f7a2d45503988784cdea9026f5dce64593f581 Mon Sep 17 00:00:00 2001 From: koniifer Date: Mon, 2 Sep 2024 04:36:03 +0100 Subject: [PATCH 09/12] inline fb_driver, update to latest hblang --- Cargo.lock | 10 +++--- sysdata/libraries/stn/src/buffer.hb | 6 ++-- sysdata/libraries/stn/src/log.hb | 2 +- sysdata/libraries/stn/src/string.hb | 33 ++++++------------- sysdata/programs/diskio_driver/src/main.hb | 3 +- sysdata/programs/fb_driver/src/draw.hb | 30 ++++++++--------- .../fb_driver/src/examples/buffers.hb | 19 +++++++++++ .../fb_driver/src/examples/front_buffer.hb | 19 ----------- .../programs/fb_driver/src/examples/random.hb | 17 ++++++++++ sysdata/programs/fb_driver/src/lib.hb | 31 +++++++---------- sysdata/programs/fb_driver/src/main.hb | 4 +-- .../programs/serial_driver_test/src/main.hb | 2 +- 12 files changed, 85 insertions(+), 91 deletions(-) create mode 100644 sysdata/programs/fb_driver/src/examples/buffers.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/front_buffer.hb create mode 100644 sysdata/programs/fb_driver/src/examples/random.hb diff --git a/Cargo.lock b/Cargo.lock index 5bfd9b7..0e74d59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -444,17 +444,17 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#641be15703153386fef1a6b083a7e00c85414df9" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#f172c332478f54839ea8b3814883ffa7ac29b5b1" [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#641be15703153386fef1a6b083a7e00c85414df9" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#f172c332478f54839ea8b3814883ffa7ac29b5b1" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#641be15703153386fef1a6b083a7e00c85414df9" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#f172c332478f54839ea8b3814883ffa7ac29b5b1" dependencies = [ "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -462,7 +462,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#641be15703153386fef1a6b083a7e00c85414df9" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#f172c332478f54839ea8b3814883ffa7ac29b5b1" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -470,7 +470,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#641be15703153386fef1a6b083a7e00c85414df9" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#f172c332478f54839ea8b3814883ffa7ac29b5b1" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)", ] diff --git a/sysdata/libraries/stn/src/buffer.hb b/sysdata/libraries/stn/src/buffer.hb index fd8b0aa..ef5bf71 100644 --- a/sysdata/libraries/stn/src/buffer.hb +++ b/sysdata/libraries/stn/src/buffer.hb @@ -5,19 +5,19 @@ receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u } send_message := fn(msg: ^u8, buffer_id: int): void { - msg_length := string.length(msg) + msg_length := @inline(string.length, msg) @eca(i32, 3, buffer_id, msg, msg_length) return } create := fn(msg: ^u8): int { - msg_length := string.length(msg); + msg_length := @inline(string.length, msg); *msg = 0 return @eca(int, 3, 0, msg, msg_length) } search := fn(msg: ^u8): int { - msg_length := string.length(msg); + msg_length := @inline(string.length, msg); *msg = 3 return @eca(int, 3, 0, msg, msg_length) diff --git a/sysdata/libraries/stn/src/log.hb b/sysdata/libraries/stn/src/log.hb index 42cf4a6..d643d76 100644 --- a/sysdata/libraries/stn/src/log.hb +++ b/sysdata/libraries/stn/src/log.hb @@ -2,7 +2,7 @@ string := @use("rel:string.hb") buffer := @use("rel:buffer.hb") log := fn(message: ^u8, level: u8): void { - message_length := string.length(message); + message_length := @inline(string.length, message); *(message + message_length) = level @eca(i32, 3, 1, message, message_length + 1) return diff --git a/sysdata/libraries/stn/src/string.hb b/sysdata/libraries/stn/src/string.hb index 260b03a..e4ba668 100644 --- a/sysdata/libraries/stn/src/string.hb +++ b/sysdata/libraries/stn/src/string.hb @@ -1,51 +1,38 @@ length := fn(ptr: ^u8): int { len := 0 - loop if *ptr == 0 break else { - len += 1 - ptr += 1 - } + loop if *(ptr + len) == 0 break else len += 1 return len } display_int := fn(num: int, p: ^u8): ^u8 { i := 0 if num == 0 { - set(p, 48) + *p = 48 return p } - loop { - if num == 0 break - set(p + i, num % 10 + 48) + loop if num == 0 break else { + *(p + i) = num % 10 + 48 num /= 10 i += 1 } - reverse(p) - //null terminate - set(p + i, 0) + @inline(reverse, p); + *(p + i) = 0 return p } reverse := fn(s: ^u8): void { //reverse a string, don't remove digits len := 0 - loop { - if *(s + len) == 0 break - len += 1 - } + loop if *(s + len) == 0 break else len += 1 i := 0 j := len - 1 - loop { - if i >= j break - temp := *(s + i); + temp := 0 + loop if i >= j break else { + temp = *(s + i); *(s + i) = *(s + j); *(s + j) = temp i += 1 j -= 1 } return -} - -set := fn(change: ^u8, new: int): void { - *change = new - return } \ No newline at end of file diff --git a/sysdata/programs/diskio_driver/src/main.hb b/sysdata/programs/diskio_driver/src/main.hb index dd0ddf2..1800402 100644 --- a/sysdata/programs/diskio_driver/src/main.hb +++ b/sysdata/programs/diskio_driver/src/main.hb @@ -1,5 +1,4 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); -.{log, string, memory, buffer} := stn +.{memory, buffer} := @use("../../../libraries/stn/src/lib.hb") main := fn(): int { // shuts down ableOS diff --git a/sysdata/programs/fb_driver/src/draw.hb b/sysdata/programs/fb_driver/src/draw.hb index 9faf24a..089dc38 100644 --- a/sysdata/programs/fb_driver/src/draw.hb +++ b/sysdata/programs/fb_driver/src/draw.hb @@ -1,13 +1,13 @@ -.{draw_pixel, screenidx, Transform, Point, Rect, Buffer, FB_WIDTH} := @use("rel:lib.hb") -ColorBGRA := @use("rel:color.hb").ColorBGRA -math := @use("../../../libraries/stn/src/lib.hb").math +.{draw_pixel, screenidx, Transform, Point, Rect, Buffer, FB_WIDTH} := @use("rel:lib.hb"); +.{math} := @use("../../../libraries/stn/src/lib.hb"); +.{ColorBGRA} := @use("rel:color.hb") /* draws a filled rectangle to the screen will be optimised later */ rect_fill := fn(buffer: Buffer, pos: Point, tr: Transform, color: ColorBGRA): void { n := 0 loop if n == tr.height * tr.width break else { - *(buffer.write + screenidx(.(n % tr.width + pos.x, n / tr.width + pos.y))) = color + *(buffer.write + @inline(screenidx, .(n % tr.width + pos.x, n / tr.width + pos.y))) = color n += 1 } return @@ -22,13 +22,13 @@ rect_line := fn(buffer: Buffer, pos: Point, tr: Transform, color: ColorBGRA, thi y = pos.y x = pos.x loop if y == pos.y + tr.height break else { - *(buffer.write + pos.x + t + FB_WIDTH * y) = color; - *(buffer.write + pos.x + tr.width - t + FB_WIDTH * y) = color + *(buffer.write + @inline(screenidx, .(pos.x + t, y))) = color; + *(buffer.write + @inline(screenidx, .(pos.x + tr.width - t, y))) = color y += 1 } loop if x == pos.x + tr.width break else { - *(buffer.write + x + (pos.y + t) * FB_WIDTH) = color; - *(buffer.write + x + (pos.y + tr.height - t) * FB_WIDTH) = color + *(buffer.write + @inline(screenidx, .(x, pos.y + t))) = color; + *(buffer.write + @inline(screenidx, .(x, pos.y + tr.height - t))) = color x += 1 } t += 1 @@ -49,7 +49,7 @@ line_low := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA): void { y := p0.y x := p0.x loop if x == p1.x break else { - *(buffer.write + x + y * FB_WIDTH) = color + *(buffer.write + @inline(screenidx, .(x, y))) = color if D > 0 { y += yi D += 2 * (dy - dx) @@ -73,7 +73,7 @@ line_high := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA): void { x := p0.x y := p0.y loop if y == p1.y break else { - *(buffer.write + x + y * FB_WIDTH) = color + *(buffer.write + @inline(screenidx, .(x, y))) = color if D > 0 { x += xi D += 2 * (dx - dy) @@ -88,17 +88,17 @@ line_high := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA): void { /* implementation of Bresenham's line algorithm TODO: thickness, might need better math library */ line := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA, thickness: int): void { - if math.abs(p1.y - p0.y) < math.abs(p1.x - p0.x) { + if @inline(math.abs, p1.y - p0.y) < @inline(math.abs, p1.x - p0.x) { if p0.x > p1.x { - line_low(buffer, p1, p0, color) + @inline(line_low, buffer, p1, p0, color) } else { - line_low(buffer, p0, p1, color) + @inline(line_low, buffer, p0, p1, color) } } else { if p0.y > p1.y { - line_high(buffer, p1, p0, color) + @inline(line_high, buffer, p1, p0, color) } else { - line_high(buffer, p0, p1, color) + @inline(line_high, buffer, p0, p1, color) } } return diff --git a/sysdata/programs/fb_driver/src/examples/buffers.hb b/sysdata/programs/fb_driver/src/examples/buffers.hb new file mode 100644 index 0000000..4157408 --- /dev/null +++ b/sysdata/programs/fb_driver/src/examples/buffers.hb @@ -0,0 +1,19 @@ +.{front_buffer_ptr, front_buffer_copy, get_front_buffer, Buffer} := @use("../lib.hb"); + +example := fn(): void { + // you can get the raw frontbuffer pointer using + raw_buffer := front_buffer_ptr + // this buffer is the one that you write individual pixels to + + // you can gete the copy frontbuffer pointer using + copy_buffer := front_buffer_copy + /* this buffer is used for massive writing + operations by taking advantage of + static copying */ + + // you can construct a buffer like so + buffer := Buffer.{write: raw_buffer, copy: copy_buffer} + // this is the operation that get_front_buffer does + same_buffer := get_front_buffer() + return +} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/front_buffer.hb b/sysdata/programs/fb_driver/src/examples/front_buffer.hb deleted file mode 100644 index 8c1bf5a..0000000 --- a/sysdata/programs/fb_driver/src/examples/front_buffer.hb +++ /dev/null @@ -1,19 +0,0 @@ -.{front_buffer_ptr, front_buffer_copy, get_front_buffer, Buffer} := @use("../lib.hb"); - -example := fn(): void { - // you can get the raw frontbuffer pointer using - raw_buffer := front_buffer_ptr - // this buffer is the one that you write individual pixels to - - // you can gete the copy frontbuffer pointer using - copy_buffer := copy_buffer_ptr - /* this buffer is used for massive writing - operations by taking advantage of - static copying */ - - // you can construct a buffer like so - buffer := Buffer.{write: raw_buffer, copy: copy_buffer} - // this is the operation that get_front_buffer does - same_buffer := get_front_buffer() - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/random.hb b/sysdata/programs/fb_driver/src/examples/random.hb new file mode 100644 index 0000000..75ecb81 --- /dev/null +++ b/sysdata/programs/fb_driver/src/examples/random.hb @@ -0,0 +1,17 @@ +.{clear, get_front_buffer, screenidx} := @use("../lib.hb"); +.{ColorBGRA} := @use("../color.hb"); +.{random} := @use("../../../../libraries/stn/src/lib.hb") + +example := fn(): void { + buffer := get_front_buffer() + clear(buffer) + loop { + x := random.integer(0, 1024) + y := random.integer(0, 768) + r := random.integer(0, 255) + g := random.integer(0, 75) + b := random.integer(0, 155); + *(buffer.write + @inline(screenidx, .(x, y))) = ColorBGRA.(b, g, r, 255) + } + return +} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/lib.hb b/sysdata/programs/fb_driver/src/lib.hb index 02c88c5..ca91a63 100644 --- a/sysdata/programs/fb_driver/src/lib.hb +++ b/sysdata/programs/fb_driver/src/lib.hb @@ -1,4 +1,4 @@ -.{memory, log, math} := @use("../../../libraries/stn/src/lib.hb"); +.{memory, math} := @use("../../../libraries/stn/src/lib.hb"); .{ColorBGRA, blend} := @use("rel:color.hb") FB_WIDTH := 1024 @@ -14,29 +14,27 @@ TOTAL_PAGES := 1 + FB_BYTES >> 12 Buffer := struct {write: ^ColorBGRA, copy: ^[ColorBGRA; COPY_PIXELS]} Point := struct {x: int, y: int} Transform := struct {width: int, height: int} -Rect := struct {p1: Point, p2: Point} front_buffer_ptr := @as(^ColorBGRA, @bitcast(0xFFFF8000C0000000)) front_buffer_copy := @as(^[ColorBGRA; COPY_PIXELS], @bitcast(front_buffer_ptr)) get_front_buffer := fn(): Buffer { // trying to return front_buffer_ptr or front_buffer_copy causes reg id leak - return Buffer.{write: @as(^ColorBGRA, @bitcast(0xFFFF8000C0000000)), copy: @as(^[ColorBGRA; COPY_PIXELS], @bitcast(0xFFFF8000C0000000))} + buffer := Buffer.{write: front_buffer_ptr, copy: front_buffer_copy} + return buffer } /* this is separate to create_raw_buffer because returning a Buffer from create_raw_buffer causes reg id leak */ create_buffer := fn(): Buffer { - ptr := create_raw_buffer() - ptr_copy := @as(^[ColorBGRA; COPY_PIXELS], @bitcast(ptr)) - // same here, bitcasting inside the struct literal causes reg id leak - buffer := Buffer.{write: ptr, copy: ptr_copy} + ptr := @inline(create_raw_buffer) + buffer := Buffer.{write: ptr, copy: @as(^[ColorBGRA; COPY_PIXELS], @bitcast(ptr))} return buffer } create_raw_buffer := fn(): ^ColorBGRA { if TOTAL_PAGES <= 0xFF { - return @bitcast(memory.request_page(TOTAL_PAGES)) + return @bitcast(@inline(memory.request_page, TOTAL_PAGES)) } - ptr := memory.request_page(255) + ptr := @inline(memory.request_page, 255) remaining := TOTAL_PAGES - 0xFF loop if remaining <= 0 break else { if remaining < 0xFF { @@ -66,11 +64,11 @@ clear := fn(buffer: Buffer, color: ColorBGRA): void { } // only required to be called when using a back buffer. if using single-buffered rendering, do not call this. present := fn(buffer: Buffer): void { - offset := 0 + n := 0 // copy chunks of the read buffer to the front buffer - loop if offset >= PARTITIONS break else { - *(front_buffer_copy + offset) = *(buffer.copy + offset) - offset += 1 + loop if n >= PARTITIONS break else { + *(front_buffer_copy + n) = *(buffer.copy + n) + n += 1 } return } @@ -85,13 +83,6 @@ composite := fn(buffer1: Buffer, buffer2: Buffer): void { } return } -// really need to be able to inline this please - aurlex screenidx := fn(pos: Point): int { return pos.x + FB_WIDTH * pos.y -} -point2rect := fn(pos: Point, tr: Transform): Rect { - return .(pos, .(pos.x + tr.x, pos.y + tr.y)) -} -rect2point := fn(rect: Rect): struct {point: Point, transform: Transform} { - return .(.(0, 0), .(0, 0)) } \ 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 ab3726b..e1c71c2 100644 --- a/sysdata/programs/fb_driver/src/main.hb +++ b/sysdata/programs/fb_driver/src/main.hb @@ -1,6 +1,6 @@ -.{example} := @use("./examples/colors.hb") +.{example} := @use("./examples/lines.hb") main := fn(): int { - example() + @inline(example) return 0 } \ No newline at end of file diff --git a/sysdata/programs/serial_driver_test/src/main.hb b/sysdata/programs/serial_driver_test/src/main.hb index da3b881..a9af0fa 100644 --- a/sysdata/programs/serial_driver_test/src/main.hb +++ b/sysdata/programs/serial_driver_test/src/main.hb @@ -5,7 +5,7 @@ log_info := fn(): void { if a == 0 { } else { msg := "XABC\0" - msg_length := string.length(msg) + msg_length := @inline(string.length, msg) @eca(void, 3, a, msg, msg_length) } From a7517005de4d981b18d2432578dd76221116d826 Mon Sep 17 00:00:00 2001 From: koniifer Date: Wed, 4 Sep 2024 16:08:01 +0100 Subject: [PATCH 10/12] update to latest hblang --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e74d59..a6a454e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,9 +160,9 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cc" -version = "1.1.15" +version = "1.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" +checksum = "e9d013ecb737093c0e86b151a7b837993cf9ec6c502946cfb44bedc392421e0b" dependencies = [ "shlex", ] @@ -444,17 +444,17 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#f172c332478f54839ea8b3814883ffa7ac29b5b1" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#894f73ca35199f524dff6160c57c0916169fbaf6" [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#f172c332478f54839ea8b3814883ffa7ac29b5b1" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#894f73ca35199f524dff6160c57c0916169fbaf6" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#f172c332478f54839ea8b3814883ffa7ac29b5b1" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#894f73ca35199f524dff6160c57c0916169fbaf6" dependencies = [ "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -462,7 +462,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#f172c332478f54839ea8b3814883ffa7ac29b5b1" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#894f73ca35199f524dff6160c57c0916169fbaf6" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -470,7 +470,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#f172c332478f54839ea8b3814883ffa7ac29b5b1" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#894f73ca35199f524dff6160c57c0916169fbaf6" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)", ] From 1a2b60b53bd3a9bb807a4f43af2b5fd9c8ada32c Mon Sep 17 00:00:00 2001 From: mlokr Date: Wed, 4 Sep 2024 19:14:30 +0200 Subject: [PATCH 11/12] foo --- Cargo.lock | 6 +++--- kernel/src/holeybytes/ecah.rs | 3 ++- .../kernel_services/service_definition_service.rs | 3 +++ repbuild/src/dev.rs | 14 +++++++++++--- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6a454e..0fadff6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -444,7 +444,7 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#894f73ca35199f524dff6160c57c0916169fbaf6" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741" [[package]] name = "hbbytecode" @@ -454,7 +454,7 @@ source = "git+https://git.ablecorp.us/ableos/holey-bytes#894f73ca35199f524dff616 [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#894f73ca35199f524dff6160c57c0916169fbaf6" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741" dependencies = [ "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -462,7 +462,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#894f73ca35199f524dff6160c57c0916169fbaf6" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 548ddeb..f4f162c 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -74,7 +74,7 @@ pub fn handler(vm: &mut Vm) { match buffer_id { 0 => match sds_msg_handler(vm, mem_addr, length) { Ok(()) => {} - Err(err) => log::error!("Improper sds format"), + Err(err) => log::error!("Improper sds format: {err:?}"), }, 1 => match log_msg_handler(vm, mem_addr, length) { Ok(()) => {} @@ -285,6 +285,7 @@ fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogE #[derive(Debug)] pub enum LogError { + NoMessages, InvalidLogFormat, } use {alloc::vec, log::Record}; diff --git a/kernel/src/holeybytes/kernel_services/service_definition_service.rs b/kernel/src/holeybytes/kernel_services/service_definition_service.rs index 1a12447..547ac33 100644 --- a/kernel/src/holeybytes/kernel_services/service_definition_service.rs +++ b/kernel/src/holeybytes/kernel_services/service_definition_service.rs @@ -23,6 +23,9 @@ pub static SERVICES: Lazy> = Lazy::new(|| { pub fn sds_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { let mut msg_vec = block_read(mem_addr, length); + if msg_vec.is_empty() { + return Err(LogError::NoMessages); + } let sds_event_type: ServiceEventType = msg_vec[0].into(); msg_vec.remove(0); diff --git a/repbuild/src/dev.rs b/repbuild/src/dev.rs index 5c92480..67768e8 100644 --- a/repbuild/src/dev.rs +++ b/repbuild/src/dev.rs @@ -85,9 +85,17 @@ impl Package { Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => (), Err(e) => panic!("{}", e), } - let path = format!("target/programs/{}.hbf", self.name); - let mut file = File::create(path).unwrap(); - file.write_all(&bytes).unwrap(); + std::fs::write(format!("target/programs/{}.hbf", self.name), &bytes).unwrap(); + bytes.clear(); + let _ = hblang::run_compiler( + &path, + Options { + dump_asm: true, + ..Default::default() + }, + &mut bytes, + ); + std::fs::write(format!("target/programs/{}.hba", self.name), &bytes).unwrap(); } } } From f8c787397802d1ebf1ca1388e1fd43ecd26f80e2 Mon Sep 17 00:00:00 2001 From: koniifer Date: Fri, 13 Sep 2024 22:41:31 +0100 Subject: [PATCH 12/12] squash --- Cargo.lock | 777 ++++++++++-------- Cargo.toml | 8 +- kernel/Cargo.toml | 29 +- .../src/arch/aarch64/device_info_collector.rs | 4 +- kernel/src/arch/aarch64/logging.rs | 5 +- kernel/src/arch/aarch64/mod.rs | 31 +- kernel/src/arch/riscv64/memory.rs | 42 +- kernel/src/arch/riscv64/mod.rs | 12 +- kernel/src/arch/x86_64/gdt.rs | 25 +- kernel/src/arch/x86_64/interrupts.rs | 6 +- kernel/src/arch/x86_64/logging.rs | 7 +- kernel/src/arch/x86_64/mod.rs | 74 +- kernel/src/bootmodules.rs | 52 +- kernel/src/holeybytes/ecah.rs | 137 +-- .../holeybytes/kernel_services/mem_serve.rs | 77 +- kernel/src/holeybytes/kernel_services/mod.rs | 14 +- .../service_definition_service.rs | 32 +- kernel/src/holeybytes/mem.rs | 15 +- kernel/src/holeybytes/mod.rs | 115 ++- kernel/src/ipc/buffer.rs | 12 +- kernel/src/ipc/protocol.rs | 13 +- kernel/src/kmain.rs | 35 +- kernel/src/lib.rs | 15 +- kernel/src/logger.rs | 1 + kernel/src/memory.rs | 19 +- kernel/src/task.rs | 194 +++-- repbuild/Cargo.toml | 21 +- repbuild/src/dev.rs | 1 + repbuild/src/main.rs | 32 +- rust-toolchain.toml | 2 +- sysdata/libraries/render/README.md | 9 + sysdata/libraries/render/src/lib.hb | 47 ++ sysdata/libraries/render/src/software.hb | 263 ++++++ sysdata/libraries/render/src/svga.hb | 91 ++ sysdata/libraries/stn/src/lib.hb | 3 +- sysdata/libraries/stn/src/math.hb | 11 +- sysdata/libraries/stn/src/memory.hb | 18 +- sysdata/libraries/stn/src/pci.hb | 50 ++ sysdata/libraries/stn/src/random.hb | 11 +- sysdata/programs/diskio_driver/src/main.hb | 2 +- sysdata/programs/fb_driver/README.md | 2 - sysdata/programs/fb_driver/UNTESTED_FUNCTIONS | 7 - sysdata/programs/fb_driver/src/color.hb | 27 - sysdata/programs/fb_driver/src/draw.hb | 113 --- .../programs/fb_driver/src/examples/amogus.hb | 26 - .../fb_driver/src/examples/buffers.hb | 19 - .../programs/fb_driver/src/examples/colors.hb | 27 - .../programs/fb_driver/src/examples/lines.hb | 25 - .../programs/fb_driver/src/examples/random.hb | 17 - .../programs/fb_driver/src/examples/square.hb | 32 - .../programs/fb_driver/src/examples/strobe.hb | 20 - sysdata/programs/fb_driver/src/lib.hb | 88 -- sysdata/programs/fb_driver/src/main.hb | 6 - .../{fb_driver => render_example}/meta.toml | 4 +- .../render_example/src/examples/amogus.hb | 20 + .../render_example/src/examples/colors.hb | 21 + .../render_example/src/examples/lines.hb | 22 + .../render_example/src/examples/random.hb | 17 + .../render_example/src/examples/square.hb | 27 + .../render_example/src/examples/strobe.hb | 15 + .../render_example/src/examples/svga.hb | 8 + sysdata/programs/render_example/src/main.hb | 6 + .../README.md | 0 .../meta.toml | 2 +- .../src/main.hb | 3 +- .../programs/serial_driver_test/src/main.hb | 2 +- sysdata/system_config.toml | 12 +- 67 files changed, 1599 insertions(+), 1281 deletions(-) create mode 100644 sysdata/libraries/render/README.md create mode 100644 sysdata/libraries/render/src/lib.hb create mode 100644 sysdata/libraries/render/src/software.hb create mode 100644 sysdata/libraries/render/src/svga.hb create mode 100644 sysdata/libraries/stn/src/pci.hb delete mode 100644 sysdata/programs/fb_driver/README.md delete mode 100644 sysdata/programs/fb_driver/UNTESTED_FUNCTIONS delete mode 100644 sysdata/programs/fb_driver/src/color.hb delete mode 100644 sysdata/programs/fb_driver/src/draw.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/amogus.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/buffers.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/colors.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/lines.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/random.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/square.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/strobe.hb delete mode 100644 sysdata/programs/fb_driver/src/lib.hb delete mode 100644 sysdata/programs/fb_driver/src/main.hb rename sysdata/programs/{fb_driver => render_example}/meta.toml (71%) create mode 100644 sysdata/programs/render_example/src/examples/amogus.hb create mode 100644 sysdata/programs/render_example/src/examples/colors.hb create mode 100644 sysdata/programs/render_example/src/examples/lines.hb create mode 100644 sysdata/programs/render_example/src/examples/random.hb create mode 100644 sysdata/programs/render_example/src/examples/square.hb create mode 100644 sysdata/programs/render_example/src/examples/strobe.hb create mode 100644 sysdata/programs/render_example/src/examples/svga.hb create mode 100644 sysdata/programs/render_example/src/main.hb rename sysdata/programs/{a_serial_driver => serial_driver}/README.md (100%) rename sysdata/programs/{a_serial_driver => serial_driver}/meta.toml (84%) rename sysdata/programs/{a_serial_driver => serial_driver}/src/main.hb (90%) diff --git a/Cargo.lock b/Cargo.lock index 0fadff6..75c9a25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,40 +3,28 @@ version = 3 [[package]] -name = "able_graphics_library" -version = "0.1.2" -source = "git+https://git.ablecorp.us/ableos/ableos_userland#6c38f2b2f1f7f04b43a8def709de1da98cb5fba1" +name = "aarch64-cpu" +version = "9.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac42a04a61c19fc8196dd728022a784baecc5d63d7e256c01ad1b3fbfab26287" dependencies = [ - "embedded-graphics", - "log", - "versioning", + "tock-registers", ] [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "ahash" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "ahash" @@ -47,7 +35,7 @@ dependencies = [ "cfg-if", "once_cell", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -73,9 +61,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" [[package]] name = "autocfg" @@ -91,24 +79,24 @@ checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets", ] [[package]] name = "base64" -version = "0.21.7" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "beef" @@ -160,9 +148,9 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cc" -version = "1.1.16" +version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d013ecb737093c0e86b151a7b837993cf9ec6c502946cfb44bedc392421e0b" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" dependencies = [ "shlex", ] @@ -184,33 +172,7 @@ dependencies = [ "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.6", -] - -[[package]] -name = "clparse" -version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/ableos_userland#6c38f2b2f1f7f04b43a8def709de1da98cb5fba1" -dependencies = [ - "hashbrown 0.14.5", - "log", - "toml 0.5.9", -] - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", + "windows-targets", ] [[package]] @@ -236,15 +198,23 @@ checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "derive_more" -version = "0.99.18" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ - "convert_case", "proc-macro2", "quote", - "rustc_version", "syn", + "unicode-xid", ] [[package]] @@ -256,9 +226,9 @@ dependencies = [ [[package]] name = "embedded-graphics" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "750082c65094fbcc4baf9ba31583ce9a8bb7f52cadfb96f6164b1bc7f922f32b" +checksum = "0649998afacf6d575d126d83e68b78c0ab0e00ca2ac7e9b3db11b4cbe8274ef0" dependencies = [ "az", "byteorder", @@ -269,21 +239,23 @@ dependencies = [ [[package]] name = "embedded-graphics-core" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b1239db5f3eeb7e33e35bd10bd014e7b2537b17e071f726a09351431337cfa" +checksum = "ba9ecd261f991856250d2207f6d8376946cd9f412a2165d3b75bc87a0bc7a044" dependencies = [ "az", "byteorder", ] [[package]] -name = "encoding_rs" -version = "0.8.34" +name = "enumn" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ - "cfg-if", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -294,9 +266,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "error-stack" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27a72baa257b5e0e2de241967bc5ee8f855d6072351042688621081d66b2a76b" +checksum = "fe413319145d1063f080f27556fd30b1d70b01e2ba10c2a6e40d4be982ffc5d1" dependencies = [ "anyhow", "rustc_version", @@ -316,9 +288,9 @@ dependencies = [ [[package]] name = "float-cmp" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1267f4ac4f343772758f7b1bdcbe767c218bbab93bb432acbf5162bbf85a6c4" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" dependencies = [ "num-traits", ] @@ -345,6 +317,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -379,6 +352,7 @@ checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-io", + "futures-sink", "futures-task", "memchr", "pin-project-lite", @@ -399,37 +373,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" - -[[package]] -name = "h2" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.8", -] +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "hashbrown" @@ -437,24 +383,24 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash 0.8.11", + "ahash", "allocator-api2", ] [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#894f73ca35199f524dff6160c57c0916169fbaf6" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" dependencies = [ "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -462,7 +408,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -470,7 +416,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#894f73ca35199f524dff6160c57c0916169fbaf6" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)", ] @@ -483,9 +429,9 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "http" -version = "0.2.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", @@ -494,12 +440,24 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.6" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", "pin-project-lite", ] @@ -509,48 +467,61 @@ version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - [[package]] name = "hyper" -version = "0.14.30" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", - "futures-core", "futures-util", - "h2", "http", "http-body", "httparse", - "httpdate", "itoa", "pin-project-lite", - "socket2", + "smallvec", "tokio", - "tower-service", - "tracing", "want", ] [[package]] name = "hyper-rustls" -version = "0.24.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http", "hyper", + "hyper-util", "rustls", + "rustls-pki-types", "tokio", "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -593,14 +564,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown", ] [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "itoa" @@ -621,17 +592,14 @@ dependencies = [ name = "kernel" version = "0.2.0" dependencies = [ - "able_graphics_library", - "clparse", + "aarch64-cpu", "crossbeam-queue", "derive_more", "embedded-graphics", - "hashbrown 0.14.5", + "hashbrown", "hbvm 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)", - "kiam", "limine", "log", - "rdrand", "sbi", "slab", "spin", @@ -639,16 +607,10 @@ dependencies = [ "versioning", "virtio-drivers", "x2apic", - "x86_64", + "x86_64 0.15.1", "xml", ] -[[package]] -name = "kiam" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0fc32485e41ae5e9dedd1442f36dec998431adc9f321224c2c5d645f38fdcb" - [[package]] name = "lazy_static" version = "1.5.0" @@ -724,9 +686,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "micromath" -version = "1.1.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc4010833aea396656c2f91ee704d51a6f1329ec2ab56ffd00bfd56f7481ea94" +checksum = "c3c8dda44ff03a2f238717214da50f65d5a53b45cd213a7370424ffdb6fae815" [[package]] name = "mime" @@ -736,11 +698,11 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] @@ -791,6 +753,26 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.14" @@ -803,6 +785,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -812,6 +803,54 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quinn" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +dependencies = [ + "bytes", + "rand", + "ring", + "rustc-hash", + "rustls", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.59.0", +] + [[package]] name = "quote" version = "1.0.37" @@ -821,11 +860,35 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] [[package]] name = "raw-cpuid" @@ -836,15 +899,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "rdrand" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d92195228612ac8eed47adbc2ed0f04e513a4ccb98175b6f2bd04d963b533655" -dependencies = [ - "rand_core", -] - [[package]] name = "regex-syntax" version = "0.8.4" @@ -861,25 +915,26 @@ dependencies = [ "hblang", "reqwest", "str-reader", - "toml 0.5.11", + "toml", ] [[package]] name = "reqwest" -version = "0.11.27" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ "base64", "bytes", - "encoding_rs", + "futures-channel", "futures-core", "futures-util", - "h2", "http", "http-body", + "http-body-util", "hyper", "hyper-rustls", + "hyper-util", "ipnet", "js-sys", "log", @@ -887,13 +942,14 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "quinn", "rustls", "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", - "system-configuration", "tokio", "tokio-rustls", "tower-service", @@ -902,7 +958,7 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots", - "winreg", + "windows-registry", ] [[package]] @@ -926,6 +982,12 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc_version" version = "0.4.1" @@ -937,32 +999,42 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.12" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ - "log", + "once_cell", "ring", + "rustls-pki-types", "rustls-webpki", - "sct", + "subtle", + "zeroize", ] [[package]] name = "rustls-pemfile" -version = "1.0.4" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ "base64", + "rustls-pki-types", ] [[package]] -name = "rustls-webpki" -version = "0.101.7" +name = "rustls-pki-types" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" + +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring", + "rustls-pki-types", "untrusted", ] @@ -990,16 +1062,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "semver" version = "1.0.23" @@ -1008,18 +1070,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -1028,9 +1090,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.127" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -1038,6 +1100,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1065,6 +1136,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + [[package]] name = "socket2" version = "0.5.7" @@ -1090,6 +1167,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6aa20b89aec46e0bffbb8756e089beb4c43bbec53d0667de34212f048bdab10" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.77" @@ -1103,29 +1186,31 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "0.1.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", + "futures-core", ] [[package]] -name = "system-configuration-sys" -version = "0.5.0" +name = "thiserror" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ - "core-foundation-sys", - "libc", + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1143,6 +1228,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tock-registers" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "696941a0aee7e276a165a978b37918fd5d22c55c3d6bda197813070ca9c0f21c" + [[package]] name = "tokio" version = "1.40.0" @@ -1160,44 +1251,69 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.1" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ "rustls", + "rustls-pki-types", "tokio", ] [[package]] -name = "tokio-util" -version = "0.7.11" +name = "toml" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ - "bytes", "futures-core", - "futures-sink", + "futures-util", + "pin-project", "pin-project-lite", "tokio", + "tower-layer", + "tower-service", ] [[package]] -name = "toml" -version = "0.5.9" -source = "git+https://git.ablecorp.us/asya/toml-rs#4379150168e87103739a196566a7ce17ff245f01" -dependencies = [ - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "toml" -version = "0.5.11" +name = "tower-layer" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" @@ -1232,13 +1348,13 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "uart_16550" -version = "0.2.19" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614ff2a87880d4bd4374722268598a970bbad05ced8bf630439417347254ab2e" +checksum = "4922792855b1bce30997fbaa5418597902c278a92d20dfe348e6f062c3bd861d" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "rustversion", - "x86_64", + "x86", ] [[package]] @@ -1249,9 +1365,9 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" @@ -1262,6 +1378,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-xid" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" + [[package]] name = "untrusted" version = "0.9.0" @@ -1295,13 +1417,14 @@ dependencies = [ [[package]] name = "virtio-drivers" -version = "0.4.0" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42299957c6f61af586fe3eae398c16ec07f33a02579fa1d41ae96156ce437029" +checksum = "d6a39747311dabb3d37807037ed1c3c38d39f99198d091b5b79ecd5c8d82f799" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", + "enumn", "log", - "zerocopy 0.6.6", + "zerocopy", ] [[package]] @@ -1404,9 +1527,12 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.4" +version = "0.26.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" +dependencies = [ + "rustls-pki-types", +] [[package]] name = "windows-core" @@ -1414,16 +1540,37 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] -name = "windows-sys" -version = "0.48.0" +name = "windows-registry" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ - "windows-targets 0.48.5", + "windows-result", + "windows-strings", + "windows-targets", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets", ] [[package]] @@ -1432,22 +1579,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] -name = "windows-targets" -version = "0.48.5" +name = "windows-sys" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -1456,46 +1597,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1508,48 +1631,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -1557,13 +1656,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "winreg" -version = "0.50.0" +name = "winnow" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ - "cfg-if", - "windows-sys 0.48.0", + "memchr", ] [[package]] @@ -1576,7 +1674,18 @@ dependencies = [ "bitflags 1.3.2", "paste", "raw-cpuid", - "x86_64", + "x86_64 0.14.12", +] + +[[package]] +name = "x86" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385" +dependencies = [ + "bit_field", + "bitflags 1.3.2", + "raw-cpuid", ] [[package]] @@ -1591,6 +1700,18 @@ dependencies = [ "volatile", ] +[[package]] +name = "x86_64" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bc79523af8abf92fb1a970c3e086c5a343f6bcc1a0eb890f575cbb3b45743df" +dependencies = [ + "bit_field", + "bitflags 2.6.0", + "rustversion", + "volatile", +] + [[package]] name = "xml" version = "0.1.0" @@ -1599,34 +1720,14 @@ dependencies = [ "serde", ] -[[package]] -name = "zerocopy" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" -dependencies = [ - "byteorder", - "zerocopy-derive 0.6.6", -] - [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy-derive" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "byteorder", + "zerocopy-derive", ] [[package]] @@ -1639,3 +1740,9 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/Cargo.toml b/Cargo.toml index 85e0ede..38799da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,9 @@ [workspace] resolver = "2" -members = [ "dev","kernel", "repbuild"] +members = ["dev", "kernel", "repbuild"] + +# [profile.release] +# strip = "symbols" +# codegen-units = 1 +# lto = true +# panic = "abort" diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 27c8c8b..d1764db 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -5,17 +5,16 @@ version = "0.2.0" [dependencies] -embedded-graphics = "0.7" +embedded-graphics = "0.8" hbvm.git = "https://git.ablecorp.us/ableos/holey-bytes" log = "0.4" spin = "0.9" -uart_16550 = "0.2" slab = { version = "0.4", default-features = false } +uart_16550 = { version = "0.3", features = ["nightly"] } xml.git = "https://git.ablecorp.us/ableos/ableos_userland" versioning.git = "https://git.ablecorp.us/ableos/ableos_userland" -able_graphics_library.git = "https://git.ablecorp.us/ableos/ableos_userland" -hashbrown = "*" -kiam = "0.1.1" +# able_graphics_library.git = "https://git.ablecorp.us/ableos/ableos_userland" +hashbrown = { version = "0.14", features = ["nightly"] } [dependencies.limine] version = "0.1" @@ -24,14 +23,14 @@ version = "0.1" [dependencies.crossbeam-queue] version = "0.3" default-features = false -features = ["alloc"] +features = ["alloc", "nightly"] -[dependencies.clparse] -git = "https://git.ablecorp.us/ableos/ableos_userland" -default-features = false +# [dependencies.clparse] +# git = "https://git.ablecorp.us/ableos/ableos_userland" +# default-features = false [dependencies.derive_more] -version = "0.99" +version = "1" default-features = false features = [ "add", @@ -48,12 +47,12 @@ features = [ [target.'cfg(target_arch = "x86_64")'.dependencies] -x86_64 = "0.14" +x86_64 = "0.15" x2apic = "0.4" -virtio-drivers = "0.4.0" -# rdrand = "*" -rdrand = { version = "0.8", default-features = false } - +virtio-drivers = "0.7" [target.'cfg(target_arch = "riscv64")'.dependencies] sbi = "0.2.0" + +[target.'cfg(target_arch = "aarch64")'.dependencies] +aarch64-cpu = "9" diff --git a/kernel/src/arch/aarch64/device_info_collector.rs b/kernel/src/arch/aarch64/device_info_collector.rs index dd200d3..c17d5d1 100644 --- a/kernel/src/arch/aarch64/device_info_collector.rs +++ b/kernel/src/arch/aarch64/device_info_collector.rs @@ -29,7 +29,7 @@ fn collect_cpu_info(device_tree: &mut DeviceTree) { } fn cpu_id() -> (String, u64) { - let mut cpu_id: u64 = 0; + let mut cpu_id: u64; unsafe { asm!("mrs {cpu_id}, MIDR_EL1", cpu_id = out(reg) cpu_id, @@ -41,6 +41,8 @@ fn cpu_id() -> (String, u64) { // https://raspberrypi.stackexchange.com/questions/117175/how-do-i-read-the-cpuid-in-aarch64-asm 0x410FD034 => "Cortex-A53".to_string(), 0x410FD083 => "Cortex-A72".to_string(), + // the source of this one was checking the cpu id :thinking: + 0x410FD493 => "Neoverse N2".to_string(), _ => "Unknown".to_string(), }; log::trace!("CPU Name: {cpu_name} - CPU ID: 0x{:X}", cpu_id); diff --git a/kernel/src/arch/aarch64/logging.rs b/kernel/src/arch/aarch64/logging.rs index 5db9bc0..20e73f8 100644 --- a/kernel/src/arch/aarch64/logging.rs +++ b/kernel/src/arch/aarch64/logging.rs @@ -1,5 +1,5 @@ use {crate::logger::TERMINAL_LOGGER, core::fmt::Write, spin::Mutex}; -const SERIAL_CONSOLE: Mutex = Mutex::new(SerialConsole { +static SERIAL_CONSOLE: Mutex = Mutex::new(SerialConsole { uart: 0x09000000 as *mut u8, }); @@ -17,6 +17,9 @@ impl core::fmt::Write for SerialConsole { } } +unsafe impl Sync for SerialConsole {} +unsafe impl Send for SerialConsole {} + pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result { SERIAL_CONSOLE.lock().write_fmt(args)?; TERMINAL_LOGGER.lock().write_fmt(args)?; diff --git a/kernel/src/arch/aarch64/mod.rs b/kernel/src/arch/aarch64/mod.rs index 793288a..a69e1ee 100644 --- a/kernel/src/arch/aarch64/mod.rs +++ b/kernel/src/arch/aarch64/mod.rs @@ -1,6 +1,7 @@ pub use logging::log; use { crate::{allocator, bootmodules::BootModule, kmain::kmain}, + alloc::vec::Vec, core::arch::asm, limine::FramebufferRequest, }; @@ -41,7 +42,7 @@ unsafe extern "C" fn _kernel_start() -> ! { static KFILE_REQ: KernelFileRequest = KernelFileRequest::new(0); static MOD_REQ: ModuleRequest = ModuleRequest::new(0); - let mut bootmodules = alloc::vec::Vec::new(); + let mut bootmodules = Vec::new(); if bm.is_some() { let bm = bm.unwrap(); @@ -52,18 +53,13 @@ unsafe extern "C" fn _kernel_start() -> ! { let raw_bytes = core::slice::from_raw_parts( file.base.as_ptr().expect("invalid initrd"), file.length as usize, - ) - .to_vec(); - - let file_path = alloc::string::String::from_utf8( - file.path.to_str().unwrap().to_bytes().to_vec(), ); + + let file_path = file.path.to_str().unwrap().to_str(); if file_path.is_err() { panic!("invalid file path: {:?}", file_path); } - let file_cmd = alloc::string::String::from_utf8( - file.cmdline.to_str().unwrap().to_bytes().to_vec(), - ); + let file_cmd = file.cmdline.to_str().unwrap().to_str(); if file_cmd.is_err() { panic!("invalid module cmd: {:?}", file_cmd); } @@ -85,7 +81,7 @@ unsafe extern "C" fn _kernel_start() -> ! { assert_eq!(bm.module_count, bootmodules.len() as u64); } - crate::kmain::kmain( + kmain( KFILE_REQ .get_response() .get() @@ -99,8 +95,6 @@ unsafe extern "C" fn _kernel_start() -> ! { .unwrap_or_default(), bootmodules, ); - - spin_loop(); } pub fn spin_loop() -> ! { @@ -109,8 +103,19 @@ pub fn spin_loop() -> ! { } } +/// I am sorry. +static mut A_REAL_RANDOM_U64_I_PROMISE: u64 = 0; + pub fn hardware_random_u64() -> u64 { - 0 + if let Some(rng) = aarch64_cpu::asm::random::ArmRng::new() { + if let Some(rnd) = rng.rndr() { + return rnd; + } + } + unsafe { + A_REAL_RANDOM_U64_I_PROMISE += 1; + A_REAL_RANDOM_U64_I_PROMISE + } } pub fn register_dump() {} diff --git a/kernel/src/arch/riscv64/memory.rs b/kernel/src/arch/riscv64/memory.rs index b6411d7..a4859ae 100644 --- a/kernel/src/arch/riscv64/memory.rs +++ b/kernel/src/arch/riscv64/memory.rs @@ -1,8 +1,10 @@ use core::num; -use alloc::boxed::Box; -use spin::{Mutex, Once}; -use crate::memory::{MemoryManager, PhysicalAddress, VirtualAddress}; +use { + crate::memory::{MemoryManager, PhysicalAddress, VirtualAddress}, + alloc::boxed::Box, + spin::{Mutex, Once}, +}; use super::PAGE_SIZE; @@ -28,7 +30,7 @@ impl PageSize { } pub struct PageTable { - entries: [PageEntry; 512] + entries: [PageEntry; 512], } impl PageTable { @@ -72,8 +74,14 @@ impl PageTable { /// flags MUST include one or more of the following: /// Read, Write, Execute /// The valid bit automatically gets added - pub fn map(&mut self, vaddr: VirtualAddress, paddr: PhysicalAddress, flags: PageEntryFlags, page_size: PageSize) { - assert!(flags as usize & 0xe != 0); + pub fn map( + &mut self, + vaddr: VirtualAddress, + paddr: PhysicalAddress, + flags: PageEntryFlags, + page_size: PageSize, + ) { + assert!(flags as usize & 0xE != 0); let vpn = vaddr.vpns(); let ppn = paddr.ppns(); @@ -91,7 +99,7 @@ impl PageTable { } let entry = v.addr().as_mut_ptr::(); - v = unsafe { entry.add(vpn[i]).as_mut().unwrap() }; + v = unsafe { entry.add(vpn[i]).as_mut().unwrap() }; } // When we get here, we should be at VPN[0] and v should be pointing to our entry. @@ -105,14 +113,24 @@ impl PageTable { } /// Identity maps a page of memory - pub fn identity_map(&mut self, addr: PhysicalAddress, flags: PageEntryFlags, page_size: PageSize) { + pub fn identity_map( + &mut self, + addr: PhysicalAddress, + flags: PageEntryFlags, + page_size: PageSize, + ) { // log::debug!("identity mapped {addr}"); self.map(addr.as_addr().into(), addr, flags, page_size); } /// Identity maps a range of contiguous memory /// This assumes that start <= end - pub fn identity_map_range(&mut self, start: PhysicalAddress, end: PhysicalAddress, flags: PageEntryFlags) { + pub fn identity_map_range( + &mut self, + start: PhysicalAddress, + end: PhysicalAddress, + flags: PageEntryFlags, + ) { log::debug!("start: {start}, end: {end}"); let mut mem_addr = start.as_addr() & !(PAGE_SIZE - 1); let num_pages = (align_val(end.as_addr(), 12) - mem_addr - 1) / PAGE_SIZE + 1; @@ -142,7 +160,7 @@ impl PageTable { } let entry = v.addr().as_mut_ptr::(); - v = unsafe { entry.add(vpn[i]).as_mut().unwrap() }; + v = unsafe { entry.add(vpn[i]).as_mut().unwrap() }; } // If we're here this is an unmapped page @@ -182,7 +200,7 @@ pub enum PageEntryFlags { Global = 1 << 5, Access = 1 << 6, Dirty = 1 << 7, - + // for convenience ReadWrite = Self::Read as usize | Self::Write as usize, ReadExecute = Self::Read as usize | Self::Execute as usize, @@ -228,7 +246,7 @@ impl PageEntry { } fn addr(&self) -> PhysicalAddress { - ((self.entry() as usize & !0x3ff) << 2).into() + ((self.entry() as usize & !0x3FF) << 2).into() } fn destroy(&mut self) { diff --git a/kernel/src/arch/riscv64/mod.rs b/kernel/src/arch/riscv64/mod.rs index 2caa6c3..c1a8519 100644 --- a/kernel/src/arch/riscv64/mod.rs +++ b/kernel/src/arch/riscv64/mod.rs @@ -1,7 +1,7 @@ mod memory; use { - alloc::boxed::Box, + alloc::{boxed::Box, vec::Vec}, core::{ arch::{asm, global_asm}, fmt::Write, @@ -45,7 +45,7 @@ extern "C" { static USABLE_MEMORY_SIZE: usize; } -static SERIAL_CONSOLE: Once> = Once::new(); +pub static SERIAL_CONSOLE: Once> = Once::new(); #[no_mangle] unsafe extern "C" fn _kernel_start() -> ! { @@ -95,7 +95,7 @@ unsafe extern "C" fn _kernel_start() -> ! { in(reg) satp_value, ); - crate::kmain::kmain("baka=9", None); + crate::kmain::kmain("baka=9", Vec::new()); } /// Spin loop @@ -105,6 +105,12 @@ pub fn spin_loop() -> ! { } } +pub fn hardware_random_u64() -> u64 { + 0 +} + +pub fn register_dump() {} + pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result { SERIAL_CONSOLE.get().unwrap().lock().write_fmt(args) } diff --git a/kernel/src/arch/x86_64/gdt.rs b/kernel/src/arch/x86_64/gdt.rs index 4bc32b2..a1e7759 100644 --- a/kernel/src/arch/x86_64/gdt.rs +++ b/kernel/src/arch/x86_64/gdt.rs @@ -11,6 +11,9 @@ use { pub const DOUBLE_FAULT_IX: u16 = 0; +const STACK_SIZE: usize = 5 * 1024; +const STACK_ALIGNMENT: usize = 4096; + pub unsafe fn init() { use x86_64::instructions::{ segmentation::{Segment, CS, SS}, @@ -32,24 +35,24 @@ struct Selectors { static TSS: Lazy = Lazy::new(|| { let mut tss = TaskStateSegment::new(); - tss.interrupt_stack_table[usize::from(DOUBLE_FAULT_IX)] = { - const SIZE: usize = 5 * 1024; - let stack = unsafe { - alloc::alloc::alloc_zeroed( - alloc::alloc::Layout::from_size_align(SIZE, 1).expect("stack pointer"), - ) - }; - VirtAddr::from_ptr(stack) + SIZE + + let stack_ptr = unsafe { + let layout = alloc::alloc::Layout::from_size_align(STACK_SIZE, STACK_ALIGNMENT) + .expect("Failed to create stack layout"); + let stack = alloc::alloc::alloc_zeroed(layout); + VirtAddr::from_ptr(stack) + STACK_SIZE as u64 }; + + tss.interrupt_stack_table[usize::from(DOUBLE_FAULT_IX)] = stack_ptr; tss }); static GDT: Lazy<(GlobalDescriptorTable, Selectors)> = Lazy::new(|| { let mut gdt = GlobalDescriptorTable::new(); let sels = Selectors { - kcode: gdt.add_entry(Descriptor::kernel_code_segment()), - kdata: gdt.add_entry(Descriptor::kernel_data_segment()), - tss: gdt.add_entry(Descriptor::tss_segment(&TSS)), + kcode: gdt.append(Descriptor::kernel_code_segment()), + kdata: gdt.append(Descriptor::kernel_data_segment()), + tss: gdt.append(Descriptor::tss_segment(&TSS)), }; (gdt, sels) }); diff --git a/kernel/src/arch/x86_64/interrupts.rs b/kernel/src/arch/x86_64/interrupts.rs index bc7ea2f..08e7aa0 100644 --- a/kernel/src/arch/x86_64/interrupts.rs +++ b/kernel/src/arch/x86_64/interrupts.rs @@ -45,9 +45,9 @@ static IDT: Lazy = Lazy::new(|| { } idt.page_fault.set_handler_fn(page_fault); - idt[Interrupt::ApicErr as usize].set_handler_fn(apic_err); - idt[Interrupt::Spurious as usize].set_handler_fn(spurious); - idt[Interrupt::Timer as usize].set_handler_fn(timer); + idt[Interrupt::ApicErr as u8].set_handler_fn(apic_err); + idt[Interrupt::Spurious as u8].set_handler_fn(spurious); + idt[Interrupt::Timer as u8].set_handler_fn(timer); idt }); diff --git a/kernel/src/arch/x86_64/logging.rs b/kernel/src/arch/x86_64/logging.rs index 5652b25..13fd49e 100644 --- a/kernel/src/arch/x86_64/logging.rs +++ b/kernel/src/arch/x86_64/logging.rs @@ -1,11 +1,6 @@ //! Logging (as in terms of console / serial output) #![allow(deprecated)] -use { - core::fmt::Write, - limine::{TerminalRequest, TerminalResponse}, - spin::{Lazy, Mutex}, - uart_16550::SerialPort, -}; +use {core::fmt::Write, spin::Mutex, uart_16550::SerialPort}; pub static SERIAL_CONSOLE: Mutex = Mutex::new(unsafe { SerialPort::new(0x3F8) }); diff --git a/kernel/src/arch/x86_64/mod.rs b/kernel/src/arch/x86_64/mod.rs index 7437b1e..51dd9ee 100644 --- a/kernel/src/arch/x86_64/mod.rs +++ b/kernel/src/arch/x86_64/mod.rs @@ -1,7 +1,6 @@ -use { - crate::bootmodules::BootModule, core::arch::asm, embedded_graphics::pixelcolor::Rgb888, - log::warn, rdrand::RdSeed, -}; +use core::arch::x86_64::{_rdrand64_step, _rdseed64_step}; + +use {crate::bootmodules::BootModule, core::arch::asm, log::warn}; pub mod memory; mod cpuid; @@ -143,18 +142,13 @@ unsafe extern "C" fn start() -> ! { let raw_bytes = core::slice::from_raw_parts( file.base.as_ptr().expect("invalid initrd"), file.length as usize, - ) - .to_vec(); - - let file_path = alloc::string::String::from_utf8( - file.path.to_str().unwrap().to_bytes().to_vec(), ); + + let file_path = file.path.to_str().unwrap().to_str(); if file_path.is_err() { panic!("invalid file path: {:?}", file_path); } - let file_cmd = alloc::string::String::from_utf8( - file.cmdline.to_str().unwrap().to_bytes().to_vec(), - ); + let file_cmd = file.cmdline.to_str().unwrap().to_str(); if file_cmd.is_err() { panic!("invalid module cmd: {:?}", file_cmd); } @@ -195,59 +189,20 @@ unsafe extern "C" fn start() -> ! { /// Spin loop pub fn spin_loop() -> ! { loop { - x86_64::instructions::hlt(); + x86_64::instructions::hlt() } } pub fn hardware_random_u64() -> u64 { - use {log::trace, rdrand::RdRand}; - let gen = RdRand::new(); - match gen { - Ok(gen) => { - let ret = gen.try_next_u64().unwrap(); - trace!("Random {}", ret); - return ret; - } - Err(err) => { + let mut out: u64 = 0; + match unsafe { _rdrand64_step(&mut out) } { + 1 => out, + _ => { warn!("RDRand not supported."); // Try rdseed - let gen = RdSeed::new(); - match gen { - Ok(gen) => { - let ret = gen.try_next_u64().unwrap(); - trace!("Random {}", ret); - return ret; - } - Err(err) => { - panic!("Neither RDRand or RDSeed are supported") - } - } - } - } -} - -pub fn hardware_random_u32() -> u32 { - use {log::trace, rdrand::RdRand}; - let gen = RdRand::new(); - match gen { - Ok(gen) => { - let ret = gen.try_next_u32().unwrap(); - trace!("Random {}", ret); - return ret; - } - Err(err) => { - warn!("RDRand not supported."); - // Try rdseed - let gen = RdSeed::new(); - match gen { - Ok(gen) => { - let ret = gen.try_next_u32().unwrap(); - trace!("Random {}", ret); - return ret; - } - Err(err) => { - panic!("Neither RDRand or RDSeed are supported") - } + match unsafe { _rdseed64_step(&mut out) } { + 1 => out, + _ => panic!("Neither RDRand or RDSeed are supported"), } } } @@ -255,6 +210,7 @@ pub fn hardware_random_u32() -> u32 { pub fn get_edid() {} +#[allow(unused)] pub fn register_dump() { let rax: u64; let rbx: u64 = 0; diff --git a/kernel/src/bootmodules.rs b/kernel/src/bootmodules.rs index 729bd92..81d15b4 100644 --- a/kernel/src/bootmodules.rs +++ b/kernel/src/bootmodules.rs @@ -1,36 +1,36 @@ use { - crate::alloc::string::ToString, - alloc::{string::String, vec::Vec}, - clparse::Arguments, - core::fmt::{Debug, Display}, - log::trace, - xml::XMLElement, + // crate::alloc::string::ToString, + alloc::vec::Vec, + // clparse::Arguments, + // core::fmt::{Debug, Display}, + // log::trace, + // xml::XMLElement, }; -pub type BootModules = Vec; +pub type BootModules<'a> = Vec>; -pub struct BootModule { - pub path: String, - pub bytes: Vec, - pub cmd: String, +pub struct BootModule<'a> { + pub path: &'a str, + pub bytes: &'a [u8], + pub cmd: &'a str, } -impl BootModule { - pub fn new(path: String, bytes: Vec, cmd: String) -> Self { +impl<'a> BootModule<'a> { + pub fn new(path: &'a str, bytes: &'a [u8], cmd: &'a str) -> Self { Self { path, bytes, cmd } } } -pub fn build_cmd(name: T, cmdline: T) -> XMLElement { - let mut cmdline = cmdline.to_string(); - cmdline.pop(); - cmdline.remove(0); +// pub fn build_cmd(name: T, cmdline: T) -> XMLElement { +// let mut cmdline = cmdline.to_string(); +// cmdline.pop(); +// cmdline.remove(0); - let cmd = Arguments::parse(cmdline.to_string()).unwrap(); - trace!("Cmdline: {cmd:?}"); +// let cmd = Arguments::parse(cmdline.to_string()).unwrap(); +// trace!("Cmdline: {cmd:?}"); - let mut clo = XMLElement::new(name); - for (key, value) in cmd.arguments { - clo.set_attribute(key, value); - } - trace!("command line object: {:?}", clo); - clo -} +// let mut clo = XMLElement::new(name); +// for (key, value) in cmd.arguments { +// clo.set_attribute(key, value); +// } +// trace!("command line object: {:?}", clo); +// clo +// } diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index f4f162c..dc4b83c 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -1,19 +1,10 @@ //! Environment call handling routines -use core::borrow::Borrow; - -use crate::{ - allocator, - holeybytes::kernel_services::{ - block_read, - service_definition_service::{sds_msg_handler, SERVICES}, - }, -}; +use crate::holeybytes::kernel_services::{block_read, service_definition_service::sds_msg_handler}; use { - super::{mem::Memory, Vm}, - crate::{arch, holeybytes::mem, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS}, - alloc::string::String, + super::Vm, + crate::{arch, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS}, log::{debug, error, info, trace, warn}, }; @@ -78,7 +69,7 @@ pub fn handler(vm: &mut Vm) { }, 1 => match log_msg_handler(vm, mem_addr, length) { Ok(()) => {} - Err(err) => log::error!("Improper log format"), + Err(_) => log::error!("Improper log format"), }, 2 => { use crate::holeybytes::kernel_services::mem_serve::memory_msg_handler; @@ -87,29 +78,21 @@ pub fn handler(vm: &mut Vm) { Err(_) => {} } } + #[cfg(not(target_arch = "x86_64"))] + 3 => info!("TODO: implement whatever buffer 3 does for no x86_64"), + #[cfg(target_arch = "x86_64")] 3 => { - unsafe fn x86_in(address: u16) -> u8 { - x86_64::instructions::port::Port::new(address).read() - } - unsafe fn x86_in_16(address: u16) -> u16 { - x86_64::instructions::port::Port::new(address).read() - } - unsafe fn x86_in_32(address: u16) -> u32 { - x86_64::instructions::port::Port::new(address).read() - } - unsafe fn x86_out(address: u16, value: u8) { + unsafe fn x86_out( + address: u16, + value: T, + ) { x86_64::instructions::port::Port::new(address).write(value); } - unsafe fn x86_out_16(address: u16, value: u16) { - x86_64::instructions::port::Port::new(address).write(value); + unsafe fn x86_in(address: u16) -> T { + x86_64::instructions::port::Port::new(address).read() } - unsafe fn x86_out_32(address: u16, value: u32) { - x86_64::instructions::port::Port::new(address).write(value); - } - - let mut msg_vec = block_read(mem_addr, length); + let msg_vec = block_read(mem_addr, length); let msg_type = msg_vec[0]; - msg_vec.remove(0); match msg_type { 0 => 'wow: { let size = match msg_vec[0] { @@ -121,24 +104,20 @@ pub fn handler(vm: &mut Vm) { break 'wow; } }; - msg_vec.remove(0); - let addr = u16::from_le_bytes(msg_vec[0..2].try_into().unwrap()); - msg_vec.remove(0); - msg_vec.remove(0); + let addr = u16::from_le_bytes(msg_vec[1..3].try_into().unwrap()); let value = unsafe { match size { - 1 => x86_in(addr) as u64, - 2 => x86_in_16(addr) as u64, - 4 => x86_in_32(addr) as u64, + 1 => x86_in::(addr) as u64, + 2 => x86_in::(addr) as u64, + 4 => x86_in::(addr) as u64, _ => panic!("how?"), } }; - msg_vec.clear(); trace!("Read the value {} from address {}", value, addr); vm.registers[1] = hbvm::value::Value(value); } 1 => 'wow: { - let size = match msg_vec[0] { + let size = match msg_vec[1] { 0 => 1, 1 => 2, 2 => 4, @@ -147,50 +126,88 @@ pub fn handler(vm: &mut Vm) { break 'wow; } }; - msg_vec.remove(0); - let addr = u16::from_le_bytes(msg_vec[0..2].try_into().unwrap()); - msg_vec.remove(0); - msg_vec.remove(0); + let addr = unsafe { + u16::from_le_bytes(msg_vec[1..3].try_into().unwrap_unchecked()) + }; trace!("Setting address {}", addr); unsafe { match size { - 1 => x86_out(addr, msg_vec[0]), - 2 => x86_out_16( + 1 => x86_out(addr, msg_vec[3]), + 2 => x86_out( addr, - u16::from_le_bytes(msg_vec[0..2].try_into().unwrap()), + u16::from_le_bytes( + msg_vec[3..5].try_into().unwrap_unchecked(), + ), ), - 4 => x86_out_32( + 4 => x86_out( addr, - u32::from_le_bytes(msg_vec[0..4].try_into().unwrap()), + u32::from_le_bytes( + msg_vec[3..7].try_into().unwrap_unchecked(), + ), ), _ => panic!("How?"), } } - msg_vec.clear(); } _ => {} } } // source of rng 4 => { - vm.registers[1] = hbvm::value::Value(crate::arch::hardware_random_u32() as u64); + // limit to last 32 bits + vm.registers[1] = + hbvm::value::Value(crate::arch::hardware_random_u64() & 0xFFFFFFFF); + } + // get arch + 5 => { + if cfg!(target_arch = "x86_64") { + vm.registers[1] = hbvm::value::Value(0); + } else if cfg!(target_arch = "aarch64") { + vm.registers[1] = hbvm::value::Value(1); + } else { + vm.registers[1] = hbvm::value::Value(u64::MAX) + } + } + // AbleCodeâ„¢ (get fb ptr) + 6 => { + use { + crate::kmain::FB_REQ, + limine::{Framebuffer, NonNullPtr}, + }; + let fb1: &NonNullPtr = + &FB_REQ.get_response().get().unwrap().framebuffers()[0]; + let msg = block_read(mem_addr, length)[0]; + if msg == b'p' { + // ptr + let fb_front = fb1.address.as_ptr().unwrap() as *const u8; + log::info!("Graphics front ptr {:?}", fb_front); + vm.registers[1] = hbvm::value::Value(fb_front as u64); + } else if msg == b'w' { + // width + log::info!("FB Width: {}", fb1.width); + vm.registers[1] = hbvm::value::Value(fb1.width); + } else if msg == b'h' { + // height + log::info!("FB Height: {}", fb1.height); + vm.registers[1] = hbvm::value::Value(fb1.height); + } } buffer_id => { let mut buffs = IPC_BUFFERS.lock(); match buffs.get_mut(&buffer_id) { Some(buff) => { - let mut msg_vec = vec![]; + let mut msg_vec = Vec::with_capacity(length); for x in 0..(length as isize) { let xyz = mem_addr as *const u8; let value = unsafe { xyz.offset(x).read() }; msg_vec.push(value); } - buff.push(msg_vec.clone()); debug!( "Message {:?} has been sent to Buffer({})", msg_vec, buffer_id ); + buff.push(msg_vec); } None => { log::error!("Access of non-existent buffer {}", buffer_id) @@ -206,7 +223,7 @@ pub fn handler(vm: &mut Vm) { let max_length = vm.registers[5].cast::(); let mut buffs = IPC_BUFFERS.lock(); - let mut buff: &mut IpcBuffer; + let buff: &mut IpcBuffer; if buffs.get_mut(&buffer_id).is_some() { buff = buffs.get_mut(&buffer_id).unwrap(); @@ -255,16 +272,16 @@ pub fn handler(vm: &mut Vm) { } } -fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { +fn log_msg_handler(_vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { // let message_length = 8 + 8 + 8; // log::info!("Mem Addr 0x{:x?} length {}", mem_addr, length); - let mut msg_vec = block_read(mem_addr, length); + let msg_vec = block_read(mem_addr, length); - let log_level = msg_vec.pop().unwrap(); - match String::from_utf8(msg_vec) { + let log_level = msg_vec.last().unwrap(); + match core::str::from_utf8(&msg_vec[1..]) { Ok(strr) => { // use LogLevel::*; - let ll = match log_level { + let _ll = match log_level { 0 | 48 => error!("{}", strr), 1 | 49 => warn!("{}", strr), 2 | 50 => info!("{}", strr), @@ -288,8 +305,8 @@ pub enum LogError { NoMessages, InvalidLogFormat, } -use {alloc::vec, log::Record}; +// use {alloc::vec, log::Record}; // fn memory_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { // let mut val = alloc::vec::Vec::new(); // for _ in 0..4096 { diff --git a/kernel/src/holeybytes/kernel_services/mem_serve.rs b/kernel/src/holeybytes/kernel_services/mem_serve.rs index 16ecbe8..feeba2e 100644 --- a/kernel/src/holeybytes/kernel_services/mem_serve.rs +++ b/kernel/src/holeybytes/kernel_services/mem_serve.rs @@ -1,10 +1,7 @@ use { - crate::holeybytes::{ - ecah::LogError, - kernel_services::{block_read, mem_serve}, - Vm, - }, - alloc::alloc::alloc_zeroed, + crate::holeybytes::{kernel_services::block_read, Vm}, + alloc::alloc::{alloc_zeroed, dealloc}, + core::alloc::Layout, log::{debug, info}, }; @@ -19,13 +16,10 @@ pub enum MemoryQuotaType { KillQuota = 3, } -fn alloc_page(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), MemoryServiceError> { - let mut val = alloc::vec::Vec::new(); - for _ in 0..4096 { - val.push(0); - } - info!("Block address: {:?}", val.as_ptr()); - vm.registers[1] = hbvm::value::Value(val.as_ptr() as u64); +fn alloc_page(vm: &mut Vm, _mem_addr: u64, _length: usize) -> Result<(), MemoryServiceError> { + let ptr = unsafe { alloc_zeroed(Layout::new::<[u8; 4096]>()) }; + info!("Block address: {:?}", ptr); + vm.registers[1] = hbvm::value::Value(ptr as u64); vm.registers[2] = hbvm::value::Value(4096); Ok(()) } @@ -35,34 +29,39 @@ pub fn memory_msg_handler( mem_addr: u64, length: usize, ) -> Result<(), MemoryServiceError> { - let mut msg_vec = block_read(mem_addr, length); + let msg_vec = block_read(mem_addr, length); let msg_type = msg_vec[0]; - - msg_vec.remove(0); match msg_type { 0 => { - let page_count = msg_vec[0]; - msg_vec.remove(0); - - let mptr_raw: [u8; 8] = msg_vec[0..8].try_into().unwrap(); + let page_count = msg_vec[1]; + let mptr_raw: [u8; 8] = msg_vec[2..10].try_into().unwrap(); let mptr: u64 = u64::from_le_bytes(mptr_raw); log::debug!("Allocating {} pages @ {:x}", page_count, mptr); - let mut val = alloc::vec::Vec::new(); - for _ in 0..(page_count as isize * 4096) { - val.push(0); - } - vm.registers[1] = hbvm::value::Value(val.as_ptr() as u64); - log::debug!("Kernel ptr: {:x}", val.as_ptr() as u64); - } - 1 => { - let page_count = msg_vec[0]; - msg_vec.remove(0); + let ptr = unsafe { + alloc_zeroed(Layout::from_size_align_unchecked( + page_count as usize * 4096, + 1, + )) + }; - let mptr_raw: [u8; 8] = msg_vec[0..8].try_into().unwrap(); + vm.registers[1] = hbvm::value::Value(ptr as u64); + log::debug!("Kernel ptr: {:x}", ptr as u64); + } + + 1 => { + let page_count = msg_vec[1]; + + let mptr_raw: [u8; 8] = msg_vec[2..10].try_into().unwrap(); let mptr: u64 = u64::from_le_bytes(mptr_raw); log::debug!("Deallocating {} pages @ {:x}", page_count, mptr); + unsafe { + dealloc( + mptr as *mut u8, + Layout::from_size_align_unchecked(page_count as usize * 4096, 1), + ) + } } 2 => { use MemoryQuotaType::*; @@ -73,19 +72,10 @@ pub fn memory_msg_handler( 3 => KillQuota, _ => NoQuota, }; - msg_vec.remove(0); - let hid_raw: [u8; 8] = msg_vec[0..8].try_into().unwrap(); + let hid_raw: [u8; 8] = msg_vec[2..10].try_into().unwrap(); let hid: u64 = u64::from_le_bytes(hid_raw); - for _ in 0..8 { - msg_vec.remove(0); - } - - let pid_raw: [u8; 8] = msg_vec[0..8].try_into().unwrap(); - let pid: u64 = u64::from_le_bytes(hid_raw); - for _ in 0..8 { - msg_vec.remove(0); - } - + let pid_raw: [u8; 8] = msg_vec[10..18].try_into().unwrap(); + let pid: u64 = u64::from_le_bytes(pid_raw); debug!( "Setting HID-{:x}:PID-{:x}'s quota type to {:?}", hid, pid, quota_type @@ -94,7 +84,6 @@ pub fn memory_msg_handler( 3 => { let page_count = msg_vec[0]; log::debug!(" {} pages", page_count); - msg_vec.remove(0); } _ => { diff --git a/kernel/src/holeybytes/kernel_services/mod.rs b/kernel/src/holeybytes/kernel_services/mod.rs index 23908ef..8c80f49 100644 --- a/kernel/src/holeybytes/kernel_services/mod.rs +++ b/kernel/src/holeybytes/kernel_services/mod.rs @@ -1,15 +1,9 @@ -use alloc::{vec, vec::Vec}; +use core::slice; pub mod mem_serve; pub mod service_definition_service; -pub fn block_read(mem_addr: u64, length: usize) -> Vec { - let mut msg_vec = vec![]; - - for x in 0..(length as isize) { - let xyz = mem_addr as *const u8; - let value = unsafe { xyz.offset(x).read() }; - msg_vec.push(value); - } - msg_vec +#[inline(always)] +pub fn block_read<'a>(mem_addr: u64, length: usize) -> &'a [u8] { + unsafe { slice::from_raw_parts(mem_addr as *const u8, length) } } diff --git a/kernel/src/holeybytes/kernel_services/service_definition_service.rs b/kernel/src/holeybytes/kernel_services/service_definition_service.rs index 547ac33..3382f1b 100644 --- a/kernel/src/holeybytes/kernel_services/service_definition_service.rs +++ b/kernel/src/holeybytes/kernel_services/service_definition_service.rs @@ -1,20 +1,15 @@ use { crate::{ - alloc::string::ToString, arch::hardware_random_u64, holeybytes::{ecah::LogError, kernel_services::block_read, Vm}, - ipc::{ - buffer::IpcBuffer, - protocol::{self, Protocol}, - }, + ipc::{buffer::IpcBuffer, protocol::Protocol}, kmain::IPC_BUFFERS, }, - alloc::string::String, hashbrown::HashMap, log::{info, trace}, spin::{lazy::Lazy, Mutex}, }; -pub struct Services(HashMap); +pub struct Services<'a>(HashMap>); pub static SERVICES: Lazy> = Lazy::new(|| { let mut dt = Services(HashMap::new()); dt.0.insert(0, Protocol::void()); @@ -22,25 +17,26 @@ pub static SERVICES: Lazy> = Lazy::new(|| { }); pub fn sds_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { - let mut msg_vec = block_read(mem_addr, length); + let msg_vec = block_read(mem_addr, length); if msg_vec.is_empty() { return Err(LogError::NoMessages); } let sds_event_type: ServiceEventType = msg_vec[0].into(); - msg_vec.remove(0); // info!("Length {}", msg_vec.len()); use ServiceEventType::*; match sds_event_type { CreateService => { - let string = String::from_utf8(msg_vec).expect("Our bytes should be valid utf8"); + let string = + core::str::from_utf8(&msg_vec[1..]).expect("Our bytes should be valid utf8"); let ret = sds_create_service(string); vm.registers[1] = hbvm::value::Value(ret as u64); } DeleteService => todo!(), SearchServices => { - let string = String::from_utf8(msg_vec).expect("Our bytes should be valid utf8"); + let string = + core::str::from_utf8(&msg_vec[1..]).expect("Our bytes should be valid utf8"); let ret = sds_search_service(string); vm.registers[1] = hbvm::value::Value(ret as u64); } @@ -82,16 +78,16 @@ impl From for ServiceEventType { } } -fn sds_create_service(protocol: String) -> u64 { +fn sds_create_service(protocol: &'static str) -> u64 { let buff_id = hardware_random_u64(); let mut services = SERVICES.lock(); let mut buffers = IPC_BUFFERS.lock(); - let protocol_ = Protocol::from(protocol.clone()); + let protocol_ = Protocol::from(protocol); let mut buff = IpcBuffer::new(false, 0); services.0.insert(buff_id, protocol_.clone()); - buff.protocol = protocol_.clone(); + buff.protocol = protocol_; buffers.insert(buff_id, buff); trace!("BufferID({}) => {}", buff_id, protocol); @@ -99,13 +95,13 @@ fn sds_create_service(protocol: String) -> u64 { buff_id } -fn sds_search_service(protocol: String) -> u64 { - let mut services = SERVICES.lock(); - let compare = Protocol::from(protocol.clone()); +fn sds_search_service(protocol: &str) -> u64 { + let services = SERVICES.lock(); + let compare = Protocol::from(protocol); for (bid, protocol_canidate) in &services.0 { trace!("BID-{bid} protocol_canidate {:?}", protocol_canidate); if protocol_canidate == &compare { - trace!("BufferID({}) => {}", bid, protocol.clone()); + trace!("BufferID({}) => {}", bid, protocol); return *bid; } } diff --git a/kernel/src/holeybytes/mem.rs b/kernel/src/holeybytes/mem.rs index e9024c5..35a423b 100644 --- a/kernel/src/holeybytes/mem.rs +++ b/kernel/src/holeybytes/mem.rs @@ -7,7 +7,7 @@ use hbvm::mem::Address; fn calc_start_of_page(ptr: u64) -> u64 { - let mut page_aligned = false; + let _page_aligned = false; if ptr % 4096 == 0 { // page_aligned = true; return ptr / 4096; @@ -21,11 +21,11 @@ pub struct Memory { impl Memory { #[cfg(target_arch = "x86_64")] - fn read_device(addr: Address) { - unsafe { - // - // x86_64::instructions::port::Port::new(addr.get()).read() - } + fn read_device(_addr: Address) { + //unsafe { + // + // x86_64::instructions::port::Port::new(addr.get()).read() + //} } } @@ -37,7 +37,6 @@ impl hbvm::mem::Memory for Memory { target: *mut u8, count: usize, ) -> Result<(), hbvm::mem::LoadError> { - use log::{error, info}; if addr.get() % 4096 == 0 {} core::ptr::copy(addr.get() as *const u8, target, count); Ok(()) @@ -56,6 +55,6 @@ impl hbvm::mem::Memory for Memory { #[inline] unsafe fn prog_read(&mut self, addr: Address) -> T { - (addr.get() as *const T).read_unaligned() + (addr.get() as *const T).read() } } diff --git a/kernel/src/holeybytes/mod.rs b/kernel/src/holeybytes/mod.rs index 6ae91ca..aecadd3 100644 --- a/kernel/src/holeybytes/mod.rs +++ b/kernel/src/holeybytes/mod.rs @@ -3,86 +3,86 @@ mod kernel_services; mod mem; use { - crate::{arch, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS}, - alloc::boxed::Box, - core::{default, future::Future, marker::PhantomData, ptr::NonNull, task::Poll}, + alloc::alloc::{alloc_zeroed, dealloc}, + core::{ + alloc::Layout, + future::Future, + pin::Pin, + task::{Context, Poll}, + }, hbvm::{ - mem::{ - softpaging::{icache::ICache, HandlePageFault, SoftPagedMem}, - Address, Memory, - }, + mem::{softpaging::HandlePageFault, Address}, VmRunError, VmRunOk, }, - log::{debug, error, info, trace, warn}, + log::error, }; const STACK_SIZE: usize = 1024 * 1024; -const TIMER_QUOTIENT: usize = 100; +const TIMER_QUOTIENT: usize = 1000; type Vm = hbvm::Vm; -pub struct ExecThread<'p> { +pub struct ExecThread { vm: Vm, stack_bottom: *mut u8, - _phantom: PhantomData<&'p [u8]>, } -unsafe impl<'p> Send for ExecThread<'p> {} -impl<'p> ExecThread<'p> { +unsafe impl Send for ExecThread {} + +impl ExecThread { pub fn set_arguments(&mut self, ptr: u64, length: u64) { self.vm.registers[1] = hbvm::value::Value(ptr); self.vm.registers[2] = hbvm::value::Value(length); } - pub unsafe fn new(program: &'p [u8], entrypoint: Address) -> Self { - let mut vm = unsafe { - Vm::new( - mem::Memory {}, - Address::new(program.as_ptr() as u64 + entrypoint.get()), - ) - }; + pub unsafe fn new(program: &[u8], entrypoint: Address) -> Self { + let mut vm = Vm::new( + mem::Memory {}, + Address::new(program.as_ptr() as u64 + entrypoint.get()), + ); + + let stack_bottom = allocate_stack(); - let stack_bottom = unsafe { allocate_stack().as_ptr() }; vm.write_reg(254, (stack_bottom as usize + STACK_SIZE - 1) as u64); - ExecThread { - vm, - stack_bottom, - _phantom: Default::default(), - } + ExecThread { vm, stack_bottom } } } -impl<'p> Drop for ExecThread<'p> { +impl<'p> Drop for ExecThread { fn drop(&mut self) { - unsafe { alloc::alloc::dealloc(self.stack_bottom, stack_layout()) }; + unsafe { dealloc(self.stack_bottom, stack_layout()) }; } } -impl<'p> Future for ExecThread<'p> { +impl<'p> Future for ExecThread { type Output = Result<(), VmRunError>; - fn poll( - mut self: core::pin::Pin<&mut Self>, - cx: &mut core::task::Context<'_>, - ) -> Poll { + #[inline(always)] + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.vm.run() { Err(err) => { - log::error!("HBVM Error\r\nRegister dump: {:?}", self.vm.registers,); - return Poll::Ready(Err(err)); + error!("HBVM Error\r\nRegister dump: {:?}", self.vm.registers); + Poll::Ready(Err(err)) + } + Ok(VmRunOk::End) => Poll::Ready(Ok(())), + Ok(VmRunOk::Ecall) => { + ecah::handler(&mut self.vm); + cx.waker().wake_by_ref(); + Poll::Pending + } + Ok(VmRunOk::Timer) => { + cx.waker().wake_by_ref(); + Poll::Pending } - Ok(VmRunOk::End) => return Poll::Ready(Ok(())), - Ok(VmRunOk::Ecall) => ecah::handler(&mut self.vm), - Ok(VmRunOk::Timer) => (), Ok(VmRunOk::Breakpoint) => { - log::error!( + error!( "HBVM Debug breakpoint\r\nRegister dump: {:?}", - self.vm.registers, + self.vm.registers ); + cx.waker().wake_by_ref(); + Poll::Pending } } - - cx.waker().wake_by_ref(); - Poll::Pending } } @@ -91,33 +91,22 @@ impl HandlePageFault for PageFaultHandler { fn page_fault( &mut self, reason: hbvm::mem::MemoryAccessReason, - pagetable: &mut hbvm::mem::softpaging::paging::PageTable, + _pagetable: &mut hbvm::mem::softpaging::paging::PageTable, vaddr: hbvm::mem::Address, size: hbvm::mem::softpaging::PageSize, dataptr: *mut u8, - ) -> bool - where - Self: Sized, - { - log::error!( - "REASON: {reason} \ - vaddr: {vaddr} \ - size: {size:?} \ - Dataptr {dataptr:p}", - ); - + ) -> bool { + error!("REASON: {reason} vaddr: {vaddr} size: {size:?} Dataptr {dataptr:p}"); false } } -const fn stack_layout() -> core::alloc::Layout { - unsafe { alloc::alloc::Layout::from_size_align_unchecked(STACK_SIZE, 4096) } +#[inline(always)] +const fn stack_layout() -> Layout { + unsafe { Layout::from_size_align_unchecked(STACK_SIZE, 4096) } } -fn allocate_stack() -> NonNull { - let layout = stack_layout(); - match NonNull::new(unsafe { alloc::alloc::alloc_zeroed(layout) }) { - Some(ptr) => ptr, - None => alloc::alloc::handle_alloc_error(layout), - } +#[inline(always)] +fn allocate_stack() -> *mut u8 { + unsafe { alloc_zeroed(stack_layout()) } } diff --git a/kernel/src/ipc/buffer.rs b/kernel/src/ipc/buffer.rs index 71756bb..a7c1920 100644 --- a/kernel/src/ipc/buffer.rs +++ b/kernel/src/ipc/buffer.rs @@ -9,12 +9,12 @@ pub enum BufferTypes { Bound(ArrayQueue), } /// Interproccess buffer -pub struct IpcBuffer { - pub protocol: Protocol, +pub struct IpcBuffer<'a> { + pub protocol: Protocol<'a>, pub buffer: BufferTypes, } -impl IpcBuffer { +impl<'a> IpcBuffer<'a> { pub fn new(bounded: bool, length: u64) -> Self { log::debug!( "New IPCBuffer\r @@ -24,7 +24,7 @@ impl IpcBuffer { length ); match (bounded, length) { - (false, a) => { + (false, ..) => { let buftype = BufferTypes::Unbound(SegQueue::new()); Self { @@ -48,9 +48,9 @@ impl IpcBuffer { } pub fn push(&mut self, msg: Message) { match &self.buffer { - BufferTypes::Unbound(buff) => buff.push(msg.clone()), + BufferTypes::Unbound(buff) => buff.push(msg), BufferTypes::Bound(buff) => { - let _ = buff.push(msg.clone()); + let _ = buff.push(msg); } }; } diff --git a/kernel/src/ipc/protocol.rs b/kernel/src/ipc/protocol.rs index e8cead3..0e8427e 100644 --- a/kernel/src/ipc/protocol.rs +++ b/kernel/src/ipc/protocol.rs @@ -1,7 +1,6 @@ use { alloc::{string::String, vec::Vec}, hashbrown::HashMap, - log::info, }; #[derive(Debug, PartialEq, Clone)] pub struct Type {} @@ -11,11 +10,11 @@ pub struct Funct { gives: Vec, } #[derive(Debug, PartialEq, Clone)] -pub struct Protocol { - types: HashMap, - fns: HashMap, +pub struct Protocol<'a> { + types: HashMap<&'a str, Type>, + fns: HashMap<&'a str, Funct>, } -impl Protocol { +impl<'a> Protocol<'a> { pub fn void() -> Self { Self { types: HashMap::new(), @@ -28,8 +27,8 @@ impl Protocol { } } -impl From for Protocol { - fn from(value: alloc::string::String) -> Self { +impl<'a> From<&'a str> for Protocol<'a> { + fn from(value: &'a str) -> Self { let mut hm_t = HashMap::new(); hm_t.insert(value, Type {}); Self { diff --git a/kernel/src/kmain.rs b/kernel/src/kmain.rs index 0c6790c..dcd2ad8 100644 --- a/kernel/src/kmain.rs +++ b/kernel/src/kmain.rs @@ -2,27 +2,25 @@ use { crate::{ - arch::{hardware_random_u64, logging::SERIAL_CONSOLE}, - bootmodules::{build_cmd, BootModules}, - capabilities, + arch::hardware_random_u64, + bootmodules::BootModules, + //bootmodules::build_cmd, device_tree::DeviceTree, holeybytes::ExecThread, - ipc::buffer::{self, IpcBuffer}, + ipc::buffer::IpcBuffer, }, - alloc::format, hashbrown::HashMap, hbvm::mem::Address, limine::{Framebuffer, FramebufferRequest, NonNullPtr}, - log::{debug, info, trace}, + log::{debug, info}, spin::{Lazy, Mutex}, - xml::XMLElement, }; -pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! { +pub fn kmain(_cmdline: &str, boot_modules: BootModules) -> ! { debug!("Entered kmain"); - let kcmd = build_cmd("Kernel Command Line", cmdline); - trace!("Cmdline: {kcmd:?}"); + // let kcmd = build_cmd("Kernel Command Line", cmdline); + // trace!("Cmdline: {kcmd:?}"); // for (i, bm) in boot_modules.iter().enumerate() { // let name = format!("module-{}", i); @@ -68,17 +66,18 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! { fb1.address.as_ptr().unwrap() as *const u8 ); - let mut executor = crate::task::Executor::default(); + let mut executor = crate::task::Executor::new(256); let bm_take = boot_modules.len(); unsafe { for module in boot_modules.into_iter().take(bm_take) { let mut cmd = module.cmd; if cmd.len() > 2 { - // Remove the quotes - cmd.remove(0); - cmd.pop(); + // // Remove the quotes + // cmd.remove(0); + // cmd.pop(); + cmd = &cmd[1..cmd.len()] } - let cmd_len = cmd.as_bytes().len() as u64; + let cmd_len = cmd.len() as u64; log::info!("Spawning {} with arguments \"{}\"", module.path, cmd); @@ -87,11 +86,10 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! { if cmd_len > 0 { thr.set_arguments(cmd.as_bytes().as_ptr() as u64, cmd_len); } - if let Err(e) = thr.await { log::error!("{e:?}"); } - }); + }) } info!("Random number: {}", hardware_random_u64()); @@ -108,8 +106,7 @@ pub static DEVICE_TREE: Lazy> = Lazy::new(|| { }); pub static FB_REQ: FramebufferRequest = FramebufferRequest::new(0); -use alloc::vec::Vec; -pub type IpcBuffers = HashMap; +pub type IpcBuffers<'a> = HashMap>; pub static IPC_BUFFERS: Lazy> = Lazy::new(|| { let mut bufs = HashMap::new(); let log_buffer = IpcBuffer::new(false, 0); diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 26c3270..194b150 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -1,21 +1,19 @@ //! The ableOS kernel. //! Named akern. //! Akern is woefully undersupported at the moment but we are looking to add support improve hardware discovery and make our lives as kernel and operating system developers easier and better - #![no_std] +#![feature(new_uninit)] #![feature( abi_x86_interrupt, alloc_error_handler, - inline_const, - panic_info_message, - pointer_is_aligned, ptr_sub_ptr, custom_test_frameworks, naked_functions, pointer_is_aligned_to )] -#![allow(dead_code)] #![test_runner(crate::test_runner)] +#![cfg_attr(not(debug_assertions), allow(unused, deprecated))] +#![allow(dead_code)] extern crate alloc; mod allocator; @@ -42,6 +40,7 @@ pub const VERSION: Version = Version { }; #[panic_handler] +#[cfg(target_os = "none")] fn panic(info: &core::panic::PanicInfo) -> ! { arch::register_dump(); @@ -54,10 +53,8 @@ fn panic(info: &core::panic::PanicInfo) -> ! { )); } - if let Some(msg) = info.message() { - let _ = crate::arch::log(format_args!("{msg}\r\n")); - } - + let msg = info.message(); + let _ = crate::arch::log(format_args!("{msg}\r\n")); loop {} } diff --git a/kernel/src/logger.rs b/kernel/src/logger.rs index b403fa9..fd9cc4a 100644 --- a/kernel/src/logger.rs +++ b/kernel/src/logger.rs @@ -1,3 +1,4 @@ +#![allow(deprecated)] // TODO: Add a logger api with logger levels and various outputs pub static TERMINAL_LOGGER: Lazy> = Lazy::new(|| Mutex::new(TermLogger::new())); diff --git a/kernel/src/memory.rs b/kernel/src/memory.rs index 15b5db1..1f0a2fc 100644 --- a/kernel/src/memory.rs +++ b/kernel/src/memory.rs @@ -1,7 +1,6 @@ //! The Memory Manager -use alloc::collections::VecDeque; -use derive_more::*; +use {alloc::collections::VecDeque, derive_more::*}; pub use crate::arch::PAGE_SIZE; pub const MAX_ORDER: usize = 10; @@ -44,7 +43,7 @@ pub const MAX_ORDER: usize = 10; Sum, UpperHex, )] -#[display(fmt = "0x{:x}", _0)] +#[display("0x{:x}", _0)] #[from(forward)] pub struct VirtualAddress(usize); @@ -55,11 +54,11 @@ impl VirtualAddress { pub fn vpns(&self) -> [usize; 3] { [ // [20:12] - (self.0 >> 12) & 0x1ff, + (self.0 >> 12) & 0x1FF, // [29:21] - (self.0 >> 21) & 0x1ff, + (self.0 >> 21) & 0x1FF, // [38:30] - (self.0 >> 30) & 0x1ff, + (self.0 >> 30) & 0x1FF, ] } @@ -114,7 +113,7 @@ impl VirtualAddress { Sum, UpperHex, )] -#[display(fmt = "0x{:x}", _0)] +#[display("0x{:x}", _0)] #[from(forward)] pub struct PhysicalAddress(usize); @@ -125,11 +124,11 @@ impl PhysicalAddress { pub fn ppns(&self) -> [usize; 3] { [ // [20:12] - (self.0 >> 12) & 0x1ff, + (self.0 >> 12) & 0x1FF, // [29:21] - (self.0 >> 21) & 0x1ff, + (self.0 >> 21) & 0x1FF, // [55:30] - (self.0 >> 30) & 0x3ffffff, + (self.0 >> 30) & 0x3FFFFFF, ] } diff --git a/kernel/src/task.rs b/kernel/src/task.rs index 4c603e1..241f64c 100644 --- a/kernel/src/task.rs +++ b/kernel/src/task.rs @@ -1,31 +1,20 @@ -#![allow(unused)] - use { - alloc::{boxed::Box, collections::BTreeMap, sync::Arc, task::Wake}, + alloc::{boxed::Box, sync::Arc}, core::{ future::Future, pin::Pin, - task::{Context, Poll, Waker}, + task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, }, crossbeam_queue::SegQueue, - kiam::when, slab::Slab, - spin::RwLock, }; -static SPAWN_QUEUE: RwLock> = RwLock::new(None); -pub fn spawn(future: impl Future + Send + 'static) { - match &*SPAWN_QUEUE.read() { - Some(s) => s.push(Task::new(future)), - None => panic!("no task executor is running"), - } -} - pub fn yield_now() -> impl Future { struct YieldNow(bool); impl Future for YieldNow { type Output = (); + #[inline(always)] fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if self.0 { Poll::Ready(()) @@ -40,101 +29,150 @@ pub fn yield_now() -> impl Future { YieldNow(false) } -#[derive(Default)] -pub struct Executor { - tasks: Slab, - queue: TaskQueue, - to_spawn: SpawnQueue, - wakers: BTreeMap, +pub struct Executor + Send> { + tasks: Slab>, + task_queue: Arc, } -impl Executor { - pub fn spawn(&mut self, future: impl Future + Send + 'static) { - self.queue - .push(TaskId(self.tasks.insert(Task::new(future)))); +impl + Send> Executor { + pub fn new(size: usize) -> Self { + Self { + tasks: Slab::with_capacity(size), + task_queue: Arc::new(TaskQueue::new()), + } + } + + #[inline] + pub fn spawn(&mut self, future: F) { + self.task_queue + .queue + .push(self.tasks.insert(Task::new(future))); } pub fn run(&mut self) { - { - let mut global_spawner = SPAWN_QUEUE.write(); - if global_spawner.is_some() { - panic!("Task executor is already running"); - } - - *global_spawner = Some(Arc::clone(&self.to_spawn)); - } + let mut task_batch = [0; 32]; + let mut batch_len = 0; loop { - when! { - let Some(id) = self - .to_spawn - .pop() - .map(|t| TaskId(self.tasks.insert(t))) - .or_else(|| self.queue.pop()) - => { - let Some(task) = self.tasks.get_mut(id.0) else { - panic!("Attempted to get task from empty slot: {}", id.0); - }; + self.task_queue.batch_pop(&mut task_batch, &mut batch_len); - let mut cx = Context::from_waker(self.wakers.entry(id).or_insert_with(|| { - Waker::from(Arc::new(TaskWaker { - id, - queue: Arc::clone(&self.queue), - })) - })); + if batch_len == 0 { + if self.task_queue.is_empty() { + break; + } else { + continue; + } + } - match task.poll(&mut cx) { - Poll::Ready(()) => { - self.tasks.remove(id.0); - self.wakers.remove(&id); - } - Poll::Pending => (), + for &id in &task_batch[..batch_len] { + if let Some(task) = self.tasks.get_mut(id) { + let waker = task + .waker + .get_or_insert_with(|| TaskWaker::new(id, Arc::clone(&self.task_queue))); + + let waker = unsafe { Waker::from_raw(TaskWaker::into_raw_waker(waker)) }; + let mut cx = Context::from_waker(&waker); + + if let Poll::Ready(()) = task.poll(&mut cx) { + self.tasks.remove(id); + self.task_queue.free_tasks.push(id); } - }, - self.tasks.is_empty() => break, - _ => (), + } } } - - *SPAWN_QUEUE.write() = None; } } -struct Task { - future: Pin + Send>>, +struct Task + Send> { + future: Pin>, + waker: Option, } -impl Task { - pub fn new(future: impl Future + Send + 'static) -> Self { - log::trace!("New task scheduled"); +impl + Send> Task { + #[inline(always)] + pub fn new(future: F) -> Self { Self { future: Box::pin(future), + waker: None, } } + #[inline(always)] fn poll(&mut self, cx: &mut Context) -> Poll<()> { self.future.as_mut().poll(cx) } } -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] -struct TaskId(usize); - -type TaskQueue = Arc>; -type SpawnQueue = Arc>; - struct TaskWaker { - id: TaskId, - queue: TaskQueue, + id: usize, + task_queue: Arc, } -impl Wake for TaskWaker { - fn wake(self: Arc) { - log::trace!("Woke Task-{:?}", self.id); - self.wake_by_ref(); +impl TaskWaker { + #[inline(always)] + fn new(id: usize, task_queue: Arc) -> Self { + Self { id, task_queue } } - fn wake_by_ref(self: &Arc) { - self.queue.push(self.id); + #[inline(always)] + fn wake(&self) { + self.task_queue.queue.push(self.id); + } + + fn into_raw_waker(waker: &TaskWaker) -> RawWaker { + let ptr = waker as *const TaskWaker; + RawWaker::new(ptr.cast(), &VTABLE) + } +} + +const VTABLE: RawWakerVTable = RawWakerVTable::new(clone_raw, wake_raw, wake_by_ref_raw, drop_raw); + +unsafe fn clone_raw(ptr: *const ()) -> RawWaker { + let waker = &*(ptr as *const TaskWaker); + TaskWaker::into_raw_waker(waker) +} + +unsafe fn wake_raw(ptr: *const ()) { + let waker = &*(ptr as *const TaskWaker); + waker.wake(); +} + +unsafe fn wake_by_ref_raw(ptr: *const ()) { + let waker = &*(ptr as *const TaskWaker); + waker.wake(); +} + +unsafe fn drop_raw(_: *const ()) {} + +struct TaskQueue { + queue: SegQueue, + next_task: usize, + free_tasks: SegQueue, +} + +impl TaskQueue { + fn new() -> Self { + Self { + queue: SegQueue::new(), + next_task: 0, + free_tasks: SegQueue::new(), + } + } + + #[inline(always)] + fn batch_pop(&self, output: &mut [usize], len: &mut usize) { + *len = 0; + while let Some(id) = self.queue.pop() { + output[*len] = id; + *len += 1; + if *len == output.len() { + break; + } + } + } + + #[inline(always)] + fn is_empty(&self) -> bool { + self.queue.is_empty() } } diff --git a/repbuild/Cargo.toml b/repbuild/Cargo.toml index c9c209b..a082573 100644 --- a/repbuild/Cargo.toml +++ b/repbuild/Cargo.toml @@ -4,15 +4,26 @@ version = "0.2.0" edition = "2021" [dependencies] -str-reader = "0.1.2" -derive_more = "0.99" -error-stack = "0.4" +str-reader = "0.1" +derive_more = { version = "1", default-features = false, features = [ + "add", + "add_assign", + "constructor", + "display", + "from", + "into", + "mul", + "mul_assign", + "not", + "sum", +] } +error-stack = "0.5" fatfs = "0.3" -toml = "0.5.2" +toml = "0.8" # hbasm.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git" hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git" [dependencies.reqwest] -version = "0.11" +version = "0.12" default-features = false features = ["rustls-tls", "blocking"] diff --git a/repbuild/src/dev.rs b/repbuild/src/dev.rs index 67768e8..2e81228 100644 --- a/repbuild/src/dev.rs +++ b/repbuild/src/dev.rs @@ -1,3 +1,4 @@ +#![allow(unused)] use std::{ fmt::format, fs::{read_to_string, File}, diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 8eb4835..eede3ed 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -1,3 +1,5 @@ +// #![allow(unused)] + mod dev; use { @@ -6,7 +8,7 @@ use { error_stack::{bail, report, Context, Report, Result, ResultExt}, fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek}, std::{ - fmt::Display, + // fmt::Display, fs::{self, File}, io::{self, Write}, path::Path, @@ -193,7 +195,7 @@ TERM_BACKDROP={} let modules = value.get_mut("modules").unwrap().as_table_mut().unwrap(); // let mut real_modules = modules.clone(); - modules.into_iter().for_each(|(key, value)| { + modules.into_iter().for_each(|(_, value)| { if value.is_table() { let path = get_path_without_boot_prefix( value.get("path").expect("You must have `path` as a value"), @@ -242,7 +244,7 @@ TERM_BACKDROP={} let bootdir = fs.root_dir().create_dir("efi")?.create_dir("boot")?; let mut f = fs.root_dir().create_file("limine.cfg")?; - let a = f.write(limine_str.as_bytes())?; + let _ = f.write(limine_str.as_bytes())?; drop(f); io::copy( @@ -368,7 +370,7 @@ fn run(release: bool, target: Target) -> Result<(), Error> { #[rustfmt::skip] com.args([ "-M", "virt", - "-cpu", "cortex-a72", + "-cpu", "neoverse-n2", "-device", "ramfb", "-device", "qemu-xhci", "-device", "usb-kbd", @@ -427,11 +429,11 @@ fn fetch_ovmf(target: Target) -> Result { #[derive(Debug, Display)] enum OvmfFetchError { - #[display(fmt = "Failed to fetch OVMF package")] + #[display("Failed to fetch OVMF package")] Fetch, - #[display(fmt = "No OVMF package available")] + #[display("No OVMF package available")] Empty, - #[display(fmt = "IO Error")] + #[display("IO Error")] Io, } @@ -444,26 +446,28 @@ enum Target { Aarch64, } +#[allow(unused)] #[derive(Debug, Display)] enum Error { - #[display(fmt = "Failed to build the kernel")] + #[display("Failed to build the kernel")] Build, - #[display(fmt = "Missing or invalid subcommand (available: build, run)")] + #[display("Missing or invalid subcommand (available: build, run)")] InvalidSubCom, - #[display(fmt = "IO Error")] + #[display("IO Error")] Io, - #[display(fmt = "Failed to spawn a process")] + #[display("Failed to spawn a process")] ProcessSpawn, - #[display(fmt = "Failed to fetch UEFI firmware")] + #[display("Failed to fetch UEFI firmware")] OvmfFetch, - #[display(fmt = "Failed to assemble Holey Bytes code")] + #[display("Failed to assemble Holey Bytes code")] Assembler, - #[display(fmt = "QEMU Error: {}", "fmt_qemu_err(*_0)")] + #[display("QEMU Error: {}", "fmt_qemu_err(*_0)")] Qemu(Option), } impl Context for Error {} +#[allow(dead_code)] fn fmt_qemu_err(e: Option) -> impl Display { struct W(Option); impl Display for W { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b9ef17e..9353a54 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2024-05-17" +channel = "nightly-2024-07-27" components = ["rust-src", "llvm-tools"] diff --git a/sysdata/libraries/render/README.md b/sysdata/libraries/render/README.md new file mode 100644 index 0000000..ac765eb --- /dev/null +++ b/sysdata/libraries/render/README.md @@ -0,0 +1,9 @@ +Rendering interface for SVGA and Software renderers + +# TODO: + +- SVGA Driver + - needs pci driver + - needs init (requiring program) +- Double Buffer mode for Software renderer + - needs init (requiring program) \ No newline at end of file diff --git a/sysdata/libraries/render/src/lib.hb b/sysdata/libraries/render/src/lib.hb new file mode 100644 index 0000000..6cf0ccd --- /dev/null +++ b/sysdata/libraries/render/src/lib.hb @@ -0,0 +1,47 @@ +svga := @use("rel:svga.hb") +software := @use("rel:software.hb") + +// default mode +mode := software + +init := mode.init +doublebuffer := mode.doublebuffer + +// Colours +Color := mode.Color +white := mode.white +black := mode.black +gray := mode.gray +red := mode.red +green := mode.green +yellow := mode.yellow +blue := mode.blue +magenta := mode.magenta +cyan := mode.cyan +light_gray := mode.light_gray +light_red := mode.light_red +light_green := mode.light_green +light_yellow := mode.light_yellow +light_blue := mode.light_blue +light_magenta := mode.light_magenta +light_cyan := mode.light_cyan + +// Drawing +put_pixel := mode.put_pixel +put_rect := mode.put_rect +put_filled_rect := mode.put_filled_rect +put_line := mode.put_line +clear := mode.clear + +// Display +width := mode.width +height := mode.height +dimensions := mode.dimensions +set_height := mode.set_height +set_width := mode.set_width +set_dimensions := mode.set_dimensions +sync := mode.sync + +// Math +UVec2 := struct {x: uint, y: uint} +IVec2 := struct {x: int, y: int} \ 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..d584d44 --- /dev/null +++ b/sysdata/libraries/render/src/software.hb @@ -0,0 +1,263 @@ +.{math, memory} := @use("../../stn/src/lib.hb"); +.{IVec2} := @use("rel:lib.hb") + +Color := struct {b: u8, g: u8, r: u8, a: u8} +white := Color.(255, 255, 255, 255) +black := Color.(0, 0, 0, 255) +gray := Color.(127, 127, 127, 255) +red := Color.(0, 0, 205, 255) +green := Color.(0, 205, 0, 255) +yellow := Color.(0, 205, 205, 255) +blue := Color.(205, 0, 0, 255) +magenta := Color.(205, 0, 205, 255) +cyan := Color.(205, 205, 0, 255) +light_gray := Color.(229, 229, 229, 255) +light_red := Color.(0, 0, 255, 255) +light_green := Color.(0, 255, 0, 255) +light_yellow := Color.(0, 255, 255, 255) +light_blue := Color.(255, 0, 0, 255) +light_magenta := Color.(255, 0, 255, 255) +light_cyan := Color.(255, 255, 0, 255) + +// fb_width := 1024 +// fb_height := 768 +// fb_pixels := fb_width * fb_height +// fb_bytes := fb_pixels << 2 +copy_pixels := 0xC000 >> 2 +// partitions := fb_pixels / copy_pixels +// total_pages := 1 + fb_bytes >> 12 + +ctx := @as(Context, idk) + +Context := struct { + fb: ^Color, + bb: ^Color, + buf: ^Color, + width: int, + height: int, + partitions: int, + pixels: int, + bb_pages: int, + double_buffer: bool, +} + +init := fn(): void { + width := @eca(int, 3, 6, "w\0", 2) + height := @eca(int, 3, 6, "h\0", 2) + // width := 1024 + // height := 768 + pixels := width * height + bytes := pixels << 2 + partitions := pixels / copy_pixels + pages := 1 + bytes >> 12 + back_buffer := create_back_buffer(pages) + ctx = Context.{ + fb: @eca(^Color, 3, 6, "p\0", 2), + bb: back_buffer, + buf: back_buffer, + width, + height, + partitions, + pixels, + bb_pages: pages, + double_buffer: true, + } + return +} + +doublebuffer := fn(enable: bool): void { + if enable { + ctx.buf = ctx.bb + } else { + ctx.buf = ctx.fb + } + ctx.double_buffer = enable + return +} + +create_back_buffer := fn(pages: int): ^Color { + if pages <= 0xFF { + return @bitcast(@inline(memory.request_page, pages)) + } + ptr := @inline(memory.request_page, 255) + remaining := pages - 0xFF + loop if remaining <= 0 break else { + if remaining < 0xFF { + memory.request_page(remaining) + } else { + memory.request_page(0xFF) + } + remaining -= 0xFF + } + return @bitcast(ptr) +} + +clear := fn(color: Color): void { + cursor := ctx.buf + boundary := cursor + 512 + loop if cursor == boundary break else { + *cursor = color + cursor += 1 + } + boundary += 512 * 7 + loop if cursor == boundary break else { + *@as(^[Color; 512], @bitcast(cursor)) = *@as(^[Color; 512], @bitcast(ctx.buf)) + cursor += 512 + } + boundary += copy_pixels - 4096 + loop if cursor == boundary break else { + *@as(^[Color; 4096], @bitcast(cursor)) = *@as(^[Color; 4096], @bitcast(ctx.buf)) + cursor += 4096 + } + boundary += (ctx.partitions - 1) * copy_pixels + loop if cursor == boundary break else { + *@as(^[Color; copy_pixels], @bitcast(cursor)) = *@as(^[Color; copy_pixels], @bitcast(ctx.buf)) + cursor += @sizeof([u8; copy_pixels]) + } + return +} + +sync := fn(): void { + if ctx.double_buffer { + bb := ctx.buf + fb := ctx.fb + boundary := bb + ctx.pixels + loop if bb == boundary break else { + *@as(^[Color; copy_pixels], @bitcast(fb)) = *@as(^[Color; copy_pixels], @bitcast(bb)) + bb += copy_pixels + fb += copy_pixels + } + } + return +} + +width := fn(): int { + return ctx.width +} + +height := fn(): int { + return ctx.height +} + +screenidx := fn(x: int, y: int): int { + return x + ctx.width * y +} + +put_pixel := fn(pos: IVec2, color: Color): void { + *(ctx.buf + @inline(screenidx, pos.x, pos.y)) = color + return +} + +put_filled_rect := fn(pos: IVec2, tr: IVec2, color: Color): void { + x := pos.x + y := pos.y + end := pos + tr + loop if x == end.x break else { + loop if y == end.y break else { + *(ctx.buf + @inline(screenidx, x, y)) = color + y += 1 + } + x += 1 + y = pos.y + } + return +} + +put_rect := fn(pos: IVec2, tr: IVec2, color: Color): void { + x := pos.x + y := pos.y + end := pos + tr + loop if y == end.y break else { + *(ctx.buf + @inline(screenidx, x, y)) = color; + *(ctx.buf + @inline(screenidx, x + tr.x, y)) = color + y += 1 + } + y = pos.y + loop if x == end.x break else { + *(ctx.buf + @inline(screenidx, x, y)) = color; + *(ctx.buf + @inline(screenidx, x, y + tr.y)) = color + x += 1 + } + return +} + +put_line_low := fn(p0: IVec2, p1: IVec2, color: Color): void { + dx := p1.x - p0.x + dy := p1.y - p0.y + yi := 1 + if dy < 0 { + yi = 0 - 1 + dy = 0 - dy + } + D := 2 * dy - dx + y := p0.y + x := p0.x + loop if x == p1.x break else { + *(ctx.buf + @inline(screenidx, x, y)) = color + if D > 0 { + y += yi + D += 2 * (dy - dx) + } else { + D += 2 * dy + } + x += 1 + } + return +} + +put_line_high := fn(p0: IVec2, p1: IVec2, color: Color): void { + dx := p1.x - p0.x + dy := p1.y - p0.y + xi := 1 + if dy < 0 { + xi = 0 - 1 + dx = 0 - dx + } + D := 2 * dx - dy + x := p0.x + y := p0.y + loop if y == p1.y break else { + *(ctx.buf + @inline(screenidx, x, y)) = color + if D > 0 { + x += xi + D += 2 * (dx - dy) + } else { + D += 2 * dx + } + y += 1 + } + return +} + +put_line := fn(p0: IVec2, p1: IVec2, color: Color): void { + if @inline(math.abs, p1.y - p0.y) < @inline(math.abs, p1.x - p0.x) { + if p0.x > p1.x { + @inline(put_line_low, p1, p0, color) + } else { + @inline(put_line_low, p0, p1, color) + } + } else { + if p0.y > p1.y { + @inline(put_line_high, p1, p0, color) + } else { + @inline(put_line_high, p0, p1, color) + } + } + return +} + +set_height := fn(new: int): void { + return +} + +set_width := fn(new: int): void { + return +} + +dimensions := fn(): IVec2 { + return .(ctx.width, ctx.height) +} + +set_dimensions := fn(new: IVec2): void { + return +} \ No newline at end of file diff --git a/sysdata/libraries/render/src/svga.hb b/sysdata/libraries/render/src/svga.hb new file mode 100644 index 0000000..8d878c3 --- /dev/null +++ b/sysdata/libraries/render/src/svga.hb @@ -0,0 +1,91 @@ +.{pci, memory, string, log} := @use("../../stn/src/lib.hb"); +.{IVec2} := @use("rel:lib.hb") + +Color := struct {b: u8, g: u8, r: u8, a: u8} +white := Color.(255, 255, 255, 255) +black := Color.(0, 0, 0, 255) +gray := Color.(127, 127, 127, 255) +red := Color.(0, 0, 205, 255) +green := Color.(0, 205, 0, 255) +yellow := Color.(0, 205, 205, 255) +blue := Color.(205, 0, 0, 255) +magenta := Color.(205, 0, 205, 255) +cyan := Color.(205, 205, 0, 255) +light_gray := Color.(229, 229, 229, 255) +light_red := Color.(0, 0, 255, 255) +light_green := Color.(0, 255, 0, 255) +light_yellow := Color.(0, 255, 255, 255) +light_blue := Color.(255, 0, 0, 255) +light_magenta := Color.(255, 0, 255, 255) +light_cyan := Color.(255, 255, 0, 255) + +clear := fn(color: Color): void { + return +} + +width := fn(): int { + return 0 +} + +height := fn(): int { + return 0 +} + +dimensions := fn(): IVec2 { + return .(0, 0) +} + +put_pixel := fn(position: IVec2, color: Color): void { + return +} + +put_filled_rect := fn(pos: IVec2, tr: IVec2, color: Color): void { + return +} + +put_rect := fn(pos: IVec2, tr: IVec2, color: Color): void { + return +} + +put_line_low := fn(p0: IVec2, p1: IVec2, color: Color): void { + return +} +// do not use, use line() instead +put_line_high := fn(p0: IVec2, p1: IVec2, color: Color): void { + return +} + +put_line := fn(p0: IVec2, p1: IVec2, color: Color): void { + return +} + +set_height := fn(new: int): void { + return +} + +set_width := fn(new: int): void { + return +} + +set_dimensions := fn(new: IVec2): void { + return +} + +sync := fn(): void { + return +} + +init := fn(): void { + b := memory.request_page(1) + bus := 0 + device := 0 + loop if bus == 256 break else { + loop if device == 32 break else { + a := pci.config_read(0, 0, 0, 0) + log.info(string.display_int(a, b)) + device += 1 + } + bus += 1 + } + return +} \ No newline at end of file diff --git a/sysdata/libraries/stn/src/lib.hb b/sysdata/libraries/stn/src/lib.hb index fa4414b..be4dac2 100644 --- a/sysdata/libraries/stn/src/lib.hb +++ b/sysdata/libraries/stn/src/lib.hb @@ -3,4 +3,5 @@ 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") \ No newline at end of file +random := @use("rel:random.hb") +pci := @use("rel:pci.hb") \ No newline at end of file diff --git a/sysdata/libraries/stn/src/math.hb b/sysdata/libraries/stn/src/math.hb index 94ee78a..4c4f87e 100644 --- a/sysdata/libraries/stn/src/math.hb +++ b/sysdata/libraries/stn/src/math.hb @@ -1,14 +1,15 @@ -SIZEOF_INT := 31 +shift := 31 +// following only work for: int abs := fn(x: int): int { - mask := x >> SIZEOF_INT + mask := x >> shift return (x ^ mask) - mask } min := fn(a: int, b: int): int { c := a - b - return b + (c & c >> SIZEOF_INT) + return b + (c & c >> shift) } -max := fn(a: int, b: int): int { +max := fn(a: int, b: uint): int { c := a - b - return a - (c & c >> SIZEOF_INT) + return a - (c & c >> shift) } \ No newline at end of file diff --git a/sysdata/libraries/stn/src/memory.hb b/sysdata/libraries/stn/src/memory.hb index 0d25d87..7d4e71f 100644 --- a/sysdata/libraries/stn/src/memory.hb +++ b/sysdata/libraries/stn/src/memory.hb @@ -19,26 +19,26 @@ release_page := fn(ptr: ^u8, page_count: u8): void { outb := fn(addr: u16, value: u8): void { msg := "\0\0\0\0\0"; - *msg = 1; - *(msg + 1) = 0; + *@as(^u8, msg) = @as(u8, 1); + *@as(^u8, msg + 1) = @as(u8, 0); *@as(^u16, @bitcast(msg + 2)) = addr; - *(msg + 4) = value + *@as(^u8, msg + 4) = value @eca(void, 3, 3, msg, 5) return } inb := fn(addr: u16): u8 { msg := "\0\0\0\0"; - *msg = 0; - *(msg + 1) = 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"; - *msg = 1; - *(msg + 1) = 2; + *@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) @@ -47,8 +47,8 @@ outl := fn(addr: u16, value: u32): void { inl := fn(addr: u16): u32 { msg := "\0\0\0\0"; - *msg = 0; - *(msg + 1) = 2; + *@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) } \ No newline at end of file diff --git a/sysdata/libraries/stn/src/pci.hb b/sysdata/libraries/stn/src/pci.hb new file mode 100644 index 0000000..c07b518 --- /dev/null +++ b/sysdata/libraries/stn/src/pci.hb @@ -0,0 +1,50 @@ +.{inl, outl} := @use("rel:memory.hb") + +config_read := fn(bus: u8, device: u8, func: u8, offset: u8): u32 { + lbus := @as(u32, bus) + ldevice := @as(u32, device) + lfunc := @as(u32, func) + loffset := @as(u32, offset) + + address := lbus << 16 | ldevice << 11 | lfunc << 8 | loffset & 0xFC | @as(u32, 0x80000000) + + outl(0xCF8, address) + return inl(0xCFC) +} + +config_write := fn(bus: u8, device: u8, func: u8, offset: u8, value: u32): void { + lbus := @as(u32, bus) + ldevice := @as(u32, device) + lfunc := @as(u32, func) + loffset := @as(u32, offset) + + address := lbus << 16 | ldevice << 11 | lfunc << 8 | loffset & 0xFC | @as(u32, 0x80000000) + + outl(0xCF8, address) + outl(0xCFC, value) +} + +get_header_type := fn(bus: u8, device: u8, func: u8): u8 { + return @as(u8, config_read(bus, device, func, 0xC) >> 16 & 0xFF) +} + +Ids := struct {vendor: u16, device: u16} + +get_ids := fn(bus: u8, device: u8, func: u8): Ids { + res := config_read(bus, device, func, 0) + return .(@as(u16, res >> 16 & 0xFFFF), @as(u16, res & 0xFFFF)) +} + +PciDeviceInfo := struct {header_type: u8, device: u8, bus: u8, device_id: Ids, full_class: u16, rev_id: u8} + +check_device := fn(bus: u8, device: u8): PciDeviceInfo { + ids := get_ids(bus, device, 0) + if ids.vendor == 0xFFFF { + return .(0, 0, 0, .(0, 0), 0, 0) + } + reg2 := config_read(bus, device, 0, 0x8) + class := @as(u16, reg2 >> 16 & 0xFFFF) + header_type := get_header_type(bus, device, 0) + + return .(header_type, device, bus, ids, class, @as(u8, reg2 & 0xFF)) +} \ No newline at end of file diff --git a/sysdata/libraries/stn/src/random.hb b/sysdata/libraries/stn/src/random.hb index dbff80a..b515d1c 100644 --- a/sysdata/libraries/stn/src/random.hb +++ b/sysdata/libraries/stn/src/random.hb @@ -1,8 +1,7 @@ -integer := fn(min: int, max: int): int { - rng := @eca(int, 3, 4) +integer := fn(): int { + return @eca(int, 3, 4) +} - if min != 0 | max != 0 { - return rng % (max - min + 1) + min - } - return rng +integer_range := fn(min: int, max: int): int { + return @eca(int, 3, 4) % (max - min + 1) + min } \ No newline at end of file diff --git a/sysdata/programs/diskio_driver/src/main.hb b/sysdata/programs/diskio_driver/src/main.hb index 1800402..e5edf84 100644 --- a/sysdata/programs/diskio_driver/src/main.hb +++ b/sysdata/programs/diskio_driver/src/main.hb @@ -2,7 +2,7 @@ main := fn(): int { // shuts down ableOS - //memory.outb(0xF400, 0) + // memory.outb(0xF400, 0) a := memory.inb(0x4600) b := memory.inb(0x4700) diff --git a/sysdata/programs/fb_driver/README.md b/sysdata/programs/fb_driver/README.md deleted file mode 100644 index b354f04..0000000 --- a/sysdata/programs/fb_driver/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Framebuffer Driver -A simple framebuffer driver. \ No newline at end of file diff --git a/sysdata/programs/fb_driver/UNTESTED_FUNCTIONS b/sysdata/programs/fb_driver/UNTESTED_FUNCTIONS deleted file mode 100644 index 7c7d0f5..0000000 --- a/sysdata/programs/fb_driver/UNTESTED_FUNCTIONS +++ /dev/null @@ -1,7 +0,0 @@ -color.blend - -lib.composite -lib.screen2rect -lib.rect2screen - -draw.tri_line \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/color.hb b/sysdata/programs/fb_driver/src/color.hb deleted file mode 100644 index 802c127..0000000 --- a/sysdata/programs/fb_driver/src/color.hb +++ /dev/null @@ -1,27 +0,0 @@ -ColorBGRA := struct {b: u8, g: u8, r: u8, a: u8} - -/* ALL the colo(u)rs you will ever need. - they dont work though, cause hblang bug (reg id leaked, again) */ -WHITE := ColorBGRA.{b: 255, g: 255, r: 255, a: 255} -BLACK := ColorBGRA.{b: 0, g: 0, r: 0, a: 255} -GRAY := ColorBGRA.{b: 127, g: 127, r: 127, a: 255} -RED := ColorBGRA.{b: 0, g: 0, r: 205, a: 255} -GREEN := ColorBGRA.{b: 0, g: 205, r: 0, a: 255} -YELLOW := ColorBGRA.{b: 0, g: 205, r: 205, a: 255} -BLUE := ColorBGRA.{b: 205, g: 0, r: 0, a: 255} -MAGENTA := ColorBGRA.{b: 205, g: 0, r: 205, a: 255} -CYAN := ColorBGRA.{b: 205, g: 205, r: 0, a: 255} -LIGHTGRAY := ColorBGRA.{b: 229, g: 229, r: 229, a: 255} -LIGHTRED := ColorBGRA.{b: 0, g: 0, r: 255, a: 255} -LIGHTGREEN := ColorBGRA.{b: 0, g: 255, r: 0, a: 255} -LIGHTYELLOW := ColorBGRA.{b: 0, g: 255, r: 255, a: 255} -LIGHTBLUE := ColorBGRA.{b: 255, g: 0, r: 0, a: 255} -LIGHTMAGENTA := ColorBGRA.{b: 255, g: 0, r: 255, a: 255} -LIGHTCYAN := ColorBGRA.{b: 255, g: 255, r: 0, a: 255} - -// i have no clue if this works. please don't me ask how it works. -koniifer -blend := fn(fg: ColorBGRA, bg: ColorBGRA): ColorBGRA { - s := fg + bg - m := s - ((fg ^ bg) & 0x1010100) & 0x1010100 - return (m >> 8 | 0x1000000 * (s < fg)) * 0xFF | s - m -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/draw.hb b/sysdata/programs/fb_driver/src/draw.hb deleted file mode 100644 index 089dc38..0000000 --- a/sysdata/programs/fb_driver/src/draw.hb +++ /dev/null @@ -1,113 +0,0 @@ -.{draw_pixel, screenidx, Transform, Point, Rect, Buffer, FB_WIDTH} := @use("rel:lib.hb"); -.{math} := @use("../../../libraries/stn/src/lib.hb"); -.{ColorBGRA} := @use("rel:color.hb") - -/* draws a filled rectangle to the screen - will be optimised later */ -rect_fill := fn(buffer: Buffer, pos: Point, tr: Transform, color: ColorBGRA): void { - n := 0 - loop if n == tr.height * tr.width break else { - *(buffer.write + @inline(screenidx, .(n % tr.width + pos.x, n / tr.width + pos.y))) = color - n += 1 - } - return -} -/* draws a wireframe rectangle to the screen - will also be optimised later */ -rect_line := fn(buffer: Buffer, pos: Point, tr: Transform, color: ColorBGRA, thickness: int): void { - t := 0 - y := 0 - x := 0 - loop if t == thickness break else { - y = pos.y - x = pos.x - loop if y == pos.y + tr.height break else { - *(buffer.write + @inline(screenidx, .(pos.x + t, y))) = color; - *(buffer.write + @inline(screenidx, .(pos.x + tr.width - t, y))) = color - y += 1 - } - loop if x == pos.x + tr.width break else { - *(buffer.write + @inline(screenidx, .(x, pos.y + t))) = color; - *(buffer.write + @inline(screenidx, .(x, pos.y + tr.height - t))) = color - x += 1 - } - t += 1 - } - return -} - -// do not use, use line() instead -line_low := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA): void { - dx := p1.x - p0.x - dy := p1.y - p0.y - yi := 1 - if dy < 0 { - yi = 0 - 1 - dy = 0 - dy - } - D := 2 * dy - dx - y := p0.y - x := p0.x - loop if x == p1.x break else { - *(buffer.write + @inline(screenidx, .(x, y))) = color - if D > 0 { - y += yi - D += 2 * (dy - dx) - } else { - D += 2 * dy - } - x += 1 - } - return -} -// do not use, use line() instead -line_high := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA): void { - dx := p1.x - p0.x - dy := p1.y - p0.y - xi := 1 - if dy < 0 { - xi = 0 - 1 - dx = 0 - dx - } - D := 2 * dx - dy - x := p0.x - y := p0.y - loop if y == p1.y break else { - *(buffer.write + @inline(screenidx, .(x, y))) = color - if D > 0 { - x += xi - D += 2 * (dx - dy) - } else { - D += 2 * dx - } - y += 1 - } - return -} - -/* implementation of Bresenham's line algorithm - TODO: thickness, might need better math library */ -line := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA, thickness: int): void { - if @inline(math.abs, p1.y - p0.y) < @inline(math.abs, p1.x - p0.x) { - if p0.x > p1.x { - @inline(line_low, buffer, p1, p0, color) - } else { - @inline(line_low, buffer, p0, p1, color) - } - } else { - if p0.y > p1.y { - @inline(line_high, buffer, p1, p0, color) - } else { - @inline(line_high, buffer, p0, p1, color) - } - } - return -} - -// theoretically draws a wireframe polygon to the screen. untested. -tri_line := fn(buffer: Buffer, p0: Point, p1: Point, p2: Point, color: ColorBGRA, thickness: int): void { - line(buffer, p0, p1, color, thickness) - line(buffer, p1, p2, color, thickness) - line(buffer, p2, p0, color, thickness) - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/amogus.hb b/sysdata/programs/fb_driver/src/examples/amogus.hb deleted file mode 100644 index b045f47..0000000 --- a/sysdata/programs/fb_driver/src/examples/amogus.hb +++ /dev/null @@ -1,26 +0,0 @@ -.{rect_line} := @use("../draw.hb"); -.{present, create_buffer, clear} := @use("../lib.hb") - -/* expected result: - the impostor travels left and loops around the screen */ - -example := fn(): void { - // Creates a back buffer, which we write to, to avoid screen flickering - buffer := create_buffer() - x := 0 - loop { - // draw all our shapes to the back buffer - rect_line(buffer, .(200 - x, 80), .(430, 380), .(0, 0, 255, 0), 1) - rect_line(buffer, .(630 - x, 120), .(120, 300), .(0, 0, 255, 0), 1) - rect_line(buffer, .(200 - x, 460), .(160, 270), .(0, 0, 255, 0), 1) - rect_line(buffer, .(470 - x, 460), .(160, 270), .(0, 0, 255, 0), 1) - rect_line(buffer, .(140 - x, 140), .(340, 250), .(255, 255, 0, 0), 1) - /* push the back buffer to the front buffer - this displays our image to the screen */ - present(buffer) - // erase our old image - clear(buffer, .(0, 0, 0, 0)) - x += 1 - } - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/buffers.hb b/sysdata/programs/fb_driver/src/examples/buffers.hb deleted file mode 100644 index 4157408..0000000 --- a/sysdata/programs/fb_driver/src/examples/buffers.hb +++ /dev/null @@ -1,19 +0,0 @@ -.{front_buffer_ptr, front_buffer_copy, get_front_buffer, Buffer} := @use("../lib.hb"); - -example := fn(): void { - // you can get the raw frontbuffer pointer using - raw_buffer := front_buffer_ptr - // this buffer is the one that you write individual pixels to - - // you can gete the copy frontbuffer pointer using - copy_buffer := front_buffer_copy - /* this buffer is used for massive writing - operations by taking advantage of - static copying */ - - // you can construct a buffer like so - buffer := Buffer.{write: raw_buffer, copy: copy_buffer} - // this is the operation that get_front_buffer does - same_buffer := get_front_buffer() - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/colors.hb b/sysdata/programs/fb_driver/src/examples/colors.hb deleted file mode 100644 index 1d29d04..0000000 --- a/sysdata/programs/fb_driver/src/examples/colors.hb +++ /dev/null @@ -1,27 +0,0 @@ -.{clear, create_buffer, present} := @use("../lib.hb"); -.{ColorBGRA} := @use("../color.hb") - -/* expected result: - the screen fades from green to cyan - then wraps back to green - note that this may happen too fast for you to notice... */ - -example := fn(): void { - // creates a back buffer, which we write to, to avoid screen flickering - buffer := create_buffer() - color := ColorBGRA.(0, 255, 0, 255) - /* have to explicitly say 0 is a u8, or we do something crazy to the colors. - looks like a compiler bug */ - n := @as(u8, 0) - 1 - loop { - clear(buffer, color) - present(buffer) - /* because for some reason just comparing doesnt work. - also looks like a compiler bug */ - if (color.b & 255) == 255 | (color.b & 255) == 0 { - n = 0 - n - } - color.b += n - } - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/lines.hb b/sysdata/programs/fb_driver/src/examples/lines.hb deleted file mode 100644 index 11adde7..0000000 --- a/sysdata/programs/fb_driver/src/examples/lines.hb +++ /dev/null @@ -1,25 +0,0 @@ -.{line} := @use("../draw.hb"); -.{clear, create_buffer, present, FB_WIDTH, FB_HEIGHT, Point} := @use("../lib.hb") - -/* expected result: - a 3d-looking blue set of lines - created on a blue background */ - -example := fn(): void { - // creates a back buffer, which we write to, to avoid screen flickering - buffer := create_buffer() - // fill the screen in blue - clear(buffer, .(100, 50, 0, 255)) - p0 := Point.(0, 0 - 1) - p1 := Point.(0, FB_HEIGHT - 1) - loop if p0.y >= FB_HEIGHT break else { - // draw a line between p0 and p1 - line(buffer, p0, p1, .(255, 180, 100, 255), 3) - p0.y += FB_HEIGHT >> 6 - p1.x += FB_WIDTH >> 6 - } - /* push the back buffer to the front buffer - this displays our image to the screen */ - present(buffer) - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/random.hb b/sysdata/programs/fb_driver/src/examples/random.hb deleted file mode 100644 index 75ecb81..0000000 --- a/sysdata/programs/fb_driver/src/examples/random.hb +++ /dev/null @@ -1,17 +0,0 @@ -.{clear, get_front_buffer, screenidx} := @use("../lib.hb"); -.{ColorBGRA} := @use("../color.hb"); -.{random} := @use("../../../../libraries/stn/src/lib.hb") - -example := fn(): void { - buffer := get_front_buffer() - clear(buffer) - loop { - x := random.integer(0, 1024) - y := random.integer(0, 768) - r := random.integer(0, 255) - g := random.integer(0, 75) - b := random.integer(0, 155); - *(buffer.write + @inline(screenidx, .(x, y))) = ColorBGRA.(b, g, r, 255) - } - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/square.hb b/sysdata/programs/fb_driver/src/examples/square.hb deleted file mode 100644 index 84b3994..0000000 --- a/sysdata/programs/fb_driver/src/examples/square.hb +++ /dev/null @@ -1,32 +0,0 @@ -.{rect_line} := @use("../draw.hb"); -.{clear, create_buffer, present, Point, FB_HEIGHT, FB_WIDTH} := @use("../lib.hb") - -/* expected result: - the white outline of a square bounces around the screen */ - -example := fn(): void { - // creates a back buffer, which we write to, to avoid screen flickering - buffer := create_buffer() - vel := Point.{x: 1, y: 1} - pos := Point.{x: 100, y: 100} - loop { - // draw the square at our current position - rect_line(buffer, pos, .(100, 100), .(255, 255, 255, 255), 3) - /* push the back buffer to the front buffer - this displays our image to the screen */ - present(buffer) - // erase our old image - clear(buffer, .(0, 0, 0, 0)) - - // bounce the square if it touches the screen edges - if pos.x == 0 | pos.x == FB_WIDTH - 100 { - vel.x = 0 - vel.x - } - if pos.y == 0 | pos.y == FB_HEIGHT - 100 { - vel.y = 0 - vel.y - } - - pos += vel - } - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/strobe.hb b/sysdata/programs/fb_driver/src/examples/strobe.hb deleted file mode 100644 index e46653c..0000000 --- a/sysdata/programs/fb_driver/src/examples/strobe.hb +++ /dev/null @@ -1,20 +0,0 @@ -.{clear, create_buffer, present} := @use("../lib.hb") - -/* expected result: (EPILEPSY WARNING) - the screen rapidly flashes red then black */ - -example := fn(): void { - // creates a back buffer, which we write to, to avoid screen flickering - buffer := create_buffer() - loop { - // screen go red - clear(buffer, .(0, 0, 255, 0)) - // show the red - present(buffer) - // screen go black - clear(buffer, .(0, 255, 255, 0)) - // show the black - present(buffer) - } - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/lib.hb b/sysdata/programs/fb_driver/src/lib.hb deleted file mode 100644 index ca91a63..0000000 --- a/sysdata/programs/fb_driver/src/lib.hb +++ /dev/null @@ -1,88 +0,0 @@ -.{memory, math} := @use("../../../libraries/stn/src/lib.hb"); -.{ColorBGRA, blend} := @use("rel:color.hb") - -FB_WIDTH := 1024 -FB_HEIGHT := 768 -FB_PIXELS := FB_WIDTH * FB_HEIGHT -FB_BYTES := FB_PIXELS << 2 -// actual enforced max copy size is 0xFFFF, but this was faster -MAX_COPY_SIZE := 0x1800 -COPY_PIXELS := math.min(MAX_COPY_SIZE, FB_BYTES) >> 2 -PARTITIONS := FB_PIXELS / COPY_PIXELS -TOTAL_PAGES := 1 + FB_BYTES >> 12 - -Buffer := struct {write: ^ColorBGRA, copy: ^[ColorBGRA; COPY_PIXELS]} -Point := struct {x: int, y: int} -Transform := struct {width: int, height: int} - -front_buffer_ptr := @as(^ColorBGRA, @bitcast(0xFFFF8000C0000000)) -front_buffer_copy := @as(^[ColorBGRA; COPY_PIXELS], @bitcast(front_buffer_ptr)) - -get_front_buffer := fn(): Buffer { - // trying to return front_buffer_ptr or front_buffer_copy causes reg id leak - buffer := Buffer.{write: front_buffer_ptr, copy: front_buffer_copy} - return buffer -} -/* this is separate to create_raw_buffer because returning a Buffer from - create_raw_buffer causes reg id leak */ -create_buffer := fn(): Buffer { - ptr := @inline(create_raw_buffer) - buffer := Buffer.{write: ptr, copy: @as(^[ColorBGRA; COPY_PIXELS], @bitcast(ptr))} - return buffer -} -create_raw_buffer := fn(): ^ColorBGRA { - if TOTAL_PAGES <= 0xFF { - return @bitcast(@inline(memory.request_page, TOTAL_PAGES)) - } - ptr := @inline(memory.request_page, 255) - remaining := TOTAL_PAGES - 0xFF - loop if remaining <= 0 break else { - if remaining < 0xFF { - memory.request_page(remaining) - } else { - memory.request_page(0xFF) - } - remaining -= 0xFF - } - return @bitcast(ptr) -} -// sets the buffer to the color. very fast. -clear := fn(buffer: Buffer, color: ColorBGRA): void { - n := 0 - // write the first pixel chunk - loop if n >= COPY_PIXELS break else { - *(buffer.write + n) = color - n += 1 - } - n = 1 - // copy that pixel chunk through the buffer, taking advantage of memory copying - loop if n >= PARTITIONS break else { - *(buffer.copy + n) = *buffer.copy - n += 1 - } - return -} -// only required to be called when using a back buffer. if using single-buffered rendering, do not call this. -present := fn(buffer: Buffer): void { - n := 0 - // copy chunks of the read buffer to the front buffer - loop if n >= PARTITIONS break else { - *(front_buffer_copy + n) = *(buffer.copy + n) - n += 1 - } - return -} -// composites the contents of buffer1 into buffer2, accounting for alpha transparency -// i dont know if it works. i have not tested it. it probably doesnt work -composite := fn(buffer1: Buffer, buffer2: Buffer): void { - n := 0 - loop if n == FB_PIXELS break else { - bg := *(buffer2.write + n); - *(buffer2.write + n) = blend(*(buffer1.write + n), bg) - n += 1 - } - return -} -screenidx := fn(pos: Point): int { - return pos.x + FB_WIDTH * pos.y -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/main.hb b/sysdata/programs/fb_driver/src/main.hb deleted file mode 100644 index e1c71c2..0000000 --- a/sysdata/programs/fb_driver/src/main.hb +++ /dev/null @@ -1,6 +0,0 @@ -.{example} := @use("./examples/lines.hb") - -main := fn(): int { - @inline(example) - return 0 -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/meta.toml b/sysdata/programs/render_example/meta.toml similarity index 71% rename from sysdata/programs/fb_driver/meta.toml rename to sysdata/programs/render_example/meta.toml index c2659bc..4712b53 100644 --- a/sysdata/programs/fb_driver/meta.toml +++ b/sysdata/programs/render_example/meta.toml @@ -1,6 +1,6 @@ [package] -name = "fb_driver" -authors = ["able", "aurlex"] +name = "render_example" +authors = ["koniifer"] [dependants.libraries] diff --git a/sysdata/programs/render_example/src/examples/amogus.hb b/sysdata/programs/render_example/src/examples/amogus.hb new file mode 100644 index 0000000..eca4e48 --- /dev/null +++ b/sysdata/programs/render_example/src/examples/amogus.hb @@ -0,0 +1,20 @@ +render := @use("../../../../libraries/render/src/lib.hb") + +/* expected result: + the impostor travels left and loops around the screen */ + +example := fn(): void { + render.init() + x := 0 + loop { + render.put_rect(.(200 - x, 80), .(430, 380), render.red) + render.put_rect(.(630 - x, 120), .(120, 300), render.red) + render.put_rect(.(200 - x, 460), .(160, 270), render.red) + render.put_rect(.(470 - x, 460), .(160, 270), render.red) + render.put_rect(.(140 - x, 140), .(340, 250), render.cyan) + render.sync() + render.clear(render.black) + x += 1 + } + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/colors.hb b/sysdata/programs/render_example/src/examples/colors.hb new file mode 100644 index 0000000..5451d3d --- /dev/null +++ b/sysdata/programs/render_example/src/examples/colors.hb @@ -0,0 +1,21 @@ +render := @use("../../../../libraries/render/src/lib.hb") + +/* expected result: + the screen fades from cyan to green + then wraps back to cyan + note that this may happen too fast for you to notice... */ + +example := fn(): void { + render.init() + color := render.light_cyan + n := @as(u8, 1) + loop { + render.clear(color) + render.sync() + if (color.b & 255) == 255 | (color.b & 255) == 0 { + n = 0 - n + } + color.b += n + } + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/lines.hb b/sysdata/programs/render_example/src/examples/lines.hb new file mode 100644 index 0000000..5a41609 --- /dev/null +++ b/sysdata/programs/render_example/src/examples/lines.hb @@ -0,0 +1,22 @@ +render := @use("../../../../libraries/render/src/lib.hb") + +/* expected result: + a 3d-looking set of blue lines + created on a blue background */ + +example := fn(): void { + render.init() + render.clear(.(100, 50, 0, 255)) + width := render.width() + height := render.height() + p0 := render.IVec2.(0, 0) + p1 := render.IVec2.(0, height) + loop if p0.y >= height break else { + render.put_line(p0, p1, .(255, 180, 100, 255)) + render.put_line(.(width, height) - p0, .(width, height) - p1, .(255, 180, 100, 255)) + p0.y += height >> 6 + p1.x += width >> 6 + } + render.sync() + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/random.hb b/sysdata/programs/render_example/src/examples/random.hb new file mode 100644 index 0000000..7b0fbbb --- /dev/null +++ b/sysdata/programs/render_example/src/examples/random.hb @@ -0,0 +1,17 @@ +.{random} := @use("../../../../libraries/stn/src/lib.hb") +render := @use("../../../../libraries/render/src/lib.hb") + +example := fn(): void { + render.init() + render.doublebuffer(false) + render.clear(render.black) + loop { + x := random.integer_range(0, 1024) + y := random.integer_range(0, 768) + r := random.integer_range(0, 255) + g := random.integer_range(0, 75) + b := random.integer_range(0, 155) + render.put_pixel(.(x, y), .(b, g, r, 255)) + } + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/square.hb b/sysdata/programs/render_example/src/examples/square.hb new file mode 100644 index 0000000..def4fea --- /dev/null +++ b/sysdata/programs/render_example/src/examples/square.hb @@ -0,0 +1,27 @@ +render := @use("../../../../libraries/render/src/lib.hb") + +/* expected result: + the white outline of a square bounces around the screen */ + +example := fn(): void { + render.init() + vel := render.IVec2.(1, 1) + pos := render.IVec2.(100, 100) + width := render.width() + height := render.height() + loop { + render.put_rect(pos, .(100, 100), render.white) + render.sync() + render.clear(render.black) + + if pos.x == 0 | pos.x == width - 100 { + vel.x = 0 - vel.x + } + if pos.y == 0 | pos.y == height - 100 { + vel.y = 0 - vel.y + } + + pos += vel + } + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/strobe.hb b/sysdata/programs/render_example/src/examples/strobe.hb new file mode 100644 index 0000000..4681cc5 --- /dev/null +++ b/sysdata/programs/render_example/src/examples/strobe.hb @@ -0,0 +1,15 @@ +render := @use("../../../../libraries/render/src/lib.hb") + +/* expected result: (EPILEPSY WARNING) + the screen rapidly flashes red then black */ + +example := fn(): void { + render.init() + loop { + render.clear(render.red) + render.sync() + render.clear(render.yellow) + render.sync() + } + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/svga.hb b/sysdata/programs/render_example/src/examples/svga.hb new file mode 100644 index 0000000..101aa6f --- /dev/null +++ b/sysdata/programs/render_example/src/examples/svga.hb @@ -0,0 +1,8 @@ +render := @use("../../../../libraries/render/src/lib.hb") + +render.mode = render.svga + +example := fn(): void { + render.init() + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/main.hb b/sysdata/programs/render_example/src/main.hb new file mode 100644 index 0000000..35b2706 --- /dev/null +++ b/sysdata/programs/render_example/src/main.hb @@ -0,0 +1,6 @@ +.{example} := @use("./examples/amogus.hb") + +main := fn(): void { + @inline(example) + return +} \ No newline at end of file diff --git a/sysdata/programs/a_serial_driver/README.md b/sysdata/programs/serial_driver/README.md similarity index 100% rename from sysdata/programs/a_serial_driver/README.md rename to sysdata/programs/serial_driver/README.md diff --git a/sysdata/programs/a_serial_driver/meta.toml b/sysdata/programs/serial_driver/meta.toml similarity index 84% rename from sysdata/programs/a_serial_driver/meta.toml rename to sysdata/programs/serial_driver/meta.toml index 812e297..33de705 100644 --- a/sysdata/programs/a_serial_driver/meta.toml +++ b/sysdata/programs/serial_driver/meta.toml @@ -1,5 +1,5 @@ [package] -name = "a_serial_driver" +name = "serial_driver" authors = ["Able"] [dependants.libraries] diff --git a/sysdata/programs/a_serial_driver/src/main.hb b/sysdata/programs/serial_driver/src/main.hb similarity index 90% rename from sysdata/programs/a_serial_driver/src/main.hb rename to sysdata/programs/serial_driver/src/main.hb index c98054f..4cb3f11 100644 --- a/sysdata/programs/a_serial_driver/src/main.hb +++ b/sysdata/programs/serial_driver/src/main.hb @@ -1,5 +1,4 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); -.{log, string, memory, buffer} := stn +.{memory, buffer} := @use("../../../libraries/stn/src/lib.hb") serial_print := fn(ptr: ^u8): void { letter := 0 diff --git a/sysdata/programs/serial_driver_test/src/main.hb b/sysdata/programs/serial_driver_test/src/main.hb index a9af0fa..6893bc2 100644 --- a/sysdata/programs/serial_driver_test/src/main.hb +++ b/sysdata/programs/serial_driver_test/src/main.hb @@ -1,4 +1,4 @@ -.{string, memory, buffer} := @use("../../../libraries/stn/src/lib.hb") +.{string, buffer} := @use("../../../libraries/stn/src/lib.hb") log_info := fn(): void { a := buffer.search("XNumber\0") diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index ee0625c..98caf84 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -17,17 +17,17 @@ resolution = "1024x768x24" [boot.limine.ableos.modules] -# [boot.limine.ableos.modules.tests] -# path = "boot:///tests.hbf" +[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.0serial_driver] +path = "boot:///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.render_example] +path = "boot:///render_example.hbf" [boot.limine.ableos.modules.serial_driver_test] path = "boot:///serial_driver_test.hbf"