source: anotherchoice/tags/jsp-1.4.4-full-UTF8/cfg/jsp/jsp_checkscript.cpp@ 363

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

add tags/jsp-1.4.4-full-UTF8

  • Property svn:executable set to *
File size: 9.2 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_checkscript.cpp,v 1.18 2005/07/27 10:26:30 honda Exp $
51 */
52
53// $Header: /home/CVS/configurator/jsp/jsp_checkscript.cpp,v 1.18 2005/07/27 10:26:30 honda Exp $
54
55#include "jsp/jsp_defs.h"
56#include "jsp/jsp_common.h"
57
58#include <string>
59#include <iostream>
60
61#include "base/component.h"
62#include "base/mpstrstream.h"
63
64using namespace std;
65using namespace ToppersJsp;
66
67class CheckScriptGenerator : public Component
68{
69protected:
70 virtual void parseOption(Directory & container);
71 virtual void body(Directory & container);
72
73 void insertMagic(void) throw(Exception);
74
75public:
76 CheckScriptGenerator(void) : Component(FINALIZE) {};
77} instance_of_CheckScriptGenerator;
78
79void CheckScriptGenerator::parseOption(Directory & container)
80{
81 MultipartStream * stream;
82 string work;
83
84 if(findOption("h","help"))
85 {
86 cerr << '\n' << Message(
87 "Configuration Checker Script Generation Option\n"
88 " -c, --check : Generate a checker script\n",
89 "カーネル構成チェックスクリプト生成用オプション\n"
90 " -c, --check : チェックスクリプトを生成します\n");
91 return;
92 }
93
94 if(findOption("c","check",&work))
95 {
96 if(work.empty())
97 work.assign("kernel_chk.c");
98
99 stream = new MultipartStream(work);
100 stream->createPart("header")
101 .createPart("body")
102 .createPart("footer");
103
104 container["/file/kernel_chk"] = stream;
105
106 checkOption("ci","checker-macro");
107 activateComponent();
108 }
109}
110
111static void createScriptEntry(Directory & container, MultipartStream * out, const char * objname, const char * member, bool mode = true)
112{
113 string work;
114 string inib;
115 Directory * scope;
116 int i, j;
117
118 (*out) << container.format("\n\t\t/* $@ */\n\n");
119
120 if(mode)
121 {
122 scope = container.getFirstChild();
123 while(scope != 0)
124 {
125 work = scope->getKey();
126 if(work[0] < '0' || work[1] > '9')
127 (*out) << "\tOBJECT(" << container.getKey() << '_' << scope->toInteger() << ',' << work << ");\n";
128
129 scope = scope->getNext();
130 }
131
132 (*out) << container.format("\tEVAR(ID,_kernel_tmax_$(/prefix/$@/id)id);\n");
133 }else
134 {
135 i = 0;
136 scope = container.getFirstChild();
137 while(scope != 0)
138 {
139 work = scope->getKey();
140 (*out) << "\tOBJECT(" << container.getKey() << '_' << (i++) << ',' << scope->getKey() << ");\n";
141 scope = scope->getNext();
142 }
143
144 (*out) << container.format("\tEVAR(ID,_kernel_tnum_$(/prefix/$@/id)no);\n");
145 }
146
147 (*out) << container.format("\tEVAR($(/prefix/$@/SID)INIB,_kernel_$(/prefix/$@/sid)inib_table);\n");
148
149 work.assign(member);
150 i = 0;
151 j = work.find_first_of(',');
152 if(objname == NULL)
153 inib = container.getKey();
154 else
155 inib = objname;
156
157 do {
158 (*out) << "\tMEMBER(" << inib << "_initialization_block," << work.substr(i, j-i) << ");\n";
159
160 i = j + 1;
161 j = work.find_first_of(',', i);
162 } while(i != string::npos+1);
163 (*out) << '\n';
164}
165
166inline void createScriptEntry(Directory & container, MultipartStream * out, const char * member)
167{ createScriptEntry(container, out, NULL, member, true); }
168
169void CheckScriptGenerator::insertMagic(void) throw(Exception)
170{
171 KernelCfg * out = dynamic_cast<KernelCfg *>(RuntimeObjectTable::getInstance(typeid(KernelCfg)));
172 if(out != 0) {
173 out->movePart("others");
174 out->createPart("checkscript");
175 (*out) << Message("\t/* Variables for kernel checker */\n", "\t/* カーネルチェッカ用変数 */\n");
176 (*out) << "const UW _checker_magic_number = 0x01234567;\n\n";
177 }
178}
179
180void CheckScriptGenerator::body(Directory & container)
181{
182 MultipartStream * out;
183
184 out = reinterpret_cast<MultipartStream *>(container["/file/kernel_chk"].toPointer());
185
186 out->movePart("header") <<
187 "#include \"jsp_kernel.h\"\n"
188 "#include \"logtask.h\"\n"
189 "#include \"timer.h\"\n\n";
190
191
192 string work;
193 if(findOption("ci","checker-macro",&work)) {
194
195 /* 中身が空でなかったらincludeをするが,空ならincludeすら吐かない */
196 if(!work.empty())
197 (*out) << "#include \"" << work << "\"\n\n";
198 }
199 else {
200 (*out) << "#define OBJECT(x,y) __asm(\"d\" #x \",\" #y \"@\");\n"
201 "#define MEMBER(x,y) __asm(\"s\" #x \"::\" #y \",(%0),(%1)@\" ::\\\n"
202 " \"i\"(sizeof(((struct x *)0)->y)), \"i\"(&((struct x *)0)->y));\n"
203 "#define VAR(x) __asm(\"s\" #x \",(%0),(0)@\" :: \"i\"(sizeof(x)));\n"
204 "#define EVAR(x,y) __asm(\"s\" #y \",(%0),(0)@\" :: \"i\"(sizeof(x)));\n"
205 "#define SVAR(x) __asm(\"s\" #x \",(%0),(0)@\" :: \"i\"(sizeof(x[0])));\n"
206 "#define DEFS(x) __asm(\"s\" #x \",(%0),(0)@\" :: \"i\"((unsigned long)x));\n\n";
207 }
208
209 (*out) << "#include \"queue.h\"\n\n"
210 "#include \"task.h\"\n"
211 "#include \"semaphore.h\"\n"
212 "#include \"eventflag.h\"\n"
213 "#include \"dataqueue.h\"\n"
214 "#include \"mailbox.h\"\n"
215 "#include \"mempfix.h\"\n"
216 "#include \"cyclic.h\"\n"
217 "#include \"../kernel/exception.h\"\n"
218 "#include \"interrupt.h\"\n"
219 "#include \"wait.h\"\n\n"
220 "void checker_function(void)\n{\n";
221
222 out->movePart("footer") << "}\n";
223
224 out->movePart("body") <<
225 "\tDEFS(TMAX_TPRI);\n\tDEFS(TMIN_TPRI);\n\n"
226 "\tDEFS(TMAX_MPRI);\n\tDEFS(TMIN_MPRI);\n\n"
227// "\tDEFS(TMAX_MAXSEM);\n\n"
228 "\tDEFS(TMAX_RELTIM);\n\n"
229 "\tMEMBER(queue,next);\n\tMEMBER(queue,prev);\n\n";
230
231 createScriptEntry(container[OBJECTTREE "/" TASK], out, "tskatr,exinf,task,ipriority,stksz,stk,texatr,texrtn");
232 createScriptEntry(container[OBJECTTREE "/" SEMAPHORE], out, "sematr,isemcnt,maxsem");
233 createScriptEntry(container[OBJECTTREE "/" EVENTFLAG], out, "flgatr,iflgptn");
234 createScriptEntry(container[OBJECTTREE "/" DATAQUEUE], out, "dtqatr,dtqcnt,dtq");
235 createScriptEntry(container[OBJECTTREE "/" MAILBOX], out, "mbxatr,maxmpri");
236 createScriptEntry(container[OBJECTTREE "/" FIXEDSIZEMEMORYPOOL], out, "fixed_memorypool", "mpfatr,blksz,mpf,limit");
237 createScriptEntry(container[OBJECTTREE "/" CYCLICHANDLER], out, "cyclic_handler", "cycatr,exinf,cychdr,cyctim,cycphs");
238 createScriptEntry(container[OBJECTTREE "/" INTERRUPTHANDLER], out, "interrupt_handler", "inhno,inhatr,inthdr", false);
239 createScriptEntry(container[OBJECTTREE "/" EXCEPTIONHANDLER], out, "cpu_exception_handler", "excno,excatr,exchdr", false);
240
241 insertMagic();
242
243 VerboseMessage("Configuration check script generation was finished successfully.\n","カーネル構成チェックスクリプトファイルを出力しました\n");
244}
245
Note: See TracBrowser for help on using the repository browser.