[363] | 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 | *
|
---|
| 9 | * ä¸è¨èä½æ¨©è
|
---|
| 10 | ã¯ï¼ä»¥ä¸ã® (1)ã(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
| 11 | * ã«ãã£ã¦å
|
---|
| 12 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
| 13 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
| 14 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
| 15 | å¸ï¼ä»¥ä¸ï¼
|
---|
| 16 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 17 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
| 18 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
| 19 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 20 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 21 | * ç¨ã§ããå½¢ã§åé
|
---|
| 22 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 23 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
| 24 | * è
|
---|
| 25 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
| 26 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 27 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 28 | * ç¨ã§ããªãå½¢ã§åé
|
---|
| 29 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
| 30 | * ã¨ï¼
|
---|
| 31 | * (a) åé
|
---|
| 32 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 33 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
| 34 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 35 | * (b) åé
|
---|
| 36 | å¸ã®å½¢æ
|
---|
| 37 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
| 38 | * å ±åãããã¨ï¼
|
---|
| 39 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
| 40 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 41 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 42 | 責ãããã¨ï¼
|
---|
| 43 | *
|
---|
| 44 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 45 | ã
|
---|
| 46 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
| 47 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
| 48 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
| 49 | *
|
---|
| 50 | * @(#) $Id: eventlog.c,v 1.7 2003/12/15 07:19:22 takayuki Exp $
|
---|
| 51 | */
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | #include <s_services.h>
|
---|
| 55 |
|
---|
| 56 | #ifdef EVENTLOG_ENABLE
|
---|
| 57 |
|
---|
| 58 | #include "jsp_kernel.h"
|
---|
| 59 | #include "task.h"
|
---|
| 60 | #include "semaphore.h"
|
---|
| 61 | #include "dataqueue.h"
|
---|
| 62 | #include "eventflag.h"
|
---|
| 63 | #include "mempfix.h"
|
---|
| 64 | #include "mailbox.h"
|
---|
| 65 |
|
---|
| 66 | //#include <kernel_debug.h>
|
---|
| 67 |
|
---|
| 68 | extern SEMCB semcb_table[1];
|
---|
| 69 | extern UINT tmax_semid;
|
---|
| 70 | extern FLGCB flgcb_table[1];
|
---|
| 71 | extern UINT tmax_flgid;
|
---|
| 72 | extern DTQCB dtqcb_table[1];
|
---|
| 73 | extern UINT tmax_dtqid;
|
---|
| 74 | extern MBXCB mbxcb_table[1];
|
---|
| 75 | extern UINT tmax_mbxid;
|
---|
| 76 | extern MPFCB mpfcb_table[1];
|
---|
| 77 | extern UINT tmax_mpfid;
|
---|
| 78 |
|
---|
| 79 | /*
|
---|
| 80 | * ã¤ãã³ããã°åºåç¨ ã¿ã¹ã¯ç¶æ
|
---|
| 81 | åå¾é¢æ°
|
---|
| 82 | * (com_support.cã¯C++ã«ãªãã®ã§ãããã«ç½®ã)
|
---|
| 83 | */
|
---|
| 84 |
|
---|
| 85 | Inline BOOL is_inside_of(void * src, void * min, void * sup)
|
---|
| 86 | { return ((long)src >= (long)min) && ((long)src < (long)sup); }
|
---|
| 87 |
|
---|
| 88 | static void decode_waitstatus(TCB * tcb, unsigned int * objtype, int * objid)
|
---|
| 89 | {
|
---|
| 90 | QUEUE * queue;
|
---|
| 91 |
|
---|
| 92 | if((tcb->tstat & TS_WAIT_SLEEP) != 0)
|
---|
| 93 | {
|
---|
| 94 | *objtype = TTW_SLP;
|
---|
| 95 | }else
|
---|
| 96 | {
|
---|
| 97 | if((tcb->tstat & TS_WAIT_WOBJCB) != 0)
|
---|
| 98 | {
|
---|
| 99 | do {
|
---|
| 100 | queue = tcb->task_queue.next;
|
---|
| 101 | } while( queue != &tcb->task_queue && is_inside_of(queue, tcb_table, &tcb_table[TNUM_TSK]) );
|
---|
| 102 |
|
---|
| 103 | if(queue == &tcb->task_queue)
|
---|
| 104 | *objtype = 0;
|
---|
| 105 |
|
---|
| 106 | /* ã»ããã© */
|
---|
| 107 | else if(is_inside_of(queue, semcb_table, &semcb_table[tmax_semid-1]))
|
---|
| 108 | {
|
---|
| 109 | *objtype = TTW_SEM;
|
---|
| 110 | *objid = ((long)queue - (long)semcb_table) / sizeof(SEMCB) + 1;
|
---|
| 111 | }
|
---|
| 112 | /* ã¤ãã³ããã©ã° */
|
---|
| 113 | else if(is_inside_of(queue, flgcb_table, &flgcb_table[tmax_flgid-1]))
|
---|
| 114 | {
|
---|
| 115 | *objtype = TTW_FLG;
|
---|
| 116 | *objid = ((long)queue - (long)flgcb_table) / sizeof(FLGCB) + 1;
|
---|
| 117 | }
|
---|
| 118 | /* ãã¼ã¿ãã¥ã¼ */
|
---|
| 119 | else if(is_inside_of(queue, dtqcb_table, &dtqcb_table[tmax_dtqid-1]))
|
---|
| 120 | {
|
---|
| 121 | if(((long)queue % sizeof(DTQCB)) == (long)(&((DTQCB *)0)->rwait_queue))
|
---|
| 122 | *objtype = TTW_RDTQ;
|
---|
| 123 | else
|
---|
| 124 | *objtype = TTW_SDTQ;
|
---|
| 125 | *objid = ((long)queue - (long)dtqcb_table) / sizeof(DTQCB) + 1;
|
---|
| 126 | }
|
---|
| 127 | /* ã¡ã¼ã«ããã¯ã¹ */
|
---|
| 128 | else if(is_inside_of(queue, mbxcb_table, &mbxcb_table[tmax_mbxid-1]))
|
---|
| 129 | {
|
---|
| 130 | *objtype = TTW_MBX;
|
---|
| 131 | *objid = ((long)queue - (long)mbxcb_table) / sizeof(MBXCB) + 1;
|
---|
| 132 | }
|
---|
| 133 | /* åºå®é·ã¡ã¢ãªãã¼ã« */
|
---|
| 134 | else if(is_inside_of(queue, mpfcb_table, &mpfcb_table[tmax_mpfid-1]))
|
---|
| 135 | {
|
---|
| 136 | *objtype = TTW_MPL;
|
---|
| 137 | *objid = ((long)queue - (long)mpfcb_table) / sizeof(MPFCB) + 1;
|
---|
| 138 | }
|
---|
| 139 | }else
|
---|
| 140 | {
|
---|
| 141 | /* slp_tskã§ã¯ãªãããªãã¸ã§ã¯ãå¾
|
---|
| 142 | ã¡ãã¥ã¼ã«ã¤ãªããã¦ããªãã¿ã¤ã ã¢ã¦ãä»ãã®å¾
|
---|
| 143 | ã¡ -> dly_tsk */
|
---|
| 144 | if(tcb->winfo->tmevtb != NULL)
|
---|
| 145 | *objtype = TTW_DLY;
|
---|
| 146 | }
|
---|
| 147 | }
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | void decode_taskstatus(TCB * tcb, int * tskid, unsigned int * tskstat, unsigned int * objtype, int * objid)
|
---|
| 151 | {
|
---|
| 152 | int stat = tcb->tstat;
|
---|
| 153 |
|
---|
| 154 | /* ã¿ã¹ã¯ID */
|
---|
| 155 | *tskid = TSKID(tcb);
|
---|
| 156 |
|
---|
| 157 | /* ã¿ã¹ã¯ç¶æ
|
---|
| 158 | */
|
---|
| 159 | *tskstat = TTS_DMT;
|
---|
| 160 | if((stat & TS_RUNNABLE) != 0)
|
---|
| 161 | {
|
---|
| 162 | *tskstat = TTS_RDY;
|
---|
| 163 | }else
|
---|
| 164 | {
|
---|
| 165 | if((stat & TS_WAITING) != 0)
|
---|
| 166 | {
|
---|
| 167 | /* å¾
|
---|
| 168 | ã¡æ
|
---|
| 169 | å ±ã®ãã³ã¼ã */
|
---|
| 170 | decode_waitstatus((TCB *)tcb, objtype, objid);
|
---|
| 171 |
|
---|
| 172 | if((stat & TS_SUSPENDED) != 0)
|
---|
| 173 | *tskstat = TTS_WAS;
|
---|
| 174 | else
|
---|
| 175 | *tskstat = TTS_WAI;
|
---|
| 176 | }else
|
---|
| 177 | {
|
---|
| 178 | if((stat & TS_SUSPENDED) != 0)
|
---|
| 179 | *tskstat = TTS_SUS;
|
---|
| 180 | }
|
---|
| 181 | }
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | #endif
|
---|
| 185 |
|
---|