From 8e8289f5ba73bc5840a291b0d7249ff20f42bade Mon Sep 17 00:00:00 2001 From: able Date: Sat, 8 Jul 2023 23:22:44 -0500 Subject: [PATCH] BOOT: Work on boot modules --- Cargo.lock | 414 ++++++++++++---------------------- kernel/src/arch/x86_64/mod.rs | 59 ++++- kernel/src/bootmodules.rs | 36 +++ kernel/src/host.rs | 20 +- kernel/src/kmain.rs | 134 ++++++----- kernel/src/lib.rs | 1 + repbuild/limine.cfg | 11 +- 7 files changed, 309 insertions(+), 366 deletions(-) create mode 100644 kernel/src/bootmodules.rs diff --git a/Cargo.lock b/Cargo.lock index 96497fe..3436bb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ version = 3 [[package]] name = "able_graphics_library" version = "0.1.2" -source = "git+https://git.ablecorp.us/ableos/ableos_userland#f433484f2f56a4e8f77b1f39680b88c3d1e27830" +source = "git+https://git.ablecorp.us/ableos/ableos_userland#a45a19c6b7355ebdac53259d06a1894a096143e6" dependencies = [ "embedded-graphics", "log", @@ -36,9 +36,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] @@ -49,6 +49,12 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56fc6cf8dc8c4158eed8649f9b8b0ea1518eb62b544fe9490d66fa0b349eafe9" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -60,9 +66,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "atty" @@ -112,10 +118,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bumpalo" -version = "3.12.0" +name = "bitflags" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + +[[package]] +name = "bumpalo" +version = "3.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "byteorder" @@ -137,13 +149,13 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.24" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", "time", "wasm-bindgen", @@ -153,23 +165,13 @@ dependencies = [ [[package]] name = "clparse" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/ableos_userland#f433484f2f56a4e8f77b1f39680b88c3d1e27830" +source = "git+https://git.ablecorp.us/ableos/ableos_userland#a45a19c6b7355ebdac53259d06a1894a096143e6" dependencies = [ - "hashbrown 0.12.3", + "hashbrown 0.14.0", "log", "toml", ] -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "convert_case" version = "0.4.0" @@ -194,57 +196,13 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", ] -[[package]] -name = "cxx" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 2.0.13", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.13", -] - [[package]] name = "delegate" version = "0.9.0" @@ -307,13 +265,13 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -352,7 +310,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05669f8e7e2d7badc545c513710f0eba09c2fbef683eb859fd79c46c355048e0" dependencies = [ - "bitflags", + "bitflags 1.3.2", "byteorder", "chrono", "log", @@ -375,9 +333,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -415,7 +373,7 @@ dependencies = [ [[package]] name = "hbasm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#b7c34775e4514c05bf0927bd2bd2f6de90715f0d" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#b6ea49a1b5e45a3f64737ddd40707731e71ac1d2" dependencies = [ "hashbrown 0.14.0", "hbbytecode", @@ -427,12 +385,12 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#b7c34775e4514c05bf0927bd2bd2f6de90715f0d" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#b6ea49a1b5e45a3f64737ddd40707731e71ac1d2" [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#b7c34775e4514c05bf0927bd2bd2f6de90715f0d" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#b6ea49a1b5e45a3f64737ddd40707731e71ac1d2" dependencies = [ "delegate", "derive_more", @@ -454,9 +412,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "humantime" @@ -466,9 +424,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iana-time-zone" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -480,35 +438,22 @@ dependencies = [ [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" -dependencies = [ - "hermit-abi 0.3.1", - "libc", - "windows-sys 0.48.0", + "cc", ] [[package]] name = "is-terminal" -version = "0.4.6" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", + "hermit-abi 0.3.2", "rustix", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -519,9 +464,9 @@ checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -536,7 +481,7 @@ dependencies = [ "derive_more", "embedded-graphics", "error-stack 0.3.1", - "hashbrown 0.12.3", + "hashbrown 0.14.0", "hbasm", "hbvm", "limine", @@ -565,35 +510,26 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.141" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "limine" -version = "0.1.10" -source = "git+https://github.com/limine-bootloader/limine-rs#d34b1863a0355e8606a0090663a9f4749c02f838" - -[[package]] -name = "link-cplusplus" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" -dependencies = [ - "cc", -] +version = "0.1.11" +source = "git+https://github.com/limine-bootloader/limine-rs#4394419fe347901a9308a8956df16454a4b87b02" [[package]] name = "linux-raw-sys" -version = "0.3.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -601,12 +537,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "logos" @@ -627,8 +560,8 @@ dependencies = [ "fnv", "proc-macro2", "quote", - "regex-syntax", - "syn 2.0.13", + "regex-syntax 0.6.29", + "syn 2.0.23", ] [[package]] @@ -652,16 +585,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc4010833aea396656c2f91ee704d51a6f1329ec2ab56ffd00bfd56f7481ea94" -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.15" @@ -673,9 +596,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "owo-colors" @@ -688,24 +611,24 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.26" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -722,7 +645,7 @@ version = "10.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -736,13 +659,25 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.3" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-automata", + "regex-syntax 0.7.3", +] + +[[package]] +name = "regex-automata" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d3daa6976cffb758ec878f108ba0e062a45b2d6ca3a2cca965338855476caf" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.7.3", ] [[package]] @@ -751,6 +686,12 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +[[package]] +name = "regex-syntax" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab07dc67230e4a4718e70fd5c20055a4334b121f1f9db8fe63ef39ce9b8c846" + [[package]] name = "repbuild" version = "0.2.0" @@ -772,23 +713,22 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.7" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aae838e49b3d63e9274e1c01833cc8139d3fec468c3b84688c628f44b1ae11d" +checksum = "ac5ffa1efe7548069688cd7028f32591853cd7b5b756d41bcffd2353e4fc75b4" dependencies = [ - "bitflags", + "bitflags 2.3.3", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] name = "rustversion" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" +checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" [[package]] name = "sbi" @@ -802,12 +742,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scratch" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" - [[package]] name = "semver" version = "1.0.17" @@ -816,22 +750,22 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.159" +version = "1.0.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" +checksum = "d614f89548720367ded108b3c843be93f3a341e22d5674ca0dd5cd57f34926af" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.159" +version = "1.0.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" +checksum = "d4fe589678c688e44177da4f27152ee2d190757271dc7f1d5b6b9f68d869d641" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.23", ] [[package]] @@ -881,9 +815,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.13" +version = "2.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" +checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" dependencies = [ "proc-macro2", "quote", @@ -921,26 +855,20 @@ dependencies = [ [[package]] name = "uart_16550" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b074eb9300ad949edd74c529c0e8d451625af71bb948e6b65fe69f72dc1363d9" +checksum = "614ff2a87880d4bd4374722268598a970bbad05ced8bf630439417347254ab2e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "rustversion", "x86_64", ] [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" [[package]] name = "version_check" @@ -951,7 +879,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "versioning" version = "0.1.3" -source = "git+https://git.ablecorp.us/ableos/ableos_userland#f433484f2f56a4e8f77b1f39680b88c3d1e27830" +source = "git+https://git.ablecorp.us/ableos/ableos_userland#a45a19c6b7355ebdac53259d06a1894a096143e6" dependencies = [ "serde", ] @@ -962,7 +890,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42299957c6f61af586fe3eae398c16ec07f33a02579fa1d41ae96156ce437029" dependencies = [ - "bitflags", + "bitflags 1.3.2", "log", "zerocopy", ] @@ -987,9 +915,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -997,24 +925,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.23", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1022,22 +950,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.23", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "winapi" @@ -1076,16 +1004,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", + "windows-targets", ] [[package]] @@ -1094,117 +1013,60 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows-targets" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.0" @@ -1218,7 +1080,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "547152b57dd1ae0ce7a4ef1c6470f6039aa7ed22e2179d5bc4f3eda1304e0db3" dependencies = [ "bit", - "bitflags", + "bitflags 1.3.2", "paste", "raw-cpuid", "x86_64", @@ -1231,7 +1093,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "100555a863c0092238c2e0e814c1096c1e5cf066a309c696a87e907b5f8c5d69" dependencies = [ "bit_field", - "bitflags", + "bitflags 1.3.2", "rustversion", "volatile", ] @@ -1239,7 +1101,7 @@ dependencies = [ [[package]] name = "xml" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/ableos_userland#f433484f2f56a4e8f77b1f39680b88c3d1e27830" +source = "git+https://git.ablecorp.us/ableos/ableos_userland#a45a19c6b7355ebdac53259d06a1894a096143e6" dependencies = [ "serde", ] diff --git a/kernel/src/arch/x86_64/mod.rs b/kernel/src/arch/x86_64/mod.rs index 0c81116..0151c7d 100644 --- a/kernel/src/arch/x86_64/mod.rs +++ b/kernel/src/arch/x86_64/mod.rs @@ -2,7 +2,7 @@ use {limine::SmpRequest, xml::XMLElement}; use embedded_graphics::pixelcolor::Rgb888; -use crate::{arch::x86_64::graphics::DISPLAY, kmain::DEVICE_TREE}; +use crate::{arch::x86_64::graphics::DISPLAY, bootmodules::BootModule, kmain::DEVICE_TREE}; pub mod memory; @@ -180,6 +180,52 @@ unsafe extern "C" fn _kernel_start() -> ! { // TODO: Add in rdseed and rdrand as sources for randomness let _rand = xml::XMLElement::new("Random"); + let bm = MOD_REQ.get_response().get(); + + let mut bootmodules = alloc::vec::Vec::new(); + + if bm.is_some() { + let bm = bm.unwrap(); + for x in 0..bm.module_count { + let file = bm.modules().get(x as usize); + if file.is_some() { + let file = file.unwrap(); + 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(), + ); + 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(), + ); + if file_cmd.is_err() { + panic!("invalid module cmd: {:?}", file_cmd); + } + + log::trace!("module path: {:?}", file_path); + log::trace!("module cmd: {:?}", file_cmd); + + bootmodules.push(BootModule::new( + file_path.unwrap(), + raw_bytes, + file_cmd.unwrap(), + )); + } else { + log::error!("You should not be here"); + break; + } + } + log::info!("Boot module count: {:?}", bootmodules.len()); + assert_eq!(bm.module_count, bootmodules.len() as u64); + } + crate::kmain::kmain( KFILE_REQ .get_response() @@ -192,16 +238,7 @@ unsafe extern "C" fn _kernel_start() -> ! { .transpose() .expect("expected valid cmdline string") .unwrap_or_default(), - MOD_REQ - .get_response() - .get() - .and_then(|m| m.modules().get(0)) - .map(|file| unsafe { - core::slice::from_raw_parts( - file.base.as_ptr().expect("invalid initrd"), - file.length as usize, - ) - }), + bootmodules, ) } diff --git a/kernel/src/bootmodules.rs b/kernel/src/bootmodules.rs new file mode 100644 index 0000000..729bd92 --- /dev/null +++ b/kernel/src/bootmodules.rs @@ -0,0 +1,36 @@ +use { + crate::alloc::string::ToString, + alloc::{string::String, vec::Vec}, + clparse::Arguments, + core::fmt::{Debug, Display}, + log::trace, + xml::XMLElement, +}; +pub type BootModules = Vec; + +pub struct BootModule { + pub path: String, + pub bytes: Vec, + pub cmd: String, +} +impl BootModule { + pub fn new(path: String, bytes: Vec, cmd: String) -> 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); + + 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 +} diff --git a/kernel/src/host.rs b/kernel/src/host.rs index 965116f..e2e29af 100644 --- a/kernel/src/host.rs +++ b/kernel/src/host.rs @@ -63,6 +63,8 @@ pub enum HostError { // // pub fn rpc_register(_engine: &mut Engine) {} // // pub fn rpc_call(_engine: &mut Engine) {} +use log::error; + use hbvm::vm::{ mem::{Memory, MemoryAccessReason, PageSize}, trap::HandleTrap, @@ -74,12 +76,20 @@ pub struct TrapHandler; impl HandleTrap for TrapHandler { fn page_fault( &mut self, - _: MemoryAccessReason, - _: &mut Memory, - _: u64, - _: PageSize, - _: *mut u8, + mar: MemoryAccessReason, + memory: &mut Memory, + vaddr: u64, + size: PageSize, + dataptr: *mut u8, ) -> bool { + error!( + "MemoryAccessReason: {} +Memory: {:?} +VAddr: {} +Size: {:?} +DataPTR: {:?}", + mar, memory, vaddr, size, dataptr + ); false } diff --git a/kernel/src/kmain.rs b/kernel/src/kmain.rs index 98cd84f..5a3fd52 100644 --- a/kernel/src/kmain.rs +++ b/kernel/src/kmain.rs @@ -1,108 +1,102 @@ //! AbleOS Kernel Entrypoint +// use crate::arch::sloop; use { - crate::{alloc::string::ToString, arch::logging::SERIAL_CONSOLE, device_tree::DeviceTree}, - clparse::Arguments, - log::{debug, trace}, + crate::{ + arch::logging::SERIAL_CONSOLE, + bootmodules::{build_cmd, BootModules}, + device_tree::DeviceTree, + }, + alloc::format, + log::{debug, info, trace}, spin::{Lazy, Mutex}, xml::XMLElement, }; -pub fn kmain(cmdline: &str, bootstrap: Option<&'static [u8]>) -> ! { +pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! { debug!("Entered kmain"); - let mut cmdline = cmdline.to_string(); - cmdline.pop(); - cmdline.remove(0); - - let kcmd = Arguments::parse(cmdline.to_string()).unwrap(); + let kcmd = build_cmd("Kernel Command Line", &cmdline); trace!("Cmdline: {kcmd:?}"); - let mut kcl = XMLElement::new("Kernel Command Line"); - for (key, value) in kcmd.arguments { - kcl.set_attribute(key, value); + for (i, bm) in boot_modules.iter().enumerate() { + let name = format!("module-{}", i); + let _bmcmd: XMLElement; + if bm.cmd.len() >= 2 { + // TODO: pass into the program + _bmcmd = build_cmd(name, bm.cmd.clone()); + } } - debug!("kernel command line object: {:?}", kcl); - let bootstrap = bootstrap/*.expect("no bootstrap found")*/; - match bootstrap { - Some(bootstrap_mod) => { - debug!("Bootstrap Module: {:?}", bootstrap_mod); - } - None => { - debug!("No bootstrap module loaded.") - } - } let dt = DEVICE_TREE.lock(); - log::info!("Device Tree{}", dt); - log::info!("Boot complete. Moving to init_system"); + info!("Device Tree{}", dt); + info!("Boot complete. Moving to init_system"); // TODO: schedule the disk driver from the initramfs // TODO: schedule the filesystem driver from the initramfs // TODO: schedule the init system from the initramfs - let code = "li r1, 8 -li r2, 10 -add r1, r1, r2 - - -ecall" - .to_string(); - - let mut prog = alloc::vec![]; - // TODO: Port hbasm to be fully nostd - if let Err(e) = hbasm::assembly(&code, &mut prog) { - log::error!( - "Error {:?} at {:?} (`{}`)", - e.kind, - e.span.clone(), - &code[e.span], - ); - } - - use hbvm::validate::validate; - - #[allow(clippy::redundant_else)] - if let Err(e) = validate(&prog) { - log::error!("Program validation error: {e:?}"); - } else { - log::info!("valid program"); - unsafe { - use {crate::host::TrapHandler, hbvm::vm::Vm}; - let mut vm = Vm::new_unchecked(&prog, TrapHandler); - vm.memory.insert_test_page(); - log::info!("Program interrupt: {:?}", vm.run()); - log::info!("{:?}", vm.registers); - } - } // TODO: change this to a driver { - let _buf = [8; 128 * 4]; + let mut prog = alloc::vec![]; + let mut code = alloc::string::String::new(); let mut sc = SERIAL_CONSOLE.lock(); loop { - // TODO: Implement an API for sending and recieving serial stuff - { - fn read_ipc_buff() {} - fn write_ipc_buff() {} - // TODO: read from the IPC buffer and push to serial stream - let _msg = read_ipc_buff(); - for byte in 0..0 { - sc.send(byte); - } - } - match sc.receive() { b'\r' => { + code.push('\n'); + + sc.send(b'\r'); sc.send(b'\n'); + + match hbasm::assembly(&code, &mut prog) { + Ok(_) => { + use hbvm::validate::validate; + match validate(&prog) { + Err(_e) => { + // log::error!("Program validation error: {e:?}"); + } + Ok(_) => { + // log::info!("valid program"); + use {crate::host::TrapHandler, hbvm::vm::Vm}; + let mut vm; + unsafe { + vm = Vm::new_unchecked(&prog, TrapHandler); + vm.memory.insert_test_page(); + } + // log::info!("Program interrupt: {:?}", vm.run()); + // log::debug!("{:?}", vm.registers); + } + } + + sc.send(b'>'); + } + Err(_e) => { + // log::error!( + // "Error {:?} at {:?} (`{}`)", + // e.kind, + // e.span.clone(), + // &code[e.span], + // ); + for x in "err".as_bytes() { + sc.send(*x); + } + } + } + code = alloc::string::String::new(); } byte => { + code.push(byte as char); + sc.send(byte); } } } } + + // sloop(); } pub static DEVICE_TREE: Lazy> = Lazy::new(|| { diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index f28fee3..4aeb67c 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -21,6 +21,7 @@ extern crate alloc; mod allocator; mod arch; +mod bootmodules; pub mod device_tree; pub mod handle; pub mod host; diff --git a/repbuild/limine.cfg b/repbuild/limine.cfg index 149bd06..6f8f009 100644 --- a/repbuild/limine.cfg +++ b/repbuild/limine.cfg @@ -13,10 +13,13 @@ TERM_BACKDROP=008080 COMMENT=Default AbleOS boot entry. PROTOCOL=limine KERNEL_PATH=${ABLEOS_KERNEL} - KERNEL_CMDLINE="baka=false foobles=true" - # KERNEL_CMDLINE="" + # execute is an array of boot modules to execute + KERNEL_CMDLINE="execute=[0,1]" # Setting a default resolution for the framebuffer RESOLUTION=1024x768x24 - # MODULE_PATH=boot:///boot/fs.wasm - # MODULE_CMDLINE=This is the first module. + MODULE_PATH=boot:///background.bmp + MODULE_CMDLINE="diskid=123456789" + + MODULE_PATH=boot:///background.bmp + MODULE_CMDLINE="" \ No newline at end of file