mtkernel_3/kernel/sysdepend/cpu/core/armv7a/cpu_task.h | bare source | permlink (0.00 seconds) |
1: /* 2: *---------------------------------------------------------------------- 3: * micro T-Kernel 3.00.05 4: * 5: * Copyright (C) 2006-2021 by Ken Sakamura. 6: * This software is distributed under the T-License 2.2. 7: *---------------------------------------------------------------------- 8: * 9: * Released by TRON Forum(http://www.tron.org) at 2021/11. 10: * 11: *---------------------------------------------------------------------- 12: */ 13: 14: /* 15: * cpu_task.h (ARMv7-A) 16: * CPU-Dependent Task Start Processing 17: */ 18: 19: #ifndef _SYSDEPEND_CPU_CORE_CPUTASK_ 20: #define _SYSDEPEND_CPU_CORE_CPUTASK_ 21: 22: /* 23: * System stack configuration at task startup 24: */ 25: typedef struct { 26: UW r_[8]; /* R4-R11 */ 27: // Exception entry stack 28: UW r[4]; /* R0-R3 */ 29: UW ip; /* R12 */ 30: void *lr; /* lr */ 31: void *pc; /* pc */ 32: UW cpsr; /* cpsr */ 33: } SStackFrame; 34: 35: /* 36: * Size of system stack area destroyed by 'make_dormant()' 37: * In other words, the size of area required to write by 'knl_setup_context().' 38: */ 39: #define DORMANT_STACK_SIZE ( sizeof(SStackFrame) + 0x10 ) 40: 41: #if USE_FPU 42: typedef struct { 43: UW rsv; 44: UW fpscr; 45: UD d[32]; 46: } FPUContext; 47: 48: IMPORT TCB *knl_fpu_ctx; /* Task in FPU context */ 49: 50: #endif /* USE_FPU */ 51: 52: /* 53: * Create stack frame for task startup 54: * Call from 'make_dormant()' 55: */ 56: Inline void knl_setup_context( TCB *tcb ) 57: { 58: SStackFrame *ssp; 59: 60: ssp = tcb->isstack; 61: 62: #if USE_FPU 63: if ( (tcb->tskatr & TA_FPU) != 0 ) { 64: /* Initialize FPU context */ 65: FPUContext *fpu = tcb->isstack; 66: (--fpu)->fpscr = FPSCR_INIT; 67: ssp = (SStackFrame*)fpu; 68: } 69: #endif /* USE_FPU */ 70: 71: ssp--; 72: 73: /* CPU context initialization */ 74: ssp->lr = 0; 75: ssp->cpsr = PSR_SVC; /* Initial CPSR */ 76: ssp->pc = (void *)tcb->task; /* Task startup address */ 77: 78: tcb->tskctxb.ssp = ssp; /* System stack */ 79: } 80: 81: /* 82: * Set task startup code 83: * Called by 'tk_sta_tsk()' processing. 84: */ 85: Inline void knl_setup_stacd( TCB *tcb, INT stacd ) 86: { 87: SStackFrame *ssp = tcb->tskctxb.ssp; 88: 89: ssp->r[0] = stacd; 90: ssp->r[1] = (VW)tcb->exinf; 91: } 92: 93: /* 94: * Delete task contexts 95: */ 96: Inline void knl_cleanup_context( TCB *tcb ) 97: { 98: #if USE_FPU 99: if(tcb->tskatr & TA_FPU){ 100: if (knl_fpu_ctx == tcb) { 101: knl_fpu_ctx = NULL; 102: } 103: } 104: #endif // USE_FPU 105: } 106: 107: #endif /* _SYSDEPEND_CPU_CORE_CPUTASK_ */