From 65b6f52d2e2b20c48f6dc3e37d476a8c2e2bbc73 Mon Sep 17 00:00:00 2001 From: able Date: Tue, 21 Nov 2023 03:56:18 -0600 Subject: [PATCH] POC serial driver for arm Does not work for x86 yet --- repbuild/src/main.rs | 1 + sysdata/limine.cfg | 5 +++- .../limine_framebuffer_driver.rhai | 8 ++++++ sysdata/test-programs/serial_driver.rhai | 27 +++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 sysdata/test-programs/serial_driver.rhai diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index f9c06916..e2cc634d 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -149,6 +149,7 @@ fn get_fs() -> Result, io::Error> { "target/test-programs/failure.hbf", "target/test-programs/ecall.hbf", "target/test-programs/main.hbf", + "target/test-programs/serial_driver.hbf", "target/test-programs/vfs_test.hbf", "target/test-programs/limine_framebuffer_driver.hbf", ] { diff --git a/sysdata/limine.cfg b/sysdata/limine.cfg index 8e5699f6..c082f685 100644 --- a/sysdata/limine.cfg +++ b/sysdata/limine.cfg @@ -31,4 +31,7 @@ TERM_BACKDROP=008080 MODULE_CMDLINE="" MODULE_PATH=boot:///limine_framebuffer_driver.hbf - MODULE_CMDLINE="height=10 width=10 arch=${ARCH}" \ No newline at end of file + MODULE_CMDLINE="height=10 width=10 arch=${ARCH}" + + MODULE_PATH=boot:///serial_driver.hbf + MODULE_CMDLINE="arch=${ARCH}" \ No newline at end of file diff --git a/sysdata/test-programs/limine_framebuffer_driver.rhai b/sysdata/test-programs/limine_framebuffer_driver.rhai index bfd3969e..7b1a6f57 100644 --- a/sysdata/test-programs/limine_framebuffer_driver.rhai +++ b/sysdata/test-programs/limine_framebuffer_driver.rhai @@ -90,6 +90,14 @@ fn main(){ li64(r2, 1); eca(); + // Zero out all used registers + li64(r1, 0); + li64(r2, 0); + li64(r3, 0); + li64(r4, 0); + li64(r5, 0); + li64(r6, 0); + li64(r7, 0); } std::Info("Starting the limine framebuffer driver."); // un(); diff --git a/sysdata/test-programs/serial_driver.rhai b/sysdata/test-programs/serial_driver.rhai new file mode 100644 index 00000000..546b5a54 --- /dev/null +++ b/sysdata/test-programs/serial_driver.rhai @@ -0,0 +1,27 @@ +import "sysdata/test-programs/hblib/std" as std; + + + +fn main(){ + let ADDR = 0; + // FIXME: Actually check the arch argument + let architecture = "ARM"; + if architecture == "ARM" { + std::Info("Arm Serial Driver"); + ADDR = 0x09000000; + } + + + lra(r3, r0, ADDR); + + li64(r1, 0); + li8(r1, 65); + st(r1, r0, ADDR, 1); + + // New Line + li8(r1, 12);st(r1, r0, ADDR, 1); + + tx(); +} + +main(); \ No newline at end of file