📄 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 (MC9328) * CPU-Dependant Task Start Processing */#ifndef _CPU_TASK_#define _CPU_TASK_#include "cpu_insn.h"IMPORT UW *SystemUATB; /* System page table UATB */IMPORT UW *cur_uatb; /* Current task space *//* * System stack configuration at task startup */typedef struct { VW r[12]; /* R0-R11 */ UW taskmode; VP usp; /* R13_usr */ VP lr_usr; /* R14_usr */ VP lr_svc; /* R14_svc */ VW spsr_svc; VW ip; /* R12 */ VP pc; /* R15 */} SStackFrame;/* * 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(VW) * 7 ) /* To 'taskmode' *//* * Size of area kept for special use from system stack */#define RESERVE_SSTACK(tskatr) 0/* * Initial value for task startup */#if USE_MMU#define INIT_PSR(rng) ( ( (rng) == 0 )? PSR_SVC: \ ( (rng) == 3 )? PSR_USR: PSR_SYS )#else#define INIT_PSR(rng) ( ( (rng) == 0 )? PSR_SVC: PSR_SYS )#endif#define INIT_TMF(rng) ( TMF_PPL(rng) | TMF_CPL(rng) )/* * Switch task space */Inline void change_space( VP uatb ){IMPORT void FlushCache( VP laddr, INT len ); UW *sp, *dp, *ep; /* If there is no space in the switched target, do not switch actually. */ if ( uatb != NULL ) { FlushCache(NULL, 0); /* Cache flash */ /* UATB copy */ sp = uatb; dp = SystemUATB; ep = SystemUATB + NUM_PDIR_ENTRIES; while ( dp < ep ) *dp++ = *sp++; PurgeTLB(); /* TLB invalidate */ }}/* * Create stack frame for task startup * Call from 'make_dormant()' */Inline void setup_context( TCB *tcb ){ SStackFrame *ssp; W rng; UW pc, spsr; rng = (tcb->tskatr & TA_RNG3) >> 8; ssp = tcb->isstack; ssp--; spsr = INIT_PSR(rng); pc = (UW)tcb->task; if ( (pc & 1) != 0 ) spsr |= PSR_T; /* Thumb mode */ /* CPU context initialization */ ssp->taskmode = INIT_TMF(rng); /* Initial taskmode */ ssp->spsr_svc = spsr; /* Initial SR */ ssp->pc = (VP)(pc & ~1); /* Task startup address */ tcb->tskctxb.ssp = ssp; /* System stack */ if ( rng > 0 ) { ssp->usp = tcb->istack; /* User stack */ }}/* * Set task startup code * Called by 'tk_sta_tsk()' processing. */Inline void setup_stacd( TCB *tcb, INT stacd ){ SStackFrame *ssp = tcb->tskctxb.ssp; ssp->r[0] = stacd; ssp->r[1] = (VW)tcb->exinf;}/* * Delete task contexts */Inline void cleanup_context( TCB *tcb ){EXPORT void FlushCache( VP laddr, INT len ); UW *p, *ep; /* If the current space belongs to 'tcb,' disable the space */ if ( ctxtsk == tcb && cur_uatb == tcb->tskctxb.uatb ) { cur_uatb = NULL; FlushCache(NULL, 0); /* Cache flash */ /* Clear UATB */ p = SystemUATB; ep = SystemUATB + NUM_PDIR_ENTRIES; while ( p < ep ) *p++ = 0; PurgeTLB(); /* TLB invalidate */ }}#endif /* _CPU_TASK_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -