Use gcc to pre-process mipsel assembly

Signed-off-by: Harry Chen <i@harrychen.xyz>
master
Harry Chen 6 years ago
parent 8ed6822636
commit 65d6fb5b1e

2
.gitignore vendored

@ -1,7 +1,7 @@
build build
target target
/kernel/src/arch/x86_64/interrupt/vector.asm /kernel/src/arch/x86_64/interrupt/vector.asm
/kernel/src/arch/*/boot/dtb.S *.gen.s
*.dtb *.dtb
Cargo.lock Cargo.lock

@ -317,6 +317,9 @@ else ifeq ($(arch), riscv64)
else ifeq ($(arch), aarch64) else ifeq ($(arch), aarch64)
@cargo xbuild $(build_args) @cargo xbuild $(build_args)
else ifeq ($(arch), mipsel) else ifeq ($(arch), mipsel)
@for file in context entry trap ; do \
$(cc) -E src/arch/$(arch)/boot/$${file}.S -o src/arch/$(arch)/boot/$${file}.gen.s ; \
done
@cargo xbuild $(build_args) @cargo xbuild $(build_args)
endif endif

@ -60,13 +60,12 @@ fn gen_dtb_asm(arch: &String, _board: &String) -> Result<()> {
panic!("DTB `{}` not found", dtb) panic!("DTB `{}` not found", dtb)
} }
let mut f = File::create(format!("src/arch/{}/boot/dtb.S", arch)).unwrap(); let mut f = File::create(format!("src/arch/{}/boot/dtb.gen.s", arch)).unwrap();
println!("cargo:rerun-if-changed={}", dtb); println!("cargo:rerun-if-changed={}", dtb);
println!("cargo:rerun-if-env-changed=DTB"); println!("cargo:rerun-if-env-changed=DTB");
writeln!(f, "# generated by build.rs - do not edit")?; writeln!(f, "# generated by build.rs - do not edit")?;
writeln!(f, ".intel_syntax noprefix")?;
write!(f, r#" write!(f, r#"
.section .dtb,"a" .section .dtb,"a"
.align 12 .align 12

@ -11,14 +11,15 @@ _start:
# set ebase # set ebase
la t0, trap_entry la t0, trap_entry
mfc0 t1, 15 # C0_EBASE mfc0 t1, $15 # C0_EBASE
or t1, t1, t0 or t1, t1, t0
mtc0 t1, 15 mtc0 t1, $15
# exit bootstrap mode # exit bootstrap mode
mfc0 t0, 12 # C0_STATUS mfc0 t0, $12 # C0_STATUS
andi t0, t0, 0xFFBFFFFF # set BEV (bit 22) to 0 li t1, 0xFFBFFFFF # set BEV (bit 22) to 0
mtc0 t0, 12 and t0, t0, t1
mtc0 t0, $12
# directly jump to main function # directly jump to main function
b rust_main b rust_main

@ -159,7 +159,7 @@ impl Context {
#[naked] #[naked]
#[inline(never)] #[inline(never)]
pub unsafe extern fn switch(&mut self, _target: &mut Self) { pub unsafe extern fn switch(&mut self, _target: &mut Self) {
asm!(include_str!("boot/context.S")); asm!(include_str!("boot/context.gen.s"));
} }
/// Constructs a null Context for the current running thread. /// Constructs a null Context for the current running thread.

@ -74,6 +74,6 @@ fn others_main() -> ! {
const BOOT_CPU_ID: u32 = 0; const BOOT_CPU_ID: u32 = 0;
global_asm!(include_str!("boot/entry.S")); global_asm!(include_str!("boot/entry.gen.s"));
global_asm!(include_str!("boot/trap.S")); global_asm!(include_str!("boot/trap.gen.s"));
global_asm!(include_str!("boot/dtb.S")); global_asm!(include_str!("boot/dtb.gen.s"));

Loading…
Cancel
Save