1 | # -*- coding: utf-8 -*-
|
---|
2 | #
|
---|
3 | # TOPPERS/ASP Kernel
|
---|
4 | # Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
5 | # Advanced Standard Profile Kernel
|
---|
6 | #
|
---|
7 | # Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
|
---|
8 | # Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
|
---|
9 | # Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
10 | #
|
---|
11 | # ä¸è¨èä½æ¨©è
|
---|
12 | ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
13 | # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
14 | # å¤ã»åé
|
---|
15 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
16 | # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
17 | # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
18 | # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
19 | # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
20 | # ç¨ã§ããå½¢ã§åé
|
---|
21 | å¸ããå ´åã«ã¯ï¼åé
|
---|
22 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
23 | # è
|
---|
24 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
25 | # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
26 | # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
27 | # ç¨ã§ããªãå½¢ã§åé
|
---|
28 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
29 | # ã¨ï¼
|
---|
30 | # (a) åé
|
---|
31 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
32 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
33 | # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
34 | # (b) åé
|
---|
35 | å¸ã®å½¢æ
|
---|
36 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
37 | # å ±åãããã¨ï¼
|
---|
38 | # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
39 | # 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
40 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
41 | 責ãããã¨ï¼
|
---|
42 | # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
43 | # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
44 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
45 | # å
|
---|
46 | 責ãããã¨ï¼
|
---|
47 | #
|
---|
48 | # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
49 | ã
|
---|
50 | # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
51 | # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
52 | # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
53 | # ã®è²¬ä»»ãè² ããªãï¼
|
---|
54 | #
|
---|
55 | # $Id: kernel_check.trb 662 2016-02-27 02:33:51Z ertl-hiro $
|
---|
56 | #
|
---|
57 |
|
---|
58 | #
|
---|
59 | # ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ã®ãã¹3ã®çæã¹ã¯ãªãã
|
---|
60 | #
|
---|
61 |
|
---|
62 | #
|
---|
63 | # ã¿ã¤ã ã¹ã¿ã³ããã¡ã¤ã«ã®æå®
|
---|
64 | #
|
---|
65 | $timeStampFileName = "check.timestamp"
|
---|
66 |
|
---|
67 | #
|
---|
68 | # ãã¼ã¿ã»ã¯ã·ã§ã³ã®LMAããVMAã¸ã®ã³ãã¼
|
---|
69 | #
|
---|
70 | if !$lmaList.nil?
|
---|
71 | $lmaList.each do |lma|
|
---|
72 | startData = SYMBOL(lma[:START_DATA])
|
---|
73 | endData = SYMBOL(lma[:END_DATA])
|
---|
74 | startIdata = SYMBOL(lma[:START_IDATA])
|
---|
75 | if startData.nil?
|
---|
76 | error_exit("symbol `lma[:START_DATA]' not found")
|
---|
77 | elsif endData.nil?
|
---|
78 | error_exit("symbol `lma[:END_DATA]' not found")
|
---|
79 | elsif startIdata.nil?
|
---|
80 | error_exit("symbol `lma[:START_IDATA]' not found")
|
---|
81 | else
|
---|
82 | BCOPY(startIdata, startData, endData - startData)
|
---|
83 | end
|
---|
84 | end
|
---|
85 | end
|
---|
86 |
|
---|
87 | #
|
---|
88 | # éç¥æ
|
---|
89 | å ±ã®ãã§ãã¯é¢æ°
|
---|
90 | #
|
---|
91 | $tmax_tskid = $TMIN_TSKID + $cfgData[:CRE_TSK].size - 1
|
---|
92 | $tmax_semid = $TMIN_SEMID + $cfgData[:CRE_SEM].size - 1
|
---|
93 | $tmax_flgid = $TMIN_FLGID + $cfgData[:CRE_FLG].size - 1
|
---|
94 | $tmax_dtqid = $TMIN_DTQID + $cfgData[:CRE_DTQ].size - 1
|
---|
95 | $tmax_mbxid = $TMIN_MBXID + $cfgData[:CRE_MBX].size - 1
|
---|
96 |
|
---|
97 | #
|
---|
98 | # ã¿ã¹ã¯ã«é¢ãããã§ãã¯
|
---|
99 | #
|
---|
100 | tinib = SYMBOL("_kernel_tinib_table")
|
---|
101 | $cfgData[:CRE_TSK].sort.each do |key, params|
|
---|
102 | task = PEEK(tinib + $offsetof_TINIB_task, $sizeof_TASK)
|
---|
103 |
|
---|
104 | # ã¿ã¹ã¯ã®å
|
---|
105 | é çªå°ã®ãã§ãã¯ï¼»NGKI1033ï¼½
|
---|
106 | if (task & ($CHECK_FUNC_ALIGN - 1)) != 0
|
---|
107 | error_wrong_id("E_PAR", params, :task, :tskid, "not aligned")
|
---|
108 | end
|
---|
109 | if $CHECK_FUNC_NONNULL && task == 0
|
---|
110 | error_wrong_id("E_PAR", params, :task, :tskid, "null")
|
---|
111 | end
|
---|
112 |
|
---|
113 | # ã¿ã¹ã¯ã®ã¹ã¿ãã¯é åã®å
|
---|
114 | é çªå°ã®ãã§ãã¯ï¼»NGKI1056ï¼½
|
---|
115 | if $USE_TSKINICTXB
|
---|
116 | stk = GetStackTskinictxb(key, params, tinib)
|
---|
117 | else
|
---|
118 | stk = PEEK(tinib + $offsetof_TINIB_stk, $sizeof_void_ptr)
|
---|
119 | end
|
---|
120 | if (stk & ($CHECK_STACK_ALIGN - 1)) != 0
|
---|
121 | error_wrong_id("E_PAR", params, :stk, :tskid, "not aligned")
|
---|
122 | end
|
---|
123 | if $CHECK_STACK_NONNULL && stk == 0
|
---|
124 | error_wrong_id("E_PAR", params, :stk, :tskid, "null")
|
---|
125 | end
|
---|
126 |
|
---|
127 | tinib += $sizeof_TINIB
|
---|
128 | end
|
---|
129 |
|
---|
130 | #
|
---|
131 | # åºå®é·ã¡ã¢ãªãã¼ã«ã«é¢ãããã§ãã¯
|
---|
132 | #
|
---|
133 | mpfinib = SYMBOL("_kernel_mpfinib_table")
|
---|
134 | $cfgData[:CRE_MPF].sort.each do |key, params|
|
---|
135 | mpf = PEEK(mpfinib + $offsetof_MPFINIB_mpf, $sizeof_void_ptr)
|
---|
136 |
|
---|
137 | # åºå®é·ã¡ã¢ãªãã¼ã«é åã®å
|
---|
138 | é çªå°ã®ãã§ãã¯ï¼»NGKI2249ï¼½
|
---|
139 | if (mpf & ($CHECK_MPF_ALIGN - 1)) != 0
|
---|
140 | error_wrong_id("E_PAR", params, :mpf, :mpfid, "not aligned")
|
---|
141 | end
|
---|
142 | if $CHECK_MPF_NONNULL && mpf == 0
|
---|
143 | error_wrong_id("E_PAR", params, :mpf, :mpfid, "null")
|
---|
144 | end
|
---|
145 |
|
---|
146 | mpfinib += $sizeof_MPFINIB
|
---|
147 | end
|
---|
148 |
|
---|
149 | #
|
---|
150 | # å¨æéç¥ã«é¢ãããã§ãã¯
|
---|
151 | #
|
---|
152 | cycinib = SYMBOL("_kernel_cycinib_table")
|
---|
153 | $cfgData[:CRE_CYC].sort.each do |key, params|
|
---|
154 | exinf = PEEK(cycinib + $offsetof_CYCINIB_exinf, $sizeof_intptr_t)
|
---|
155 | cychdr = PEEK(cycinib + $offsetof_CYCINIB_cychdr, $sizeof_CYCHDR)
|
---|
156 |
|
---|
157 | # ãã³ãã©ã®å
|
---|
158 | é çªå°ã®ãã§ãã¯ï¼»NGKI3135ï¼½
|
---|
159 | if (cychdr && ($CHECK_FUNC_ALIGN - 1)) != 0
|
---|
160 | error_wrong_id("E_PAR", params, :cychdr, :cycid, "not aligned")
|
---|
161 | end
|
---|
162 | if $CHECK_FUNC_NONNULL && :cychdr == 0
|
---|
163 | error_wrong_id("E_PAR", params, :cychdr, :cycid, "null")
|
---|
164 | end
|
---|
165 |
|
---|
166 | cycinib += $sizeof_CYCINIB
|
---|
167 | end
|
---|
168 |
|
---|
169 | #
|
---|
170 | # ã¢ã©ã¼ã éç¥ã«é¢ãããã§ãã¯
|
---|
171 | #
|
---|
172 | alminib = SYMBOL("_kernel_alminib_table")
|
---|
173 | $cfgData[:CRE_ALM].sort.each do |key, params|
|
---|
174 | exinf = PEEK(alminib + $offsetof_ALMINIB_exinf, $sizeof_intptr_t)
|
---|
175 | almhdr = PEEK(alminib + $offsetof_ALMINIB_almhdr, $sizeof_ALMHDR)
|
---|
176 |
|
---|
177 | # ãã³ãã©ã®å
|
---|
178 | é çªå°ã®ãã§ãã¯ï¼»NGKI3135ï¼½
|
---|
179 | if (almhdr && ($CHECK_FUNC_ALIGN - 1)) != 0
|
---|
180 | error_wrong_id("E_PAR", params, :almhdr, :almid, "not aligned")
|
---|
181 | end
|
---|
182 | if $CHECK_FUNC_NONNULL && params[:almhdr] == 0
|
---|
183 | error_wrong_id("E_PAR", params, :almhdr, :almid, "null")
|
---|
184 | end
|
---|
185 |
|
---|
186 | alminib += $sizeof_ALMINIB
|
---|
187 | end
|
---|
188 |
|
---|
189 | #
|
---|
190 | # å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã«é¢ãããã§ãã¯
|
---|
191 | #
|
---|
192 | isrinib = SYMBOL("_kernel_sisrinib_table")
|
---|
193 | $cfgData[:ATT_ISR].sort.each do |key, params|
|
---|
194 | isr = PEEK(isrinib + $offsetof_ISRINIB_isr, $sizeof_ISR)
|
---|
195 |
|
---|
196 | # å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã®å
|
---|
197 | é çªå°ã®ãã§ãã¯ï¼»NGKI3004ï¼½
|
---|
198 | if (isr & ($CHECK_FUNC_ALIGN - 1)) != 0
|
---|
199 | error_wrong_id("E_PAR", params, :isr, :isrid, "not aligned")
|
---|
200 | end
|
---|
201 | if $CHECK_FUNC_NONNULL && isr == 0
|
---|
202 | error_wrong_id("E_PAR", params, :isr, :isrid, "null")
|
---|
203 | end
|
---|
204 |
|
---|
205 | isrinib += $sizeof_ISRINIB
|
---|
206 | end
|
---|
207 |
|
---|
208 | #
|
---|
209 | # éã¿ã¹ã¯ã³ã³ããã¹ãç¨ã®ã¹ã¿ãã¯é åã«é¢ãããã§ãã¯
|
---|
210 | #
|
---|
211 | istkAddr = SYMBOL("_kernel_istk")
|
---|
212 | if !istkAddr.nil?
|
---|
213 | istk = PEEK(istkAddr, $sizeof_void_ptr)
|
---|
214 |
|
---|
215 | # éã¿ã¹ã¯ã³ã³ããã¹ãç¨ã®ã¹ã¿ãã¯é åã®å
|
---|
216 | é çªå°ã®ãã§ãã¯ï¼»NGKI3222ï¼½
|
---|
217 | if (istk & ($CHECK_STACK_ALIGN - 1)) != 0
|
---|
218 | error_wrong("E_PAR", $cfgData[:DEF_ICS][1], :istk, "not aligned")
|
---|
219 | end
|
---|
220 | if $CHECK_STACK_NONNULL && istk == 0
|
---|
221 | error_wrong("E_PAR", $cfgData[:DEF_ICS][1], :istk, "null")
|
---|
222 | end
|
---|
223 | end
|
---|
224 |
|
---|
225 | #
|
---|
226 | # ã«ã¼ãã«ãå²ãä»ããã¡ã¢ãªé åã«é¢ãããã§ãã¯
|
---|
227 | #
|
---|
228 | kmmAddr = SYMBOL("_kernel_kmm")
|
---|
229 | if !kmmAddr.nil?
|
---|
230 | kmm = PEEK(kmmAddr, $sizeof_void_ptr)
|
---|
231 |
|
---|
232 | # ã«ã¼ãã«ãå²ãä»ããã¡ã¢ãªé åã®å
|
---|
233 | é çªå°ã®ãã§ãã¯
|
---|
234 | if (kmm & ($CHECK_MB_ALIGN - 1)) != 0
|
---|
235 | error_wrong("E_PAR", $cfgData[:DEF_KMM][1], :kmm, "not aligned")
|
---|
236 | end
|
---|
237 | end
|
---|