1
0
Fork 0
forked from AbleOS/ableos

fix buffers

update hblang
auto cpu feature detection for repbuild
less verbose buffer api
add peony's tetris stub
This commit is contained in:
koniifer 2024-10-12 13:35:49 +01:00
parent 07ee8de9f1
commit 3df6f18c85
11 changed files with 182 additions and 131 deletions

141
Cargo.lock generated
View file

@ -13,9 +13,9 @@ dependencies = [
[[package]] [[package]]
name = "addr2line" name = "addr2line"
version = "0.24.1" version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
dependencies = [ dependencies = [
"gimli", "gimli",
] ]
@ -145,9 +145,9 @@ checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.1.23" version = "1.1.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bbb537bb4a30b90362caddba8f360c0a56bc13d3a5570028e7197204cb54a17" checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945"
dependencies = [ dependencies = [
"shlex", "shlex",
] ]
@ -266,9 +266,9 @@ dependencies = [
[[package]] [[package]]
name = "futures-channel" name = "futures-channel"
version = "0.3.30" version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
@ -276,33 +276,33 @@ dependencies = [
[[package]] [[package]]
name = "futures-core" name = "futures-core"
version = "0.3.30" version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
[[package]] [[package]]
name = "futures-io" name = "futures-io"
version = "0.3.30" version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
[[package]] [[package]]
name = "futures-sink" name = "futures-sink"
version = "0.3.30" version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7"
[[package]] [[package]]
name = "futures-task" name = "futures-task"
version = "0.3.30" version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
[[package]] [[package]]
name = "futures-util" name = "futures-util"
version = "0.3.30" version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-io", "futures-io",
@ -327,9 +327,9 @@ dependencies = [
[[package]] [[package]]
name = "gimli" name = "gimli"
version = "0.31.0" version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
@ -341,17 +341,23 @@ dependencies = [
"allocator-api2", "allocator-api2",
] ]
[[package]]
name = "hashbrown"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
[[package]] [[package]]
name = "hbbytecode" name = "hbbytecode"
version = "0.1.0" 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]] [[package]]
name = "hblang" name = "hblang"
version = "0.1.0" 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 = [ dependencies = [
"hashbrown", "hashbrown 0.15.0",
"hbbytecode", "hbbytecode",
"hbvm", "hbvm",
"log", "log",
@ -361,7 +367,7 @@ dependencies = [
[[package]] [[package]]
name = "hbvm" name = "hbvm"
version = "0.1.0" 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 = [ dependencies = [
"hbbytecode", "hbbytecode",
] ]
@ -503,19 +509,19 @@ dependencies = [
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "2.5.0" version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
dependencies = [ dependencies = [
"equivalent", "equivalent",
"hashbrown", "hashbrown 0.15.0",
] ]
[[package]] [[package]]
name = "ipnet" name = "ipnet"
version = "2.10.0" version = "2.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708"
[[package]] [[package]]
name = "itoa" name = "itoa"
@ -525,9 +531,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.70" version = "0.3.72"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9"
dependencies = [ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
@ -539,7 +545,7 @@ dependencies = [
"aarch64-cpu", "aarch64-cpu",
"crossbeam-queue", "crossbeam-queue",
"derive_more", "derive_more",
"hashbrown", "hashbrown 0.14.5",
"hbvm", "hbvm",
"limine", "limine",
"log", "log",
@ -664,21 +670,18 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.36.4" version = "0.36.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.20.1" version = "1.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
dependencies = [
"portable-atomic",
]
[[package]] [[package]]
name = "paste" name = "paste"
@ -704,12 +707,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "portable-atomic"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2"
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.20" version = "0.2.20"
@ -721,9 +718,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.86" version = "1.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -824,14 +821,23 @@ dependencies = [
"bitflags 1.3.2", "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]] [[package]]
name = "regalloc2" name = "regalloc2"
version = "0.10.2" 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 = [ dependencies = [
"allocator-api2", "allocator-api2",
"bumpalo", "bumpalo",
"hashbrown", "hashbrown 0.14.5",
"log", "log",
"rustc-hash", "rustc-hash",
"smallvec", "smallvec",
@ -852,6 +858,7 @@ dependencies = [
"fatfs", "fatfs",
"hblang", "hblang",
"log", "log",
"raw-cpuid 11.2.0",
"reqwest", "reqwest",
"str-reader", "str-reader",
"toml", "toml",
@ -938,9 +945,9 @@ dependencies = [
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.23.13" version = "0.23.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"ring", "ring",
@ -1276,9 +1283,9 @@ dependencies = [
[[package]] [[package]]
name = "unicode-bidi" name = "unicode-bidi"
version = "0.3.15" version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
@ -1355,9 +1362,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.93" version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"once_cell", "once_cell",
@ -1366,9 +1373,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-backend" name = "wasm-bindgen-backend"
version = "0.2.93" version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"log", "log",
@ -1381,9 +1388,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-futures" name = "wasm-bindgen-futures"
version = "0.4.43" version = "0.4.45"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"js-sys", "js-sys",
@ -1393,9 +1400,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro" name = "wasm-bindgen-macro"
version = "0.2.93" version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56"
dependencies = [ dependencies = [
"quote", "quote",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
@ -1403,9 +1410,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro-support" name = "wasm-bindgen-macro-support"
version = "0.2.93" version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1416,15 +1423,15 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-shared" name = "wasm-bindgen-shared"
version = "0.2.93" version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
[[package]] [[package]]
name = "web-sys" name = "web-sys"
version = "0.3.70" version = "0.3.72"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
@ -1578,7 +1585,7 @@ dependencies = [
"bit", "bit",
"bitflags 1.3.2", "bitflags 1.3.2",
"paste", "paste",
"raw-cpuid", "raw-cpuid 10.7.0",
"x86_64 0.14.12", "x86_64 0.14.12",
] ]
@ -1590,7 +1597,7 @@ checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385"
dependencies = [ dependencies = [
"bit_field", "bit_field",
"bitflags 1.3.2", "bitflags 1.3.2",
"raw-cpuid", "raw-cpuid 10.7.0",
] ]
[[package]] [[package]]

View file

@ -22,7 +22,7 @@ unsafe fn x86_in<T: x86_64::instructions::port::PortRead>(address: u16) -> T {
} }
pub fn handler(vm: &mut Vm) { pub fn handler(vm: &mut Vm) {
let Value(ecall_number) = vm.registers[2]; let ecall_number = vm.registers[2].cast::<u64>();
// log::info!("eca called :pensive:"); // log::info!("eca called :pensive:");
// debug!("Ecall number {:?}", ecall_number); // debug!("Ecall number {:?}", ecall_number);
//info!("Register dump: {:?}", vm.registers); //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::<u64>();
let mut buffs = IPC_BUFFERS.lock(); let mut buffs = IPC_BUFFERS.lock();
let abc; let abc;
@ -69,14 +69,10 @@ pub fn handler(vm: &mut Vm) {
} }
3 => { 3 => {
// Send a message to a buffer // Send a message to a buffer
let Value(buffer_id) = vm.registers[3]; let buffer_id = vm.registers[3].cast::<u64>();
let Value(mem_addr) = vm.registers[4]; let mem_addr = vm.registers[4].cast::<u64>();
let length = { let length = vm.registers[5].cast::<u64>() as usize;
let Value(length) = vm.registers[5];
length as usize
};
trace!("IPC address: {:?}", mem_addr); trace!("IPC address: {:?}", mem_addr);
use alloc::vec::Vec;
match buffer_id { match buffer_id {
0 => match sds_msg_handler(vm, mem_addr, length) { 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(); let mut buffs = IPC_BUFFERS.lock();
match buffs.get_mut(&buffer_id) { match buffs.get_mut(&buffer_id) {
Some(buff) => { Some(buff) => {
let mut msg_vec = Vec::with_capacity(length); let msg_vec = block_read(mem_addr, length).to_vec();
debug!("Sending Message {:?} to Buffer({})", msg_vec, buffer_id);
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
);
buff.push(msg_vec); buff.push(msg_vec);
} }
None => { None => {
@ -171,34 +158,29 @@ pub fn handler(vm: &mut Vm) {
} }
} }
4 => { 4 => {
let Value(buffer_id) = vm.registers[3]; let buffer_id = vm.registers[3].cast::<u64>();
let Value(mut map_ptr) = vm.registers[4]; let map_ptr = vm.registers[4].cast::<u64>();
let Value(max_length) = vm.registers[5]; let max_length = vm.registers[5].cast::<u64>();
let mut buffs = IPC_BUFFERS.lock(); 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() { let msg = match buff.pop() {
buff = buffs.get_mut(&buffer_id).unwrap(); Ok(msg) => msg,
} else { Err(_) => return,
// info!("AHHH"); };
vm.registers[1] = hbvm::value::Value(0);
return;
}
let pop = buff.pop();
if pop.is_err() {
return;
}
let msg = pop.unwrap();
if msg.len() > max_length.try_into().unwrap() { if msg.len() > max_length.try_into().unwrap() {
info!("{}", max_length); info!("{}", max_length);
error!("Message is too long to map in."); error!("Message is too long to map in.");
} else { } else {
unsafe { unsafe {
let ptr: *mut u64 = &mut map_ptr; let ptr = map_ptr as *mut u8;
for (index, byte) in msg.iter().enumerate() { ptr.copy_from(msg.as_ptr(), msg.len());
ptr.offset(index.try_into().unwrap()).write_bytes(*byte, 1);
}
} }
debug!("Recieve {:?} from Buffer({})", msg, buffer_id); debug!("Recieve {:?} from Buffer({})", msg, buffer_id);
@ -207,7 +189,7 @@ pub fn handler(vm: &mut Vm) {
5 => { 5 => {
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
{ {
let Value(r2) = vm.registers[2]; let r2 = vm.registers[2].cast::<u64>();
let x = hbvm::value::Value(unsafe { x86_in::<u8>(r2 as u16) } as u64); let x = hbvm::value::Value(unsafe { x86_in::<u8>(r2 as u16) } as u64);
// info!("Read {:?} from Port {:?}", x, r2); // info!("Read {:?} from Port {:?}", x, r2);
vm.registers[3] = x vm.registers[3] = x

View file

@ -49,9 +49,7 @@ impl<'a> IpcBuffer<'a> {
pub fn push(&mut self, msg: Message) { pub fn push(&mut self, msg: Message) {
match &self.buffer { match &self.buffer {
BufferTypes::Unbound(buff) => buff.push(msg), BufferTypes::Unbound(buff) => buff.push(msg),
BufferTypes::Bound(buff) => { BufferTypes::Bound(buff) => buff.push(msg).unwrap(),
let _ = buff.push(msg);
}
}; };
} }
pub fn pop(&mut self) -> Result<Message, IpcError> { pub fn pop(&mut self) -> Result<Message, IpcError> {

View file

@ -23,6 +23,7 @@ toml = "0.8"
# hbasm.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git" # hbasm.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git" hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
log = "0.4" log = "0.4"
raw-cpuid = "11"
[dependencies.reqwest] [dependencies.reqwest]
version = "0.12" version = "0.12"

View file

@ -7,12 +7,13 @@ use {
dev::Package, dev::Package,
error_stack::{bail, report, Context, Report, Result, ResultExt}, error_stack::{bail, report, Context, Report, Result, ResultExt},
fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek}, fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek},
raw_cpuid::HypervisorInfo,
std::{ std::{
// fmt::Display, // fmt::Display,
fs::{self, File}, fs::{self, File},
io::{self, Write}, io::{self, Write},
path::Path, path::Path,
process::{exit, Command}, process::{exit, Command, Stdio},
}, },
toml::Value, toml::Value,
}; };
@ -335,13 +336,43 @@ fn build(release: bool, target: Target, debuginfo: bool) -> Result<(), Error> {
} }
fn run(release: bool, target: Target) -> Result<(), Error> { fn run(release: bool, target: Target) -> Result<(), Error> {
let mut com = match target { let target_str = match target {
Target::X86_64 => Command::new("qemu-system-x86_64"), Target::X86_64 => "qemu-system-x86_64",
Target::Riscv64Virt => Command::new("qemu-system-riscv64"), Target::Riscv64Virt => "qemu-system-riscv64",
Target::Aarch64 => Command::new("qemu-system-aarch64"), 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 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 { match target {
Target::X86_64 => { Target::X86_64 => {
#[rustfmt::skip] #[rustfmt::skip]
@ -351,8 +382,15 @@ fn run(release: bool, target: Target) -> Result<(), Error> {
"-device", "vmware-svga", "-device", "vmware-svga",
"-m", "2G", "-m", "2G",
"-smp", "1", "-smp", "1",
"-machine", "accel=kvm", "-parallel", "none",
"-cpu", "host", "-monitor", "none",
"-machine", accel,
"-cpu",
if accel != "accel=tcg" {
"host"
} else {
"Broadwell-v4"
},
"-device", "isa-debug-exit,iobase=0xf4,iosize=0x04", "-device", "isa-debug-exit,iobase=0xf4,iosize=0x04",
]); ]);
} }

View file

@ -1,10 +1,10 @@
string := @use("string.hb") 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) 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) return @eca(3, buffer_id, msg, length)
} }

View file

@ -4,7 +4,7 @@ acs := @use("acs.hb");
// Paths without a node-disk component are to be treated as local files. // Paths without a node-disk component are to be treated as local files.
// file_path := "DID:/test\0"; // file_path := "DID:/test\0";
Path := struct { Path := struct {
// DiskID holds the host id // DiskID holds the host id
disk_id: DiskID, disk_id: DiskID,
length: u8, length: u8,
data: ^u8, data: ^u8,

View file

@ -6,17 +6,15 @@ send_byte := fn(byte: u8): u8 {
} }
main := fn(): int { main := fn(): int {
buf := buffer.create("XKeyboard\0")
send_byte(238) send_byte(238)
log.info("PS/2 Driver Loaded\0") log.info("PS/2 Driver Loaded\0")
if send_byte(238) == 238 { if send_byte(238) == 238 {
log.info("PS/2 Keyboard Echoed\0") log.info("PS/2 Keyboard Echoed\0")
} }
a := 0
// a += 1
if send_byte(244) == 250 { if send_byte(244) == 250 {
log.info("Enabled scanning\0") log.info("Enabled scanning\0")
} }
buf := buffer.create("XKeyboard\0")
ptr := memory.request_page(1) ptr := memory.request_page(1)
prev_input := 250 prev_input := 250
loop { loop {
@ -25,9 +23,7 @@ main := fn(): int {
continue continue
} }
prev_input = input prev_input = input
keycode_str := string.display_int(input, ptr) buffer.write(&input, buf, 1)
log.info(keycode_str)
buffer.send_message(&input, buf, 1)
} }
return 0 return 0
} }

View file

@ -0,0 +1,11 @@
[package]
name = "tetris"
authors = ["peony"]
[dependants.libraries]
[dependants.binaries]
hblang.version = "1.0.0"
[build]
command = "hblang src/main.hb"

View file

@ -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
}

View file

@ -26,8 +26,8 @@ resolution = "1024x768x24"
# [boot.limine.ableos.modules.diskio_driver] # [boot.limine.ableos.modules.diskio_driver]
# path = "boot:///diskio_driver.hbf" # path = "boot:///diskio_driver.hbf"
[boot.limine.ableos.modules.render_example] # [boot.limine.ableos.modules.render_example]
path = "boot:///render_example.hbf" # path = "boot:///render_example.hbf"
# [boot.limine.ableos.modules.serial_driver_test] # [boot.limine.ableos.modules.serial_driver_test]
# path = "boot:///serial_driver_test.hbf" # path = "boot:///serial_driver_test.hbf"
@ -44,11 +44,14 @@ path = "boot:///render_example.hbf"
# [boot.limine.ableos.modules.svga_driver] # [boot.limine.ableos.modules.svga_driver]
# path = "boot:///svga_driver.hbf" # path = "boot:///svga_driver.hbf"
# [boot.limine.ableos.modules.ps2_driver] [boot.limine.ableos.modules.ps2_driver]
# path = "boot:///ps2_driver.hbf" path = "boot:///ps2_driver.hbf"
# [boot.limine.ableos.modules.filesystem_fat32] # [boot.limine.ableos.modules.filesystem_fat32]
# path = "boot:///filesystem_fat32.hbf" # path = "boot:///filesystem_fat32.hbf"
# [boot.limine.ableos.modules.pumpkin_print] # [boot.limine.ableos.modules.pumpkin_print]
# path = "boot:///pumpkin_print.hbf" # path = "boot:///pumpkin_print.hbf"
[boot.limine.ableos.modules.tetris]
path = "boot:///tetris.hbf"