Add support for variable cell width in ConfigEditor
Current ConfigEditor only supports UINT8 format cell in table. This patch added support for variable cell width including UINT8, UINT16, UINT32 in table widget. Test configuration items were also added in QEMU to test these format. Signed-off-by: Maurice Ma <maurice.ma@intel.com>
This commit is contained in:
parent
d313c9c5fc
commit
e2d1d73684
|
@ -23,7 +23,7 @@ else:
|
||||||
import tkMessageBox as messagebox
|
import tkMessageBox as messagebox
|
||||||
import tkFileDialog as filedialog
|
import tkFileDialog as filedialog
|
||||||
|
|
||||||
from GenCfgData import CGenCfgData, Bytes2Str, Bytes2Val, Array2Val
|
from GenCfgData import CGenCfgData, Bytes2Str, Bytes2Val, Val2Bytes, Array2Val
|
||||||
|
|
||||||
class CreateToolTip(object):
|
class CreateToolTip(object):
|
||||||
'''
|
'''
|
||||||
|
@ -70,8 +70,11 @@ class CreateToolTip(object):
|
||||||
|
|
||||||
|
|
||||||
class ValidatingEntry(Entry):
|
class ValidatingEntry(Entry):
|
||||||
|
_Padding = 2
|
||||||
|
_CharWidth = 1
|
||||||
|
|
||||||
def __init__(self, master, value="", **kw):
|
def __init__(self, master, value="", **kw):
|
||||||
apply(Entry.__init__, (self, master), kw)
|
Entry.__init__(*(self, master), **kw)
|
||||||
self.Value = value
|
self.Value = value
|
||||||
self.Variable = StringVar()
|
self.Variable = StringVar()
|
||||||
self.Variable.set(value)
|
self.Variable.set(value)
|
||||||
|
@ -79,6 +82,17 @@ class ValidatingEntry(Entry):
|
||||||
self.config(textvariable=self.Variable)
|
self.config(textvariable=self.Variable)
|
||||||
self.bind("<FocusOut>", self.FocusOut)
|
self.bind("<FocusOut>", self.FocusOut)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def ToCellWidth (ByteLen):
|
||||||
|
return ByteLen * 2 * ValidatingEntry._CharWidth + ValidatingEntry._Padding
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def ToByteLen (CellWidth):
|
||||||
|
return (CellWidth - ValidatingEntry._Padding) // (ValidatingEntry._CharWidth * 2)
|
||||||
|
|
||||||
|
def GetByteLen (self):
|
||||||
|
return ValidatingEntry.ToByteLen (self['width'])
|
||||||
|
|
||||||
def FocusOut(self, Event):
|
def FocusOut(self, Event):
|
||||||
Value = self.Variable.get()
|
Value = self.Variable.get()
|
||||||
if len(Value) == 0:
|
if len(Value) == 0:
|
||||||
|
@ -103,8 +117,9 @@ class ValidatingEntry(Entry):
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if len(Value) > 2:
|
MaxLen = self.GetByteLen() * 2
|
||||||
return None
|
if len(Value) > MaxLen:
|
||||||
|
Value = Value[:MaxLen]
|
||||||
|
|
||||||
return Value.upper()
|
return Value.upper()
|
||||||
|
|
||||||
|
@ -134,12 +149,12 @@ class CustomTable(Frame):
|
||||||
for Col in range(Cols): #Columns
|
for Col in range(Cols): #Columns
|
||||||
if Idx >= len(Bins):
|
if Idx >= len(Bins):
|
||||||
break
|
break
|
||||||
Hex = "%02X" % Bins[Idx]
|
ByteLen = int(ColHdr[Col].split(':')[1])
|
||||||
ValidatingEntry(self, width=4,
|
Value = Bytes2Val (Bins[Idx:Idx+ByteLen])
|
||||||
justify=CENTER,
|
Hex = ("%%0%dX" % (ByteLen * 2) ) % Value
|
||||||
value=Hex).grid(row=Row + RowAdj,
|
ValidatingEntry(self, width=ValidatingEntry.ToCellWidth(ByteLen),
|
||||||
column=Col + ColAdj)
|
justify=CENTER, value=Hex).grid(row=Row + RowAdj, column=Col + ColAdj)
|
||||||
Idx += 1
|
Idx += ByteLen
|
||||||
if Idx >= len(Bins):
|
if Idx >= len(Bins):
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -148,10 +163,12 @@ class CustomTable(Frame):
|
||||||
for Widget in self.winfo_children():
|
for Widget in self.winfo_children():
|
||||||
if not isinstance(Widget, ValidatingEntry):
|
if not isinstance(Widget, ValidatingEntry):
|
||||||
continue
|
continue
|
||||||
|
ByteLen = Widget.GetByteLen ()
|
||||||
Hex = Widget.get()
|
Hex = Widget.get()
|
||||||
if not Hex:
|
if not Hex:
|
||||||
break
|
break
|
||||||
Bins.append(int(Hex, 16) & 0xff)
|
Values = Val2Bytes (int(Hex, 16) & ((1 << ByteLen * 8) - 1), ByteLen)
|
||||||
|
Bins.extend(Values)
|
||||||
return Bins
|
return Bins
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
|
|
|
@ -446,6 +446,9 @@ EndList
|
||||||
DataList = self.ValueToList(ConfigDict['value'], ConfigDict['length'])
|
DataList = self.ValueToList(ConfigDict['value'], ConfigDict['length'])
|
||||||
Unit = int(Struct[4:]) // 8
|
Unit = int(Struct[4:]) // 8
|
||||||
if int(ConfigDict['length']) != Unit * len(DataList):
|
if int(ConfigDict['length']) != Unit * len(DataList):
|
||||||
|
# Fallback to byte array
|
||||||
|
Unit = 1
|
||||||
|
if int(ConfigDict['length']) != len(DataList):
|
||||||
raise Exception("Array size is not proper for '%s' !" % ConfigDict['cname'])
|
raise Exception("Array size is not proper for '%s' !" % ConfigDict['cname'])
|
||||||
|
|
||||||
ByteArray = []
|
ByteArray = []
|
||||||
|
|
|
@ -141,10 +141,25 @@
|
||||||
# !BSF HELP:{Silicon Test 1}
|
# !BSF HELP:{Silicon Test 1}
|
||||||
gCfgData.SiliconTest1 | * | 0x04 | 0x11223347
|
gCfgData.SiliconTest1 | * | 0x04 | 0x11223347
|
||||||
|
|
||||||
# !BSF NAME:{Silicon Test 9}
|
# !BSF NAME:{Silicon Test 2}
|
||||||
# !BSF TYPE:{EditNum, HEX, (0x00000000,0xFFFFFFFF)}
|
# !BSF TYPE:{Table}
|
||||||
# !BSF HELP:{Silicon Test 9}
|
# !BSF OPTION:{ 0:1:HEX, 1:1:HEX, 2:1:HEX, 3:1:HEX}
|
||||||
gCfgData.SiliconTest2 | * | 0x04 | 0x11223348
|
# !BSF HELP:{Silicon Test 2 to show BYTE table configuration}
|
||||||
|
gCfgData.SiliconTest2 | * | 0x04 | 0x04030201
|
||||||
|
|
||||||
|
# !BSF NAME:{Silicon Test 3}
|
||||||
|
# !BSF TYPE:{Table}
|
||||||
|
# !BSF OPTION:{ 0:2:HEX, 1:2:HEX}
|
||||||
|
# !BSF HELP:{Silicon Test 3 to show UINT16 table configuration}
|
||||||
|
# !HDR STRUCT:{UINT16}
|
||||||
|
gCfgData.SiliconTest3 | * | 0x08 | {0x1111, 0x2222, 0x3333, 0x4444}
|
||||||
|
|
||||||
|
# !BSF NAME:{Silicon Test 4}
|
||||||
|
# !BSF TYPE:{Table}
|
||||||
|
# !BSF OPTION:{ 0:4:HEX, 1:4:HEX}
|
||||||
|
# !BSF HELP:{Silicon Test 4 to show UINT32 table configuration}
|
||||||
|
# !HDR STRUCT:{UINT32}
|
||||||
|
gCfgData.SiliconTest4 | * | 0x08 | {0x11112222, 0x33334444}
|
||||||
# !HDR EMBED:{SILICON_CFG_DATA:TAG_200:END}
|
# !HDR EMBED:{SILICON_CFG_DATA:TAG_200:END}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue