📄 jsp_check.cpp
字号:
Message("Illegal attribute value [0x%]",
"偍偐偟側懏惈抣 [0x%]") << setbase(16) << (work & ~0x1));
LoadVal(work, inib.address, "dataqueue_initialization_block::dtqcnt");
LoadVal(dtq, inib.address, "dataqueue_initialization_block::dtq");
if(work != 0 && dtq == 0)
notify(TOPPERS,
Message("Dataqueue buffer should not be NULL", "僨乕僞僉儏乕偺僶僢僼傽偑NULL抣"));
inib.address += inib.size;
}
return old_error_count == error_count;
}
bool ConfigurationChecker::check_mailboxblock(Directory & parameter, filecontainer * container)
{
unsigned int id;
unsigned int num;
unsigned int work;
int maxpri;
int minpri;
unsigned int old_error_count = error_count;
struct variable_information inib;
Message object("Mailbox","儊乕儖儃僢僋僗");
Load(num, "_kernel_tmax_mbxid");
if(num < 1)
return true;
inib = container->get_variable_information("_kernel_mbxinib_table");
maxpri = container->get_variable_information("TMAX_MPRI").value;
minpri = container->get_variable_information("TMIN_MPRI").value;
VerboseMessage("% object : % items\n","%僆僽僕僃僋僩 : % 屄\n") << object << num;
for(id = 1; id <= num; id++)
{
set_banner(parameter, object, MAILBOX, id);
//attribute validation check
LoadVal(work, inib.address, "mailbox_initialization_block::mbxatr");
if((work & ~0x3) != 0)
notify(STANDARD,
Message("Illegal attribute value [0x%]",
"偍偐偟側懏惈抣 [0x%]") << setbase(16) << (work & ~0x3));
//mailbox message priority check
LoadVal(work, inib.address, "mailbox_initialization_block::maxmpri");
if( container->get_variable_information("mailbox_initialization_block::maxmpri").size == 2)
work = (int)((short)work);
if((signed)work < 0)
notify(STANDARD,
Message("Priority must not be a negative number.","桪愭搙偑晧抣"));
if((signed)work < minpri)
notify(STANDARD,
Message("Message priority should be greater than or equal to %.",
"儊僢僙乕僕桪愭搙偼%埲忋偱側偗傟偽偄偗傑偣傫") << minpri);
if((signed)work > maxpri)
notify(STANDARD,
Message("Message priority should be less than or equal to %.",
"儊僢僙乕僕桪愭搙偼%埲壓偱側偗傟偽偄偗傑偣傫") << maxpri);
inib.address += inib.size;
}
return old_error_count == error_count;
}
bool ConfigurationChecker::check_fixed_memorypoolblock(Directory & parameter, filecontainer * container)
{
unsigned int id;
unsigned int num;
unsigned int work;
unsigned int limit;
unsigned int old_error_count = error_count;
struct variable_information inib;
Message object("Fixed size memory pool","屌掕挿儊儌儕僾乕儖");
Load(num, "_kernel_tmax_mpfid");
if(num < 1)
return true;
inib = container->get_variable_information("_kernel_mpfinib_table");
VerboseMessage("% object : % items\n","%僆僽僕僃僋僩 : % 屄\n") << object << num;
for(id = 1; id <= num; id++)
{
set_banner(parameter, object, FIXEDSIZEMEMORYPOOL, id);
//attribute validation check
LoadVal(work, inib.address, "fixed_memorypool_initialization_block::mpfatr");
if((work & ~0x1) != 0)
notify(STANDARD,
Message("Illegal attribute value [0x%]","偍偐偟側懏惈抣 [0x%]") << (work & ~0x1));
//僽儘僢僋悢偑0
LoadVal(work, inib.address, "fixed_memorypool_initialization_block::mpf");
LoadVal(limit, inib.address, "fixed_memorypool_initialization_block::limit");
if(work == limit)
notify(STANDARD,
Message("blkcnt should be a non-zero value.","僽儘僢僋悢偑0偱偡"));
//僽儘僢僋僒僀僘偑0
LoadVal(work, inib.address, "fixed_memorypool_initialization_block::blksz");
if(work == 0)
notify(STANDARD,
Message("blksz should be a non-zero value.","僽儘僢僋僒僀僘偑0偱偡"));
//僶僢僼傽傾僪儗僗偑0
LoadVal(work, inib.address, "fixed_memorypool_initialization_block::mpf");
if(work == 0)
notify(TOPPERS,
Message("buffer address is a NULL pointer.","僶僢僼傽傾僪儗僗偑NULL億僀儞僞偵側偭偰偄傑偡"));
inib.address += inib.size;
}
return old_error_count == error_count;
}
bool ConfigurationChecker::check_cyclic_handlerblock(Directory & parameter, filecontainer * container)
{
unsigned int id;
unsigned int num;
unsigned int work;
unsigned int maxreltim;
unsigned int old_error_count = error_count;
struct variable_information inib;
Message object("Cyclic handler","廃婜僴儞僪儔");
Load(num, "_kernel_tmax_cycid");
if(num < 1)
return true;
inib = container->get_variable_information("_kernel_cycinib_table");
VerboseMessage("% object : % items\n","%僆僽僕僃僋僩 : % 屄\n") << object << num;
for(id = 1; id <= num; id++)
{
set_banner(parameter, object, CYCLICHANDLER, id);
//attribute validation check
LoadVal(work, inib.address, "cyclic_handler_initialization_block::cycatr");
if((work & ~0x7) != 0)
notify(STANDARD,
Message("Illegal attribute value [0x%]","偍偐偟側懏惈抣 [0x%]") << (work & ~0x1));
if((work & 0x4) != 0)
notify(TOPPERS, //旕埶懚晹側偺偱RESTRICTED偵偟側偄
Message("TA_PHS is not supported in this kernel.","TA_PHS偼僒億乕僩奜"));
// 懏惈抣偵 TA_ASM 偑娷傑傟偰偄傞
if((work & 0x1) != 0)
notify( RESTRICTED,
Message("TOPPERS/JSP Kernel never minds the flag 'TA_ASM'.",
"TOPPERS/JSP僇乕僱儖偺慡偰偺婡庬埶懚晹偱TA_ASM傪僒億乕僩偡傞偲偼尷傜側偄"));
//RELTIM偱偺昞尰斖埻撪偵偁傞偐偳偆偐偺僠僃僢僋
maxreltim = container->get_variable_information("TMAX_RELTIM").value;
LoadVal(work, inib.address, "cyclic_handler_initialization_block::cyctim");
if(work > maxreltim)
notify(STANDARD,
Message("The cyclic object has a period (%) that exceeds the maximum period (%)",
"婲摦廃婜(%)偑昞尰壜擻側憡懳帪娫偺斖埻(%)傪挻偊偰偄傑偡") << work << maxreltim);
//婲摦廃婜偑0偱側偄偙偲偺僠僃僢僋
if(work == 0)
notify(STANDARD,
Message("The cyclic object has a ZERO period.",
"婲摦廃婜偑0偵側偭偰偄傑偡"));
LoadVal(work, inib.address, "cyclic_handler_initialization_block::cycphs");
if(work > maxreltim)
notify(STANDARD,
Message("The cyclic object has a initial delay (%) that exceeds the maximum period (%)",
"婲摦埵憡(%)偑昞尰壜擻側憡懳帪娫偺斖埻(%)傪挻偊偰偄傑偡") << work << maxreltim);
inib.address += inib.size;
}
return old_error_count == error_count;
}
bool ConfigurationChecker::check_interrupt_handlerblock(Directory & parameter, filecontainer * container)
{
unsigned int id;
unsigned int num;
unsigned int work;
unsigned int old_error_count = error_count;
struct variable_information inib;
Message object("Interrupt handler","妱崬傒僴儞僪儔");
Load(num, "_kernel_tnum_inhno");
if(num == 0)
return true;
inib = container->get_variable_information("_kernel_inhinib_table");
VerboseMessage("% object : % items\n","%僆僽僕僃僋僩 : % 屄\n") << object << num;
for(id = 0; id < num; id++)
{
set_banner(parameter, object, INTERRUPTHANDLER, id);
//attribute validation check
LoadVal(work, inib.address, "interrupt_handler_initialization_block::inhatr");
if((work & 0x1) != 0)
notify(STANDARD,
Message("The attribute can take only TA_HLNG|TA_ASM",
"TA_HNLG|TA_ASM埲奜偺懏惈偼愝掕偱偒傑偣傫"));
// 懏惈抣偵 TA_ASM 偑娷傑傟偰偄傞
if((work & 0x1) != 0)
notify(RESTRICTED,
Message("TOPPERS/JSP Kernel never minds the flag 'TA_ASM'.",
"TA_ASM偑巊梡偝傟偰偄傞"));
// 婲摦斣抧僠僃僢僋
LoadVal(work, inib.address, "interrupt_handler_initialization_block::inthdr");
if(work == 0)
notify(RESTRICTED,
Message("NULL pointer is specified as an inthdr address.",
"妱崬傒僴儞僪儔偺斣抧偑NULL偱偡"));
inib.address += inib.size;
}
return old_error_count == error_count;
}
bool ConfigurationChecker::check_exception_handlerblock(Directory & parameter, filecontainer * container)
{
unsigned int id;
unsigned int num;
unsigned int work;
unsigned int old_error_count = error_count;
struct variable_information inib;
Message object("Exception handler","椺奜僴儞僪儔");
Load(num, "_kernel_tnum_excno");
if(num == 0)
return true;
inib = container->get_variable_information("_kernel_excinib_table");
VerboseMessage("% object : % items\n","%僆僽僕僃僋僩 : % 屄\n") << object << num;
for(id = 0; id < num; id++)
{
set_banner(parameter, object, EXCEPTIONHANDLER, id);
//attribute validation check
LoadVal(work, inib.address, "cpu_exception_handler_initialization_block::excatr");
if((work & 0x1) != 0)
notify(STANDARD,
Message("The attribute can take only TA_HLNG|TA_ASM",
"TA_HNLG|TA_ASM埲奜偺懏惈偼愝掕偱偒傑偣傫"));
// 懏惈抣偵 TA_ASM 偑娷傑傟偰偄傞
if((work & 0x1) != 0)
notify(RESTRICTED,
Message("TOPPERS/JSP Kernel never minds the flag 'TA_ASM'.",
"TOPPERS/JSP僇乕僱儖偺慡偰偺婡庬埶懚晹偱TA_ASM傪僒億乕僩偡傞偲偼尷傜側偄"));
// 婲摦斣抧僠僃僢僋
LoadVal(work, inib.address, "cpu_exception_handler_initialization_block::exchdr");
if(work == 0)
notify(RESTRICTED,
Message("NULL pointer is specified as an exchdr address.",
"椺奜僴儞僪儔偺斣抧偑NULL偱偡"));
inib.address += inib.size;
}
return old_error_count == error_count;
}
//------------------------------------------------------
#undef LoadVal
#undef Load
void ConfigurationChecker::parseOption(Directory & parameter)
{
string loadmodule;
string work;
if(findOption(parameter,"h","help"))
{
cout << endl << Message(
"Configuration checker - option\n"
" -m, --module=filename : Specify the load module (essential option)\n"
" -cs, --script=filename : Specify the checker script file\n"
" -cl, --checklevel=level : Specify one of the check levels below \n"
" l(azy) : Minimum check will be performed.\n"
" s(tandard) : includes some ITRON Standard check items.\n"
" t(oppers) : checks whether it meets TOPPERS/JSP restrictions\n"
" r(estricted) : All of check items will be performed.\n",
"僐儞僼傿僊儏儗乕僔儑儞僠僃僢僇 - 僆僾僔儑儞\n"
" -m, --module=僼傽僀儖柤 : 儘乕僪儌僕儏乕儖柤傪巜掕偟傑偡 (昁恵崁栚)\n"
" -cs, --script=僼傽僀儖柤 : 僠僃僢僇僗僋儕僾僩傪巜掕偟傑偡\n"
" -cl, --checklevel=level : Specify one of the check levels below \n"
" l(azy) : 嵟彫尷偺僠僃僢僋偺傒傪峴偄傑偡\n"
" s(tandard) : ITRON巇條偺斖埻偱僠僃僢僋傪峴偄傑偡\n"
" t(oppers) : TOPPERS/JSP僇乕僱儖偺惂尷傪枮偨偡偙偲傪妋擣偟傑偡\n"
" r(estricted) : 婡庬埶懚晹傪娷傔慡偰偺僠僃僢僋崁栚傪幚巤偟傑偡\n");
return;
}
if(findOption(parameter,"m","module",&loadmodule) || findOption(parameter,DEFAULT_PARAMETER,NULL,&loadmodule))
{
if(findOption(parameter,"s","source"))
ExceptionMessage("Configuration checker can not execute while Configurator executes","僐儞僼傿僊儏儗乕僞偲僠僃僢僇偼摨帪偵婲摦偱偒傑偣傫").throwException();
parameter["/file/loadmodule"] = loadmodule;
activateComponent(false);
}
if(!findOption(parameter,"cs","script",&work))
work = loadmodule.substr(0,loadmodule.find_last_of('.')) + ".chk";
parameter["/file/checkerscript"] = work;
if(findOption(parameter,"obj","load-object",&work))
{
if(work.empty())
work.assign("kernel_obj.dat");
fstream f(work.c_str(), ios::in|ios::binary);
if(f.is_open())
{
parameter["/object"].Load(&f);
f.close();
}else
ExceptionMessage(" Failed to open the file '%' for storing object definitions"," 僆僽僕僃僋僩忣曬傪奿擺偡傞偨傔偺僼傽僀儖(%)偑奐偗傑偣傫") << work << throwException;
}
if(findOption(parameter,"cl","checklevel",&work))
{
current_level = UNKNOWN;
if(work.compare("lazy") == 0 || work[0] == 'l')
current_level = LAZY;
if(work.compare("standard") == 0 || work[0] == 's')
current_level = STANDARD;
if(work.compare("toppers") == 0 || work[0] == 't')
current_level = TOPPERS;
if(work.compare("restricted") == 0 || work[0] == 'r')
current_level = RESTRICTED;
if(current_level == UNKNOWN)
ExceptionMessage(" Unknown check level [%] specified"," 柍岠側僠僃僢僋儗儀儖巜掕 [%]") << work << throwException;
}else
current_level = NORMAL;
checkOption(parameter, "cpu", "cpu");
checkOption(parameter, "system", "system");
}
void ConfigurationChecker::body(Directory & parameter)
{
filecontainer * container;
bool result = true;
/* 傛傝桪愭搙偺崅偄僄儔乕傕懳徾偵 */
current_level = static_cast<enum tagCheckLevel>(static_cast<int>(current_level) * 2 - 1);
container = filecontainer::get_instance();
container->attach_infofile(parameter["/file/checkerscript"].toString().c_str());
container->attach_module(parameter["/file/loadmodule"].toString().c_str());
if(VerboseMessage::getVerbose())
{
cout << Message(" Target architecture : "," 僞乕僎僢僩傾乕僉僥僋僠儍 : ")
<< container->get_architecture() << endl;
}
error_count = 0;
result &= check_taskblock(parameter,container);
result &= check_semaphoreblock(parameter,container);
result &= check_eventflagblock(parameter,container);
result &= check_dataqueueblock(parameter,container);
result &= check_mailboxblock(parameter,container);
result &= check_fixed_memorypoolblock(parameter,container);
result &= check_cyclic_handlerblock(parameter,container);
result &= check_interrupt_handlerblock(parameter,container);
result &= check_exception_handlerblock(parameter,container);
if(!result)
ExceptionMessage("Total % errors found in current configuration.\n","慡晹偱%屄偺僄儔乕偑専弌偝傟傑偟偨\n") << error_count << throwException;
VerboseMessage("No error found in current configuration\n","峔惉偵堎忢偼偁傝傑偣傫偱偟偨\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -