cpu/mips32r2_common: Don't access sched_active_*

Replaced accesses to sched_active_* with API calls in C files
This commit is contained in:
Marian Buschsieweke 2020-08-17 11:48:34 +02:00
parent 346fb432ed
commit ac394ce826
No known key found for this signature in database
GPG Key ID: 61F64C6599B1539F
2 changed files with 16 additions and 15 deletions

View File

@ -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;
}

View File

@ -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