From 3c3c156eb0e7f740c16f0d04daca32529de45e62 Mon Sep 17 00:00:00 2001 From: Able Date: Fri, 1 Nov 2024 13:09:12 -0500 Subject: [PATCH 1/2] misc changes + mouse driver work --- Cargo.lock | 6 +- repbuild/Cargo.toml | 2 +- repbuild/src/dev.rs | 7 +- repbuild/src/main.rs | 3 +- sysdata/libraries/render/src/software.hb | 2 +- sysdata/programs/horizon/src/main.hb | 7 ++ .../horizon_testing_program/src/main.hb | 2 + sysdata/programs/mouse_driver/README.md | 1 + sysdata/programs/mouse_driver/meta.toml | 11 +++ sysdata/programs/mouse_driver/src/main.hb | 79 +++++++++++++++++++ .../render_example/src/examples/text.hb | 7 +- sysdata/programs/render_example/src/main.hb | 4 +- sysdata/system_config.toml | 8 +- 13 files changed, 120 insertions(+), 19 deletions(-) create mode 100644 sysdata/programs/mouse_driver/README.md create mode 100644 sysdata/programs/mouse_driver/meta.toml create mode 100644 sysdata/programs/mouse_driver/src/main.hb diff --git a/Cargo.lock b/Cargo.lock index 5b028ce..b20adbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -253,12 +253,12 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#faa8dd2e6fabe2e0e4a375e677171856da491c61" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#38a00cbaa09434324d209fc5f59480d2b6743fb3" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#faa8dd2e6fabe2e0e4a375e677171856da491c61" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#38a00cbaa09434324d209fc5f59480d2b6743fb3" dependencies = [ "hashbrown 0.15.0", "hbbytecode", @@ -270,7 +270,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#faa8dd2e6fabe2e0e4a375e677171856da491c61" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#38a00cbaa09434324d209fc5f59480d2b6743fb3" dependencies = [ "hbbytecode", ] diff --git a/repbuild/Cargo.toml b/repbuild/Cargo.toml index ea41857..a681d45 100644 --- a/repbuild/Cargo.toml +++ b/repbuild/Cargo.toml @@ -22,7 +22,7 @@ fatfs = "0.3" toml = "0.8" hblang = { git = "https://git.ablecorp.us/AbleOS/holey-bytes.git", features = [ "std", - "opts", + # "opts", ], default-features = false } log = "0.4" raw-cpuid = "11" diff --git a/repbuild/src/dev.rs b/repbuild/src/dev.rs index 7186d39..d2a66e3 100644 --- a/repbuild/src/dev.rs +++ b/repbuild/src/dev.rs @@ -47,7 +47,6 @@ impl Package { for (count, (name, table)) in bin_table.into_iter().enumerate() { // if count != 0 { - println!("{}", name); binaries.push(name.clone()); // } } @@ -75,7 +74,7 @@ impl Package { &path, Options { fmt: true, - optimize: true, + // optimize: true, ..Default::default() }, &mut bytes, @@ -84,7 +83,7 @@ impl Package { hblang::run_compiler( &path, Options { - optimize: true, + // optimize: true, ..Default::default() }, &mut bytes, @@ -101,7 +100,7 @@ impl Package { &path, Options { dump_asm: true, - optimize: true, + // optimize: true, ..Default::default() }, &mut bytes, diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 19f2d38..fadaa60 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -407,7 +407,8 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> { "-parallel", "none", "-monitor", "none", "-machine", accel, - "-cpu", "max", + "-cpu", "max", "-serial", "stdio", + "-device", "isa-debug-exit,iobase=0xf4,iosize=0x04", ]); } diff --git a/sysdata/libraries/render/src/software.hb b/sysdata/libraries/render/src/software.hb index 28f99e3..3fa79de 100644 --- a/sysdata/libraries/render/src/software.hb +++ b/sysdata/libraries/render/src/software.hb @@ -36,7 +36,7 @@ free_surface := fn(surface: Surface): void { return @inline(memory.free, Color, surface.buf, @intcast(surface.width * surface.height), false) } -framebuffer := @as(^Color, idk) +framebuffer := @as(^Color, null) init := fn(doublebuffer: bool): Surface { framebuffer = dt.get(^Color, "framebuffer/fb0/ptr\0") diff --git a/sysdata/programs/horizon/src/main.hb b/sysdata/programs/horizon/src/main.hb index ed2c23f..f8af80b 100644 --- a/sysdata/programs/horizon/src/main.hb +++ b/sysdata/programs/horizon/src/main.hb @@ -15,6 +15,8 @@ Window := struct { y: int, } +psf := @embed("../../../consolefonts/tamsyn/10x20r.psf") + main := fn(): int { win_buff := buffer.create("XHorizon\0") @@ -33,6 +35,8 @@ main := fn(): int { vel_inner := Vec2(int).(1, 1) pos_inner := Vec2(uint).((window.width - side) / 2, (window.height - side) / 2) + str := "Window Title Bar\0" + font := render.text.font_from_psf2(@bitcast(&psf)) loop { // Clear the screen @@ -43,6 +47,8 @@ main := fn(): int { ret := buffer.recv([u8; 4096], win_buff, mem_buf) if ret == 0 { log.info("No messages\0") + } else { + log.info("Handle Messages\0") } } @@ -65,6 +71,7 @@ main := fn(): int { { render.put_rect(window, .(0, 0), .(window.width - 1, window.height - 1), render.white) render.put_rect(window, .(0, 0), .(window.width - 1, 20), render.white) + render.put_text(window, font, .(window.width / 2, 1), render.white, str) } render.put_filled_rect(window, pos_inner, .(side, side), color) diff --git a/sysdata/programs/horizon_testing_program/src/main.hb b/sysdata/programs/horizon_testing_program/src/main.hb index 3fe241b..d5b6362 100644 --- a/sysdata/programs/horizon_testing_program/src/main.hb +++ b/sysdata/programs/horizon_testing_program/src/main.hb @@ -7,6 +7,8 @@ horizon_api := @use("../../../libraries/horizon_api/src/lib.hb"); ignim := @use("../../../libraries/ignim/src/lib.hb"); .{errors} := ignim +psf := @embed("../../../consolefonts/tamsyn/10x20r.psf") + main := fn(): int { x := 0 // loop if x > 10000 break else x += 1 diff --git a/sysdata/programs/mouse_driver/README.md b/sysdata/programs/mouse_driver/README.md new file mode 100644 index 0000000..b951afa --- /dev/null +++ b/sysdata/programs/mouse_driver/README.md @@ -0,0 +1 @@ +# mouse_driver \ No newline at end of file diff --git a/sysdata/programs/mouse_driver/meta.toml b/sysdata/programs/mouse_driver/meta.toml new file mode 100644 index 0000000..21bdba8 --- /dev/null +++ b/sysdata/programs/mouse_driver/meta.toml @@ -0,0 +1,11 @@ +[package] +name = "mouse_driver" +authors = [""] + +[dependants.libraries] + +[dependants.binaries] +hblang.version = "1.0.0" + +[build] +command = "hblang src/main.hb" diff --git a/sysdata/programs/mouse_driver/src/main.hb b/sysdata/programs/mouse_driver/src/main.hb new file mode 100644 index 0000000..f1c24f3 --- /dev/null +++ b/sysdata/programs/mouse_driver/src/main.hb @@ -0,0 +1,79 @@ +.{memory, buffer, log, string} := @use("../../../libraries/stn/src/lib.hb") +render := @use("../../../libraries/render/src/lib.hb") + +ACK := 250 + +wait_for := fn(for: u8): void { + log.info("Start waiting\0") + loop { + if (memory.inb(0x64) & 2 >> for) == for { + log.info("End waiting\0") + return + } + } +} + +send_info := fn(info: u8): void { + wait_for(1) + memory.outb(0x64, info) +} + +send_command := fn(command: u8): void { + send_info(0xD4) + wait_for(1) + memory.outb(0x60, command) +} + +get_response := fn(): u8 { + wait_for(1) + return memory.inb(0x60) +} + +main := fn(): int { + // screen := render.init(true) + + format_page := memory.alloc(u8, 1024) + + wait_for(0) + memory.outb(0x64, 0xA8) + log.info("Aux mouse device enabled.\0") + + send_command(0xF6) + a := get_response() + + send_command(0xF4) + b := get_response() + + x := -0 + y := -0 + + loop { + // render.clear(screen, render.black) + + loop { + if (memory.inb(0x64) & 0x20) == 0x20 { + log.info("Yeah\0") + + break + } else { + } + } + + status := memory.inb(0x60) + log.info(string.display_int(status, format_page, 10)) + d_x := memory.inb(0x60) + log.info(string.display_int(d_x, format_page, 10)) + x = x + d_x + d_y := memory.inb(0x60) + y = y + d_y + log.info(string.display_int(d_y, format_page, 10)) + // render.put_rect(screen, .(x, y), .(x + 10, y + 10), render.white) + + log.info("XY\0") + + log.info(string.display_int(x, format_page, 10)) + log.info(string.display_int(y, format_page, 10)) + } + + return 0 +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/text.hb b/sysdata/programs/render_example/src/examples/text.hb index 98789d6..1108667 100644 --- a/sysdata/programs/render_example/src/examples/text.hb +++ b/sysdata/programs/render_example/src/examples/text.hb @@ -10,14 +10,13 @@ example := fn(): void { screen := render.init(true) font := render.text.font_from_psf2(@bitcast(&psf)) t := 0 - str := "Hello, World! -This is a test -of multiline rendering\0" + str := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX\0" + loop { render.clear(screen, render.black) render.put_text(screen, font, .(t, t % screen.height), render.red, str) render.sync(screen) - t += 1 + // t += 1 } 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 index 3edd356..77cb04c 100644 --- a/sysdata/programs/render_example/src/main.hb +++ b/sysdata/programs/render_example/src/main.hb @@ -1,3 +1 @@ -.{example} := @use("./examples/text.hb") - -main := example \ No newline at end of file +.{example: main} := @use("./examples/text.hb") \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index f556282..09fe797 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -28,8 +28,8 @@ resolution = "1024x768x24" # [boot.limine.ableos.modules.diskio_driver] # path = "boot:///diskio_driver.hbf" -[boot.limine.ableos.modules.render_example] -path = "boot:///render_example.hbf" +# [boot.limine.ableos.modules.render_example] +# path = "boot:///render_example.hbf" # [boot.limine.ableos.modules.serial_driver] # path = "boot:///serial_driver.hbf" @@ -57,3 +57,7 @@ path = "boot:///render_example.hbf" # [boot.limine.ableos.modules.pumpkin_print] # path = "boot:///pumpkin_print.hbf" + + +[boot.limine.ableos.modules.mouse_driver] +path = "boot:///mouse_driver.hbf" From 80d363bc59320a410093783d9748b22955b72666 Mon Sep 17 00:00:00 2001 From: Able Date: Fri, 1 Nov 2024 15:11:33 -0500 Subject: [PATCH 2/2] panic func in stn --- sysdata/libraries/stn/src/panic.hb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 sysdata/libraries/stn/src/panic.hb diff --git a/sysdata/libraries/stn/src/panic.hb b/sysdata/libraries/stn/src/panic.hb new file mode 100644 index 0000000..eddf15a --- /dev/null +++ b/sysdata/libraries/stn/src/panic.hb @@ -0,0 +1,8 @@ +panic := fn(message: ?^u8): void { + if message != null { + log.error(message) + } + // TODO: replace with die keyword when it gets pushed + loop { + } +} \ No newline at end of file