Skip to content
Snippets Groups Projects
Commit 04117f03 authored by Tingwei Zhang's avatar Tingwei Zhang
Browse files

dcc_parser: Add dynamic loop offset support

Add a new option for DCC parser to configure loop offset.

Change-Id: Ia888cfaff2f0310463d59d3f63dc2b4904759269
parent d3fb4a90
Branches
No related tags found
No related merge requests found
# Copyright (c) 2015, 2017, The Linux Foundation. All rights reserved. # Copyright (c) 2015, 2017, 2019 The Linux Foundation. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 and # it under the terms of the GNU General Public License version 2 and
...@@ -22,6 +22,14 @@ count = 0 ...@@ -22,6 +22,14 @@ count = 0
address = [] address = []
data = [] data = []
def bm(msb, lsb):
'Creates a bitmask from msb to lsb'
return int(('1' * (msb - lsb + 1)) + ('0' * lsb), 2)
def bvalsel(msb, lsb, val):
'Masks and returns the bits from msb to lsb in val'
return ((val & bm(msb, lsb)) >> lsb)
def log_init(name, path, filename): def log_init(name, path, filename):
# Set up logger # Set up logger
...@@ -95,6 +103,11 @@ def read_config(config_pt): ...@@ -95,6 +103,11 @@ def read_config(config_pt):
if options.config_offset is not None: if options.config_offset is not None:
config_pt.seek(int(options.config_offset, 16), 1) config_pt.seek(int(options.config_offset, 16), 1)
if options.config_loopoffset is not None:
config_loopoffset = int(options.config_loopoffset)
else:
config_loopoffset = 13
while True: while True:
word = config_pt.read(4) word = config_pt.read(4)
if len(word) != 4: if len(word) != 4:
...@@ -131,8 +144,8 @@ def read_config(config_pt): ...@@ -131,8 +144,8 @@ def read_config(config_pt):
else: else:
offset = 0 offset = 0
elif descriptor == loop_descriptor: elif descriptor == loop_descriptor:
loop_offset = val & 0x1FFF loop_offset = val & bm(config_loopoffset, 0)
loop_count = (val & 0xFFFE000) >> 13 loop_count = bvalsel(27, config_loopoffset, val)
if loop_offset == 0: if loop_offset == 0:
continue continue
...@@ -228,6 +241,8 @@ if __name__ == '__main__': ...@@ -228,6 +241,8 @@ if __name__ == '__main__':
help='DCC driver version 2') help='DCC driver version 2')
parser.add_option('--config-offset', dest='config_offset', parser.add_option('--config-offset', dest='config_offset',
help='Start offset for DCC configuration') help='Start offset for DCC configuration')
parser.add_option('--config-loopoffset', dest='config_loopoffset',
help='Offset of loop value')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment