|
|
kernel_chk.cpp00001 /* 00002 * TOPPERS/FDMP Kernel 00003 * Toyohashi Open Platform for Embedded Real-Time Systems/ 00004 * Function Distributed Multiprocessor Kernel 00005 * 00006 * Copyright (C) 2005 by Takagi Nobuhisa 00007 * 00008 * 上記著作権者は,以下の (1)〜(4) の条件か,Free Software Foundation 00009 * によって公表されている GNU General Public License の Version 2 に記 00010 * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア 00011 * を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下, 00012 * 利用と呼ぶ)することを無償で許諾する. 00013 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 00014 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 00015 * スコード中に含まれていること. 00016 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 00017 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 00018 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 00019 * の無保証規定を掲載すること. 00020 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 00021 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 00022 * と. 00023 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 00024 * 作権表示,この利用条件および下記の無保証規定を掲載すること. 00025 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 00026 * 報告すること. 00027 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 00028 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 00029 * 00030 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 00031 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も 00032 * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直 00033 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない. 00034 * 00035 */ 00036 00037 /* 00038 * toppers/itron/jsp/kernel_chk.cpp 00039 */ 00040 #include "toppers/itron/jsp/kernel_chk.hpp" 00041 #include "toppers/itron/jsp/kernel_policy.hpp" 00042 #include "toppers/s_record.hpp" 00043 #include "toppers/reporter.hpp" 00044 #include <ostream> 00045 #include <boost/lexical_cast.hpp> 00046 00047 namespace toppers 00048 { 00049 namespace itron 00050 { 00051 namespace jsp 00052 { 00053 00054 void kernel_chk::do_body( std::ostream& ostr ) const 00055 { 00056 ostr << "#include \"kernel_cfg.h\"\n" 00057 "#include <stddef.h>\n" 00058 "\n"; 00059 00060 ostr << "const UW kernel_chk[] = {\n"; 00061 00062 std::string table[table_size]; 00063 00064 table[magic_number] = "0x12345678"; 00065 table[TKERNEL_PRID] = boost::lexical_cast<std::string>( (int)kernel_policy::prid_ ) + "\t/* TKERNEL_PRID */"; 00066 00067 table[sizeof_ID] = "sizeof(ID)"; 00068 table[sizeof_UINT] = "sizeof(UINT)"; 00069 table[sizeof_SIZE] = "sizeof(SIZE)"; 00070 table[sizeof_ATR] = "sizeof(ATR)"; 00071 table[sizeof_PRI] = "sizeof(PRI)"; 00072 table[sizeof_RELTIM] = "sizeof(RELTIM)"; 00073 table[sizeof_VP] = "sizeof(VP)"; 00074 table[sizeof_VP_INT] = "sizeof(VP_INT)"; 00075 table[sizeof_FP] = "sizeof(FP)"; 00076 00077 table[countof_TSKID] = boost::lexical_cast<std::string>( countof( "task" ) ) + "\t/* TNUM_TSKID */"; 00078 table[sizeof_TINIB] = "sizeof(TINIB)"; 00079 table[offsetof_TINIB_tskatr] = "offsetof(TINIB, tskatr)"; 00080 table[offsetof_TINIB_exinf] = "offsetof(TINIB, exinf)"; 00081 table[offsetof_TINIB_task] = "offsetof(TINIB, task)"; 00082 table[offsetof_TINIB_ipriority] = "offsetof(TINIB, ipriority)"; 00083 table[offsetof_TINIB_stksz] = "offsetof(TINIB, stksz)"; 00084 table[offsetof_TINIB_stk] = "offsetof(TINIB, stk)"; 00085 table[offsetof_TINIB_texatr] = "offsetof(TINIB, texatr)"; 00086 table[offsetof_TINIB_texrtn] = "offsetof(TINIB, texrtn)"; 00087 00088 table[countof_SEMID] = boost::lexical_cast<std::string>( countof( "semaphore" ) ) + "\t/* TNUM_SEMID */"; 00089 table[sizeof_SEMINIB] = "sizeof(SEMINIB)"; 00090 table[offsetof_SEMINIB_sematr] = "offsetof(SEMINIB, sematr)"; 00091 table[offsetof_SEMINIB_isemcnt] = "offsetof(SEMINIB, isemcnt)"; 00092 table[offsetof_SEMINIB_maxsem] = "offsetof(SEMINIB, maxsem)"; 00093 00094 table[countof_FLGID] = boost::lexical_cast<std::string>( countof( "eventflag" ) ) + "\t/* TNUM_FLGID */"; 00095 table[sizeof_FLGPTN] = "sizeof(FLGPTN)"; 00096 table[sizeof_FLGINIB] = "sizeof(FLGINIB)"; 00097 table[offsetof_FLGINIB_flgatr] = "offsetof(FLGINIB, flgatr)"; 00098 table[offsetof_FLGINIB_iflgptn] = "offsetof(FLGINIB, iflgptn)"; 00099 00100 table[countof_DTQID] = boost::lexical_cast<std::string>( countof( "dataqueue" ) ) + "\t/* TNUM_DTQID */"; 00101 table[sizeof_DTQINIB] = "sizeof(DTQINIB)"; 00102 table[offsetof_DTQINIB_dtqatr] = "offsetof(DTQINIB, dtqatr)"; 00103 table[offsetof_DTQINIB_dtqcnt] = "offsetof(DTQINIB, dtqcnt)"; 00104 table[offsetof_DTQINIB_dtq] = "offsetof(DTQINIB, dtq)"; 00105 00106 table[countof_MBXID] = boost::lexical_cast<std::string>( countof( "mailbox" ) ) + "\t/* TNUM_MBXID */"; 00107 table[sizeof_MBXINIB] = "sizeof(MBXINIB)"; 00108 table[offsetof_MBXINIB_mbxatr] = "offsetof(MBXINIB, mbxatr)"; 00109 table[offsetof_MBXINIB_maxmpri] = "offsetof(MBXINIB, maxmpri)"; 00110 00111 table[countof_MPFID] = boost::lexical_cast<std::string>( countof( "mempfix" ) ) + "\t/* TNUM_MPFID */"; 00112 table[sizeof_MPFINIB] = "sizeof(MPFINIB)"; 00113 table[offsetof_MPFINIB_mpfatr] = "offsetof(MPFINIB, mpfatr)"; 00114 table[offsetof_MPFINIB_blksz] = "offsetof(MPFINIB, blksz)"; 00115 table[offsetof_MPFINIB_mpf] = "offsetof(MPFINIB, mpf)"; 00116 table[offsetof_MPFINIB_limit] = "offsetof(MPFINIB, limit)"; 00117 00118 table[countof_CYCID] = boost::lexical_cast<std::string>( countof( "cyclic" ) ) + "\t/* TNUM_CYCID */"; 00119 table[sizeof_CYCINIB] = "sizeof(CYCINIB)"; 00120 table[offsetof_CYCINIB_cycatr] = "offsetof(CYCINIB, cycatr)"; 00121 table[offsetof_CYCINIB_exinf] = "offsetof(CYCINIB, exinf)"; 00122 table[offsetof_CYCINIB_cychdr] = "offsetof(CYCINIB, cychdr)"; 00123 table[offsetof_CYCINIB_cyctim] = "offsetof(CYCINIB, cyctim)"; 00124 table[offsetof_CYCINIB_cycphs] = "offsetof(CYCINIB, cycphs)"; 00125 00126 table[countof_INHNO] = boost::lexical_cast<std::string>( countof( "interrupt" ) ) + "\t/* TNUM_INHNO */"; 00127 table[sizeof_INHNO] = "sizeof(INHNO)"; 00128 table[sizeof_INHINIB] = "sizeof(INHINIB)"; 00129 table[offsetof_INHINIB_inhno] = "offsetof(INHINIB, inhno)"; 00130 table[offsetof_INHINIB_inhatr] = "offsetof(INHINIB, inhatr)"; 00131 table[offsetof_INHINIB_inthdr] = "offsetof(INHINIB, inthdr)"; 00132 00133 table[countof_EXCNO] = boost::lexical_cast<std::string>( countof( "exception" ) ) + "\t/* TNUM_EXCNO */"; 00134 table[sizeof_EXCNO] = "sizeof(EXCNO)"; 00135 table[sizeof_EXCINIB] = "sizeof(EXCINIB)"; 00136 table[offsetof_EXCINIB_excno] = "offsetof(EXCINIB, excno)"; 00137 table[offsetof_EXCINIB_excatr] = "offsetof(EXCINIB, excatr)"; 00138 table[offsetof_EXCINIB_exchdr] = "offsetof(EXCINIB, exchdr)"; 00139 00140 for ( int i = 0; i < table_size; i++ ) 00141 { 00142 ostr << '\t' << table[i] << ",\n"; 00143 } 00144 00145 ostr << "};\n"; 00146 } 00147 00148 bool kernel_chk::do_load( const s_record& srec, unsigned long address ) 00149 { 00150 bool result = true; 00151 set( table_size-1, 0 ); // 効率化のため、終端要素を空打ちする 00152 00153 for ( int i = 0; i < table_size; i++ ) 00154 { 00155 unsigned long value = 0; 00156 for ( int j = 0; j < 4; j++ ) 00157 { 00158 value = value << 8 | srec[address + i*4 + j]; 00159 } 00160 set( i, value ); 00161 } 00162 00163 switch ( get( magic_number ) ) 00164 { 00165 case 0x12345678: 00166 byteorder( big_endian ); 00167 break; 00168 case 0x78563412: 00169 byteorder( little_endian ); 00170 for ( int i = 0; i < table_size; i++ ) 00171 { 00172 unsigned long value = 0; 00173 unsigned long t = get( i ); 00174 for ( int j = 0; j < 4; j++ ) 00175 { 00176 value = value << 8 | ( t & 0xff ); 00177 t >>= 8; 00178 } 00179 set( i, value ); 00180 } 00181 break; 00182 default: 00183 result = false; 00184 break; 00185 } 00186 return result; 00187 } 00188 00189 } 00190 } 00191 } Copyright © 2006 by TAKAGI Nobuhisa. このページは Wed Apr 12 16:31:56 2006 に Doxygen によって生成されました。 |