From a3aee581800316764692d492523b27b5d0153ba4 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 13 Nov 2022 22:09:32 +0100 Subject: [PATCH 01/21] Set version numbers --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 8 +++++++- api/Cargo.toml | 2 +- bios/boot_sector/Cargo.toml | 2 +- bios/common/Cargo.toml | 2 +- bios/stage-2/Cargo.toml | 4 ++-- bios/stage-3/Cargo.toml | 4 ++-- bios/stage-4/Cargo.toml | 8 ++++---- common/Cargo.toml | 4 ++-- uefi/Cargo.toml | 6 +++--- 10 files changed, 32 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6db246ac..7865abdd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,7 +55,7 @@ dependencies = [ [[package]] name = "bootloader" -version = "0.11.0-alpha" +version = "0.11.0-beta" dependencies = [ "anyhow", "bootloader_test_runner", @@ -72,15 +72,15 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-boot-sector" -version = "0.1.0" +version = "0.1.0-beta" [[package]] name = "bootloader-x86_64-bios-common" -version = "0.1.0" +version = "0.1.0-beta" [[package]] name = "bootloader-x86_64-bios-stage-2" -version = "0.1.0" +version = "0.1.0-beta" dependencies = [ "bootloader-x86_64-bios-common", "byteorder", @@ -89,7 +89,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-stage-3" -version = "0.1.0" +version = "0.1.0-beta" dependencies = [ "bootloader-x86_64-bios-common", "noto-sans-mono-bitmap 0.1.6", @@ -97,7 +97,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-stage-4" -version = "0.1.0-alpha.0" +version = "0.11.0-beta" dependencies = [ "bootloader-x86_64-bios-common", "bootloader-x86_64-common", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-common" -version = "0.1.0-alpha.0" +version = "0.11.0-beta" dependencies = [ "bootloader_api", "conquer-once", @@ -127,7 +127,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-uefi" -version = "0.1.0-alpha.0" +version = "0.11.0-beta" dependencies = [ "bootloader-x86_64-common", "bootloader_api", @@ -138,7 +138,7 @@ dependencies = [ [[package]] name = "bootloader_api" -version = "0.1.0-alpha.0" +version = "0.11.0-beta" dependencies = [ "rand", ] diff --git a/Cargo.toml b/Cargo.toml index 0f3e49c3..3e025e39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ cargo-features = ["profile-rustflags"] [package] name = "bootloader" -version = "0.11.0-alpha" +version.workspace = true authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental x86_64 bootloader that works on both BIOS and UEFI systems." @@ -26,6 +26,12 @@ members = [ ] exclude = ["examples/basic", "examples/test_framework"] +[workspace.package] +version = "0.11.0-beta" + +[workspace.dependencies] +bootloader_api = { version = "0.11.0-beta", path = "api" } +bootloader-x86_64-common = { version = "0.11.0-beta", path = "common" } [dependencies] anyhow = "1.0.32" diff --git a/api/Cargo.toml b/api/Cargo.toml index a2fe956f..5b5c004b 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader_api" -version = "0.1.0-alpha.0" +version.workspace = true edition = "2021" description = "Makes a kernel compatible with the bootloader crate" license = "MIT/Apache-2.0" diff --git a/bios/boot_sector/Cargo.toml b/bios/boot_sector/Cargo.toml index 620a036f..9830c79e 100644 --- a/bios/boot_sector/Cargo.toml +++ b/bios/boot_sector/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader-x86_64-bios-boot-sector" -version = "0.1.0" +version = "0.1.0-beta" authors = ["Philipp Oppermann "] edition = "2021" diff --git a/bios/common/Cargo.toml b/bios/common/Cargo.toml index fedddfc8..94143122 100644 --- a/bios/common/Cargo.toml +++ b/bios/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader-x86_64-bios-common" -version = "0.1.0" +version = "0.1.0-beta" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bios/stage-2/Cargo.toml b/bios/stage-2/Cargo.toml index f70bf2b4..fc05b401 100644 --- a/bios/stage-2/Cargo.toml +++ b/bios/stage-2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader-x86_64-bios-stage-2" -version = "0.1.0" +version = "0.1.0-beta" authors = ["Philipp Oppermann "] edition = "2021" @@ -9,4 +9,4 @@ edition = "2021" [dependencies] mbr-nostd = "0.1.0" byteorder = { version = "1.4.3", default-features = false } -bootloader-x86_64-bios-common = { version = "0.1.0", path = "../common" } +bootloader-x86_64-bios-common = { version = "0.1.0-beta", path = "../common" } diff --git a/bios/stage-3/Cargo.toml b/bios/stage-3/Cargo.toml index bd606566..bbc033a9 100644 --- a/bios/stage-3/Cargo.toml +++ b/bios/stage-3/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "bootloader-x86_64-bios-stage-3" -version = "0.1.0" +version = "0.1.0-beta" authors = ["Philipp Oppermann "] edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bootloader-x86_64-bios-common = { version = "0.1.0", path = "../common" } +bootloader-x86_64-bios-common = { version = "0.1.0-beta", path = "../common" } noto-sans-mono-bitmap = "0.1.5" diff --git a/bios/stage-4/Cargo.toml b/bios/stage-4/Cargo.toml index ad3aac08..6a8f4c4e 100644 --- a/bios/stage-4/Cargo.toml +++ b/bios/stage-4/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "bootloader-x86_64-bios-stage-4" -version = "0.1.0-alpha.0" +version.workspace = true edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bootloader_api = { version = "0.1.0-alpha.0", path = "../../api" } -bootloader-x86_64-bios-common = { version = "0.1.0", path = "../common" } -bootloader-x86_64-common = { version = "0.1.0-alpha.0", path = "../../common" } +bootloader_api = { workspace = true } +bootloader-x86_64-common = { workspace = true } +bootloader-x86_64-bios-common = { version = "0.1.0-beta", path = "../common" } log = "0.4.14" x86_64 = "0.14.8" rsdp = "2.0.0" diff --git a/common/Cargo.toml b/common/Cargo.toml index 67c3505c..09b7d873 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader-x86_64-common" -version = "0.1.0-alpha.0" +version.workspace = true edition = "2021" description = "Common code for the x86_64 bootloader implementations" license = "MIT/Apache-2.0" @@ -8,7 +8,7 @@ license = "MIT/Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bootloader_api = { version = "0.1.0-alpha.0", path = "../api" } +bootloader_api = { workspace = true } conquer-once = { version = "0.3.2", default-features = false } log = "0.4.14" spinning_top = "0.2.4" diff --git a/uefi/Cargo.toml b/uefi/Cargo.toml index 109b9298..aafc558a 100644 --- a/uefi/Cargo.toml +++ b/uefi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader-x86_64-uefi" -version = "0.1.0-alpha.0" +version.workspace = true edition = "2021" description = "UEFI bootloader for x86_64" license = "MIT/Apache-2.0" @@ -8,8 +8,8 @@ license = "MIT/Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bootloader_api = { version = "0.1.0-alpha.0", path = "../api" } -bootloader-x86_64-common = { version = "0.1.0-alpha.0", path = "../common" } +bootloader_api = { workspace = true } +bootloader-x86_64-common = { workspace = true } log = "0.4.14" uefi = "0.16.0" x86_64 = "0.14.8" From e97fa4f78d802d854d3c3970068579b1e960cbd5 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 13 Nov 2022 22:13:28 +0100 Subject: [PATCH 02/21] Set license and repository link for all crates --- Cargo.toml | 8 +++++--- api/Cargo.toml | 3 ++- bios/boot_sector/Cargo.toml | 2 ++ bios/common/Cargo.toml | 2 ++ bios/stage-2/Cargo.toml | 2 ++ bios/stage-3/Cargo.toml | 2 ++ bios/stage-4/Cargo.toml | 2 ++ common/Cargo.toml | 3 ++- uefi/Cargo.toml | 3 ++- 9 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3e025e39..96dd6267 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,11 +2,11 @@ cargo-features = ["profile-rustflags"] [package] name = "bootloader" +description = "An experimental x86_64 bootloader that works on both BIOS and UEFI systems." +license.workspace = true version.workspace = true +repository.workspace = true authors = ["Philipp Oppermann "] -license = "MIT/Apache-2.0" -description = "An experimental x86_64 bootloader that works on both BIOS and UEFI systems." -repository = "https://github.com/rust-osdev/bootloader" edition = "2021" [workspace] @@ -28,6 +28,8 @@ exclude = ["examples/basic", "examples/test_framework"] [workspace.package] version = "0.11.0-beta" +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-osdev/bootloader" [workspace.dependencies] bootloader_api = { version = "0.11.0-beta", path = "api" } diff --git a/api/Cargo.toml b/api/Cargo.toml index 5b5c004b..ef687b0c 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -1,9 +1,10 @@ [package] name = "bootloader_api" +license.workspace = true version.workspace = true +repository.workspace = true edition = "2021" description = "Makes a kernel compatible with the bootloader crate" -license = "MIT/Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bios/boot_sector/Cargo.toml b/bios/boot_sector/Cargo.toml index 9830c79e..8a15cf3d 100644 --- a/bios/boot_sector/Cargo.toml +++ b/bios/boot_sector/Cargo.toml @@ -3,6 +3,8 @@ name = "bootloader-x86_64-bios-boot-sector" version = "0.1.0-beta" authors = ["Philipp Oppermann "] edition = "2021" +license.workspace = true +repository.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bios/common/Cargo.toml b/bios/common/Cargo.toml index 94143122..d360c922 100644 --- a/bios/common/Cargo.toml +++ b/bios/common/Cargo.toml @@ -2,6 +2,8 @@ name = "bootloader-x86_64-bios-common" version = "0.1.0-beta" edition = "2021" +license.workspace = true +repository.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bios/stage-2/Cargo.toml b/bios/stage-2/Cargo.toml index fc05b401..ec5bbfdc 100644 --- a/bios/stage-2/Cargo.toml +++ b/bios/stage-2/Cargo.toml @@ -3,6 +3,8 @@ name = "bootloader-x86_64-bios-stage-2" version = "0.1.0-beta" authors = ["Philipp Oppermann "] edition = "2021" +license.workspace = true +repository.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bios/stage-3/Cargo.toml b/bios/stage-3/Cargo.toml index bbc033a9..8a4a3624 100644 --- a/bios/stage-3/Cargo.toml +++ b/bios/stage-3/Cargo.toml @@ -3,6 +3,8 @@ name = "bootloader-x86_64-bios-stage-3" version = "0.1.0-beta" authors = ["Philipp Oppermann "] edition = "2021" +license.workspace = true +repository.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bios/stage-4/Cargo.toml b/bios/stage-4/Cargo.toml index 6a8f4c4e..54c615f8 100644 --- a/bios/stage-4/Cargo.toml +++ b/bios/stage-4/Cargo.toml @@ -2,6 +2,8 @@ name = "bootloader-x86_64-bios-stage-4" version.workspace = true edition = "2021" +license.workspace = true +repository.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/common/Cargo.toml b/common/Cargo.toml index 09b7d873..0d84c5f5 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -3,7 +3,8 @@ name = "bootloader-x86_64-common" version.workspace = true edition = "2021" description = "Common code for the x86_64 bootloader implementations" -license = "MIT/Apache-2.0" +license.workspace = true +repository.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/uefi/Cargo.toml b/uefi/Cargo.toml index aafc558a..a2dfe632 100644 --- a/uefi/Cargo.toml +++ b/uefi/Cargo.toml @@ -3,7 +3,8 @@ name = "bootloader-x86_64-uefi" version.workspace = true edition = "2021" description = "UEFI bootloader for x86_64" -license = "MIT/Apache-2.0" +license.workspace = true +repository.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 852320fd78598bee7084a459371a9a70e5ad4caf Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 13 Nov 2022 22:14:55 +0100 Subject: [PATCH 03/21] Add a description for BIOS boot sector crate --- bios/boot_sector/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/bios/boot_sector/Cargo.toml b/bios/boot_sector/Cargo.toml index 8a15cf3d..c87c7e80 100644 --- a/bios/boot_sector/Cargo.toml +++ b/bios/boot_sector/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Philipp Oppermann "] edition = "2021" license.workspace = true repository.workspace = true +description = "BIOS boot sector for the `bootloader` crate" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From c920a5a5072c5d0e94279919c7db94723f059374 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 13 Nov 2022 22:22:48 +0100 Subject: [PATCH 04/21] Duplicate profile in sub-crate for publishing --- Cargo.lock | 2 +- Cargo.toml | 1 + bios/boot_sector/Cargo.toml | 12 +++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7865abdd..2770b28e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,7 +72,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-boot-sector" -version = "0.1.0-beta" +version = "0.1.0-beta.1" [[package]] name = "bootloader-x86_64-bios-common" diff --git a/Cargo.toml b/Cargo.toml index 96dd6267..8285dba0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,6 +58,7 @@ lto = false debug = true overflow-checks = true +# duplicated from `bios/boot_sector/Cargo.toml` [profile.stage-1] inherits = "release" opt-level = "s" diff --git a/bios/boot_sector/Cargo.toml b/bios/boot_sector/Cargo.toml index c87c7e80..1670b356 100644 --- a/bios/boot_sector/Cargo.toml +++ b/bios/boot_sector/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader-x86_64-bios-boot-sector" -version = "0.1.0-beta" +version = "0.1.0-beta.1" authors = ["Philipp Oppermann "] edition = "2021" license.workspace = true @@ -10,3 +10,13 @@ description = "BIOS boot sector for the `bootloader` crate" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] + +# This currently causes a cargo warning, but it is required for publishing to crates.io. +# See https://github.com/rust-lang/cargo/issues/8264 for details. +[profile.stage-1] +inherits = "release" +opt-level = "s" +lto = true +codegen-units = 1 +debug = false +overflow-checks = false From c09aca850bf5cc6490710c672b20786bbcde6f40 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 13 Nov 2022 22:33:53 +0100 Subject: [PATCH 05/21] Add descriptions for BIOS crates --- bios/common/Cargo.toml | 1 + bios/stage-2/Cargo.toml | 1 + bios/stage-3/Cargo.toml | 1 + bios/stage-4/Cargo.toml | 1 + 4 files changed, 4 insertions(+) diff --git a/bios/common/Cargo.toml b/bios/common/Cargo.toml index d360c922..f7f7d7da 100644 --- a/bios/common/Cargo.toml +++ b/bios/common/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0-beta" edition = "2021" license.workspace = true repository.workspace = true +description = "Common code for BIOS stages of the `bootloader` crate" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bios/stage-2/Cargo.toml b/bios/stage-2/Cargo.toml index ec5bbfdc..cbf07e64 100644 --- a/bios/stage-2/Cargo.toml +++ b/bios/stage-2/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Philipp Oppermann "] edition = "2021" license.workspace = true repository.workspace = true +description = "Second BIOS stage of the `bootloader` crate" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bios/stage-3/Cargo.toml b/bios/stage-3/Cargo.toml index 8a4a3624..eb1b493e 100644 --- a/bios/stage-3/Cargo.toml +++ b/bios/stage-3/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Philipp Oppermann "] edition = "2021" license.workspace = true repository.workspace = true +description = "Third BIOS stage of the `bootloader` crate" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bios/stage-4/Cargo.toml b/bios/stage-4/Cargo.toml index 54c615f8..8d75a53c 100644 --- a/bios/stage-4/Cargo.toml +++ b/bios/stage-4/Cargo.toml @@ -4,6 +4,7 @@ version.workspace = true edition = "2021" license.workspace = true repository.workspace = true +description = "Fourth BIOS stage of the `bootloader` crate" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 2572926892be39dfac4117cc63f1336c69e6fb9a Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 13 Nov 2022 22:36:16 +0100 Subject: [PATCH 06/21] Duplicate profile sections in BIOS sub-crate for publishing --- Cargo.toml | 3 +++ bios/stage-2/Cargo.toml | 9 +++++++++ bios/stage-3/Cargo.toml | 7 +++++++ bios/stage-4/Cargo.toml | 7 +++++++ 4 files changed, 26 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 8285dba0..8b43455b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,6 +67,7 @@ codegen-units = 1 debug = false overflow-checks = false +# duplicated from `bios/stage-2/Cargo.toml` [profile.stage-2] inherits = "release" opt-level = "s" @@ -74,11 +75,13 @@ codegen-units = 1 debug = false overflow-checks = true +# duplicated from `bios/stage-3/Cargo.toml` [profile.stage-3] inherits = "release" debug = true overflow-checks = true +# duplicated from `bios/stage-4/Cargo.toml` [profile.stage-4] inherits = "release" debug = true diff --git a/bios/stage-2/Cargo.toml b/bios/stage-2/Cargo.toml index cbf07e64..d36b4078 100644 --- a/bios/stage-2/Cargo.toml +++ b/bios/stage-2/Cargo.toml @@ -13,3 +13,12 @@ description = "Second BIOS stage of the `bootloader` crate" mbr-nostd = "0.1.0" byteorder = { version = "1.4.3", default-features = false } bootloader-x86_64-bios-common = { version = "0.1.0-beta", path = "../common" } + +# This currently causes a cargo warning, but it is required for publishing to crates.io. +# See https://github.com/rust-lang/cargo/issues/8264 for details. +[profile.stage-2] +inherits = "release" +opt-level = "s" +codegen-units = 1 +debug = false +overflow-checks = true diff --git a/bios/stage-3/Cargo.toml b/bios/stage-3/Cargo.toml index eb1b493e..5f59c2f2 100644 --- a/bios/stage-3/Cargo.toml +++ b/bios/stage-3/Cargo.toml @@ -12,3 +12,10 @@ description = "Third BIOS stage of the `bootloader` crate" [dependencies] bootloader-x86_64-bios-common = { version = "0.1.0-beta", path = "../common" } noto-sans-mono-bitmap = "0.1.5" + +# This currently causes a cargo warning, but it is required for publishing to crates.io. +# See https://github.com/rust-lang/cargo/issues/8264 for details. +[profile.stage-3] +inherits = "release" +debug = true +overflow-checks = true diff --git a/bios/stage-4/Cargo.toml b/bios/stage-4/Cargo.toml index 8d75a53c..6a3d8bba 100644 --- a/bios/stage-4/Cargo.toml +++ b/bios/stage-4/Cargo.toml @@ -16,3 +16,10 @@ log = "0.4.14" x86_64 = "0.14.8" rsdp = "2.0.0" usize_conversions = "0.2.0" + +# This currently causes a cargo warning, but it is required for publishing to crates.io. +# See https://github.com/rust-lang/cargo/issues/8264 for details. +[profile.stage-4] +inherits = "release" +debug = true +overflow-checks = true From b285e67014a2f1be949d39cc32ea51c5e391e696 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 13 Nov 2022 22:45:53 +0100 Subject: [PATCH 07/21] Update dependency versions in build script --- build.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.rs b/build.rs index 979050ed..f628be0e 100644 --- a/build.rs +++ b/build.rs @@ -3,12 +3,12 @@ use std::{ process::Command, }; -const BOOTLOADER_X86_64_UEFI_VERSION: &str = "0.1.0-alpha.0"; +const BOOTLOADER_X86_64_UEFI_VERSION: &str = "0.11.0-beta"; -const BOOTLOADER_X86_64_BIOS_BOOT_SECTOR_VERSION: &str = "0.1.0-alpha.0"; -const BOOTLOADER_X86_64_BIOS_STAGE_2_VERSION: &str = "0.1.0-alpha.0"; -const BOOTLOADER_X86_64_BIOS_STAGE_3_VERSION: &str = "0.1.0-alpha.0"; -const BOOTLOADER_X86_64_BIOS_STAGE_4_VERSION: &str = "0.1.0-alpha.0"; +const BOOTLOADER_X86_64_BIOS_BOOT_SECTOR_VERSION: &str = "0.1.0-beta.1"; +const BOOTLOADER_X86_64_BIOS_STAGE_2_VERSION: &str = "0.1.0-beta"; +const BOOTLOADER_X86_64_BIOS_STAGE_3_VERSION: &str = "0.1.0-beta"; +const BOOTLOADER_X86_64_BIOS_STAGE_4_VERSION: &str = "0.11.0-beta"; fn main() { let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); From 6ae16606bfa32bb84f9b8ba5897201ee1aae5974 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 14 Nov 2022 10:07:34 +0100 Subject: [PATCH 08/21] Set up dummy build script for docs.rs Docs.rs has no network access, so we can't `cargo install` the binary dependencies. This is not required for doc generation, so we trick our way around that issue by providing a dummy build script just for docs.rs. --- Cargo.toml | 2 +- build.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8b43455b..9cac3020 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -105,7 +105,7 @@ rustflags = [ llvm-tools = "0.1.1" [package.metadata.docs.rs] -default-target = "x86_64-unknown-linux-gnu" +rustc-args = ["--cfg", "docsrs_dummy_build"] [package.metadata.release] dev-version = false diff --git a/build.rs b/build.rs index f628be0e..6259ed71 100644 --- a/build.rs +++ b/build.rs @@ -46,6 +46,7 @@ fn main() { ); } +#[cfg(not(docsrs_dummy_build))] fn build_uefi_bootloader(out_dir: &Path) -> PathBuf { let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into()); let mut cmd = Command::new(cargo); @@ -79,6 +80,7 @@ fn build_uefi_bootloader(out_dir: &Path) -> PathBuf { } } +#[cfg(not(docsrs_dummy_build))] fn build_bios_boot_sector(out_dir: &Path) -> PathBuf { let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into()); let mut cmd = Command::new(cargo); @@ -121,6 +123,7 @@ fn build_bios_boot_sector(out_dir: &Path) -> PathBuf { convert_elf_to_bin(elf_path) } +#[cfg(not(docsrs_dummy_build))] fn build_bios_stage_2(out_dir: &Path) -> PathBuf { let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into()); let mut cmd = Command::new(cargo); @@ -161,6 +164,7 @@ fn build_bios_stage_2(out_dir: &Path) -> PathBuf { convert_elf_to_bin(elf_path) } +#[cfg(not(docsrs_dummy_build))] fn build_bios_stage_3(out_dir: &Path) -> PathBuf { let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into()); let mut cmd = Command::new(cargo); @@ -201,6 +205,7 @@ fn build_bios_stage_3(out_dir: &Path) -> PathBuf { convert_elf_to_bin(elf_path) } +#[cfg(not(docsrs_dummy_build))] fn build_bios_stage_4(out_dir: &Path) -> PathBuf { let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into()); let mut cmd = Command::new(cargo); @@ -268,3 +273,26 @@ fn convert_elf_to_bin(elf_path: PathBuf) -> PathBuf { } flat_binary_path } + +// dummy implementations because docsrs builds have no network access + +#[cfg(docsrs_dummy_build)] +fn build_uefi_bootloader(_out_dir: &Path) -> PathBuf { + PathBuf::new() +} +#[cfg(docsrs_dummy_build)] +fn build_bios_boot_sector(_out_dir: &Path) -> PathBuf { + PathBuf::new() +} +#[cfg(docsrs_dummy_build)] +fn build_bios_stage_2(_out_dir: &Path) -> PathBuf { + PathBuf::new() +} +#[cfg(docsrs_dummy_build)] +fn build_bios_stage_3(_out_dir: &Path) -> PathBuf { + PathBuf::new() +} +#[cfg(docsrs_dummy_build)] +fn build_bios_stage_4(_out_dir: &Path) -> PathBuf { + PathBuf::new() +} From c242c84209922b81d5fd8114830aff00d51fd478 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 14 Nov 2022 10:35:54 +0100 Subject: [PATCH 09/21] Bump version to v0.11.0-beta.1 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2770b28e..029f7b61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,7 +55,7 @@ dependencies = [ [[package]] name = "bootloader" -version = "0.11.0-beta" +version = "0.11.0-beta.1" dependencies = [ "anyhow", "bootloader_test_runner", diff --git a/Cargo.toml b/Cargo.toml index 9cac3020..873b7a3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ cargo-features = ["profile-rustflags"] name = "bootloader" description = "An experimental x86_64 bootloader that works on both BIOS and UEFI systems." license.workspace = true -version.workspace = true +version = "0.11.0-beta.1" repository.workspace = true authors = ["Philipp Oppermann "] edition = "2021" From 4c5a4a04fc3d9066b65f76d7a45c513ca90a38c2 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sat, 26 Nov 2022 14:44:27 +0100 Subject: [PATCH 10/21] Shrink down boot sector Fixes the build on the latest Rust nightlies, which apparently generate slightly bigger code than older nightlies. --- bios/boot_sector/src/main.rs | 17 +++-------------- bios/boot_sector/src/mbr.rs | 7 +------ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/bios/boot_sector/src/main.rs b/bios/boot_sector/src/main.rs index 251495aa..ab10922e 100644 --- a/bios/boot_sector/src/main.rs +++ b/bios/boot_sector/src/main.rs @@ -2,11 +2,8 @@ #![no_main] #![warn(unsafe_op_in_unsafe_fn)] -use core::{ - arch::{asm, global_asm}, - slice, -}; -use fail::{print_char, UnwrapOrFail}; +use core::{arch::global_asm, slice}; +use fail::UnwrapOrFail; global_asm!(include_str!("boot.s")); @@ -31,12 +28,10 @@ fn second_stage_start() -> *const () { #[no_mangle] pub extern "C" fn first_stage(disk_number: u16) { // read partition table and look for second stage partition - print_char(b'1'); let partition_table = unsafe { slice::from_raw_parts(partition_table_raw(), 16 * 4) }; let second_stage_partition = mbr::get_partition(partition_table, 0); // load second stage partition into memory - print_char(b'2'); let entry_point_address = second_stage_start() as u32; let mut start_lba = second_stage_partition.logical_block_address.into(); @@ -65,18 +60,12 @@ pub extern "C" fn first_stage(disk_number: u16) { } // jump to second stage - print_char(b'3'); let second_stage_entry_point: extern "C" fn( disk_number: u16, partition_table_start: *const u8, ) = unsafe { core::mem::transmute(entry_point_address as *const ()) }; let partition_table_start = unsafe { partition_table_raw() }; second_stage_entry_point(disk_number, partition_table_start); - for _ in 0..10 { - print_char(b'R'); - } - loop { - unsafe { asm!("hlt") } - } + fail::fail(b'R'); } diff --git a/bios/boot_sector/src/mbr.rs b/bios/boot_sector/src/mbr.rs index 39b1c756..1f7eed52 100644 --- a/bios/boot_sector/src/mbr.rs +++ b/bios/boot_sector/src/mbr.rs @@ -1,13 +1,8 @@ -use super::fail::{fail, UnwrapOrFail}; +use super::fail::UnwrapOrFail; pub(crate) fn get_partition(partitions_raw: &[u8], index: usize) -> PartitionTableEntry { - const PARTITIONS_AREA_SIZE: usize = 16 * 4; const ENTRY_SIZE: usize = 16; - if partitions_raw.len() < PARTITIONS_AREA_SIZE { - fail(b'a'); - } - let offset = index * ENTRY_SIZE; let buffer = partitions_raw.get(offset..).unwrap_or_fail(b'c'); From 11736be598ff786b2c86cda5144627768d838953 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sat, 26 Nov 2022 14:52:34 +0100 Subject: [PATCH 11/21] Remove some `rerun-if-changed` commands to fix #286 --- build.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/build.rs b/build.rs index 6259ed71..bed36b82 100644 --- a/build.rs +++ b/build.rs @@ -12,9 +12,6 @@ const BOOTLOADER_X86_64_BIOS_STAGE_4_VERSION: &str = "0.11.0-beta"; fn main() { let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); - println!("cargo:rerun-if-changed=build.rs"); - println!("cargo:rerun-if-changed=Cargo.toml"); - println!("cargo:rerun-if-changed=Cargo.lock"); let uefi_path = build_uefi_bootloader(&out_dir); println!( From 148009899275c52b26be8dce7ae48e28018ef266 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 27 Nov 2022 17:35:25 +0100 Subject: [PATCH 12/21] Use unified version across all sub-crates to simplify release process --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 9 +++++---- bios/boot_sector/Cargo.toml | 2 +- bios/common/Cargo.toml | 2 +- bios/stage-2/Cargo.toml | 4 ++-- bios/stage-3/Cargo.toml | 4 ++-- bios/stage-4/Cargo.toml | 2 +- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 029f7b61..d20b3d1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,15 +72,15 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-boot-sector" -version = "0.1.0-beta.1" +version = "0.11.0-beta.1" [[package]] name = "bootloader-x86_64-bios-common" -version = "0.1.0-beta" +version = "0.11.0-beta.1" [[package]] name = "bootloader-x86_64-bios-stage-2" -version = "0.1.0-beta" +version = "0.11.0-beta.1" dependencies = [ "bootloader-x86_64-bios-common", "byteorder", @@ -89,7 +89,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-stage-3" -version = "0.1.0-beta" +version = "0.11.0-beta.1" dependencies = [ "bootloader-x86_64-bios-common", "noto-sans-mono-bitmap 0.1.6", @@ -97,7 +97,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-stage-4" -version = "0.11.0-beta" +version = "0.11.0-beta.1" dependencies = [ "bootloader-x86_64-bios-common", "bootloader-x86_64-common", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-common" -version = "0.11.0-beta" +version = "0.11.0-beta.1" dependencies = [ "bootloader_api", "conquer-once", @@ -127,7 +127,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-uefi" -version = "0.11.0-beta" +version = "0.11.0-beta.1" dependencies = [ "bootloader-x86_64-common", "bootloader_api", @@ -138,7 +138,7 @@ dependencies = [ [[package]] name = "bootloader_api" -version = "0.11.0-beta" +version = "0.11.0-beta.1" dependencies = [ "rand", ] diff --git a/Cargo.toml b/Cargo.toml index 873b7a3e..d24c4f54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ cargo-features = ["profile-rustflags"] name = "bootloader" description = "An experimental x86_64 bootloader that works on both BIOS and UEFI systems." license.workspace = true -version = "0.11.0-beta.1" +version.workspace = true repository.workspace = true authors = ["Philipp Oppermann "] edition = "2021" @@ -27,13 +27,14 @@ members = [ exclude = ["examples/basic", "examples/test_framework"] [workspace.package] -version = "0.11.0-beta" +version = "0.11.0-beta.1" license = "MIT/Apache-2.0" repository = "https://github.com/rust-osdev/bootloader" [workspace.dependencies] -bootloader_api = { version = "0.11.0-beta", path = "api" } -bootloader-x86_64-common = { version = "0.11.0-beta", path = "common" } +bootloader_api = { version = "0.11.0-beta.1", path = "api" } +bootloader-x86_64-common = { version = "0.11.0-beta.1", path = "common" } +bootloader-x86_64-bios-common = { version = "0.11.0-beta.1", path = "bios/common" } [dependencies] anyhow = "1.0.32" diff --git a/bios/boot_sector/Cargo.toml b/bios/boot_sector/Cargo.toml index 1670b356..ca870600 100644 --- a/bios/boot_sector/Cargo.toml +++ b/bios/boot_sector/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader-x86_64-bios-boot-sector" -version = "0.1.0-beta.1" +version.workspace = true authors = ["Philipp Oppermann "] edition = "2021" license.workspace = true diff --git a/bios/common/Cargo.toml b/bios/common/Cargo.toml index f7f7d7da..0417d017 100644 --- a/bios/common/Cargo.toml +++ b/bios/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader-x86_64-bios-common" -version = "0.1.0-beta" +version.workspace = true edition = "2021" license.workspace = true repository.workspace = true diff --git a/bios/stage-2/Cargo.toml b/bios/stage-2/Cargo.toml index d36b4078..4e39accb 100644 --- a/bios/stage-2/Cargo.toml +++ b/bios/stage-2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader-x86_64-bios-stage-2" -version = "0.1.0-beta" +version.workspace = true authors = ["Philipp Oppermann "] edition = "2021" license.workspace = true @@ -12,7 +12,7 @@ description = "Second BIOS stage of the `bootloader` crate" [dependencies] mbr-nostd = "0.1.0" byteorder = { version = "1.4.3", default-features = false } -bootloader-x86_64-bios-common = { version = "0.1.0-beta", path = "../common" } +bootloader-x86_64-bios-common = { workspace = true } # This currently causes a cargo warning, but it is required for publishing to crates.io. # See https://github.com/rust-lang/cargo/issues/8264 for details. diff --git a/bios/stage-3/Cargo.toml b/bios/stage-3/Cargo.toml index 5f59c2f2..9db2bcce 100644 --- a/bios/stage-3/Cargo.toml +++ b/bios/stage-3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader-x86_64-bios-stage-3" -version = "0.1.0-beta" +version.workspace = true authors = ["Philipp Oppermann "] edition = "2021" license.workspace = true @@ -10,7 +10,7 @@ description = "Third BIOS stage of the `bootloader` crate" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bootloader-x86_64-bios-common = { version = "0.1.0-beta", path = "../common" } +bootloader-x86_64-bios-common = { workspace = true } noto-sans-mono-bitmap = "0.1.5" # This currently causes a cargo warning, but it is required for publishing to crates.io. diff --git a/bios/stage-4/Cargo.toml b/bios/stage-4/Cargo.toml index 6a3d8bba..c02209fb 100644 --- a/bios/stage-4/Cargo.toml +++ b/bios/stage-4/Cargo.toml @@ -11,7 +11,7 @@ description = "Fourth BIOS stage of the `bootloader` crate" [dependencies] bootloader_api = { workspace = true } bootloader-x86_64-common = { workspace = true } -bootloader-x86_64-bios-common = { version = "0.1.0-beta", path = "../common" } +bootloader-x86_64-bios-common = { workspace = true } log = "0.4.14" x86_64 = "0.14.8" rsdp = "2.0.0" From aed94625defe6b8060231c15d1ba094e2df93250 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 27 Nov 2022 17:52:18 +0100 Subject: [PATCH 13/21] Add a release CI job --- .github/workflows/release.yml | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..b9e7e7f9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: Release + +on: + release: + types: + - published + +jobs: + release: + name: "Release" + runs-on: ubuntu-latest + timeout-minutes: 15 + environment: crates_io_release + + steps: + - name: "Checkout Repository" + uses: actions/checkout@v1 + + - run: cargo publish -p bootloader_api + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + - run: cargo publish -p bootloader-x86_64-bios-common + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + - run: cargo publish -p bootloader-x86_64-common + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + - run: cargo publish -p bootloader-x86_64-bios-boot-sector --no-verify + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + - run: cargo publish -p bootloader-x86_64-bios-stage-2 --no-verify + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + - run: cargo publish -p bootloader-x86_64-bios-stage-3 --no-verify + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + - run: cargo publish -p bootloader-x86_64-bios-stage-4 --no-verify + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + - run: cargo publish -p bootloader-x86_64-uefi --no-verify + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + - run: cargo publish -p bootloader + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} From c15405cd74c229108a56f5ae8e200441e5643121 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 27 Nov 2022 17:54:19 +0100 Subject: [PATCH 14/21] Bump version to v0.11.0-beta.2 --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d20b3d1c..ac4a12ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,7 +55,7 @@ dependencies = [ [[package]] name = "bootloader" -version = "0.11.0-beta.1" +version = "0.11.0-beta.2" dependencies = [ "anyhow", "bootloader_test_runner", @@ -72,15 +72,15 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-boot-sector" -version = "0.11.0-beta.1" +version = "0.11.0-beta.2" [[package]] name = "bootloader-x86_64-bios-common" -version = "0.11.0-beta.1" +version = "0.11.0-beta.2" [[package]] name = "bootloader-x86_64-bios-stage-2" -version = "0.11.0-beta.1" +version = "0.11.0-beta.2" dependencies = [ "bootloader-x86_64-bios-common", "byteorder", @@ -89,7 +89,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-stage-3" -version = "0.11.0-beta.1" +version = "0.11.0-beta.2" dependencies = [ "bootloader-x86_64-bios-common", "noto-sans-mono-bitmap 0.1.6", @@ -97,7 +97,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-stage-4" -version = "0.11.0-beta.1" +version = "0.11.0-beta.2" dependencies = [ "bootloader-x86_64-bios-common", "bootloader-x86_64-common", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-common" -version = "0.11.0-beta.1" +version = "0.11.0-beta.2" dependencies = [ "bootloader_api", "conquer-once", @@ -127,7 +127,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-uefi" -version = "0.11.0-beta.1" +version = "0.11.0-beta.2" dependencies = [ "bootloader-x86_64-common", "bootloader_api", @@ -138,7 +138,7 @@ dependencies = [ [[package]] name = "bootloader_api" -version = "0.11.0-beta.1" +version = "0.11.0-beta.2" dependencies = [ "rand", ] diff --git a/Cargo.toml b/Cargo.toml index d24c4f54..04b0e5da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,14 +27,14 @@ members = [ exclude = ["examples/basic", "examples/test_framework"] [workspace.package] -version = "0.11.0-beta.1" +version = "0.11.0-beta.2" license = "MIT/Apache-2.0" repository = "https://github.com/rust-osdev/bootloader" [workspace.dependencies] -bootloader_api = { version = "0.11.0-beta.1", path = "api" } -bootloader-x86_64-common = { version = "0.11.0-beta.1", path = "common" } -bootloader-x86_64-bios-common = { version = "0.11.0-beta.1", path = "bios/common" } +bootloader_api = { version = "0.11.0-beta.2", path = "api" } +bootloader-x86_64-common = { version = "0.11.0-beta.2", path = "common" } +bootloader-x86_64-bios-common = { version = "0.11.0-beta.2", path = "bios/common" } [dependencies] anyhow = "1.0.32" From d8d9086ca61507bca3fae8beecccb0ea49b09ca5 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 27 Nov 2022 18:44:40 +0100 Subject: [PATCH 15/21] Replace `mbrman` with fork to avoid yanked `funty` version --- Cargo.lock | 34 ++++++++++++++++++++++------------ Cargo.toml | 5 ++++- src/mbr.rs | 5 +++-- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac4a12ff..db50755a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,9 +43,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitvec" -version = "0.22.3" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5237f00a8c86130a0cc317830e558b966dd7850d48a953d998c813f01a41b527" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", "radium", @@ -62,7 +62,7 @@ dependencies = [ "fatfs", "gpt", "llvm-tools", - "mbrman", + "mbrman---bitvec-1-0", "tempfile", "test_kernel_default_settings", "test_kernel_higher_half", @@ -230,9 +230,9 @@ dependencies = [ [[package]] name = "funty" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1847abb9cb65d566acd5942e94aea9c8f547ad02c98e1649326fc0e8910b8b1e" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "getrandom" @@ -307,14 +307,15 @@ dependencies = [ ] [[package]] -name = "mbrman" -version = "0.4.2" +name = "mbrman---bitvec-1-0" +version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef6f6de0b8cfc56e13dc3ac3c662d9419f8aa5e3ebceb2d0eb25abce49e00395" +checksum = "9ad793076d220aa65f16eeedb2000b9d94f771a9e98aa74e07c870cdeb94f9c2" dependencies = [ "bincode", "bitvec", "serde", + "serde-big-array", "thiserror", ] @@ -381,9 +382,9 @@ dependencies = [ [[package]] name = "radium" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" [[package]] name = "rand" @@ -481,6 +482,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-big-array" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3323f09a748af288c3dc2474ea6803ee81f118321775bffa3ac8f7e65c5e90e7" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.136" @@ -742,9 +752,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "wyz" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "129e027ad65ce1453680623c3fb5163cbf7107bfe1aa32257e7d0e63f9ced188" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" dependencies = [ "tap", ] diff --git a/Cargo.toml b/Cargo.toml index 04b0e5da..0ec97f2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,10 @@ bootloader-x86_64-bios-common = { version = "0.11.0-beta.2", path = "bios/common anyhow = "1.0.32" fatfs = "0.3.4" gpt = "3.0.0" -mbrman = "0.4.2" +# replace with `mbrman` crate once +# https://github.com/rust-disk-partition-management/mbrman/pull/25 +# is merged +mbrman = { version = "0.0.1", package = "mbrman---bitvec-1-0" } tempfile = "3.3.0" [dev-dependencies] diff --git a/src/mbr.rs b/src/mbr.rs index f5608cc1..821bb7eb 100644 --- a/src/mbr.rs +++ b/src/mbr.rs @@ -1,4 +1,5 @@ use anyhow::Context; +use mbrman::BOOT_ACTIVE; use std::{ fs::{self, File}, io::{self, Seek, SeekFrom}, @@ -33,7 +34,7 @@ pub fn create_mbr_disk( .try_into() .context("size of second stage is larger than u32::MAX")?; mbr[1] = mbrman::MBRPartitionEntry { - boot: true, + boot: BOOT_ACTIVE, starting_lba: second_stage_start_sector, sectors: second_stage_sectors, // see BOOTLOADER_SECOND_STAGE_PARTITION_TYPE in `boot_sector` crate @@ -51,7 +52,7 @@ pub fn create_mbr_disk( .context("failed to read file metadata of FAT boot partition")? .len(); mbr[2] = mbrman::MBRPartitionEntry { - boot: false, + boot: BOOT_ACTIVE, starting_lba: boot_partition_start_sector, sectors: ((boot_partition_size - 1) / u64::from(SECTOR_SIZE) + 1) .try_into() From 35b78b3c7dbf213a7239c923bd440708ffd5ff39 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 27 Nov 2022 18:56:22 +0100 Subject: [PATCH 16/21] Add a `docs/README.md` overview page --- docs/migration/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 docs/migration/README.md diff --git a/docs/migration/README.md b/docs/migration/README.md new file mode 100644 index 00000000..5eef5ed0 --- /dev/null +++ b/docs/migration/README.md @@ -0,0 +1,6 @@ +# Migration Guides + +These guides explain how to migrate your project from older `bootloader` versions: + +- [Migration from `v0.9.X`](v0.9.md) +- [Migration from `v0.10.X`](v0.10.md) From 95d046a0b8ed19f7e292973741f82ecaeef82121 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 27 Nov 2022 18:56:31 +0100 Subject: [PATCH 17/21] Create a changelog entry --- Changelog.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Changelog.md b/Changelog.md index 7f0e4614..453e9ac6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,15 @@ # Unreleased +Major rewrite of the `bootloader` crate with various breaking changes: + +- **Separate API crate:** The bootloader is now split into two parts: An API crate to make kernels loadable by the bootloader and the actual bootloader implementation. This makes the build process for kernels much easier and faster. +- **New config system:** Instead of configuring the bootloader via a special table in the `Cargo.toml`, the configuration now happens through a normal Rust struct, which is part of the `entry_point!` macro. The macro then serializes the config struct at compile time and places it in a special ELF output section. The compile time serialization happens through a manually implemented `const fn` of the config struct. +- **Load the kernel at runtime:** The bootloader is now able to load files from FAT partitions at runtime. Thus, we don't need to link the kernel into the bootloader executable anymore. As a result, we don't need to recompile the bootloader on kernel changes anymore. We also load the config at runtime from the kernel's ELF section, which eliminates the second reason for recompiling the bootloader as well. +- **Split into sub-crates:** Since the bootloader build process does not need access to the kernel executable or its `Cargo.toml` anymore, we can build the different parts of the bootloader independently. For example, the BIOS boot sector is now a separate crate, and the UEFI bootloader is too. +- **Library to create disk images:** To create an abstraction the complex build steps of the different bootloader executables, we compile them inside cargo build scripts. At the top level, we provide a `bootloader` _library_ crate, which compiles everything as part of its build script. This library includes functions for creating BIOS and UEFI disk images for a given kernel. These functions can be used e.g. from a builder crate or a build script of the downstream operating system. + +See our [migration guides](docs/migration/README.md) for details. + # 0.10.13 – 2022-09-25 - Add dynamic range configuration ([#229](https://github.com/rust-osdev/bootloader/pull/229)) From 85b6b0f4d3cabdf9b97486251ecc1eab91c47cb6 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 27 Nov 2022 18:58:17 +0100 Subject: [PATCH 18/21] Use package version for dependencies in `build.rs` --- build.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.rs b/build.rs index bed36b82..7f04dddf 100644 --- a/build.rs +++ b/build.rs @@ -3,12 +3,12 @@ use std::{ process::Command, }; -const BOOTLOADER_X86_64_UEFI_VERSION: &str = "0.11.0-beta"; +const BOOTLOADER_X86_64_UEFI_VERSION: &str = env!("CARGO_PKG_VERSION"); -const BOOTLOADER_X86_64_BIOS_BOOT_SECTOR_VERSION: &str = "0.1.0-beta.1"; -const BOOTLOADER_X86_64_BIOS_STAGE_2_VERSION: &str = "0.1.0-beta"; -const BOOTLOADER_X86_64_BIOS_STAGE_3_VERSION: &str = "0.1.0-beta"; -const BOOTLOADER_X86_64_BIOS_STAGE_4_VERSION: &str = "0.11.0-beta"; +const BOOTLOADER_X86_64_BIOS_BOOT_SECTOR_VERSION: &str = env!("CARGO_PKG_VERSION"); +const BOOTLOADER_X86_64_BIOS_STAGE_2_VERSION: &str = env!("CARGO_PKG_VERSION"); +const BOOTLOADER_X86_64_BIOS_STAGE_3_VERSION: &str = env!("CARGO_PKG_VERSION"); +const BOOTLOADER_X86_64_BIOS_STAGE_4_VERSION: &str = env!("CARGO_PKG_VERSION"); fn main() { let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); From c0d44866115969d4a342104dc053c07848b63ced Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 27 Nov 2022 19:04:44 +0100 Subject: [PATCH 19/21] Bump version to v0.11.0-beta.4 --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db50755a..913b53e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,7 +55,7 @@ dependencies = [ [[package]] name = "bootloader" -version = "0.11.0-beta.2" +version = "0.11.0-beta.4" dependencies = [ "anyhow", "bootloader_test_runner", @@ -72,15 +72,15 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-boot-sector" -version = "0.11.0-beta.2" +version = "0.11.0-beta.4" [[package]] name = "bootloader-x86_64-bios-common" -version = "0.11.0-beta.2" +version = "0.11.0-beta.4" [[package]] name = "bootloader-x86_64-bios-stage-2" -version = "0.11.0-beta.2" +version = "0.11.0-beta.4" dependencies = [ "bootloader-x86_64-bios-common", "byteorder", @@ -89,7 +89,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-stage-3" -version = "0.11.0-beta.2" +version = "0.11.0-beta.4" dependencies = [ "bootloader-x86_64-bios-common", "noto-sans-mono-bitmap 0.1.6", @@ -97,7 +97,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-bios-stage-4" -version = "0.11.0-beta.2" +version = "0.11.0-beta.4" dependencies = [ "bootloader-x86_64-bios-common", "bootloader-x86_64-common", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-common" -version = "0.11.0-beta.2" +version = "0.11.0-beta.4" dependencies = [ "bootloader_api", "conquer-once", @@ -127,7 +127,7 @@ dependencies = [ [[package]] name = "bootloader-x86_64-uefi" -version = "0.11.0-beta.2" +version = "0.11.0-beta.4" dependencies = [ "bootloader-x86_64-common", "bootloader_api", @@ -138,7 +138,7 @@ dependencies = [ [[package]] name = "bootloader_api" -version = "0.11.0-beta.2" +version = "0.11.0-beta.4" dependencies = [ "rand", ] diff --git a/Cargo.toml b/Cargo.toml index 0ec97f2d..6dd92032 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,14 +27,14 @@ members = [ exclude = ["examples/basic", "examples/test_framework"] [workspace.package] -version = "0.11.0-beta.2" +version = "0.11.0-beta.4" license = "MIT/Apache-2.0" repository = "https://github.com/rust-osdev/bootloader" [workspace.dependencies] -bootloader_api = { version = "0.11.0-beta.2", path = "api" } -bootloader-x86_64-common = { version = "0.11.0-beta.2", path = "common" } -bootloader-x86_64-bios-common = { version = "0.11.0-beta.2", path = "bios/common" } +bootloader_api = { version = "0.11.0-beta.4", path = "api" } +bootloader-x86_64-common = { version = "0.11.0-beta.4", path = "common" } +bootloader-x86_64-bios-common = { version = "0.11.0-beta.4", path = "bios/common" } [dependencies] anyhow = "1.0.32" From 7fca949b7023ae55dc716a52a32d337f049c48a9 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 1 Dec 2022 10:30:32 +0100 Subject: [PATCH 20/21] Switch back to upstream `mbrman` crate again and update to `v0.5.1` --- Cargo.lock | 8 ++++---- Cargo.toml | 5 +---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 913b53e6..672a597c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,7 +62,7 @@ dependencies = [ "fatfs", "gpt", "llvm-tools", - "mbrman---bitvec-1-0", + "mbrman", "tempfile", "test_kernel_default_settings", "test_kernel_higher_half", @@ -307,10 +307,10 @@ dependencies = [ ] [[package]] -name = "mbrman---bitvec-1-0" -version = "0.0.1" +name = "mbrman" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad793076d220aa65f16eeedb2000b9d94f771a9e98aa74e07c870cdeb94f9c2" +checksum = "a4b239f4755d00466e3ac1d55ddeaf77a66c7580352fc6cbc40d56c218fc94a9" dependencies = [ "bincode", "bitvec", diff --git a/Cargo.toml b/Cargo.toml index 6dd92032..fc742db7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,10 +40,7 @@ bootloader-x86_64-bios-common = { version = "0.11.0-beta.4", path = "bios/common anyhow = "1.0.32" fatfs = "0.3.4" gpt = "3.0.0" -# replace with `mbrman` crate once -# https://github.com/rust-disk-partition-management/mbrman/pull/25 -# is merged -mbrman = { version = "0.0.1", package = "mbrman---bitvec-1-0" } +mbrman = "0.5.1" tempfile = "3.3.0" [dev-dependencies] From c716ac8f628fdd37d459b5f9e955cecc64d6f3ab Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 1 Dec 2022 10:56:42 +0100 Subject: [PATCH 21/21] Create CI script to trigger a release on new version in Cargo.toml --- .github/workflows/trigger-release.yml | 23 ++++++++++ .../trigger-release/requirements.txt | 1 + .../trigger-release/trigger-release.py | 42 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 .github/workflows/trigger-release.yml create mode 100644 .github/workflows/trigger-release/requirements.txt create mode 100644 .github/workflows/trigger-release/trigger-release.py diff --git a/.github/workflows/trigger-release.yml b/.github/workflows/trigger-release.yml new file mode 100644 index 00000000..02f96aaa --- /dev/null +++ b/.github/workflows/trigger-release.yml @@ -0,0 +1,23 @@ +name: Trigger Release + +on: + push: + branches: + - "main" + +jobs: + check: + name: Trigger Release + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v3 + + - name: "Install Python Libraries" + run: python -m pip install --user -r .github/workflows/trigger-release/requirements.txt + + - name: "Run release script" + run: "python3 .github/workflows/trigger-release/trigger-release.py" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/trigger-release/requirements.txt b/.github/workflows/trigger-release/requirements.txt new file mode 100644 index 00000000..bd79a658 --- /dev/null +++ b/.github/workflows/trigger-release/requirements.txt @@ -0,0 +1 @@ +toml diff --git a/.github/workflows/trigger-release/trigger-release.py b/.github/workflows/trigger-release/trigger-release.py new file mode 100644 index 00000000..da62986d --- /dev/null +++ b/.github/workflows/trigger-release/trigger-release.py @@ -0,0 +1,42 @@ +import toml +import requests +import subprocess + +cargo_toml = toml.load("Cargo.toml") +crate_version = cargo_toml["workspace"]["package"]["version"] +print("Detected crate version " + crate_version) + +api_url = "https://crates.io/api/v1/crates/bootloader/" + crate_version +released_version = requests.get(api_url).json() + +if "version" in released_version: + version = released_version["version"] + assert (version["crate"] == "bootloader") + assert (version["num"] == crate_version) + print("Version " + crate_version + " already exists on crates.io") + +else: + print("Could not find version " + crate_version + + " on crates.io; creating a new release") + + tag_name = "v" + crate_version + print(" Tagging commit as " + tag_name) + sha = subprocess.run(["git", "rev-parse", "HEAD"], check=True, + stdout=subprocess.PIPE).stdout.decode("utf-8").strip() + subprocess.run([ + "gh", "api", "/repos/rust-osdev/x86_64/git/refs", + "-X", "POST", "-H", "Accept: application/vnd.github.v3+json", + "-F", "ref=refs/tags/" + tag_name, + "-F", "sha="+sha + ]) + + subprocess.run([ + "gh", "api", "--method", "POST", "-H", "Accept: application/vnd.github+json", + "/repos/rust-osdev/bootloader/releases", + "-f", f"tag_name='{tag_name}'", "-f", f"target_commitish='{sha}'", + "-f", f"name='{tag_name}'", + "-f", "body='[Changelog](https://github.com/rust-osdev/bootloader/blob/main/Changelog.md)'", + "-F", "draft=false", "-F", "prerelease=false", "-F", "generate_release_notes=false", + ]) + + print(" Done")