1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: 17: 18: 19:
20:
21: #include "kernel.h"
22: #include "task.h"
23: #include "check.h"
24: #include <sys/rominfo.h>
25:
26: IMPORT const T_RVER kernel_version;
27:
28: 29: 30:
31: SYSCALL ER _tk_ref_sys( T_RSYS *pk_rsys )
32: {
33: if ( in_indp() ) {
34: pk_rsys->sysstat = TSS_INDP;
35: } else {
36: if ( in_qtsk() ) {
37: pk_rsys->sysstat = TSS_QTSK;
38: } else {
39: pk_rsys->sysstat = TSS_TSK;
40: }
41: if ( in_loc() ) {
42: pk_rsys->sysstat |= TSS_DINT;
43: }
44: if ( in_ddsp() ) {
45: pk_rsys->sysstat |= TSS_DDSP;
46: }
47: }
48: pk_rsys->runtskid = ( ctxtsk != NULL )? ctxtsk->tskid: 0;
49: pk_rsys->schedtskid = ( schedtsk != NULL )? schedtsk->tskid: 0;
50:
51: return E_OK;
52: }
53:
54: 55: 56: 57: 58:
59: #define RVER_PRNO_SIZE (4)
60: SYSCALL ER _tk_ref_ver( T_RVER *pk_rver )
61: {
62: INT info[RVER_PRNO_SIZE];
63: INT n;
64:
65: MEMCPY(pk_rver, &kernel_version, sizeof(T_RVER));
66:
67: if ( (n = _tk_get_cfn(SCTAG_MAKER, info, 1)) >= 1 ) {
68: pk_rver->maker = (UH)info[0];
69: }
70: if ( (n = _tk_get_cfn(SCTAG_PRODUCTID, info, 1)) >= 1) {
71: pk_rver->prid = (UH)info[0];
72: }
73: if ( (n = _tk_get_cfn(SCTAG_SPECVER, info, 1)) >= 1) {
74: pk_rver->spver = (UH)info[0];
75: }
76: if ( (n = _tk_get_cfn(SCTAG_PRODUCTVER, info, 1)) >= 1) {
77: pk_rver->prver = (UH)info[0];
78: }
79: if ( (n = _tk_get_cfn(SCTAG_PRODUCTNO, info, RVER_PRNO_SIZE)) >= 1) {
80: if (n > RVER_PRNO_SIZE) {
81: n = RVER_PRNO_SIZE;
82: }
83: while (--n >= 0) {
84: pk_rver->prno[n] = (UH)info[n];
85: }
86: }
87:
88: return E_OK;
89: }
90:
91: 92: 93: 94:
95: EXPORT UINT lowpow_discnt = 0;
96:
97: #define LOWPOW_LIMIT 0x7fff
98:
99: 100: 101:
102: SYSCALL ER _tk_set_pow( UINT pwmode )
103: {
104: IMPORT void off_pow( void );
105: ER ercd = E_OK;
106:
107: CHECK_INTSK();
108:
109: BEGIN_CRITICAL_SECTION;
110: switch ( pwmode ) {
111: case TPW_DOSUSPEND:
112: off_pow();
113: break;
114:
115: case TPW_DISLOWPOW:
116: if ( lowpow_discnt >= LOWPOW_LIMIT ) {
117: ercd = E_QOVR;
118: } else {
119: lowpow_discnt++;
120: }
121: break;
122: case TPW_ENALOWPOW:
123: if ( lowpow_discnt <= 0 ) {
124: ercd = E_OBJ;
125: } else {
126: lowpow_discnt--;
127: }
128: break;
129:
130: default:
131: ercd = E_PAR;
132: }
133: END_CRITICAL_SECTION;
134:
135: return ercd;
136: }
137:
138:
139: 140: 141:
142: #if USE_DBGSPT
143:
144: 145: 146:
147: EXPORT FP hook_enterfn;
148: EXPORT FP hook_leavefn;
149: EXPORT FP hook_execfn;
150: EXPORT FP hook_stopfn;
151: EXPORT FP hook_ienterfn;
152: EXPORT FP hook_ileavefn;
153:
154: #if TA_GP
155: EXPORT void *hook_svc_gp;
156: EXPORT void *hook_dsp_gp;
157: EXPORT void *hook_int_gp;
158: #endif
159:
160: 161: 162:
163: IMPORT void hook_svc( void );
164: IMPORT void unhook_svc( void );
165: IMPORT void hook_dsp( void );
166: IMPORT void unhook_dsp( void );
167: IMPORT void hook_int( void );
168: IMPORT void unhook_int( void );
169:
170: 171: 172:
173: SYSCALL ER _td_hok_svc P1( CONST TD_HSVC *hsvc )
174: {
175: BEGIN_DISABLE_INTERRUPT;
176: if ( hsvc == NULL ) {
177:
178: unhook_svc();
179: } else {
180:
181: hook_enterfn = hsvc->enter;
182: hook_leavefn = hsvc->leave;
183: #if TA_GP
184: hook_svc_gp = gp;
185: #endif
186: hook_svc();
187: }
188: END_DISABLE_INTERRUPT;
189:
190: return E_OK;
191: }
192:
193: 194:
195: SYSCALL ER _td_hok_dsp P1( CONST TD_HDSP *hdsp )
196: {
197: BEGIN_DISABLE_INTERRUPT;
198: if ( hdsp == NULL ) {
199:
200: unhook_dsp();
201: } else {
202:
203: hook_execfn = hdsp->exec;
204: hook_stopfn = hdsp->stop;
205: #if TA_GP
206: hook_dsp_gp = gp;
207: #endif
208: hook_dsp();
209: }
210: END_DISABLE_INTERRUPT;
211:
212: return E_OK;
213: }
214:
215: 216: 217:
218: SYSCALL ER _td_hok_int P1( CONST TD_HINT *hint )
219: {
220: BEGIN_DISABLE_INTERRUPT;
221: if ( hint == NULL ) {
222:
223: unhook_int();
224: } else {
225:
226: hook_ienterfn = hint->enter;
227: hook_ileavefn = hint->leave;
228: #if TA_GP
229: hook_int_gp = gp;
230: #endif
231: hook_int();
232: }
233: END_DISABLE_INTERRUPT;
234:
235: return E_OK;
236: }
237:
238: 239: 240:
241: SYSCALL ER _td_ref_sys( TD_RSYS *pk_rsys )
242: {
243: if ( in_indp() ) {
244: pk_rsys->sysstat = TSS_INDP;
245: } else {
246: if ( in_qtsk() ) {
247: pk_rsys->sysstat = TSS_QTSK;
248: } else {
249: pk_rsys->sysstat = TSS_TSK;
250: }
251: if ( in_loc() ) {
252: pk_rsys->sysstat |= TSS_DINT;
253: }
254: if ( in_ddsp() ) {
255: pk_rsys->sysstat |= TSS_DDSP;
256: }
257: }
258: pk_rsys->runtskid = ( ctxtsk != NULL )? ctxtsk->tskid: 0;
259: pk_rsys->schedtskid = ( schedtsk != NULL )? schedtsk->tskid: 0;
260:
261: return E_OK;
262: }
263:
264: #endif