⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hook.c

📁 符合日本著名的ITRON规范的开源操作系统。 TOPPERS/JSP内核就是TOPPERS工程按μITRON4.0研发的第一个 软件
💻 C
字号:
/* *  TOPPERS/JSP Kernel *      Toyohashi Open Platform for Embedded Real-Time Systems/ *      Just Standard Profile Kernel *  *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory *                              Toyohashi Univ. of Technology, JAPAN *                2003      by Advanced Data Controls, Corp *  *  惧淡螟侯涪荚は·笆布の (1)×(4) の掘凤か·Free Software Foundation  *  によって给山されている GNU General Public License の Version 2 に淡 *  揭されている掘凤を塔たす眷圭に嘎り·塑ソフトウェア∈塑ソフトウェア *  を猖恃したものを崔むˉ笆布票じ∷を蝗脱ˇ剩澜ˇ猖恃ˇ浩芹邵∈笆布· *  网脱と钙ぶ∷することを痰浸で钓满するˉ *  (1) 塑ソフトウェアをソ〖スコ〖ドの妨で网脱する眷圭には·惧淡の螟侯 *      涪山绩·この网脱掘凤および布淡の痰瘦沮惮年が·そのままの妨でソ〖 *      スコ〖ド面に崔まれていることˉ *  (2) 塑ソフトウェアを·ライブラリ妨及など·戮のソフトウェア倡券に蝗 *      脱できる妨で浩芹邵する眷圭には·浩芹邵に燃うドキュメント∈网脱 *      荚マニュアルなど∷に·惧淡の螟侯涪山绩·この网脱掘凤および布淡 *      の痰瘦沮惮年を非很することˉ *  (3) 塑ソフトウェアを·怠达に寥み哈むなど·戮のソフトウェア倡券に蝗 *      脱できない妨で浩芹邵する眷圭には·肌のいずれかの掘凤を塔たすこ *      とˉ *    (a) 浩芹邵に燃うドキュメント∈网脱荚マニュアルなど∷に·惧淡の螟 *        侯涪山绩·この网脱掘凤および布淡の痰瘦沮惮年を非很することˉ *    (b) 浩芹邵の妨轮を·侍に年める数恕によって·TOPPERSプロジェクトに *        鼠桂することˉ *  (4) 塑ソフトウェアの网脱により木儡弄または粗儡弄に栏じるいかなる禄 *      巢からも·惧淡螟侯涪荚およびTOPPERSプロジェクトを倘勒することˉ *  *  塑ソフトウェアは·痰瘦沮で捏丁されているものであるˉ惧淡螟侯涪荚お *  よびTOPPERSプロジェクトは·塑ソフトウェアに簇して·その努脱材墙拉も *  崔めて·いかなる瘦沮も乖わないˉまた·塑ソフトウェアの网脱により木 *  儡弄または粗儡弄に栏じたいかなる禄巢に簇しても·その勒扦を砷わないˉ *  *  @(#) $Id: hook.c,v 1.2 2003/12/19 11:48:37 honda Exp $ */#ifdef GHS_HOOK#include "jsp_kernel.h"#include "kernel.h"#include "task.h"#include "ghs_hook.h"void sys_hook0(int grp, int code){    ID tskid=TSKID(runtsk);#if(GHS_HOOK != 1)    if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))        return;    if (tskid > TRACE_TNUM_TSKID || !(Ros_buf.hook.task_id[tskid]))        return;#endif    t_lock_cpu();    ghs_hook4(THG_SYS, tskid, code);    t_unlock_cpu();}void sys_hook0_i(int grp, int code){#if(GHS_HOOK != 1)    if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))        return;    if (!(Ros_buf.hook.task_id[0]))        return;#endif    t_lock_cpu();    ghs_hook4(THG_SYS, 0, code);    t_unlock_cpu();}void sys_hook1(int grp, int code, int p1){    ID tskid = TSKID(runtsk);#if(GHS_HOOK != 1)    if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))        return;    if (tskid > TRACE_TNUM_TSKID || !(Ros_buf.hook.task_id[tskid]))	return;#endif    t_lock_cpu();    ghs_hook5(THG_SYS, tskid, code, p1);    t_unlock_cpu();}void sys_hook1_i(int grp, int code, int p1){#if(GHS_HOOK != 1)    if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))        return;    if (!(Ros_buf.hook.task_id[0]))        return;#endif    t_lock_cpu();    ghs_hook5(THG_SYS, 0, code, p1);    t_unlock_cpu();}void sys_hook2(int grp, int code, int p1, int p2){    ID tskid = TSKID(runtsk);#if(GHS_HOOK != 1)    if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))        return;    if (tskid > TRACE_TNUM_TSKID || !(Ros_buf.hook.task_id[tskid]))        return;#endif    t_lock_cpu();    ghs_hook6(THG_SYS, tskid, code, p1, p2);    t_unlock_cpu();}void sys_hook2_i(int grp, int code, int p1, int p2){#if(GHS_HOOK != 1)    if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))        return;    if (!(Ros_buf.hook.task_id[0]))        return;#endif    t_lock_cpu();    ghs_hook6(THG_SYS, 0, code, p1, p2);    t_unlock_cpu();}void sys_hook3(int grp, int code, int p1, int p2, int p3){    ID tskid = TSKID(runtsk);#if(GHS_HOOK != 1)    if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))        return;    if (!(Ros_buf.hook.task_id[tskid & (TRACE_TNUM_TSKID-1)]))        return;#endif    t_lock_cpu();    ghs_hook7(THG_SYS, tskid, code, p1, p2, p3);    t_unlock_cpu();}void sys_hook4(int grp, int code, int p1, int p2, int p3, int p4){    ID tskid = TSKID(runtsk);#if(GHS_HOOK != 1)    if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))        return;    if (tskid > TRACE_TNUM_TSKID || !(Ros_buf.hook.task_id[tskid]))        return;#endif    t_lock_cpu();    ghs_hook8(THG_SYS, tskid, code, p1, p2, p3, p4);    t_unlock_cpu();}void trc_rtn_hook(int grp, int code, int ercd){    ID	tskid = TSKID(runtsk);#if(GHS_HOOK != 1)    if (!(Ros_buf.hook.trc_grp & THG_RET))        return;    if (!(Ros_buf.hook.trc_grp & THG_SYS) || !(Ros_buf.hook.sys_grp & grp))        return;    if (tskid > TRACE_TNUM_TSKID || !(Ros_buf.hook.task_id[tskid]))	return;#endif    t_lock_cpu();    ghs_hook5(THG_RET, tskid, code, ercd);    t_unlock_cpu();}/*CPUロック觉轮で钙ばれるため、CPUをロックする涩妥はない*/void sts_hook(ID tskid){	TCB	*tcb;	int tstat;#if(GHS_HOOK != 1)    if (!(Ros_buf.hook.trc_grp & THG_STS))        return;    if (tskid > TRACE_TNUM_TSKID || !(Ros_buf.hook.task_id[tskid]))        return;#endif    tcb = get_tcb(tskid);	tstat = (int)(tcb->tstat);	if(TSTAT_DORMANT(tstat)) tstat = 0x1;	/* 0x1:Dormant */	else if(TSTAT_RUNNABLE(tstat)) tstat = 0x0;	/* 0x0:Ready */	else if(TSTAT_WAITING(tstat)) {		if((tstat & (TS_WAIT_SLEEP | TS_WAIT_WOBJ)) == 0) tstat = 0x09;  /* 0x9:Delay */		else {			if((tstat & TS_WAIT_SLEEP) != 0) tstat = 0x08;  /* 0x8:Sleep */			else tstat = 0x0a;  /* 0xa:Waiting */		}	if(TSTAT_SUSPENDED(tstat)) tstat |= 0x10;	}	else if(TSTAT_SUSPENDED(tstat)) tstat = 0x10;	ghs_hook4(THG_STS, tskid, tstat);}void dispatch_hook(TCB	*tcb){    ID tskid;#if(GHS_HOOK != 1)    if (!(Ros_buf.hook.trc_grp & THG_DSP))        return;#endif    tskid = runtsk == NULL ? 0 : TSKID(runtsk);    t_lock_cpu();    ghs_hook4(THG_DSP, tskid, TSKID(tcb));}void exception_hook(int code, int addr){    int i;    ID tskid;#if(GHS_HOOK != 1)    if (!(Ros_buf.hook.trc_grp & THG_INT))        return;#endif    for(i = 0; i < TRACE_TNUM_EVT; i++){        if(Ros_buf.hook.evtcode[i] == 0) return;        if(Ros_buf.hook.evtcode[i] == code){            tskid = runtsk == NULL ? 0 : TSKID(runtsk);            ghs_hook5(THG_INT, tskid, code, addr);            return;        }    }}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -