wip
This commit is contained in:
parent
0bbf694137
commit
be4a7a3e80
8 changed files with 35 additions and 17 deletions
|
@ -2,8 +2,14 @@
|
||||||
target = "riscv64gc-unknown-none-elf"
|
target = "riscv64gc-unknown-none-elf"
|
||||||
|
|
||||||
[target.riscv64gc-unknown-none-elf]
|
[target.riscv64gc-unknown-none-elf]
|
||||||
rustflags = ["-C", "link-arg=-Tsrc/ld/kernel.ld"]
|
rustflags = [
|
||||||
runner = "./scripts/start.sh"
|
"--print",
|
||||||
|
"link-args",
|
||||||
|
"-C",
|
||||||
|
"link-arg=--script",
|
||||||
|
"-C",
|
||||||
|
"link-arg=src/ld/kernel.ld",
|
||||||
|
]
|
||||||
|
|
||||||
[term]
|
[term]
|
||||||
verbose = true
|
verbose = true
|
||||||
|
|
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -3,5 +3,5 @@
|
||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "eos0"
|
name = "kernel"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
name = "eos0"
|
name = "kernel"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
panic = "abort"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
11
Makefile
11
Makefile
|
@ -1,8 +1,7 @@
|
||||||
KERNEL = target/riscv64gc-unknown-none-elf/debug/xv6-riscv-rust
|
KERNEL = target/riscv64gc-unknown-none-elf/debug/kernel
|
||||||
SOURCES := $(shell find -name "*.rs")
|
SOURCES := $(shell find . -name "*.rs")
|
||||||
|
|
||||||
|
.PHONY: $(KERNEL)
|
||||||
|
|
||||||
$(KERNEL): $(SOURCES)
|
$(KERNEL): $(SOURCES)
|
||||||
cargo build
|
cargo rustc
|
||||||
|
|
||||||
fs.img: mkfs/mkfs README.md $(UPROGS)
|
|
||||||
mkfs/mkfs fs.img README.md $(UPROGS)
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
KERNEL=$1
|
KERNEL=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
@ -8,7 +10,8 @@ qemu-system-riscv64 \
|
||||||
-machine virt \
|
-machine virt \
|
||||||
-bios none \
|
-bios none \
|
||||||
-m 3G \
|
-m 3G \
|
||||||
-smp 3 \
|
-d trace:exec_tb \
|
||||||
# -drive file=fs.img,if=none,format=raw,id=x0 \
|
|
||||||
-device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0 \
|
|
||||||
-kernel "$KERNEL"
|
-kernel "$KERNEL"
|
||||||
|
|
||||||
|
# -smp 3 \
|
||||||
|
# -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0 \
|
||||||
|
|
3
src/asm/entry.S
Normal file
3
src/asm/entry.S
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
.global _entry
|
||||||
|
_entry:
|
||||||
|
call start
|
|
@ -3,10 +3,15 @@ ENTRY(_entry)
|
||||||
|
|
||||||
SECTIONS {
|
SECTIONS {
|
||||||
/*
|
/*
|
||||||
It seems that QEMU jumps to 0x8000000 after setting up memory, so we want
|
It seems that QEMU jumps to 0x80000000 after setting up memory, so we want
|
||||||
our kernel code to begin here.
|
our kernel code to begin here.
|
||||||
|
|
||||||
TODO: Is there an authoritative source that says that this is the address?
|
TODO: Is there an authoritative source that says that this is the address?
|
||||||
|
How to test this: Run QEMU using -d trace:exec_tb and see where the PC goes
|
||||||
*/
|
*/
|
||||||
. = 0x8000000;
|
. = 0x80000000;
|
||||||
|
|
||||||
|
.text : {
|
||||||
|
*(.text)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,7 @@ fn panic_handler(_: &PanicInfo) -> ! {
|
||||||
|
|
||||||
static HELLO: &[u8] = b"Hello World!";
|
static HELLO: &[u8] = b"Hello World!";
|
||||||
|
|
||||||
#[no_mangle]
|
pub extern "C" fn start() -> ! {
|
||||||
pub extern "C" fn _start() -> ! {
|
|
||||||
let vga_buffer = 0xb8000 as *mut u8;
|
let vga_buffer = 0xb8000 as *mut u8;
|
||||||
|
|
||||||
for (i, &byte) in HELLO.iter().enumerate() {
|
for (i, &byte) in HELLO.iter().enumerate() {
|
||||||
|
|
Loading…
Reference in a new issue