[270] | 1 | # -*- coding: utf-8 -*-
|
---|
| 2 | #
|
---|
| 3 | # TECS Generator Cell-type plugin
|
---|
| 4 | # for TOPPERS Embedded Component System
|
---|
| 5 | #
|
---|
| 6 | # Copyright (C) 2008-2014 by TOPPERS Project TECS-WG
|
---|
| 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 | #== celltype ãã©ã°ã¤ã³ã®å
|
---|
| 56 | ±éã®è¦ªã¯ã©ã¹
|
---|
| 57 | class ATK1KernelPlugin < CelltypePlugin
|
---|
| 58 | #@celltype:: Celltype
|
---|
| 59 | #@option:: String :ãªãã·ã§ã³æåå
|
---|
| 60 | @@cell_list = []
|
---|
| 61 |
|
---|
| 62 | #signature:: Celltype ã·ã°ããã£ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
|
---|
| 63 | def initialize( celltype, option )
|
---|
| 64 | super
|
---|
| 65 | end
|
---|
| 66 |
|
---|
| 67 | #=== CDL ãã¡ã¤ã«ã®çæ
|
---|
| 68 | # typedef, signature, celltype, cell ã®ã³ã¼ããçæ
|
---|
| 69 | # éè¤ãã¦çæãã¦ã¯ãªããªã
|
---|
| 70 | # ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã
|
---|
| 71 | # ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã
|
---|
| 72 | #file:: FILE çæãããã¡ã¤ã«
|
---|
| 73 | # def gen_cdl_file file
|
---|
| 74 | # end
|
---|
| 75 |
|
---|
| 76 | def new_cell cell
|
---|
| 77 | # join_list = cell.get_join_list
|
---|
| 78 | # a = join_list.get_item( :resource )
|
---|
| 79 | # if a == nil
|
---|
| 80 | # Generator.error( "resource: must be initialized")
|
---|
| 81 | # elsif ! a.get_rhs.instance_of? Array
|
---|
| 82 | # Generator.error( "resource: initializer must be in format of '{val1, val2 ...}'")
|
---|
| 83 | # end
|
---|
| 84 | @@cell_list << cell
|
---|
| 85 | end
|
---|
| 86 |
|
---|
| 87 | #=== åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
|
---|
| 88 | # ãã®ã¡ã½ãããæªå®ç¾©ã®å ´åãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
|
---|
| 89 | # ãã®ã¡ã½ãããå®ç¾©æ¸ã¿ã®å ´åãï¼ãã³ãã¬ã¼ãã§ã¯ãªããå¤æ´ããå¿
|
---|
| 90 | è¦ã®ãªãï¼ã»ã«ã¿ã¤ãã³ã¼ããçæãã
|
---|
| 91 | #file:: FILE åºåå
|
---|
| 92 | ãã¡ã¤ã«
|
---|
| 93 | #b_singleton:: bool true if singleton
|
---|
| 94 | #ct_name:: Symbol
|
---|
| 95 | #global_ct_name:: string
|
---|
| 96 | #sig_name:: string
|
---|
| 97 | #ep_name:: string
|
---|
| 98 | #func_name:: string
|
---|
| 99 | #func_global_name:: string
|
---|
| 100 | #func_type:: class derived from Type
|
---|
| 101 | # 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 )
|
---|
| 102 | # end
|
---|
| 103 |
|
---|
| 104 | def gen_factory file
|
---|
| 105 |
|
---|
| 106 | file2 = CFile.open( "#{$gen}/Kernel_tecsgen.oil", "w" )
|
---|
| 107 |
|
---|
| 108 | # Kernel
|
---|
| 109 | @celltype.get_cell_list.each { |cell|
|
---|
| 110 |
|
---|
| 111 | if cell.is_generate?
|
---|
| 112 |
|
---|
| 113 | file2.print "\tOS #{cell.get_name} {\n"
|
---|
| 114 |
|
---|
| 115 | # STATUS
|
---|
| 116 | join = cell.get_join_list.get_item( :status )
|
---|
| 117 | if join then
|
---|
| 118 | str = join.get_rhs.to_s.gsub(/^"(.*)"$/, '\1')
|
---|
| 119 | file2.print "\t\tSTATUS = #{str};\n"
|
---|
| 120 | end
|
---|
| 121 |
|
---|
| 122 | # STARTUPHOOK
|
---|
| 123 | join = cell.get_join_list.get_item( :useStartupHook )
|
---|
| 124 | if join then
|
---|
| 125 | str = join.get_rhs.to_s
|
---|
| 126 | file2.print "\t\tSTARTUPHOOK = #{str};\n"
|
---|
| 127 | end
|
---|
| 128 |
|
---|
| 129 | # ERRORHOOK
|
---|
| 130 | join = cell.get_join_list.get_item( :useErrorHook )
|
---|
| 131 | if join then
|
---|
| 132 | str = join.get_rhs.to_s
|
---|
| 133 | file2.print "\t\tERRORHOOK = #{str};\n"
|
---|
| 134 | end
|
---|
| 135 |
|
---|
| 136 | # SHUTDOWNHOOK
|
---|
| 137 | join = cell.get_join_list.get_item( :useShutdownHook )
|
---|
| 138 | if join then
|
---|
| 139 | str = join.get_rhs.to_s
|
---|
| 140 | file2.print "\t\tSHUTDOWNHOOK = #{str};\n"
|
---|
| 141 | end
|
---|
| 142 |
|
---|
| 143 | # PRETASKHOOK
|
---|
| 144 | join = cell.get_join_list.get_item( :usePreTaskHook )
|
---|
| 145 | if join then
|
---|
| 146 | str = join.get_rhs.to_s
|
---|
| 147 | file2.print "\t\tPRETASKHOOK = #{str};\n"
|
---|
| 148 | end
|
---|
| 149 |
|
---|
| 150 | # POSTASKHOOK
|
---|
| 151 | join = cell.get_join_list.get_item( :usePostTaskHook )
|
---|
| 152 | if join then
|
---|
| 153 | str = join.get_rhs.to_s
|
---|
| 154 | file2.print "\t\tPOSTTASKHOOK = #{str};\n"
|
---|
| 155 | end
|
---|
| 156 |
|
---|
| 157 | # USEGETSERVICEID
|
---|
| 158 | join = cell.get_join_list.get_item( :useGetServiceId )
|
---|
| 159 | if join then
|
---|
| 160 | str = join.get_rhs.to_s
|
---|
| 161 | file2.print "\t\tUSEGETSERVICEID = #{str};\n"
|
---|
| 162 | end
|
---|
| 163 |
|
---|
| 164 | # USEPARAMETERACCESS
|
---|
| 165 | join = cell.get_join_list.get_item( :useParameterAccess )
|
---|
| 166 | if join then
|
---|
| 167 | str = join.get_rhs.to_s
|
---|
| 168 | file2.print "\t\tUSEPARAMETERACCESS = #{str};\n"
|
---|
| 169 | end
|
---|
| 170 |
|
---|
| 171 | # USERESSCHEDULER
|
---|
| 172 | join = cell.get_join_list.get_item( :useResourceScheduler )
|
---|
| 173 | if join then
|
---|
| 174 | str = join.get_rhs.to_s
|
---|
| 175 | file2.print "\t\tUSERESSCHEDULER = #{str};\n"
|
---|
| 176 | end
|
---|
| 177 |
|
---|
| 178 | file2.print "\t};\n\n"
|
---|
| 179 |
|
---|
| 180 | end
|
---|
| 181 |
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | file2.close
|
---|
| 185 |
|
---|
| 186 | # 追è¨ããããã« AppFile ã使ãï¼æåã³ã¼ãå¤æãããªãï¼
|
---|
| 187 | file2 = AppFile.open( "#{$gen}/tKernel_tecsgen.#{$c_suffix}" )
|
---|
| 188 | file2.print "\n/* Generated by ATK1KernelPlugin */\n\n"
|
---|
| 189 | @celltype.get_cell_list.each { |cell|
|
---|
| 190 | if cell.is_generate?
|
---|
| 191 | name_array = @celltype.get_name_array( cell )
|
---|
| 192 |
|
---|
| 193 | join = cell.get_join_list.get_item( :useStartupHook )
|
---|
| 194 | if join then
|
---|
| 195 | str = join.get_rhs.to_s
|
---|
| 196 | if str == "TRUE" then
|
---|
| 197 | file2.print <<EOT
|
---|
| 198 | #ifdef USE_STARTUPHOOK
|
---|
| 199 | void StartupHook(void)
|
---|
| 200 | {
|
---|
| 201 | /* CELLCB *p_cellcb = #{name_array[8]}; */
|
---|
| 202 | INT32 i;
|
---|
| 203 | for(i = 0; i < N_CP_cStartupHookBody; i++){
|
---|
| 204 | cStartupHookBody_main(i);
|
---|
| 205 | }
|
---|
| 206 | }
|
---|
| 207 | #endif /* USE_STARTUPHOOK */
|
---|
| 208 | EOT
|
---|
| 209 | end
|
---|
| 210 | end
|
---|
| 211 |
|
---|
| 212 | join = cell.get_join_list.get_item( :useErrorHook )
|
---|
| 213 | if join then
|
---|
| 214 | str = join.get_rhs.to_s
|
---|
| 215 | if str == "TRUE" then
|
---|
| 216 | file2.print <<EOT
|
---|
| 217 | #ifdef USE_ERRORHOOK
|
---|
| 218 | void ErrorHook(StatusType ercd)
|
---|
| 219 | {
|
---|
| 220 | /* CELLCB *p_cellcb = #{name_array[8]}; */
|
---|
| 221 | cErrorHookBody_main( ercd );
|
---|
| 222 | }
|
---|
| 223 | #endif /* USE_ERRORHOOK */
|
---|
| 224 |
|
---|
| 225 | EOT
|
---|
| 226 | end
|
---|
| 227 | end
|
---|
| 228 |
|
---|
| 229 | join = cell.get_join_list.get_item( :useShutdownHook )
|
---|
| 230 | if join then
|
---|
| 231 | str = join.get_rhs.to_s
|
---|
| 232 | if str == "TRUE" then
|
---|
| 233 | file2.print <<EOT
|
---|
| 234 | #ifdef USE_SHUTDOWNHOOK
|
---|
| 235 | void ShutdownHook(StatusType ercd)
|
---|
| 236 | {
|
---|
| 237 | /* CELLCB *p_cellcb = #{name_array[8]}; */
|
---|
| 238 | INT32 i;
|
---|
| 239 | for(i = 0; i < N_CP_cShutdownHookBody; i++){
|
---|
| 240 | cShutdownHookBody_main( i, ercd );
|
---|
| 241 | }
|
---|
| 242 | }
|
---|
| 243 | #endif /* USE_SHUTDOWNHOOK */
|
---|
| 244 |
|
---|
| 245 | EOT
|
---|
| 246 | end
|
---|
| 247 | end
|
---|
| 248 |
|
---|
| 249 | join = cell.get_join_list.get_item( :usePreTaskHook )
|
---|
| 250 | if join then
|
---|
| 251 | str = join.get_rhs.to_s
|
---|
| 252 | if str == "TRUE" then
|
---|
| 253 | file2.print <<EOT
|
---|
| 254 | #ifdef USE_PRETASKHOOK
|
---|
| 255 | void PreTaskHook(void)
|
---|
| 256 | {
|
---|
| 257 | /* CELLCB *p_cellcb = #{name_array[8]}; */
|
---|
| 258 | cPreTaskHookBody_main();
|
---|
| 259 | }
|
---|
| 260 | #endif /* USE_PRETASKHOOK */
|
---|
| 261 |
|
---|
| 262 | EOT
|
---|
| 263 | end
|
---|
| 264 | end
|
---|
| 265 |
|
---|
| 266 | join = cell.get_join_list.get_item( :usePostTaskHook )
|
---|
| 267 | if join then
|
---|
| 268 | str = join.get_rhs.to_s
|
---|
| 269 | if str == "TRUE" then
|
---|
| 270 | file2.print <<EOT
|
---|
| 271 | #ifdef USE_POSTTASKHOOK
|
---|
| 272 | void PostTaskHook(void)
|
---|
| 273 | {
|
---|
| 274 | /* CELLCB *p_cellcb = #{name_array[8]}; */
|
---|
| 275 | cPostTaskHookBody_main();
|
---|
| 276 | }
|
---|
| 277 | #endif /* USE_POSTTASKHOOK */
|
---|
| 278 |
|
---|
| 279 | EOT
|
---|
| 280 | end
|
---|
| 281 | end
|
---|
| 282 |
|
---|
| 283 | end
|
---|
| 284 | }
|
---|
| 285 |
|
---|
| 286 | file2.close
|
---|
| 287 |
|
---|
| 288 | end
|
---|
| 289 |
|
---|
| 290 | def self.gen_post_code file
|
---|
| 291 |
|
---|
| 292 | @@cell_list.each { |cell|
|
---|
| 293 | join = cell.get_join_list.get_item( :useResourceScheduler )
|
---|
| 294 | if join then
|
---|
| 295 | flag = join.get_rhs.to_s
|
---|
| 296 | if flag == "TRUE" then
|
---|
| 297 | file.print <<EOT
|
---|
| 298 | cell tResource RES_SCHEDULER {
|
---|
| 299 | property = "STANDARD";
|
---|
| 300 | };
|
---|
| 301 | EOT
|
---|
| 302 | else
|
---|
| 303 | file.print <<EOT
|
---|
| 304 | EOT
|
---|
| 305 | end
|
---|
| 306 | end
|
---|
| 307 | }
|
---|
| 308 |
|
---|
| 309 | end
|
---|
| 310 |
|
---|
| 311 | end
|
---|
| 312 |
|
---|