Save/restore FP registers when context switching (broken mipsel arch)

Signed-off-by: Harry Chen <i@harrychen.xyz>
master
Harry Chen 6 years ago
parent 6b7aa5ae59
commit d261b4e0b3

@ -346,7 +346,7 @@ 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 \ @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 done
@cargo xbuild $(build_args) @cargo xbuild $(build_args)
endif endif

@ -43,8 +43,15 @@ trap_from_kernel:
move sp, k0 move sp, k0
sp_aligned: sp_aligned:
# allocate 38 words for trapframe + 6 extra words # allocate 38 / 70 words for trapframe + 6 extra words
addiu sp, sp, -176
#ifdef board_thinpad
#define TRAPFRAME_SIZE 304
#else
#define TRAPFRAME_SIZE 176
#endif
addiu sp, sp, -TRAPFRAME_SIZE
# save general registers # save general registers
sw ra, 160(sp) sw ra, 160(sp)
@ -80,6 +87,42 @@ sp_aligned:
sw AT, 40(sp) sw AT, 40(sp)
nop 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 # save hi/lo
mflo t1 mflo t1
sw t1, 36(sp) sw t1, 36(sp)
@ -158,9 +201,45 @@ trap_return:
lw fp, 156(sp) lw fp, 156(sp)
lw ra, 160(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 # save kernel stack
lw k0, 0(sp) lw k0, 0(sp)
addiu k1, sp, 176 addiu k1, sp, TRAPFRAME_SIZE
movn k1, k0, k0 movn k1, k0, k0
la k0, _cur_kstack_ptr la k0, _cur_kstack_ptr

@ -52,6 +52,39 @@ pub struct TrapFrame {
pub sp: usize, pub sp: usize,
pub fp: usize, pub fp: usize,
pub ra: 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 /// Reserved
pub reserved: usize, pub reserved: usize,
pub __padding: [usize; 2], pub __padding: [usize; 2],

@ -10,7 +10,7 @@ pub mod console;
/// Initialize common drivers /// Initialize common drivers
pub fn init() { pub fn init() {
board::init_driver(); board::init_driver();
console::init(); // console::init();
if let Some(con) = console::CONSOLE.lock().as_mut() { if let Some(con) = console::CONSOLE.lock().as_mut() {
con.clear(); con.clear();
} }

@ -7,7 +7,7 @@
"target-pointer-width": "32", "target-pointer-width": "32",
"target-c-int-width": "32", "target-c-int-width": "32",
"os": "none", "os": "none",
"features": "+mips32r2,+soft-float", "features": "+mips32r2,+single-float",
"max-atomic-width": "32", "max-atomic-width": "32",
"linker": "rust-lld", "linker": "rust-lld",
"linker-flavor": "ld.lld", "linker-flavor": "ld.lld",

Loading…
Cancel
Save