From 3df6f18c851fa9510986d9462113a5f85ce8412d Mon Sep 17 00:00:00 2001 From: koniifer Date: Sat, 12 Oct 2024 13:35:49 +0100 Subject: [PATCH] fix buffers update hblang auto cpu feature detection for repbuild less verbose buffer api add peony's tetris stub --- Cargo.lock | 141 +++++++++++++----------- kernel/src/holeybytes/ecah.rs | 64 ++++------- kernel/src/ipc/buffer.rs | 4 +- repbuild/Cargo.toml | 1 + repbuild/src/main.rs | 52 +++++++-- sysdata/libraries/stn/src/buffer.hb | 4 +- sysdata/libraries/stn/src/file_io.hb | 2 +- sysdata/programs/ps2_driver/src/main.hb | 8 +- sysdata/programs/tetris/meta.toml | 11 ++ sysdata/programs/tetris/src/main.hb | 15 +++ sysdata/system_config.toml | 11 +- 11 files changed, 182 insertions(+), 131 deletions(-) create mode 100644 sysdata/programs/tetris/meta.toml create mode 100644 sysdata/programs/tetris/src/main.hb diff --git a/Cargo.lock b/Cargo.lock index 93ff235..a5b6b05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] @@ -145,9 +145,9 @@ checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "cc" -version = "1.1.23" +version = "1.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bbb537bb4a30b90362caddba8f360c0a56bc13d3a5570028e7197204cb54a17" +checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" dependencies = [ "shlex", ] @@ -266,9 +266,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -276,33 +276,33 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", "futures-io", @@ -327,9 +327,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "hashbrown" @@ -341,17 +341,23 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#1f5846afaacb237245c0061422d9799f71d7f623" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#c4826d3bfdc2def022fc7e80c6d5fe86df4e1c95" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#1f5846afaacb237245c0061422d9799f71d7f623" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#c4826d3bfdc2def022fc7e80c6d5fe86df4e1c95" dependencies = [ - "hashbrown", + "hashbrown 0.15.0", "hbbytecode", "hbvm", "log", @@ -361,7 +367,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#1f5846afaacb237245c0061422d9799f71d7f623" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#c4826d3bfdc2def022fc7e80c6d5fe86df4e1c95" dependencies = [ "hbbytecode", ] @@ -503,19 +509,19 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.0", ] [[package]] name = "ipnet" -version = "2.10.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "itoa" @@ -525,9 +531,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -539,7 +545,7 @@ dependencies = [ "aarch64-cpu", "crossbeam-queue", "derive_more", - "hashbrown", + "hashbrown 0.14.5", "hbvm", "limine", "log", @@ -664,21 +670,18 @@ dependencies = [ [[package]] name = "object" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.20.1" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" -dependencies = [ - "portable-atomic", -] +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "paste" @@ -704,12 +707,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "portable-atomic" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" - [[package]] name = "ppv-lite86" version = "0.2.20" @@ -721,9 +718,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] @@ -824,14 +821,23 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "raw-cpuid" +version = "11.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ab240315c661615f2ee9f0f2cd32d5a7343a84d5ebcccb99d46e6637565e7b0" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "regalloc2" version = "0.10.2" -source = "git+https://github.com/jakubDoka/regalloc2?branch=reuse-allocations#c4d21e228dd70fda27b3e92eeff282d32858d613" +source = "git+https://github.com/jakubDoka/regalloc2?branch=reuse-allocations#21c43e3ee182824e92e2b25f1d3c03ed47f9c02b" dependencies = [ "allocator-api2", "bumpalo", - "hashbrown", + "hashbrown 0.14.5", "log", "rustc-hash", "smallvec", @@ -852,6 +858,7 @@ dependencies = [ "fatfs", "hblang", "log", + "raw-cpuid 11.2.0", "reqwest", "str-reader", "toml", @@ -938,9 +945,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.13" +version = "0.23.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" +checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" dependencies = [ "once_cell", "ring", @@ -1276,9 +1283,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" @@ -1355,9 +1362,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -1366,9 +1373,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", @@ -1381,9 +1388,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -1393,9 +1400,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1403,9 +1410,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", @@ -1416,15 +1423,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -1578,7 +1585,7 @@ dependencies = [ "bit", "bitflags 1.3.2", "paste", - "raw-cpuid", + "raw-cpuid 10.7.0", "x86_64 0.14.12", ] @@ -1590,7 +1597,7 @@ checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385" dependencies = [ "bit_field", "bitflags 1.3.2", - "raw-cpuid", + "raw-cpuid 10.7.0", ] [[package]] diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 24fb324..0a1f898 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -22,7 +22,7 @@ unsafe fn x86_in(address: u16) -> T { } pub fn handler(vm: &mut Vm) { - let Value(ecall_number) = vm.registers[2]; + let ecall_number = vm.registers[2].cast::(); // log::info!("eca called :pensive:"); // debug!("Ecall number {:?}", ecall_number); //info!("Register dump: {:?}", vm.registers); @@ -46,7 +46,7 @@ pub fn handler(vm: &mut Vm) { } }; - let Value(length) = vm.registers[4]; + let length = vm.registers[4].cast::(); let mut buffs = IPC_BUFFERS.lock(); let abc; @@ -69,14 +69,10 @@ pub fn handler(vm: &mut Vm) { } 3 => { // Send a message to a buffer - let Value(buffer_id) = vm.registers[3]; - let Value(mem_addr) = vm.registers[4]; - let length = { - let Value(length) = vm.registers[5]; - length as usize - }; + let buffer_id = vm.registers[3].cast::(); + let mem_addr = vm.registers[4].cast::(); + let length = vm.registers[5].cast::() as usize; trace!("IPC address: {:?}", mem_addr); - use alloc::vec::Vec; match buffer_id { 0 => match sds_msg_handler(vm, mem_addr, length) { @@ -149,17 +145,8 @@ pub fn handler(vm: &mut Vm) { let mut buffs = IPC_BUFFERS.lock(); match buffs.get_mut(&buffer_id) { Some(buff) => { - 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); - } - debug!( - "Message {:?} has been sent to Buffer({})", - msg_vec, buffer_id - ); + let msg_vec = block_read(mem_addr, length).to_vec(); + debug!("Sending Message {:?} to Buffer({})", msg_vec, buffer_id); buff.push(msg_vec); } None => { @@ -171,34 +158,29 @@ pub fn handler(vm: &mut Vm) { } } 4 => { - let Value(buffer_id) = vm.registers[3]; - let Value(mut map_ptr) = vm.registers[4]; - let Value(max_length) = vm.registers[5]; + let buffer_id = vm.registers[3].cast::(); + let map_ptr = vm.registers[4].cast::(); + let max_length = vm.registers[5].cast::(); let mut buffs = IPC_BUFFERS.lock(); - let buff: &mut IpcBuffer; + let buff: &mut IpcBuffer = match buffs.get_mut(&buffer_id) { + Some(buff) => buff, + None => panic!( + "Failed to get buffer: id={buffer_id}, ptr={map_ptr}, length={max_length}" + ), + }; - if buffs.get_mut(&buffer_id).is_some() { - buff = buffs.get_mut(&buffer_id).unwrap(); - } else { - // info!("AHHH"); - vm.registers[1] = hbvm::value::Value(0); - return; - } - let pop = buff.pop(); - if pop.is_err() { - return; - } - let msg = pop.unwrap(); + let msg = match buff.pop() { + Ok(msg) => msg, + Err(_) => return, + }; if msg.len() > max_length.try_into().unwrap() { info!("{}", max_length); error!("Message is too long to map in."); } else { unsafe { - let ptr: *mut u64 = &mut map_ptr; - for (index, byte) in msg.iter().enumerate() { - ptr.offset(index.try_into().unwrap()).write_bytes(*byte, 1); - } + let ptr = map_ptr as *mut u8; + ptr.copy_from(msg.as_ptr(), msg.len()); } debug!("Recieve {:?} from Buffer({})", msg, buffer_id); @@ -207,7 +189,7 @@ pub fn handler(vm: &mut Vm) { 5 => { #[cfg(target_arch = "x86_64")] { - let Value(r2) = vm.registers[2]; + let r2 = vm.registers[2].cast::(); let x = hbvm::value::Value(unsafe { x86_in::(r2 as u16) } as u64); // info!("Read {:?} from Port {:?}", x, r2); vm.registers[3] = x diff --git a/kernel/src/ipc/buffer.rs b/kernel/src/ipc/buffer.rs index a7c1920..b4500a2 100644 --- a/kernel/src/ipc/buffer.rs +++ b/kernel/src/ipc/buffer.rs @@ -49,9 +49,7 @@ impl<'a> IpcBuffer<'a> { pub fn push(&mut self, msg: Message) { match &self.buffer { BufferTypes::Unbound(buff) => buff.push(msg), - BufferTypes::Bound(buff) => { - let _ = buff.push(msg); - } + BufferTypes::Bound(buff) => buff.push(msg).unwrap(), }; } pub fn pop(&mut self) -> Result { diff --git a/repbuild/Cargo.toml b/repbuild/Cargo.toml index 71aa93a..4d7abaa 100644 --- a/repbuild/Cargo.toml +++ b/repbuild/Cargo.toml @@ -23,6 +23,7 @@ toml = "0.8" # hbasm.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git" hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git" log = "0.4" +raw-cpuid = "11" [dependencies.reqwest] version = "0.12" diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 3032333..47a0653 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -7,12 +7,13 @@ use { dev::Package, error_stack::{bail, report, Context, Report, Result, ResultExt}, fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek}, + raw_cpuid::HypervisorInfo, std::{ // fmt::Display, fs::{self, File}, io::{self, Write}, path::Path, - process::{exit, Command}, + process::{exit, Command, Stdio}, }, toml::Value, }; @@ -335,13 +336,43 @@ fn build(release: bool, target: Target, debuginfo: bool) -> Result<(), Error> { } fn run(release: bool, target: Target) -> Result<(), Error> { - let mut com = match target { - Target::X86_64 => Command::new("qemu-system-x86_64"), - Target::Riscv64Virt => Command::new("qemu-system-riscv64"), - Target::Aarch64 => Command::new("qemu-system-aarch64"), + let target_str = match target { + Target::X86_64 => "qemu-system-x86_64", + Target::Riscv64Virt => "qemu-system-riscv64", + Target::Aarch64 => "qemu-system-aarch64", }; + let (mut com, mut com2) = (Command::new(target_str), Command::new(target_str)); let ovmf_path = fetch_ovmf(target); + let supported = String::from_utf8( + com2.args(["--accel", "help"]) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .unwrap() + .wait_with_output() + .unwrap() + .stdout, + ) + .unwrap(); + + let cpuid = raw_cpuid::CpuId::new(); + let vmx = cpuid.get_feature_info().unwrap().has_vmx(); + let svm = cpuid.get_svm_info().is_some(); + + let accel = if supported.contains("kvm") && (vmx | svm) { + "accel=kvm" + } else if cpuid.get_processor_brand_string() == "GenuineIntel" + && supported.contains("hax") + && vmx + { + "accel=hax" + } else if supported.contains("whpx") { + "accel=whpx" + } else { + "accel=tcg" + }; + match target { Target::X86_64 => { #[rustfmt::skip] @@ -351,8 +382,15 @@ fn run(release: bool, target: Target) -> Result<(), Error> { "-device", "vmware-svga", "-m", "2G", "-smp", "1", - "-machine", "accel=kvm", - "-cpu", "host", + "-parallel", "none", + "-monitor", "none", + "-machine", accel, + "-cpu", + if accel != "accel=tcg" { + "host" + } else { + "Broadwell-v4" + }, "-device", "isa-debug-exit,iobase=0xf4,iosize=0x04", ]); } diff --git a/sysdata/libraries/stn/src/buffer.hb b/sysdata/libraries/stn/src/buffer.hb index 896a909..554783b 100644 --- a/sysdata/libraries/stn/src/buffer.hb +++ b/sysdata/libraries/stn/src/buffer.hb @@ -1,10 +1,10 @@ string := @use("string.hb") -receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u8 { +recv := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u8 { return @eca(4, buffer_id, memory_map_location, length) } -send_message := fn(msg: ^u8, buffer_id: int, length: int): void { +write := fn(msg: ^u8, buffer_id: int, length: int): void { return @eca(3, buffer_id, msg, length) } diff --git a/sysdata/libraries/stn/src/file_io.hb b/sysdata/libraries/stn/src/file_io.hb index feddd52..2664c24 100644 --- a/sysdata/libraries/stn/src/file_io.hb +++ b/sysdata/libraries/stn/src/file_io.hb @@ -4,7 +4,7 @@ acs := @use("acs.hb"); // Paths without a node-disk component are to be treated as local files. // file_path := "DID:/test\0"; Path := struct { - // DiskID holds the host id + // DiskID holds the host id disk_id: DiskID, length: u8, data: ^u8, diff --git a/sysdata/programs/ps2_driver/src/main.hb b/sysdata/programs/ps2_driver/src/main.hb index 5096f7a..26be502 100644 --- a/sysdata/programs/ps2_driver/src/main.hb +++ b/sysdata/programs/ps2_driver/src/main.hb @@ -6,17 +6,15 @@ send_byte := fn(byte: u8): u8 { } main := fn(): int { + buf := buffer.create("XKeyboard\0") send_byte(238) log.info("PS/2 Driver Loaded\0") if send_byte(238) == 238 { log.info("PS/2 Keyboard Echoed\0") } - a := 0 - // a += 1 if send_byte(244) == 250 { log.info("Enabled scanning\0") } - buf := buffer.create("XKeyboard\0") ptr := memory.request_page(1) prev_input := 250 loop { @@ -25,9 +23,7 @@ main := fn(): int { continue } prev_input = input - keycode_str := string.display_int(input, ptr) - log.info(keycode_str) - buffer.send_message(&input, buf, 1) + buffer.write(&input, buf, 1) } return 0 } \ No newline at end of file diff --git a/sysdata/programs/tetris/meta.toml b/sysdata/programs/tetris/meta.toml new file mode 100644 index 0000000..d2a5f97 --- /dev/null +++ b/sysdata/programs/tetris/meta.toml @@ -0,0 +1,11 @@ +[package] +name = "tetris" +authors = ["peony"] + +[dependants.libraries] + +[dependants.binaries] +hblang.version = "1.0.0" + +[build] +command = "hblang src/main.hb" diff --git a/sysdata/programs/tetris/src/main.hb b/sysdata/programs/tetris/src/main.hb new file mode 100644 index 0000000..e61324b --- /dev/null +++ b/sysdata/programs/tetris/src/main.hb @@ -0,0 +1,15 @@ +.{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb") + +main := fn(): void { + storage := @as(u8, 0) + output_buffer := memory.request_page(1) + input_buffer := buffer.search("XKeyboard\0") + loop { + buffer.recv(input_buffer, &storage, 1) + if storage != 0 { + log.info(string.display_int(storage, output_buffer)) + storage = 0 + } + } + return +} \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 2d11d43..76c2ccc 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -26,8 +26,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_test] # path = "boot:///serial_driver_test.hbf" @@ -44,11 +44,14 @@ path = "boot:///render_example.hbf" # [boot.limine.ableos.modules.svga_driver] # path = "boot:///svga_driver.hbf" -# [boot.limine.ableos.modules.ps2_driver] -# path = "boot:///ps2_driver.hbf" +[boot.limine.ableos.modules.ps2_driver] +path = "boot:///ps2_driver.hbf" # [boot.limine.ableos.modules.filesystem_fat32] # path = "boot:///filesystem_fat32.hbf" # [boot.limine.ableos.modules.pumpkin_print] # path = "boot:///pumpkin_print.hbf" + +[boot.limine.ableos.modules.tetris] +path = "boot:///tetris.hbf"