嵌入式操作系统T-Kernel
完整代码
源代码在线查看: setspc.c
/* *---------------------------------------------------------------------- * T-Kernel * * Copyright (C) 2004 by Ken Sakamura. All rights reserved. * T-Kernel is distributed under the T-License. *---------------------------------------------------------------------- * * Version: 1.01.00 * Released by T-Engine Forum(http://www.t-engine.org) at 2004/6/28. * *---------------------------------------------------------------------- */ /* * @(#)setspc.c (libtk/MC9328) * * Address space control */ #include #include #include #include "getsvcenv.h" /* * Set task address space */ EXPORT ER SetTaskSpace( ID taskid ) { UW taskmode; ER er; if ( taskid == TSK_SELF ) { /* Set current CPL in RPL */ taskmode = getsvcenv(); SCInfo.taskmode ^= (taskmode ^ (taskmode } else { T_EIT r_eit; T_CREGS r_cregs; T_TSKSPC tskspc; /* Get logical space/taskmode for taskid tasks */ er = tk_get_reg(taskid, NULL, &r_eit, &r_cregs); if ( er < E_OK ) goto err_ret; /* Change to logical space for nominated tasks */ tskspc.uatb = r_cregs.uatb; tskspc.lsid = r_cregs.lsid; er = tk_set_tsp(TSK_SELF, &tskspc); if ( er < E_OK ) goto err_ret; /* Change to PPL for nominted tasks */ taskmode = getsvcenv(); SCInfo.taskmode ^= (taskmode ^ r_eit.taskmode) & TMF_PPL(3); } return E_OK; err_ret: return er; }