Skip to content

Commit 0d90f03

Browse files
committed
wip
1 parent 967a09b commit 0d90f03

File tree

17 files changed

+309
-600
lines changed

17 files changed

+309
-600
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use std::{
2+
process::Command,
3+
path::Path,
4+
};
5+
6+
fn main() {
7+
let mut cmd = Command::new("cargo");
8+
cmd.arg("xbuild").arg("--release");
9+
cmd.arg("--manifest-path").arg("protected_mode/Cargo.toml");
10+
cmd.arg("--target").arg("protected_mode/i686-bootloader.json");
11+
cmd.env("RUSTFLAGS", "");
12+
cmd.status().unwrap();
13+
14+
let out_dir = Path::new("protected_mode/target/i686-bootloader/release").canonicalize().unwrap();
15+
16+
println!("cargo:rustc-link-search=native={}", out_dir.display());
17+
println!("cargo:rustc-link-lib=static=protected_mode");
18+
19+
println!("cargo:rerun-if-changed=protected_mode");
20+
}

linker.ld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ENTRY(_start)
1+
ENTRY(entry_point)
22

33
SECTIONS {
44
. = 0x500;
@@ -31,14 +31,14 @@ SECTIONS {
3131
*(.boot)
3232

3333
/* second stage */
34-
_second_stage_start_addr = .;
34+
_bootloader_rest_start_addr = .;
3535
*(.second_stage)
3636
*(.context_switch)
3737
*(.text .text.*)
3838
*(.rodata .rodata.*)
3939
*(.data .data.*)
4040
. = ALIGN(512);
41-
_second_stage_end_addr = .;
41+
_bootloader_rest_end_addr = .;
4242
}
4343

4444
_kernel_info_block_start = .;

protected_mode/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target/
2+
**/*.rs.bk

protected_mode/Cargo.lock

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

protected_mode/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "protected_mode"
3+
version = "0.1.0"
4+
authors = ["Philipp Oppermann <[email protected]>"]
5+
edition = "2018"
6+
7+
[lib]
8+
crate-type = ["staticlib"]
9+
10+
[dependencies]
11+
x86_64 = "0.3"

protected_mode/i686-bootloader.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"arch": "x86",
3+
"data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128",
4+
"llvm-target": "i686-unknown-linux-gnu",
5+
"linker-flavor": "ld.lld",
6+
"linker": "rust-lld",
7+
"target-endian": "little",
8+
"target-pointer-width": "32",
9+
"target-c-int-width": "32",
10+
"os": "none",
11+
"disable-redzone": true,
12+
"panic": "abort",
13+
"executables": true,
14+
"relocation_model": "static"
15+
}

src/memory_map.s renamed to protected_mode/src/e820.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.section .second_stage, "awx"
2+
.global do_e820
23
.intel_syntax noprefix
34
.code16
45

protected_mode/src/lib.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#![feature(global_asm)]
2+
#![feature(lang_items)]
3+
4+
#![no_std]
5+
6+
use core::panic::PanicInfo;
7+
8+
global_asm!(include_str!("e820.s"));
9+
10+
pub mod stages;
11+
12+
extern "C" {
13+
pub fn first_stage();
14+
}
15+
16+
#[no_mangle]
17+
pub extern "C" fn hello_world() {
18+
unsafe { first_stage() }
19+
}
20+
21+
#[panic_handler]
22+
#[no_mangle]
23+
pub extern "C" fn panic(_info: &PanicInfo) -> ! {
24+
loop {}
25+
}
26+
27+
#[lang = "eh_personality"]
28+
#[no_mangle]
29+
pub extern "C" fn eh_personality() {
30+
loop {}
31+
}
File renamed without changes.

0 commit comments

Comments
 (0)