diff options
author | RaindropsSys <raindrops@equestria.dev> | 2023-11-22 21:50:14 +0100 |
---|---|---|
committer | RaindropsSys <raindrops@equestria.dev> | 2023-11-22 21:50:14 +0100 |
commit | aff3f702a041d55b930527eebb73e8d338a17d9d (patch) | |
tree | 2d8388e4747cc89b944fcc3ea5c55ebf2174fcdc | |
download | cometos-aff3f702a041d55b930527eebb73e8d338a17d9d.tar.gz cometos-aff3f702a041d55b930527eebb73e8d338a17d9d.tar.bz2 cometos-aff3f702a041d55b930527eebb73e8d338a17d9d.zip |
Initial commit
-rw-r--r-- | .DS_Store | bin | 0 -> 10244 bytes | |||
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | .idea/.gitignore | 8 | ||||
-rw-r--r-- | .idea/cutieos.iml | 11 | ||||
-rw-r--r-- | .idea/modules.xml | 8 | ||||
-rw-r--r-- | .idea/vcs.xml | 6 | ||||
-rw-r--r-- | Cargo.lock | 843 | ||||
-rw-r--r-- | Cargo.toml | 15 | ||||
-rw-r--r-- | OVMF_CODE.fd | bin | 0 -> 3653632 bytes | |||
-rw-r--r-- | OVMF_VARS.fd | bin | 0 -> 540672 bytes | |||
-rw-r--r-- | build.rs | 5 | ||||
-rw-r--r-- | esp/.DS_Store | bin | 0 -> 6148 bytes | |||
-rw-r--r-- | esp/efi/.DS_Store | bin | 0 -> 6148 bytes | |||
-rwxr-xr-x | esp/efi/boot/bootx64.efi | bin | 0 -> 155648 bytes | |||
-rw-r--r-- | rust-toolchain.toml | 2 | ||||
-rw-r--r-- | src/boot.rs | 19 | ||||
-rw-r--r-- | src/core.rs | 150 | ||||
-rw-r--r-- | src/main.rs | 37 | ||||
-rw-r--r-- | src/panic.rs | 34 | ||||
-rw-r--r-- | src/shell.rs | 12 |
20 files changed, 1151 insertions, 0 deletions
diff --git a/.DS_Store b/.DS_Store Binary files differnew file mode 100644 index 0000000..9ca7ba7 --- /dev/null +++ b/.DS_Store diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/cutieos.iml b/.idea/cutieos.iml new file mode 100644 index 0000000..cf84ae4 --- /dev/null +++ b/.idea/cutieos.iml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="EMPTY_MODULE" version="4"> + <component name="NewModuleRootManager"> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + <excludeFolder url="file://$MODULE_DIR$/target" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module>
\ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..daa2e99 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/cutieos.iml" filepath="$PROJECT_DIR$/.idea/cutieos.iml" /> + </modules> + </component> +</project>
\ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="" vcs="Git" /> + </component> +</project>
\ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..f11b569 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,843 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.21.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + +[[package]] +name = "build-info" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "155eb070980e96aeb4ef3b8620b0febb2ae5e17451dc1b329681bdd4eb0a94e1" +dependencies = [ + "build-info-proc", +] + +[[package]] +name = "build-info-build" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b69d6331ec579144d39e1c128f343d23e9b837617df1bed4ed032e141f83f06a" +dependencies = [ + "anyhow", + "base64", + "bincode", + "build-info-common", + "cargo_metadata", + "chrono", + "git2", + "glob", + "pretty_assertions", + "rustc_version", + "serde_json", + "zstd", +] + +[[package]] +name = "build-info-common" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8209c0c2b13da7e5f7202e591b6d41b46c8f0e78d031dedf5cff71cc8c6ec773" +dependencies = [ + "chrono", + "derive_more", + "semver", + "serde", +] + +[[package]] +name = "build-info-proc" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc1874cb1995691fb01f9bb56e75f9660d2614e74607fa71c08a8b3bd7e30e4" +dependencies = [ + "anyhow", + "base64", + "bincode", + "build-info-common", + "chrono", + "num-bigint", + "num-traits", + "proc-macro-error", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.39", + "zstd", +] + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "camino" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e34637b3140142bdf929fb439e8aa4ebad7651ebf7b1080b3930aa16ac1459ff" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "jobserver", + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-targets", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "cutieos" +version = "0.1.0" +dependencies = [ + "build-info", + "build-info-build", + "log", + "uefi", + "uefi-services", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 1.0.109", +] + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "git2" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" +dependencies = [ + "bitflags", + "libc", + "libgit2-sys", + "log", + "url", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "iana-time-zone" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[package]] +name = "jobserver" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "libgit2-sys" +version = "0.16.1+1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + +[[package]] +name = "libz-sys" +version = "1.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[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.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + +[[package]] +name = "pkg-config" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + +[[package]] +name = "pretty_assertions" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +dependencies = [ + "diff", + "yansi", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "ptr_meta" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcada80daa06c42ed5f48c9a043865edea5dc44cbf9ac009fda3b89526e28607" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bca9224df2e20e7c5548aeb5f110a0f3b77ef05f8585139b7148b59056168ed2" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +dependencies = [ + "serde", +] + +[[package]] +name = "serde" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "serde_json" +version = "1.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "ucs2" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad643914094137d475641b6bab89462505316ec2ce70907ad20102d28a79ab8" +dependencies = [ + "bit_field", +] + +[[package]] +name = "uefi" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ead9f748a4646479b850add36b527113a80e80a7e0f44d7b0334291850dcc5" +dependencies = [ + "bitflags", + "log", + "ptr_meta", + "ucs2", + "uefi-macros", + "uefi-raw", + "uguid", +] + +[[package]] +name = "uefi-macros" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26a7b1c2c808c3db854a54d5215e3f7e7aaf5dcfbce095598cba6af29895695d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "uefi-raw" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "864ac69eadd877bfb34e7814be1928122ed0057d9f975169a56ee496aa7bdfd7" +dependencies = [ + "bitflags", + "ptr_meta", + "uguid", +] + +[[package]] +name = "uefi-services" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a79fcb420624743c895bad0f9480fbc2f64e7c8d8611fb1ada6bdd799942feb4" +dependencies = [ + "cfg-if", + "log", + "uefi", +] + +[[package]] +name = "uguid" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ef516f0806c5f61da6aa95125d0eb2d91cc95b2df426c06bde8be657282aee5" + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasm-bindgen" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.39", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" + +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "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_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[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_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[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_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[package]] +name = "zstd" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "6.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.9+zstd.1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..6de0363 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "cutieos" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +log = "0.4.20" +uefi = { version = "0.26.0", features = ["alloc"] } +uefi-services = { version = "0.23.0", features = ["logger"], default-features = false } +build-info = { version = "0.0.34", features = [], default-features = false } + +[build-dependencies] +build-info-build = "0.0.34"
\ No newline at end of file diff --git a/OVMF_CODE.fd b/OVMF_CODE.fd Binary files differnew file mode 100644 index 0000000..1c3d46f --- /dev/null +++ b/OVMF_CODE.fd diff --git a/OVMF_VARS.fd b/OVMF_VARS.fd Binary files differnew file mode 100644 index 0000000..efb4f46 --- /dev/null +++ b/OVMF_VARS.fd diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..6ed4499 --- /dev/null +++ b/build.rs @@ -0,0 +1,5 @@ +#![no_std] + +fn main() { + build_info_build::build_script(); +}
\ No newline at end of file diff --git a/esp/.DS_Store b/esp/.DS_Store Binary files differnew file mode 100644 index 0000000..8975e2a --- /dev/null +++ b/esp/.DS_Store diff --git a/esp/efi/.DS_Store b/esp/efi/.DS_Store Binary files differnew file mode 100644 index 0000000..68f40be --- /dev/null +++ b/esp/efi/.DS_Store diff --git a/esp/efi/boot/bootx64.efi b/esp/efi/boot/bootx64.efi Binary files differnew file mode 100755 index 0000000..934f24c --- /dev/null +++ b/esp/efi/boot/bootx64.efi diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..e756ee7 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +targets = ["aarch64-unknown-uefi", "i686-unknown-uefi", "x86_64-unknown-uefi"] diff --git a/src/boot.rs b/src/boot.rs new file mode 100644 index 0000000..96871e5 --- /dev/null +++ b/src/boot.rs @@ -0,0 +1,19 @@ +use log::info; +use crate::core::Toolkit; +use crate::shell::run_shell; + +pub fn start_boot(mut tk: Toolkit) { + info!("Welcome to CutieOS!"); + info!("Disabling boot watchdog"); + tk.disable_watchdog(); + + info!("Checking for system directory"); + if !tk.file_exists("CutieOS") { + tk.mkdir("CutieOS"); + } + tk.chdir("CutieOS"); + + info!("Handing over control to the userland"); + + run_shell(tk); +}
\ No newline at end of file diff --git a/src/core.rs b/src/core.rs new file mode 100644 index 0000000..9f0d376 --- /dev/null +++ b/src/core.rs @@ -0,0 +1,150 @@ +use alloc::string::{String, ToString}; +use alloc::vec; +use alloc::vec::Vec; +use uefi::{Char16, CStr16}; +use uefi::prelude::*; +use uefi::fs::Path; +use uefi::proto::console::text::{Key, ScanCode}; +use uefi::fs::FileSystem; + +pub static mut CPU_ARCHITECTURE: &str = "unknown"; + +pub struct ToolkitWorkingPath { + name: String +} + +pub struct Toolkit { + system_table: SystemTable<Boot>, + pub current_directory: ToolkitWorkingPath +} + +impl Toolkit { + pub fn new(system_table: SystemTable<Boot>) -> Self { + unsafe { + CPU_ARCHITECTURE = "unknown"; + + #[cfg(any(target_arch = "x86_64"))] { + CPU_ARCHITECTURE = "x86_64"; + } + + #[cfg(any(target_arch = "aarch64"))] { + CPU_ARCHITECTURE = "aarch64"; + } + } + + Self { + system_table, + current_directory: ToolkitWorkingPath { + name: String::from("") + } + } + } +} + +impl Toolkit { + pub fn prompt(&mut self) -> String { + let mut out: String = String::from(""); + + loop { + let mut events = [self.system_table.stdin().wait_for_key_event().unwrap()]; + self.system_table.boot_services() + .wait_for_event(&mut events) + .discard_errdata().expect("Failed to discard errors"); + + let ret = Char16::try_from('\r').unwrap(); + match self.system_table.stdin().read_key().expect("Failed to read key") { + Some(Key::Printable(key)) if key == ret => { + self.print("\r\n"); + return out; + } + + Some(Key::Printable(key)) => { + out += &key.to_string(); + self.print(&key.to_string()); + } + + Some(Key::Special(ScanCode::ESCAPE)) => { + panic!("Pressed Escape") + } + + _ => {} + } + } + } + + pub fn clear(&mut self) { + let stdout = self.system_table.stdout(); + stdout.reset(false).expect("Failed to clear screen buffer"); + } + + /*pub fn sleep(&mut self, time: usize) { + self.system_table.boot_services().stall(time * 1000); + }*/ + + pub fn get_cwd(&self) -> &str { + &self.current_directory.name + } + + pub fn chdir(&mut self, dir: &str) { + if !self.file_exists(dir) { + panic!("Attempted to change the working directory to a non-existent directory"); + } + + self.current_directory.name += "/"; + self.current_directory.name += dir; + } + + pub fn uefi_version(&mut self) -> String { + self.system_table.uefi_revision().to_string() + } + + pub fn uefi_vendor(&mut self) -> String { + self.system_table.firmware_vendor().to_string() + } + + pub fn uefi_revision(&mut self) -> u32 { + self.system_table.firmware_revision() + } + + pub fn uefi_arch(&mut self) -> String { + unsafe { + CPU_ARCHITECTURE.to_string() + } + } + + pub fn set_cursor(&mut self, state: bool) { + let stdout = self.system_table.stdout(); + stdout.enable_cursor(state).expect("Failed to change cursor state"); + } + + pub fn disable_watchdog(&self) { + self.system_table.boot_services().set_watchdog_timer(0, 65536, None).expect("Failed to disable the watchdog"); + } + + pub fn file_exists(&self, path: &str) -> bool { + let handle = self.system_table.boot_services().image_handle(); + let fs = self.system_table.boot_services().get_image_file_system(handle).expect("Failed to start up filesystem"); + let mut filesystem = FileSystem::new(fs); + let mut buf: Vec<u16> = vec![0; path.len() + 1]; + return filesystem.try_exists(&Path::new(&CStr16::from_str_with_buf("CutieOS", &mut buf).unwrap())).unwrap(); + } + + pub fn mkdir(&self, path: &str) { + let handle = self.system_table.boot_services().image_handle(); + let fs = self.system_table.boot_services().get_image_file_system(handle).expect("Failed to start up filesystem"); + let mut filesystem = FileSystem::new(fs); + let mut buf: Vec<u16> = vec![0; path.len() + 1]; + filesystem.create_dir(&Path::new(&CStr16::from_str_with_buf("CutieOS", &mut buf).unwrap())).unwrap(); + } + + pub fn print(&mut self, str: &str) { + let stdout = self.system_table.stdout(); + let mut buf = vec![0; str.len() + 1]; + stdout.output_string(CStr16::from_str_with_buf(str, &mut buf).expect("Failed to format text")).expect("Failed to print"); + } + + pub fn println(&mut self, str: &str) { + self.print(str); + self.print("\r\n"); + } +}
\ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..cf11852 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,37 @@ +#![no_main] +#![no_std] + +mod core; +mod panic; +mod shell; +mod boot; + +extern crate alloc; + +use alloc::format; +use uefi::prelude::*; +use core::*; +use crate::boot::start_boot; +use crate::panic::init_panic; + +#[entry] +fn main(_image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status { + unsafe { init_panic(system_table.unsafe_clone()); } + uefi_services::init(&mut system_table).unwrap(); + let mut tk = Toolkit::new(system_table); + + tk.clear(); + tk.println(&format!("CutieOS {} ({}, {})", build_info::format!("{}", $.crate_info.version), build_info::format!("{}", $.timestamp), build_info::format!("{}", $.compiler))); + + let uefi = tk.uefi_version(); + let vendor = tk.uefi_vendor(); + let revision = tk.uefi_revision(); + let arch = tk.uefi_arch(); + tk.println(&format!("UEFI {} ({}, rev. {}), {}", uefi, vendor, revision, arch)); + + tk.println(""); + tk.set_cursor(true); + + start_boot(tk); + loop {} +} diff --git a/src/panic.rs b/src/panic.rs new file mode 100644 index 0000000..fc7eea0 --- /dev/null +++ b/src/panic.rs @@ -0,0 +1,34 @@ +use alloc::string::{String, ToString}; +use alloc::{format, vec}; +use core::panic::PanicInfo; +use uefi::CStr16; +use uefi::prelude::{Boot, SystemTable}; + +static mut SYSTEM_TABLE: Option<SystemTable<Boot>> = None; + +pub fn init_panic(system_table: SystemTable<Boot>) { + unsafe { + SYSTEM_TABLE = Option::from(system_table.unsafe_clone()); + } + + #[panic_handler] + unsafe fn panic(info: &PanicInfo) -> ! { + match SYSTEM_TABLE.as_ref() { + None => {} + Some(system_table_ref) => { + let mut system_table = system_table_ref.unsafe_clone(); + let stdout = system_table.stdout(); + + let mut str = String::from("\r\n\r\n--------------------------------------------\r\nKERNEL PANIC!\r\n\r\n"); + str += &info.to_string().replace("\n", "\r\n"); + str += "\r\n\r\n"; + str += &format!("CutieOS {} ({}, {})", build_info::format!("{}", $.crate_info.version), build_info::format!("{}", $.timestamp), build_info::format!("{}", $.compiler)); + str += "\r\n--------------------------------------------\r\n"; + + let mut buf = vec![0; str.len() + 1]; + stdout.output_string(CStr16::from_str_with_buf(&str, &mut buf).expect("Failed to format text")).expect("Failed to print"); + } + } + loop {} + } +}
\ No newline at end of file diff --git a/src/shell.rs b/src/shell.rs new file mode 100644 index 0000000..a646c76 --- /dev/null +++ b/src/shell.rs @@ -0,0 +1,12 @@ +use alloc::format; +use crate::core::Toolkit; + +pub fn run_shell(mut tk: Toolkit) { + tk.println(""); + + loop { + tk.print(&format!("{}> ", tk.get_cwd())); + let text = &tk.prompt(); + tk.println(&format!("You said: {}", text)); + } +}
\ No newline at end of file |