📄 jsp_checkscript.cpp
字号:
/*
* TOPPERS/JSP Kernel
* Toyohashi Open Platform for Embedded Real-Time Systems/
* Just Standard Profile Kernel
*
* Copyright (C) 2000-2002 by Embedded and Real-Time Systems Laboratory
* Toyohashi Univ. of Technology, JAPAN
*
* 忋婰挊嶌尃幰偼丆埲壓偺 (1)乣(4) 偺忦審偐丆Free Software Foundation
* 偵傛偭偰岞昞偝傟偰偄傞 GNU General Public License 偺 Version 2 偵婰
* 弎偝傟偰偄傞忦審傪枮偨偡応崌偵尷傝丆杮僜僼僩僂僃傾乮杮僜僼僩僂僃傾
* 傪夵曄偟偨傕偺傪娷傓丏埲壓摨偠乯傪巊梡丒暋惢丒夵曄丒嵞攝晍乮埲壓丆
* 棙梡偲屇傇乯偡傞偙偲傪柍彏偱嫋戻偡傞丏
* (1) 杮僜僼僩僂僃傾傪僜乕僗僐乕僪偺宍偱棙梡偡傞応崌偵偼丆忋婰偺挊嶌
* 尃昞帵丆偙偺棙梡忦審偍傛傃壓婰偺柍曐徹婯掕偑丆偦偺傑傑偺宍偱僜乕
* 僗僐乕僪拞偵娷傑傟偰偄傞偙偲丏
* (2) 杮僜僼僩僂僃傾傪丆儔僀僽儔儕宍幃側偳丆懠偺僜僼僩僂僃傾奐敪偵巊
* 梡偱偒傞宍偱嵞攝晍偡傞応崌偵偼丆嵞攝晍偵敽偆僪僉儏儊儞僩乮棙梡
* 幰儅僯儏傾儖側偳乯偵丆忋婰偺挊嶌尃昞帵丆偙偺棙梡忦審偍傛傃壓婰
* 偺柍曐徹婯掕傪宖嵹偡傞偙偲丏
* (3) 杮僜僼僩僂僃傾傪丆婡婍偵慻傒崬傓側偳丆懠偺僜僼僩僂僃傾奐敪偵巊
* 梡偱偒側偄宍偱嵞攝晍偡傞応崌偵偼丆師偺偄偢傟偐偺忦審傪枮偨偡偙
* 偲丏
* (a) 嵞攝晍偵敽偆僪僉儏儊儞僩乮棙梡幰儅僯儏傾儖側偳乯偵丆忋婰偺挊
* 嶌尃昞帵丆偙偺棙梡忦審偍傛傃壓婰偺柍曐徹婯掕傪宖嵹偡傞偙偲丏
* (b) 嵞攝晍偺宍懺傪丆暿偵掕傔傞曽朄偵傛偭偰丆TOPPERS僾儘僕僃僋僩偵
* 曬崘偡傞偙偲丏
* (4) 杮僜僼僩僂僃傾偺棙梡偵傛傝捈愙揑傑偨偼娫愙揑偵惗偠傞偄偐側傞懝
* 奞偐傜傕丆忋婰挊嶌尃幰偍傛傃TOPPERS僾儘僕僃僋僩傪柶愑偡傞偙偲丏
*
* 杮僜僼僩僂僃傾偼丆柍曐徹偱採嫙偝傟偰偄傞傕偺偱偁傞丏忋婰挊嶌尃幰偍
* 傛傃TOPPERS僾儘僕僃僋僩偼丆杮僜僼僩僂僃傾偵娭偟偰丆偦偺揔梡壜擻惈傕
* 娷傔偰丆偄偐側傞曐徹傕峴傢側偄丏傑偨丆杮僜僼僩僂僃傾偺棙梡偵傛傝捈
* 愙揑傑偨偼娫愙揑偵惗偠偨偄偐側傞懝奞偵娭偟偰傕丆偦偺愑擟傪晧傢側偄丏
*
* @(#) $Id: jsp_checkscript.cpp,v 1.10 2003/06/30 09:48:51 takayuki Exp $
*/
// $Header: /home/CVS/configurator/jsp/jsp_checkscript.cpp,v 1.10 2003/06/30 09:48:51 takayuki Exp $
#include "jsp/jsp_defs.h"
#include <string>
#include <iostream>
#include "base/component.h"
#include "base/mpstrstream.h"
using namespace std;
class CheckScriptGenerator : public Component
{
protected:
virtual void parseOption(Directory &);
virtual void body(Directory &);
public:
CheckScriptGenerator(void) : Component(FINALIZE) {};
} instance_of_CheckScriptGenerator;
void CheckScriptGenerator::parseOption(Directory & container)
{
mpstrstream * stream;
string work;
if(findOption(container,"h","help"))
{
cerr << '\n' << Message(
"Configuration Checker Script Generation Option\n"
" -c, --check : Generate a checker script\n",
"僇乕僱儖峔惉僠僃僢僋僗僋儕僾僩惗惉梡僆僾僔儑儞\n"
" -c, --check : 僠僃僢僋僗僋儕僾僩傪惗惉偟傑偡\n");
return;
}
if(findOption(container,"c","check",&work))
{
if(work.empty())
work.assign("kernel_chk.c");
stream = new mpstrstream(work);
stream->createpart("header", "body","footer",NULL);
container["/file/kernel_chk"] = stream;
activateComponent(false);
}
}
static void createScriptEntry(Directory & container, mpstrstream * out, const char * objname, const char * member, bool mode = true)
{
string work;
string inib;
Directory * scope;
int i, j;
(*out) << container.format("\n\t\t/* $@ */\n\n");
if(mode)
{
scope = container.getFirstChild();
while(scope != 0)
{
work = scope->getKey();
if(work[0] < '0' || work[1] > '9')
(*out) << "\tOBJECT(" << container.getKey() << '_' << scope->toInteger() << ',' << work << ");\n";
scope = scope->getNext();
}
(*out) << container.format("\tEVAR(ID,_kernel_tmax_$(/prefix/$@/id)id);\n");
}else
{
i = 0;
scope = container.getFirstChild();
while(scope != 0)
{
work = scope->getKey();
(*out) << "\tOBJECT(" << container.getKey() << '_' << (i++) << ',' << scope->getKey() << ");\n";
scope = scope->getNext();
}
(*out) << container.format("\tEVAR(ID,_kernel_tnum_$(/prefix/$@/id)no);\n");
}
(*out) << container.format("\tEVAR($(/prefix/$@/SID)INIB,_kernel_$(/prefix/$@/sid)inib_table);\n");
work.assign(member);
i = 0;
j = work.find_first_of(',');
if(objname == NULL)
inib = container.getKey();
else
inib = objname;
do {
(*out) << "\tMEMBER(" << inib << "_initialization_block," << work.substr(i, j-i) << ");\n";
i = j + 1;
j = work.find_first_of(',', i);
} while(i != string::npos+1);
(*out) << '\n';
}
inline void createScriptEntry(Directory & container, mpstrstream * out, const char * member)
{ createScriptEntry(container, out, NULL, member, true); }
void CheckScriptGenerator::body(Directory & container)
{
mpstrstream * out;
out = reinterpret_cast<mpstrstream *>(container["/file/kernel_chk"].toPointer());
out->moveto("header") <<
"#include \"jsp_kernel.h\"\n"
"#include \"logtask.h\"\n"
"#include \"timer.h\"\n\n"
"#define OBJECT(x,y) __asm(\"d\" #x \",\" #y \"@\");\n"
"#define MEMBER(x,y) __asm(\"s\" #x \"::\" #y \",(%0),(%1)@\" ::\\\n"
" \"i\"(sizeof(((struct x *)0)->y)), \"i\"(&((struct x *)0)->y));\n"
"#define VAR(x) __asm(\"s\" #x \",(%0),(0)@\" :: \"i\"(sizeof(x)));\n"
"#define EVAR(x,y) __asm(\"s\" #y \",(%0),(0)@\" :: \"i\"(sizeof(x)));\n"
"#define SVAR(x) __asm(\"s\" #x \",(%0),(0)@\" :: \"i\"(sizeof(x[0])));\n"
"#define DEFS(x) __asm(\"s\" #x \",(%0),(0)@\" :: \"i\"((unsigned long)x));\n\n"
"#include \"queue.h\"\n\n"
"#include \"task.h\"\n"
"#include \"semaphore.h\"\n"
"#include \"eventflag.h\"\n"
"#include \"dataqueue.h\"\n"
"#include \"mailbox.h\"\n"
"#include \"mempfix.h\"\n"
"#include \"cyclic.h\"\n"
"#include \"../kernel/exception.h\"\n"
"#include \"interrupt.h\"\n"
"#include \"wait.h\"\n\n"
"void checker_function(void)\n{\n";
out->moveto("footer") << "}\n";
out->moveto("body") <<
"\tDEFS(TMAX_TPRI);\n\tDEFS(TMIN_TPRI);\n\n"
"\tDEFS(TMAX_MPRI);\n\tDEFS(TMIN_MPRI);\n\n"
// "\tDEFS(TMAX_MAXSEM);\n\n"
"\tDEFS(TMAX_RELTIM);\n\n"
"\tMEMBER(queue,next);\n\tMEMBER(queue,prev);\n\n";
createScriptEntry(container[OBJECTTREE "/" TASK], out, "tskatr,exinf,task,ipriority,stksz,stk,texatr,texrtn");
createScriptEntry(container[OBJECTTREE "/" SEMAPHORE], out, "sematr,isemcnt,maxsem");
createScriptEntry(container[OBJECTTREE "/" EVENTFLAG], out, "flgatr,iflgptn");
createScriptEntry(container[OBJECTTREE "/" DATAQUEUE], out, "dtqatr,dtqcnt,dtq");
createScriptEntry(container[OBJECTTREE "/" MAILBOX], out, "mbxatr,maxmpri");
createScriptEntry(container[OBJECTTREE "/" FIXEDSIZEMEMORYPOOL], out, "fixed_memorypool", "mpfatr,blksz,mpf,limit");
createScriptEntry(container[OBJECTTREE "/" CYCLICHANDLER], out, "cyclic_handler", "cycatr,exinf,cychdr,cyctim,cycphs");
createScriptEntry(container[OBJECTTREE "/" INTERRUPTHANDLER], out, "interrupt_handler", "inhno,inhatr,inthdr", false);
createScriptEntry(container[OBJECTTREE "/" EXCEPTIONHANDLER], out, "cpu_exception_handler", "excno,excatr,exchdr", false);
VerboseMessage("Configuration check script generation was finished successfully.\n","僇乕僱儖峔惉僠僃僢僋僗僋儕僾僩僼傽僀儖傪弌椡偟傑偟偨");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -