Simplify setcontext syscall by rearranging regs in exc_frame_t
MODIFY
include/mips/exc.h
include/mips/exc.h
register_t t0, t1, t2, t3, t4, t5, t6, t7; \
register_t s0, s1, s2, s3, s4, s5, s6, s7; \
register_t t8, t9; \
+ register_t k0, k1; \
register_t gp, sp, fp, ra; \
register_t lo, hi; \
- register_t pc, sr, badvaddr, cause; \
+ register_t cause, pc, sr, badvaddr; \
}
#define FPU_FRAME \

MODIFY
sys/mips/context.c
sys/mips/context.c
@@ -60,15 +60,11 @@ int do_setcontext(thread_t *td, ucontext_t *uc) {
mcontext_t *from = &uc->uc_mcontext;
exc_frame_t *to = td->td_uframe;
- /* registers AT-T9 */
- memcpy(&to->at, &from->__gregs[_REG_AT], sizeof(__greg_t) * 25);
- /* registers GP-HI */
- memcpy(&to->gp, &from->__gregs[_REG_GP], sizeof(__greg_t) * 6);
+ /* registers AT-PC */
+ memcpy(&to->at, &from->__gregs[_REG_AT],
+ sizeof(__greg_t) * (_REG_EPC - _REG_AT + 1));
- to->cause = from->__gregs[_REG_CAUSE];
- to->pc = from->__gregs[_REG_EPC];
-
- /* FP registers + FP CSR */
+ /* 32 FP registers + FP CSR */
memcpy(&to->f0, &from->__fpregs.__fp_r,
sizeof(from->__fpregs.__fp_r) + sizeof(from->__fpregs.__fp_csr));

Simplify setcontext syscall by rearranging regs in exc_frame_t (#558)