ch1:First instruction in kernel
This commit is contained in:
parent
ad42f53386
commit
5de7bac424
4 changed files with 61 additions and 1 deletions
|
@ -1,2 +1,7 @@
|
|||
[build]
|
||||
target = "riscv64gc-unknown-none-elf"
|
||||
target = "riscv64gc-unknown-none-elf"
|
||||
|
||||
[target.riscv64gc-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-Clink-arg=-Tsrc/linker.ld", "-Cforce-frame-pointers=yes"
|
||||
]
|
4
src/entry.asm
Normal file
4
src/entry.asm
Normal file
|
@ -0,0 +1,4 @@
|
|||
.section .text.entry
|
||||
.globl _start
|
||||
_start:
|
||||
li x1, 100
|
48
src/linker.ld
Normal file
48
src/linker.ld
Normal file
|
@ -0,0 +1,48 @@
|
|||
OUTPUT_ARCH(riscv)
|
||||
ENTRY(_start)
|
||||
BASE_ADDRESS = 0x80200000;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = BASE_ADDRESS;
|
||||
skernel = .;
|
||||
|
||||
stext = .;
|
||||
.text : {
|
||||
*(.text.entry)
|
||||
*(.text .text.*)
|
||||
}
|
||||
|
||||
. = ALIGN(4K);
|
||||
etext = .;
|
||||
srodata = .;
|
||||
.rodata : {
|
||||
*(.data .rodata.*)
|
||||
*(.srodata .srodata.*)
|
||||
}
|
||||
|
||||
. = ALIGN(4K);
|
||||
erodata = .;
|
||||
sdata = .;
|
||||
.data : {
|
||||
*(.data .data.*)
|
||||
*(.sdata .sdata.*)
|
||||
}
|
||||
|
||||
. = ALIGN(4K);
|
||||
edata = .;
|
||||
.bss : {
|
||||
*(.bss.stack)
|
||||
sbss = .;
|
||||
*(.bss .bss.*)
|
||||
*(.sbss .sbss.*)
|
||||
}
|
||||
|
||||
. = ALIGN(4K);
|
||||
ebss = .;
|
||||
ekernel = .;
|
||||
|
||||
/DISCARD/ : {
|
||||
*(.eh_frame)
|
||||
}
|
||||
}
|
|
@ -2,3 +2,6 @@
|
|||
#![no_main]
|
||||
|
||||
mod lang_items;
|
||||
|
||||
use core::arch::global_asm;
|
||||
global_asm!(include_str!("entry.asm"));
|
Loading…
Add table
Add a link
Reference in a new issue