📄 cpu_task.h
字号:
/* *---------------------------------------------------------------------- * 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. * *---------------------------------------------------------------------- *//* * cpu_task.h (VR4131) * CPU-Dependant Task Start Processing */#ifndef _CPU_TASK_#define _CPU_TASK_#include "cpu_insn.h"IMPORT TCB *fpu_ctxtsk; /* Task including FPU context *//* * System stack configuration at task startup */typedef struct { struct rng0_3 { /* RNG 0-3 common */ DW hi, lo; DW at; DW v[2]; /* v0-v1 */ DW a[4]; /* a0-a3 */ DW t[8]; /* t0-t7 */ DW s[8]; /* s0-s7 */ DW fp, ra, gp; DW t8, t9; DW epc; UW taskmode; UW psr; } rng0_3; struct rng1_3 { /* Only RNG 1-3 */ DW usp; } rng1_3;} SStackFrame;#define SizeofSS0 ( sizeof(struct rng0_3) ) /* RNG 0 */#define SizeofSS1_3 ( sizeof(SStackFrame) ) /* RNG 1-3 *//* Stack consumption by function arguments */#define SizeofFUNCPARA ( sizeof(DW) * 4 )/* * User stack configuration at task startup (only RNG 1-3) */typedef struct { /* Empty */} UStackFrame;/* * Size of system stack area destroyed by 'make_dormant()' * In other words, the size of area required to write by 'setup_context().' */#define DORMANT_STACK_SIZE ( sizeof(DW) * 6 ) /* To 'gp' *//* * Size of area kept for special use from system stack */#if TA_FPU#define RESERVE_SSTACK(tskatr) \ ( ( ((tskatr) & TA_FPU) != 0 )? sizeof(T_COP0REGS): 0 )#else#define RESERVE_SSTACK(tskatr) 0#endif/* * Initial value for task startup */#if USE_MMU#define INIT_KSU(rng) ( ( (rng) == 3 )? SR_USR: SR_KNL )#else#define INIT_KSU(rng) ( SR_KNL )#endifIMPORT UW initPSR;#define _INIT_IM (SR_IMMSK & ~SR_IM(7))#define _INIT_PSR (_INIT_IM|SR_XX|SR_KX|SR_SX|SR_UX)#define INIT_PSR(rng) ( initPSR | _INIT_PSR|SR_EXL|SR_IE|INIT_KSU(rng) )#define INIT_TMF(rng) ( TMF_PPL(rng) | TMF_CPL(rng) )#define INIT_FCR31 0x01000000 /* FS=1 *//* * Switch task space */Inline void change_space( INT lsid ){ /* Set ASID for entry Hi register */ Asm("dmtc0 %0, $10":: "r"(lsid));}/* * Create stack frame for task startup * Call from 'make_dormant()' */Inline void setup_context( TCB *tcb ){ SStackFrame *ssp; W rng; rng = (tcb->tskatr & TA_RNG3) >> 8; ssp = tcb->isstack; (UB*)ssp -= ( rng == 0 )? SizeofSS0 + SizeofFUNCPARA: SizeofSS1_3;#if TA_FPU if ( (tcb->tskatr & TA_FPU) != 0 ) { /* FPU context initialization */ T_COP0REGS *fpu; fpu = tcb->isstack; fpu->fcr31 = INIT_FCR31; }#endif /* CPU context initialization */ SetDW(&ssp->rng0_3.gp, (INT)tcb->gp); /* Global pointer */ SetDW(&ssp->rng0_3.epc, (INT)tcb->task);/* Task startup address */ ssp->rng0_3.taskmode = INIT_TMF(rng); /* Initial taskmode */ ssp->rng0_3.psr = INIT_PSR(rng); /* Initial SR */ SetDW(&tcb->tskctxb.ssp, (INT)ssp); /* System stack */ if ( rng > 0 ) { SetDW(&ssp->rng1_3.usp, (INT)tcb->istack - SizeofFUNCPARA); /* User stack */ }}/* * Set task startup code * Called by 'tk_sta_tsk()' processing. */Inline void setup_stacd( TCB *tcb, INT stacd ){ SStackFrame *ssp = (VP)tcb->tskctxb.ssp.lo; SetDW(&ssp->rng0_3.a[0], stacd); SetDW(&ssp->rng0_3.a[1], (INT)tcb->exinf);}/* * Delete task contexts */Inline void cleanup_context( TCB *tcb ){#if TA_FPU /* If the current FPU context belongs to 'tcb', Disable the FPU context */ if ( fpu_ctxtsk == tcb ) fpu_ctxtsk = NULL;#endif}#endif /* _CPU_TASK_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -