source: anotherchoice/tags/jsp-1.4.4-full-UTF8/cfg/jsp/jsp_check.cpp

Last change on this file was 363, checked in by ykominami, 5 years ago

add tags/jsp-1.4.4-full-UTF8

  • Property svn:executable set to *
File size: 30.1 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 *
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: jsp_check.cpp,v 1.25 2005/07/06 01:29:21 honda Exp $
51 */
52
53// $Header: /home/CVS/configurator/jsp/jsp_check.cpp,v 1.25 2005/07/06 01:29:21 honda Exp $
54
55#include "base/defs.h"
56#include "jsp/jsp_defs.h"
57#include "base/message.h"
58#include "base/component.h"
59#include "base/filecontainer.h"
60
61#include <fstream>
62#include <iomanip>
63
64class ConfigurationChecker : public Component
65{
66public:
67
68 enum tagCheckLevel
69 {
70 UNKNOWN = 0,
71 LAZY = 1, /* 致命的 (行き過ぎ改造防止用) */
72 STANDARD = 2, /* ITRON仕様の範囲 (改造を許容) */
73 TOPPERS = 4, /* TOPPERS/JSPの範囲内
74 */
75 RESTRICTED = 8, /* 片っ端から捕まえる */
76
77 NORMAL = 8
78 };
79
80protected:
81 enum tagCheckLevel current_level;
82
83 unsigned int error_count;
84 std::string banner;
85
86 void set_banner(Directory &, Formatter , const char *, int);
87 void notify(enum tagCheckLevel, Formatter , bool = true);
88
89 bool check_taskblock(Directory &, FileContainer *);
90 bool check_semaphoreblock(Directory &, FileContainer *);
91 bool check_eventflagblock(Directory &, FileContainer *);
92 bool check_dataqueueblock(Directory &, FileContainer *);
93 bool check_mailboxblock(Directory &, FileContainer *);
94 bool check_fixed_memorypoolblock(Directory &, FileContainer *);
95 bool check_cyclic_handlerblock(Directory &, FileContainer *);
96 bool check_interrupt_handlerblock(Directory &, FileContainer *);
97 bool check_exception_handlerblock(Directory &, FileContainer *);
98
99 virtual void parseOption(Directory &);
100 virtual void body(Directory &);
101
102public:
103 ConfigurationChecker(void) throw();
104 ~ConfigurationChecker(void) throw() {}
105};
106
107//------------------------------------------------------
108using namespace std;
109
110static ConfigurationChecker instance_of_ConfigurationChecker;
111
112//------------------------------------------------------
113 //ターゲットの同名の型よりも大きな型の定義
114 // (注) 値比較, 演算が可能な型であること
115
116typedef int DT_INT;
117typedef unsigned int DT_UINT;
118typedef unsigned long DT_FP;
119typedef unsigned long DT_VP_INT;
120typedef unsigned long DT_VP;
121typedef long DT_RELTIM;
122
123//------------------------------------------------------
124
125ConfigurationChecker::ConfigurationChecker(void) throw()
126{
127 setBanner("--- TOPPERS/JSP Configuration Checker (ver 2.4) ---");
128}
129
130void ConfigurationChecker::set_banner(Directory & container, Formatter object, const char * type, int id)
131{
132 Directory * node;
133 char buffer[32];
134
135 banner = string(" ") + object.str() + " : ";
136
137 sprintf(buffer, "id = %d", id);
138
139 node = container.findChild(OBJECTTREE, type, NULL)->getFirstChild();
140 while(node != 0 && node->toInteger() != id)
141 node = node->getNext();
142
143 if( node != 0 ) {
144 banner += node->getKey() + " (" + buffer + ") ";
145
146 node = node->findChild("position");
147 if(node != 0)
148 banner += string("at ") + node->toString();
149 }
150 else
151 banner += buffer;
152
153 if(VerboseMessage::getVerbose())
154 {
155 cout << banner << endl;
156 banner.erase();
157 }
158}
159
160void ConfigurationChecker::notify(enum tagCheckLevel level, Formatter msg, bool error)
161{
162 if((level & current_level) != 0)
163 {
164
165 if(!banner.empty())
166 {
167 cout << banner << endl;
168 banner.erase();
169 }
170
171 cout << " ";
172
173 if(error)
174 {
175 cout << Message("[ Error ] ","[エラー] ");
176 error_count ++;
177 }else
178 cout << Message("[Warning] ","[ 警告 ] ");
179 cout << msg << endl;
180 }
181}
182
183 /*
184 * タスクオブジェクトに関するエラー検出
185 */
186
187bool ConfigurationChecker::check_taskblock(Directory & parameter, FileContainer * container)
188{
189 unsigned int id;
190 unsigned int maxpri;
191 unsigned int minpri;
192 unsigned int old_error_count = error_count;
193
194 TargetVariable<unsigned int> _kernel_tmax_tskid("_kernel_tmax_tskid");
195
196 Message object("Task","タスク");
197
198 if(!_kernel_tmax_tskid.isValid())
199 ExceptionMessage(
200 "Internal error: Unknown symbol (Probably, Symbol table was stripped)",
201 "内
202部エラー: 不正なシンボル名 (実行形式がシンボルテーブルを含んでない可能性があります)").throwException();
203
204 if(*_kernel_tmax_tskid < 1)
205 {
206 notify(RESTRICTED,
207 Message(" [Task] : No tasks created\n"," [タスク] : タスクオブジェクトがありません\n"));
208 return true;
209 }
210
211 TargetVariable<DT_UINT> tskatr("_kernel_tinib_table", "task_initialization_block::tskatr");
212 TargetVariable<DT_FP> task("_kernel_tinib_table", "task_initialization_block::task");
213 TargetVariable<DT_INT> ipriority("_kernel_tinib_table", "task_initialization_block::ipriority");
214 TargetVariable<DT_UINT> texatr("_kernel_tinib_table", "task_initialization_block::texatr");
215 TargetVariable<DT_UINT> stksz("_kernel_tinib_table", "task_initialization_block::stksz");
216
217 maxpri = container->getVariableInfo("TMAX_TPRI").value;
218 minpri = container->getVariableInfo("TMIN_TPRI").value;
219
220 VerboseMessage("% object : % items\n","%オブジェクト : % 個\n") << object << *_kernel_tmax_tskid;
221 for(id = 1; id <= *_kernel_tmax_tskid; id++)
222 {
223 set_banner(parameter, object, TASK, id);
224
225 /*
226 * 属性チェック
227 */
228
229 // 属性値が TA_HLNG|TA_ASM|TA_ACT 以外の値をとっている
230 if((*tskatr & ~0x3) != 0)
231 notify( STANDARD,
232 Message("Illegal task attribute (It should be ((TA_HLNG||TA_ASM)|TA_ACT))",
233 "不正なタスク属性 ((TA_HLNG||TA_ASM)|TA_ACT)以外"));
234
235 // 属性値に TA_ASM が含まれている
236 if((*tskatr & 0x1) != 0)
237 notify( RESTRICTED,
238 Message("TA_ASM specified as task attribute takes no effect.",
239 "タスク属性にTA_ASMが指定されている"));
240
241 /* 起動番地が0 */
242 if(*task == 0)
243 notify(RESTRICTED,
244 Message("The address of task routine is equal to zero.",
245 "開始番地に0が設定されています"));
246
247 /*
248 * 優å…
249ˆåº¦ãƒã‚§ãƒƒã‚¯
250 */
251
252 // 最大優å…
253ˆåº¦ã¨æœ€å°å„ªå…
254ˆåº¦ã®è¨­å®šãŒãŠã‹ã—い
255 if(maxpri < minpri)
256 notify(LAZY,
257 Message("Illegal Priority Settings found (TMAX_TPRI(%) < TMIN_TPRI).",
258 "初期優å…
259ˆåº¦ãŒæœ€ä½Žå„ªå…
260ˆåº¦(%)を超
261えている") << minpri);
262
263 // 優å…
264ˆåº¦ã®ç¯„囲が[最小優å…
265ˆåº¦, 最大優å…
266ˆåº¦]の範囲を超
267えている
268 if(*ipriority > (signed)(maxpri - minpri))
269 notify(TOPPERS,
270 Message("Initial priority is greater than maximum priority (%).",
271 "初期優å…
272ˆåº¦ãŒæœ€å¤§å„ªå…
273ˆåº¦(%)を超
274えている") << maxpri);
275 if(*ipriority < 0)
276 notify(STANDARD,
277 Message("Initial priority is less than the minimum priority (%).",
278 "初期優å…
279ˆåº¦ãŒæœ€ä½Žå„ªå…
280ˆåº¦(%)を下回る") << minpri);
281
282 /*
283 * タスク例外属性チェック
284 */
285
286 // 属性値がTA_HLNG or TA_ASMでない
287 if((*texatr & ~0x3) != 0)
288 notify(STANDARD,
289 Message("Task exception routine has an illegal attribute specifier.",
290 "タスク例外に無効な属性(TA_HLNG,TA_ASM以外) が設定されています"));
291
292 // 属性値に TA_ASM が含まれている
293 if((*texatr & 0x1) != 0)
294 notify( RESTRICTED,
295 Message("TA_ASM, specified as texatr, does not always take effect.",
296 "タスク例外にTA_ASMが指定されています"));
297
298 /*
299 * スタックチェック
300 */
301
302 // スタックサイズが0
303 if(*stksz == 0)
304 notify(RESTRICTED,
305 Message("Stack size is equal to zero.",
306 "スタックサイズに0が設定されています"));
307
308 // スタックの番地が0
309 if(*stksz == 0)
310 notify(RESTRICTED,
311 Message("The address of task stack is equal to zero.",
312 "スタック開始番地に0が設定されています"));
313
314 ++ tskatr, ++ task, ++ ipriority, ++ texatr, ++ stksz;
315 }
316
317 return old_error_count == error_count;
318}
319
320bool ConfigurationChecker::check_semaphoreblock(Directory & parameter, FileContainer * container)
321{
322 unsigned int id;
323 unsigned int old_error_count = error_count;
324
325 Message object("Semaphore","セマフォ");
326
327 TargetVariable<DT_UINT> _kernel_tmax_semid("_kernel_tmax_semid");
328 if(*_kernel_tmax_semid < 1)
329 return true;
330
331 TargetVariable<DT_UINT> sematr("_kernel_seminib_table","semaphore_initialization_block::sematr");
332 TargetVariable<DT_UINT> maxsem("_kernel_seminib_table","semaphore_initialization_block::maxsem");
333 TargetVariable<DT_UINT> isemcnt("_kernel_seminib_table","semaphore_initialization_block::isemcnt");
334
335 VerboseMessage("% object : % items\n","%オブジェクト : % 個\n")
336 << object << *_kernel_tmax_semid;
337
338 for(id = 1; id <= *_kernel_tmax_semid; id++)
339 {
340 set_banner(parameter, object, SEMAPHORE, id);
341
342 //attribute validation check
343 if((*sematr & ~0x1) != 0)
344 notify(STANDARD,
345 Message("Illegal attribute (It should be (TA_TFIFO||TA_TPRI)).",
346 "(TA_TFIFO||TA_TPRI)以外の属性が指定されている"));
347
348 //maxcnt < isemcnt
349 if(*maxsem < *isemcnt)
350 notify(STANDARD,
351 Message("Initial count[%] is greater than the maximum count[%] of this semaphore",
352 "初期値[%]が最大値[%]を超
353えている") << *isemcnt << *maxsem);
354
355 if(*maxsem == 0)
356 notify(STANDARD,
357 Message("Maximum count must be greater than zero.",
358 "セマフォの最大カウントは1以上でなければいけません"));
359
360 ++ sematr, ++ maxsem, ++ isemcnt;
361 }
362
363 return old_error_count == error_count;
364}
365
366
367bool ConfigurationChecker::check_eventflagblock(Directory & parameter, FileContainer * container)
368{
369 unsigned int id;
370 unsigned int old_error_count = error_count;
371
372 Message object("Event flag","イベントフラグ");
373
374 TargetVariable<DT_UINT> _kernel_tmax_flgid("_kernel_tmax_flgid");
375 if(*_kernel_tmax_flgid < 1)
376 return true;
377
378 TargetVariable<DT_UINT> flgatr("_kernel_flginib_table","eventflag_initialization_block::flgatr");
379
380 VerboseMessage("% object : % items\n","%オブジェクト : % 個\n")
381 << object << *_kernel_tmax_flgid;
382
383 for(id = 1; id <= *_kernel_tmax_flgid; id++)
384 {
385 set_banner(parameter, object, EVENTFLAG, id);
386
387 //attribute validation check
388 if((*flgatr & ~0x7) != 0)
389 notify(STANDARD,
390 Message("Illegal attribute value [0x%]",
391 "おかしな属性値 [0x%]") << setbase(16) << (*flgatr & ~0x7));
392
393 if((*flgatr & 0x2) != 0)
394 notify(TOPPERS, //依存部で直らないのでRESTRICTEDにしない
395 Message("Attribute TA_WMUL is not supported in current version.",
396 "TA_WMULはサポート外"));
397
398 ++ flgatr;
399 }
400
401 return old_error_count == error_count;
402}
403
404
405bool ConfigurationChecker::check_dataqueueblock(Directory & parameter, FileContainer * container)
406{
407 unsigned int id;
408 unsigned int old_error_count = error_count;
409
410 Message object("Data queue","データキュー");
411
412 TargetVariable<DT_UINT> _kernel_tmax_dtqid("_kernel_tmax_dtqid");
413 if(*_kernel_tmax_dtqid < 1)
414 return true;
415
416 TargetVariable<DT_UINT> dtqatr("_kernel_dtqinib_table", "dataqueue_initialization_block::dtqatr");
417 TargetVariable<DT_UINT> dtqcnt("_kernel_dtqinib_table", "dataqueue_initialization_block::dtqcnt");
418 TargetVariable<DT_VP_INT> dtq("_kernel_dtqinib_table", "dataqueue_initialization_block::dtq");
419
420 VerboseMessage("% object : % items\n","%オブジェクト : % 個\n")
421 << object << *_kernel_tmax_dtqid;
422
423 for(id = 1; id <= *_kernel_tmax_dtqid; id++)
424 {
425 set_banner(parameter, object, DATAQUEUE, id);
426
427 //attribute validation check
428 if((*dtqatr & ~0x1) != 0)
429 notify(STANDARD,
430 Message("Illegal attribute value [0x%]",
431 "おかしな属性値 [0x%]") << setbase(16) << (*dtqatr & ~0x1));
432
433 if(*dtqcnt != 0 && *dtq == 0)
434 notify(TOPPERS,
435 Message("Dataqueue buffer should not be NULL", "データキューのバッファがNULL値"));
436
437 ++ dtqatr, ++ dtqcnt, ++ dtq;
438 }
439
440 return old_error_count == error_count;
441}
442
443
444bool ConfigurationChecker::check_mailboxblock(Directory & parameter, FileContainer * container)
445{
446 unsigned int id;
447 unsigned int old_error_count = error_count;
448
449 Message object("Mailbox","メールボックス");
450
451 TargetVariable<DT_UINT> _kernel_tmax_mbxid("_kernel_tmax_mbxid");
452 if(*_kernel_tmax_mbxid < 1)
453 return true;
454
455 TargetVariable<DT_UINT> mbxatr("_kernel_mbxinib_table","mailbox_initialization_block::mbxatr");
456 TargetVariable<DT_INT> maxmpri("_kernel_mbxinib_table","mailbox_initialization_block::maxmpri");
457
458 DT_INT maxpri = container->getVariableInfo("TMAX_MPRI").value;
459 DT_INT minpri = container->getVariableInfo("TMIN_MPRI").value;
460
461 VerboseMessage("% object : % items\n","%オブジェクト : % 個\n") << object << *_kernel_tmax_mbxid;
462 for(id = 1; id <= *_kernel_tmax_mbxid; id++)
463 {
464 set_banner(parameter, object, MAILBOX, id);
465
466 //attribute validation check
467 if((*mbxatr & ~0x3) != 0)
468 notify(STANDARD,
469 Message("Illegal attribute value [0x%]",
470 "おかしな属性値 [0x%]") << setbase(16) << (*mbxatr & ~0x3));
471
472 //mailbox message priority check
473 if(*maxmpri < 0)
474 notify(STANDARD,
475 Message("Priority must not be a negative number.","優å…
476ˆåº¦ãŒè² å€¤"));
477
478 if(*maxmpri < minpri)
479 notify(STANDARD,
480 Message("Message priority should be greater than or equal to %.",
481 "メッセージ優å…
482ˆåº¦ã¯%以上でなければいけません") << minpri);
483
484 if(*maxmpri > maxpri)
485 notify(STANDARD,
486 Message("Message priority should be less than or equal to %.",
487 "メッセージ優å…
488ˆåº¦ã¯%以下でなければいけません") << maxpri);
489
490 ++ mbxatr, ++ maxmpri;
491 }
492
493 return old_error_count == error_count;
494}
495
496bool ConfigurationChecker::check_fixed_memorypoolblock(Directory & parameter, FileContainer * container)
497{
498 unsigned int id;
499 unsigned int old_error_count = error_count;
500
501 Message object("Fixed size memory pool","固定長メモリプール");
502
503 TargetVariable<DT_UINT> _kernel_tmax_mpfid("_kernel_tmax_mpfid");
504 if(*_kernel_tmax_mpfid < 1)
505 return true;
506
507 TargetVariable<DT_UINT> mpfatr("_kernel_mpfinib_table", "fixed_memorypool_initialization_block::mpfatr");
508 TargetVariable<DT_UINT> limit ("_kernel_mpfinib_table", "fixed_memorypool_initialization_block::limit");
509 TargetVariable<DT_VP> mpf ("_kernel_mpfinib_table", "fixed_memorypool_initialization_block::mpf");
510 TargetVariable<DT_UINT> blksz ("_kernel_mpfinib_table", "fixed_memorypool_initialization_block::blksz");
511
512 VerboseMessage("% object : % items\n","%オブジェクト : % 個\n") << object << *_kernel_tmax_mpfid;
513 for(id = 1; id <= *_kernel_tmax_mpfid; id++)
514 {
515 set_banner(parameter, object, FIXEDSIZEMEMORYPOOL, id);
516
517 //attribute validation check
518 if((*mpfatr & ~0x1) != 0)
519 notify(STANDARD,
520 Message("Illegal attribute value [0x%]","おかしな属性値 [0x%]") << (*mpfatr & ~0x1));
521
522 //ブロック数が0
523 if(*mpf == *limit)
524 notify(STANDARD,
525 Message("blkcnt should be a non-zero value.","ブロック数が0です"));
526
527 //ブロックサイズが0
528 if(*blksz == 0)
529 notify(STANDARD,
530 Message("blksz should be a non-zero value.","ブロックサイズが0です"));
531
532 //バッファアドレスが0
533 if(*mpf == 0)
534 notify(TOPPERS,
535 Message("buffer address is a NULL pointer.","バッファアドレスがNULLポインタになっています"));
536
537 ++ mpfatr, ++ limit, ++ mpf, ++ blksz;
538 }
539
540 return old_error_count == error_count;
541}
542
543
544bool ConfigurationChecker::check_cyclic_handlerblock(Directory & parameter, FileContainer * container)
545{
546 unsigned int id;
547 unsigned int old_error_count = error_count;
548
549 Message object("Cyclic handler","周期ハンドラ");
550
551 TargetVariable<DT_UINT> _kernel_tmax_cycid("_kernel_tmax_cycid");
552 if(*_kernel_tmax_cycid < 1)
553 return true;
554
555 DT_RELTIM maxreltim = container->getVariableInfo("TMAX_RELTIM").value;
556 TargetVariable<DT_UINT> cycatr("_kernel_cycinib_table", "cyclic_handler_initialization_block::cycatr");
557 TargetVariable<DT_RELTIM> cyctim("_kernel_cycinib_table", "cyclic_handler_initialization_block::cyctim");
558 TargetVariable<DT_RELTIM> cycphs("_kernel_cycinib_table", "cyclic_handler_initialization_block::cycphs");
559
560 VerboseMessage("% object : % items\n","%オブジェクト : % 個\n") << object << *_kernel_tmax_cycid;
561 for(id = 1; id <= *_kernel_tmax_cycid; id++)
562 {
563 set_banner(parameter, object, CYCLICHANDLER, id);
564
565 //attribute validation check
566 if((*cycatr & ~0x7) != 0)
567 notify(STANDARD,
568 Message("Illegal attribute value [0x%]","おかしな属性値 [0x%]") << (*cycatr & ~0x1));
569
570 if((*cycatr & 0x4) != 0)
571 notify(TOPPERS, //非依存部なのでRESTRICTEDにしない
572 Message("TA_PHS is not supported in this kernel.","TA_PHSはサポート外"));
573
574 // 属性値に TA_ASM が含まれている
575 if((*cycatr & 0x1) != 0)
576 notify( RESTRICTED,
577 Message("TOPPERS/JSP Kernel never minds the flag 'TA_ASM'.",
578 "TOPPERS/JSPカーネルのå…
579¨ã¦ã®æ©Ÿç¨®ä¾å­˜éƒ¨ã§TA_ASMをサポートするとは限らない"));
580
581 //RELTIMでの表現範囲内
582にあるかどうかのチェック
583 if(*cyctim > maxreltim)
584 notify(STANDARD,
585 Message("The cyclic object has a period (%) that exceeds the maximum period (%)",
586 "起動周期(%)が表現可能な相対時間の範囲(%)を超
587えています") << *cyctim << maxreltim);
588
589 //起動周期が0でないことのチェック
590 if(*cyctim == 0)
591 notify(STANDARD,
592 Message("The cyclic object has a ZERO period.",
593 "起動周期が0になっています"));
594
595 if(*cycphs > maxreltim)
596 notify(STANDARD,
597 Message("The cyclic object has a initial delay (%) that exceeds the maximum period (%)",
598 "起動位相(%)が表現可能な相対時間の範囲(%)を超
599えています") << *cycphs << maxreltim);
600
601 ++ cycatr, ++ cyctim, ++ cycphs;
602 }
603
604 return old_error_count == error_count;
605}
606
607bool ConfigurationChecker::check_interrupt_handlerblock(Directory & parameter, FileContainer * container)
608{
609 unsigned int id;
610 unsigned int old_error_count = error_count;
611
612 Message object("Interrupt handler","割込みハンドラ");
613
614 TargetVariable<DT_UINT> _kernel_tnum_inhno("_kernel_tnum_inhno");
615 if(*_kernel_tnum_inhno == 0)
616 return true;
617
618 TargetVariable<DT_UINT> inhatr("_kernel_inhinib_table", "interrupt_handler_initialization_block::inhatr");
619 TargetVariable<DT_FP> inthdr("_kernel_inhinib_table", "interrupt_handler_initialization_block::inthdr");
620
621 VerboseMessage("% object : % items\n","%オブジェクト : % 個\n") << object << *_kernel_tnum_inhno;
622 for(id = 0; id < *_kernel_tnum_inhno; id++)
623 {
624 set_banner(parameter, object, INTERRUPTHANDLER, id);
625
626 //attribute validation check
627 if((*inhatr & 0x1) != 0)
628 notify(STANDARD,
629 Message("The attribute can take only TA_HLNG|TA_ASM",
630 "TA_HLNG|TA_ASM以外の属性は設定できません"));
631
632 // 属性値に TA_ASM が含まれている
633 if((*inhatr & 0x1) != 0)
634 notify(RESTRICTED,
635 Message("TOPPERS/JSP Kernel never minds the flag 'TA_ASM'.",
636 "TA_ASMが使用されている"));
637
638 // 起動番地チェック
639 if(*inthdr == 0)
640 notify(RESTRICTED,
641 Message("NULL pointer is specified as an inthdr address.",
642 "割込みハンドラの番地がNULLです"));
643
644 ++ inhatr, ++ inthdr;
645 }
646
647 return old_error_count == error_count;
648}
649
650bool ConfigurationChecker::check_exception_handlerblock(Directory & parameter, FileContainer * container)
651{
652 unsigned int id;
653 unsigned int old_error_count = error_count;
654
655 Message object("Exception handler","例外ハンドラ");
656
657 TargetVariable<DT_UINT> _kernel_tnum_excno("_kernel_tnum_excno");
658 if(*_kernel_tnum_excno == 0)
659 return true;
660
661 TargetVariable<DT_UINT> excatr("_kernel_excinib_table", "cpu_exception_handler_initialization_block::excatr");
662 TargetVariable<DT_FP> exchdr("_kernel_excinib_table", "cpu_exception_handler_initialization_block::exchdr");
663
664 VerboseMessage("% object : % items\n","%オブジェクト : % 個\n") << object << *_kernel_tnum_excno;
665 for(id = 0; id < *_kernel_tnum_excno; id++)
666 {
667 set_banner(parameter, object, EXCEPTIONHANDLER, id);
668
669 //attribute validation check
670 if((*excatr & 0x1) != 0)
671 notify(STANDARD,
672 Message("The attribute can take only TA_HLNG|TA_ASM",
673 "TA_HLNG|TA_ASM以外の属性は設定できません"));
674
675 // 属性値に TA_ASM が含まれている
676 if((*excatr & 0x1) != 0)
677 notify(RESTRICTED,
678 Message("TOPPERS/JSP Kernel never minds the flag 'TA_ASM'.",
679 "TOPPERS/JSPカーネルのå…
680¨ã¦ã®æ©Ÿç¨®ä¾å­˜éƒ¨ã§TA_ASMをサポートするとは限らない"));
681
682 // 起動番地チェック
683 if(*exchdr == 0)
684 notify(RESTRICTED,
685 Message("NULL pointer is specified as an exchdr address.",
686 "例外ハンドラの番地がNULLです"));
687
688 ++ excatr, ++ exchdr;
689 }
690
691 return old_error_count == error_count;
692}
693
694//------------------------------------------------------
695
696void ConfigurationChecker::parseOption(Directory & parameter)
697{
698 string loadmodule;
699 string work;
700
701 if(findOption("h","help"))
702 {
703 cout << endl << Message(
704 "Configuration checker - option\n"
705 " -m, --module=filename : Specify the load module (essential option)\n"
706 " -cs, --script=filename : Specify the checker script file\n"
707 " -cl, --checklevel=level : Specify one of the check levels below \n"
708 " l(azy) : Minimum check will be performed.\n"
709 " s(tandard) : includes some ITRON Standard check items.\n"
710 " t(oppers) : checks whether it meets TOPPERS/JSP restrictions\n"
711 " r(estricted) : All of check items will be performed.\n",
712 "コンフィギュレーションチェッカ - オプション\n"
713 " -m, --module=ファイル名 : ロードモジュール名を指定します (必
714須項
715目)\n"
716 " -cs, --script=ファイル名 : チェッカスクリプトを指定します\n"
717 " -cl, --checklevel=level : Specify one of the check levels below \n"
718 " l(azy) : 最小限のチェックのみを行います\n"
719 " s(tandard) : ITRON仕様の範囲でチェックを行います\n"
720 " t(oppers) : TOPPERS/JSPカーネルの制限を満たすことを確認します\n"
721 " r(estricted) : 機種依存部を含めå…
722¨ã¦ã®ãƒã‚§ãƒƒã‚¯é …
723目を実施します\n");
724 cout << endl
725 << Message("Supported architecture : ", "対応アーキテクチャ : ")
726 << FileContainer::getInstance()->getArchitecture()
727 << endl;
728 return;
729 }
730
731 if(findOption("m","module",&loadmodule) || findOption(DEFAULT_PARAMETER,NULL,&loadmodule))
732 {
733 if(findOption("s","source"))
734 ExceptionMessage("Configuration checker can not execute while Configurator executes","コンフィギュレータとチェッカは同時に起動できません").throwException();
735
736 parameter["/file/loadmodule"] = loadmodule;
737 activateComponent();
738 }
739
740 if(!findOption("cs","script",&work))
741 work = loadmodule.substr(0,loadmodule.find_last_of('.')) + ".chk";
742 parameter["/file/checkerscript"] = work;
743
744 work.erase();
745 if(findOption("obj","load-object",&work))
746 {
747 if(work.empty())
748 work.assign("kernel_obj.dat");
749
750 fstream f(work.c_str(), ios::in|ios::binary);
751 if(f.is_open())
752 {
753 parameter["/object"].Load(&f);
754 f.close();
755 }else
756 ExceptionMessage(" Failed to open the file '%' for storing object definitions"," オブジェクト情
757報を格納するためのファイル(%)が開けません") << work << throwException;
758 }
759
760 if(findOption("cl","checklevel",&work))
761 {
762 current_level = UNKNOWN;
763
764 if(work.compare("lazy") == 0 || work[0] == 'l')
765 current_level = LAZY;
766 if(work.compare("standard") == 0 || work[0] == 's')
767 current_level = STANDARD;
768 if(work.compare("toppers") == 0 || work[0] == 't')
769 current_level = TOPPERS;
770 if(work.compare("restricted") == 0 || work[0] == 'r')
771 current_level = RESTRICTED;
772
773 if(current_level == UNKNOWN)
774 ExceptionMessage(" Unknown check level [%] specified"," 無効なチェックレベル指定 [%]") << work << throwException;
775 }else
776 current_level = NORMAL;
777
778 checkOption("cpu", "cpu");
779 checkOption("system", "system");
780}
781
782void ConfigurationChecker::body(Directory & parameter)
783{
784 FileContainer * container;
785 bool result = true;
786
787 /* より優å…
788ˆåº¦ã®é«˜ã„エラーも対象に */
789 current_level = static_cast<enum tagCheckLevel>(static_cast<int>(current_level) * 2 - 1);
790
791 container = FileContainer::getInstance();
792 container->attachInfo(parameter["/file/checkerscript"].toString());
793 container->attachModule(parameter["/file/loadmodule"].toString());
794
795 if(VerboseMessage::getVerbose())
796 {
797 cout << Message(" Target architecture : "," ターゲットアーキテクチャ : ")
798 << container->getArchitecture() << endl;
799 }
800
801 error_count = 0;
802 result &= check_taskblock(parameter,container);
803 result &= check_semaphoreblock(parameter,container);
804 result &= check_eventflagblock(parameter,container);
805 result &= check_dataqueueblock(parameter,container);
806 result &= check_mailboxblock(parameter,container);
807 result &= check_fixed_memorypoolblock(parameter,container);
808 result &= check_cyclic_handlerblock(parameter,container);
809 result &= check_interrupt_handlerblock(parameter,container);
810 result &= check_exception_handlerblock(parameter,container);
811
812 if(!result)
813 ExceptionMessage("Total % errors found in current configuration.\n","å…
814¨éƒ¨ã§%個のエラーが検出されました\n") << error_count << throwException;
815
816 VerboseMessage("No error found in current configuration\n","構成に異常はありませんでした\n");
817}
818
Note: See TracBrowser for help on using the repository browser.