[26] | 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 |
|
---|
| 64 | using namespace std;
|
---|
| 65 | using namespace ToppersJsp;
|
---|
| 66 |
|
---|
| 67 | class CheckScriptGenerator : public Component
|
---|
| 68 | {
|
---|
| 69 | protected:
|
---|
| 70 | virtual void parseOption(Directory & container);
|
---|
| 71 | virtual void body(Directory & container);
|
---|
| 72 |
|
---|
| 73 | void insertMagic(void) throw(Exception);
|
---|
| 74 |
|
---|
| 75 | public:
|
---|
| 76 | CheckScriptGenerator(void) : Component(FINALIZE) {};
|
---|
| 77 | } instance_of_CheckScriptGenerator;
|
---|
| 78 |
|
---|
| 79 | void 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 |
|
---|
| 111 | static 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 |
|
---|
| 166 | inline void createScriptEntry(Directory & container, MultipartStream * out, const char * member)
|
---|
| 167 | { createScriptEntry(container, out, NULL, member, true); }
|
---|
| 168 |
|
---|
| 169 | void 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 |
|
---|
| 180 | void 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 |
|
---|