From 6885f1cdaf46910244ee4f87bf8a992ce1b5f1db Mon Sep 17 00:00:00 2001 From: Erin Date: Sat, 28 Oct 2023 03:26:04 +0200 Subject: [PATCH] Updated HBVM version --- Cargo.lock | 485 ++++++++++++++++++++---------- kernel/src/arch/x86_64/mod.rs | 17 ++ kernel/src/holeybytes/ecah.rs | 86 ++++++ kernel/src/holeybytes/mem.rs | 37 +++ kernel/src/holeybytes/mod.rs | 113 ++----- kernel/src/kmain.rs | 2 +- kernel/src/lib.rs | 4 +- kernel/targets/x86_64-ableos.json | 2 +- repbuild/Cargo.toml | 1 + repbuild/holeybytes/ecall.hb | Bin 90 -> 0 bytes repbuild/holeybytes/ecall.rhai | 3 + repbuild/holeybytes/failure.hb | Bin 17 -> 0 bytes repbuild/holeybytes/failure.rhai | 1 + repbuild/limine.cfg | 4 +- repbuild/src/main.rs | 46 ++- 15 files changed, 530 insertions(+), 271 deletions(-) create mode 100644 kernel/src/holeybytes/ecah.rs create mode 100644 kernel/src/holeybytes/mem.rs delete mode 100644 repbuild/holeybytes/ecall.hb create mode 100644 repbuild/holeybytes/ecall.rhai delete mode 100644 repbuild/holeybytes/failure.hb create mode 100644 repbuild/holeybytes/failure.rhai diff --git a/Cargo.lock b/Cargo.lock index 26d448cc..bd339415 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ version = 3 [[package]] name = "able_graphics_library" version = "0.1.2" -source = "git+https://git.ablecorp.us/ableos/ableos_userland#a45a19c6b7355ebdac53259d06a1894a096143e6" +source = "git+https://git.ablecorp.us/ableos/ableos_userland#c990d072981b3076fa3e4f30f5c7c8f84b01c804" dependencies = [ "embedded-graphics", "log", @@ -29,9 +29,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ "getrandom", "once_cell", @@ -40,13 +40,16 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", + "const-random", + "getrandom", "once_cell", "version_check", + "zerocopy 0.7.18", ] [[package]] @@ -105,9 +108,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.3" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bit" @@ -128,22 +131,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bumpalo" -version = "3.13.0" +name = "bitflags" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" @@ -162,15 +171,14 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.27" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56b4c72906975ca04becb8a30e102dfecddd0c06181e3e95ddc444be28881f8" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", - "time", "wasm-bindgen", "windows-targets", ] @@ -178,19 +186,49 @@ dependencies = [ [[package]] name = "clparse" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/ableos_userland#a45a19c6b7355ebdac53259d06a1894a096143e6" +source = "git+https://git.ablecorp.us/ableos/ableos_userland#c990d072981b3076fa3e4f30f5c7c8f84b01c804" dependencies = [ - "hashbrown 0.14.0", + "hashbrown 0.14.2", "log", "toml", ] +[[package]] +name = "const-random" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11df32a13d7892ec42d51d3d175faba5211ffe13ed25d4fb348ac9e9ce835593" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom", + "once_cell", + "tiny-keccak", +] + [[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.4" @@ -216,6 +254,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "derive_more" version = "0.99.17" @@ -263,9 +307,9 @@ dependencies = [ [[package]] name = "error-stack" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6a37ef405b504fc3b87a24fa52906d98cdd1a7d4e5ef2b49f0d5fead138fced" +checksum = "27a72baa257b5e0e2de241967bc5ee8f855d6072351042688621081d66b2a76b" dependencies = [ "anyhow", "rustc_version", @@ -277,7 +321,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05669f8e7e2d7badc545c513710f0eba09c2fbef683eb859fd79c46c355048e0" dependencies = [ - "bitflags", + "bitflags 1.3.2", "byteorder", "chrono", "log", @@ -309,57 +353,45 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" - -[[package]] -name = "futures-macro" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.29", -] +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-core", "futures-io", - "futures-macro", "futures-task", "memchr", "pin-project-lite", @@ -375,7 +407,7 @@ checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -409,37 +441,50 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", ] [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "allocator-api2", ] +[[package]] +name = "hbasm" +version = "0.1.0" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#fbc68fadc3fc84018aa57322ef93af8fe7ec7d10" +dependencies = [ + "paste", + "rhai", + "with_builtin_macros", +] + [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#35f3d59a547e285310551177e31bd3522d62fa08" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#7b1f6d535db3ac4163b45967d963d31f2c577898" +dependencies = [ + "with_builtin_macros", +] [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#35f3d59a547e285310551177e31bd3522d62fa08" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#7b1f6d535db3ac4163b45967d963d31f2c577898" dependencies = [ "hbbytecode", ] [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "http" @@ -492,7 +537,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -501,9 +546,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", @@ -515,16 +560,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -557,10 +602,19 @@ dependencies = [ ] [[package]] -name = "ipnet" -version = "2.8.0" +name = "instant" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "itoa" @@ -586,7 +640,7 @@ dependencies = [ "crossbeam-queue", "derive_more", "embedded-graphics", - "hashbrown 0.14.0", + "hashbrown 0.14.2", "hbvm", "kiam", "limine", @@ -594,7 +648,7 @@ dependencies = [ "rdrand", "sbi", "slab", - "spin 0.9.8", + "spin", "uart_16550", "versioning", "virtio-drivers", @@ -611,9 +665,9 @@ checksum = "cb0fc32485e41ae5e9dedd1442f36dec998431adc9f321224c2c5d645f38fdcb" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "limine" @@ -622,9 +676,9 @@ source = "git+https://github.com/limine-bootloader/limine-rs#4394419fe347901a930 [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -638,9 +692,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.6.1" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f478948fd84d9f8e86967bf432640e46adfb5a4bd4f14ef7e864ab38220534ae" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "micromath" @@ -665,20 +719,20 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys", ] [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -695,9 +749,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -734,9 +788,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -762,7 +816,7 @@ version = "10.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -781,14 +835,15 @@ dependencies = [ "derive_more", "error-stack", "fatfs", + "hbasm", "reqwest", ] [[package]] name = "reqwest" -version = "0.11.20" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ "base64", "bytes", @@ -812,6 +867,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", "tokio-rustls", "tower-service", @@ -824,18 +880,44 @@ dependencies = [ ] [[package]] -name = "ring" -version = "0.16.20" +name = "rhai" +version = "1.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "206cee941730eaf90a22c84235b25193df661393688162e15551164f92f09eca" +dependencies = [ + "ahash 0.8.6", + "bitflags 2.4.1", + "instant", + "num-traits", + "once_cell", + "rhai_codegen", + "smallvec", + "smartstring", +] + +[[package]] +name = "rhai_codegen" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "853977598f084a492323fe2f7896b4100a86284ee8473612de60021ea341310f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + +[[package]] +name = "ring" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" dependencies = [ "cc", + "getrandom", "libc", - "once_cell", - "spin 0.5.2", + "spin", "untrusted", - "web-sys", - "winapi", + "windows-sys", ] [[package]] @@ -855,9 +937,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", "ring", @@ -876,9 +958,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.101.4" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ "ring", "untrusted", @@ -910,9 +992,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ "ring", "untrusted", @@ -920,35 +1002,35 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -977,10 +1059,27 @@ dependencies = [ ] [[package]] -name = "socket2" -version = "0.4.9" +name = "smallvec" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" + +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check", +] + +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", @@ -988,20 +1087,14 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -1011,6 +1104,12 @@ dependencies = [ "lock_api", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "syn" version = "1.0.109" @@ -1024,9 +1123,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.29" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -1034,14 +1133,33 @@ dependencies = [ ] [[package]] -name = "time" -version = "0.1.45" +name = "system-configuration" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", ] [[package]] @@ -1061,9 +1179,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ "backtrace", "bytes", @@ -1071,7 +1189,7 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", - "socket2 0.5.3", + "socket2 0.5.5", "windows-sys", ] @@ -1087,9 +1205,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -1116,20 +1234,19 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "pin-project-lite", "tracing-core", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] @@ -1146,7 +1263,7 @@ version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "614ff2a87880d4bd4374722268598a970bbad05ced8bf630439417347254ab2e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "rustversion", "x86_64", ] @@ -1159,9 +1276,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -1174,9 +1291,9 @@ dependencies = [ [[package]] name = "untrusted" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" @@ -1198,7 +1315,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "versioning" version = "0.1.3" -source = "git+https://git.ablecorp.us/ableos/ableos_userland#a45a19c6b7355ebdac53259d06a1894a096143e6" +source = "git+https://git.ablecorp.us/ableos/ableos_userland#c990d072981b3076fa3e4f30f5c7c8f84b01c804" dependencies = [ "serde", ] @@ -1209,9 +1326,9 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42299957c6f61af586fe3eae398c16ec07f33a02579fa1d41ae96156ce437029" dependencies = [ - "bitflags", + "bitflags 1.3.2", "log", - "zerocopy", + "zerocopy 0.6.5", ] [[package]] @@ -1229,12 +1346,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1262,7 +1373,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -1296,7 +1407,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1346,10 +1457,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ "windows-targets", ] @@ -1431,13 +1542,33 @@ dependencies = [ ] [[package]] -name = "x2apic" -version = "0.4.2" +name = "with_builtin_macros" +version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "547152b57dd1ae0ce7a4ef1c6470f6039aa7ed22e2179d5bc4f3eda1304e0db3" +checksum = "a59d55032495429b87f9d69954c6c8602e4d3f3e0a747a12dea6b0b23de685da" +dependencies = [ + "with_builtin_macros-proc_macros", +] + +[[package]] +name = "with_builtin_macros-proc_macros" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15bd7679c15e22924f53aee34d4e448c45b674feb6129689af88593e129f8f42" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "x2apic" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbcd582541cbb8ef1dfc24a3c849a64ff074b1b512af723ad90056558d424602" dependencies = [ "bit", - "bitflags", + "bitflags 1.3.2", "paste", "raw-cpuid", "x86_64", @@ -1445,12 +1576,12 @@ dependencies = [ [[package]] name = "x86_64" -version = "0.14.10" +version = "0.14.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "100555a863c0092238c2e0e814c1096c1e5cf066a309c696a87e907b5f8c5d69" +checksum = "3b835097a84e4457323331ec5d6eb23d096066cbfb215d54096dcb4b2e85f500" dependencies = [ "bit_field", - "bitflags", + "bitflags 2.4.1", "rustversion", "volatile", ] @@ -1458,28 +1589,48 @@ dependencies = [ [[package]] name = "xml" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/ableos_userland#a45a19c6b7355ebdac53259d06a1894a096143e6" +source = "git+https://git.ablecorp.us/ableos/ableos_userland#c990d072981b3076fa3e4f30f5c7c8f84b01c804" dependencies = [ "serde", ] [[package]] name = "zerocopy" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3b9c234616391070b0b173963ebc65a9195068e7ed3731c6edac2ec45ebe106" +checksum = "96f8f25c15a0edc9b07eb66e7e6e97d124c0505435c382fde1ab7ceb188aa956" dependencies = [ "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.6.5", +] + +[[package]] +name = "zerocopy" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ede7d7c7970ca2215b8c1ccf4d4f354c4733201dfaaba72d44ae5b37472e4901" +dependencies = [ + "zerocopy-derive 0.7.18", ] [[package]] name = "zerocopy-derive" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f7f3a471f98d0a61c34322fbbfd10c384b07687f680d4119813713f72308d91" +checksum = "855e0f6af9cd72b87d8a6c586f3cb583f5cdcc62c2c80869d8cd7e96fdf7ee20" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b27b1bb92570f989aac0ab7e9cbfbacdd65973f7ee920d9f0e71ebac878fd0b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", ] diff --git a/kernel/src/arch/x86_64/mod.rs b/kernel/src/arch/x86_64/mod.rs index 18809cfc..a8bae23e 100644 --- a/kernel/src/arch/x86_64/mod.rs +++ b/kernel/src/arch/x86_64/mod.rs @@ -33,7 +33,24 @@ const INITIAL_KERNEL_HEAP_START: *mut u8 = _initial_kernel_heap_start as _; const INITIAL_KERNEL_HEAP_SIZE: *const () = _initial_kernel_heap_size as _; #[no_mangle] +#[naked] unsafe extern "C" fn _kernel_start() -> ! { + // Initialise SSE and jump to kernel entrypoint + core::arch::asm!( + "mov rax, cr0", + "and ax, 0xfffb", + "or ax, 0x2", + "mov cr0, rax", + "mov rax, cr4", + "or ax, 3 << 9", + "mov cr4, rax", + "jmp {}", + sym start, + options(noreturn), + ) +} + +unsafe extern "C" fn start() -> ! { logging::init(); crate::logger::init().expect("failed to set logger"); log::info!("Initialising AKern {}", crate::VERSION); diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs new file mode 100644 index 00000000..8cce65d0 --- /dev/null +++ b/kernel/src/holeybytes/ecah.rs @@ -0,0 +1,86 @@ +//! Environment call handling routines + +use { + super::{mem::Memory, Vm}, + crate::{arch, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS}, + log::{debug, error, info, trace, warn}, +}; + +pub fn handler(vm: &mut Vm) { + let r255 = vm.registers[255].cast::(); + let r254 = vm.registers[254].cast::(); + let r253 = vm.registers[253].cast::(); + + debug!("Ecall number {:?}", r255); + trace!("Register dump: {:?}", vm.registers); + + match r255 { + 0 => { + // TODO: explode computer + // hello world ecall + for x in 0u64..=255 { + vm.registers[x as usize] = x.into(); + } + } + 1 => { + // Make buffer + let r255 = vm.registers[255].cast::(); + let r254 = vm.registers[254].cast::(); + let r253 = vm.registers[253].cast::(); + + let bounded = match r254 { + 0 => false, + 1 => true, + _ => { + panic!("Bad"); + } + }; + + let length = r254; + + let mut buffs = IPC_BUFFERS.lock(); + let abc; + + match bounded { + false => { + abc = IpcBuffer::new(false, 0); + } + true => { + abc = IpcBuffer::new(true, length); + } + }; + let buff_id = arch::hardware_random_u64(); + buffs.insert(buff_id, abc); + debug!("Buffer ID: {}", buff_id); + } + 2 => { + // Delete buffer + } + 3 => { + // Send a message to a buffer + let r254 = vm.registers[254].cast::(); + let r253 = vm.registers[253].cast::(); + let r252 = vm.registers[252].cast::(); + + let buffer_id = r254; + let mem_addr = r253; + let length = r252 as usize; + trace!("IPC address: {:?}", mem_addr); + use alloc::vec::Vec; + + match buffer_id { + 1 => { + error!("Logging via IPC isn't quite ready") + } + buffer_id => { + info!("Message has been sent to {}", buffer_id) + } + } + } + // 4 + // 5 + _ => { + log::error!("Syscall unknown {:?}", r255) + } + } +} diff --git a/kernel/src/holeybytes/mem.rs b/kernel/src/holeybytes/mem.rs new file mode 100644 index 00000000..8c7fdd97 --- /dev/null +++ b/kernel/src/holeybytes/mem.rs @@ -0,0 +1,37 @@ +//! Security? Multiple address spaces? What are you talking about +//! young adventurer. In this temple, we know no such words. +//! +//! Want your program to override other program's data or even the +//! data of the kernel itself? Sure. This right shall not be infringed. + +use hbvm::mem::Address; + +pub struct Memory; +impl hbvm::mem::Memory for Memory { + #[inline] + unsafe fn load( + &mut self, + addr: Address, + target: *mut u8, + count: usize, + ) -> Result<(), hbvm::mem::LoadError> { + core::ptr::copy(addr.get() as *const u8, target, count); + Ok(()) + } + + #[inline] + unsafe fn store( + &mut self, + addr: Address, + source: *const u8, + count: usize, + ) -> Result<(), hbvm::mem::StoreError> { + core::ptr::copy(source, addr.get() as *mut u8, count); + Ok(()) + } + + #[inline] + unsafe fn prog_read(&mut self, addr: Address) -> T { + (addr.get() as *const T).read() + } +} diff --git a/kernel/src/holeybytes/mod.rs b/kernel/src/holeybytes/mod.rs index 4e2b69c8..3b79f5e5 100644 --- a/kernel/src/holeybytes/mod.rs +++ b/kernel/src/holeybytes/mod.rs @@ -1,21 +1,26 @@ +mod ecah; +mod mem; + use { crate::{arch, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS}, alloc::boxed::Box, - core::{default, future::Future, task::Poll}, + core::{default, future::Future, marker::PhantomData, task::Poll}, hbvm::{ mem::{ softpaging::{icache::ICache, HandlePageFault, SoftPagedMem}, Address, Memory, }, - Vm, VmRunError, VmRunOk, + VmRunError, VmRunOk, }, log::{debug, error, info, trace, warn}, }; const TIMER_QUOTIENT: usize = 100; +type Vm = hbvm::Vm; pub struct ExecThread<'p> { - vm: Vm, TIMER_QUOTIENT>, + vm: Vm, + _phantom: PhantomData<&'p [u8]>, } unsafe impl<'p> Send for ExecThread<'p> {} @@ -24,15 +29,11 @@ impl<'p> ExecThread<'p> { ExecThread { vm: unsafe { Vm::new( - SoftPagedMem { - root_pt: Box::into_raw(Box::default()), - pf_handler: PageFaultHandler, - program, - icache: ICache::default(), - }, - entrypoint, + mem::Memory, + Address::new(program.as_ptr() as u64 + entrypoint.get()), ) }, + _phantom: Default::default(), } } } @@ -46,94 +47,18 @@ impl<'p> Future for ExecThread<'p> { ) -> Poll { match self.vm.run() { Err(err) => { - log::error!( - "HBVM Error\r -Register dump: {:?}", - self.vm.registers - ); - + log::error!("HBVM Error\r\nRegister dump: {:?}", self.vm.registers,); return Poll::Ready(Err(err)); } Ok(VmRunOk::End) => return Poll::Ready(Ok(())), - Ok(VmRunOk::Ecall) => { - let r255 = self.vm.registers[255]; - let r254 = self.vm.registers[254]; - let r253 = self.vm.registers[253]; - - debug!("Ecall number {:?}", r255); - trace!("Register dump: {:?}", self.vm.registers); - - match r255.cast::() { - 0 => { - // TODO: explode computer - // hello world ecall - for x in 0u64..=255 { - self.vm.registers[x as usize] = x.into(); - } - } - 1 => { - // Make buffer - let r255 = self.vm.registers[255]; - let r254 = self.vm.registers[254]; - let r253 = self.vm.registers[253]; - - let bounded = match unsafe { r254.u64 } { - 0 => false, - 1 => true, - _ => { - panic!("Bad"); - } - }; - - let length = unsafe { r254.u64 }; - - let mut buffs = IPC_BUFFERS.lock(); - let abc; - - match bounded { - false => { - abc = IpcBuffer::new(false, 0); - } - true => { - abc = IpcBuffer::new(true, length); - } - }; - let buff_id = arch::hardware_random_u64(); - buffs.insert(buff_id, abc); - debug!("Buffer ID: {}", buff_id); - } - 2 => { - // Delete buffer - } - 3 => { - // Send a message to a buffer - let r254 = self.vm.registers[254]; - let r253 = self.vm.registers[253]; - let r252 = self.vm.registers[252]; - - let buffer_id = unsafe { r254.u64 }; - let mem_addr = unsafe { r253.u64 }; - let length = unsafe { r252.u64 as usize }; - trace!("IPC address: {:?}", mem_addr); - use alloc::vec::Vec; - - match buffer_id { - 1 => { - error!("Logging via IPC isn't quite ready") - } - buffer_id => { - info!("Message has been sent to {}", buffer_id) - } - } - } - // 4 - // 5 - _ => { - log::error!("Syscall unknown {:?}", r255) - } - } - } + Ok(VmRunOk::Ecall) => ecah::handler(&mut self.vm), Ok(VmRunOk::Timer) => (), + Ok(VmRunOk::Breakpoint) => { + log::error!( + "HBVM Debug breakpoint\r\nRegister dump: {:?}", + self.vm.registers, + ); + } } cx.waker().wake_by_ref(); diff --git a/kernel/src/kmain.rs b/kernel/src/kmain.rs index 192dc313..65c05a10 100644 --- a/kernel/src/kmain.rs +++ b/kernel/src/kmain.rs @@ -47,7 +47,7 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! { unsafe { for module in boot_modules.into_iter().take(2) { executor.spawn(async move { - if let Err(e) = ExecThread::new(&module.bytes, Address::new(4)).await { + if let Err(e) = ExecThread::new(&module.bytes, Address::new(0)).await { log::error!("{e:?}"); } }); diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 4b08366f..e16c84c3 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -10,11 +10,11 @@ panic_info_message, pointer_is_aligned, ptr_sub_ptr, - custom_test_frameworks + custom_test_frameworks, + naked_functions, )] #![allow(dead_code)] #![test_runner(crate::test_runner)] - extern crate alloc; mod allocator; diff --git a/kernel/targets/x86_64-ableos.json b/kernel/targets/x86_64-ableos.json index cd32752a..3aec5d63 100644 --- a/kernel/targets/x86_64-ableos.json +++ b/kernel/targets/x86_64-ableos.json @@ -11,7 +11,7 @@ "linker": "rust-lld", "panic-strategy": "abort", "disable-redzone": true, - "features": "-mmx,-sse,+soft-float", + "features": "", "code-model": "kernel", "pre-link-args": { "ld.lld": [ diff --git a/repbuild/Cargo.toml b/repbuild/Cargo.toml index f537a2ae..d7569a32 100644 --- a/repbuild/Cargo.toml +++ b/repbuild/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" derive_more = "0.99" error-stack = "0.4" fatfs = "0.3" +hbasm.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git" [dependencies.reqwest] version = "0.11" diff --git a/repbuild/holeybytes/ecall.hb b/repbuild/holeybytes/ecall.hb deleted file mode 100644 index 77c83ec84dbb6ba34ba457f5234db74c654f12d2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 90 ncmd;=jtiLG;X=W_a3NUGy4lo}87{Upe diff --git a/repbuild/holeybytes/ecall.rhai b/repbuild/holeybytes/ecall.rhai new file mode 100644 index 00000000..556d6f17 --- /dev/null +++ b/repbuild/holeybytes/ecall.rhai @@ -0,0 +1,3 @@ +li8 (r1, 0x69); +eca (); +tx (); diff --git a/repbuild/holeybytes/failure.hb b/repbuild/holeybytes/failure.hb deleted file mode 100644 index 0cf46f6a39c8944b5fccfbb4d90d405d0f53d8fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 Ocmd; Result<(), Error> { } } + assemble()?; build(release, target).change_context(Error::Build) } Some("run" | "r") => { @@ -52,6 +53,7 @@ fn main() -> Result<(), Error> { } } + assemble()?; build(release, target)?; run(release, target) } @@ -72,6 +74,40 @@ fn main() -> Result<(), Error> { } } +fn assemble() -> Result<(), Error> { + match std::fs::create_dir("target/holeybytes") { + Ok(_) => (), + Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => (), + Err(e) => return Err(Report::new(e).change_context(Error::Io)), + } + + for entry in std::fs::read_dir("repbuild/holeybytes") + .map_err(Report::from) + .change_context(Error::Io)? + { + let entry = entry.map_err(Report::from).change_context(Error::Io)?; + let name = entry.file_name(); + let name = name.to_string_lossy(); + let name = name.trim_end_matches(".rhai"); + + let mut out = File::options() + .write(true) + .create(true) + .open(Path::new("target/holeybytes").join(format!("{name}.hbf"))) + .map_err(Report::from) + .change_context(Error::Io)?; + + out.set_len(0) + .map_err(Report::from) + .change_context(Error::Io)?; + + hbasm::assembler(&mut out, |engine| engine.run_file(entry.path())) + .map_err(|e| report!(Error::Assembler).attach_printable(e.to_string()))?; + } + + Ok(()) +} + fn get_fs() -> Result, io::Error> { let mut img = File::options() .read(true) @@ -112,13 +148,13 @@ fn get_fs() -> Result, io::Error> { &mut fs.root_dir().create_file("background.bmp")?, )?; io::copy( - &mut File::open("repbuild/holeybytes/failure.hb")?, - &mut fs.root_dir().create_file("failure.hb")?, + &mut File::open("target/holeybytes/failure.hbf")?, + &mut fs.root_dir().create_file("failure.hbf")?, )?; io::copy( - &mut File::open("repbuild/holeybytes/ecall.hb")?, - &mut fs.root_dir().create_file("ecall.hb")?, + &mut File::open("target/holeybytes/ecall.hbf")?, + &mut fs.root_dir().create_file("ecall.hbf")?, )?; drop(bootdir); @@ -300,6 +336,8 @@ enum Error { ProcessSpawn, #[display(fmt = "Failed to fetch UEFI firmware")] OvmfFetch, + #[display(fmt = "Failed to assemble Holey Bytes code")] + Assembler, #[display(fmt = "QEMU Error: {}", "fmt_qemu_err(*_0)")] Qemu(Option), }