Changeset 429 for EcnlProtoTool/trunk/asp3_dcre/kernel/genoffset.trb
- Timestamp:
- Jul 3, 2020, 7:19:17 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/kernel/genoffset.trb
r321 r429 1 1 # -*- coding: utf-8 -*- 2 # 3 # TOPPERS Software 4 # Toyohashi Open Platform for Embedded Real-Time Systems 2 5 # 3 # TOPPERS/ASP Kernel 4 # Toyohashi Open Platform for Embedded Real-Time Systems/ 5 # Advanced Standard Profile Kernel 6 # 7 # Copyright (C) 2011-2016 by Embedded and Real-Time Systems Laboratory 6 # Copyright (C) 2011-2018 by Embedded and Real-Time Systems Laboratory 8 7 # Graduate School of Information Science, Nagoya Univ., JAPAN 9 8 # … … 37 36 # の責任を負わない. 38 37 # 39 # $Id $38 # $Id: genoffset.trb 936 2018-04-07 09:46:42Z ertl-hiro $ 40 39 # 41 40 … … 44 43 # 45 44 46 # 45 # 47 46 # タイムスタンプファイルの指定 48 # 47 # 49 48 $timeStampFileName = "offset.timestamp" 50 49 51 # 50 # 52 51 # offset.hの先頭部分の生成 53 # 52 # 54 53 $offsetH = GenFile.new("offset.h") 55 54 $offsetH.add2("/* offset.h */") 56 55 57 # 58 # #defineディレクティブの生成 59 # 60 def GenerateDefine(symbol, value) 61 $offsetH.add("#define #{symbol}\t#{value}") 62 end 63 64 # 56 # 65 57 # ビットのサーチ 66 # 58 # 67 59 def SearchBit(val) 68 60 (0..7).each do |valBit| … … 74 66 end 75 67 76 # 77 # ビットフィールドのオフセットとビット位置の 定義の生成78 # 79 def GenerateDefineBit(label, structSize, outputSize)68 # 69 # ビットフィールドのオフセットとビット位置の算出 70 # 71 def BitOffsetPosition(label, structSize, outputSize) 80 72 top = SYMBOL(label) 81 73 if top.nil? … … 96 88 error_exit("bit not found in `#{label}'") 97 89 else 98 valBit= SearchBit(val)90 position = SearchBit(val) 99 91 case outputSize 100 when "W"101 if $ SIL_ENDIAN_BIG102 valBit = valBit + 24 -((offset & 0x03) << 3)92 when 4, "W" 93 if $endianLittle 94 position = position + ((offset & 0x03) << 3) 103 95 else 104 valBit = valBit +((offset & 0x03) << 3)96 position = position + 24 - ((offset & 0x03) << 3) 105 97 end 106 98 offset &= ~0x03 107 when "H"108 if $ SIL_ENDIAN_BIG109 valBit = valBit + 8 -((offset & 0x01) << 3)99 when 2, "H" 100 if $endianLittle 101 position = position + ((offset & 0x01) << 3) 110 102 else 111 valBit = valBit +((offset & 0x01) << 3)103 position = position + 8 - ((offset & 0x01) << 3) 112 104 end 113 105 offset &= ~0x01 114 106 end 115 107 end 116 117 $offsetH.add("#define #{label}\t#{offset}") 118 $offsetH.add("#define #{label}_bit\t#{valBit}") 119 $offsetH.add("#define #{label}_mask\t#{sprintf("0x%x", 1 << valBit)}") 108 return offset, position 120 109 end 121 110 end 122 111 123 # 124 # バイト配置のチェック 125 # 126 def magicCheck(size, check) 127 label = "MAGIC_#{size}" 128 top = SYMBOL(label) 129 if top.nil? 130 error_exit("label `#{label}' not found") 131 else 132 1.upto(size).each do |offset| 133 if $SIL_ENDIAN_BIG 134 val = PEEK(top + offset - 1, 1) 135 else 136 val = PEEK(top + size - offset, 1) 137 end 138 if val != check.at(offset - 1) 139 error_exit("value check of `#{label}' failed") 140 end 141 end 112 # 以下の定義は,過去のバージョンとの互換性のために残している. 113 114 # 115 # #defineディレクティブの生成 116 # 117 def GenerateDefine(symbol, value) 118 $offsetH.add("#define #{symbol}\t#{value}") 119 end 120 121 # 122 # ビットフィールドのオフセットとビット位置の定義の生成 123 # 124 def GenerateDefineBit(label, structSize, outputSize) 125 offset, position = BitOffsetPosition(label, structSize, outputSize) 126 if !offset.nil? 127 GenerateDefine(label, offset) 128 GenerateDefine("#{label}_bit", position) 129 GenerateDefine("#{label}_mask", sprintf("0x%x", 1 << position)) 142 130 end 143 131 end 144 145 magicCheck(1, [ 0x12 ])146 magicCheck(2, [ 0x12, 0x34 ])147 magicCheck(4, [ 0x12, 0x34, 0x56, 0x78 ])
Note:
See TracChangeset
for help on using the changeset viewer.