source: anotherchoice/tags/jsp-1.4.4-full-UTF8/tools/GHS/ghs_hook_bld/hook.c@ 26

Last change on this file since 26 was 26, checked in by ykominami, 12 years ago

initial

File size: 7.2 KB
Line 
1/*
2 * TOPPERS/JSP Kernel
3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Just Standard Profile Kernel
5 *
6 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
7 * Toyohashi Univ. of Technology, JAPAN
8 * 2003 by Advanced Data Controls, Corp
9 *
10 * 上記著作権者
11は,以下の (1)〜(4) の条件か,Free Software Foundation
12 * によってå…
13¬è¡¨ã•ã‚Œã¦ã„ã‚‹ GNU General Public License の Version 2 に記
14 * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
15 * を改変したものを含む.以下同じ)を使用・複製・改変・再é…
16å¸ƒï¼ˆä»¥ä¸‹ï¼Œ
17 * 利用と呼ぶ)することを無償で許諾する.
18 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
19 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
20 * スコード中に含まれていること.
21 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
22 * 用できる形で再é…
23å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œå†é…
24å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨
25 * 者
26マニュアルなど)に,上記の著作権表示,この利用条件および下記
27 * の無保証規定を掲載すること.
28 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
29 * 用できない形で再é…
30å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œæ¬¡ã®ã„ずれかの条件を満たすこ
31 * と.
32 * (a) 再é…
33å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨è€…
34マニュアルなど)に,上記の著
35 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
36 * (b) 再é…
37å¸ƒã®å½¢æ…
38‹ã‚’,別に定める方法によって,TOPPERSプロジェクトに
39 * 報告すること.
40 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
41 * 害からも,上記著作権者
42およびTOPPERSプロジェクトをå…
43è²¬ã™ã‚‹ã“と.
44 *
45 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者
46お
47 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
48 * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
49 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
50 *
51 * @(#) $Id: hook.c,v 1.2 2003/12/19 11:48:37 honda Exp $
52 */
53
54#ifdef GHS_HOOK
55#include "jsp_kernel.h"
56#include "kernel.h"
57#include "task.h"
58#include "ghs_hook.h"
59
60void sys_hook0(int grp, int code)
61{
62 ID tskid=TSKID(runtsk);
63#if(GHS_HOOK != 1)
64 if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))
65 return;
66 if (tskid > TRACE_TNUM_TSKID || !(Ros_buf.hook.task_id[tskid]))
67 return;
68#endif
69 t_lock_cpu();
70 ghs_hook4(THG_SYS, tskid, code);
71 t_unlock_cpu();
72}
73
74void sys_hook0_i(int grp, int code)
75{
76#if(GHS_HOOK != 1)
77 if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))
78 return;
79 if (!(Ros_buf.hook.task_id[0]))
80 return;
81#endif
82 t_lock_cpu();
83 ghs_hook4(THG_SYS, 0, code);
84 t_unlock_cpu();
85}
86
87void sys_hook1(int grp, int code, int p1)
88{
89 ID tskid = TSKID(runtsk);
90#if(GHS_HOOK != 1)
91 if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))
92 return;
93 if (tskid > TRACE_TNUM_TSKID || !(Ros_buf.hook.task_id[tskid]))
94 return;
95#endif
96 t_lock_cpu();
97 ghs_hook5(THG_SYS, tskid, code, p1);
98 t_unlock_cpu();
99}
100
101void sys_hook1_i(int grp, int code, int p1)
102{
103#if(GHS_HOOK != 1)
104 if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))
105 return;
106 if (!(Ros_buf.hook.task_id[0]))
107 return;
108#endif
109 t_lock_cpu();
110 ghs_hook5(THG_SYS, 0, code, p1);
111 t_unlock_cpu();
112}
113
114void sys_hook2(int grp, int code, int p1, int p2)
115{
116 ID tskid = TSKID(runtsk);
117#if(GHS_HOOK != 1)
118 if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))
119 return;
120 if (tskid > TRACE_TNUM_TSKID || !(Ros_buf.hook.task_id[tskid]))
121 return;
122#endif
123 t_lock_cpu();
124 ghs_hook6(THG_SYS, tskid, code, p1, p2);
125 t_unlock_cpu();
126}
127
128void sys_hook2_i(int grp, int code, int p1, int p2)
129{
130#if(GHS_HOOK != 1)
131 if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))
132 return;
133 if (!(Ros_buf.hook.task_id[0]))
134 return;
135#endif
136 t_lock_cpu();
137 ghs_hook6(THG_SYS, 0, code, p1, p2);
138 t_unlock_cpu();
139}
140
141void sys_hook3(int grp, int code, int p1, int p2, int p3)
142{
143 ID tskid = TSKID(runtsk);
144#if(GHS_HOOK != 1)
145 if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))
146 return;
147 if (!(Ros_buf.hook.task_id[tskid & (TRACE_TNUM_TSKID-1)]))
148 return;
149#endif
150 t_lock_cpu();
151 ghs_hook7(THG_SYS, tskid, code, p1, p2, p3);
152 t_unlock_cpu();
153}
154
155void sys_hook4(int grp, int code, int p1, int p2, int p3, int p4)
156{
157 ID tskid = TSKID(runtsk);
158#if(GHS_HOOK != 1)
159 if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))
160 return;
161 if (tskid > TRACE_TNUM_TSKID || !(Ros_buf.hook.task_id[tskid]))
162 return;
163#endif
164 t_lock_cpu();
165 ghs_hook8(THG_SYS, tskid, code, p1, p2, p3, p4);
166 t_unlock_cpu();
167}
168
169
170void trc_rtn_hook(int grp, int code, int ercd)
171{
172 ID tskid = TSKID(runtsk);
173#if(GHS_HOOK != 1)
174 if (!(Ros_buf.hook.trc_grp & THG_RET))
175 return;
176 if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))
177 return;
178 if (tskid > TRACE_TNUM_TSKID || !(Ros_buf.hook.task_id[tskid]))
179 return;
180#endif
181 t_lock_cpu();
182 ghs_hook5(THG_RET, tskid, code, ercd);
183 t_unlock_cpu();
184}
185
186/*CPUロック状æ…
187‹ã§å‘¼ã°ã‚Œã‚‹ãŸã‚ã€CPUをロックする必
188要はない*/
189void sts_hook(ID tskid)
190{
191 TCB *tcb;
192 int tstat;
193#if(GHS_HOOK != 1)
194 if (!(Ros_buf.hook.trc_grp & THG_STS))
195 return;
196 if (tskid > TRACE_TNUM_TSKID || !(Ros_buf.hook.task_id[tskid]))
197 return;
198#endif
199 tcb = get_tcb(tskid);
200 tstat = (int)(tcb->tstat);
201 if(TSTAT_DORMANT(tstat)) tstat = 0x1; /* 0x1:Dormant */
202 else if(TSTAT_RUNNABLE(tstat)) tstat = 0x0; /* 0x0:Ready */
203 else if(TSTAT_WAITING(tstat)) {
204 if((tstat & (TS_WAIT_SLEEP | TS_WAIT_WOBJ)) == 0) tstat = 0x09; /* 0x9:Delay */
205 else {
206 if((tstat & TS_WAIT_SLEEP) != 0) tstat = 0x08; /* 0x8:Sleep */
207 else tstat = 0x0a; /* 0xa:Waiting */
208 }
209 if(TSTAT_SUSPENDED(tstat)) tstat |= 0x10;
210 }
211 else if(TSTAT_SUSPENDED(tstat)) tstat = 0x10;
212 ghs_hook4(THG_STS, tskid, tstat);
213}
214
215void dispatch_hook(TCB *tcb)
216{
217 ID tskid;
218
219#if(GHS_HOOK != 1)
220 if (!(Ros_buf.hook.trc_grp & THG_DSP))
221 return;
222#endif
223 tskid = runtsk == NULL ? 0 : TSKID(runtsk);
224 t_lock_cpu();
225 ghs_hook4(THG_DSP, tskid, TSKID(tcb));
226}
227
228void exception_hook(int code, int addr)
229{
230 int i;
231 ID tskid;
232
233#if(GHS_HOOK != 1)
234 if (!(Ros_buf.hook.trc_grp & THG_INT))
235 return;
236#endif
237 for(i = 0; i < TRACE_TNUM_EVT; i++){
238 if(Ros_buf.hook.evtcode[i] == 0) return;
239 if(Ros_buf.hook.evtcode[i] == code){
240 tskid = runtsk == NULL ? 0 : TSKID(runtsk);
241 ghs_hook5(THG_INT, tskid, code, addr);
242 return;
243 }
244 }
245}
246#endif
247
Note: See TracBrowser for help on using the repository browser.