From a5161881f6eed9fa64f5c82f2cb6b49a643a9e64 Mon Sep 17 00:00:00 2001 From: Mathieu Strypsteen Date: Fri, 11 Oct 2024 10:50:46 +0200 Subject: [PATCH] Use cargo workspace --- kernel/Cargo.lock => Cargo.lock | 126 ++++++++++++++++++++- Cargo.toml | 6 + build.sh | 2 +- kernel/.cargo/config.toml | 2 +- kernel/Cargo.toml | 3 - kernel/build.rs | 2 +- lib/kernel-common/Cargo.lock | 23 ---- loader/Cargo.lock | 192 -------------------------------- loader/Cargo.toml | 3 - loader/src/main.rs | 2 +- 10 files changed, 134 insertions(+), 227 deletions(-) rename kernel/Cargo.lock => Cargo.lock (78%) create mode 100644 Cargo.toml delete mode 100644 lib/kernel-common/Cargo.lock delete mode 100644 loader/Cargo.lock diff --git a/kernel/Cargo.lock b/Cargo.lock similarity index 78% rename from kernel/Cargo.lock rename to Cargo.lock index ab86769..2759d51 100644 --- a/kernel/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "alloc-traits" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b2d54853319fd101b8dd81de382bcbf3e03410a64d8928bbee85a3e7dcde483" + [[package]] name = "autocfg" version = "1.4.0" @@ -34,9 +40,15 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn", + "syn 2.0.79", ] +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + [[package]] name = "bitfield" version = "0.17.0" @@ -93,6 +105,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "elf" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4445909572dbd556c457c849c4ca58623d84b27c8fff1e74b0b4227d8b90d17b" + [[package]] name = "funty" version = "2.0.0" @@ -160,6 +178,17 @@ dependencies = [ "spinning_top", ] +[[package]] +name = "loader" +version = "0.0.1" +dependencies = [ + "elf", + "kernel-common", + "log", + "static-alloc", + "uefi", +] + [[package]] name = "lock_api" version = "0.4.12" @@ -205,7 +234,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn", + "syn 2.0.79", ] [[package]] @@ -217,6 +246,26 @@ 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.37" @@ -297,6 +346,26 @@ dependencies = [ "lock_api", ] +[[package]] +name = "static-alloc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2975e035ce16539eecee08d7c6e5626ca26f299c6e90af343b302c6dd2e61e" +dependencies = [ + "alloc-traits", +] + +[[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.79" @@ -314,6 +383,59 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "ucs2" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df79298e11f316400c57ec268f3c2c29ac3c4d4777687955cd3d4f3a35ce7eba" +dependencies = [ + "bit_field", +] + +[[package]] +name = "uefi" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91f17ea8502a6bd414acb2bf5194f90ca4c48e33a2d18cb57eab3294d2050d99" +dependencies = [ + "bitflags", + "cfg-if", + "log", + "ptr_meta", + "ucs2", + "uefi-macros", + "uefi-raw", + "uguid", +] + +[[package]] +name = "uefi-macros" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19ee3a01d435eda42cb9931269b349d28a1762f91ddf01c68d276f74b957cc3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "uefi-raw" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b463030b802e1265a3800fab24df95d3229c202c2e408832a206f05b4d1496ca" +dependencies = [ + "bitflags", + "ptr_meta", + "uguid", +] + +[[package]] +name = "uguid" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab14ea9660d240e7865ce9d54ecdbd1cd9fa5802ae6f4512f093c7907e921533" + [[package]] name = "unicode-ident" version = "1.0.13" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..87e0c17 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[workspace] +resolver = "2" +members = ["lib/kernel-common", "loader", "kernel"] + +[profile.release] +lto = true diff --git a/build.sh b/build.sh index 573b9e6..a630f55 100755 --- a/build.sh +++ b/build.sh @@ -5,7 +5,7 @@ mkdir -p img/boot/efi/boot cd lib/acpica-build && make -j4 && cd ../.. cd kernel && cargo build --release && cd .. cd loader && cargo build --release && cd .. -cp loader/target/x86_64-unknown-uefi/release/loader.efi img/boot/efi/boot/bootx64.efi +cp target/x86_64-unknown-uefi/release/loader.efi img/boot/efi/boot/bootx64.efi cd img dd if=/dev/zero of=boot.img bs=1M count=16 status=none mformat -i boot.img diff --git a/kernel/.cargo/config.toml b/kernel/.cargo/config.toml index 712c292..e161ebb 100644 --- a/kernel/.cargo/config.toml +++ b/kernel/.cargo/config.toml @@ -1,3 +1,3 @@ [build] target = "x86_64-unknown-none" -rustflags = ["-C", "link-arg=link.ld", "-C", "link-arg=-no-pie"] +rustflags = ["-C", "link-arg=kernel/link.ld", "-C", "link-arg=-no-pie"] diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index c561a50..37d864b 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -13,6 +13,3 @@ spin = "0.9.8" [build-dependencies] bindgen = "0.70.1" - -[profile.release] -lto = true diff --git a/kernel/build.rs b/kernel/build.rs index 93626a1..5596a5e 100644 --- a/kernel/build.rs +++ b/kernel/build.rs @@ -1,7 +1,7 @@ use bindgen::Builder; fn main() { - println!("cargo::rustc-link-search=../lib/acpica-build"); + println!("cargo::rustc-link-search=lib/acpica-build"); println!("cargo::rustc-link-lib=acpica"); let bindings = Builder::default() .use_core() diff --git a/lib/kernel-common/Cargo.lock b/lib/kernel-common/Cargo.lock deleted file mode 100644 index 61f1fe7..0000000 --- a/lib/kernel-common/Cargo.lock +++ /dev/null @@ -1,23 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "bitfield" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f798d2d157e547aa99aab0967df39edd0b70307312b6f8bd2848e6abe40896e0" - -[[package]] -name = "kernel-common" -version = "0.0.1" -dependencies = [ - "bitfield", - "log", -] - -[[package]] -name = "log" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" diff --git a/loader/Cargo.lock b/loader/Cargo.lock deleted file mode 100644 index 3db4783..0000000 --- a/loader/Cargo.lock +++ /dev/null @@ -1,192 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "alloc-traits" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b2d54853319fd101b8dd81de382bcbf3e03410a64d8928bbee85a3e7dcde483" - -[[package]] -name = "bit_field" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" - -[[package]] -name = "bitfield" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f798d2d157e547aa99aab0967df39edd0b70307312b6f8bd2848e6abe40896e0" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "elf" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4445909572dbd556c457c849c4ca58623d84b27c8fff1e74b0b4227d8b90d17b" - -[[package]] -name = "kernel-common" -version = "0.0.1" -dependencies = [ - "bitfield", - "log", -] - -[[package]] -name = "loader" -version = "0.0.1" -dependencies = [ - "elf", - "kernel-common", - "log", - "static-alloc", - "uefi", -] - -[[package]] -name = "log" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" - -[[package]] -name = "proc-macro2" -version = "1.0.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" -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.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "static-alloc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b2975e035ce16539eecee08d7c6e5626ca26f299c6e90af343b302c6dd2e61e" -dependencies = [ - "alloc-traits", -] - -[[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.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "ucs2" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df79298e11f316400c57ec268f3c2c29ac3c4d4777687955cd3d4f3a35ce7eba" -dependencies = [ - "bit_field", -] - -[[package]] -name = "uefi" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91f17ea8502a6bd414acb2bf5194f90ca4c48e33a2d18cb57eab3294d2050d99" -dependencies = [ - "bitflags", - "cfg-if", - "log", - "ptr_meta", - "ucs2", - "uefi-macros", - "uefi-raw", - "uguid", -] - -[[package]] -name = "uefi-macros" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19ee3a01d435eda42cb9931269b349d28a1762f91ddf01c68d276f74b957cc3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.79", -] - -[[package]] -name = "uefi-raw" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b463030b802e1265a3800fab24df95d3229c202c2e408832a206f05b4d1496ca" -dependencies = [ - "bitflags", - "ptr_meta", - "uguid", -] - -[[package]] -name = "uguid" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab14ea9660d240e7865ce9d54ecdbd1cd9fa5802ae6f4512f093c7907e921533" - -[[package]] -name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" diff --git a/loader/Cargo.toml b/loader/Cargo.toml index b455ad0..41140c5 100644 --- a/loader/Cargo.toml +++ b/loader/Cargo.toml @@ -9,6 +9,3 @@ kernel-common = {path = "../lib/kernel-common"} log = "0.4.22" static-alloc = "0.2.5" uefi = "0.32.0" - -[profile.release] -lto = true diff --git a/loader/src/main.rs b/loader/src/main.rs index 031da4a..e197ff4 100644 --- a/loader/src/main.rs +++ b/loader/src/main.rs @@ -36,7 +36,7 @@ mod paging; #[global_allocator] static ALLOC: Bump<[u8; 8 * 1024 * 1024]> = Bump::uninit(); -const KERNEL: &[u8] = include_bytes!("../../kernel/target/x86_64-unknown-none/release/kernel"); +const KERNEL: &[u8] = include_bytes!("../../target/x86_64-unknown-none/release/kernel"); #[entry] fn main() -> Status {