diff --git a/.gitignore b/.gitignore index 8a4757c..2f7896d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1 @@ target/ -.gdb_history -!*/.gitkeep -__pycache__/ -debug.log -/disk/ -/limine/ -/disk.img diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a32d038 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,5 @@ +[submodule "limine"] + path = limine + url = https://github.com/limine-bootloader/limine.git + branch = v4.x-branch-binary + shallow = true diff --git a/Cargo.lock b/Cargo.lock index 4ffaadb..7748189 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,98 +12,19 @@ dependencies = [ ] [[package]] -name = "async-broadcast" -version = "0.4.1" +name = "android_system_properties" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d26004fe83b2d1cd3a97609b21e39f9a31535822210fe83205d2ce48866ea61" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" dependencies = [ - "event-listener", - "futures-core", - "parking_lot", -] - -[[package]] -name = "async-channel" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28" -dependencies = [ - "concurrent-queue 1.2.4", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-executor" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" -dependencies = [ - "async-lock", - "async-task", - "concurrent-queue 2.0.0", - "fastrand", - "futures-lite", - "slab", -] - -[[package]] -name = "async-io" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8121296a9f05be7f34aa4196b1747243b3b62e048bb7906f644f3fbfc490cf7" -dependencies = [ - "async-lock", - "autocfg", - "concurrent-queue 1.2.4", - "futures-lite", "libc", - "log", - "parking", - "polling", - "slab", - "socket2", - "waker-fn", - "winapi", ] [[package]] -name = "async-lock" -version = "2.6.0" +name = "anyhow" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" -dependencies = [ - "event-listener", - "futures-lite", -] - -[[package]] -name = "async-recursion" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "async-task" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" - -[[package]] -name = "async-trait" -version = "0.1.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" [[package]] name = "atty" @@ -111,7 +32,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -140,23 +61,23 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + [[package]] name = "byteorder" version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -[[package]] -name = "cache-padded" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" - [[package]] name = "cc" -version = "1.0.77" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" +checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" [[package]] name = "cfg-if" @@ -165,33 +86,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "colored" -version = "2.0.0" +name = "chrono" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ - "atty", - "lazy_static", + "iana-time-zone", + "js-sys", + "num-integer", + "num-traits", + "time", + "wasm-bindgen", "winapi", ] [[package]] -name = "concurrent-queue" -version = "1.2.4" +name = "codespan-reporting" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ - "cache-padded", + "termcolor", + "unicode-width", ] [[package]] -name = "concurrent-queue" -version = "2.0.0" +name = "core-foundation-sys" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" -dependencies = [ - "crossbeam-utils", -] +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "crossbeam-queue" @@ -213,10 +136,43 @@ dependencies = [ ] [[package]] -name = "derivative" -version = "2.2.0" +name = "cxx" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" dependencies = [ "proc-macro2", "quote", @@ -224,123 +180,60 @@ dependencies = [ ] [[package]] -name = "dirs" -version = "4.0.0" +name = "env_logger" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" dependencies = [ - "dirs-sys", + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", ] [[package]] -name = "dirs-sys" -version = "0.3.7" +name = "errno" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" dependencies = [ + "errno-dragonfly", "libc", - "redox_users", "winapi", ] [[package]] -name = "enumflags2" -version = "0.7.5" +name = "errno-dragonfly" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" dependencies = [ - "enumflags2_derive", - "serde", -] - -[[package]] -name = "enumflags2_derive" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - -[[package]] -name = "fastrand" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" -dependencies = [ - "instant", -] - -[[package]] -name = "futures-core" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" - -[[package]] -name = "futures-io" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" - -[[package]] -name = "futures-lite" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - -[[package]] -name = "futures-sink" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" - -[[package]] -name = "futures-task" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" - -[[package]] -name = "futures-util" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" -dependencies = [ - "futures-core", - "futures-sink", - "futures-task", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "getrandom" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" -dependencies = [ - "cfg-if", + "cc", "libc", - "wasi", +] + +[[package]] +name = "error-stack" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d224e04b2d93d974c08e375dac9b8d1a513846e44c6666450a57b1ed963f9" +dependencies = [ + "anyhow", + "owo-colors", + "rustc_version", +] + +[[package]] +name = "fatfs" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e18f80a87439240dac45d927fd8f8081b6f1e34c03e97271189fa8a8c2e96c8f" +dependencies = [ + "bitflags", + "byteorder", + "chrono", + "log", ] [[package]] @@ -353,18 +246,79 @@ dependencies = [ ] [[package]] -name = "hex" -version = "0.4.3" +name = "hermit-abi" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] [[package]] -name = "instant" -version = "0.1.12" +name = "humantime" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" dependencies = [ - "cfg-if", + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi 0.2.6", + "io-lifetimes", + "rustix", + "windows-sys", +] + +[[package]] +name = "is_ci" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", ] [[package]] @@ -382,17 +336,11 @@ dependencies = [ "x86_64", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" -version = "0.2.137" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "limine" @@ -400,6 +348,21 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac64618e505bab2387986e5b1014f5d344130d609685bbd8b71a10af3ee599d" +[[package]] +name = "link-cplusplus" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "lock_api" version = "0.4.7" @@ -426,70 +389,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] -name = "memoffset" -version = "0.6.5" +name = "nix" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "46a58d1d356c6597d08cde02c2f09d785b09e28711837b1ed667dc652c08a694" +dependencies = [ + "bitflags", + "cfg-if", + "libc", + "static_assertions", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] -[[package]] -name = "nix" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" -dependencies = [ - "bitflags", - "cc", - "cfg-if", - "libc", - "memoffset", -] - [[package]] name = "once_cell" -version = "1.13.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] -name = "ordered-stream" -version = "0.0.1" +name = "owo-colors" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44630c059eacfd6e08bdaa51b1db2ce33119caa4ddc1235e923109aa5f25ccb1" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" dependencies = [ - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "parking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys", + "supports-color", ] [[package]] @@ -498,49 +440,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" -[[package]] -name = "pin-project-lite" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "polling" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4609a838d88b73d8238967b60dd115cc08d38e2bbaf51ee1e4b695f89122e2" -dependencies = [ - "autocfg", - "cfg-if", - "libc", - "log", - "wepoll-ffi", - "winapi", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "proc-macro-crate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" -dependencies = [ - "once_cell", - "thiserror", - "toml", -] - [[package]] name = "proc-macro2" version = "1.0.47" @@ -559,36 +458,6 @@ 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.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom", -] - [[package]] name = "raw-cpuid" version = "10.6.0" @@ -598,26 +467,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom", - "redox_syscall", - "thiserror", -] - [[package]] name = "regex" version = "1.7.0" @@ -631,26 +480,42 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "repbuild" -version = "0.1.0" +version = "0.2.0" dependencies = [ - "colored", - "udisks", - "zbus", + "env_logger", + "error-stack", + "fatfs", + "log", + "nix", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.36.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", ] [[package]] @@ -665,6 +530,18 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "scratch" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" + +[[package]] +name = "semver" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" + [[package]] name = "serde" version = "1.0.141" @@ -685,32 +562,6 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_repr" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sha1" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" -dependencies = [ - "sha1_smol", -] - -[[package]] -name = "sha1_smol" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" - [[package]] name = "slab" version = "0.4.7" @@ -720,22 +571,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - -[[package]] -name = "socket2" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "spin" version = "0.9.4" @@ -751,6 +586,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "supports-color" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ba6faf2ca7ee42fdd458f4347ae0a9bd6bcc445ad7cb57ad82b383f18870d6f" +dependencies = [ + "atty", + "is_ci", +] + [[package]] name = "syn" version = "1.0.103" @@ -763,80 +608,25 @@ dependencies = [ ] [[package]] -name = "tempfile" -version = "3.3.0" +name = "termcolor" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ - "cfg-if", - "fastrand", "libc", - "redox_syscall", - "remove_dir_all", + "wasi", "winapi", ] -[[package]] -name = "thiserror" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "toml" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" -dependencies = [ - "serde", -] - -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" -dependencies = [ - "once_cell", -] - [[package]] name = "uart_16550" version = "0.2.18" @@ -848,32 +638,18 @@ dependencies = [ "x86_64", ] -[[package]] -name = "udisks" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55c5fe7da3b0a73f1c7c96cbb00e9684e93ee5b8141851bfeb0f073cfed39069" -dependencies = [ - "serde", - "zbus", -] - -[[package]] -name = "uds_windows" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" -dependencies = [ - "tempfile", - "winapi", -] - [[package]] name = "unicode-ident" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + [[package]] name = "versioning" version = "0.1.2" @@ -888,27 +664,66 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3ca98349dda8a60ae74e04fd90c7fb4d6a4fbe01e6d3be095478aa0b76f6c0c" -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] -name = "wepoll-ffi" -version = "0.1.2" +name = "wasm-bindgen" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" dependencies = [ - "cc", + "cfg-if", + "wasm-bindgen-macro", ] +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + [[package]] name = "winapi" version = "0.3.9" @@ -925,6 +740,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -1012,93 +836,3 @@ dependencies = [ "rustversion", "volatile", ] - -[[package]] -name = "zbus" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d8f1a037b2c4a67d9654dc7bdfa8ff2e80555bbefdd3c1833c1d1b27c963a6b" -dependencies = [ - "async-broadcast", - "async-channel", - "async-executor", - "async-io", - "async-lock", - "async-recursion", - "async-task", - "async-trait", - "byteorder", - "derivative", - "dirs", - "enumflags2", - "event-listener", - "futures-core", - "futures-sink", - "futures-util", - "hex", - "lazy_static", - "nix", - "once_cell", - "ordered-stream", - "rand", - "serde", - "serde_repr", - "sha1", - "static_assertions", - "tracing", - "uds_windows", - "winapi", - "zbus_macros", - "zbus_names", - "zvariant", -] - -[[package]] -name = "zbus_macros" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f8fb5186d1c87ae88cf234974c240671238b4a679158ad3b94ec465237349a6" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "regex", - "syn", -] - -[[package]] -name = "zbus_names" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d69bb79b44e1901ed8b217e485d0f01991aec574479b68cb03415f142bc7ae67" -dependencies = [ - "serde", - "static_assertions", - "zvariant", -] - -[[package]] -name = "zvariant" -version = "3.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c817f416f05fcbc833902f1e6064b72b1778573978cfeac54731451ccc9e207" -dependencies = [ - "byteorder", - "enumflags2", - "libc", - "serde", - "static_assertions", - "zvariant_derive", -] - -[[package]] -name = "zvariant_derive" -version = "3.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdd24fffd02794a76eb10109de463444064c88f5adb9e9d1a78488adc332bfef" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] diff --git a/base/README.md b/base/README.md deleted file mode 100644 index c251711..0000000 --- a/base/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Base Root Filesystem - -This is the base root filesystem for ableOS. It's used by tepbuild while -building the disk image. diff --git a/base/boot/initrd.tar b/base/boot/initrd.tar deleted file mode 100644 index 9df6499..0000000 Binary files a/base/boot/initrd.tar and /dev/null differ diff --git a/base/boot/kernel.toml b/base/boot/kernel.toml deleted file mode 100644 index c375fcc..0000000 --- a/base/boot/kernel.toml +++ /dev/null @@ -1,7 +0,0 @@ -[logging] -enabled = true -level = "Trace" -log_to_serial = true -log_to_vterm = false -filter = ["ableos::ps2_mouse", "ableos::vterm", "ableos::devices::pci"] - diff --git a/base/home/able/bins/aos_test.wasm b/base/home/able/bins/aos_test.wasm deleted file mode 100755 index b9350d9..0000000 Binary files a/base/home/able/bins/aos_test.wasm and /dev/null differ diff --git a/base/home/able/bins/weealloc_test.wasm b/base/home/able/bins/weealloc_test.wasm deleted file mode 100755 index 7af3a9f..0000000 Binary files a/base/home/able/bins/weealloc_test.wasm and /dev/null differ diff --git a/base/home/able/configs/qwerty.keymap b/base/home/able/configs/qwerty.keymap deleted file mode 100644 index 95db614..0000000 --- a/base/home/able/configs/qwerty.keymap +++ /dev/null @@ -1,252 +0,0 @@ -# Able doesn't have a full keyboard -0-NONE -1- -2- -3-BACKSPACE -4- -5- -6- -7- -8- -9-TAB -10- -11- -12- -13-ENTER -14- -15- -16-SHIFT -17-CONTROL -18-ALT -19-PAUSE -20-CAPS_LOCK -21- -22- -23- -24- -25- -26- -27- -28- -29- -30- -31- -32-SPACE -33-PAGE_UP -34-PAGE_DOWN -35-END -36-HOME -37-ARROW_LEFT -38-ARROW_UP -39-ARROW_RIGHT -40-ARROW_DOWN -41- -42- -43- -44- -45-INSERT -46-DELETE -47- -48-0 -49-1 -50-2 -51-3 -52-4 -53-5 -54-6 -55-7 -56-8 -57-9 -58- -59-SEMICOLON -60- -61-EQUAL -62- -63- -64- -65-a -66-b -67-c -68-d -69-e -70-f -71-g -72-h -73-i -74-j -75-k -76-l -77-m -78-n -79-o -80-p -81-q -82-r -83-s -84-t -85-u -86-v -87-w -88-x -89-y -90-z -91- -92- -93- -94- -95- -96- -97- -98- -99- -100- -101- -102- -103- -106- -107- -108- -109- -110- -111- -112-FUNCTION_1 -113-FUNCTION_2 -114-FUNCTION_3 -115-FUNCTION_4 -116-FUNCTION_5 -117-FUNCTION_6 -118-FUNCTION_7 -119-FUNCTION_8 -120-FUNCTION_9 -121-FUNCTION_10 -122-FUNCTION_11 -123-FUNCTION_12 -124- -125- -126- -127- -128- -129- -130- -131- -132- -134- -135- -136- -137- -138- -139- -140- -141- -142- -143- -145-SCROLL_LOCK -146- -147- -148- -149- -150- -151- -152- -153- -154- -155- -156- -157- -158- -159- -160- -161- -162- -163- -164- -165- -166- -167- -168- -169- -170- -171- -172- -173-MINUS -174- -175- -176- -177- -178- -179- -180- -181- -182- -183- -184- -185- -186- -187- -188-COMMA -189- -190-PERIOD -191-FORWARD_SLASH -192-GRAVE -193- -194- -195- -196- -197- -198- -199- -200- -201- -202- -203- -204- -205- -206- -207- -208- -209- -210- -211- -212- -213- -214- -215- -216- -218- -219-BRACKET_LEFT -220-BACK_SLASH -221-BRACKET_RIGHT -222-QUOTE -223- -224- -225- -226- -227- -228- -229- -230- -231- -232- -233- -234- -235- -236- -237- -238- -239- -240- -241- -242- -243- -244- -245- -246- -247- -248- -249- -250- -251- -252- -253- -254- -255- diff --git a/base/home/able/layout.txt b/base/home/able/layout.txt deleted file mode 100644 index 73c3402..0000000 --- a/base/home/able/layout.txt +++ /dev/null @@ -1,14 +0,0 @@ -boot/ -├─ kernel.img -home/ -├─ able/ -│ ├─ bins/ -│ ├─ config/ -│ │ ├─ able_edit/ -│ │ │ ├─ config.toml -│ ├─ irl_pic.png -│ ├─ password.txt -system/ -├─ bins/ -├─ configs/ -│ ├─ kernel.toml \ No newline at end of file diff --git a/kernel/.cargo/config.toml b/kernel/.cargo/config.toml index e8fc403..5e82bd2 100644 --- a/kernel/.cargo/config.toml +++ b/kernel/.cargo/config.toml @@ -6,4 +6,4 @@ build-std-features = ["compiler-builtins-mem"] target = "./targets/x86_64-ableos.json" [target.'cfg(target_arch = "x86_64")'] -rustflags = ["-C", "target-feature=+rdrand"] \ No newline at end of file +rustflags = ["-C", "target-feature=+rdrand"] diff --git a/limine b/limine new file mode 160000 index 0000000..83e6e5b --- /dev/null +++ b/limine @@ -0,0 +1 @@ +Subproject commit 83e6e5b4da7791ade3b367ceec8ce82c469d06db diff --git a/repbuild/Cargo.toml b/repbuild/Cargo.toml index 7ab309c..4d0b89b 100644 --- a/repbuild/Cargo.toml +++ b/repbuild/Cargo.toml @@ -1,11 +1,15 @@ [package] name = "repbuild" -version = "0.1.0" +version = "0.2.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -colored = "2.0" -udisks = "0.1" -zbus = "2.3" +env_logger = "0.10" +error-stack = "0.2" +fatfs = "0.3" +log = "0.4" + +[dependencies.nix] +version = "0.26" +default-features = false +features = ["fs"] diff --git a/base/boot/limine.cfg b/repbuild/limine.cfg similarity index 78% rename from base/boot/limine.cfg rename to repbuild/limine.cfg index a26657e..27ff2b9 100644 --- a/base/boot/limine.cfg +++ b/repbuild/limine.cfg @@ -1,4 +1,4 @@ -${ABLEOS_KERNEL}=boot:///boot/kernel +${ABLEOS_KERNEL}=boot:///kernel # TODO: Make a boot background image for ableOS # ${WALLPAPER_PATH}=boot:///boot/bg.bmp @@ -18,5 +18,5 @@ TERM_BACKDROP=008080 # Setting a default resolution for the framebuffer RESOLUTION=800x600x24 - MODULE_PATH=boot:///boot/initrd.tar - MODULE_CMDLINE=This is the first module. + # MODULE_PATH=boot:///boot/initrd.tar + # MODULE_CMDLINE=This is the first module. diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 86fcd37..e6bbcb4 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -1,539 +1,170 @@ -/* - * Copyright (c) 2022, Umut İnan Erdoğan - * Copyright (c) 2022, able - * - * SPDX-License-Identifier: MPL-2.0 - */ +use error_stack::{bail, report, Context, IntoReport, Result, ResultExt}; +use fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek}; +use nix::fcntl::FallocateFlags; +use std::{fmt::Display, fs::File, io, os::fd::AsRawFd, path::Path, process::Command}; -use colored::*; -use std::{ - fs::{self, File}, - os::fd::AsRawFd, - process::Command, -}; -use udisks::{ - filesystem::{MountOptions, UnMountOptions}, - manager::LoopSetupOptions, -}; +fn main() -> Result<(), Error> { + env_logger::init(); + let mut args = std::env::args(); + args.next(); -struct Options { - pub subcommand: Subcommand, - pub arguments: Vec, -} - -enum Subcommand { - BuildImage, - Doc, - Help, - Run, - Empty, - /// Run all tests for all architectures - Test, - Unknown(String), -} - -impl Subcommand { - fn from_str>(str: S) -> Subcommand { - match str.as_ref() { - "build-image" => Subcommand::BuildImage, - "doc" => Subcommand::Doc, - "help" => Subcommand::Help, - "run" | "r" => Subcommand::Run, - "test" | "t" => Subcommand::Test, - "" => Subcommand::Empty, - unknown => Subcommand::Unknown(unknown.to_string()), + match args.next().as_deref() { + Some("build" | "b") => build( + args.next() + .map(|x| x == "-r" || x == "--release") + .unwrap_or_default(), + ) + .change_context(Error::Build), + Some("run" | "r") => { + build( + args.next() + .map(|x| x == "-r" || x == "--release") + .unwrap_or_default(), + )?; + run() } - } -} - -enum MachineType { - X86_64, - RiscV64, - AArch64, - Unknown(String), -} - -fn main() -> Result<(), Box> { - let options = options(); - - match options.subcommand { - Subcommand::BuildImage => { - let machine_text = options.arguments.get(0).cloned().unwrap_or_default(); - - match machine(machine_text) { - MachineType::X86_64 => { - // Cleanup - // NOTE: we are not unwrapping these, as we don't want this to fail if they - // don't exist yet, probably not the best idea tho. - // FIXME: figure out a better way to ignore errors about these not existing - #[allow(unused_must_use)] - { - fs::remove_dir_all("./limine"); - fs::remove_dir_all("./disk"); - fs::remove_file("./target/disk.img"); - } - - // Build ableOS in release mode - Command::new("cargo") - .args(["build", "--release"]) - .current_dir(fs::canonicalize("./kernel").unwrap()) - .status() - .unwrap(); - - // Create disk directory - fs::create_dir("./disk").unwrap(); - - // Clone limine 4.x binaries - Command::new("git") - .arg("clone") - .arg("https://github.com/limine-bootloader/limine.git") - .arg("--branch=v4.x-branch-binary") - .arg("--depth=1") - .status() - .unwrap(); - - println!("{}", "Building limine".bold()); - Command::new("make") - .args(["-C", "limine"]) - .status() - .unwrap(); - - println!("{}", "Allocating new disk image".bold()); - Command::new("fallocate") - .args(["-l", "256M", "./target/disk.img"]) - .status() - .unwrap(); - - println!("{}", "Partitioning disk image".bold()); - let dbus_conn = zbus::blocking::Connection::system()?; - - // Setup loop device - let disk_img = File::options() - .read(true) - .write(true) - .open("./target/disk.img")?; - let loopdev = udisks::manager::UDisks2ManagerProxyBlocking::new(&dbus_conn)? - .loop_setup( - disk_img.as_raw_fd().into(), - LoopSetupOptions { - no_user_interaction: true, - offset: 0, - size: 0, - readonly: false, - no_part_scan: false, - }, - )?; - - // Create MBR - udisks::block::BlockProxyBlocking::builder(&dbus_conn) - .path(&loopdev)? - .build()? - .format("dos", Default::default())?; - - // Create and format partition - let filesystem = - udisks::partition::PartitionTableProxyBlocking::builder(&dbus_conn) - .destination("org.freedesktop.UDisks2")? - .path(&loopdev)? - .build()? - .create_partition_and_format( - 0, - 0, - "", - "", - Default::default(), - "ext2", - [("take-ownership", true.into())].into_iter().collect(), - )?; - - let fsproxy = udisks::filesystem::FilesystemProxyBlocking::builder(&dbus_conn) - .path(&filesystem)? - .build()?; - - // Mount the filesystem - let mountpoint = fsproxy - .mount(MountOptions { - no_user_interaction: true, - fs_type: String::new(), - mount_options: String::new(), - }) - .or_else(|_| { - Ok::(loop { - if let Some(m) = fsproxy.mount_points()?.get(0) { - break m.to_string(); - } - }) - })?; - - // copy ./base/* over to ./disk - Command::new("sh") - .arg("-c") - .arg(format!("cp -r ./base/* {mountpoint}")) - .status()?; - - // copy ./limine/limine.sys over to ./disk/boot - Command::new("cp") - .args(["./limine/limine.sys", &format!("{mountpoint}/boot")]) - .status()?; - - // copy the kernel over to ./disk/boot/kernel - Command::new("cp") - .arg("./target/x86_64-ableos/release/kernel") - .arg(&format!("{mountpoint}/boot/kernel")) - .status()?; - - // Unmount the filesystem (and the rest of things will follow) - fsproxy.unmount(UnMountOptions { - no_user_interaction: true, - force: false, - })?; - - println!("{}", "Deploying limine".bold()); - Command::new("./limine/limine-deploy") - .arg("./target/disk.img") - .status() - .unwrap(); - } - MachineType::Unknown(unknown) => { - eprintln!( - "{}: unknown machine type `{}`", - "error".red().bold(), - unknown.bold(), - ); - eprintln!("expected one of x86_64, riscv64 or aarch64"); - } - _ => { - eprintln!( - "{}: build-image not implemented for this machine type", - "error".red().bold(), - ); - } - } - } - Subcommand::Test => { - Command::new("cargo") - .args(["test", "--target=json_targets/x86_64-ableos.json"]) - .current_dir(fs::canonicalize("./ableos").unwrap()) - .status() - .unwrap(); - - // panic!("Test Infrastructure missing"); - } - Subcommand::Doc => { - let machine_text = options.arguments.get(0).cloned().unwrap_or_default(); - - match machine(machine_text) { - MachineType::X86_64 => { - Command::new("cargo") - .args(["doc", "--open"]) - .current_dir(fs::canonicalize("./ableos").unwrap()) - .status() - .unwrap(); - } - MachineType::RiscV64 => { - Command::new("cargo") - .args(["doc", "--open", "--target=riscv64gc-unknown-none-elf"]) - .current_dir(fs::canonicalize("./ableos").unwrap()) - .status() - .unwrap(); - } - MachineType::AArch64 => { - Command::new("cargo") - .args(["doc", "--open", "--target=json_targets/aarch64-ableos.json"]) - .current_dir(fs::canonicalize("./ableos").unwrap()) - .status() - .unwrap(); - } - MachineType::Unknown(unknown) => { - eprintln!( - "{}: unknown machine type `{}`", - "error".red().bold(), - unknown.bold(), - ); - eprintln!("expected one of x86_64, riscv64 or aarch64"); - } - } - } - Subcommand::Help => help(), - Subcommand::Run => { - let machine_text = options.arguments.get(0).cloned().unwrap_or_default(); - let debug = options.arguments.get(1).cloned().unwrap_or_default(); - let debug = matches!(debug.as_str(), "--debug" | "--dbg" | "-d"); - - match machine(machine_text) { - MachineType::X86_64 if debug => { - // Build ableOS - Command::new("cargo") - .arg("build") - .current_dir(fs::canonicalize("./kernel").unwrap()) - .status() - .unwrap(); - - // Setup loopback device for disk.img, with partitions - // FIXME: don't do ths if running without changes - // Setup loop device - let disk_img = File::options() - .read(true) - .write(true) - .open("./target/disk.img")?; - let dbus_conn = zbus::blocking::Connection::system()?; - let loopdev = udisks::manager::UDisks2ManagerProxyBlocking::new(&dbus_conn)? - .loop_setup( - disk_img.as_raw_fd().into(), - LoopSetupOptions { - no_user_interaction: true, - offset: 0, - size: 0, - readonly: false, - no_part_scan: false, - }, - )?; - - let parts = udisks::partition::PartitionTableProxyBlocking::builder(&dbus_conn) - .destination("org.freedesktop.UDisks2")? - .path(loopdev)? - .build()? - .partitions()?; - - let fsobjpath = parts.get(0).ok_or("missing boot partition")?; - let mountpoint = - udisks::filesystem::FilesystemProxyBlocking::builder(&dbus_conn) - .path(fsobjpath)? - .build()? - .mount(MountOptions { - no_user_interaction: true, - fs_type: String::new(), - mount_options: String::new(), - })?; - - // copy the kernel over to ./disk/boot/kernel - Command::new("cp") - .arg("./target/x86_64-ableos/debug/kernel") - .arg(format!("{mountpoint}/boot/kernel")) - .status() - .unwrap(); - - udisks::filesystem::FilesystemProxyBlocking::builder(&dbus_conn) - .path(fsobjpath)? - .build()? - .unmount(UnMountOptions { - no_user_interaction: true, - force: false, - })?; - - // run qemu with "-S", "-gdb", "tcp:9000" - Command::new("qemu-system-x86_64") - .args(["-device", "piix4-ide,id=ide"]) - .arg("-drive") - .arg("file=./target/disk.img,format=raw,if=none,id=disk") - .args(["-device", "ide-hd,drive=disk,bus=ide.0"]) - // .arg("--nodefaults") - .args(["-cpu", "Broadwell-v3"]) - .args(["-m", "4G"]) - .args(["-serial", "stdio"]) - .args(["-smp", "cores=2"]) - // .args(["-soundhw", "pcspk"]) - // .args(["-device", "VGA"]) - // .args(["-device", "virtio-gpu-pci"]) - .args(["-device", "vmware-svga"]) - .args(["-device", "sb16"]) - // .args(["-machine", "pcspk-audiodev=0"]) - // .args(["-qmp", "unix:../qmp-sock,server,nowait"]) - .args(["-S", "-gdb", "tcp:9000"]) - .status() - .unwrap(); - } - MachineType::X86_64 => { - // Build ableOS - Command::new("cargo") - .args(["build", "--release"]) - .current_dir(fs::canonicalize("./kernel").unwrap()) - .status() - .unwrap(); - - // Setup loopback device for disk.img, with partitions - // FIXME: don't do ths if running without changes - let disk_img = File::options() - .read(true) - .write(true) - .open("./target/disk.img")?; - let dbus_conn = zbus::blocking::Connection::system()?; - let loopdev = udisks::manager::UDisks2ManagerProxyBlocking::new(&dbus_conn)? - .loop_setup( - disk_img.as_raw_fd().into(), - LoopSetupOptions { - no_user_interaction: true, - offset: 0, - size: 0, - readonly: false, - no_part_scan: false, - }, - )?; - - let parts = udisks::partition::PartitionTableProxyBlocking::builder(&dbus_conn) - .destination("org.freedesktop.UDisks2")? - .path(loopdev)? - .build()? - .partitions()?; - - let fsproxy = udisks::filesystem::FilesystemProxyBlocking::builder(&dbus_conn) - .path(&parts[0])? - .build()?; - - // Mount the filesystem - let mountpoint = fsproxy - .mount(MountOptions { - no_user_interaction: true, - fs_type: String::new(), - mount_options: String::new(), - }) - .or_else(|_| { - Ok::(loop { - if let Some(m) = fsproxy.mount_points()?.get(0) { - break m.to_string(); - } - }) - })?; - - // copy the kernel over to ./disk/boot/kernel - Command::new("cp") - .arg("./target/x86_64-ableos/release/kernel") - .arg(format!("{mountpoint}/boot/kernel")) - .status() - .unwrap(); - - fsproxy.unmount(UnMountOptions { - no_user_interaction: true, - force: false, - })?; - - // run qemu - Command::new("qemu-system-x86_64") - .args(["-device", "piix4-ide,id=ide"]) - .arg("-drive") - .arg("file=./target/disk.img,format=raw,if=none,id=disk") - .args(["-device", "ide-hd,drive=disk,bus=ide.0"]) - // .arg("--nodefaults") - .args(["-cpu", "Broadwell-v3"]) - .args(["-m", "4G"]) - .args(["-serial", "stdio"]) - .args(["-smp", "cores=2"]) - // .args(["-soundhw", "pcspk"]) - // .args(["-device", "VGA"]) - // .args(["-device", "virtio-gpu-pci"]) - .args(["-device", "vmware-svga"]) - .args(["-device", "sb16"]) - // .args(["-machine", "pcspk-audiodev=0"]) - // .args(["-qmp", "unix:../qmp-sock,server,nowait"]) - .status() - .unwrap(); - } - MachineType::RiscV64 if debug => { - eprintln!( - "{}: debug is not implemented for riscv64", - "error".red().bold() - ); - } - MachineType::RiscV64 => { - Command::new("cargo") - .args(["build", "--release", "--target=riscv64gc-unknown-none-elf"]) - .current_dir(fs::canonicalize("./ableos").unwrap()) - .status() - .unwrap(); - - Command::new("qemu-system-riscv64") - .args(["-machine", "virt"]) - .args(["-cpu", "rv64"]) - .args(["-smp", "8"]) - .args(["-m", "128M"]) - .arg("-bios") - .arg("src/arch/riscv/firmwear/opensbi-riscv64-generic-fw_jump.bin") - .arg("-kernel") - .arg("target/riscv64gc-unknown-none-elf/release/ableos") - .current_dir(fs::canonicalize("./ableos").unwrap()) - .status() - .unwrap(); - } - MachineType::AArch64 if debug => { - eprintln!( - "{}: debug is not implemented for aarch64", - "error".red().bold() - ); - } - MachineType::AArch64 => { - Command::new("cargo") - .args([ - "build", - "--release", - "--target=json_targets/aarch64-ableos.json", - ]) - .current_dir(fs::canonicalize("./ableos").unwrap()) - .status() - .unwrap(); - - Command::new("qemu-system-aarch64") - .args(["-machine", "virt"]) - .args(["-m", "1024M"]) - .args(["-cpu", "cortex-a53"]) - .args(["-kernel", "target/aarch64-ableos/release/ableos"]) - .args(["-device", "virtio-keyboard"]) - .current_dir(fs::canonicalize("./ableos").unwrap()) - .status() - .unwrap(); - } - MachineType::Unknown(unknown) => { - eprintln!( - "{}: unknown machine type `{}`", - "error".red().bold(), - unknown.bold(), - ); - eprintln!("expected one of x86_64, riscv64 or aarch64"); - } - } - } - Subcommand::Empty => { - eprintln!("{}: no subcommand passed", "error".red().bold()); - help(); - } - Subcommand::Unknown(unknown) => { - eprintln!( - "{}: unknown subcommand `{}`", - "error".red().bold(), - unknown.bold() + Some("help" | "h") => { + println!( + concat!( + "AbleOS RepBuild\n", + "Subcommands:\n", + " build (b): Build a bootable disk image\n", + " help (h): Print this message\n", + " run (r): Build and run AbleOS in QEMU\n\n", + "Options for build and run:\n", + " -r: build in release mode", + ), ); - help(); + Ok(()) + } + _ => Err(report!(Error::InvalidSubCom)), + } +} + +fn get_fs() -> Result, io::Error> { + let path = Path::new("target/disk.img"); + + match std::fs::metadata(path) { + Err(e) if e.kind() == io::ErrorKind::NotFound => (), + Err(e) => bail!(e), + Ok(_) => { + return FileSystem::new( + File::options().read(true).write(true).open(path)?, + FsOptions::new(), + ) + .into_report() } } - Ok(()) + let mut img = File::options() + .read(true) + .write(true) + .create(true) + .open(path)?; + + { + #[cfg(unix)] + nix::fcntl::fallocate( + img.as_raw_fd(), + FallocateFlags::from_bits(0).unwrap(), + 0, + 1024 * 1024 * 64, + ) + .map_err(|e| std::io::Error::from_raw_os_error(e as i32))?; + + #[cfg(not(any(unix)))] + compile_error!("unsupported platform"); + } + + fatfs::format_volume(&mut img, FormatVolumeOptions::new())?; + + let fs = FileSystem::new(img, FsOptions::new())?; + let bootdir = fs.root_dir().create_dir("efi")?.create_dir("boot")?; + + io::copy( + &mut File::open("limine/BOOTX64.EFI")?, + &mut bootdir.create_file("bootx64.efi")?, + )?; + + io::copy( + &mut File::open(Path::new("repbuild/limine.cfg"))?, + &mut fs.root_dir().create_file("limine.cfg")?, + )?; + + drop(bootdir); + Ok(fs) } -fn options() -> Options { - let subcommand = std::env::args().nth(1).unwrap_or_default(); - let arguments = std::env::args().skip(2).collect(); +fn build(release: bool) -> Result<(), Error> { + let fs = get_fs().change_context(Error::Io)?; + let mut com = Command::new("cargo"); + com.current_dir("kernel"); + com.args(["b"]); + if release { + com.arg("-r"); + } - Options { - subcommand: Subcommand::from_str(subcommand), - arguments, + com.status().into_report().change_context(Error::Build)?; + + (|| -> std::io::Result<_> { + io::copy( + &mut File::open( + Path::new("target/x86_64-ableos") + .join(if release { "release" } else { "debug" }) + .join("kernel"), + )?, + &mut fs.root_dir().create_file("kernel")?, + ) + .map(|_| ()) + })() + .into_report() + .change_context(Error::Io) +} + +fn run() -> Result<(), Error> { + #[rustfmt::skip] + let args = [ + "-bios", "/usr/share/OVMF/OVMF_CODE.fd", + "-enable-kvm", + "-cpu", "host", + "-drive", "file=target/disk.img,format=raw", + "-m", "4G", + "-serial", "stdio", + "-smp", "cores=2", + ]; + + match Command::new("qemu-system-x86_64") + .args(args) + .status() + .into_report() + .change_context(Error::ProcessSpawn)? + { + s if s.success() => Ok(()), + s => Err(report!(Error::Qemu(s.code()))), } } -fn machine>(text: S) -> MachineType { - match text.as_ref() { - "x86" | "x86_64" => MachineType::X86_64, - "riscv" | "riscv64" => MachineType::RiscV64, - "arm" | "arm64" | "aarch64" => MachineType::AArch64, - "" => { - eprintln!( - "{}: no machine type passed, defaulting to x86_64", - "warning".yellow().bold() - ); - MachineType::X86_64 +#[derive(Debug)] +enum Error { + Build, + InvalidSubCom, + Io, + ProcessSpawn, + Qemu(Option), +} + +impl Context for Error {} +impl Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Build => f.write_str("failed to build the kernel"), + Self::InvalidSubCom => { + f.write_str("missing or invalid subcommand (available: build, run)") + } + Self::Io => f.write_str("IO error"), + Self::ProcessSpawn => f.write_str("failed to spawn a process"), + Self::Qemu(Some(c)) => write!(f, "QEMU Error: {c}"), + Self::Qemu(None) => write!(f, "QEMU Error: interrupted by signal"), } - unknown => MachineType::Unknown(unknown.to_string()), } } - -fn help() { - todo!("`help`") -}