Ignore:
Timestamp:
Jul 3, 2020, 7:19:17 PM (4 years ago)
Author:
coas-nagasima
Message:

ASP3, TINET, mbed を更新

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/asp3_dcre/kernel/genoffset.trb

    r321 r429  
    11# -*- coding: utf-8 -*-
     2#
     3#   TOPPERS Software
     4#       Toyohashi Open Platform for Embedded Real-Time Systems
    25#
    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
    87#               Graduate School of Information Science, Nagoya Univ., JAPAN
    98
     
    3736#   の責任を負わない.
    3837#
    39 #   $Id$
     38#   $Id: genoffset.trb 936 2018-04-07 09:46:42Z ertl-hiro $
    4039#
    4140
     
    4443#
    4544
    46 # 
     45#
    4746#  タイムスタンプファイルの指定
    48 # 
     47#
    4948$timeStampFileName = "offset.timestamp"
    5049
    51 # 
     50#
    5251#  offset.hの先頭部分の生成
    53 # 
     52#
    5453$offsetH = GenFile.new("offset.h")
    5554$offsetH.add2("/* offset.h */")
    5655
    57 #
    58 #  #defineディレクティブの生成
    59 #
    60 def GenerateDefine(symbol, value)
    61   $offsetH.add("#define #{symbol}\t#{value}")
    62 end
    63 
    64 #
     56#
    6557#  ビットのサーチ
    66 # 
     58#
    6759def SearchBit(val)
    6860  (0..7).each do |valBit|
     
    7466end
    7567
    76 # 
    77 #  ビットフィールドのオフセットとビット位置の定義の生成
    78 # 
    79 def GenerateDefineBit(label, structSize, outputSize)
     68#
     69#  ビットフィールドのオフセットとビット位置の算出
     70#
     71def BitOffsetPosition(label, structSize, outputSize)
    8072  top = SYMBOL(label)
    8173  if top.nil?
     
    9688      error_exit("bit not found in `#{label}'")
    9789    else
    98       valBit = SearchBit(val)
     90      position = SearchBit(val)
    9991      case outputSize
    100       when "W"
    101         if $SIL_ENDIAN_BIG
    102           valBit = valBit + 24 - ((offset & 0x03) << 3)
     92      when 4, "W"
     93        if $endianLittle
     94          position = position + ((offset & 0x03) << 3)
    10395        else
    104           valBit = valBit + ((offset & 0x03) << 3)
     96          position = position + 24 - ((offset & 0x03) << 3)
    10597        end
    10698        offset &= ~0x03
    107       when "H"
    108         if $SIL_ENDIAN_BIG
    109           valBit = valBit + 8 - ((offset & 0x01) << 3)
     99      when 2, "H"
     100        if $endianLittle
     101          position = position + ((offset & 0x01) << 3)
    110102        else
    111           valBit = valBit + ((offset & 0x01) << 3)
     103          position = position + 8 - ((offset & 0x01) << 3)
    112104        end
    113105        offset &= ~0x01
    114106      end
    115107    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
    120109  end
    121110end
    122111
    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#
     117def GenerateDefine(symbol, value)
     118  $offsetH.add("#define #{symbol}\t#{value}")
     119end
     120
     121#
     122#  ビットフィールドのオフセットとビット位置の定義の生成
     123#
     124def 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))
    142130  end
    143131end
    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.