📄 jsp_check.cpp
字号:
/*
* TOPPERS/JSP Kernel
* Toyohashi Open Platform for Embedded Real-Time Systems/
* Just Standard Profile Kernel
*
* Copyright (C) 2000-2003 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_check.cpp,v 1.1 2006/04/14 02:46:08 9564907 Exp $
*/
// $Header: J:\\SapporoSoft\\usb20\\S1R72V05\\Debug\\Repository/S1R72V05_Toppers/Toppers/cfg/jsp/jsp_check.cpp,v 1.1 2006/04/14 02:46:08 9564907 Exp $
#include "base/defs.h"
#include "jsp/jsp_defs.h"
#include "base/message.h"
#include "base/component.h"
#include "base/filecontainer.h"
#include <fstream>
#include <iomanip>
class ConfigurationChecker : public Component
{
public:
enum tagCheckLevel
{
UNKNOWN = 0,
LAZY = 1, /* 抳柦揑 (峴偒夁偓夵憿杊巭梡) */
STANDARD = 2, /* ITRON巇條偺斖埻 (夵憿傪嫋梕) */
TOPPERS = 4, /* TOPPERS/JSP偺斖埻撪 */
RESTRICTED = 8, /* 曅偭抂偐傜曔傑偊傞 */
NORMAL = 8
};
protected:
enum tagCheckLevel current_level;
unsigned int error_count;
std::string banner;
void set_banner(Directory &, Formatter , const char *, int);
void notify(enum tagCheckLevel, Formatter , bool = true);
bool check_taskblock(Directory &, FileContainer *);
bool check_semaphoreblock(Directory &, FileContainer *);
bool check_eventflagblock(Directory &, FileContainer *);
bool check_dataqueueblock(Directory &, FileContainer *);
bool check_mailboxblock(Directory &, FileContainer *);
bool check_fixed_memorypoolblock(Directory &, FileContainer *);
bool check_cyclic_handlerblock(Directory &, FileContainer *);
bool check_interrupt_handlerblock(Directory &, FileContainer *);
bool check_exception_handlerblock(Directory &, FileContainer *);
virtual void parseOption(Directory &);
virtual void body(Directory &);
public:
ConfigurationChecker(void) throw();
~ConfigurationChecker(void) throw() {}
};
//------------------------------------------------------
using namespace std;
static ConfigurationChecker instance_of_ConfigurationChecker;
//------------------------------------------------------
//僞乕僎僢僩偺摨柤偺宆傛傝傕戝偒側宆偺掕媊
// (拲) 抣斾妑, 墘嶼偑壜擻側宆偱偁傞偙偲
typedef int DT_INT;
typedef unsigned int DT_UINT;
typedef unsigned long DT_FP;
typedef unsigned long DT_VP_INT;
typedef unsigned long DT_VP;
typedef long DT_RELTIM;
//------------------------------------------------------
ConfigurationChecker::ConfigurationChecker(void) throw()
{
setBanner("--- TOPPERS/JSP Configuration Checker (ver 2.4) ---");
}
void ConfigurationChecker::set_banner(Directory & container, Formatter object, const char * type, int id)
{
Directory * node;
char buffer[32];
banner = string(" ") + object.str() + " : ";
sprintf(buffer, "id = %d", id);
node = container.findChild(OBJECTTREE, type, NULL)->getFirstChild();
while(node != 0 && node->toInteger() != id)
node = node->getNext();
if( node != 0 ) {
banner += node->getKey() + " (" + buffer + ") ";
node = node->findChild("position");
if(node != 0)
banner += string("at ") + node->toString();
}
else
banner += buffer;
if(VerboseMessage::getVerbose())
{
cout << banner << endl;
banner.erase();
}
}
void ConfigurationChecker::notify(enum tagCheckLevel level, Formatter msg, bool error)
{
if((level & current_level) != 0)
{
if(!banner.empty())
{
cout << banner << endl;
banner.erase();
}
cout << " ";
if(error)
{
cout << Message("[ Error ] ","[僄儔乕] ");
error_count ++;
}else
cout << Message("[Warning] ","[ 寈崘 ] ");
cout << msg << endl;
}
}
/*
* 僞僗僋僆僽僕僃僋僩偵娭偡傞僄儔乕専弌
*/
bool ConfigurationChecker::check_taskblock(Directory & parameter, FileContainer * container)
{
unsigned int id;
unsigned int maxpri;
unsigned int minpri;
unsigned int old_error_count = error_count;
TargetVariable<unsigned int> _kernel_tmax_tskid("_kernel_tmax_tskid");
Message object("Task","僞僗僋");
if(!_kernel_tmax_tskid.isValid())
ExceptionMessage(
"Internal error: Unknown symbol (Probably, Symbol table was stripped)",
"撪晹僄儔乕: 晄惓側僔儞儃儖柤 (幚峴宍幃偑僔儞儃儖僥乕僽儖傪娷傫偱側偄壜擻惈偑偁傝傑偡)").throwException();
if(*_kernel_tmax_tskid < 1)
{
notify(RESTRICTED,
Message(" [Task] : No tasks created\n"," [僞僗僋] : 僞僗僋僆僽僕僃僋僩偑偁傝傑偣傫\n"));
return true;
}
TargetVariable<DT_UINT> tskatr("_kernel_tinib_table", "task_initialization_block::tskatr");
TargetVariable<DT_FP> task("_kernel_tinib_table", "task_initialization_block::task");
TargetVariable<DT_INT> ipriority("_kernel_tinib_table", "task_initialization_block::ipriority");
TargetVariable<DT_UINT> texatr("_kernel_tinib_table", "task_initialization_block::texatr");
TargetVariable<DT_UINT> stksz("_kernel_tinib_table", "task_initialization_block::stksz");
maxpri = container->getVariableInfo("TMAX_TPRI").value;
minpri = container->getVariableInfo("TMIN_TPRI").value;
VerboseMessage("% object : % items\n","%僆僽僕僃僋僩 : % 屄\n") << object << *_kernel_tmax_tskid;
for(id = 1; id <= *_kernel_tmax_tskid; id++)
{
set_banner(parameter, object, TASK, id);
/*
* 懏惈僠僃僢僋
*/
// 懏惈抣偑 TA_HLNG|TA_ASM|TA_ACT 埲奜偺抣傪偲偭偰偄傞
if((*tskatr & ~0x3) != 0)
notify( STANDARD,
Message("Illegal task attribute (It should be ((TA_HLNG||TA_ASM)|TA_ACT))",
"晄惓側僞僗僋懏惈 ((TA_HLNG||TA_ASM)|TA_ACT)埲奜"));
// 懏惈抣偵 TA_ASM 偑娷傑傟偰偄傞
if((*tskatr & 0x1) != 0)
notify( RESTRICTED,
Message("TA_ASM specified as task attribute takes no effect.",
"僞僗僋懏惈偵TA_ASM偑巜掕偝傟偰偄傞"));
/* 婲摦斣抧偑0 */
if(*task == 0)
notify(RESTRICTED,
Message("The address of task routine is equal to zero.",
"奐巒斣抧偵0偑愝掕偝傟偰偄傑偡"));
/*
* 桪愭搙僠僃僢僋
*/
// 嵟戝桪愭搙偲嵟彫桪愭搙偺愝掕偑偍偐偟偄
if(maxpri < minpri)
notify(LAZY,
Message("Illegal Priority Settings found (TMAX_TPRI(%) < TMIN_TPRI).",
"弶婜桪愭搙偑嵟掅桪愭搙(%)傪挻偊偰偄傞") << minpri);
// 桪愭搙偺斖埻偑[嵟彫桪愭搙, 嵟戝桪愭搙]偺斖埻傪挻偊偰偄傞
if(*ipriority > (signed)(maxpri - minpri))
notify(TOPPERS,
Message("Initial priority is greater than maximum priority (%).",
"弶婜桪愭搙偑嵟戝桪愭搙(%)傪挻偊偰偄傞") << maxpri);
if(*ipriority < 0)
notify(STANDARD,
Message("Initial priority is less than the minimum priority (%).",
"弶婜桪愭搙偑嵟掅桪愭搙(%)傪壓夞傞") << minpri);
/*
* 僞僗僋椺奜懏惈僠僃僢僋
*/
// 懏惈抣偑TA_HLNG or TA_ASM偱側偄
if((*texatr & ~0x3) != 0)
notify(STANDARD,
Message("Task exception routine has an illegal attribute specifier.",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -