BaseTools: Update SkuId as SKU_ID type to follow current implementation

Update PCD DB and Default setting format as nature alignment.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
Liming Gao 2017-12-20 17:16:28 +08:00
parent 47854fd598
commit 7e6e459a3d
2 changed files with 29 additions and 22 deletions

View File

@ -176,7 +176,8 @@ typedef struct {
//GUID Signature; // PcdDataBaseGuid
//UINT32 BuildVersion;
//UINT32 Length;
//SKU_ID SystemSkuId; // Current SkuId value.
//SKU_ID SystemSkuId; // Current SkuId value.
//UINT32 LengthForAllSkus; // Length of all SKU PCD DB
//UINT32 UninitDataBaseSize;// Total size for PCD those default value with 0.
//TABLE_OFFSET LocalTokenNumberTableOffset;
//TABLE_OFFSET ExMapTableOffset;
@ -188,7 +189,7 @@ typedef struct {
//UINT16 LocalTokenCount; // LOCAL_TOKEN_NUMBER for all
//UINT16 ExTokenCount; // EX_TOKEN_NUMBER for DynamicEx
//UINT16 GuidTableCount; // The Number of Guid in GuidTable
//UINT8 Pad[2];
//UINT8 Pad[6];
${PHASE}_PCD_DATABASE_INIT Init;
${PHASE}_PCD_DATABASE_UNINIT Uninit;
} ${PHASE}_PCD_DATABASE;
@ -767,7 +768,7 @@ def BuildExDataBase(Dict):
# VardefValueBoolean is the last table in the init table items
InitTableNum = DbNameTotle.index("VardefValueBoolean") + 1
# The FixedHeader length of the PCD_DATABASE_INIT, from Signature to Pad
FixedHeaderLen = 76
FixedHeaderLen = 80
# Get offset of SkuId table in the database
SkuIdTableOffset = FixedHeaderLen
@ -924,10 +925,11 @@ def BuildExDataBase(Dict):
Buffer += b
b = pack('=B', Pad)
Buffer += b
b = pack('=B', Pad)
Buffer += b
Buffer += b
Buffer += b
Buffer += b
Buffer += b
Index = 0
@ -991,9 +993,13 @@ def CreatePcdDataBase(PcdDBData):
databasebuff = PcdDBData[("DEFAULT","0")][0]
for skuname,skuid in delta:
databasebuff += pack('=H', int(skuid))
databasebuff += pack('=H', 0)
databasebuff += pack('=L', 8+4*len(delta[(skuname,skuid)]))
# 8 byte align
if len(databasebuff) % 8 > 0:
for i in range(8 - (len(databasebuff) % 8)):
databasebuff += pack("=B",0)
databasebuff += pack('=Q', int(skuid))
databasebuff += pack('=Q', 0)
databasebuff += pack('=L', 8+8+4+4*len(delta[(skuname,skuid)]))
for item in delta[(skuname,skuid)]:
databasebuff += pack("=L",item[0])
databasebuff = databasebuff[:-1] + pack("=B",item[1])

View File

@ -69,7 +69,7 @@ class VariableMgr(object):
def PatchNVStoreDefaultMaxSize(self,maxsize):
if not self.NVHeaderBuff:
return ""
self.NVHeaderBuff = self.NVHeaderBuff[:8] + pack("=L",maxsize)
self.NVHeaderBuff = self.NVHeaderBuff[:8] + pack("=Q",maxsize)
default_var_bin = self.format_data(self.NVHeaderBuff + self.VarDefaultBuff + self.VarDeltaBuff)
value_str = "{"
default_var_bin_strip = [ data.strip("""'""") for data in default_var_bin]
@ -166,7 +166,7 @@ class VariableMgr(object):
variable_storage_header_buffer = self.PACK_VARIABLE_STORE_HEADER(len(NvStoreDataBuffer) + 28)
nv_default_part = self.AlignData(self.PACK_DEFAULT_DATA(0, 0, self.unpack_data(variable_storage_header_buffer+NvStoreDataBuffer)))
nv_default_part = self.AlignData(self.PACK_DEFAULT_DATA(0, 0, self.unpack_data(variable_storage_header_buffer+NvStoreDataBuffer)), 8)
data_delta_structure_buffer = ""
for skuname,defaultstore in var_data:
@ -180,9 +180,9 @@ class VariableMgr(object):
delta_data = [(item[0] + offset, item[1]) for item in delta_data]
delta_data_set.extend(delta_data)
data_delta_structure_buffer += self.AlignData(self.PACK_DELTA_DATA(skuname,defaultstore,delta_data_set))
data_delta_structure_buffer += self.AlignData(self.PACK_DELTA_DATA(skuname,defaultstore,delta_data_set), 8)
size = len(nv_default_part + data_delta_structure_buffer) + 12
size = len(nv_default_part + data_delta_structure_buffer) + 16
maxsize = self.VpdRegionSize if self.VpdRegionSize else size
NV_Store_Default_Header = self.PACK_NV_STORE_DEFAULT_HEADER(size,maxsize)
@ -243,7 +243,7 @@ class VariableMgr(object):
Signature += pack("=B",ord('B'))
SizeBuffer = pack("=L",size)
MaxSizeBuffer = pack("=L",maxsize)
MaxSizeBuffer = pack("=Q",maxsize)
return Signature + SizeBuffer + MaxSizeBuffer
@ -292,9 +292,9 @@ class VariableMgr(object):
def PACK_DEFAULT_DATA(self, defaultstoragename,skuid,var_value):
Buffer = ""
Buffer += pack("=L",8)
Buffer += pack("=H",int(defaultstoragename))
Buffer += pack("=H",int(skuid))
Buffer += pack("=L",4+8+8)
Buffer += pack("=Q",int(skuid))
Buffer += pack("=Q",int(defaultstoragename))
for item in var_value:
Buffer += pack("=B",item)
@ -315,9 +315,9 @@ class VariableMgr(object):
skuid = self.GetSkuId(skuname)
defaultstorageid = self.GetDefaultStoreId(defaultstoragename)
Buffer = ""
Buffer += pack("=L",8)
Buffer += pack("=H",int(skuid))
Buffer += pack("=H",int(defaultstorageid))
Buffer += pack("=L",4+8+8)
Buffer += pack("=Q",int(skuid))
Buffer += pack("=Q",int(defaultstorageid))
for (delta_offset,value) in delta_list:
Buffer += pack("=L",delta_offset)
Buffer = Buffer[:-1] + pack("=B",value)
@ -328,8 +328,9 @@ class VariableMgr(object):
def AlignData(self,data, align = 4):
mybuffer = data
for i in range(len(data) % align):
mybuffer += pack("=B",0)
if (len(data) % align) > 0:
for i in range(align - (len(data) % align)):
mybuffer += pack("=B",0)
return mybuffer