From d27a59a28e2475f3cdee2c1aae6a5ac4a5094732 Mon Sep 17 00:00:00 2001 From: HimbeerserverDE Date: Tue, 13 Sep 2022 16:03:05 +0200 Subject: [PATCH] Maybe load stage 2? Not sure --- stage1/boot.asm | 30 +++++++++++++++--------------- stage2/.cargo/config.toml | 2 +- stage2/Cargo.toml | 4 ++++ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/stage1/boot.asm b/stage1/boot.asm index 559d916..ff80f2a 100644 --- a/stage1/boot.asm +++ b/stage1/boot.asm @@ -1,7 +1,7 @@ [org 0x7c00] %define STAGE2START 0x7e00 -%define STAGE2SIZE 0x7f +%define STAGE2SECTORS (STAGE2SIZE + 511) / 512 ; Initialize registers xor ax, ax @@ -64,30 +64,30 @@ boot: ; Move cursor to 0, 0 on page 0 mov ah, 0x02 - mov bh, 0 ; Page - mov dh, 0 ; Row - mov dl, 0 ; Column + mov bh, 0 ; Page + mov dh, 0 ; Row + mov dl, 0 ; Column int 0x10 - mov ch, 33 ; Our string is 33 characters long + mov ch, 33 ; Our string is 33 characters long mov si, hello call print_bytes_si - mov ah, 0x02 ; Read sectors - mov al, STAGE2SIZE ; Stage 2 size (16 MiB) in sectors - xor ch, ch ; Cylinder 0 - mov cl, 2 ; Second sector, they start at 1 - xor dh, dh ; Head 0 - mov dl, 0x80 ; Hard Drive 1 - mov bx, STAGE2START ; Memory address to load stage 2 into + mov ah, 0x02 ; Read sectors + mov al, STAGE2SECTORS ; Stage 2 size in sectors + xor ch, ch ; Cylinder 0 + mov cl, 2 ; Second sector, they start at 1 + xor dh, dh ; Head 0 + mov dl, 0x80 ; Hard Drive 1 + mov bx, STAGE2START ; Memory address to load stage 2 into int 0x13 - jc stage2_error ; Carry flag is set if there was an error + jc stage2_error ; Carry flag is set if there was an error - cmp al, STAGE2SIZE ; Have we read as many sectors as we requested? + cmp al, STAGE2SECTORS ; Have we read as many sectors as we requested? jne stage2_error - jmp STAGE2START ; Hand over control to stage 2 + jmp STAGE2START ; Hand over control to stage 2 hello db 'Welcome to loadnothing stage 1!', 13, 10 ; \r\n error db 'Error reading stage 2 from disk', 13, 10 ; \r\n diff --git a/stage2/.cargo/config.toml b/stage2/.cargo/config.toml index 845acf4..354486a 100644 --- a/stage2/.cargo/config.toml +++ b/stage2/.cargo/config.toml @@ -1,6 +1,6 @@ [unstable] build-std = ["core", "compiler_builtins"] -build-std-features = ["compiler-builtins-mem"] +build-std-features = ["compiler-builtins-mem", "panic_immediate_abort"] [build] target = "x86_64-loadnothing.json" diff --git a/stage2/Cargo.toml b/stage2/Cargo.toml index eaf63ed..c1cd277 100644 --- a/stage2/Cargo.toml +++ b/stage2/Cargo.toml @@ -10,5 +10,9 @@ panic = "abort" [profile.release] panic = "abort" +strip = true +opt-level = "z" +lto = true +codegen-units = 1 [dependencies] -- 2.44.0