diff --git a/kernel/Makefile b/kernel/Makefile index b0ccb2a..275d0b7 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -346,7 +346,7 @@ else ifeq ($(arch), aarch64) @cargo xbuild $(build_args) else ifeq ($(arch), mipsel) @for file in context entry trap ; do \ - $(hostcc) -E src/arch/$(arch)/boot/$${file}.S -o src/arch/$(arch)/boot/$${file}.gen.s ; \ + $(hostcc) -Dboard_$(board) -E src/arch/$(arch)/boot/$${file}.S -o src/arch/$(arch)/boot/$${file}.gen.s ; \ done @cargo xbuild $(build_args) endif diff --git a/kernel/src/arch/mipsel/boot/trap.S b/kernel/src/arch/mipsel/boot/trap.S index 07b7ffa..4ec8650 100644 --- a/kernel/src/arch/mipsel/boot/trap.S +++ b/kernel/src/arch/mipsel/boot/trap.S @@ -43,8 +43,15 @@ trap_from_kernel: move sp, k0 sp_aligned: - # allocate 38 words for trapframe + 6 extra words - addiu sp, sp, -176 + # allocate 38 / 70 words for trapframe + 6 extra words + +#ifdef board_thinpad +#define TRAPFRAME_SIZE 304 +#else +#define TRAPFRAME_SIZE 176 +#endif + + addiu sp, sp, -TRAPFRAME_SIZE # save general registers sw ra, 160(sp) @@ -80,6 +87,42 @@ sp_aligned: sw AT, 40(sp) nop +#ifdef board_thinpad + # save floating point registers + swc1 $f0, 164(sp) + swc1 $f1, 168(sp) + swc1 $f2, 172(sp) + swc1 $f3, 176(sp) + swc1 $f4, 180(sp) + swc1 $f5, 184(sp) + swc1 $f6, 188(sp) + swc1 $f7, 192(sp) + swc1 $f8, 196(sp) + swc1 $f9, 200(sp) + swc1 $f10, 204(sp) + swc1 $f11, 208(sp) + swc1 $f12, 212(sp) + swc1 $f13, 216(sp) + swc1 $f14, 220(sp) + swc1 $f15, 224(sp) + swc1 $f16, 228(sp) + swc1 $f17, 232(sp) + swc1 $f18, 236(sp) + swc1 $f19, 240(sp) + swc1 $f20, 244(sp) + swc1 $f21, 248(sp) + swc1 $f22, 252(sp) + swc1 $f23, 256(sp) + swc1 $f24, 260(sp) + swc1 $f25, 264(sp) + swc1 $f26, 268(sp) + swc1 $f27, 272(sp) + swc1 $f28, 276(sp) + swc1 $f29, 280(sp) + swc1 $f30, 284(sp) + swc1 $f31, 288(sp) +#endif + # save hi/lo mflo t1 sw t1, 36(sp) @@ -158,9 +201,45 @@ trap_return: lw fp, 156(sp) lw ra, 160(sp) +#ifdef board_thinpad + # restore floating point registers + lwc1 $f0, 164(sp) + lwc1 $f1, 168(sp) + lwc1 $f2, 172(sp) + lwc1 $f3, 176(sp) + lwc1 $f4, 180(sp) + lwc1 $f5, 184(sp) + lwc1 $f6, 188(sp) + lwc1 $f7, 192(sp) + lwc1 $f8, 196(sp) + lwc1 $f9, 200(sp) + lwc1 $f10, 204(sp) + lwc1 $f11, 208(sp) + lwc1 $f12, 212(sp) + lwc1 $f13, 216(sp) + lwc1 $f14, 220(sp) + lwc1 $f15, 224(sp) + lwc1 $f16, 228(sp) + lwc1 $f17, 232(sp) + lwc1 $f18, 236(sp) + lwc1 $f19, 240(sp) + lwc1 $f20, 244(sp) + lwc1 $f21, 248(sp) + lwc1 $f22, 252(sp) + lwc1 $f23, 256(sp) + lwc1 $f24, 260(sp) + lwc1 $f25, 264(sp) + lwc1 $f26, 268(sp) + lwc1 $f27, 272(sp) + lwc1 $f28, 276(sp) + lwc1 $f29, 280(sp) + lwc1 $f30, 284(sp) + lwc1 $f31, 288(sp) +#endif + # save kernel stack lw k0, 0(sp) - addiu k1, sp, 176 + addiu k1, sp, TRAPFRAME_SIZE movn k1, k0, k0 la k0, _cur_kstack_ptr diff --git a/kernel/src/arch/mipsel/context.rs b/kernel/src/arch/mipsel/context.rs index 116e9f0..9441313 100644 --- a/kernel/src/arch/mipsel/context.rs +++ b/kernel/src/arch/mipsel/context.rs @@ -52,6 +52,39 @@ pub struct TrapFrame { pub sp: usize, pub fp: usize, pub ra: usize, + /// Floating-point registers (contains garbage if no FP support present) + pub f0: usize, + pub f1: usize, + pub f2: usize, + pub f3: usize, + pub f4: usize, + pub f5: usize, + pub f6: usize, + pub f7: usize, + pub f8: usize, + pub f9: usize, + pub f10: usize, + pub f11: usize, + pub f12: usize, + pub f13: usize, + pub f14: usize, + pub f15: usize, + pub f16: usize, + pub f17: usize, + pub f18: usize, + pub f19: usize, + pub f20: usize, + pub f21: usize, + pub f22: usize, + pub f23: usize, + pub f24: usize, + pub f25: usize, + pub f26: usize, + pub f27: usize, + pub f28: usize, + pub f29: usize, + pub f30: usize, + pub f31: usize, /// Reserved pub reserved: usize, pub __padding: [usize; 2], diff --git a/kernel/src/arch/mipsel/driver/mod.rs b/kernel/src/arch/mipsel/driver/mod.rs index 071142b..206d601 100644 --- a/kernel/src/arch/mipsel/driver/mod.rs +++ b/kernel/src/arch/mipsel/driver/mod.rs @@ -10,7 +10,7 @@ pub mod console; /// Initialize common drivers pub fn init() { board::init_driver(); - console::init(); + // console::init(); if let Some(con) = console::CONSOLE.lock().as_mut() { con.clear(); } diff --git a/kernel/targets/mipsel.json b/kernel/targets/mipsel.json index 346e3e8..7cc6d7d 100644 --- a/kernel/targets/mipsel.json +++ b/kernel/targets/mipsel.json @@ -7,7 +7,7 @@ "target-pointer-width": "32", "target-c-int-width": "32", "os": "none", - "features": "+mips32r2,+soft-float", + "features": "+mips32r2,+single-float", "max-atomic-width": "32", "linker": "rust-lld", "linker-flavor": "ld.lld",