add stage1 skeleton

This commit is contained in:
anna 2023-05-28 19:28:21 +02:00
parent 343512ee2f
commit fb36d1f949
Signed by: fef
GPG Key ID: 2585C2DC6D79B485
7 changed files with 97 additions and 2 deletions

6
Cargo.lock generated
View File

@ -4,4 +4,8 @@ version = 3
[[package]]
name = "bussy"
version = "0.1.0"
version = "0.1.0"
[[package]]
name = "bussy-stage1"
version = "0.1.0"

View File

@ -1,10 +1,30 @@
[package]
name = "bussy"
version = "0.1.0"
edition = "2021"
version.workspace = true
repository.workspace = true
[workspace]
members = [
"stage1"
]
[workspace.package]
version = "0.1.0"
repository = "https://git.bsd.gay/fef/bussy"
[profile.dev]
panic = "abort"
opt-level = "s"
lto = true
codegen-units = 1
debug = true
overflow-checks = true
[profile.release]
panic = "abort"
opt-level = "s"
lto = true
codegen-units = 1
debug = true
overflow-checks = false

7
stage1/Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "stage1"
version = "0.1.0"

5
stage1/Cargo.toml Normal file
View File

@ -0,0 +1,5 @@
[package]
name = "bussy-stage1"
edition = "2021"
version.workspace = true
repository.workspace = true

8
stage1/build.rs Normal file
View File

@ -0,0 +1,8 @@
use std::path::Path;
fn main() {
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
let ld_script_path = manifest_dir.join("stage1.ld");
println!("cargo:rustc-link-arg=--script={}", ld_script_path.display());
}

19
stage1/src/main.rs Normal file
View File

@ -0,0 +1,19 @@
#![no_std]
#![no_main]
use core::arch::asm;
use core::panic::PanicInfo;
#[no_mangle]
pub extern "C" fn main() -> ! {
loop {}
}
#[panic_handler]
pub fn rust_panic(_info: &PanicInfo) -> ! {
loop {
unsafe {
asm!("cli", "hlt");
}
}
}

32
stage1/stage1.ld Normal file
View File

@ -0,0 +1,32 @@
OUTPUT_FORMAT(elf32-i386)
ENTRY(_start)
SECTIONS {
. = 0x0500;
_stage1_start = .;
.header : {
KEEP(*(.header))
}
.text : ALIGN(8) {
*(.text .text.*)
}
.data : ALIGN(8) {
*(.data .data.*)
}
.rodata : ALIGN(8) {
*(.rodata .rodata.*)
}
_stage1_end = .;
.bss(NOLOAD) : ALIGN(8) {
_bss_start = .;
*(.bss .bss.*)
_bss_end = .;
}
}