1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17:
18:
19: #include "kernel.h"
20: #include "task.h"
21: #include "check.h"
22:
23:
24: #ifdef USE_FUNC_TK_DIS_DSP
25:
26: 27: 28:
29: SYSCALL ER tk_dis_dsp( void )
30: {
31: CHECK_CTX(!in_loc());
32:
33: knl_dispatch_disabled = DDS_DISABLE;
34:
35: return E_OK;
36: }
37: #endif
38:
39:
40:
41: 42: 43:
44: #ifdef USE_FUNC_TK_ENA_DSP
45: SYSCALL ER tk_ena_dsp( void )
46: {
47: CHECK_CTX(!in_loc());
48:
49: knl_dispatch_disabled = DDS_ENABLE;
50: if ( knl_ctxtsk != knl_schedtsk ) {
51: knl_dispatch();
52: }
53:
54: return E_OK;
55: }
56: #endif
57:
58: #if TK_SUPPORT_REGOPS
59: #ifdef USE_FUNC_TK_SET_REG
60:
61: 62: 63:
64: SYSCALL ER tk_set_reg( ID tskid,
65: CONST T_REGS *pk_regs, CONST T_EIT *pk_eit, CONST T_CREGS *pk_cregs )
66: {
67: TCB *tcb;
68: ER ercd = E_OK;
69:
70: CHECK_INTSK();
71: CHECK_TSKID(tskid);
72: CHECK_NONSELF(tskid);
73:
74: tcb = get_tcb(tskid);
75:
76: BEGIN_CRITICAL_SECTION;
77: if ( tcb->state == TS_NONEXIST ) {
78: ercd = E_NOEXS;
79: } else {
80: knl_set_reg(tcb, pk_regs, pk_eit, pk_cregs);
81: }
82: END_CRITICAL_SECTION;
83:
84: return ercd;
85: }
86: #endif
87:
88: #ifdef USE_FUNC_TK_GET_REG
89:
90: 91: 92:
93: SYSCALL ER tk_get_reg( ID tskid, T_REGS *pk_regs, T_EIT *pk_eit, T_CREGS *pk_cregs )
94: {
95: TCB *tcb;
96: ER ercd = E_OK;
97:
98: CHECK_INTSK();
99: CHECK_TSKID(tskid);
100: CHECK_NONSELF(tskid);
101:
102: tcb = get_tcb(tskid);
103:
104: BEGIN_CRITICAL_SECTION;
105: if ( tcb->state == TS_NONEXIST ) {
106: ercd = E_NOEXS;
107: } else {
108: knl_get_reg(tcb, pk_regs, pk_eit, pk_cregs);
109: }
110: END_CRITICAL_SECTION;
111:
112: return ercd;
113: }
114:
115: #endif
116: #endif
117:
118: #if NUM_COPROCESSOR > 0
119: #ifdef USE_FUNC_TK_SET_CPR
120:
121: 122: 123:
124: SYSCALL ER tk_set_cpr( ID tskid, INT copno, CONST T_COPREGS *pk_copregs )
125: {
126: TCB *tcb;
127: ER ercd = E_OK;
128:
129: CHECK_INTSK();
130: CHECK_TSKID(tskid);
131: CHECK_NONSELF(tskid);
132:
133: tcb = get_tcb(tskid);
134: if((copno < 0) || (copno >= NUM_COPROCESSOR)
135: || !(tcb->tskatr & (TA_COP0 << copno))) {
136: return E_PAR;
137: }
138:
139: BEGIN_CRITICAL_SECTION;
140: if ( tcb->state == TS_NONEXIST ) {
141: ercd = E_NOEXS;
142: } else {
143: ercd = knl_set_cpr(tcb, copno, pk_copregs);
144: }
145: END_CRITICAL_SECTION;
146:
147: return ercd;
148: }
149: #endif
150:
151: #ifdef USE_FUNC_TK_GET_CPR
152:
153: 154: 155:
156: SYSCALL ER tk_get_cpr( ID tskid, INT copno, T_COPREGS *pk_copregs )
157: {
158: TCB *tcb;
159: ER ercd = E_OK;
160:
161: CHECK_INTSK();
162: CHECK_TSKID(tskid);
163: CHECK_NONSELF(tskid);
164:
165: tcb = get_tcb(tskid);
166: if((copno < 0) || (copno >= NUM_COPROCESSOR)
167: || !(tcb->tskatr & (TA_COP0 << copno))) {
168: return E_PAR;
169: }
170:
171: BEGIN_CRITICAL_SECTION;
172: if ( tcb->state == TS_NONEXIST ) {
173: ercd = E_NOEXS;
174: } else {
175: ercd = knl_get_cpr(tcb, copno, pk_copregs);
176: }
177: END_CRITICAL_SECTION;
178:
179: return ercd;
180: }
181: #endif
182: #endif
183:
184: #if USE_DBGSPT
185:
186: 187: 188:
189:
190: #if TK_SUPPORT_REGOPS
191: #ifdef USE_FUNC_TD_SET_REG
192:
193: 194: 195:
196: SYSCALL ER td_set_reg( ID tskid, CONST T_REGS *regs, CONST T_EIT *eit, CONST T_CREGS *cregs )
197: {
198: TCB *tcb;
199: ER ercd = E_OK;
200:
201: CHECK_TSKID(tskid);
202:
203: tcb = get_tcb(tskid);
204: if ( tcb == knl_ctxtsk ) {
205: return E_OBJ;
206: }
207:
208: BEGIN_DISABLE_INTERRUPT;
209: if ( tcb->state == TS_NONEXIST ) {
210: ercd = E_NOEXS;
211: } else {
212: knl_set_reg(tcb, regs, eit, cregs);
213: }
214: END_DISABLE_INTERRUPT;
215:
216: return ercd;
217: }
218: #endif
219:
220: #ifdef USE_FUNC_TD_GET_REG
221:
222: 223: 224:
225: SYSCALL ER td_get_reg( ID tskid, T_REGS *regs, T_EIT *eit, T_CREGS *cregs )
226: {
227: TCB *tcb;
228: ER ercd = E_OK;
229:
230: CHECK_TSKID(tskid);
231:
232: tcb = get_tcb(tskid);
233: if ( tcb == knl_ctxtsk ) {
234: return E_OBJ;
235: }
236:
237: BEGIN_DISABLE_INTERRUPT;
238: if ( tcb->state == TS_NONEXIST ) {
239: ercd = E_NOEXS;
240: } else {
241: knl_get_reg(tcb, regs, eit, cregs);
242: }
243: END_DISABLE_INTERRUPT;
244:
245: return ercd;
246: }
247: #endif
248: #endif
249:
250: #endif