Skip to content

Commit b891b3a

Browse files
Protected Mode
1 parent 155ec06 commit b891b3a

24 files changed

+412
-98
lines changed

.cargo/config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
target = "i8086-bootloader.json"
33

44
[alias]
5-
xbuild = "build -Zbuild-std=core"
5+
bbuild = "build -Zbuild-std=core"

Cargo.lock

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ name = "bootloader"
33
version = "0.1.0"
44
authors = ["Ryland Morgan <[email protected]>"]
55
edition = "2018"
6+
description = "An experimental bootloader, written in Rust"
67
build = "build.rs"
78

89
[dependencies]
910
shared = { path = "src/shared" }
11+
rlibc = "1"
1012

1113
[build-dependencies]
1214
llvm-tools = "0.1"

build.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ fn main() {
2626
.tool(&exe("llvm-objcopy"))
2727
.expect("llvm-objcopy not found");
2828

29+
// Build stage 3
30+
build_subproject(
31+
Path::new("src/protected/stage_3"),
32+
&["third_stage"],
33+
"../i386-unknown-none.json",
34+
&target_dir,
35+
&objcopy,
36+
&cargo,
37+
);
38+
39+
2940
// Build the bootsector
3041
build_subproject(
3142
Path::new("src/real/bootsector"),
@@ -35,7 +46,7 @@ fn main() {
3546
"no_int13h_extensions",
3647
"dap_load_failed",
3748
],
38-
"../i8086-real_mode.json",
49+
"../i386-unknown-none-code16.json",
3950
&target_dir,
4051
&objcopy,
4152
&cargo,
@@ -45,7 +56,7 @@ fn main() {
4556
build_subproject(
4657
Path::new("src/real/stage_2"),
4758
&["second_stage"],
48-
"../i8086-real_mode.json",
59+
"../i386-unknown-none-code16.json",
4960
&target_dir,
5061
&objcopy,
5162
&cargo,

i8086-bootloader.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"eliminate_frame_pointer": true,
2121
"pre-link-args": {
2222
"ld.lld": [
23-
"--script=src/real/linker.ld"
23+
"--script=linker.ld"
2424
]
2525
}
2626
}

linker.ld

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ SECTIONS {
2424
.rest_of_bootloader :
2525
{
2626
_rest_of_bootloader_start = .;
27-
28-
*stage_2*
29-
*core*
30-
27+
3128
*(.text .text.*)
3229
*(.data .data.*)
3330
*(.rodata .rodata.*)

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33

44
mod panic;
55

6+
extern crate rlibc;
7+
68
#[no_mangle]
79
fn bootloader_no_optimize() {}

src/panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use shared::utils;
44

55
#[panic_handler]
66
pub fn panic(info: &PanicInfo) -> ! {
7-
println!("[Panic]");
7+
println!("[Panic] {}", info);
88

99
loop {
1010
utils::hlt()

src/protected/Cargo.lock

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/protected/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[workspace]
2+
members = [
3+
"v86",
4+
"stage_3"
5+
]
6+
7+
[profile.release]
8+
opt-level = "z"
9+
panic = "abort"
10+
lto = true

0 commit comments

Comments
 (0)