source: cfg_itronx+oil_gcc/toppers/itronx/cfg1_out.hpp

Last change on this file was 54, checked in by ertl-ishikawa, 12 years ago

cfg+oil対応コンフィギュレータを追加

File size: 4.6 KB
Line 
1/*
2 * TOPPERS Software
3 * Toyohashi Open Platform for Embedded Real-Time Systems
4 *
5 * Copyright (C) 2007-2010 by TAKAGI Nobuhisa
6 *
7 * 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
8 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
9 * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
10 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
11 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
12 * スコード中に含まれていること.
13 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
14 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
15 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
16 * の無保証規定を掲載すること.
17 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
18 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
19 * と.
20 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
21 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
22 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
23 * 報告すること.
24 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
25 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
26 * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
27 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
28 * 免責すること.
29 *
30 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
31 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
32 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
33 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
34 * の責任を負わない.
35 *
36 */
37/*!
38 * \file toppers/itronx/cfg1_out.hpp
39 * \brief cfg1_out.c/.srec ファイルを扱うための宣言定義
40 *
41 * このファイルで定義されるクラス
42 * \code
43 * class cfg1_out;
44 * \endcode
45 */
46#ifndef TOPPERS_ITRONX_CFG1_OUT_HPP_
47#define TOPPERS_ITRONX_CFG1_OUT_HPP_
48
49#include <string>
50#include <vector>
51#include <map>
52#include "toppers/workaround.hpp"
53#include "toppers/codeset.hpp"
54#include "toppers/itronx/static_api.hpp"
55
56namespace toppers
57{
58
59 class macro_processor;
60 class s_record;
61 class nm_symbol;
62
63 namespace itronx
64 {
65
66 /*!
67 * \class cfg1_out cfg1_out.hpp "toppers/itronx/cfg1_out.hpp"
68 * \brief cfg1_out.c/.srec ファイル管理クラス
69 */
70 class cfg1_out
71 {
72 public:
73 struct cfg1_def_t
74 {
75 bool is_signed;
76 std::string name;
77 std::string expression;
78 std::string value1;
79 std::string value2;
80 };
81 typedef std::map< std::string, std::vector< static_api > > static_api_map;
82 typedef std::vector< cfg1_def_t > cfg1_def_table;
83
84 explicit cfg1_out( std::string const& filename, cfg1_def_table const* def_table = 0 );
85 cfg1_out( cfg1_out const& other );
86 virtual ~cfg1_out();
87 cfg1_out& operator = ( cfg1_out const& other )
88 {
89 cfg1_out t( other );
90 swap( t );
91 return *this;
92 }
93
94 void load_cfg( std::string const& input_file, codeset_t codeset, std::map< std::string, static_api::info > const& info_map );
95 void generate( char const* type = 0 ) const;
96 std::vector< static_api > const& get_static_api_array() const;
97 std::vector< std::pair< std::string, long > > const& get_domid_table() const;
98 std::vector< std::pair< std::string, long > > const& get_clsid_table() const;
99 std::string const& get_includes() const;
100
101 void load_srec();
102 std::tr1::shared_ptr< s_record > get_srec() const;
103 std::tr1::shared_ptr< nm_symbol > get_syms() const;
104 cfg1_def_table const* get_def_table() const;
105 static_api_map merge() const;
106 bool is_little_endian() const;
107
108 void swap( cfg1_out& other )
109 {
110 implementation* t = pimpl_;
111 pimpl_ = other.pimpl_;
112 other.pimpl_ = t;
113 }
114
115 static std::tr1::int32_t make_signed( std::tr1::uint32_t value )
116 {
117 std::tr1::int32_t result;
118 if ( ( value >> 31 ) != 0 )
119 {
120 result = -static_cast< std::tr1::int32_t >( ( value ^ 0xffffffff ) + 1 ); // 2の補数表現にしか対応しない
121 }
122 else
123 {
124 result = static_cast< std::tr1::int32_t >( value );
125 }
126 return result;
127 }
128
129 static void load_id_input_file( std::map< std::string, std::pair< long, bool > >& id_map );
130
131 protected:
132 struct implementation;
133 explicit cfg1_out( implementation* pimpl ) : pimpl_( pimpl ) {}
134 private:
135 implementation* pimpl_;
136 };
137
138 }
139}
140
141#endif // ! TOPPERS_ITRONX_CFG1_OUT_HPP_
Note: See TracBrowser for help on using the repository browser.