From f8c787397802d1ebf1ca1388e1fd43ecd26f80e2 Mon Sep 17 00:00:00 2001 From: koniifer Date: Fri, 13 Sep 2024 22:41:31 +0100 Subject: [PATCH] squash --- Cargo.lock | 777 ++++++++++-------- Cargo.toml | 8 +- kernel/Cargo.toml | 29 +- .../src/arch/aarch64/device_info_collector.rs | 4 +- kernel/src/arch/aarch64/logging.rs | 5 +- kernel/src/arch/aarch64/mod.rs | 31 +- kernel/src/arch/riscv64/memory.rs | 42 +- kernel/src/arch/riscv64/mod.rs | 12 +- kernel/src/arch/x86_64/gdt.rs | 25 +- kernel/src/arch/x86_64/interrupts.rs | 6 +- kernel/src/arch/x86_64/logging.rs | 7 +- kernel/src/arch/x86_64/mod.rs | 74 +- kernel/src/bootmodules.rs | 52 +- kernel/src/holeybytes/ecah.rs | 137 +-- .../holeybytes/kernel_services/mem_serve.rs | 77 +- kernel/src/holeybytes/kernel_services/mod.rs | 14 +- .../service_definition_service.rs | 32 +- kernel/src/holeybytes/mem.rs | 15 +- kernel/src/holeybytes/mod.rs | 115 ++- kernel/src/ipc/buffer.rs | 12 +- kernel/src/ipc/protocol.rs | 13 +- kernel/src/kmain.rs | 35 +- kernel/src/lib.rs | 15 +- kernel/src/logger.rs | 1 + kernel/src/memory.rs | 19 +- kernel/src/task.rs | 194 +++-- repbuild/Cargo.toml | 21 +- repbuild/src/dev.rs | 1 + repbuild/src/main.rs | 32 +- rust-toolchain.toml | 2 +- sysdata/libraries/render/README.md | 9 + sysdata/libraries/render/src/lib.hb | 47 ++ sysdata/libraries/render/src/software.hb | 263 ++++++ sysdata/libraries/render/src/svga.hb | 91 ++ sysdata/libraries/stn/src/lib.hb | 3 +- sysdata/libraries/stn/src/math.hb | 11 +- sysdata/libraries/stn/src/memory.hb | 18 +- sysdata/libraries/stn/src/pci.hb | 50 ++ sysdata/libraries/stn/src/random.hb | 11 +- sysdata/programs/diskio_driver/src/main.hb | 2 +- sysdata/programs/fb_driver/README.md | 2 - sysdata/programs/fb_driver/UNTESTED_FUNCTIONS | 7 - sysdata/programs/fb_driver/src/color.hb | 27 - sysdata/programs/fb_driver/src/draw.hb | 113 --- .../programs/fb_driver/src/examples/amogus.hb | 26 - .../fb_driver/src/examples/buffers.hb | 19 - .../programs/fb_driver/src/examples/colors.hb | 27 - .../programs/fb_driver/src/examples/lines.hb | 25 - .../programs/fb_driver/src/examples/random.hb | 17 - .../programs/fb_driver/src/examples/square.hb | 32 - .../programs/fb_driver/src/examples/strobe.hb | 20 - sysdata/programs/fb_driver/src/lib.hb | 88 -- sysdata/programs/fb_driver/src/main.hb | 6 - .../{fb_driver => render_example}/meta.toml | 4 +- .../render_example/src/examples/amogus.hb | 20 + .../render_example/src/examples/colors.hb | 21 + .../render_example/src/examples/lines.hb | 22 + .../render_example/src/examples/random.hb | 17 + .../render_example/src/examples/square.hb | 27 + .../render_example/src/examples/strobe.hb | 15 + .../render_example/src/examples/svga.hb | 8 + sysdata/programs/render_example/src/main.hb | 6 + .../README.md | 0 .../meta.toml | 2 +- .../src/main.hb | 3 +- .../programs/serial_driver_test/src/main.hb | 2 +- sysdata/system_config.toml | 12 +- 67 files changed, 1599 insertions(+), 1281 deletions(-) create mode 100644 sysdata/libraries/render/README.md create mode 100644 sysdata/libraries/render/src/lib.hb create mode 100644 sysdata/libraries/render/src/software.hb create mode 100644 sysdata/libraries/render/src/svga.hb create mode 100644 sysdata/libraries/stn/src/pci.hb delete mode 100644 sysdata/programs/fb_driver/README.md delete mode 100644 sysdata/programs/fb_driver/UNTESTED_FUNCTIONS delete mode 100644 sysdata/programs/fb_driver/src/color.hb delete mode 100644 sysdata/programs/fb_driver/src/draw.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/amogus.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/buffers.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/colors.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/lines.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/random.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/square.hb delete mode 100644 sysdata/programs/fb_driver/src/examples/strobe.hb delete mode 100644 sysdata/programs/fb_driver/src/lib.hb delete mode 100644 sysdata/programs/fb_driver/src/main.hb rename sysdata/programs/{fb_driver => render_example}/meta.toml (71%) create mode 100644 sysdata/programs/render_example/src/examples/amogus.hb create mode 100644 sysdata/programs/render_example/src/examples/colors.hb create mode 100644 sysdata/programs/render_example/src/examples/lines.hb create mode 100644 sysdata/programs/render_example/src/examples/random.hb create mode 100644 sysdata/programs/render_example/src/examples/square.hb create mode 100644 sysdata/programs/render_example/src/examples/strobe.hb create mode 100644 sysdata/programs/render_example/src/examples/svga.hb create mode 100644 sysdata/programs/render_example/src/main.hb rename sysdata/programs/{a_serial_driver => serial_driver}/README.md (100%) rename sysdata/programs/{a_serial_driver => serial_driver}/meta.toml (84%) rename sysdata/programs/{a_serial_driver => serial_driver}/src/main.hb (90%) diff --git a/Cargo.lock b/Cargo.lock index 0fadff6..75c9a25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,40 +3,28 @@ version = 3 [[package]] -name = "able_graphics_library" -version = "0.1.2" -source = "git+https://git.ablecorp.us/ableos/ableos_userland#6c38f2b2f1f7f04b43a8def709de1da98cb5fba1" +name = "aarch64-cpu" +version = "9.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac42a04a61c19fc8196dd728022a784baecc5d63d7e256c01ad1b3fbfab26287" dependencies = [ - "embedded-graphics", - "log", - "versioning", + "tock-registers", ] [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "ahash" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "ahash" @@ -47,7 +35,7 @@ dependencies = [ "cfg-if", "once_cell", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -73,9 +61,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" [[package]] name = "autocfg" @@ -91,24 +79,24 @@ checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets", ] [[package]] name = "base64" -version = "0.21.7" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "beef" @@ -160,9 +148,9 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cc" -version = "1.1.16" +version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d013ecb737093c0e86b151a7b837993cf9ec6c502946cfb44bedc392421e0b" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" dependencies = [ "shlex", ] @@ -184,33 +172,7 @@ dependencies = [ "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.6", -] - -[[package]] -name = "clparse" -version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/ableos_userland#6c38f2b2f1f7f04b43a8def709de1da98cb5fba1" -dependencies = [ - "hashbrown 0.14.5", - "log", - "toml 0.5.9", -] - -[[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.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", + "windows-targets", ] [[package]] @@ -236,15 +198,23 @@ checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "derive_more" -version = "0.99.18" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ - "convert_case", "proc-macro2", "quote", - "rustc_version", "syn", + "unicode-xid", ] [[package]] @@ -256,9 +226,9 @@ dependencies = [ [[package]] name = "embedded-graphics" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "750082c65094fbcc4baf9ba31583ce9a8bb7f52cadfb96f6164b1bc7f922f32b" +checksum = "0649998afacf6d575d126d83e68b78c0ab0e00ca2ac7e9b3db11b4cbe8274ef0" dependencies = [ "az", "byteorder", @@ -269,21 +239,23 @@ dependencies = [ [[package]] name = "embedded-graphics-core" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b1239db5f3eeb7e33e35bd10bd014e7b2537b17e071f726a09351431337cfa" +checksum = "ba9ecd261f991856250d2207f6d8376946cd9f412a2165d3b75bc87a0bc7a044" dependencies = [ "az", "byteorder", ] [[package]] -name = "encoding_rs" -version = "0.8.34" +name = "enumn" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ - "cfg-if", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -294,9 +266,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "error-stack" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27a72baa257b5e0e2de241967bc5ee8f855d6072351042688621081d66b2a76b" +checksum = "fe413319145d1063f080f27556fd30b1d70b01e2ba10c2a6e40d4be982ffc5d1" dependencies = [ "anyhow", "rustc_version", @@ -316,9 +288,9 @@ dependencies = [ [[package]] name = "float-cmp" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1267f4ac4f343772758f7b1bdcbe767c218bbab93bb432acbf5162bbf85a6c4" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" dependencies = [ "num-traits", ] @@ -345,6 +317,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -379,6 +352,7 @@ checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-io", + "futures-sink", "futures-task", "memchr", "pin-project-lite", @@ -399,37 +373,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" - -[[package]] -name = "h2" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.8", -] +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "hashbrown" @@ -437,24 +383,24 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash 0.8.11", + "ahash", "allocator-api2", ] [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#894f73ca35199f524dff6160c57c0916169fbaf6" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" dependencies = [ "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -462,7 +408,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -470,7 +416,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#894f73ca35199f524dff6160c57c0916169fbaf6" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)", ] @@ -483,9 +429,9 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "http" -version = "0.2.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", @@ -494,12 +440,24 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.6" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", "pin-project-lite", ] @@ -509,48 +467,61 @@ version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - [[package]] name = "hyper" -version = "0.14.30" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", - "futures-core", "futures-util", - "h2", "http", "http-body", "httparse", - "httpdate", "itoa", "pin-project-lite", - "socket2", + "smallvec", "tokio", - "tower-service", - "tracing", "want", ] [[package]] name = "hyper-rustls" -version = "0.24.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http", "hyper", + "hyper-util", "rustls", + "rustls-pki-types", "tokio", "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -593,14 +564,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown", ] [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "itoa" @@ -621,17 +592,14 @@ dependencies = [ name = "kernel" version = "0.2.0" dependencies = [ - "able_graphics_library", - "clparse", + "aarch64-cpu", "crossbeam-queue", "derive_more", "embedded-graphics", - "hashbrown 0.14.5", + "hashbrown", "hbvm 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)", - "kiam", "limine", "log", - "rdrand", "sbi", "slab", "spin", @@ -639,16 +607,10 @@ dependencies = [ "versioning", "virtio-drivers", "x2apic", - "x86_64", + "x86_64 0.15.1", "xml", ] -[[package]] -name = "kiam" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0fc32485e41ae5e9dedd1442f36dec998431adc9f321224c2c5d645f38fdcb" - [[package]] name = "lazy_static" version = "1.5.0" @@ -724,9 +686,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "micromath" -version = "1.1.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc4010833aea396656c2f91ee704d51a6f1329ec2ab56ffd00bfd56f7481ea94" +checksum = "c3c8dda44ff03a2f238717214da50f65d5a53b45cd213a7370424ffdb6fae815" [[package]] name = "mime" @@ -736,11 +698,11 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] @@ -791,6 +753,26 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.14" @@ -803,6 +785,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -812,6 +803,54 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quinn" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +dependencies = [ + "bytes", + "rand", + "ring", + "rustc-hash", + "rustls", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.59.0", +] + [[package]] name = "quote" version = "1.0.37" @@ -821,11 +860,35 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] [[package]] name = "raw-cpuid" @@ -836,15 +899,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "rdrand" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d92195228612ac8eed47adbc2ed0f04e513a4ccb98175b6f2bd04d963b533655" -dependencies = [ - "rand_core", -] - [[package]] name = "regex-syntax" version = "0.8.4" @@ -861,25 +915,26 @@ dependencies = [ "hblang", "reqwest", "str-reader", - "toml 0.5.11", + "toml", ] [[package]] name = "reqwest" -version = "0.11.27" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ "base64", "bytes", - "encoding_rs", + "futures-channel", "futures-core", "futures-util", - "h2", "http", "http-body", + "http-body-util", "hyper", "hyper-rustls", + "hyper-util", "ipnet", "js-sys", "log", @@ -887,13 +942,14 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "quinn", "rustls", "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", - "system-configuration", "tokio", "tokio-rustls", "tower-service", @@ -902,7 +958,7 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots", - "winreg", + "windows-registry", ] [[package]] @@ -926,6 +982,12 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc_version" version = "0.4.1" @@ -937,32 +999,42 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.12" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ - "log", + "once_cell", "ring", + "rustls-pki-types", "rustls-webpki", - "sct", + "subtle", + "zeroize", ] [[package]] name = "rustls-pemfile" -version = "1.0.4" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ "base64", + "rustls-pki-types", ] [[package]] -name = "rustls-webpki" -version = "0.101.7" +name = "rustls-pki-types" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" + +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring", + "rustls-pki-types", "untrusted", ] @@ -990,16 +1062,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "semver" version = "1.0.23" @@ -1008,18 +1070,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -1028,9 +1090,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.127" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -1038,6 +1100,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1065,6 +1136,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + [[package]] name = "socket2" version = "0.5.7" @@ -1090,6 +1167,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6aa20b89aec46e0bffbb8756e089beb4c43bbec53d0667de34212f048bdab10" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.77" @@ -1103,29 +1186,31 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "0.1.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", + "futures-core", ] [[package]] -name = "system-configuration-sys" -version = "0.5.0" +name = "thiserror" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ - "core-foundation-sys", - "libc", + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1143,6 +1228,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tock-registers" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "696941a0aee7e276a165a978b37918fd5d22c55c3d6bda197813070ca9c0f21c" + [[package]] name = "tokio" version = "1.40.0" @@ -1160,44 +1251,69 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.1" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ "rustls", + "rustls-pki-types", "tokio", ] [[package]] -name = "tokio-util" -version = "0.7.11" +name = "toml" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ - "bytes", "futures-core", - "futures-sink", + "futures-util", + "pin-project", "pin-project-lite", "tokio", + "tower-layer", + "tower-service", ] [[package]] -name = "toml" -version = "0.5.9" -source = "git+https://git.ablecorp.us/asya/toml-rs#4379150168e87103739a196566a7ce17ff245f01" -dependencies = [ - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "toml" -version = "0.5.11" +name = "tower-layer" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" @@ -1232,13 +1348,13 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "uart_16550" -version = "0.2.19" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614ff2a87880d4bd4374722268598a970bbad05ced8bf630439417347254ab2e" +checksum = "4922792855b1bce30997fbaa5418597902c278a92d20dfe348e6f062c3bd861d" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "rustversion", - "x86_64", + "x86", ] [[package]] @@ -1249,9 +1365,9 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" @@ -1262,6 +1378,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-xid" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" + [[package]] name = "untrusted" version = "0.9.0" @@ -1295,13 +1417,14 @@ dependencies = [ [[package]] name = "virtio-drivers" -version = "0.4.0" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42299957c6f61af586fe3eae398c16ec07f33a02579fa1d41ae96156ce437029" +checksum = "d6a39747311dabb3d37807037ed1c3c38d39f99198d091b5b79ecd5c8d82f799" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", + "enumn", "log", - "zerocopy 0.6.6", + "zerocopy", ] [[package]] @@ -1404,9 +1527,12 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.4" +version = "0.26.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" +dependencies = [ + "rustls-pki-types", +] [[package]] name = "windows-core" @@ -1414,16 +1540,37 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] -name = "windows-sys" -version = "0.48.0" +name = "windows-registry" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ - "windows-targets 0.48.5", + "windows-result", + "windows-strings", + "windows-targets", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets", ] [[package]] @@ -1432,22 +1579,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] -name = "windows-targets" -version = "0.48.5" +name = "windows-sys" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -1456,46 +1597,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1508,48 +1631,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -1557,13 +1656,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "winreg" -version = "0.50.0" +name = "winnow" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ - "cfg-if", - "windows-sys 0.48.0", + "memchr", ] [[package]] @@ -1576,7 +1674,18 @@ dependencies = [ "bitflags 1.3.2", "paste", "raw-cpuid", - "x86_64", + "x86_64 0.14.12", +] + +[[package]] +name = "x86" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385" +dependencies = [ + "bit_field", + "bitflags 1.3.2", + "raw-cpuid", ] [[package]] @@ -1591,6 +1700,18 @@ dependencies = [ "volatile", ] +[[package]] +name = "x86_64" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bc79523af8abf92fb1a970c3e086c5a343f6bcc1a0eb890f575cbb3b45743df" +dependencies = [ + "bit_field", + "bitflags 2.6.0", + "rustversion", + "volatile", +] + [[package]] name = "xml" version = "0.1.0" @@ -1599,34 +1720,14 @@ dependencies = [ "serde", ] -[[package]] -name = "zerocopy" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" -dependencies = [ - "byteorder", - "zerocopy-derive 0.6.6", -] - [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy-derive" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "byteorder", + "zerocopy-derive", ] [[package]] @@ -1639,3 +1740,9 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/Cargo.toml b/Cargo.toml index 85e0ede..38799da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,9 @@ [workspace] resolver = "2" -members = [ "dev","kernel", "repbuild"] +members = ["dev", "kernel", "repbuild"] + +# [profile.release] +# strip = "symbols" +# codegen-units = 1 +# lto = true +# panic = "abort" diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 27c8c8b..d1764db 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -5,17 +5,16 @@ version = "0.2.0" [dependencies] -embedded-graphics = "0.7" +embedded-graphics = "0.8" hbvm.git = "https://git.ablecorp.us/ableos/holey-bytes" log = "0.4" spin = "0.9" -uart_16550 = "0.2" slab = { version = "0.4", default-features = false } +uart_16550 = { version = "0.3", features = ["nightly"] } xml.git = "https://git.ablecorp.us/ableos/ableos_userland" versioning.git = "https://git.ablecorp.us/ableos/ableos_userland" -able_graphics_library.git = "https://git.ablecorp.us/ableos/ableos_userland" -hashbrown = "*" -kiam = "0.1.1" +# able_graphics_library.git = "https://git.ablecorp.us/ableos/ableos_userland" +hashbrown = { version = "0.14", features = ["nightly"] } [dependencies.limine] version = "0.1" @@ -24,14 +23,14 @@ version = "0.1" [dependencies.crossbeam-queue] version = "0.3" default-features = false -features = ["alloc"] +features = ["alloc", "nightly"] -[dependencies.clparse] -git = "https://git.ablecorp.us/ableos/ableos_userland" -default-features = false +# [dependencies.clparse] +# git = "https://git.ablecorp.us/ableos/ableos_userland" +# default-features = false [dependencies.derive_more] -version = "0.99" +version = "1" default-features = false features = [ "add", @@ -48,12 +47,12 @@ features = [ [target.'cfg(target_arch = "x86_64")'.dependencies] -x86_64 = "0.14" +x86_64 = "0.15" x2apic = "0.4" -virtio-drivers = "0.4.0" -# rdrand = "*" -rdrand = { version = "0.8", default-features = false } - +virtio-drivers = "0.7" [target.'cfg(target_arch = "riscv64")'.dependencies] sbi = "0.2.0" + +[target.'cfg(target_arch = "aarch64")'.dependencies] +aarch64-cpu = "9" diff --git a/kernel/src/arch/aarch64/device_info_collector.rs b/kernel/src/arch/aarch64/device_info_collector.rs index dd200d3..c17d5d1 100644 --- a/kernel/src/arch/aarch64/device_info_collector.rs +++ b/kernel/src/arch/aarch64/device_info_collector.rs @@ -29,7 +29,7 @@ fn collect_cpu_info(device_tree: &mut DeviceTree) { } fn cpu_id() -> (String, u64) { - let mut cpu_id: u64 = 0; + let mut cpu_id: u64; unsafe { asm!("mrs {cpu_id}, MIDR_EL1", cpu_id = out(reg) cpu_id, @@ -41,6 +41,8 @@ fn cpu_id() -> (String, u64) { // https://raspberrypi.stackexchange.com/questions/117175/how-do-i-read-the-cpuid-in-aarch64-asm 0x410FD034 => "Cortex-A53".to_string(), 0x410FD083 => "Cortex-A72".to_string(), + // the source of this one was checking the cpu id :thinking: + 0x410FD493 => "Neoverse N2".to_string(), _ => "Unknown".to_string(), }; log::trace!("CPU Name: {cpu_name} - CPU ID: 0x{:X}", cpu_id); diff --git a/kernel/src/arch/aarch64/logging.rs b/kernel/src/arch/aarch64/logging.rs index 5db9bc0..20e73f8 100644 --- a/kernel/src/arch/aarch64/logging.rs +++ b/kernel/src/arch/aarch64/logging.rs @@ -1,5 +1,5 @@ use {crate::logger::TERMINAL_LOGGER, core::fmt::Write, spin::Mutex}; -const SERIAL_CONSOLE: Mutex = Mutex::new(SerialConsole { +static SERIAL_CONSOLE: Mutex = Mutex::new(SerialConsole { uart: 0x09000000 as *mut u8, }); @@ -17,6 +17,9 @@ impl core::fmt::Write for SerialConsole { } } +unsafe impl Sync for SerialConsole {} +unsafe impl Send for SerialConsole {} + pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result { SERIAL_CONSOLE.lock().write_fmt(args)?; TERMINAL_LOGGER.lock().write_fmt(args)?; diff --git a/kernel/src/arch/aarch64/mod.rs b/kernel/src/arch/aarch64/mod.rs index 793288a..a69e1ee 100644 --- a/kernel/src/arch/aarch64/mod.rs +++ b/kernel/src/arch/aarch64/mod.rs @@ -1,6 +1,7 @@ pub use logging::log; use { crate::{allocator, bootmodules::BootModule, kmain::kmain}, + alloc::vec::Vec, core::arch::asm, limine::FramebufferRequest, }; @@ -41,7 +42,7 @@ unsafe extern "C" fn _kernel_start() -> ! { static KFILE_REQ: KernelFileRequest = KernelFileRequest::new(0); static MOD_REQ: ModuleRequest = ModuleRequest::new(0); - let mut bootmodules = alloc::vec::Vec::new(); + let mut bootmodules = Vec::new(); if bm.is_some() { let bm = bm.unwrap(); @@ -52,18 +53,13 @@ unsafe extern "C" fn _kernel_start() -> ! { let raw_bytes = core::slice::from_raw_parts( file.base.as_ptr().expect("invalid initrd"), file.length as usize, - ) - .to_vec(); - - let file_path = alloc::string::String::from_utf8( - file.path.to_str().unwrap().to_bytes().to_vec(), ); + + let file_path = file.path.to_str().unwrap().to_str(); if file_path.is_err() { panic!("invalid file path: {:?}", file_path); } - let file_cmd = alloc::string::String::from_utf8( - file.cmdline.to_str().unwrap().to_bytes().to_vec(), - ); + let file_cmd = file.cmdline.to_str().unwrap().to_str(); if file_cmd.is_err() { panic!("invalid module cmd: {:?}", file_cmd); } @@ -85,7 +81,7 @@ unsafe extern "C" fn _kernel_start() -> ! { assert_eq!(bm.module_count, bootmodules.len() as u64); } - crate::kmain::kmain( + kmain( KFILE_REQ .get_response() .get() @@ -99,8 +95,6 @@ unsafe extern "C" fn _kernel_start() -> ! { .unwrap_or_default(), bootmodules, ); - - spin_loop(); } pub fn spin_loop() -> ! { @@ -109,8 +103,19 @@ pub fn spin_loop() -> ! { } } +/// I am sorry. +static mut A_REAL_RANDOM_U64_I_PROMISE: u64 = 0; + pub fn hardware_random_u64() -> u64 { - 0 + if let Some(rng) = aarch64_cpu::asm::random::ArmRng::new() { + if let Some(rnd) = rng.rndr() { + return rnd; + } + } + unsafe { + A_REAL_RANDOM_U64_I_PROMISE += 1; + A_REAL_RANDOM_U64_I_PROMISE + } } pub fn register_dump() {} diff --git a/kernel/src/arch/riscv64/memory.rs b/kernel/src/arch/riscv64/memory.rs index b6411d7..a4859ae 100644 --- a/kernel/src/arch/riscv64/memory.rs +++ b/kernel/src/arch/riscv64/memory.rs @@ -1,8 +1,10 @@ use core::num; -use alloc::boxed::Box; -use spin::{Mutex, Once}; -use crate::memory::{MemoryManager, PhysicalAddress, VirtualAddress}; +use { + crate::memory::{MemoryManager, PhysicalAddress, VirtualAddress}, + alloc::boxed::Box, + spin::{Mutex, Once}, +}; use super::PAGE_SIZE; @@ -28,7 +30,7 @@ impl PageSize { } pub struct PageTable { - entries: [PageEntry; 512] + entries: [PageEntry; 512], } impl PageTable { @@ -72,8 +74,14 @@ impl PageTable { /// flags MUST include one or more of the following: /// Read, Write, Execute /// The valid bit automatically gets added - pub fn map(&mut self, vaddr: VirtualAddress, paddr: PhysicalAddress, flags: PageEntryFlags, page_size: PageSize) { - assert!(flags as usize & 0xe != 0); + pub fn map( + &mut self, + vaddr: VirtualAddress, + paddr: PhysicalAddress, + flags: PageEntryFlags, + page_size: PageSize, + ) { + assert!(flags as usize & 0xE != 0); let vpn = vaddr.vpns(); let ppn = paddr.ppns(); @@ -91,7 +99,7 @@ impl PageTable { } let entry = v.addr().as_mut_ptr::(); - v = unsafe { entry.add(vpn[i]).as_mut().unwrap() }; + v = unsafe { entry.add(vpn[i]).as_mut().unwrap() }; } // When we get here, we should be at VPN[0] and v should be pointing to our entry. @@ -105,14 +113,24 @@ impl PageTable { } /// Identity maps a page of memory - pub fn identity_map(&mut self, addr: PhysicalAddress, flags: PageEntryFlags, page_size: PageSize) { + pub fn identity_map( + &mut self, + addr: PhysicalAddress, + flags: PageEntryFlags, + page_size: PageSize, + ) { // log::debug!("identity mapped {addr}"); self.map(addr.as_addr().into(), addr, flags, page_size); } /// Identity maps a range of contiguous memory /// This assumes that start <= end - pub fn identity_map_range(&mut self, start: PhysicalAddress, end: PhysicalAddress, flags: PageEntryFlags) { + pub fn identity_map_range( + &mut self, + start: PhysicalAddress, + end: PhysicalAddress, + flags: PageEntryFlags, + ) { log::debug!("start: {start}, end: {end}"); let mut mem_addr = start.as_addr() & !(PAGE_SIZE - 1); let num_pages = (align_val(end.as_addr(), 12) - mem_addr - 1) / PAGE_SIZE + 1; @@ -142,7 +160,7 @@ impl PageTable { } let entry = v.addr().as_mut_ptr::(); - v = unsafe { entry.add(vpn[i]).as_mut().unwrap() }; + v = unsafe { entry.add(vpn[i]).as_mut().unwrap() }; } // If we're here this is an unmapped page @@ -182,7 +200,7 @@ pub enum PageEntryFlags { Global = 1 << 5, Access = 1 << 6, Dirty = 1 << 7, - + // for convenience ReadWrite = Self::Read as usize | Self::Write as usize, ReadExecute = Self::Read as usize | Self::Execute as usize, @@ -228,7 +246,7 @@ impl PageEntry { } fn addr(&self) -> PhysicalAddress { - ((self.entry() as usize & !0x3ff) << 2).into() + ((self.entry() as usize & !0x3FF) << 2).into() } fn destroy(&mut self) { diff --git a/kernel/src/arch/riscv64/mod.rs b/kernel/src/arch/riscv64/mod.rs index 2caa6c3..c1a8519 100644 --- a/kernel/src/arch/riscv64/mod.rs +++ b/kernel/src/arch/riscv64/mod.rs @@ -1,7 +1,7 @@ mod memory; use { - alloc::boxed::Box, + alloc::{boxed::Box, vec::Vec}, core::{ arch::{asm, global_asm}, fmt::Write, @@ -45,7 +45,7 @@ extern "C" { static USABLE_MEMORY_SIZE: usize; } -static SERIAL_CONSOLE: Once> = Once::new(); +pub static SERIAL_CONSOLE: Once> = Once::new(); #[no_mangle] unsafe extern "C" fn _kernel_start() -> ! { @@ -95,7 +95,7 @@ unsafe extern "C" fn _kernel_start() -> ! { in(reg) satp_value, ); - crate::kmain::kmain("baka=9", None); + crate::kmain::kmain("baka=9", Vec::new()); } /// Spin loop @@ -105,6 +105,12 @@ pub fn spin_loop() -> ! { } } +pub fn hardware_random_u64() -> u64 { + 0 +} + +pub fn register_dump() {} + pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result { SERIAL_CONSOLE.get().unwrap().lock().write_fmt(args) } diff --git a/kernel/src/arch/x86_64/gdt.rs b/kernel/src/arch/x86_64/gdt.rs index 4bc32b2..a1e7759 100644 --- a/kernel/src/arch/x86_64/gdt.rs +++ b/kernel/src/arch/x86_64/gdt.rs @@ -11,6 +11,9 @@ use { pub const DOUBLE_FAULT_IX: u16 = 0; +const STACK_SIZE: usize = 5 * 1024; +const STACK_ALIGNMENT: usize = 4096; + pub unsafe fn init() { use x86_64::instructions::{ segmentation::{Segment, CS, SS}, @@ -32,24 +35,24 @@ struct Selectors { static TSS: Lazy = Lazy::new(|| { let mut tss = TaskStateSegment::new(); - tss.interrupt_stack_table[usize::from(DOUBLE_FAULT_IX)] = { - const SIZE: usize = 5 * 1024; - let stack = unsafe { - alloc::alloc::alloc_zeroed( - alloc::alloc::Layout::from_size_align(SIZE, 1).expect("stack pointer"), - ) - }; - VirtAddr::from_ptr(stack) + SIZE + + let stack_ptr = unsafe { + let layout = alloc::alloc::Layout::from_size_align(STACK_SIZE, STACK_ALIGNMENT) + .expect("Failed to create stack layout"); + let stack = alloc::alloc::alloc_zeroed(layout); + VirtAddr::from_ptr(stack) + STACK_SIZE as u64 }; + + tss.interrupt_stack_table[usize::from(DOUBLE_FAULT_IX)] = stack_ptr; tss }); static GDT: Lazy<(GlobalDescriptorTable, Selectors)> = Lazy::new(|| { let mut gdt = GlobalDescriptorTable::new(); let sels = Selectors { - kcode: gdt.add_entry(Descriptor::kernel_code_segment()), - kdata: gdt.add_entry(Descriptor::kernel_data_segment()), - tss: gdt.add_entry(Descriptor::tss_segment(&TSS)), + kcode: gdt.append(Descriptor::kernel_code_segment()), + kdata: gdt.append(Descriptor::kernel_data_segment()), + tss: gdt.append(Descriptor::tss_segment(&TSS)), }; (gdt, sels) }); diff --git a/kernel/src/arch/x86_64/interrupts.rs b/kernel/src/arch/x86_64/interrupts.rs index bc7ea2f..08e7aa0 100644 --- a/kernel/src/arch/x86_64/interrupts.rs +++ b/kernel/src/arch/x86_64/interrupts.rs @@ -45,9 +45,9 @@ static IDT: Lazy = Lazy::new(|| { } idt.page_fault.set_handler_fn(page_fault); - idt[Interrupt::ApicErr as usize].set_handler_fn(apic_err); - idt[Interrupt::Spurious as usize].set_handler_fn(spurious); - idt[Interrupt::Timer as usize].set_handler_fn(timer); + idt[Interrupt::ApicErr as u8].set_handler_fn(apic_err); + idt[Interrupt::Spurious as u8].set_handler_fn(spurious); + idt[Interrupt::Timer as u8].set_handler_fn(timer); idt }); diff --git a/kernel/src/arch/x86_64/logging.rs b/kernel/src/arch/x86_64/logging.rs index 5652b25..13fd49e 100644 --- a/kernel/src/arch/x86_64/logging.rs +++ b/kernel/src/arch/x86_64/logging.rs @@ -1,11 +1,6 @@ //! Logging (as in terms of console / serial output) #![allow(deprecated)] -use { - core::fmt::Write, - limine::{TerminalRequest, TerminalResponse}, - spin::{Lazy, Mutex}, - uart_16550::SerialPort, -}; +use {core::fmt::Write, spin::Mutex, uart_16550::SerialPort}; pub static SERIAL_CONSOLE: Mutex = Mutex::new(unsafe { SerialPort::new(0x3F8) }); diff --git a/kernel/src/arch/x86_64/mod.rs b/kernel/src/arch/x86_64/mod.rs index 7437b1e..51dd9ee 100644 --- a/kernel/src/arch/x86_64/mod.rs +++ b/kernel/src/arch/x86_64/mod.rs @@ -1,7 +1,6 @@ -use { - crate::bootmodules::BootModule, core::arch::asm, embedded_graphics::pixelcolor::Rgb888, - log::warn, rdrand::RdSeed, -}; +use core::arch::x86_64::{_rdrand64_step, _rdseed64_step}; + +use {crate::bootmodules::BootModule, core::arch::asm, log::warn}; pub mod memory; mod cpuid; @@ -143,18 +142,13 @@ unsafe extern "C" fn start() -> ! { let raw_bytes = core::slice::from_raw_parts( file.base.as_ptr().expect("invalid initrd"), file.length as usize, - ) - .to_vec(); - - let file_path = alloc::string::String::from_utf8( - file.path.to_str().unwrap().to_bytes().to_vec(), ); + + let file_path = file.path.to_str().unwrap().to_str(); if file_path.is_err() { panic!("invalid file path: {:?}", file_path); } - let file_cmd = alloc::string::String::from_utf8( - file.cmdline.to_str().unwrap().to_bytes().to_vec(), - ); + let file_cmd = file.cmdline.to_str().unwrap().to_str(); if file_cmd.is_err() { panic!("invalid module cmd: {:?}", file_cmd); } @@ -195,59 +189,20 @@ unsafe extern "C" fn start() -> ! { /// Spin loop pub fn spin_loop() -> ! { loop { - x86_64::instructions::hlt(); + x86_64::instructions::hlt() } } pub fn hardware_random_u64() -> u64 { - use {log::trace, rdrand::RdRand}; - let gen = RdRand::new(); - match gen { - Ok(gen) => { - let ret = gen.try_next_u64().unwrap(); - trace!("Random {}", ret); - return ret; - } - Err(err) => { + let mut out: u64 = 0; + match unsafe { _rdrand64_step(&mut out) } { + 1 => out, + _ => { warn!("RDRand not supported."); // Try rdseed - let gen = RdSeed::new(); - match gen { - Ok(gen) => { - let ret = gen.try_next_u64().unwrap(); - trace!("Random {}", ret); - return ret; - } - Err(err) => { - panic!("Neither RDRand or RDSeed are supported") - } - } - } - } -} - -pub fn hardware_random_u32() -> u32 { - use {log::trace, rdrand::RdRand}; - let gen = RdRand::new(); - match gen { - Ok(gen) => { - let ret = gen.try_next_u32().unwrap(); - trace!("Random {}", ret); - return ret; - } - Err(err) => { - warn!("RDRand not supported."); - // Try rdseed - let gen = RdSeed::new(); - match gen { - Ok(gen) => { - let ret = gen.try_next_u32().unwrap(); - trace!("Random {}", ret); - return ret; - } - Err(err) => { - panic!("Neither RDRand or RDSeed are supported") - } + match unsafe { _rdseed64_step(&mut out) } { + 1 => out, + _ => panic!("Neither RDRand or RDSeed are supported"), } } } @@ -255,6 +210,7 @@ pub fn hardware_random_u32() -> u32 { pub fn get_edid() {} +#[allow(unused)] pub fn register_dump() { let rax: u64; let rbx: u64 = 0; diff --git a/kernel/src/bootmodules.rs b/kernel/src/bootmodules.rs index 729bd92..81d15b4 100644 --- a/kernel/src/bootmodules.rs +++ b/kernel/src/bootmodules.rs @@ -1,36 +1,36 @@ use { - crate::alloc::string::ToString, - alloc::{string::String, vec::Vec}, - clparse::Arguments, - core::fmt::{Debug, Display}, - log::trace, - xml::XMLElement, + // crate::alloc::string::ToString, + alloc::vec::Vec, + // clparse::Arguments, + // core::fmt::{Debug, Display}, + // log::trace, + // xml::XMLElement, }; -pub type BootModules = Vec; +pub type BootModules<'a> = Vec>; -pub struct BootModule { - pub path: String, - pub bytes: Vec, - pub cmd: String, +pub struct BootModule<'a> { + pub path: &'a str, + pub bytes: &'a [u8], + pub cmd: &'a str, } -impl BootModule { - pub fn new(path: String, bytes: Vec, cmd: String) -> Self { +impl<'a> BootModule<'a> { + pub fn new(path: &'a str, bytes: &'a [u8], cmd: &'a str) -> Self { Self { path, bytes, cmd } } } -pub fn build_cmd(name: T, cmdline: T) -> XMLElement { - let mut cmdline = cmdline.to_string(); - cmdline.pop(); - cmdline.remove(0); +// pub fn build_cmd(name: T, cmdline: T) -> XMLElement { +// let mut cmdline = cmdline.to_string(); +// cmdline.pop(); +// cmdline.remove(0); - let cmd = Arguments::parse(cmdline.to_string()).unwrap(); - trace!("Cmdline: {cmd:?}"); +// let cmd = Arguments::parse(cmdline.to_string()).unwrap(); +// trace!("Cmdline: {cmd:?}"); - let mut clo = XMLElement::new(name); - for (key, value) in cmd.arguments { - clo.set_attribute(key, value); - } - trace!("command line object: {:?}", clo); - clo -} +// let mut clo = XMLElement::new(name); +// for (key, value) in cmd.arguments { +// clo.set_attribute(key, value); +// } +// trace!("command line object: {:?}", clo); +// clo +// } diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index f4f162c..dc4b83c 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -1,19 +1,10 @@ //! Environment call handling routines -use core::borrow::Borrow; - -use crate::{ - allocator, - holeybytes::kernel_services::{ - block_read, - service_definition_service::{sds_msg_handler, SERVICES}, - }, -}; +use crate::holeybytes::kernel_services::{block_read, service_definition_service::sds_msg_handler}; use { - super::{mem::Memory, Vm}, - crate::{arch, holeybytes::mem, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS}, - alloc::string::String, + super::Vm, + crate::{arch, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS}, log::{debug, error, info, trace, warn}, }; @@ -78,7 +69,7 @@ pub fn handler(vm: &mut Vm) { }, 1 => match log_msg_handler(vm, mem_addr, length) { Ok(()) => {} - Err(err) => log::error!("Improper log format"), + Err(_) => log::error!("Improper log format"), }, 2 => { use crate::holeybytes::kernel_services::mem_serve::memory_msg_handler; @@ -87,29 +78,21 @@ pub fn handler(vm: &mut Vm) { Err(_) => {} } } + #[cfg(not(target_arch = "x86_64"))] + 3 => info!("TODO: implement whatever buffer 3 does for no x86_64"), + #[cfg(target_arch = "x86_64")] 3 => { - unsafe fn x86_in(address: u16) -> u8 { - x86_64::instructions::port::Port::new(address).read() - } - unsafe fn x86_in_16(address: u16) -> u16 { - x86_64::instructions::port::Port::new(address).read() - } - unsafe fn x86_in_32(address: u16) -> u32 { - x86_64::instructions::port::Port::new(address).read() - } - unsafe fn x86_out(address: u16, value: u8) { + unsafe fn x86_out( + address: u16, + value: T, + ) { x86_64::instructions::port::Port::new(address).write(value); } - unsafe fn x86_out_16(address: u16, value: u16) { - x86_64::instructions::port::Port::new(address).write(value); + unsafe fn x86_in(address: u16) -> T { + x86_64::instructions::port::Port::new(address).read() } - unsafe fn x86_out_32(address: u16, value: u32) { - x86_64::instructions::port::Port::new(address).write(value); - } - - let mut msg_vec = block_read(mem_addr, length); + let msg_vec = block_read(mem_addr, length); let msg_type = msg_vec[0]; - msg_vec.remove(0); match msg_type { 0 => 'wow: { let size = match msg_vec[0] { @@ -121,24 +104,20 @@ pub fn handler(vm: &mut Vm) { break 'wow; } }; - msg_vec.remove(0); - let addr = u16::from_le_bytes(msg_vec[0..2].try_into().unwrap()); - msg_vec.remove(0); - msg_vec.remove(0); + let addr = u16::from_le_bytes(msg_vec[1..3].try_into().unwrap()); let value = unsafe { match size { - 1 => x86_in(addr) as u64, - 2 => x86_in_16(addr) as u64, - 4 => x86_in_32(addr) as u64, + 1 => x86_in::(addr) as u64, + 2 => x86_in::(addr) as u64, + 4 => x86_in::(addr) as u64, _ => panic!("how?"), } }; - msg_vec.clear(); trace!("Read the value {} from address {}", value, addr); vm.registers[1] = hbvm::value::Value(value); } 1 => 'wow: { - let size = match msg_vec[0] { + let size = match msg_vec[1] { 0 => 1, 1 => 2, 2 => 4, @@ -147,50 +126,88 @@ pub fn handler(vm: &mut Vm) { break 'wow; } }; - msg_vec.remove(0); - let addr = u16::from_le_bytes(msg_vec[0..2].try_into().unwrap()); - msg_vec.remove(0); - msg_vec.remove(0); + let addr = unsafe { + u16::from_le_bytes(msg_vec[1..3].try_into().unwrap_unchecked()) + }; trace!("Setting address {}", addr); unsafe { match size { - 1 => x86_out(addr, msg_vec[0]), - 2 => x86_out_16( + 1 => x86_out(addr, msg_vec[3]), + 2 => x86_out( addr, - u16::from_le_bytes(msg_vec[0..2].try_into().unwrap()), + u16::from_le_bytes( + msg_vec[3..5].try_into().unwrap_unchecked(), + ), ), - 4 => x86_out_32( + 4 => x86_out( addr, - u32::from_le_bytes(msg_vec[0..4].try_into().unwrap()), + u32::from_le_bytes( + msg_vec[3..7].try_into().unwrap_unchecked(), + ), ), _ => panic!("How?"), } } - msg_vec.clear(); } _ => {} } } // source of rng 4 => { - vm.registers[1] = hbvm::value::Value(crate::arch::hardware_random_u32() as u64); + // limit to last 32 bits + vm.registers[1] = + hbvm::value::Value(crate::arch::hardware_random_u64() & 0xFFFFFFFF); + } + // get arch + 5 => { + if cfg!(target_arch = "x86_64") { + vm.registers[1] = hbvm::value::Value(0); + } else if cfg!(target_arch = "aarch64") { + vm.registers[1] = hbvm::value::Value(1); + } else { + vm.registers[1] = hbvm::value::Value(u64::MAX) + } + } + // AbleCodeâ„¢ (get fb ptr) + 6 => { + use { + crate::kmain::FB_REQ, + limine::{Framebuffer, NonNullPtr}, + }; + let fb1: &NonNullPtr = + &FB_REQ.get_response().get().unwrap().framebuffers()[0]; + let msg = block_read(mem_addr, length)[0]; + if msg == b'p' { + // ptr + let fb_front = fb1.address.as_ptr().unwrap() as *const u8; + log::info!("Graphics front ptr {:?}", fb_front); + vm.registers[1] = hbvm::value::Value(fb_front as u64); + } else if msg == b'w' { + // width + log::info!("FB Width: {}", fb1.width); + vm.registers[1] = hbvm::value::Value(fb1.width); + } else if msg == b'h' { + // height + log::info!("FB Height: {}", fb1.height); + vm.registers[1] = hbvm::value::Value(fb1.height); + } } buffer_id => { let mut buffs = IPC_BUFFERS.lock(); match buffs.get_mut(&buffer_id) { Some(buff) => { - let mut msg_vec = vec![]; + 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); } - buff.push(msg_vec.clone()); debug!( "Message {:?} has been sent to Buffer({})", msg_vec, buffer_id ); + buff.push(msg_vec); } None => { log::error!("Access of non-existent buffer {}", buffer_id) @@ -206,7 +223,7 @@ pub fn handler(vm: &mut Vm) { let max_length = vm.registers[5].cast::(); let mut buffs = IPC_BUFFERS.lock(); - let mut buff: &mut IpcBuffer; + let buff: &mut IpcBuffer; if buffs.get_mut(&buffer_id).is_some() { buff = buffs.get_mut(&buffer_id).unwrap(); @@ -255,16 +272,16 @@ pub fn handler(vm: &mut Vm) { } } -fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { +fn log_msg_handler(_vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { // let message_length = 8 + 8 + 8; // log::info!("Mem Addr 0x{:x?} length {}", mem_addr, length); - let mut msg_vec = block_read(mem_addr, length); + let msg_vec = block_read(mem_addr, length); - let log_level = msg_vec.pop().unwrap(); - match String::from_utf8(msg_vec) { + let log_level = msg_vec.last().unwrap(); + match core::str::from_utf8(&msg_vec[1..]) { Ok(strr) => { // use LogLevel::*; - let ll = match log_level { + let _ll = match log_level { 0 | 48 => error!("{}", strr), 1 | 49 => warn!("{}", strr), 2 | 50 => info!("{}", strr), @@ -288,8 +305,8 @@ pub enum LogError { NoMessages, InvalidLogFormat, } -use {alloc::vec, log::Record}; +// use {alloc::vec, log::Record}; // fn memory_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { // let mut val = alloc::vec::Vec::new(); // for _ in 0..4096 { diff --git a/kernel/src/holeybytes/kernel_services/mem_serve.rs b/kernel/src/holeybytes/kernel_services/mem_serve.rs index 16ecbe8..feeba2e 100644 --- a/kernel/src/holeybytes/kernel_services/mem_serve.rs +++ b/kernel/src/holeybytes/kernel_services/mem_serve.rs @@ -1,10 +1,7 @@ use { - crate::holeybytes::{ - ecah::LogError, - kernel_services::{block_read, mem_serve}, - Vm, - }, - alloc::alloc::alloc_zeroed, + crate::holeybytes::{kernel_services::block_read, Vm}, + alloc::alloc::{alloc_zeroed, dealloc}, + core::alloc::Layout, log::{debug, info}, }; @@ -19,13 +16,10 @@ pub enum MemoryQuotaType { KillQuota = 3, } -fn alloc_page(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), MemoryServiceError> { - let mut val = alloc::vec::Vec::new(); - for _ in 0..4096 { - val.push(0); - } - info!("Block address: {:?}", val.as_ptr()); - vm.registers[1] = hbvm::value::Value(val.as_ptr() as u64); +fn alloc_page(vm: &mut Vm, _mem_addr: u64, _length: usize) -> Result<(), MemoryServiceError> { + let ptr = unsafe { alloc_zeroed(Layout::new::<[u8; 4096]>()) }; + info!("Block address: {:?}", ptr); + vm.registers[1] = hbvm::value::Value(ptr as u64); vm.registers[2] = hbvm::value::Value(4096); Ok(()) } @@ -35,34 +29,39 @@ pub fn memory_msg_handler( mem_addr: u64, length: usize, ) -> Result<(), MemoryServiceError> { - let mut msg_vec = block_read(mem_addr, length); + let msg_vec = block_read(mem_addr, length); let msg_type = msg_vec[0]; - - msg_vec.remove(0); match msg_type { 0 => { - let page_count = msg_vec[0]; - msg_vec.remove(0); - - let mptr_raw: [u8; 8] = msg_vec[0..8].try_into().unwrap(); + let page_count = msg_vec[1]; + let mptr_raw: [u8; 8] = msg_vec[2..10].try_into().unwrap(); let mptr: u64 = u64::from_le_bytes(mptr_raw); log::debug!("Allocating {} pages @ {:x}", page_count, mptr); - let mut val = alloc::vec::Vec::new(); - for _ in 0..(page_count as isize * 4096) { - val.push(0); - } - vm.registers[1] = hbvm::value::Value(val.as_ptr() as u64); - log::debug!("Kernel ptr: {:x}", val.as_ptr() as u64); - } - 1 => { - let page_count = msg_vec[0]; - msg_vec.remove(0); + let ptr = unsafe { + alloc_zeroed(Layout::from_size_align_unchecked( + page_count as usize * 4096, + 1, + )) + }; - let mptr_raw: [u8; 8] = msg_vec[0..8].try_into().unwrap(); + vm.registers[1] = hbvm::value::Value(ptr as u64); + log::debug!("Kernel ptr: {:x}", ptr as u64); + } + + 1 => { + let page_count = msg_vec[1]; + + let mptr_raw: [u8; 8] = msg_vec[2..10].try_into().unwrap(); let mptr: u64 = u64::from_le_bytes(mptr_raw); log::debug!("Deallocating {} pages @ {:x}", page_count, mptr); + unsafe { + dealloc( + mptr as *mut u8, + Layout::from_size_align_unchecked(page_count as usize * 4096, 1), + ) + } } 2 => { use MemoryQuotaType::*; @@ -73,19 +72,10 @@ pub fn memory_msg_handler( 3 => KillQuota, _ => NoQuota, }; - msg_vec.remove(0); - let hid_raw: [u8; 8] = msg_vec[0..8].try_into().unwrap(); + let hid_raw: [u8; 8] = msg_vec[2..10].try_into().unwrap(); let hid: u64 = u64::from_le_bytes(hid_raw); - for _ in 0..8 { - msg_vec.remove(0); - } - - let pid_raw: [u8; 8] = msg_vec[0..8].try_into().unwrap(); - let pid: u64 = u64::from_le_bytes(hid_raw); - for _ in 0..8 { - msg_vec.remove(0); - } - + let pid_raw: [u8; 8] = msg_vec[10..18].try_into().unwrap(); + let pid: u64 = u64::from_le_bytes(pid_raw); debug!( "Setting HID-{:x}:PID-{:x}'s quota type to {:?}", hid, pid, quota_type @@ -94,7 +84,6 @@ pub fn memory_msg_handler( 3 => { let page_count = msg_vec[0]; log::debug!(" {} pages", page_count); - msg_vec.remove(0); } _ => { diff --git a/kernel/src/holeybytes/kernel_services/mod.rs b/kernel/src/holeybytes/kernel_services/mod.rs index 23908ef..8c80f49 100644 --- a/kernel/src/holeybytes/kernel_services/mod.rs +++ b/kernel/src/holeybytes/kernel_services/mod.rs @@ -1,15 +1,9 @@ -use alloc::{vec, vec::Vec}; +use core::slice; pub mod mem_serve; pub mod service_definition_service; -pub fn block_read(mem_addr: u64, length: usize) -> Vec { - let mut msg_vec = vec![]; - - 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); - } - msg_vec +#[inline(always)] +pub fn block_read<'a>(mem_addr: u64, length: usize) -> &'a [u8] { + unsafe { slice::from_raw_parts(mem_addr as *const u8, length) } } diff --git a/kernel/src/holeybytes/kernel_services/service_definition_service.rs b/kernel/src/holeybytes/kernel_services/service_definition_service.rs index 547ac33..3382f1b 100644 --- a/kernel/src/holeybytes/kernel_services/service_definition_service.rs +++ b/kernel/src/holeybytes/kernel_services/service_definition_service.rs @@ -1,20 +1,15 @@ use { crate::{ - alloc::string::ToString, arch::hardware_random_u64, holeybytes::{ecah::LogError, kernel_services::block_read, Vm}, - ipc::{ - buffer::IpcBuffer, - protocol::{self, Protocol}, - }, + ipc::{buffer::IpcBuffer, protocol::Protocol}, kmain::IPC_BUFFERS, }, - alloc::string::String, hashbrown::HashMap, log::{info, trace}, spin::{lazy::Lazy, Mutex}, }; -pub struct Services(HashMap); +pub struct Services<'a>(HashMap>); pub static SERVICES: Lazy> = Lazy::new(|| { let mut dt = Services(HashMap::new()); dt.0.insert(0, Protocol::void()); @@ -22,25 +17,26 @@ pub static SERVICES: Lazy> = Lazy::new(|| { }); pub fn sds_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { - let mut msg_vec = block_read(mem_addr, length); + let msg_vec = block_read(mem_addr, length); if msg_vec.is_empty() { return Err(LogError::NoMessages); } let sds_event_type: ServiceEventType = msg_vec[0].into(); - msg_vec.remove(0); // info!("Length {}", msg_vec.len()); use ServiceEventType::*; match sds_event_type { CreateService => { - let string = String::from_utf8(msg_vec).expect("Our bytes should be valid utf8"); + let string = + core::str::from_utf8(&msg_vec[1..]).expect("Our bytes should be valid utf8"); let ret = sds_create_service(string); vm.registers[1] = hbvm::value::Value(ret as u64); } DeleteService => todo!(), SearchServices => { - let string = String::from_utf8(msg_vec).expect("Our bytes should be valid utf8"); + let string = + core::str::from_utf8(&msg_vec[1..]).expect("Our bytes should be valid utf8"); let ret = sds_search_service(string); vm.registers[1] = hbvm::value::Value(ret as u64); } @@ -82,16 +78,16 @@ impl From for ServiceEventType { } } -fn sds_create_service(protocol: String) -> u64 { +fn sds_create_service(protocol: &'static str) -> u64 { let buff_id = hardware_random_u64(); let mut services = SERVICES.lock(); let mut buffers = IPC_BUFFERS.lock(); - let protocol_ = Protocol::from(protocol.clone()); + let protocol_ = Protocol::from(protocol); let mut buff = IpcBuffer::new(false, 0); services.0.insert(buff_id, protocol_.clone()); - buff.protocol = protocol_.clone(); + buff.protocol = protocol_; buffers.insert(buff_id, buff); trace!("BufferID({}) => {}", buff_id, protocol); @@ -99,13 +95,13 @@ fn sds_create_service(protocol: String) -> u64 { buff_id } -fn sds_search_service(protocol: String) -> u64 { - let mut services = SERVICES.lock(); - let compare = Protocol::from(protocol.clone()); +fn sds_search_service(protocol: &str) -> u64 { + let services = SERVICES.lock(); + let compare = Protocol::from(protocol); for (bid, protocol_canidate) in &services.0 { trace!("BID-{bid} protocol_canidate {:?}", protocol_canidate); if protocol_canidate == &compare { - trace!("BufferID({}) => {}", bid, protocol.clone()); + trace!("BufferID({}) => {}", bid, protocol); return *bid; } } diff --git a/kernel/src/holeybytes/mem.rs b/kernel/src/holeybytes/mem.rs index e9024c5..35a423b 100644 --- a/kernel/src/holeybytes/mem.rs +++ b/kernel/src/holeybytes/mem.rs @@ -7,7 +7,7 @@ use hbvm::mem::Address; fn calc_start_of_page(ptr: u64) -> u64 { - let mut page_aligned = false; + let _page_aligned = false; if ptr % 4096 == 0 { // page_aligned = true; return ptr / 4096; @@ -21,11 +21,11 @@ pub struct Memory { impl Memory { #[cfg(target_arch = "x86_64")] - fn read_device(addr: Address) { - unsafe { - // - // x86_64::instructions::port::Port::new(addr.get()).read() - } + fn read_device(_addr: Address) { + //unsafe { + // + // x86_64::instructions::port::Port::new(addr.get()).read() + //} } } @@ -37,7 +37,6 @@ impl hbvm::mem::Memory for Memory { target: *mut u8, count: usize, ) -> Result<(), hbvm::mem::LoadError> { - use log::{error, info}; if addr.get() % 4096 == 0 {} core::ptr::copy(addr.get() as *const u8, target, count); Ok(()) @@ -56,6 +55,6 @@ impl hbvm::mem::Memory for Memory { #[inline] unsafe fn prog_read(&mut self, addr: Address) -> T { - (addr.get() as *const T).read_unaligned() + (addr.get() as *const T).read() } } diff --git a/kernel/src/holeybytes/mod.rs b/kernel/src/holeybytes/mod.rs index 6ae91ca..aecadd3 100644 --- a/kernel/src/holeybytes/mod.rs +++ b/kernel/src/holeybytes/mod.rs @@ -3,86 +3,86 @@ mod kernel_services; mod mem; use { - crate::{arch, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS}, - alloc::boxed::Box, - core::{default, future::Future, marker::PhantomData, ptr::NonNull, task::Poll}, + alloc::alloc::{alloc_zeroed, dealloc}, + core::{ + alloc::Layout, + future::Future, + pin::Pin, + task::{Context, Poll}, + }, hbvm::{ - mem::{ - softpaging::{icache::ICache, HandlePageFault, SoftPagedMem}, - Address, Memory, - }, + mem::{softpaging::HandlePageFault, Address}, VmRunError, VmRunOk, }, - log::{debug, error, info, trace, warn}, + log::error, }; const STACK_SIZE: usize = 1024 * 1024; -const TIMER_QUOTIENT: usize = 100; +const TIMER_QUOTIENT: usize = 1000; type Vm = hbvm::Vm; -pub struct ExecThread<'p> { +pub struct ExecThread { vm: Vm, stack_bottom: *mut u8, - _phantom: PhantomData<&'p [u8]>, } -unsafe impl<'p> Send for ExecThread<'p> {} -impl<'p> ExecThread<'p> { +unsafe impl Send for ExecThread {} + +impl ExecThread { pub fn set_arguments(&mut self, ptr: u64, length: u64) { self.vm.registers[1] = hbvm::value::Value(ptr); self.vm.registers[2] = hbvm::value::Value(length); } - pub unsafe fn new(program: &'p [u8], entrypoint: Address) -> Self { - let mut vm = unsafe { - Vm::new( - mem::Memory {}, - Address::new(program.as_ptr() as u64 + entrypoint.get()), - ) - }; + pub unsafe fn new(program: &[u8], entrypoint: Address) -> Self { + let mut vm = Vm::new( + mem::Memory {}, + Address::new(program.as_ptr() as u64 + entrypoint.get()), + ); + + let stack_bottom = allocate_stack(); - let stack_bottom = unsafe { allocate_stack().as_ptr() }; vm.write_reg(254, (stack_bottom as usize + STACK_SIZE - 1) as u64); - ExecThread { - vm, - stack_bottom, - _phantom: Default::default(), - } + ExecThread { vm, stack_bottom } } } -impl<'p> Drop for ExecThread<'p> { +impl<'p> Drop for ExecThread { fn drop(&mut self) { - unsafe { alloc::alloc::dealloc(self.stack_bottom, stack_layout()) }; + unsafe { dealloc(self.stack_bottom, stack_layout()) }; } } -impl<'p> Future for ExecThread<'p> { +impl<'p> Future for ExecThread { type Output = Result<(), VmRunError>; - fn poll( - mut self: core::pin::Pin<&mut Self>, - cx: &mut core::task::Context<'_>, - ) -> Poll { + #[inline(always)] + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.vm.run() { Err(err) => { - log::error!("HBVM Error\r\nRegister dump: {:?}", self.vm.registers,); - return Poll::Ready(Err(err)); + error!("HBVM Error\r\nRegister dump: {:?}", self.vm.registers); + Poll::Ready(Err(err)) + } + Ok(VmRunOk::End) => Poll::Ready(Ok(())), + Ok(VmRunOk::Ecall) => { + ecah::handler(&mut self.vm); + cx.waker().wake_by_ref(); + Poll::Pending + } + Ok(VmRunOk::Timer) => { + cx.waker().wake_by_ref(); + Poll::Pending } - Ok(VmRunOk::End) => return Poll::Ready(Ok(())), - Ok(VmRunOk::Ecall) => ecah::handler(&mut self.vm), - Ok(VmRunOk::Timer) => (), Ok(VmRunOk::Breakpoint) => { - log::error!( + error!( "HBVM Debug breakpoint\r\nRegister dump: {:?}", - self.vm.registers, + self.vm.registers ); + cx.waker().wake_by_ref(); + Poll::Pending } } - - cx.waker().wake_by_ref(); - Poll::Pending } } @@ -91,33 +91,22 @@ impl HandlePageFault for PageFaultHandler { fn page_fault( &mut self, reason: hbvm::mem::MemoryAccessReason, - pagetable: &mut hbvm::mem::softpaging::paging::PageTable, + _pagetable: &mut hbvm::mem::softpaging::paging::PageTable, vaddr: hbvm::mem::Address, size: hbvm::mem::softpaging::PageSize, dataptr: *mut u8, - ) -> bool - where - Self: Sized, - { - log::error!( - "REASON: {reason} \ - vaddr: {vaddr} \ - size: {size:?} \ - Dataptr {dataptr:p}", - ); - + ) -> bool { + error!("REASON: {reason} vaddr: {vaddr} size: {size:?} Dataptr {dataptr:p}"); false } } -const fn stack_layout() -> core::alloc::Layout { - unsafe { alloc::alloc::Layout::from_size_align_unchecked(STACK_SIZE, 4096) } +#[inline(always)] +const fn stack_layout() -> Layout { + unsafe { Layout::from_size_align_unchecked(STACK_SIZE, 4096) } } -fn allocate_stack() -> NonNull { - let layout = stack_layout(); - match NonNull::new(unsafe { alloc::alloc::alloc_zeroed(layout) }) { - Some(ptr) => ptr, - None => alloc::alloc::handle_alloc_error(layout), - } +#[inline(always)] +fn allocate_stack() -> *mut u8 { + unsafe { alloc_zeroed(stack_layout()) } } diff --git a/kernel/src/ipc/buffer.rs b/kernel/src/ipc/buffer.rs index 71756bb..a7c1920 100644 --- a/kernel/src/ipc/buffer.rs +++ b/kernel/src/ipc/buffer.rs @@ -9,12 +9,12 @@ pub enum BufferTypes { Bound(ArrayQueue), } /// Interproccess buffer -pub struct IpcBuffer { - pub protocol: Protocol, +pub struct IpcBuffer<'a> { + pub protocol: Protocol<'a>, pub buffer: BufferTypes, } -impl IpcBuffer { +impl<'a> IpcBuffer<'a> { pub fn new(bounded: bool, length: u64) -> Self { log::debug!( "New IPCBuffer\r @@ -24,7 +24,7 @@ impl IpcBuffer { length ); match (bounded, length) { - (false, a) => { + (false, ..) => { let buftype = BufferTypes::Unbound(SegQueue::new()); Self { @@ -48,9 +48,9 @@ impl IpcBuffer { } pub fn push(&mut self, msg: Message) { match &self.buffer { - BufferTypes::Unbound(buff) => buff.push(msg.clone()), + BufferTypes::Unbound(buff) => buff.push(msg), BufferTypes::Bound(buff) => { - let _ = buff.push(msg.clone()); + let _ = buff.push(msg); } }; } diff --git a/kernel/src/ipc/protocol.rs b/kernel/src/ipc/protocol.rs index e8cead3..0e8427e 100644 --- a/kernel/src/ipc/protocol.rs +++ b/kernel/src/ipc/protocol.rs @@ -1,7 +1,6 @@ use { alloc::{string::String, vec::Vec}, hashbrown::HashMap, - log::info, }; #[derive(Debug, PartialEq, Clone)] pub struct Type {} @@ -11,11 +10,11 @@ pub struct Funct { gives: Vec, } #[derive(Debug, PartialEq, Clone)] -pub struct Protocol { - types: HashMap, - fns: HashMap, +pub struct Protocol<'a> { + types: HashMap<&'a str, Type>, + fns: HashMap<&'a str, Funct>, } -impl Protocol { +impl<'a> Protocol<'a> { pub fn void() -> Self { Self { types: HashMap::new(), @@ -28,8 +27,8 @@ impl Protocol { } } -impl From for Protocol { - fn from(value: alloc::string::String) -> Self { +impl<'a> From<&'a str> for Protocol<'a> { + fn from(value: &'a str) -> Self { let mut hm_t = HashMap::new(); hm_t.insert(value, Type {}); Self { diff --git a/kernel/src/kmain.rs b/kernel/src/kmain.rs index 0c6790c..dcd2ad8 100644 --- a/kernel/src/kmain.rs +++ b/kernel/src/kmain.rs @@ -2,27 +2,25 @@ use { crate::{ - arch::{hardware_random_u64, logging::SERIAL_CONSOLE}, - bootmodules::{build_cmd, BootModules}, - capabilities, + arch::hardware_random_u64, + bootmodules::BootModules, + //bootmodules::build_cmd, device_tree::DeviceTree, holeybytes::ExecThread, - ipc::buffer::{self, IpcBuffer}, + ipc::buffer::IpcBuffer, }, - alloc::format, hashbrown::HashMap, hbvm::mem::Address, limine::{Framebuffer, FramebufferRequest, NonNullPtr}, - log::{debug, info, trace}, + log::{debug, info}, spin::{Lazy, Mutex}, - xml::XMLElement, }; -pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! { +pub fn kmain(_cmdline: &str, boot_modules: BootModules) -> ! { debug!("Entered kmain"); - let kcmd = build_cmd("Kernel Command Line", cmdline); - trace!("Cmdline: {kcmd:?}"); + // let kcmd = build_cmd("Kernel Command Line", cmdline); + // trace!("Cmdline: {kcmd:?}"); // for (i, bm) in boot_modules.iter().enumerate() { // let name = format!("module-{}", i); @@ -68,17 +66,18 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! { fb1.address.as_ptr().unwrap() as *const u8 ); - let mut executor = crate::task::Executor::default(); + let mut executor = crate::task::Executor::new(256); let bm_take = boot_modules.len(); unsafe { for module in boot_modules.into_iter().take(bm_take) { let mut cmd = module.cmd; if cmd.len() > 2 { - // Remove the quotes - cmd.remove(0); - cmd.pop(); + // // Remove the quotes + // cmd.remove(0); + // cmd.pop(); + cmd = &cmd[1..cmd.len()] } - let cmd_len = cmd.as_bytes().len() as u64; + let cmd_len = cmd.len() as u64; log::info!("Spawning {} with arguments \"{}\"", module.path, cmd); @@ -87,11 +86,10 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! { if cmd_len > 0 { thr.set_arguments(cmd.as_bytes().as_ptr() as u64, cmd_len); } - if let Err(e) = thr.await { log::error!("{e:?}"); } - }); + }) } info!("Random number: {}", hardware_random_u64()); @@ -108,8 +106,7 @@ pub static DEVICE_TREE: Lazy> = Lazy::new(|| { }); pub static FB_REQ: FramebufferRequest = FramebufferRequest::new(0); -use alloc::vec::Vec; -pub type IpcBuffers = HashMap; +pub type IpcBuffers<'a> = HashMap>; pub static IPC_BUFFERS: Lazy> = Lazy::new(|| { let mut bufs = HashMap::new(); let log_buffer = IpcBuffer::new(false, 0); diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 26c3270..194b150 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -1,21 +1,19 @@ //! The ableOS kernel. //! Named akern. //! Akern is woefully undersupported at the moment but we are looking to add support improve hardware discovery and make our lives as kernel and operating system developers easier and better - #![no_std] +#![feature(new_uninit)] #![feature( abi_x86_interrupt, alloc_error_handler, - inline_const, - panic_info_message, - pointer_is_aligned, ptr_sub_ptr, custom_test_frameworks, naked_functions, pointer_is_aligned_to )] -#![allow(dead_code)] #![test_runner(crate::test_runner)] +#![cfg_attr(not(debug_assertions), allow(unused, deprecated))] +#![allow(dead_code)] extern crate alloc; mod allocator; @@ -42,6 +40,7 @@ pub const VERSION: Version = Version { }; #[panic_handler] +#[cfg(target_os = "none")] fn panic(info: &core::panic::PanicInfo) -> ! { arch::register_dump(); @@ -54,10 +53,8 @@ fn panic(info: &core::panic::PanicInfo) -> ! { )); } - if let Some(msg) = info.message() { - let _ = crate::arch::log(format_args!("{msg}\r\n")); - } - + let msg = info.message(); + let _ = crate::arch::log(format_args!("{msg}\r\n")); loop {} } diff --git a/kernel/src/logger.rs b/kernel/src/logger.rs index b403fa9..fd9cc4a 100644 --- a/kernel/src/logger.rs +++ b/kernel/src/logger.rs @@ -1,3 +1,4 @@ +#![allow(deprecated)] // TODO: Add a logger api with logger levels and various outputs pub static TERMINAL_LOGGER: Lazy> = Lazy::new(|| Mutex::new(TermLogger::new())); diff --git a/kernel/src/memory.rs b/kernel/src/memory.rs index 15b5db1..1f0a2fc 100644 --- a/kernel/src/memory.rs +++ b/kernel/src/memory.rs @@ -1,7 +1,6 @@ //! The Memory Manager -use alloc::collections::VecDeque; -use derive_more::*; +use {alloc::collections::VecDeque, derive_more::*}; pub use crate::arch::PAGE_SIZE; pub const MAX_ORDER: usize = 10; @@ -44,7 +43,7 @@ pub const MAX_ORDER: usize = 10; Sum, UpperHex, )] -#[display(fmt = "0x{:x}", _0)] +#[display("0x{:x}", _0)] #[from(forward)] pub struct VirtualAddress(usize); @@ -55,11 +54,11 @@ impl VirtualAddress { pub fn vpns(&self) -> [usize; 3] { [ // [20:12] - (self.0 >> 12) & 0x1ff, + (self.0 >> 12) & 0x1FF, // [29:21] - (self.0 >> 21) & 0x1ff, + (self.0 >> 21) & 0x1FF, // [38:30] - (self.0 >> 30) & 0x1ff, + (self.0 >> 30) & 0x1FF, ] } @@ -114,7 +113,7 @@ impl VirtualAddress { Sum, UpperHex, )] -#[display(fmt = "0x{:x}", _0)] +#[display("0x{:x}", _0)] #[from(forward)] pub struct PhysicalAddress(usize); @@ -125,11 +124,11 @@ impl PhysicalAddress { pub fn ppns(&self) -> [usize; 3] { [ // [20:12] - (self.0 >> 12) & 0x1ff, + (self.0 >> 12) & 0x1FF, // [29:21] - (self.0 >> 21) & 0x1ff, + (self.0 >> 21) & 0x1FF, // [55:30] - (self.0 >> 30) & 0x3ffffff, + (self.0 >> 30) & 0x3FFFFFF, ] } diff --git a/kernel/src/task.rs b/kernel/src/task.rs index 4c603e1..241f64c 100644 --- a/kernel/src/task.rs +++ b/kernel/src/task.rs @@ -1,31 +1,20 @@ -#![allow(unused)] - use { - alloc::{boxed::Box, collections::BTreeMap, sync::Arc, task::Wake}, + alloc::{boxed::Box, sync::Arc}, core::{ future::Future, pin::Pin, - task::{Context, Poll, Waker}, + task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, }, crossbeam_queue::SegQueue, - kiam::when, slab::Slab, - spin::RwLock, }; -static SPAWN_QUEUE: RwLock> = RwLock::new(None); -pub fn spawn(future: impl Future + Send + 'static) { - match &*SPAWN_QUEUE.read() { - Some(s) => s.push(Task::new(future)), - None => panic!("no task executor is running"), - } -} - pub fn yield_now() -> impl Future { struct YieldNow(bool); impl Future for YieldNow { type Output = (); + #[inline(always)] fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if self.0 { Poll::Ready(()) @@ -40,101 +29,150 @@ pub fn yield_now() -> impl Future { YieldNow(false) } -#[derive(Default)] -pub struct Executor { - tasks: Slab, - queue: TaskQueue, - to_spawn: SpawnQueue, - wakers: BTreeMap, +pub struct Executor + Send> { + tasks: Slab>, + task_queue: Arc, } -impl Executor { - pub fn spawn(&mut self, future: impl Future + Send + 'static) { - self.queue - .push(TaskId(self.tasks.insert(Task::new(future)))); +impl + Send> Executor { + pub fn new(size: usize) -> Self { + Self { + tasks: Slab::with_capacity(size), + task_queue: Arc::new(TaskQueue::new()), + } + } + + #[inline] + pub fn spawn(&mut self, future: F) { + self.task_queue + .queue + .push(self.tasks.insert(Task::new(future))); } pub fn run(&mut self) { - { - let mut global_spawner = SPAWN_QUEUE.write(); - if global_spawner.is_some() { - panic!("Task executor is already running"); - } - - *global_spawner = Some(Arc::clone(&self.to_spawn)); - } + let mut task_batch = [0; 32]; + let mut batch_len = 0; loop { - when! { - let Some(id) = self - .to_spawn - .pop() - .map(|t| TaskId(self.tasks.insert(t))) - .or_else(|| self.queue.pop()) - => { - let Some(task) = self.tasks.get_mut(id.0) else { - panic!("Attempted to get task from empty slot: {}", id.0); - }; + self.task_queue.batch_pop(&mut task_batch, &mut batch_len); - let mut cx = Context::from_waker(self.wakers.entry(id).or_insert_with(|| { - Waker::from(Arc::new(TaskWaker { - id, - queue: Arc::clone(&self.queue), - })) - })); + if batch_len == 0 { + if self.task_queue.is_empty() { + break; + } else { + continue; + } + } - match task.poll(&mut cx) { - Poll::Ready(()) => { - self.tasks.remove(id.0); - self.wakers.remove(&id); - } - Poll::Pending => (), + for &id in &task_batch[..batch_len] { + if let Some(task) = self.tasks.get_mut(id) { + let waker = task + .waker + .get_or_insert_with(|| TaskWaker::new(id, Arc::clone(&self.task_queue))); + + let waker = unsafe { Waker::from_raw(TaskWaker::into_raw_waker(waker)) }; + let mut cx = Context::from_waker(&waker); + + if let Poll::Ready(()) = task.poll(&mut cx) { + self.tasks.remove(id); + self.task_queue.free_tasks.push(id); } - }, - self.tasks.is_empty() => break, - _ => (), + } } } - - *SPAWN_QUEUE.write() = None; } } -struct Task { - future: Pin + Send>>, +struct Task + Send> { + future: Pin>, + waker: Option, } -impl Task { - pub fn new(future: impl Future + Send + 'static) -> Self { - log::trace!("New task scheduled"); +impl + Send> Task { + #[inline(always)] + pub fn new(future: F) -> Self { Self { future: Box::pin(future), + waker: None, } } + #[inline(always)] fn poll(&mut self, cx: &mut Context) -> Poll<()> { self.future.as_mut().poll(cx) } } -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] -struct TaskId(usize); - -type TaskQueue = Arc>; -type SpawnQueue = Arc>; - struct TaskWaker { - id: TaskId, - queue: TaskQueue, + id: usize, + task_queue: Arc, } -impl Wake for TaskWaker { - fn wake(self: Arc) { - log::trace!("Woke Task-{:?}", self.id); - self.wake_by_ref(); +impl TaskWaker { + #[inline(always)] + fn new(id: usize, task_queue: Arc) -> Self { + Self { id, task_queue } } - fn wake_by_ref(self: &Arc) { - self.queue.push(self.id); + #[inline(always)] + fn wake(&self) { + self.task_queue.queue.push(self.id); + } + + fn into_raw_waker(waker: &TaskWaker) -> RawWaker { + let ptr = waker as *const TaskWaker; + RawWaker::new(ptr.cast(), &VTABLE) + } +} + +const VTABLE: RawWakerVTable = RawWakerVTable::new(clone_raw, wake_raw, wake_by_ref_raw, drop_raw); + +unsafe fn clone_raw(ptr: *const ()) -> RawWaker { + let waker = &*(ptr as *const TaskWaker); + TaskWaker::into_raw_waker(waker) +} + +unsafe fn wake_raw(ptr: *const ()) { + let waker = &*(ptr as *const TaskWaker); + waker.wake(); +} + +unsafe fn wake_by_ref_raw(ptr: *const ()) { + let waker = &*(ptr as *const TaskWaker); + waker.wake(); +} + +unsafe fn drop_raw(_: *const ()) {} + +struct TaskQueue { + queue: SegQueue, + next_task: usize, + free_tasks: SegQueue, +} + +impl TaskQueue { + fn new() -> Self { + Self { + queue: SegQueue::new(), + next_task: 0, + free_tasks: SegQueue::new(), + } + } + + #[inline(always)] + fn batch_pop(&self, output: &mut [usize], len: &mut usize) { + *len = 0; + while let Some(id) = self.queue.pop() { + output[*len] = id; + *len += 1; + if *len == output.len() { + break; + } + } + } + + #[inline(always)] + fn is_empty(&self) -> bool { + self.queue.is_empty() } } diff --git a/repbuild/Cargo.toml b/repbuild/Cargo.toml index c9c209b..a082573 100644 --- a/repbuild/Cargo.toml +++ b/repbuild/Cargo.toml @@ -4,15 +4,26 @@ version = "0.2.0" edition = "2021" [dependencies] -str-reader = "0.1.2" -derive_more = "0.99" -error-stack = "0.4" +str-reader = "0.1" +derive_more = { version = "1", default-features = false, features = [ + "add", + "add_assign", + "constructor", + "display", + "from", + "into", + "mul", + "mul_assign", + "not", + "sum", +] } +error-stack = "0.5" fatfs = "0.3" -toml = "0.5.2" +toml = "0.8" # hbasm.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git" hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git" [dependencies.reqwest] -version = "0.11" +version = "0.12" default-features = false features = ["rustls-tls", "blocking"] diff --git a/repbuild/src/dev.rs b/repbuild/src/dev.rs index 67768e8..2e81228 100644 --- a/repbuild/src/dev.rs +++ b/repbuild/src/dev.rs @@ -1,3 +1,4 @@ +#![allow(unused)] use std::{ fmt::format, fs::{read_to_string, File}, diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 8eb4835..eede3ed 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -1,3 +1,5 @@ +// #![allow(unused)] + mod dev; use { @@ -6,7 +8,7 @@ use { error_stack::{bail, report, Context, Report, Result, ResultExt}, fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek}, std::{ - fmt::Display, + // fmt::Display, fs::{self, File}, io::{self, Write}, path::Path, @@ -193,7 +195,7 @@ TERM_BACKDROP={} let modules = value.get_mut("modules").unwrap().as_table_mut().unwrap(); // let mut real_modules = modules.clone(); - modules.into_iter().for_each(|(key, value)| { + modules.into_iter().for_each(|(_, value)| { if value.is_table() { let path = get_path_without_boot_prefix( value.get("path").expect("You must have `path` as a value"), @@ -242,7 +244,7 @@ TERM_BACKDROP={} let bootdir = fs.root_dir().create_dir("efi")?.create_dir("boot")?; let mut f = fs.root_dir().create_file("limine.cfg")?; - let a = f.write(limine_str.as_bytes())?; + let _ = f.write(limine_str.as_bytes())?; drop(f); io::copy( @@ -368,7 +370,7 @@ fn run(release: bool, target: Target) -> Result<(), Error> { #[rustfmt::skip] com.args([ "-M", "virt", - "-cpu", "cortex-a72", + "-cpu", "neoverse-n2", "-device", "ramfb", "-device", "qemu-xhci", "-device", "usb-kbd", @@ -427,11 +429,11 @@ fn fetch_ovmf(target: Target) -> Result { #[derive(Debug, Display)] enum OvmfFetchError { - #[display(fmt = "Failed to fetch OVMF package")] + #[display("Failed to fetch OVMF package")] Fetch, - #[display(fmt = "No OVMF package available")] + #[display("No OVMF package available")] Empty, - #[display(fmt = "IO Error")] + #[display("IO Error")] Io, } @@ -444,26 +446,28 @@ enum Target { Aarch64, } +#[allow(unused)] #[derive(Debug, Display)] enum Error { - #[display(fmt = "Failed to build the kernel")] + #[display("Failed to build the kernel")] Build, - #[display(fmt = "Missing or invalid subcommand (available: build, run)")] + #[display("Missing or invalid subcommand (available: build, run)")] InvalidSubCom, - #[display(fmt = "IO Error")] + #[display("IO Error")] Io, - #[display(fmt = "Failed to spawn a process")] + #[display("Failed to spawn a process")] ProcessSpawn, - #[display(fmt = "Failed to fetch UEFI firmware")] + #[display("Failed to fetch UEFI firmware")] OvmfFetch, - #[display(fmt = "Failed to assemble Holey Bytes code")] + #[display("Failed to assemble Holey Bytes code")] Assembler, - #[display(fmt = "QEMU Error: {}", "fmt_qemu_err(*_0)")] + #[display("QEMU Error: {}", "fmt_qemu_err(*_0)")] Qemu(Option), } impl Context for Error {} +#[allow(dead_code)] fn fmt_qemu_err(e: Option) -> impl Display { struct W(Option); impl Display for W { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b9ef17e..9353a54 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2024-05-17" +channel = "nightly-2024-07-27" components = ["rust-src", "llvm-tools"] diff --git a/sysdata/libraries/render/README.md b/sysdata/libraries/render/README.md new file mode 100644 index 0000000..ac765eb --- /dev/null +++ b/sysdata/libraries/render/README.md @@ -0,0 +1,9 @@ +Rendering interface for SVGA and Software renderers + +# TODO: + +- SVGA Driver + - needs pci driver + - needs init (requiring program) +- Double Buffer mode for Software renderer + - needs init (requiring program) \ No newline at end of file diff --git a/sysdata/libraries/render/src/lib.hb b/sysdata/libraries/render/src/lib.hb new file mode 100644 index 0000000..6cf0ccd --- /dev/null +++ b/sysdata/libraries/render/src/lib.hb @@ -0,0 +1,47 @@ +svga := @use("rel:svga.hb") +software := @use("rel:software.hb") + +// default mode +mode := software + +init := mode.init +doublebuffer := mode.doublebuffer + +// Colours +Color := mode.Color +white := mode.white +black := mode.black +gray := mode.gray +red := mode.red +green := mode.green +yellow := mode.yellow +blue := mode.blue +magenta := mode.magenta +cyan := mode.cyan +light_gray := mode.light_gray +light_red := mode.light_red +light_green := mode.light_green +light_yellow := mode.light_yellow +light_blue := mode.light_blue +light_magenta := mode.light_magenta +light_cyan := mode.light_cyan + +// Drawing +put_pixel := mode.put_pixel +put_rect := mode.put_rect +put_filled_rect := mode.put_filled_rect +put_line := mode.put_line +clear := mode.clear + +// Display +width := mode.width +height := mode.height +dimensions := mode.dimensions +set_height := mode.set_height +set_width := mode.set_width +set_dimensions := mode.set_dimensions +sync := mode.sync + +// Math +UVec2 := struct {x: uint, y: uint} +IVec2 := struct {x: int, y: int} \ No newline at end of file diff --git a/sysdata/libraries/render/src/software.hb b/sysdata/libraries/render/src/software.hb new file mode 100644 index 0000000..d584d44 --- /dev/null +++ b/sysdata/libraries/render/src/software.hb @@ -0,0 +1,263 @@ +.{math, memory} := @use("../../stn/src/lib.hb"); +.{IVec2} := @use("rel:lib.hb") + +Color := struct {b: u8, g: u8, r: u8, a: u8} +white := Color.(255, 255, 255, 255) +black := Color.(0, 0, 0, 255) +gray := Color.(127, 127, 127, 255) +red := Color.(0, 0, 205, 255) +green := Color.(0, 205, 0, 255) +yellow := Color.(0, 205, 205, 255) +blue := Color.(205, 0, 0, 255) +magenta := Color.(205, 0, 205, 255) +cyan := Color.(205, 205, 0, 255) +light_gray := Color.(229, 229, 229, 255) +light_red := Color.(0, 0, 255, 255) +light_green := Color.(0, 255, 0, 255) +light_yellow := Color.(0, 255, 255, 255) +light_blue := Color.(255, 0, 0, 255) +light_magenta := Color.(255, 0, 255, 255) +light_cyan := Color.(255, 255, 0, 255) + +// fb_width := 1024 +// fb_height := 768 +// fb_pixels := fb_width * fb_height +// fb_bytes := fb_pixels << 2 +copy_pixels := 0xC000 >> 2 +// partitions := fb_pixels / copy_pixels +// total_pages := 1 + fb_bytes >> 12 + +ctx := @as(Context, idk) + +Context := struct { + fb: ^Color, + bb: ^Color, + buf: ^Color, + width: int, + height: int, + partitions: int, + pixels: int, + bb_pages: int, + double_buffer: bool, +} + +init := fn(): void { + width := @eca(int, 3, 6, "w\0", 2) + height := @eca(int, 3, 6, "h\0", 2) + // width := 1024 + // height := 768 + pixels := width * height + bytes := pixels << 2 + partitions := pixels / copy_pixels + pages := 1 + bytes >> 12 + back_buffer := create_back_buffer(pages) + ctx = Context.{ + fb: @eca(^Color, 3, 6, "p\0", 2), + bb: back_buffer, + buf: back_buffer, + width, + height, + partitions, + pixels, + bb_pages: pages, + double_buffer: true, + } + return +} + +doublebuffer := fn(enable: bool): void { + if enable { + ctx.buf = ctx.bb + } else { + ctx.buf = ctx.fb + } + ctx.double_buffer = enable + return +} + +create_back_buffer := fn(pages: int): ^Color { + if pages <= 0xFF { + return @bitcast(@inline(memory.request_page, pages)) + } + ptr := @inline(memory.request_page, 255) + remaining := pages - 0xFF + loop if remaining <= 0 break else { + if remaining < 0xFF { + memory.request_page(remaining) + } else { + memory.request_page(0xFF) + } + remaining -= 0xFF + } + return @bitcast(ptr) +} + +clear := fn(color: Color): void { + cursor := ctx.buf + boundary := cursor + 512 + loop if cursor == boundary break else { + *cursor = color + cursor += 1 + } + boundary += 512 * 7 + loop if cursor == boundary break else { + *@as(^[Color; 512], @bitcast(cursor)) = *@as(^[Color; 512], @bitcast(ctx.buf)) + cursor += 512 + } + boundary += copy_pixels - 4096 + loop if cursor == boundary break else { + *@as(^[Color; 4096], @bitcast(cursor)) = *@as(^[Color; 4096], @bitcast(ctx.buf)) + cursor += 4096 + } + boundary += (ctx.partitions - 1) * copy_pixels + loop if cursor == boundary break else { + *@as(^[Color; copy_pixels], @bitcast(cursor)) = *@as(^[Color; copy_pixels], @bitcast(ctx.buf)) + cursor += @sizeof([u8; copy_pixels]) + } + return +} + +sync := fn(): void { + if ctx.double_buffer { + bb := ctx.buf + fb := ctx.fb + boundary := bb + ctx.pixels + loop if bb == boundary break else { + *@as(^[Color; copy_pixels], @bitcast(fb)) = *@as(^[Color; copy_pixels], @bitcast(bb)) + bb += copy_pixels + fb += copy_pixels + } + } + return +} + +width := fn(): int { + return ctx.width +} + +height := fn(): int { + return ctx.height +} + +screenidx := fn(x: int, y: int): int { + return x + ctx.width * y +} + +put_pixel := fn(pos: IVec2, color: Color): void { + *(ctx.buf + @inline(screenidx, pos.x, pos.y)) = color + return +} + +put_filled_rect := fn(pos: IVec2, tr: IVec2, color: Color): void { + x := pos.x + y := pos.y + end := pos + tr + loop if x == end.x break else { + loop if y == end.y break else { + *(ctx.buf + @inline(screenidx, x, y)) = color + y += 1 + } + x += 1 + y = pos.y + } + return +} + +put_rect := fn(pos: IVec2, tr: IVec2, color: Color): void { + x := pos.x + y := pos.y + end := pos + tr + loop if y == end.y break else { + *(ctx.buf + @inline(screenidx, x, y)) = color; + *(ctx.buf + @inline(screenidx, x + tr.x, y)) = color + y += 1 + } + y = pos.y + loop if x == end.x break else { + *(ctx.buf + @inline(screenidx, x, y)) = color; + *(ctx.buf + @inline(screenidx, x, y + tr.y)) = color + x += 1 + } + return +} + +put_line_low := fn(p0: IVec2, p1: IVec2, color: Color): void { + dx := p1.x - p0.x + dy := p1.y - p0.y + yi := 1 + if dy < 0 { + yi = 0 - 1 + dy = 0 - dy + } + D := 2 * dy - dx + y := p0.y + x := p0.x + loop if x == p1.x break else { + *(ctx.buf + @inline(screenidx, x, y)) = color + if D > 0 { + y += yi + D += 2 * (dy - dx) + } else { + D += 2 * dy + } + x += 1 + } + return +} + +put_line_high := fn(p0: IVec2, p1: IVec2, color: Color): void { + dx := p1.x - p0.x + dy := p1.y - p0.y + xi := 1 + if dy < 0 { + xi = 0 - 1 + dx = 0 - dx + } + D := 2 * dx - dy + x := p0.x + y := p0.y + loop if y == p1.y break else { + *(ctx.buf + @inline(screenidx, x, y)) = color + if D > 0 { + x += xi + D += 2 * (dx - dy) + } else { + D += 2 * dx + } + y += 1 + } + return +} + +put_line := fn(p0: IVec2, p1: IVec2, color: Color): void { + if @inline(math.abs, p1.y - p0.y) < @inline(math.abs, p1.x - p0.x) { + if p0.x > p1.x { + @inline(put_line_low, p1, p0, color) + } else { + @inline(put_line_low, p0, p1, color) + } + } else { + if p0.y > p1.y { + @inline(put_line_high, p1, p0, color) + } else { + @inline(put_line_high, p0, p1, color) + } + } + return +} + +set_height := fn(new: int): void { + return +} + +set_width := fn(new: int): void { + return +} + +dimensions := fn(): IVec2 { + return .(ctx.width, ctx.height) +} + +set_dimensions := fn(new: IVec2): void { + return +} \ No newline at end of file diff --git a/sysdata/libraries/render/src/svga.hb b/sysdata/libraries/render/src/svga.hb new file mode 100644 index 0000000..8d878c3 --- /dev/null +++ b/sysdata/libraries/render/src/svga.hb @@ -0,0 +1,91 @@ +.{pci, memory, string, log} := @use("../../stn/src/lib.hb"); +.{IVec2} := @use("rel:lib.hb") + +Color := struct {b: u8, g: u8, r: u8, a: u8} +white := Color.(255, 255, 255, 255) +black := Color.(0, 0, 0, 255) +gray := Color.(127, 127, 127, 255) +red := Color.(0, 0, 205, 255) +green := Color.(0, 205, 0, 255) +yellow := Color.(0, 205, 205, 255) +blue := Color.(205, 0, 0, 255) +magenta := Color.(205, 0, 205, 255) +cyan := Color.(205, 205, 0, 255) +light_gray := Color.(229, 229, 229, 255) +light_red := Color.(0, 0, 255, 255) +light_green := Color.(0, 255, 0, 255) +light_yellow := Color.(0, 255, 255, 255) +light_blue := Color.(255, 0, 0, 255) +light_magenta := Color.(255, 0, 255, 255) +light_cyan := Color.(255, 255, 0, 255) + +clear := fn(color: Color): void { + return +} + +width := fn(): int { + return 0 +} + +height := fn(): int { + return 0 +} + +dimensions := fn(): IVec2 { + return .(0, 0) +} + +put_pixel := fn(position: IVec2, color: Color): void { + return +} + +put_filled_rect := fn(pos: IVec2, tr: IVec2, color: Color): void { + return +} + +put_rect := fn(pos: IVec2, tr: IVec2, color: Color): void { + return +} + +put_line_low := fn(p0: IVec2, p1: IVec2, color: Color): void { + return +} +// do not use, use line() instead +put_line_high := fn(p0: IVec2, p1: IVec2, color: Color): void { + return +} + +put_line := fn(p0: IVec2, p1: IVec2, color: Color): void { + return +} + +set_height := fn(new: int): void { + return +} + +set_width := fn(new: int): void { + return +} + +set_dimensions := fn(new: IVec2): void { + return +} + +sync := fn(): void { + return +} + +init := fn(): void { + b := memory.request_page(1) + bus := 0 + device := 0 + loop if bus == 256 break else { + loop if device == 32 break else { + a := pci.config_read(0, 0, 0, 0) + log.info(string.display_int(a, b)) + device += 1 + } + bus += 1 + } + return +} \ No newline at end of file diff --git a/sysdata/libraries/stn/src/lib.hb b/sysdata/libraries/stn/src/lib.hb index fa4414b..be4dac2 100644 --- a/sysdata/libraries/stn/src/lib.hb +++ b/sysdata/libraries/stn/src/lib.hb @@ -3,4 +3,5 @@ log := @use("rel:log.hb") memory := @use("rel:memory.hb") buffer := @use("rel:buffer.hb") math := @use("rel:math.hb") -random := @use("rel:random.hb") \ No newline at end of file +random := @use("rel:random.hb") +pci := @use("rel:pci.hb") \ No newline at end of file diff --git a/sysdata/libraries/stn/src/math.hb b/sysdata/libraries/stn/src/math.hb index 94ee78a..4c4f87e 100644 --- a/sysdata/libraries/stn/src/math.hb +++ b/sysdata/libraries/stn/src/math.hb @@ -1,14 +1,15 @@ -SIZEOF_INT := 31 +shift := 31 +// following only work for: int abs := fn(x: int): int { - mask := x >> SIZEOF_INT + mask := x >> shift return (x ^ mask) - mask } min := fn(a: int, b: int): int { c := a - b - return b + (c & c >> SIZEOF_INT) + return b + (c & c >> shift) } -max := fn(a: int, b: int): int { +max := fn(a: int, b: uint): int { c := a - b - return a - (c & c >> SIZEOF_INT) + return a - (c & c >> shift) } \ No newline at end of file diff --git a/sysdata/libraries/stn/src/memory.hb b/sysdata/libraries/stn/src/memory.hb index 0d25d87..7d4e71f 100644 --- a/sysdata/libraries/stn/src/memory.hb +++ b/sysdata/libraries/stn/src/memory.hb @@ -19,26 +19,26 @@ release_page := fn(ptr: ^u8, page_count: u8): void { outb := fn(addr: u16, value: u8): void { msg := "\0\0\0\0\0"; - *msg = 1; - *(msg + 1) = 0; + *@as(^u8, msg) = @as(u8, 1); + *@as(^u8, msg + 1) = @as(u8, 0); *@as(^u16, @bitcast(msg + 2)) = addr; - *(msg + 4) = value + *@as(^u8, msg + 4) = value @eca(void, 3, 3, msg, 5) return } inb := fn(addr: u16): u8 { msg := "\0\0\0\0"; - *msg = 0; - *(msg + 1) = 0; + *@as(^u8, msg) = @as(u8, 0); + *@as(^u8, msg + 1) = @as(u8, 0); *@as(^u16, @bitcast(msg + 2)) = addr return @eca(u8, 3, 3, msg, 4) } outl := fn(addr: u16, value: u32): void { msg := "\0\0\0\0\0\0\0\0"; - *msg = 1; - *(msg + 1) = 2; + *@as(^u8, msg) = @as(u8, 1); + *@as(^u8, msg + 1) = @as(u8, 2); *@as(^u16, @bitcast(msg + 2)) = addr; *@as(^u32, @bitcast(msg + 4)) = value @eca(void, 3, 3, msg, 8) @@ -47,8 +47,8 @@ outl := fn(addr: u16, value: u32): void { inl := fn(addr: u16): u32 { msg := "\0\0\0\0"; - *msg = 0; - *(msg + 1) = 2; + *@as(^u8, msg) = @as(u8, 0); + *@as(^u8, msg + 1) = @as(u8, 2); *@as(^u16, @bitcast(msg + 2)) = addr return @eca(u32, 3, 3, msg, 4) } \ No newline at end of file diff --git a/sysdata/libraries/stn/src/pci.hb b/sysdata/libraries/stn/src/pci.hb new file mode 100644 index 0000000..c07b518 --- /dev/null +++ b/sysdata/libraries/stn/src/pci.hb @@ -0,0 +1,50 @@ +.{inl, outl} := @use("rel:memory.hb") + +config_read := fn(bus: u8, device: u8, func: u8, offset: u8): u32 { + lbus := @as(u32, bus) + ldevice := @as(u32, device) + lfunc := @as(u32, func) + loffset := @as(u32, offset) + + address := lbus << 16 | ldevice << 11 | lfunc << 8 | loffset & 0xFC | @as(u32, 0x80000000) + + outl(0xCF8, address) + return inl(0xCFC) +} + +config_write := fn(bus: u8, device: u8, func: u8, offset: u8, value: u32): void { + lbus := @as(u32, bus) + ldevice := @as(u32, device) + lfunc := @as(u32, func) + loffset := @as(u32, offset) + + address := lbus << 16 | ldevice << 11 | lfunc << 8 | loffset & 0xFC | @as(u32, 0x80000000) + + outl(0xCF8, address) + outl(0xCFC, value) +} + +get_header_type := fn(bus: u8, device: u8, func: u8): u8 { + return @as(u8, config_read(bus, device, func, 0xC) >> 16 & 0xFF) +} + +Ids := struct {vendor: u16, device: u16} + +get_ids := fn(bus: u8, device: u8, func: u8): Ids { + res := config_read(bus, device, func, 0) + return .(@as(u16, res >> 16 & 0xFFFF), @as(u16, res & 0xFFFF)) +} + +PciDeviceInfo := struct {header_type: u8, device: u8, bus: u8, device_id: Ids, full_class: u16, rev_id: u8} + +check_device := fn(bus: u8, device: u8): PciDeviceInfo { + ids := get_ids(bus, device, 0) + if ids.vendor == 0xFFFF { + return .(0, 0, 0, .(0, 0), 0, 0) + } + reg2 := config_read(bus, device, 0, 0x8) + class := @as(u16, reg2 >> 16 & 0xFFFF) + header_type := get_header_type(bus, device, 0) + + return .(header_type, device, bus, ids, class, @as(u8, reg2 & 0xFF)) +} \ No newline at end of file diff --git a/sysdata/libraries/stn/src/random.hb b/sysdata/libraries/stn/src/random.hb index dbff80a..b515d1c 100644 --- a/sysdata/libraries/stn/src/random.hb +++ b/sysdata/libraries/stn/src/random.hb @@ -1,8 +1,7 @@ -integer := fn(min: int, max: int): int { - rng := @eca(int, 3, 4) +integer := fn(): int { + return @eca(int, 3, 4) +} - if min != 0 | max != 0 { - return rng % (max - min + 1) + min - } - return rng +integer_range := fn(min: int, max: int): int { + return @eca(int, 3, 4) % (max - min + 1) + min } \ No newline at end of file diff --git a/sysdata/programs/diskio_driver/src/main.hb b/sysdata/programs/diskio_driver/src/main.hb index 1800402..e5edf84 100644 --- a/sysdata/programs/diskio_driver/src/main.hb +++ b/sysdata/programs/diskio_driver/src/main.hb @@ -2,7 +2,7 @@ main := fn(): int { // shuts down ableOS - //memory.outb(0xF400, 0) + // memory.outb(0xF400, 0) a := memory.inb(0x4600) b := memory.inb(0x4700) diff --git a/sysdata/programs/fb_driver/README.md b/sysdata/programs/fb_driver/README.md deleted file mode 100644 index b354f04..0000000 --- a/sysdata/programs/fb_driver/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Framebuffer Driver -A simple framebuffer driver. \ No newline at end of file diff --git a/sysdata/programs/fb_driver/UNTESTED_FUNCTIONS b/sysdata/programs/fb_driver/UNTESTED_FUNCTIONS deleted file mode 100644 index 7c7d0f5..0000000 --- a/sysdata/programs/fb_driver/UNTESTED_FUNCTIONS +++ /dev/null @@ -1,7 +0,0 @@ -color.blend - -lib.composite -lib.screen2rect -lib.rect2screen - -draw.tri_line \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/color.hb b/sysdata/programs/fb_driver/src/color.hb deleted file mode 100644 index 802c127..0000000 --- a/sysdata/programs/fb_driver/src/color.hb +++ /dev/null @@ -1,27 +0,0 @@ -ColorBGRA := struct {b: u8, g: u8, r: u8, a: u8} - -/* ALL the colo(u)rs you will ever need. - they dont work though, cause hblang bug (reg id leaked, again) */ -WHITE := ColorBGRA.{b: 255, g: 255, r: 255, a: 255} -BLACK := ColorBGRA.{b: 0, g: 0, r: 0, a: 255} -GRAY := ColorBGRA.{b: 127, g: 127, r: 127, a: 255} -RED := ColorBGRA.{b: 0, g: 0, r: 205, a: 255} -GREEN := ColorBGRA.{b: 0, g: 205, r: 0, a: 255} -YELLOW := ColorBGRA.{b: 0, g: 205, r: 205, a: 255} -BLUE := ColorBGRA.{b: 205, g: 0, r: 0, a: 255} -MAGENTA := ColorBGRA.{b: 205, g: 0, r: 205, a: 255} -CYAN := ColorBGRA.{b: 205, g: 205, r: 0, a: 255} -LIGHTGRAY := ColorBGRA.{b: 229, g: 229, r: 229, a: 255} -LIGHTRED := ColorBGRA.{b: 0, g: 0, r: 255, a: 255} -LIGHTGREEN := ColorBGRA.{b: 0, g: 255, r: 0, a: 255} -LIGHTYELLOW := ColorBGRA.{b: 0, g: 255, r: 255, a: 255} -LIGHTBLUE := ColorBGRA.{b: 255, g: 0, r: 0, a: 255} -LIGHTMAGENTA := ColorBGRA.{b: 255, g: 0, r: 255, a: 255} -LIGHTCYAN := ColorBGRA.{b: 255, g: 255, r: 0, a: 255} - -// i have no clue if this works. please don't me ask how it works. -koniifer -blend := fn(fg: ColorBGRA, bg: ColorBGRA): ColorBGRA { - s := fg + bg - m := s - ((fg ^ bg) & 0x1010100) & 0x1010100 - return (m >> 8 | 0x1000000 * (s < fg)) * 0xFF | s - m -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/draw.hb b/sysdata/programs/fb_driver/src/draw.hb deleted file mode 100644 index 089dc38..0000000 --- a/sysdata/programs/fb_driver/src/draw.hb +++ /dev/null @@ -1,113 +0,0 @@ -.{draw_pixel, screenidx, Transform, Point, Rect, Buffer, FB_WIDTH} := @use("rel:lib.hb"); -.{math} := @use("../../../libraries/stn/src/lib.hb"); -.{ColorBGRA} := @use("rel:color.hb") - -/* draws a filled rectangle to the screen - will be optimised later */ -rect_fill := fn(buffer: Buffer, pos: Point, tr: Transform, color: ColorBGRA): void { - n := 0 - loop if n == tr.height * tr.width break else { - *(buffer.write + @inline(screenidx, .(n % tr.width + pos.x, n / tr.width + pos.y))) = color - n += 1 - } - return -} -/* draws a wireframe rectangle to the screen - will also be optimised later */ -rect_line := fn(buffer: Buffer, pos: Point, tr: Transform, color: ColorBGRA, thickness: int): void { - t := 0 - y := 0 - x := 0 - loop if t == thickness break else { - y = pos.y - x = pos.x - loop if y == pos.y + tr.height break else { - *(buffer.write + @inline(screenidx, .(pos.x + t, y))) = color; - *(buffer.write + @inline(screenidx, .(pos.x + tr.width - t, y))) = color - y += 1 - } - loop if x == pos.x + tr.width break else { - *(buffer.write + @inline(screenidx, .(x, pos.y + t))) = color; - *(buffer.write + @inline(screenidx, .(x, pos.y + tr.height - t))) = color - x += 1 - } - t += 1 - } - return -} - -// do not use, use line() instead -line_low := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA): void { - dx := p1.x - p0.x - dy := p1.y - p0.y - yi := 1 - if dy < 0 { - yi = 0 - 1 - dy = 0 - dy - } - D := 2 * dy - dx - y := p0.y - x := p0.x - loop if x == p1.x break else { - *(buffer.write + @inline(screenidx, .(x, y))) = color - if D > 0 { - y += yi - D += 2 * (dy - dx) - } else { - D += 2 * dy - } - x += 1 - } - return -} -// do not use, use line() instead -line_high := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA): void { - dx := p1.x - p0.x - dy := p1.y - p0.y - xi := 1 - if dy < 0 { - xi = 0 - 1 - dx = 0 - dx - } - D := 2 * dx - dy - x := p0.x - y := p0.y - loop if y == p1.y break else { - *(buffer.write + @inline(screenidx, .(x, y))) = color - if D > 0 { - x += xi - D += 2 * (dx - dy) - } else { - D += 2 * dx - } - y += 1 - } - return -} - -/* implementation of Bresenham's line algorithm - TODO: thickness, might need better math library */ -line := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA, thickness: int): void { - if @inline(math.abs, p1.y - p0.y) < @inline(math.abs, p1.x - p0.x) { - if p0.x > p1.x { - @inline(line_low, buffer, p1, p0, color) - } else { - @inline(line_low, buffer, p0, p1, color) - } - } else { - if p0.y > p1.y { - @inline(line_high, buffer, p1, p0, color) - } else { - @inline(line_high, buffer, p0, p1, color) - } - } - return -} - -// theoretically draws a wireframe polygon to the screen. untested. -tri_line := fn(buffer: Buffer, p0: Point, p1: Point, p2: Point, color: ColorBGRA, thickness: int): void { - line(buffer, p0, p1, color, thickness) - line(buffer, p1, p2, color, thickness) - line(buffer, p2, p0, color, thickness) - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/amogus.hb b/sysdata/programs/fb_driver/src/examples/amogus.hb deleted file mode 100644 index b045f47..0000000 --- a/sysdata/programs/fb_driver/src/examples/amogus.hb +++ /dev/null @@ -1,26 +0,0 @@ -.{rect_line} := @use("../draw.hb"); -.{present, create_buffer, clear} := @use("../lib.hb") - -/* expected result: - the impostor travels left and loops around the screen */ - -example := fn(): void { - // Creates a back buffer, which we write to, to avoid screen flickering - buffer := create_buffer() - x := 0 - loop { - // draw all our shapes to the back buffer - rect_line(buffer, .(200 - x, 80), .(430, 380), .(0, 0, 255, 0), 1) - rect_line(buffer, .(630 - x, 120), .(120, 300), .(0, 0, 255, 0), 1) - rect_line(buffer, .(200 - x, 460), .(160, 270), .(0, 0, 255, 0), 1) - rect_line(buffer, .(470 - x, 460), .(160, 270), .(0, 0, 255, 0), 1) - rect_line(buffer, .(140 - x, 140), .(340, 250), .(255, 255, 0, 0), 1) - /* push the back buffer to the front buffer - this displays our image to the screen */ - present(buffer) - // erase our old image - clear(buffer, .(0, 0, 0, 0)) - x += 1 - } - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/buffers.hb b/sysdata/programs/fb_driver/src/examples/buffers.hb deleted file mode 100644 index 4157408..0000000 --- a/sysdata/programs/fb_driver/src/examples/buffers.hb +++ /dev/null @@ -1,19 +0,0 @@ -.{front_buffer_ptr, front_buffer_copy, get_front_buffer, Buffer} := @use("../lib.hb"); - -example := fn(): void { - // you can get the raw frontbuffer pointer using - raw_buffer := front_buffer_ptr - // this buffer is the one that you write individual pixels to - - // you can gete the copy frontbuffer pointer using - copy_buffer := front_buffer_copy - /* this buffer is used for massive writing - operations by taking advantage of - static copying */ - - // you can construct a buffer like so - buffer := Buffer.{write: raw_buffer, copy: copy_buffer} - // this is the operation that get_front_buffer does - same_buffer := get_front_buffer() - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/colors.hb b/sysdata/programs/fb_driver/src/examples/colors.hb deleted file mode 100644 index 1d29d04..0000000 --- a/sysdata/programs/fb_driver/src/examples/colors.hb +++ /dev/null @@ -1,27 +0,0 @@ -.{clear, create_buffer, present} := @use("../lib.hb"); -.{ColorBGRA} := @use("../color.hb") - -/* expected result: - the screen fades from green to cyan - then wraps back to green - note that this may happen too fast for you to notice... */ - -example := fn(): void { - // creates a back buffer, which we write to, to avoid screen flickering - buffer := create_buffer() - color := ColorBGRA.(0, 255, 0, 255) - /* have to explicitly say 0 is a u8, or we do something crazy to the colors. - looks like a compiler bug */ - n := @as(u8, 0) - 1 - loop { - clear(buffer, color) - present(buffer) - /* because for some reason just comparing doesnt work. - also looks like a compiler bug */ - if (color.b & 255) == 255 | (color.b & 255) == 0 { - n = 0 - n - } - color.b += n - } - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/lines.hb b/sysdata/programs/fb_driver/src/examples/lines.hb deleted file mode 100644 index 11adde7..0000000 --- a/sysdata/programs/fb_driver/src/examples/lines.hb +++ /dev/null @@ -1,25 +0,0 @@ -.{line} := @use("../draw.hb"); -.{clear, create_buffer, present, FB_WIDTH, FB_HEIGHT, Point} := @use("../lib.hb") - -/* expected result: - a 3d-looking blue set of lines - created on a blue background */ - -example := fn(): void { - // creates a back buffer, which we write to, to avoid screen flickering - buffer := create_buffer() - // fill the screen in blue - clear(buffer, .(100, 50, 0, 255)) - p0 := Point.(0, 0 - 1) - p1 := Point.(0, FB_HEIGHT - 1) - loop if p0.y >= FB_HEIGHT break else { - // draw a line between p0 and p1 - line(buffer, p0, p1, .(255, 180, 100, 255), 3) - p0.y += FB_HEIGHT >> 6 - p1.x += FB_WIDTH >> 6 - } - /* push the back buffer to the front buffer - this displays our image to the screen */ - present(buffer) - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/random.hb b/sysdata/programs/fb_driver/src/examples/random.hb deleted file mode 100644 index 75ecb81..0000000 --- a/sysdata/programs/fb_driver/src/examples/random.hb +++ /dev/null @@ -1,17 +0,0 @@ -.{clear, get_front_buffer, screenidx} := @use("../lib.hb"); -.{ColorBGRA} := @use("../color.hb"); -.{random} := @use("../../../../libraries/stn/src/lib.hb") - -example := fn(): void { - buffer := get_front_buffer() - clear(buffer) - loop { - x := random.integer(0, 1024) - y := random.integer(0, 768) - r := random.integer(0, 255) - g := random.integer(0, 75) - b := random.integer(0, 155); - *(buffer.write + @inline(screenidx, .(x, y))) = ColorBGRA.(b, g, r, 255) - } - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/square.hb b/sysdata/programs/fb_driver/src/examples/square.hb deleted file mode 100644 index 84b3994..0000000 --- a/sysdata/programs/fb_driver/src/examples/square.hb +++ /dev/null @@ -1,32 +0,0 @@ -.{rect_line} := @use("../draw.hb"); -.{clear, create_buffer, present, Point, FB_HEIGHT, FB_WIDTH} := @use("../lib.hb") - -/* expected result: - the white outline of a square bounces around the screen */ - -example := fn(): void { - // creates a back buffer, which we write to, to avoid screen flickering - buffer := create_buffer() - vel := Point.{x: 1, y: 1} - pos := Point.{x: 100, y: 100} - loop { - // draw the square at our current position - rect_line(buffer, pos, .(100, 100), .(255, 255, 255, 255), 3) - /* push the back buffer to the front buffer - this displays our image to the screen */ - present(buffer) - // erase our old image - clear(buffer, .(0, 0, 0, 0)) - - // bounce the square if it touches the screen edges - if pos.x == 0 | pos.x == FB_WIDTH - 100 { - vel.x = 0 - vel.x - } - if pos.y == 0 | pos.y == FB_HEIGHT - 100 { - vel.y = 0 - vel.y - } - - pos += vel - } - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/examples/strobe.hb b/sysdata/programs/fb_driver/src/examples/strobe.hb deleted file mode 100644 index e46653c..0000000 --- a/sysdata/programs/fb_driver/src/examples/strobe.hb +++ /dev/null @@ -1,20 +0,0 @@ -.{clear, create_buffer, present} := @use("../lib.hb") - -/* expected result: (EPILEPSY WARNING) - the screen rapidly flashes red then black */ - -example := fn(): void { - // creates a back buffer, which we write to, to avoid screen flickering - buffer := create_buffer() - loop { - // screen go red - clear(buffer, .(0, 0, 255, 0)) - // show the red - present(buffer) - // screen go black - clear(buffer, .(0, 255, 255, 0)) - // show the black - present(buffer) - } - return -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/lib.hb b/sysdata/programs/fb_driver/src/lib.hb deleted file mode 100644 index ca91a63..0000000 --- a/sysdata/programs/fb_driver/src/lib.hb +++ /dev/null @@ -1,88 +0,0 @@ -.{memory, math} := @use("../../../libraries/stn/src/lib.hb"); -.{ColorBGRA, blend} := @use("rel:color.hb") - -FB_WIDTH := 1024 -FB_HEIGHT := 768 -FB_PIXELS := FB_WIDTH * FB_HEIGHT -FB_BYTES := FB_PIXELS << 2 -// actual enforced max copy size is 0xFFFF, but this was faster -MAX_COPY_SIZE := 0x1800 -COPY_PIXELS := math.min(MAX_COPY_SIZE, FB_BYTES) >> 2 -PARTITIONS := FB_PIXELS / COPY_PIXELS -TOTAL_PAGES := 1 + FB_BYTES >> 12 - -Buffer := struct {write: ^ColorBGRA, copy: ^[ColorBGRA; COPY_PIXELS]} -Point := struct {x: int, y: int} -Transform := struct {width: int, height: int} - -front_buffer_ptr := @as(^ColorBGRA, @bitcast(0xFFFF8000C0000000)) -front_buffer_copy := @as(^[ColorBGRA; COPY_PIXELS], @bitcast(front_buffer_ptr)) - -get_front_buffer := fn(): Buffer { - // trying to return front_buffer_ptr or front_buffer_copy causes reg id leak - buffer := Buffer.{write: front_buffer_ptr, copy: front_buffer_copy} - return buffer -} -/* this is separate to create_raw_buffer because returning a Buffer from - create_raw_buffer causes reg id leak */ -create_buffer := fn(): Buffer { - ptr := @inline(create_raw_buffer) - buffer := Buffer.{write: ptr, copy: @as(^[ColorBGRA; COPY_PIXELS], @bitcast(ptr))} - return buffer -} -create_raw_buffer := fn(): ^ColorBGRA { - if TOTAL_PAGES <= 0xFF { - return @bitcast(@inline(memory.request_page, TOTAL_PAGES)) - } - ptr := @inline(memory.request_page, 255) - remaining := TOTAL_PAGES - 0xFF - loop if remaining <= 0 break else { - if remaining < 0xFF { - memory.request_page(remaining) - } else { - memory.request_page(0xFF) - } - remaining -= 0xFF - } - return @bitcast(ptr) -} -// sets the buffer to the color. very fast. -clear := fn(buffer: Buffer, color: ColorBGRA): void { - n := 0 - // write the first pixel chunk - loop if n >= COPY_PIXELS break else { - *(buffer.write + n) = color - n += 1 - } - n = 1 - // copy that pixel chunk through the buffer, taking advantage of memory copying - loop if n >= PARTITIONS break else { - *(buffer.copy + n) = *buffer.copy - n += 1 - } - return -} -// only required to be called when using a back buffer. if using single-buffered rendering, do not call this. -present := fn(buffer: Buffer): void { - n := 0 - // copy chunks of the read buffer to the front buffer - loop if n >= PARTITIONS break else { - *(front_buffer_copy + n) = *(buffer.copy + n) - n += 1 - } - return -} -// composites the contents of buffer1 into buffer2, accounting for alpha transparency -// i dont know if it works. i have not tested it. it probably doesnt work -composite := fn(buffer1: Buffer, buffer2: Buffer): void { - n := 0 - loop if n == FB_PIXELS break else { - bg := *(buffer2.write + n); - *(buffer2.write + n) = blend(*(buffer1.write + n), bg) - n += 1 - } - return -} -screenidx := fn(pos: Point): int { - return pos.x + FB_WIDTH * pos.y -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/src/main.hb b/sysdata/programs/fb_driver/src/main.hb deleted file mode 100644 index e1c71c2..0000000 --- a/sysdata/programs/fb_driver/src/main.hb +++ /dev/null @@ -1,6 +0,0 @@ -.{example} := @use("./examples/lines.hb") - -main := fn(): int { - @inline(example) - return 0 -} \ No newline at end of file diff --git a/sysdata/programs/fb_driver/meta.toml b/sysdata/programs/render_example/meta.toml similarity index 71% rename from sysdata/programs/fb_driver/meta.toml rename to sysdata/programs/render_example/meta.toml index c2659bc..4712b53 100644 --- a/sysdata/programs/fb_driver/meta.toml +++ b/sysdata/programs/render_example/meta.toml @@ -1,6 +1,6 @@ [package] -name = "fb_driver" -authors = ["able", "aurlex"] +name = "render_example" +authors = ["koniifer"] [dependants.libraries] diff --git a/sysdata/programs/render_example/src/examples/amogus.hb b/sysdata/programs/render_example/src/examples/amogus.hb new file mode 100644 index 0000000..eca4e48 --- /dev/null +++ b/sysdata/programs/render_example/src/examples/amogus.hb @@ -0,0 +1,20 @@ +render := @use("../../../../libraries/render/src/lib.hb") + +/* expected result: + the impostor travels left and loops around the screen */ + +example := fn(): void { + render.init() + x := 0 + loop { + render.put_rect(.(200 - x, 80), .(430, 380), render.red) + render.put_rect(.(630 - x, 120), .(120, 300), render.red) + render.put_rect(.(200 - x, 460), .(160, 270), render.red) + render.put_rect(.(470 - x, 460), .(160, 270), render.red) + render.put_rect(.(140 - x, 140), .(340, 250), render.cyan) + render.sync() + render.clear(render.black) + x += 1 + } + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/colors.hb b/sysdata/programs/render_example/src/examples/colors.hb new file mode 100644 index 0000000..5451d3d --- /dev/null +++ b/sysdata/programs/render_example/src/examples/colors.hb @@ -0,0 +1,21 @@ +render := @use("../../../../libraries/render/src/lib.hb") + +/* expected result: + the screen fades from cyan to green + then wraps back to cyan + note that this may happen too fast for you to notice... */ + +example := fn(): void { + render.init() + color := render.light_cyan + n := @as(u8, 1) + loop { + render.clear(color) + render.sync() + if (color.b & 255) == 255 | (color.b & 255) == 0 { + n = 0 - n + } + color.b += n + } + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/lines.hb b/sysdata/programs/render_example/src/examples/lines.hb new file mode 100644 index 0000000..5a41609 --- /dev/null +++ b/sysdata/programs/render_example/src/examples/lines.hb @@ -0,0 +1,22 @@ +render := @use("../../../../libraries/render/src/lib.hb") + +/* expected result: + a 3d-looking set of blue lines + created on a blue background */ + +example := fn(): void { + render.init() + render.clear(.(100, 50, 0, 255)) + width := render.width() + height := render.height() + p0 := render.IVec2.(0, 0) + p1 := render.IVec2.(0, height) + loop if p0.y >= height break else { + render.put_line(p0, p1, .(255, 180, 100, 255)) + render.put_line(.(width, height) - p0, .(width, height) - p1, .(255, 180, 100, 255)) + p0.y += height >> 6 + p1.x += width >> 6 + } + render.sync() + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/random.hb b/sysdata/programs/render_example/src/examples/random.hb new file mode 100644 index 0000000..7b0fbbb --- /dev/null +++ b/sysdata/programs/render_example/src/examples/random.hb @@ -0,0 +1,17 @@ +.{random} := @use("../../../../libraries/stn/src/lib.hb") +render := @use("../../../../libraries/render/src/lib.hb") + +example := fn(): void { + render.init() + render.doublebuffer(false) + render.clear(render.black) + loop { + x := random.integer_range(0, 1024) + y := random.integer_range(0, 768) + r := random.integer_range(0, 255) + g := random.integer_range(0, 75) + b := random.integer_range(0, 155) + render.put_pixel(.(x, y), .(b, g, r, 255)) + } + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/square.hb b/sysdata/programs/render_example/src/examples/square.hb new file mode 100644 index 0000000..def4fea --- /dev/null +++ b/sysdata/programs/render_example/src/examples/square.hb @@ -0,0 +1,27 @@ +render := @use("../../../../libraries/render/src/lib.hb") + +/* expected result: + the white outline of a square bounces around the screen */ + +example := fn(): void { + render.init() + vel := render.IVec2.(1, 1) + pos := render.IVec2.(100, 100) + width := render.width() + height := render.height() + loop { + render.put_rect(pos, .(100, 100), render.white) + render.sync() + render.clear(render.black) + + if pos.x == 0 | pos.x == width - 100 { + vel.x = 0 - vel.x + } + if pos.y == 0 | pos.y == height - 100 { + vel.y = 0 - vel.y + } + + pos += vel + } + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/strobe.hb b/sysdata/programs/render_example/src/examples/strobe.hb new file mode 100644 index 0000000..4681cc5 --- /dev/null +++ b/sysdata/programs/render_example/src/examples/strobe.hb @@ -0,0 +1,15 @@ +render := @use("../../../../libraries/render/src/lib.hb") + +/* expected result: (EPILEPSY WARNING) + the screen rapidly flashes red then black */ + +example := fn(): void { + render.init() + loop { + render.clear(render.red) + render.sync() + render.clear(render.yellow) + render.sync() + } + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/svga.hb b/sysdata/programs/render_example/src/examples/svga.hb new file mode 100644 index 0000000..101aa6f --- /dev/null +++ b/sysdata/programs/render_example/src/examples/svga.hb @@ -0,0 +1,8 @@ +render := @use("../../../../libraries/render/src/lib.hb") + +render.mode = render.svga + +example := fn(): void { + render.init() + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/main.hb b/sysdata/programs/render_example/src/main.hb new file mode 100644 index 0000000..35b2706 --- /dev/null +++ b/sysdata/programs/render_example/src/main.hb @@ -0,0 +1,6 @@ +.{example} := @use("./examples/amogus.hb") + +main := fn(): void { + @inline(example) + return +} \ No newline at end of file diff --git a/sysdata/programs/a_serial_driver/README.md b/sysdata/programs/serial_driver/README.md similarity index 100% rename from sysdata/programs/a_serial_driver/README.md rename to sysdata/programs/serial_driver/README.md diff --git a/sysdata/programs/a_serial_driver/meta.toml b/sysdata/programs/serial_driver/meta.toml similarity index 84% rename from sysdata/programs/a_serial_driver/meta.toml rename to sysdata/programs/serial_driver/meta.toml index 812e297..33de705 100644 --- a/sysdata/programs/a_serial_driver/meta.toml +++ b/sysdata/programs/serial_driver/meta.toml @@ -1,5 +1,5 @@ [package] -name = "a_serial_driver" +name = "serial_driver" authors = ["Able"] [dependants.libraries] diff --git a/sysdata/programs/a_serial_driver/src/main.hb b/sysdata/programs/serial_driver/src/main.hb similarity index 90% rename from sysdata/programs/a_serial_driver/src/main.hb rename to sysdata/programs/serial_driver/src/main.hb index c98054f..4cb3f11 100644 --- a/sysdata/programs/a_serial_driver/src/main.hb +++ b/sysdata/programs/serial_driver/src/main.hb @@ -1,5 +1,4 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); -.{log, string, memory, buffer} := stn +.{memory, buffer} := @use("../../../libraries/stn/src/lib.hb") serial_print := fn(ptr: ^u8): void { letter := 0 diff --git a/sysdata/programs/serial_driver_test/src/main.hb b/sysdata/programs/serial_driver_test/src/main.hb index a9af0fa..6893bc2 100644 --- a/sysdata/programs/serial_driver_test/src/main.hb +++ b/sysdata/programs/serial_driver_test/src/main.hb @@ -1,4 +1,4 @@ -.{string, memory, buffer} := @use("../../../libraries/stn/src/lib.hb") +.{string, buffer} := @use("../../../libraries/stn/src/lib.hb") log_info := fn(): void { a := buffer.search("XNumber\0") diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index ee0625c..98caf84 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -17,17 +17,17 @@ resolution = "1024x768x24" [boot.limine.ableos.modules] -# [boot.limine.ableos.modules.tests] -# path = "boot:///tests.hbf" +[boot.limine.ableos.modules.tests] +path = "boot:///tests.hbf" -[boot.limine.ableos.modules.a_serial_driver] -path = "boot:///a_serial_driver.hbf" +[boot.limine.ableos.modules.0serial_driver] +path = "boot:///serial_driver.hbf" [boot.limine.ableos.modules.diskio_driver] path = "boot:///diskio_driver.hbf" -[boot.limine.ableos.modules.fb_driver] -path = "boot:///fb_driver.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"