88#include "loadcore.h"
99#include "sysclib.h"
1010#include "stdio.h"
11+ #include <defs.h>
1112
1213#include <limits.h>
1314
@@ -205,7 +206,7 @@ int thread_init_and_start(struct thread *thread, int intr_state)
205206 thread -> saved_regs -> sp = (u32 )& thread -> saved_regs [1 ];
206207 thread -> saved_regs -> fp = thread -> saved_regs -> sp ;
207208 thread -> saved_regs -> ra = (u32 )ExitThread ;
208- thread -> saved_regs -> gp = thread -> gp ;
209+ thread -> saved_regs -> gp = ( u32 ) thread -> gp ;
209210 thread -> saved_regs -> sr = 0x404 ;
210211 thread -> saved_regs -> sr |= thread -> attr & 8 ;
211212 thread -> saved_regs -> pc = (u32 )thread -> entry ;
@@ -650,13 +651,11 @@ int _start(int argc, char **argv)
650651 idle -> entry = idle_thread ;
651652 idle -> saved_regs = idle -> stack_top + (((idle -> stack_size << 2 ) >> 2 ) - RESERVED_REGCTX_SIZE );
652653 memset (idle -> saved_regs , 0 , RESERVED_REGCTX_SIZE );
653-
654- __asm__ __volatile__("sw $gp, %0\n"
655- : "=m" (idle -> gp )::);
654+ idle -> gp = GetGP ();
656655
657656 idle -> saved_regs -> unk = -2 ;
658657 idle -> saved_regs -> sp = (u32 )& idle -> saved_regs [1 ];
659- idle -> saved_regs -> gp = idle -> gp ;
658+ idle -> saved_regs -> gp = ( u32 ) idle -> gp ;
660659 idle -> saved_regs -> fp = idle -> saved_regs -> sp ;
661660 idle -> saved_regs -> ra = (u32 )ExitThread ;
662661 idle -> saved_regs -> sr = (idle -> attr & 0xF0000000 ) | 0x404 ;
@@ -679,9 +678,7 @@ int _start(int argc, char **argv)
679678 current -> priority = 1 ;
680679 current -> attr = TH_C ;
681680 current -> status = THS_RUN ;
682-
683- __asm__ __volatile__("sw $gp, %0\n"
684- : "=m" (current -> gp )::);
681+ current -> gp = GetGP ();
685682
686683 list_insert (& thctx .thread_list , & current -> thread_list );
687684 thctx .current_thread = current ;
0 commit comments