diff --git a/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c b/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c index d18894f5f4..067b89133e 100644 --- a/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c +++ b/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c @@ -105,7 +105,7 @@ void *_sbrk_r(struct _reent *r, ptrdiff_t incr) */ pid_t _getpid(void) { - return sched_active_pid; + return thread_getpid(); } /** @@ -115,8 +115,8 @@ pid_t _getpid(void) */ pid_t _getpid_r(struct _reent *ptr) { - (void) ptr; - return sched_active_pid; + (void)ptr; + return thread_getpid(); } /** @@ -132,8 +132,8 @@ pid_t _getpid_r(struct _reent *ptr) __attribute__ ((weak)) int _kill_r(struct _reent *r, pid_t pid, int sig) { - (void) pid; - (void) sig; + (void)pid; + (void)sig; r->_errno = ESRCH; /* not implemented yet */ return -1; } @@ -331,8 +331,8 @@ int _isatty_r(struct _reent *r, int fd) __attribute__ ((weak)) int _kill(pid_t pid, int sig) { - (void) pid; - (void) sig; + (void)pid; + (void)sig; errno = ESRCH; /* not implemented yet */ return -1; } diff --git a/cpu/mips32r2_common/thread_arch.c b/cpu/mips32r2_common/thread_arch.c index d6ee886f83..56d434e99a 100644 --- a/cpu/mips32r2_common/thread_arch.c +++ b/cpu/mips32r2_common/thread_arch.c @@ -56,11 +56,11 @@ static struct fp64ctx *oldfpctx; /* fpu context of last task that executed * | | * --------------- * | 16 byte pad | - * --------------- <--- sched_active_thread->sp + * --------------- <--- thread_get_active()->sp */ char *thread_stack_init(thread_task_func_t task_func, void *arg, - void *stack_start, int stack_size) + void *stack_start, int stack_size) { /* make sure it is aligned to 8 bytes this is a requirement of the O32 ABI */ uintptr_t *p = (uintptr_t *)(((long)(stack_start) + stack_size) & ~7); @@ -107,7 +107,7 @@ char *thread_stack_init(thread_task_func_t task_func, void *arg, void thread_stack_print(void) { - uintptr_t *sp = (void *)sched_active_thread->sp; + uintptr_t *sp = (void *)thread_get_active()->sp; printf("Stack trace:\n"); while (*sp != STACK_END_PAINT) { @@ -132,7 +132,7 @@ void cpu_switch_context_exit(void) sched_run(); - __asm volatile ("lw $sp, 0(%0)" : : "r" (&sched_active_thread->sp)); + __asm volatile ("lw $sp, 0(%0)" : : "r" (&thread_get_active()->sp)); __exception_restore(); @@ -273,8 +273,8 @@ _mips_handle_exception(struct gpctx *ctx, int exception) * Note we cannot use the current sp value as * the prologue of this function has adjusted it */ - sched_active_thread->sp = (char *)(ctx->sp - - sizeof(struct gpctx) - PADDING); + thread_t *t = thread_get_active(); + t->sp = (char *)(ctx->sp - sizeof(struct gpctx) - PADDING); #ifdef MIPS_DSP _dsp_save(&dsp_ctx); @@ -289,7 +289,8 @@ _mips_handle_exception(struct gpctx *ctx, int exception) sched_run(); - new_ctx = (struct gpctx *)((unsigned int)sched_active_thread->sp + PADDING); + t = thread_get_active(); + new_ctx = (struct gpctx *)((unsigned int)t->sp + PADDING); #ifdef MIPS_HARD_FLOAT currentfpctx = (struct fp64ctx *)exctx_find(LINKCTX_TYPE_FP64, new_ctx); @@ -337,7 +338,7 @@ _mips_handle_exception(struct gpctx *ctx, int exception) new_ctx->status &= ~SR_CU1; #endif - __asm volatile ("lw $sp, 0(%0)" : : "r" (&sched_active_thread->sp)); + __asm volatile ("lw $sp, 0(%0)" : : "r" (&thread_get_active()->sp)); /* * Jump straight to the exception restore code