gonzui


Format: Advanced Search

tkernel_2/lib/libtk/src/sysdepend/tef_em1d/setspc.cbare sourcepermlink (0.01 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T-Kernel 2.0 Software Package
    4:  *
    5:  *    Copyright 2011 by Ken Sakamura.
    6:  *    This software is distributed under the latest version of T-License 2.x.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17.
   10:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/01.
   11:  *
   12:  *----------------------------------------------------------------------
   13:  */
   14: 
   15: /*
   16:  *      @(#)setspc.c (libtk/EM1-D512)
   17:  *
   18:  *      Address space control
   19:  */
   20: 
   21: #include <basic.h>
   22: #include <tk/tkernel.h>
   23: #include <tk/sysdef.h>
   24: #include "getsvcenv.h"
   25: 
   26: /*
   27:  * Set task address space
   28:  */
   29: EXPORT ER SetTaskSpace( ID taskid )
   30: {
   31:         UW     taskmode;
   32:         ER     ercd;
   33: 
   34:         if ( taskid == TSK_SELF ) {
   35:                 /* Set current CPL in PPL */
   36:                 taskmode = getsvcenv();
   37:                 SCInfo.taskmode ^= (taskmode ^ (taskmode << 16)) & TMF_PPL(3);
   38:         } else {
   39:                 T_EIT         r_eit;
   40:                 T_CREGS               r_cregs;
   41:                 T_TSKSPC      tskspc;
   42: 
   43:                 /* Get logical space/taskmode for taskid tasks */
   44:                 ercd = tk_get_reg(taskid, NULL, &r_eit, &r_cregs);
   45:                 if ( ercd < E_OK ) {
   46:                         goto err_ret;
   47:                 }
   48: 
   49:                 /* Change to logical space for nominated tasks */
   50:                 tskspc.uatb = r_cregs.uatb;
   51:                 tskspc.lsid = r_cregs.lsid;
   52:                 ercd = tk_set_tsp(TSK_SELF, &tskspc);
   53:                 if ( ercd < E_OK ) {
   54:                         goto err_ret;
   55:                 }
   56: 
   57:                 /* Change to PPL for nominated tasks */
   58:                 taskmode = getsvcenv();
   59:                 SCInfo.taskmode ^= (taskmode ^ r_eit.taskmode) & TMF_PPL(3);
   60:         }
   61: 
   62:         return E_OK;
   63: 
   64: err_ret:
   65:         return ercd;
   66: }