1 | # -*- coding: utf-8 -*-
|
---|
2 | #
|
---|
3 | # TECS Generator
|
---|
4 | # Generator for TOPPERS Embedded Component System
|
---|
5 | #
|
---|
6 | # Copyright (C) 2008-2014 by TOPPERS Project
|
---|
7 | #--
|
---|
8 | # ä¸è¨èä½æ¨©è
|
---|
9 | ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
10 | # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
11 | # å¤ã»åé
|
---|
12 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
13 | # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
14 | # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
15 | # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
16 | # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
17 | # ç¨ã§ããå½¢ã§åé
|
---|
18 | å¸ããå ´åã«ã¯ï¼åé
|
---|
19 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
20 | # è
|
---|
21 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
22 | # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
23 | # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
24 | # ç¨ã§ããªãå½¢ã§åé
|
---|
25 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
26 | # ã¨ï¼
|
---|
27 | # (a) åé
|
---|
28 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
29 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
30 | # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
31 | # (b) åé
|
---|
32 | å¸ã®å½¢æ
|
---|
33 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
34 | # å ±åãããã¨ï¼
|
---|
35 | # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
36 | # 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
37 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
38 | 責ãããã¨ï¼
|
---|
39 | # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
40 | # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
41 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
42 | # å
|
---|
43 | 責ãããã¨ï¼
|
---|
44 | #
|
---|
45 | # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
46 | ã
|
---|
47 | # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
48 | # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
49 | # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
50 | # ã®è²¬ä»»ãè² ããªãï¼
|
---|
51 | #
|
---|
52 | # $Id$
|
---|
53 | #++
|
---|
54 |
|
---|
55 | # mikan through plugin: namespace ãèæ
|
---|
56 | ®ããã¦ããªã
|
---|
57 | # ãããå©ç¨ããå ´åã以ä¸ã®ããã« toppers_jsp.cdl sChannel.cdl ãæå®ããå¿
|
---|
58 | è¦ããã
|
---|
59 | # tecsgen toppers_jsp.cdl sChannel.cdl your_description.cdl
|
---|
60 |
|
---|
61 | # 以ä¸ãä»®å®ï¼å¶éäºé
|
---|
62 | ï¼
|
---|
63 | # å¼ã³å
|
---|
64 | ãå¼ã³å
|
---|
65 | ã®ã¨ã³ãã£ã¢ã³ãchar, short, int_t, long_t, intptr_t ã®ãµã¤ãºãåã
|
---|
66 | # æ符å·ãç¡ç¬¦å·ã§ãµã¤ãºãåã
|
---|
67 |
|
---|
68 | class SVCManage
|
---|
69 | # TODO: ããã©ã«ãã®æ¡å¼µãµã¼ãã¹ã³ã¼ã«åãäºç´ãã¦ãã
|
---|
70 | # ããã©ã«ãã®æ¡å¼µãµã¼ãã¹ã³ã¼ã«ï¼syslogãªã©ï¼ãã³ã³ãã¼ãã³ãåããã¾ã§
|
---|
71 | @@id = 20
|
---|
72 | @@func_ids = {}
|
---|
73 | def self.get_func_id func_name
|
---|
74 | return @@func_ids[ func_name ]
|
---|
75 | end
|
---|
76 | def self.set_func_id func_name
|
---|
77 | @@func_ids[ func_name ] = self.assign_id
|
---|
78 | puts @@func_ids[ func_name ]
|
---|
79 | end
|
---|
80 | def self.include_func_id? func_name
|
---|
81 | return @@func_ids.has_key?( func_name )
|
---|
82 | end
|
---|
83 | def self.get_id
|
---|
84 | return @@id
|
---|
85 | end
|
---|
86 | def self.set_id id
|
---|
87 | @@id = id
|
---|
88 | end
|
---|
89 | def self.assign_id
|
---|
90 | @@id += 1
|
---|
91 | return @@id
|
---|
92 | end
|
---|
93 | end
|
---|
94 |
|
---|
95 | #
|
---|
96 | # æ¡å¼µãµã¼ãã¹ã³ã¼ã«ãç¨ãããã¡ã¤ã³ééä¿¡ã®
|
---|
97 | # throughãã©ã°ã¤ã³
|
---|
98 | # HRP2ãã¡ã¤ã³ãã©ã°ã¤ã³ã«ãã£ã¦æ¿å
|
---|
99 | ¥ããã
|
---|
100 | #
|
---|
101 | class HRP2SVCPlugin < ThroughPlugin
|
---|
102 |
|
---|
103 | #=== RPCPlugin ã® initialize
|
---|
104 | # 説æ㯠ThroughPlugin (plugin.rb) ãåç
|
---|
105 | §
|
---|
106 | @@generated_celltype_header = {}
|
---|
107 |
|
---|
108 | def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
|
---|
109 | super
|
---|
110 | @ct_name_body = "#{@ct_name}SVCBody_#{@next_cell.get_name}_#{@next_cell_port_name}".to_sym
|
---|
111 | @ct_name = "#{@ct_name}SVCCaller_#{@next_cell.get_name}_#{@next_cell_port_name}".to_sym
|
---|
112 | @cell_name_body = "#{@cell_name}SVCBody".to_sym
|
---|
113 | @cell_name = "#{@cell_name}SVCCaller".to_sym
|
---|
114 | puts "%%%% "
|
---|
115 | p @next_cell.get_name
|
---|
116 | p @caller_cell.get_name
|
---|
117 | end
|
---|
118 |
|
---|
119 | #=== NamespacePath ãå¾ã
|
---|
120 | # çæããã»ã«ã® namespace path ãçæãã
|
---|
121 | def get_cell_namespace_path
|
---|
122 | # nsp = @region.get_namespace.get_namespace_path
|
---|
123 | nsp = @start_region.get_namespace_path
|
---|
124 | return nsp.append( @cell_name )
|
---|
125 | end
|
---|
126 |
|
---|
127 | def gen_plugin_decl_code( file )
|
---|
128 |
|
---|
129 | # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
|
---|
130 | if !HRP2KernelObjectPlugin.include_celltype?(@next_cell.get_celltype)
|
---|
131 | if @@generated_celltype[ @ct_name_body ] == nil then
|
---|
132 | @@generated_celltype[ @ct_name_body ] = [ self ]
|
---|
133 | file2 = CFile.open( "#{$gen}/#{@ct_name_body}.cdl", "w" )
|
---|
134 | file2.print <<EOT
|
---|
135 | [active]
|
---|
136 | celltype #{@ct_name_body} {
|
---|
137 | call #{@signature.get_name} #{@call_port_name};
|
---|
138 | };
|
---|
139 | EOT
|
---|
140 | file2.close
|
---|
141 | else
|
---|
142 | @@generated_celltype[ @ct_name_body ] << self
|
---|
143 | end
|
---|
144 | file.print "import( \"#{$gen}/#{@ct_name_body}.cdl\" );\n"
|
---|
145 | end
|
---|
146 |
|
---|
147 | # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
|
---|
148 | if @@generated_celltype[ @ct_name ] == nil then
|
---|
149 | @@generated_celltype[ @ct_name ] = [ self ]
|
---|
150 | file2 = CFile.open( "#{$gen}/#{@ct_name}.cdl", "w" )
|
---|
151 | if !HRP2KernelObjectPlugin.include_celltype?(@next_cell.get_celltype)
|
---|
152 | file2.print <<EOT
|
---|
153 | celltype #{@ct_name} {
|
---|
154 | entry #{@signature.get_name} #{@entry_port_name};
|
---|
155 | };
|
---|
156 | EOT
|
---|
157 | else
|
---|
158 | # TODO inlineã«ããæ¹ãå¹çããããï¼tecsgenã®çæããããããã¡ã¤ã«ã®
|
---|
159 | # èªè¾¼é ã®ããã«ã¨ã©ã¼ã¨ãªã
|
---|
160 | file2.print <<EOT
|
---|
161 | celltype #{@ct_name} {
|
---|
162 | //[inline] entry #{@signature.get_name} #{@entry_port_name};
|
---|
163 | entry #{@signature.get_name} #{@entry_port_name};
|
---|
164 | call #{@signature.get_name} #{@call_port_name};
|
---|
165 | };
|
---|
166 | EOT
|
---|
167 | end
|
---|
168 |
|
---|
169 | file2.close
|
---|
170 | else
|
---|
171 | @@generated_celltype[ @ct_name ] << self
|
---|
172 | end
|
---|
173 | file.print "import( \"#{$gen}/#{@ct_name}.cdl\" );\n"
|
---|
174 |
|
---|
175 | =begin
|
---|
176 | # TODO: send. receive 対å¿
|
---|
177 | send_receive = []
|
---|
178 | if @signature != nil then
|
---|
179 | @signature.each_param{ |fd,param|
|
---|
180 | dir =param.get_direction
|
---|
181 | case dir
|
---|
182 | when :SEND, :RECEIVE
|
---|
183 | send_receive << [ dir, fd, param ]
|
---|
184 | end
|
---|
185 | }
|
---|
186 | end
|
---|
187 | =end
|
---|
188 |
|
---|
189 | =begin
|
---|
190 | composite #{@ct_name} {
|
---|
191 | entry #{@signature.get_name} #{@entry_port_name};
|
---|
192 | call #{@signature.get_name} #{@call_port_name};
|
---|
193 |
|
---|
194 | cell #{@ct_name}Client #{@cell_name}Client{
|
---|
195 | };
|
---|
196 |
|
---|
197 | [active]
|
---|
198 | cell #{@ct_name}Server #{@cell_name}Server{
|
---|
199 | #{@call_port_name} => composite.#{@call_port_name};
|
---|
200 | };
|
---|
201 |
|
---|
202 | composite.#{@entry_port_name} => #{@cell_name}.#{@entry_port_name};
|
---|
203 | };
|
---|
204 | =end
|
---|
205 |
|
---|
206 | end
|
---|
207 |
|
---|
208 | #=== through cell ã³ã¼ããçæ
|
---|
209 | #
|
---|
210 | #
|
---|
211 | def gen_through_cell_code( file )
|
---|
212 | #require "HRP2Cache"
|
---|
213 |
|
---|
214 | gen_plugin_decl_code( file )
|
---|
215 |
|
---|
216 | if !HRP2KernelObjectPlugin.include_celltype?(@next_cell.get_celltype)
|
---|
217 | # ã»ã«ãæ¢ã
|
---|
218 | # path =["::",@next_cell.get_name] # mikan namespace
|
---|
219 | # cell = Namespace.find( path )
|
---|
220 | # cell = Namespace.find( @next_cell.get_namespace_path )
|
---|
221 |
|
---|
222 | ##### ã¯ã©ã¤ã¢ã³ãå´ã®ã»ã«ã®çæ #####
|
---|
223 | # file.print "[domain(HRP2, \"trusted\")]"
|
---|
224 | nest = @start_region.gen_region_str_pre file
|
---|
225 | nest_str = " " * nest
|
---|
226 |
|
---|
227 | # ã¯ã©ã¤ã¢ã³ãå´ãã£ã³ãã«ã®çæ
|
---|
228 | # æ¡å¼µãµã¼ãã¹ã³ã¼ã«å¼åºã
|
---|
229 | file.print <<EOT
|
---|
230 | #{nest_str} // Client Side Channel
|
---|
231 | #{nest_str} cell #{@ct_name} #{@cell_name}{
|
---|
232 | #{nest_str} };
|
---|
233 |
|
---|
234 | EOT
|
---|
235 |
|
---|
236 | @start_region.gen_region_str_post file
|
---|
237 | file.print "\n\n"
|
---|
238 |
|
---|
239 | ##### ãµã¼ãã¼å´ã®ã»ã«ã®çæ #####
|
---|
240 | nest = @end_region.gen_region_str_pre file
|
---|
241 | nest_str = " " * nest
|
---|
242 | if @next_cell_port_subscript then
|
---|
243 | subscript = '[' + @next_cell_port_subscript.to_s + ']'
|
---|
244 | else
|
---|
245 | subscript = ""
|
---|
246 | end
|
---|
247 |
|
---|
248 | # ãµã¼ãã¼å´ãã£ã³ãã«ã®çæ
|
---|
249 | # æ¡å¼µãµã¼ãã¹ã³ã¼ã«æ¬ä½
|
---|
250 | file.print <<EOT
|
---|
251 |
|
---|
252 | #{nest_str} // Server Side Channel
|
---|
253 | #{nest_str} cell #{@ct_name_body} #{@cell_name_body}{
|
---|
254 | #{nest_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
|
---|
255 | #{nest_str} };
|
---|
256 | EOT
|
---|
257 |
|
---|
258 | @end_region.gen_region_str_post file
|
---|
259 |
|
---|
260 | file2 = AppFile.open( "#{$gen}/tecsgen.cfg" )
|
---|
261 | file2.print "\n/* Generated by HRP2SVCPlugin */\n\n"
|
---|
262 | file2.print <<EOT
|
---|
263 | #include "#{@ct_name_body}_factory.h"
|
---|
264 | EOT
|
---|
265 | file2.close
|
---|
266 | else
|
---|
267 |
|
---|
268 | ##### ã¯ã©ã¤ã¢ã³ãå´ã®ã»ã«ã®çæ #####
|
---|
269 | nest = @start_region.gen_region_str_pre file
|
---|
270 | nest_str = " " * nest
|
---|
271 | if @next_cell_port_subscript then
|
---|
272 | subscript = '[' + @next_cell_port_subscript.to_s + ']'
|
---|
273 | else
|
---|
274 | subscript = ""
|
---|
275 | end
|
---|
276 |
|
---|
277 | # ã¯ã©ã¤ã¢ã³ãå´ãã£ã³ãã«ã®çæ
|
---|
278 | # æ¡å¼µãµã¼ãã¹ã³ã¼ã«å¼åºã
|
---|
279 | file.print <<EOT
|
---|
280 | #{nest_str} // Client Side Channel
|
---|
281 | #{nest_str} cell #{@ct_name} #{@cell_name}{
|
---|
282 | #{nest_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
|
---|
283 | #{nest_str} };
|
---|
284 |
|
---|
285 | EOT
|
---|
286 |
|
---|
287 | @start_region.gen_region_str_post file
|
---|
288 | file.print "\n\n"
|
---|
289 |
|
---|
290 | end
|
---|
291 | end
|
---|
292 |
|
---|
293 | #=== åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
|
---|
294 | # é常ã§ããã°ãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
|
---|
295 | # ãã©ã°ã¤ã³ã®å ´åãå¤æ´ããå¿
|
---|
296 | è¦ã®ãªãã»ã«ã¿ã¤ãã³ã¼ããçæãã
|
---|
297 | #file:: FILE åºåå
|
---|
298 | ãã¡ã¤ã«
|
---|
299 | #b_singleton:: bool true if singleton
|
---|
300 | #ct_name:: Symbol
|
---|
301 | #global_ct_name:: string
|
---|
302 | #sig_name:: string
|
---|
303 | #ep_name:: string
|
---|
304 | #func_name:: string
|
---|
305 | #func_global_name:: string
|
---|
306 | #func_type:: class derived from Type
|
---|
307 | def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
|
---|
308 | puts "generate ep_func for #{ct_name}"
|
---|
309 |
|
---|
310 | if !HRP2KernelObjectPlugin.include_celltype?(@next_cell.get_celltype)
|
---|
311 | # æ¡å¼µãµã¼ãã¹ã³ã¼ã«å¼åºã
|
---|
312 | if ! func_type.get_type.kind_of?( VoidType ) then
|
---|
313 | file.print( " #{func_type.get_type_str} retval;\n" )
|
---|
314 | end
|
---|
315 |
|
---|
316 | if ! b_singleton then
|
---|
317 |
|
---|
318 | file.print <<EOT
|
---|
319 | #{ct_name}_CB *p_cellcb;
|
---|
320 | if( VALID_IDX( idx ) ){
|
---|
321 | p_cellcb = #{global_ct_name}_GET_CELLCB(idx);
|
---|
322 | }else{
|
---|
323 | /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
|
---|
324 | }
|
---|
325 |
|
---|
326 | EOT
|
---|
327 | end
|
---|
328 |
|
---|
329 | # p "celltype_name, sig_name, func_name, func_global_name"
|
---|
330 | # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
|
---|
331 |
|
---|
332 | delim = ""
|
---|
333 | if ! func_type.get_type.kind_of?( VoidType ) then
|
---|
334 | file.print( " retval = (#{func_type.get_type_str})" )
|
---|
335 | else
|
---|
336 | file.print( " " )
|
---|
337 | end
|
---|
338 |
|
---|
339 | #file.print( "#{@call_port_name}_#{func_name}(" )
|
---|
340 | # svcid = SVCManage.assign_id
|
---|
341 | new_func = false
|
---|
342 | if SVCManage.include_func_id?( "#{@ct_name_body}_#{func_name}" ) == false
|
---|
343 | new_func = true
|
---|
344 | SVCManage.set_func_id( "#{@ct_name_body}_#{func_name}" )
|
---|
345 | end
|
---|
346 | svcid = SVCManage.get_func_id( "#{@ct_name_body}_#{func_name}" )
|
---|
347 | #file.print( "cal_svc( #{@ct_name_body}_#{func_name}" )
|
---|
348 | file.print( "cal_svc( #{svcid.to_s}" )
|
---|
349 |
|
---|
350 | # if ( ! b_singleton ) then
|
---|
351 | # file.print( " tecs_this" )
|
---|
352 | # delim = ","
|
---|
353 | # end
|
---|
354 |
|
---|
355 | i = 0
|
---|
356 | params.each{ |param|
|
---|
357 | delim = ","
|
---|
358 | file.printf( "#{delim} #{param.get_name}" )
|
---|
359 | i += 1
|
---|
360 | }
|
---|
361 |
|
---|
362 | while(i < 5) do
|
---|
363 | delim = ","
|
---|
364 | file.printf( "#{delim} 0" )
|
---|
365 | i += 1
|
---|
366 | end
|
---|
367 |
|
---|
368 | file.print( " );\n" )
|
---|
369 |
|
---|
370 | if ! func_type.get_type.kind_of?( VoidType ) then
|
---|
371 | file.print( " return retval;\n" )
|
---|
372 | end
|
---|
373 |
|
---|
374 | # æ¡å¼µãµã¼ãã¹ã³ã¼ã«æ¬ä½
|
---|
375 | if new_func
|
---|
376 | file2 = AppFile.open( "#{$gen}/#{@ct_name_body}.c" )
|
---|
377 |
|
---|
378 | # if @@generated_celltype_header[ @ct_name_body ].nil?
|
---|
379 | # @@generated_celltype_header[ @ct_name_body ] = true
|
---|
380 | # p @@generated_celltype_header[ @ct_name_body ]
|
---|
381 | # file2.print <<EOT
|
---|
382 | # /*
|
---|
383 | # * ãã®ãã¡ã¤ã«ã¯ tecsgen ã«ããèªåçæããã¾ãã
|
---|
384 | # * ãã®ãã¡ã¤ã«ãç·¨éãã¦ä½¿ç¨ãããã¨ã¯ãæå³ããã¦ãã¾ãã
|
---|
385 | # */
|
---|
386 | # /* #[<PREAMBLE>]#
|
---|
387 | # * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
|
---|
388 | # * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
|
---|
389 | # *
|
---|
390 | # * #[</PREAMBLE>]# */
|
---|
391 | #
|
---|
392 | # /* ãããã¿ã¤ã宣è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
|
---|
393 | # #include "#{@ct_name_body}_tecsgen.h"
|
---|
394 | #
|
---|
395 | # #ifndef E_OK
|
---|
396 | # #define E_OK 0 /* success */
|
---|
397 | # #define E_ID (-18) /* illegal ID */
|
---|
398 | # #endif
|
---|
399 | #
|
---|
400 | # EOT
|
---|
401 | # end
|
---|
402 |
|
---|
403 | if func_type.get_type.kind_of?( VoidType ) then
|
---|
404 | retval_assign = ""
|
---|
405 | retval_return = ""
|
---|
406 | else
|
---|
407 | retval_assign = "retval = (ER_UINT)"
|
---|
408 | retval_return = "retval"
|
---|
409 | end
|
---|
410 |
|
---|
411 | file2.print <<EOT
|
---|
412 | ER_UINT
|
---|
413 | #{@ct_name_body}_#{func_name}(intptr_t par1, intptr_t par2, intptr_t par3, intptr_t par4, intptr_t par5, ID cdmid)
|
---|
414 | {
|
---|
415 | #{@ct_name_body}_CB *p_cellcb;
|
---|
416 | #if 0
|
---|
417 | if( VALID_IDX( idx ) ){
|
---|
418 | p_cellcb = #{@ct_name_body}_GET_CELLCB(idx);
|
---|
419 | }else{
|
---|
420 | /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
|
---|
421 | }
|
---|
422 | #else
|
---|
423 | p_cellcb = NULL;
|
---|
424 | #endif
|
---|
425 |
|
---|
426 | ER_UINT retval = 0;
|
---|
427 |
|
---|
428 | EOT
|
---|
429 |
|
---|
430 | num = 1
|
---|
431 | params.each{ |param|
|
---|
432 | if param.get_declarator.get_ptr_level > 0 then
|
---|
433 | if param.get_direction == :IN then
|
---|
434 | file2.print <<EOT
|
---|
435 | if(prb_mem((void *)par#{num.to_s}, sizeof(#{param.get_type.get_type_str}), TSK_SELF, TPM_READ) != E_OK){
|
---|
436 | return E_MACV;
|
---|
437 | }
|
---|
438 | EOT
|
---|
439 |
|
---|
440 | elsif param.get_direction == :OUT then
|
---|
441 | file2.print <<EOT
|
---|
442 | if(prb_mem((void *)par#{num.to_s}, sizeof(#{param.get_type.get_type_str}), TSK_SELF, TPM_WRITE) != E_OK){
|
---|
443 | return E_MACV;
|
---|
444 | }
|
---|
445 | EOT
|
---|
446 |
|
---|
447 | end
|
---|
448 | end
|
---|
449 | num += 1
|
---|
450 | }
|
---|
451 |
|
---|
452 | file2.print" #{retval_assign}#{@call_port_name}_#{func_name}("
|
---|
453 |
|
---|
454 | delim = ""
|
---|
455 | num = 1
|
---|
456 | params.each{ |param|
|
---|
457 | file2.print "#{delim}"
|
---|
458 | delim = ", "
|
---|
459 | file2.print "(#{param.get_type.get_type_str})"
|
---|
460 | file2.print "par" + num.to_s
|
---|
461 | file2.print param.get_type.get_type_str_post
|
---|
462 | num += 1
|
---|
463 | }
|
---|
464 |
|
---|
465 | file2.print ");\n"
|
---|
466 |
|
---|
467 | if !func_type.get_type.kind_of?( VoidType ) then
|
---|
468 | file2.print "\n return #{retval_return};\n"
|
---|
469 | end
|
---|
470 | file2.print "}\n\n"
|
---|
471 |
|
---|
472 | file2.close
|
---|
473 |
|
---|
474 | file2 = AppFile.open( "#{$gen}/tecsgen.cfg" )
|
---|
475 | file2.print "\n/* Generated by HRP2SVCPlugin */\n\n"
|
---|
476 | # TODO: ã¹ã¿ãã¯ãµã¤ãºã¯é©å½
|
---|
477 | file2.print <<EOT
|
---|
478 | KERNEL_DOMAIN{
|
---|
479 | DEF_SVC( #{svcid.to_s}, { TA_NULL, #{@ct_name_body}_#{func_name}, 256 } );
|
---|
480 | }
|
---|
481 | EOT
|
---|
482 | file2.close
|
---|
483 |
|
---|
484 | file2 = AppFile.open( "#{$gen}/#{@ct_name_body}_factory.h" )
|
---|
485 | file2.print "\n/* Generated by HRP2SVCPlugin */\n\n"
|
---|
486 | file2.print <<EOT
|
---|
487 | extern ER_UINT #{@ct_name_body}_#{func_name}(intptr_t par1, intptr_t par2, intptr_t par3, intptr_t par4, intptr_t par5, ID cdmid);
|
---|
488 | EOT
|
---|
489 | file2.close
|
---|
490 | end
|
---|
491 | else
|
---|
492 | # ã«ã¼ãã«ãã¡ã¤ã³ã®ã»ã«ã¯ç¹å¥ãªãã¨ã¯ä½ãããï¼æ®éã«å¼ã³åºã
|
---|
493 | super
|
---|
494 | end
|
---|
495 | end
|
---|
496 | end
|
---|
497 |
|
---|
498 |
|
---|