3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Just Standard Profile Kernel
6 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
7 * Toyohashi Univ. of Technology, JAPAN
9 * 上記著作権者は,以下の (1)〜(4) の条件か,Free Software Foundation
10 * によって公表されている GNU General Public License の Version 2 に記
11 * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
12 * を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下,
14 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
15 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
17 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
18 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
19 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
21 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
22 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
24 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
25 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
26 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
28 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
29 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
31 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
32 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
33 * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
34 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
36 * @(#) $Id: jsp_checkscript.cpp,v 1.1 2009/01/31 05:27:37 suikan Exp $
39 // $Header: /cvsroot/toppersjsp4bf/jsp/cfg/jsp/jsp_checkscript.cpp,v 1.1 2009/01/31 05:27:37 suikan Exp $
41 #include "jsp/jsp_defs.h"
42 #include "jsp/jsp_common.h"
47 #include "base/component.h"
48 #include "base/mpstrstream.h"
51 using namespace ToppersJsp;
53 class CheckScriptGenerator : public Component
56 virtual void parseOption(Directory & container);
57 virtual void body(Directory & container);
59 void insertMagic(void) throw(Exception);
62 CheckScriptGenerator(void) : Component(FINALIZE) {};
63 } instance_of_CheckScriptGenerator;
65 void CheckScriptGenerator::parseOption(Directory & container)
67 MultipartStream * stream;
70 if(findOption("h","help"))
72 cerr << '\n' << Message(
73 "Configuration Checker Script Generation Option\n"
74 " -c, --check : Generate a checker script\n",
75 "カーネル構成チェックスクリプト生成用オプション\n"
76 " -c, --check : チェックスクリプトを生成します\n");
80 if(findOption("c","check",&work))
83 work.assign("kernel_chk.c");
85 stream = new MultipartStream(work);
86 stream->createPart("header")
88 .createPart("footer");
90 container["/file/kernel_chk"] = stream;
92 checkOption("ci","checker-macro");
97 static void createScriptEntry(Directory & container, MultipartStream * out, const char * objname, const char * member, bool mode = true)
104 (*out) << container.format("\n\t\t/* $@ */\n\n");
108 scope = container.getFirstChild();
111 work = scope->getKey();
112 if(work[0] < '0' || work[1] > '9')
113 (*out) << "\tOBJECT(" << container.getKey() << '_' << scope->toInteger() << ',' << work << ");\n";
115 scope = scope->getNext();
118 (*out) << container.format("\tEVAR(ID,_kernel_tmax_$(/prefix/$@/id)id);\n");
122 scope = container.getFirstChild();
125 work = scope->getKey();
126 (*out) << "\tOBJECT(" << container.getKey() << '_' << (i++) << ',' << scope->getKey() << ");\n";
127 scope = scope->getNext();
130 (*out) << container.format("\tEVAR(ID,_kernel_tnum_$(/prefix/$@/id)no);\n");
133 (*out) << container.format("\tEVAR($(/prefix/$@/SID)INIB,_kernel_$(/prefix/$@/sid)inib_table);\n");
137 j = work.find_first_of(',');
139 inib = container.getKey();
144 (*out) << "\tMEMBER(" << inib << "_initialization_block," << work.substr(i, j-i) << ");\n";
147 j = work.find_first_of(',', i);
148 } while(i != string::npos+1);
152 inline void createScriptEntry(Directory & container, MultipartStream * out, const char * member)
153 { createScriptEntry(container, out, NULL, member, true); }
155 void CheckScriptGenerator::insertMagic(void) throw(Exception)
157 KernelCfg * out = dynamic_cast<KernelCfg *>(RuntimeObjectTable::getInstance(typeid(KernelCfg)));
159 out->movePart("others");
160 out->createPart("checkscript");
161 (*out) << Message("\t/* Variables for kernel checker */\n", "\t/* カーネルチェッカ用変数 */\n");
162 (*out) << "const UW _checker_magic_number = 0x01234567;\n\n";
166 void CheckScriptGenerator::body(Directory & container)
168 MultipartStream * out;
170 out = reinterpret_cast<MultipartStream *>(container["/file/kernel_chk"].toPointer());
172 out->movePart("header") <<
173 "#include \"jsp_kernel.h\"\n"
174 "#include \"logtask.h\"\n"
175 "#include \"timer.h\"\n\n";
179 if(findOption("ci","checker-macro",&work)) {
181 /* 中身が空でなかったらincludeをするが,空ならincludeすら吐かない */
183 (*out) << "#include \"" << work << "\"\n\n";
186 (*out) << "#define OBJECT(x,y) __asm(\"d\" #x \",\" #y \"@\");\n"
187 "#define MEMBER(x,y) __asm(\"s\" #x \"::\" #y \",(%0),(%1)@\" ::\\\n"
188 " \"i\"(sizeof(((struct x *)0)->y)), \"i\"(&((struct x *)0)->y));\n"
189 "#define VAR(x) __asm(\"s\" #x \",(%0),(0)@\" :: \"i\"(sizeof(x)));\n"
190 "#define EVAR(x,y) __asm(\"s\" #y \",(%0),(0)@\" :: \"i\"(sizeof(x)));\n"
191 "#define SVAR(x) __asm(\"s\" #x \",(%0),(0)@\" :: \"i\"(sizeof(x[0])));\n"
192 "#define DEFS(x) __asm(\"s\" #x \",(%0),(0)@\" :: \"i\"((unsigned long)x));\n\n";
195 (*out) << "#include \"queue.h\"\n\n"
196 "#include \"task.h\"\n"
197 "#include \"semaphore.h\"\n"
198 "#include \"eventflag.h\"\n"
199 "#include \"dataqueue.h\"\n"
200 "#include \"mailbox.h\"\n"
201 "#include \"mempfix.h\"\n"
202 "#include \"cyclic.h\"\n"
203 "#include \"../kernel/exception.h\"\n"
204 "#include \"interrupt.h\"\n"
205 "#include \"wait.h\"\n\n"
206 "void checker_function(void)\n{\n";
208 out->movePart("footer") << "}\n";
210 out->movePart("body") <<
211 "\tDEFS(TMAX_TPRI);\n\tDEFS(TMIN_TPRI);\n\n"
212 "\tDEFS(TMAX_MPRI);\n\tDEFS(TMIN_MPRI);\n\n"
213 // "\tDEFS(TMAX_MAXSEM);\n\n"
214 "\tDEFS(TMAX_RELTIM);\n\n"
215 "\tMEMBER(queue,next);\n\tMEMBER(queue,prev);\n\n";
217 createScriptEntry(container[OBJECTTREE "/" TASK], out, "tskatr,exinf,task,ipriority,stksz,stk,texatr,texrtn");
218 createScriptEntry(container[OBJECTTREE "/" SEMAPHORE], out, "sematr,isemcnt,maxsem");
219 createScriptEntry(container[OBJECTTREE "/" EVENTFLAG], out, "flgatr,iflgptn");
220 createScriptEntry(container[OBJECTTREE "/" DATAQUEUE], out, "dtqatr,dtqcnt,dtq");
221 createScriptEntry(container[OBJECTTREE "/" MAILBOX], out, "mbxatr,maxmpri");
222 createScriptEntry(container[OBJECTTREE "/" FIXEDSIZEMEMORYPOOL], out, "fixed_memorypool", "mpfatr,blksz,mpf,limit");
223 createScriptEntry(container[OBJECTTREE "/" CYCLICHANDLER], out, "cyclic_handler", "cycatr,exinf,cychdr,cyctim,cycphs");
224 createScriptEntry(container[OBJECTTREE "/" INTERRUPTHANDLER], out, "interrupt_handler", "inhno,inhatr,inthdr", false);
225 createScriptEntry(container[OBJECTTREE "/" EXCEPTIONHANDLER], out, "cpu_exception_handler", "excno,excatr,exchdr", false);
229 VerboseMessage("Configuration check script generation was finished successfully.\n","カーネル構成チェックスクリプトファイルを出力しました\n");