tkernel_2/kernel/sysdepend/cpu/em1d/cpu_status.h | bare source | permlink (0.01 seconds) |
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: * cpu_status.h (EM1-D512) 17: * EM1-D512 Dependent Definition 18: */ 19: 20: #ifndef _CPU_STATUS_ 21: #define _CPU_STATUS_ 22: 23: #include <tk/syslib.h> 24: #include <tk/sysdef.h> 25: #include "cpu_insn.h" 26: 27: /* 28: * Start/End critical section 29: */ 30: #define BEGIN_CRITICAL_SECTION { UINT _cpsr_ = disint(); 31: #define END_CRITICAL_SECTION if ( !isDI(_cpsr_) \ 32: && ctxtsk != schedtsk \ 33: && !isTaskIndependent() \ 34: && !dispatch_disabled ) { \ 35: dispatch(); \ 36: } \ 37: enaint(_cpsr_); } 38: 39: /* 40: * Start/End interrupt disable section 41: */ 42: #define BEGIN_DISABLE_INTERRUPT { UINT _cpsr_ = disint(); 43: #define END_DISABLE_INTERRUPT enaint(_cpsr_); } 44: 45: /* 46: * Interrupt enable/disable 47: */ 48: #define ENABLE_INTERRUPT { enaint(0); } 49: #define DISABLE_INTERRUPT { disint(); } 50: 51: /* 52: * Enable interrupt nesting 53: * Enable the interrupt that has a higher priority than 'level.' 54: */ 55: #define ENABLE_INTERRUPT_UPTO(level) { enaint(0); } 56: 57: /* 58: * Move to/Restore task independent part 59: */ 60: #define ENTER_TASK_INDEPENDENT { EnterTaskIndependent(); } 61: #define LEAVE_TASK_INDEPENDENT { LeaveTaskIndependent(); } 62: 63: /* ----------------------------------------------------------------------- */ 64: /* 65: * Check system state 66: */ 67: 68: /* 69: * When a system call is called from the task independent part, TRUE 70: */ 71: #define in_indp() ( isTaskIndependent() || ctxtsk == NULL ) 72: 73: /* 74: * When a system call is called during dispatch disable, TRUE 75: * Also include the task independent part as during dispatch disable. 76: */ 77: #define in_ddsp() ( dispatch_disabled \ 78: || in_indp() \ 79: || isDI(getCPSR()) ) 80: 81: /* 82: * When a system call is called during CPU lock (interrupt disable), TRUE 83: * Also include the task independent part as during CPU lock. 84: */ 85: #define in_loc() ( isDI(getCPSR()) \ 86: || in_indp() ) 87: 88: /* 89: * When a system call is called during executing the quasi task part, TRUE 90: * Valid only when in_indp() == FALSE because it is not discriminated from 91: * the task independent part. 92: */ 93: #define in_qtsk() ( ctxtsk->sysmode > ctxtsk->isysmode ) 94: 95: /* ----------------------------------------------------------------------- */ 96: /* 97: * Task dispatcher startup routine 98: */ 99: 100: /* 101: * Request for task dispatcher startup 102: * Do nothing at this point because there is no delayed 103: * interrupt function in ARM. 104: * Perform dispatcher startup with END_CRITICAL_SECTION. 105: */ 106: #define dispatch_request() /* */ 107: 108: /* 109: * Throw away the current task context. 110: * and forcibly dispatch to the task that should be performed next. 111: * Use at system startup and 'tk_ext_tsk, tk_exd_tsk.' 112: */ 113: Inline void force_dispatch( void ) 114: { 115: IMPORT void dispatch_to_schedtsk(); 116: 117: Asm("bx %0":: "r"(&dispatch_to_schedtsk)); 118: } 119: 120: /* 121: * Start task dispatcher 122: */ 123: Inline void dispatch( void ) 124: { 125: Asm("swi %0":: "i"(SWI_DISPATCH): "lr"); 126: } 127: 128: /* ----------------------------------------------------------------------- */ 129: /* 130: * Task exception 131: */ 132: 133: /* 134: * Task exception handler startup reservation 135: */ 136: IMPORT void request_tex( TCB *tcb ); 137: 138: /* ----------------------------------------------------------------------- */ 139: 140: /* 141: * Task context block 142: */ 143: typedef struct { 144: void *ssp; /* System stack pointer */ 145: void *uatb; /* Task space page table */ 146: INT lsid; /* Task space ID */ 147: UW *svc_ssp; /* ssp when SVC is called */ 148: } CTXB; 149: 150: /* 151: * CPU information 152: */ 153: IMPORT ATR available_cop; /* Enabled coprocessor (TA_COPn) */ 154: 155: #endif /* _CPU_STATUS_ */