[Tools] Automatically pad CFGDATA regions to 4 byte boundary. (#1688)
CFGDATA regions (each CFG tag) needs to be 4-byte aligned since this CFGDATA header field uses the low two bytes of the length for ConditionNum. Without this change, unaligned CFG region yaml files will cause a build error and need to be manually padded. This change adds a field "__reserved" to each CFG structure that requires padding. Signed-off-by: Bejean Mosher <bejean.mosher@intel.com> Signed-off-by: Bejean Mosher <bejean.mosher@intel.com>
This commit is contained in:
parent
7fcab220ed
commit
02a186200e
|
@ -559,6 +559,7 @@ class DefTemplate(string.Template):
|
|||
|
||||
class CGenCfgData:
|
||||
STRUCT = '$STRUCT'
|
||||
PADDINGNAME = '__reserved'
|
||||
bits_width = {'b':1, 'B':8, 'W':16, 'D':32, 'Q':64}
|
||||
builtin_option = {'$EN_DIS' : [('0', 'Disable'), ('1', 'Enable')]}
|
||||
exclude_struct = ['GPIO_GPP_*', 'GPIO_CFG_DATA', 'GpioConfPad*', 'GpioPinConfig',
|
||||
|
@ -1270,7 +1271,17 @@ class CGenCfgData:
|
|||
struct_node['length'] = info['offset'] - start
|
||||
if struct_node['length'] % 8 != 0:
|
||||
raise SystemExit("Error: Bits length not aligned for %s !" % str(path))
|
||||
|
||||
# Ensure Cfg struct is 4-byte aligned
|
||||
if 'CfgHeader' in top and (struct_node['length']//8)%4:
|
||||
padding = 4 - (struct_node['length']//8)%4
|
||||
pad_bytes = OrderedDict({})
|
||||
pad_bytes['length'] = str(padding)
|
||||
pad_bytes['value'] = str(0)
|
||||
top[CGenCfgData.PADDINGNAME] = pad_bytes
|
||||
path.append(CGenCfgData.PADDINGNAME)
|
||||
self.build_cfg_list(CGenCfgData.PADDINGNAME,pad_bytes,path,info)
|
||||
path.pop()
|
||||
struct_node['length'] = info['offset'] - start
|
||||
|
||||
def get_field_value (self, top = None):
|
||||
def _get_field_value (name, cfgs, level):
|
||||
|
|
Loading…
Reference in New Issue