Ignore:
Timestamp:
Dec 5, 2017, 4:20:07 PM (4 years ago)
Author:
alain
Message:

Fix several bugs in the fork() syscall.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/core/hal_syscall.c

    r407 r408  
    3030
    3131
    32 /////////////////////////////////////
    33 void hal_do_syscall( thread_t * this,
    34                      reg_t    * regs_tbl )
     32/////////////////////
     33void hal_do_syscall()
    3534{
     35    thread_t    * this;
    3636
    37 #if(CONFIG_SYSCALL_DEBUG & 0x1)
    38 printk("\n[DBG] %s : core[%x,%d] enter at cycle %d\n",
    39 __FUNCTION__ , local_cxy , this->core->lid , hal_time_stamp() );
    40 #endif
     37    uint32_t    * enter_uzone;
     38    uint32_t    * exit_uzone;
    4139
    42         register reg_t      arg0;
    43         register reg_t      arg1;
    44         register reg_t      arg2;
    45         register reg_t      arg3;
    46         register reg_t      service_num;
    47         register reg_t      retval;
     40        uint32_t      arg0;
     41        uint32_t      arg1;
     42        uint32_t      arg2;
     43        uint32_t      arg3;
     44        uint32_t      service_num;
     45        uint32_t      retval;
    4846 
    49         service_num = regs_tbl[UZ_V0];
     47    // get pointer on enter_thread uzone
     48    this        = CURRENT_THREAD;
     49    enter_uzone = (uint32_t *)this->uzone;
    5050
    51         arg0        = regs_tbl[UZ_A0];
    52         arg1        = regs_tbl[UZ_A1];
    53         arg2        = regs_tbl[UZ_A2];
    54         arg3        = regs_tbl[UZ_A3];
     51    // get syscall arguments from uzone
     52        service_num = enter_uzone[UZ_V0];
     53        arg0        = enter_uzone[UZ_A0];
     54        arg1        = enter_uzone[UZ_A1];
     55        arg2        = enter_uzone[UZ_A2];
     56        arg3        = enter_uzone[UZ_A3];
    5557 
     58syscall_dmsg("\n[DBG] %s : core[%x,%d] enters for %s / &uzone %x / cycle %d \n",
     59__FUNCTION__, local_cxy, this->core->lid,
     60syscall_str(service_num) , enter_uzone , (uint32_t)hal_get_cycles() );
     61
    5662    // call architecture independant syscall handler
    5763        retval = do_syscall( this,
     
    6268                         service_num );
    6369
    64         regs_tbl[UZ_V0]   = retval;
    65         regs_tbl[UZ_V1]   = this->errno;
    66         regs_tbl[UZ_EPC] += 4;
     70    // get pointer on exit_thread uzone,
     71    // exit_thread can be different from enter_thread
     72    this       = CURRENT_THREAD;
     73    exit_uzone = (uint32_t *)this->uzone;
    6774
    68 #if(CONFIG_SYSCALL_DEBUG & 0x1)
    69 printk("\n[DBG] %s : core[%x,%d] exit at cycle %d\n",
    70 __FUNCTION__ , local_cxy , this->core->lid , hal_time_stamp() );
    71 #endif
     75    // set syscall return value to uzone
     76        exit_uzone[UZ_V0] = retval;
     77
     78    // update EPC in uzone
     79        exit_uzone[UZ_EPC] += 4;
     80
     81syscall_dmsg("\n[DBG] %s : core[%x,%d] exit from %s / &uzone %x / cycle %d \n",
     82__FUNCTION__, local_cxy, this->core->lid,
     83syscall_str(service_num) , exit_uzone , (uint32_t)hal_get_cycles() );
    7284
    7385}
Note: See TracChangeset for help on using the changeset viewer.