Date   

Re: [PATCH v4 1/6] OvmfPkg/TPM: Import PeiDxeTpmPlatformHierarchyLib.c from edk2-platforms

Sean
 

Thanks for the link as i missed that message.

To me this just points out more problems with how OVMF is being managed in the edk2 project and the uselessness of edk2 platforms as anything more than just a dumping ground repo to hold sample code. But that is a problem larger than this patchset.

I guess if you are going doing option 2 can we rename the library interface you are defining in OvmfPkg so it doesn't conflict with the existing one in edk2-platforms/minplatform. That would mean change:

* name in OvmfPkg.dec file
* header file in OvmfPkg/Include/Library
* all references in DSC file for mapping an instance
* all references in your INFs for dependency

Thanks
Sean

On 8/12/2021 3:19 PM, Stefan Berger wrote:
On 8/12/21 4:59 PM, Sean Brogan wrote:
This seems like a bad place for a general purpose lib that many other platforms may take a dependency on.

In v1 this was SecurityPkg.  OvmfPkg is a platform package and therefore not a good place to define broad interfaces.

What caused this to move here?
Option 2 from this message: https://listman.redhat.com/archives/edk2-devel-archive/2021-August/msg00398.html   Stefan


Thanks
Sean


Re: [Patch 2/2] BaseTools: a new build option for variable default value generation

Sean
 

Bob,

Given this is a new feature that needs a lot of review and discussion can it get moved over to the edk2-basetools project. Since the Python Basetools RFC was accepted months ago and the CI system updated to use those artifacts (instead of the source), that is where Basetools/Source/Python should be enhanced going forward.



A few other comments.

There are some common types in python already supported (EfiTime, Variables, authenticated variables) here:

https://github.com/tianocore/edk2-pytool-library/blob/5b2dbd7b315743caa626c1a4657c642d491ea8c3/edk2toollib/uefi/authenticated_variables_structure_support.py

https://github.com/tianocore/edk2-pytool-library/blob/5b2dbd7b315743caa626c1a4657c642d491ea8c3/edk2toollib/uefi/edk2/variable_format.py

I also don't understand the reason for all this in ctypes and basically writing c-code in python. We have found that developing in native python and then at the point of binary serialization converting to/from a binary layout is a much better experience.

Thanks
Sean

On 8/13/2021 4:45 AM, Bob Feng wrote:
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3562
Create a new build option to enable vfrcompile to generate Json
format EFI variable information file and read it to generate
the EFI variable default value binary file.
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
---
BaseTools/Source/Python/AutoGen/DataPipe.py | 2 +
.../Source/Python/AutoGen/GenDefaultVar.py | 498 ++++++++++++++++++
.../Source/Python/AutoGen/ModuleAutoGen.py | 9 +
.../Python/AutoGen/ModuleAutoGenHelper.py | 4 +
BaseTools/Source/Python/Common/GlobalData.py | 5 +
BaseTools/Source/Python/build/build.py | 18 +
BaseTools/Source/Python/build/buildoptions.py | 1 +
7 files changed, 537 insertions(+)
create mode 100644 BaseTools/Source/Python/AutoGen/GenDefaultVar.py
diff --git a/BaseTools/Source/Python/AutoGen/DataPipe.py b/BaseTools/Source/Python/AutoGen/DataPipe.py
index 86ac2b928d9c..fa0c36b98f21 100755
--- a/BaseTools/Source/Python/AutoGen/DataPipe.py
+++ b/BaseTools/Source/Python/AutoGen/DataPipe.py
@@ -165,5 +165,7 @@ class MemoryDataPipe(DataPipe):
self.DataContainer = {"BinCacheSource":GlobalData.gBinCacheSource}
self.DataContainer = {"BinCacheDest":GlobalData.gBinCacheDest}
self.DataContainer = {"EnableGenfdsMultiThread":GlobalData.gEnableGenfdsMultiThread}
+
+ self.DataContainer = {"GenDefaultVarBin": GlobalData.gGenDefaultVarBin}
diff --git a/BaseTools/Source/Python/AutoGen/GenDefaultVar.py b/BaseTools/Source/Python/AutoGen/GenDefaultVar.py
new file mode 100644
index 000000000000..b82cce18ed26
--- /dev/null
+++ b/BaseTools/Source/Python/AutoGen/GenDefaultVar.py
@@ -0,0 +1,498 @@
+import json
+from ctypes import *
+import re
+import copy
+from struct import unpack
+import os
+
+class GUID(Structure):
+ _fields_ = [
+ ('Guid1', c_uint32),
+ ('Guid2', c_uint16),
+ ('Guid3', c_uint16),
+ ('Guid4', ARRAY(c_uint8, 8)),
+ ]
+
+ def from_list(self, listformat):
+ self.Guid1 = listformat[0]
+ self.Guid2 = listformat[1]
+ self.Guid3 = listformat[2]
+ for i in range(8):
+ self.Guid4[i] = listformat[i+3]
+
+ def __cmp__(self, otherguid):
+ if isinstance(otherguid, GUID):
+ return 1
+ rt = False
+ if self.Guid1 == otherguid.Guid1 and self.Guid2 == otherguid.Guid2 and self.Guid3 == otherguid.Guid3:
+ rt = True
+ for i in range(8):
+ rt = rt & (self.Guid4[i] == otherguid.Guid4[i])
+ return rt
+
+
+class TIME(Structure):
+ _fields_ = [
+ ('Year', c_uint16),
+ ('Month', c_uint8),
+ ('Day', c_uint8),
+ ('Hour', c_uint8),
+ ('Minute', c_uint8),
+ ('Second', c_uint8),
+ ('Pad1', c_uint8),
+ ('Nanosecond', c_uint32),
+ ('TimeZone', c_uint16),
+ ('Daylight', c_uint8),
+ ('Pad2', c_uint8),
+ ]
+ def __init__(self):
+ self.Year = 0x0
+ self.Month = 0x0
+ self.Day = 0x0
+ self.Hour = 0x0
+ self.Minute = 0x0
+ self.Second = 0x0
+ self.Pad1 = 0x0
+ self.Nanosecond = 0x0
+ self.TimeZone = 0x0
+ self.Daylight = 0x0
+ self.Pad2 = 0x0
+
+
+EFI_VARIABLE_GUID = [0xddcf3616, 0x3275, 0x4164,
+ 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d]
+EFI_AUTHENTICATED_VARIABLE_GUID = [
+ 0xaaf32c78, 0x947b, 0x439a, 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92]
+
+AuthVarGuid = GUID()
+AuthVarGuid.from_list(EFI_AUTHENTICATED_VARIABLE_GUID)
+VarGuid = GUID()
+VarGuid.from_list(EFI_VARIABLE_GUID)
+
+# Variable Store Header Format.
+VARIABLE_STORE_FORMATTED = 0x5a
+# Variable Store Header State.
+VARIABLE_STORE_HEALTHY = 0xfe
+
+
+class VARIABLE_STORE_HEADER(Structure):
+ _fields_ = [
+ ('Signature', GUID),
+ ('Size', c_uint32),
+ ('Format', c_uint8),
+ ('State', c_uint8),
+ ('Reserved', c_uint16),
+ ('Reserved1', c_uint32),
+ ]
+
+
+# Variable data start flag.
+VARIABLE_DATA = 0x55AA
+
+# Variable State flags.
+VAR_IN_DELETED_TRANSITION = 0xfe
+VAR_DELETED = 0xfd
+VAR_HEADER_VALID_ONLY = 0x7f
+VAR_ADDED = 0x3f
+
+
+class VARIABLE_HEADER(Structure):
+ _fields_ = [
+ ('StartId', c_uint16),
+ ('State', c_uint8),
+ ('Reserved', c_uint8),
+ ('Attributes', c_uint32),
+ ('NameSize', c_uint32),
+ ('DataSize', c_uint32),
+ ('VendorGuid', GUID),
+ ]
+
+
+class AUTHENTICATED_VARIABLE_HEADER(Structure):
+ _fields_ = [
+ ('StartId', c_uint16),
+ ('State', c_uint8),
+ ('Reserved', c_uint8),
+ ('Attributes', c_uint32),
+ ('MonotonicCount', c_uint64),
+ ('TimeStamp', TIME),
+ ('PubKeyIndex', c_uint32),
+ ('NameSize', c_uint32),
+ ('DataSize', c_uint32),
+ ('VendorGuid', GUID),
+ ]
+ _pack_ = 1
+
+
+# Alignment of Variable Data Header in Variable Store region.
+HEADER_ALIGNMENT = 4
+
+
+class DEFAULT_INFO(Structure):
+ _fields_ = [
+ ('DefaultId', c_uint16),
+ ('BoardId', c_uint16),
+ ]
+
+
+class DEFAULT_DATA(Structure):
+ _fields_ = [
+ ('HeaderSize', c_uint16),
+ ('DefaultInfo', DEFAULT_INFO),
+ ]
+
+class DELTA_DATA(Structure):
+ _fields_ = [
+ ('Offset', c_uint16),
+ ('Value', c_uint8),
+ ]
+ _pack_ = 1
+
+array_re = re.compile(
+ "(?P<mType>[a-z_A-Z][a-z_A-Z0-9]*)\[(?P<mSize>[1-9][0-9]*)\]")
+
+
+class VarField():
+ def __init__(self):
+ self.Offset = 0
+ self.Value = 0
+ self.Size = 0
+
+ @property
+ def Type(self):
+ if self.Size == 1:
+ return "UINT8"
+ if self.Size == 2:
+ return "UINT16"
+ if self.Size == 4:
+ return "UINT32"
+ if self.Size == 8:
+ return "UINT64"
+
+ return "UINT8"
+
+
+BASIC_TYPE = {
+ "BOOLEAN": 1,
+ "UINT8": 1,
+ "UINT16": 2,
+ "UINT32": 4,
+ "UINT64": 8
+}
+class CStruct():
+
+
+ def __init__(self, typedefs):
+ self.TypeDefs = typedefs
+ self.TypeStack = copy.deepcopy(typedefs)
+ self.finalDefs = {}
+
+ def CalStuctSize(self, sType):
+ rt = 0
+ if sType in BASIC_TYPE:
+ return BASIC_TYPE[sType]
+
+ ma = array_re.match(sType)
+ if ma:
+ mType = ma.group('mType')
+ mSize = ma.group('mSize')
+ rt += int(mSize) * self.CalStuctSize(mType)
+ else:
+ for subType in self.TypeDefs[sType]:
+ rt += self.CalStuctSize(subType['Type'])
+
+ return rt
+
+ def expend(self, fielditem):
+ fieldname = fielditem['Name']
+ fieldType = fielditem['Type']
+ fieldOffset = fielditem['Offset']
+
+ ma = array_re.match(fieldType)
+ if ma:
+ mType = ma.group('mType')
+ mSize = ma.group('mSize')
+ return [{"Name": "%s[%d]" % (fieldname, i), "Type": mType, "Offset": (fieldOffset + i*self.CalStuctSize(mType))} for i in range(int(mSize))]
+ else:
+ return [{"Name": "%s.%s" % (fieldname, item['Name']), "Type":item['Type'], "Offset": (fieldOffset + item['Offset'])} for item in self.TypeDefs[fielditem['Type']]]
+
+ def ExpandTypes(self):
+ if not self.finalDefs:
+ for datatype in self.TypeStack:
+ result = []
+ mTypeStack = self.TypeStack[datatype]
+ while len(mTypeStack) > 0:
+ item = mTypeStack.pop()
+ if item['Type'] in self.BASIC_TYPE:
+ result.append(item)
+ elif item['Type'] == '(null)':
+ continue
+ else:
+ for expand_item in self.expend(item):
+ mTypeStack.append(expand_item)
+ self.finalDefs[datatype] = result
+ self.finalDefs
+ return self.finalDefs
+
+def Get_Occupied_Size(FileLength, alignment):
+ if FileLength % alignment == 0:
+ return FileLength
+ return FileLength + (alignment-(FileLength % alignment))
+
+def Occupied_Size(buffer, alignment):
+ FileLength = len(buffer)
+ if FileLength % alignment != 0:
+ buffer += b'\0' * (alignment-(FileLength % alignment))
+ return buffer
+
+def PackStruct(cStruct):
+ length = sizeof(cStruct)
+ p = cast(pointer(cStruct), POINTER(c_char * length))
+ return p.contents.raw
+
+def calculate_delta(default, theother):
+
+ if len(default) - len(theother) != 0:
+ return []
+
+ data_delta = []
+ for i in range(len(default)):
+ if default[i] != theother[i]:
+ data_delta.append([i, theother[i]])
+ return data_delta
+
+class Variable():
+ def __init__(self):
+ self.mAlign = 1
+ self.mTotalSize = 1
+ self.mValue = {} # {defaultstore: value}
+ self.mBin = {}
+ self.fields = {} # {defaultstore: fileds}
+ self.delta = {}
+ self.attributes = 0
+ self.mType = ''
+ self.guid = ''
+ self.mName = ''
+ self.cDefs = None
+
+ @property
+ def GuidArray(self):
+
+ guid_array = []
+ guid = self.guid.strip().strip("{").strip("}")
+ for item in guid.split(","):
+ field = item.strip().strip("{").strip("}")
+ guid_array.append(int(field,16))
+ return guid_array
+
+ def update_delta_offset(self,base):
+ for default_id in self.delta:
+ for delta_list in self.delta[default_id]:
+ delta_list[0] += base
+
+ def pack(self):
+
+ for defaultid in self.mValue:
+ var_value = self.mValue[defaultid]
+ auth_var = AUTHENTICATED_VARIABLE_HEADER()
+ auth_var.StartId = VARIABLE_DATA
+ auth_var.State = VAR_ADDED
+ auth_var.Reserved = 0x00
+ auth_var.Attributes = 0x00000007
+ auth_var.MonotonicCount = 0x0
+ auth_var.TimeStamp = TIME()
+ auth_var.PubKeyIndex = 0x0
+ var_name_buffer = self.mName.encode('utf-16le') + b'\0\0'
+ auth_var.NameSize = len(var_name_buffer)
+ auth_var.DataSize = len(var_value)
+ vendor_guid = GUID()
+ vendor_guid.from_list(self.GuidArray)
+ auth_var.VendorGuid = vendor_guid
+
+ self.mBin[defaultid] = PackStruct(auth_var) + Occupied_Size(var_name_buffer + var_value, 4)
+
+ def TypeCheck(self,data_type, data_size):
+ if BASIC_TYPE[data_type] == data_size:
+ return True
+ return False
+
+ def ValueToBytes(self,data_type,data_value,data_size):
+
+ rt = b''
+ if not self.TypeCheck(data_type, data_size):
+ print(data_type,data_value,data_size)
+
+ if data_type == "BOOLEAN" or data_type == 'UINT8':
+ p = cast(pointer(c_uint8(int(data_value,16))), POINTER(c_char * 1))
+ rt = p.contents.raw
+ elif data_type == 'UINT16':
+ p = cast(pointer(c_uint16(int(data_value,16))), POINTER(c_char * 2))
+ rt = p.contents.raw
+ elif data_type == 'UINT32':
+ p = cast(pointer(c_uint32(int(data_value,16))), POINTER(c_char * 4))
+ rt = p.contents.raw
+ elif data_type == 'UINT64':
+ p = cast(pointer(c_uint64(int(data_value,16))), POINTER(c_char * 8))
+ rt = p.contents.raw
+
+ return rt
+
+ def serial(self):
+ for defaultstore in self.fields:
+ vValue = b''
+ vfields = {vf.Offset: vf for vf in self.fields[defaultstore]}
+ i = 0
+ while i < self.mTotalSize:
+ if i in vfields:
+ vfield = vfields[i]
+ vValue += self.ValueToBytes(vfield.Type, vfield.Value,vfield.Size)
+ i += vfield.Size
+ else:
+ vValue += self.ValueToBytes('UINT8','0x00',1)
+ i += 1
+
+ self.mValue[defaultstore] = vValue
+ standard_default = self.mValue[0]
+
+ for defaultid in self.mValue:
+ if defaultid == 0:
+ continue
+ others_default = self.mValue[defaultid]
+
+ self.delta.setdefault(defaultid, []).extend(calculate_delta(
+ standard_default, others_default))
+
+class DefaultVariableGenerator():
+ def __init__(self):
+ self.NvVarInfo = []
+
+ def LoadNvVariableInfo(self, VarInfoFilelist):
+
+ VarDataDict = {}
+ DataStruct = {}
+ VarDefine = {}
+ VarAttributes = {}
+ for VarInfoFile in VarInfoFilelist:
+ with open(VarInfoFile.strip(), "r") as fd:
+ data = json.load(fd)
+
+ DataStruct.update(data.get("DataStruct", {}))
+ Data = data.get("Data")
+ VarDefine.update(data.get("VarDefine"))
+ VarAttributes.update(data.get("DataStructAttribute"))
+
+ for vardata in Data:
+ if vardata['VendorGuid'] == 'NA':
+ continue
+ VarDataDict.setdefault(
+ (vardata['VendorGuid'], vardata["VarName"]), []).append(vardata)
+
+ cStructDefs = CStruct(DataStruct)
+ for guid, varname in VarDataDict:
+ v = Variable()
+ v.guid = guid
+ vardef = VarDefine.get(varname)
+ if vardef is None:
+ for var in VarDefine:
+ if VarDefine[var]['Type'] == varname:
+ vardef = VarDefine[var]
+ break
+ else:
+ continue
+ v.attributes = vardef['Attributes']
+ v.mType = vardef['Type']
+ v.mAlign = VarAttributes[v.mType]['Alignment']
+ v.mTotalSize = VarAttributes[v.mType]['TotalSize']
+ v.Struct = DataStruct[v.mType]
+ v.mName = varname
+ v.cDefs = cStructDefs
+ for fieldinfo in VarDataDict.get((guid, varname), []):
+ vf = VarField()
+ vf.Offset = fieldinfo['Offset']
+ vf.Value = fieldinfo['Value']
+ vf.Size = fieldinfo['Size']
+ v.fields.setdefault(
+ int(fieldinfo['DefaultStore'], 10), []).append(vf)
+ v.serial()
+ v.pack()
+ self.NvVarInfo.append(v)
+
+ def PackDeltaData(self):
+
+ default_id_set = set()
+ for v in self.NvVarInfo:
+ default_id_set |= set(v.mBin.keys())
+
+ if default_id_set:
+ default_id_set.remove(0)
+ delta_buff_set = {}
+ for defaultid in default_id_set:
+ delta_buff = b''
+ for v in self.NvVarInfo:
+ delta_list = v.delta.get(defaultid,[])
+ for delta in delta_list:
+ delta_data = DELTA_DATA()
+ delta_data.Offset, delta_data.Value = delta
+ delta_buff += PackStruct(delta_data)
+ delta_buff_set[defaultid] = delta_buff
+
+ return delta_buff_set
+
+ def PackDefaultData(self):
+
+ default_data_header = DEFAULT_DATA()
+ default_data_header.HeaderSize = sizeof(DEFAULT_DATA)
+ default_data_header.DefaultInfo.DefaultId = 0x0
+ default_data_header.DefaultInfo.BoardId = 0x0
+ default_data_header_buffer = PackStruct(default_data_header)
+
+
+ variable_store = VARIABLE_STORE_HEADER()
+ variable_store.Signature = AuthVarGuid
+
+ variable_store_size = Get_Occupied_Size(sizeof(DEFAULT_DATA) + sizeof(VARIABLE_STORE_HEADER), 4)
+ for v in self.NvVarInfo:
+ variable_store_size += Get_Occupied_Size(len(v.mBin[0]), 4)
+
+ variable_store.Size = variable_store_size
+ variable_store.Format = VARIABLE_STORE_FORMATTED
+ variable_store.State = VARIABLE_STORE_HEALTHY
+ variable_store.Reserved = 0x0
+ variable_store.Reserved2 = 0x0
+
+ variable_storage_header_buffer = PackStruct(variable_store)
+
+ variable_data = b''
+ v_offset = 0
+ for v in self.NvVarInfo:
+ v.update_delta_offset(v_offset)
+ variable_data += Occupied_Size(v.mBin[0],4)
+ v_offset += Get_Occupied_Size(len(v.mBin[0]),4)
+
+
+ final_buff = Occupied_Size(default_data_header_buffer + variable_storage_header_buffer,4) + variable_data
+
+ return final_buff
+
+ def generate(self, jsonlistfile,output_folder):
+ if not os.path.exists(jsonlistfile):
+ return
+ if not os.path.exists(output_folder):
+ os.makedirs(output_folder)
+ try:
+ with open(jsonlistfile,"r") as fd:
+ filelist = fd.readlines()
+ genVar = DefaultVariableGenerator()
+ genVar.LoadNvVariableInfo(filelist)
+ with open(os.path.join(output_folder, "default.bin"), "wb") as fd:
+ fd.write(genVar.PackDefaultData())
+
+ delta_set = genVar.PackDeltaData()
+ for default_id in delta_set:
+ with open(os.path.join(output_folder, "defaultdelta_%s.bin" % default_id), "wb") as fd:
+ fd.write(delta_set[default_id])
+ except:
+ print("generate varbin file failed")
+
+
+
diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
index d70b0d7ae828..0daf3352f91b 100755
--- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
@@ -433,10 +433,19 @@ class ModuleAutoGen(AutoGen):
## Return the directory to store auto-gened source files of the module
@cached_property
def DebugDir(self):
return _MakeDir((self.BuildDir, "DEBUG"))
+
+ @cached_property
+ def DefaultVarJsonFiles(self):
+ rt = []
+ for SrcFile in self.SourceFileList:
+ if SrcFile.Ext.lower() == '.vfr':
+ rt.append(os.path.join(self.DebugDir,os.path.join(os.path.dirname(SrcFile.File), "{}_var.json".format(SrcFile.BaseName))))
+ return rt
+
## Return the path of custom file
@cached_property
def CustomMakefile(self):
RetVal = {}
for Type in self.Module.CustomMakefile:
diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
index 036fdac3d7df..b46d041f58ab 100644
--- a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
+++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
@@ -644,10 +644,14 @@ class PlatformInfo(AutoGenInfo):
if Attr != 'PATH':
BuildOptions[ExpandedTool][Attr] += " " + mws.handleWsMacro(Value)
else:
BuildOptions[ExpandedTool][Attr] = mws.handleWsMacro(Value)
+ if self.DataPipe.Get("GenDefaultVarBin"):
+ if BuildOptions.get('VFR',{}).get('FLAGS'):
+ BuildOptions['VFR']['FLAGS'] += " " + "--variable"
+
return BuildOptions, BuildRuleOrder
def ApplyLibraryInstance(self,module):
alldeps = self.DataPipe.Get("DEPS")
if alldeps is None:
diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py
index 61ab3f7e24cd..c68ca8fbb3f7 100755
--- a/BaseTools/Source/Python/Common/GlobalData.py
+++ b/BaseTools/Source/Python/Common/GlobalData.py
@@ -88,10 +88,15 @@ gIgnoreSource = False
#
gFdfParser = None
BuildOptionPcd = []
+#
+# Build flag for generate default variable binary file
+#
+gGenDefaultVarBin = False
+
#
# Mixed PCD name dict
#
MixedPcd = {}
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 02b489892422..2f6fc6b20faf 100755
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -750,10 +750,11 @@ class Build():
GlobalData.gUseHashCache = BuildOptions.UseHashCache
GlobalData.gBinCacheDest = BuildOptions.BinCacheDest
GlobalData.gBinCacheSource = BuildOptions.BinCacheSource
GlobalData.gEnableGenfdsMultiThread = not BuildOptions.NoGenfdsMultiThread
GlobalData.gDisableIncludePathCheck = BuildOptions.DisableIncludePathCheck
+ GlobalData.gGenDefaultVarBin = BuildOptions.GenDefaultVarBin
if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache:
EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData="--binary-destination must be used together with --hash.")
if GlobalData.gBinCacheSource and not GlobalData.gUseHashCache:
@@ -1459,10 +1460,14 @@ class Build():
self.BuildModules = []
return True
# genfds
if Target == 'fds':
+ if GlobalData.gGenDefaultVarBin:
+ from AutoGen.GenDefaultVar import DefaultVariableGenerator
+ variable_info_filelist = os.path.join(AutoGenObject.BuildDir,"variable_info_filelist.txt")
+ DefaultVariableGenerator().generate(variable_info_filelist,AutoGenObject.FvDir)
if GenFdsApi(AutoGenObject.GenFdsCommandDict, self.Db):
EdkLogger.error("build", COMMAND_FAILURE)
Threshold = self.GetFreeSizeThreshold()
if Threshold:
self.CheckFreeSizeThreshold(Threshold, AutoGenObject.FvDir)
@@ -2247,10 +2252,19 @@ class Build():
AutoGenIdFile = os.path.join(GlobalData.gConfDirectory,".AutoGenIdFile.txt")
with open(AutoGenIdFile,"w") as fw:
fw.write("Arch=%s\n" % "|".join((Wa.ArchList)))
fw.write("BuildDir=%s\n" % Wa.BuildDir)
fw.write("PlatformGuid=%s\n" % str(Wa.AutoGenObjectList[0].Guid))
+ variable_info_filelist = os.path.join(Wa.BuildDir,"variable_info_filelist.txt")
+ vfr_var_json = []
+ if GlobalData.gGenDefaultVarBin:
+ for ma in self.AllModules:
+ vfr_var_json.extend(ma.DefaultVarJsonFiles)
+ SaveFileOnChange(variable_info_filelist, "\n".join(vfr_var_json), False)
+ else:
+ if os.path.exists(variable_info_filelist):
+ os.remove(variable_info_filelist)
if GlobalData.gBinCacheSource:
BuildModules.extend(self.MakeCacheMiss)
elif GlobalData.gUseHashCache and not GlobalData.gBinCacheDest:
BuildModules.extend(self.PreMakeCacheMiss)
@@ -2359,10 +2373,14 @@ class Build():
if self.Fdf:
#
# Generate FD image if there's a FDF file found
#
+ if GlobalData.gGenDefaultVarBin:
+ from AutoGen.GenDefaultVar import DefaultVariableGenerator
+ variable_info_filelist = os.path.join(Wa.BuildDir,"variable_info_filelist.txt")
+ DefaultVariableGenerator().generate(variable_info_filelist,Wa.FvDir)
GenFdsStart = time.time()
if GenFdsApi(Wa.GenFdsCommandDict, self.Db):
EdkLogger.error("build", COMMAND_FAILURE)
Threshold = self.GetFreeSizeThreshold()
if Threshold:
diff --git a/BaseTools/Source/Python/build/buildoptions.py b/BaseTools/Source/Python/build/buildoptions.py
index 39d92cff209d..6886ba7f8eb6 100644
--- a/BaseTools/Source/Python/build/buildoptions.py
+++ b/BaseTools/Source/Python/build/buildoptions.py
@@ -99,7 +99,8 @@ class MyOptionParser():
Parser.add_option("--hash", action="store_true", dest="UseHashCache", default=False, help="Enable hash-based caching during build process.")
Parser.add_option("--binary-destination", action="store", type="string", dest="BinCacheDest", help="Generate a cache of binary files in the specified directory.")
Parser.add_option("--binary-source", action="store", type="string", dest="BinCacheSource", help="Consume a cache of binary files from the specified directory.")
Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=True, help="Enable GenFds multi thread to generate ffs file.")
Parser.add_option("--no-genfds-multi-thread", action="store_true", dest="NoGenfdsMultiThread", default=False, help="Disable GenFds multi thread to generate ffs file.")
+ Parser.add_option("--gen-default-variable-bin", action="store_true", dest="GenDefaultVarBin", default=False, help="Generate default variable binary file.")
Parser.add_option("--disable-include-path-check", action="store_true", dest="DisableIncludePathCheck", default=False, help="Disable the include path check for outside of package.")
self.BuildOption, self.BuildTarget = Parser.parse_args()


Re: [edk2-platforms][PATCH v2] BoardModulePkg/BoardBdsHookLib: Register UiApp as boot option

Benjamin Doron
 

Actually, mBootMenuOptionNumber could be left alone for this patch, so it would be best to keep the patches separate: get UiApp working, then cleanup BootManagerMenuApp.


Re: [edk2-platforms][PATCH v2] BoardModulePkg/BoardBdsHookLib: Register UiApp as boot option

Benjamin Doron
 

Hi Nate,
Sure, I can do that. The UiApp boot option can then also be marked hidden.

Also, because of the way this patch would change hotkey handling, I'll drop https://edk2.groups.io/g/devel/topic/84671368.

Regards,
Benjamin


[PATCH v1 1/2] ShellPkg: Update Acpiview PCCT parser to ACPI 6.4

Chris Jones
 

Bugzilla: 3563 (https://bugzilla.tianocore.org/show_bug.cgi?id=3563)

Update the Acpiview PCCT parser to use Acpi64.h.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
---
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c | 46 ++++++++++----------
ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c | 4 +-
2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
index ca553d5953f05651d8df4c95d1e39a73eded5129..7d3a2dd10dc928265bad3711e929d96c1ed40b1d 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
@@ -1,11 +1,11 @@
/** @file
PCCT table parser

- Copyright (c) 2020, Arm Limited.
+ Copyright (c) 2021, Arm Limited.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
- - ACPI 6.3 Specification - January 2019
+ - ACPI 6.4 Specification - January 2021
**/

#include <Library/BaseMemoryLib.h>
@@ -93,9 +93,9 @@ ValidatePccType0Gas (
{
switch (*(UINT8*)Ptr) {
#if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
- case EFI_ACPI_6_3_SYSTEM_IO:
+ case EFI_ACPI_6_4_SYSTEM_IO:
#endif //if not (defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
- case EFI_ACPI_6_3_SYSTEM_MEMORY:
+ case EFI_ACPI_6_4_SYSTEM_MEMORY:
return;
default:
IncrementErrorCount ();
@@ -120,10 +120,10 @@ ValidatePccGas (
{
switch (*(UINT8*)Ptr) {
#if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
- case EFI_ACPI_6_3_SYSTEM_IO:
+ case EFI_ACPI_6_4_SYSTEM_IO:
#endif //if not (defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
- case EFI_ACPI_6_3_FUNCTIONAL_FIXED_HARDWARE:
- case EFI_ACPI_6_3_SYSTEM_MEMORY:
+ case EFI_ACPI_6_4_FUNCTIONAL_FIXED_HARDWARE:
+ case EFI_ACPI_6_4_SYSTEM_MEMORY:
return;
default:
IncrementErrorCount ();
@@ -148,10 +148,10 @@ ValidatePccDoorbellGas (
{
// For slave subspaces this field is optional, if not present the field
// should just contain zeros.
- if (*PccSubspaceType == EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) {
+ if (*PccSubspaceType == EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) {
if (IsZeroBuffer (
Ptr,
- sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE)
+ sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE)
)) {
return;
}
@@ -180,14 +180,14 @@ ValidatePccIntAckGas (
// edge driven the register may be omitted. A value of 0x0 on all
// 12 bytes of the GAS structure indicates the register is not
// present.
- if (((*PccGlobalFlags & EFI_ACPI_6_3_PCCT_FLAGS_PLATFORM_INTERRUPT) !=
- EFI_ACPI_6_3_PCCT_FLAGS_PLATFORM_INTERRUPT) ||
+ if (((*PccGlobalFlags & EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) !=
+ EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) ||
((*ExtendedPccSubspaceInterruptFlags &
- EFI_ACPI_6_3_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE) ==
- EFI_ACPI_6_3_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE)) {
+ EFI_ACPI_6_4_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE) ==
+ EFI_ACPI_6_4_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE)) {
if (IsZeroBuffer (
Ptr,
- sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE)
+ sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE)
)) {
return;
}
@@ -212,7 +212,7 @@ ValidatePccErrStatusGas (
)
{
// This field is ignored by the OSPM on slave channels.
- if (*PccSubspaceType == EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) {
+ if (*PccSubspaceType == EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) {
return;
}

@@ -236,9 +236,9 @@ ValidatePlatInterrupt (
{
// If a slave subspace is present in the PCCT, then the global Platform
// Interrupt flag must be set to 1.
- if ((*PccSubspaceType == EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) &&
- ((*PccGlobalFlags & EFI_ACPI_6_3_PCCT_FLAGS_PLATFORM_INTERRUPT) !=
- EFI_ACPI_6_3_PCCT_FLAGS_PLATFORM_INTERRUPT)) {
+ if ((*PccSubspaceType == EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) &&
+ ((*PccGlobalFlags & EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) !=
+ EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT)) {
IncrementErrorCount ();
Print (
L"\nError: Global Platform interrupt flag must be set to 1" \
@@ -563,31 +563,31 @@ ParseAcpiPcct (
}

switch (*PccSubspaceType) {
- case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_GENERIC:
+ case EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_GENERIC:
DumpPccSubspaceType0 (
PccSubspacePtr,
*PccSubspaceLength
);
break;
- case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_1_HW_REDUCED_COMMUNICATIONS:
+ case EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_1_HW_REDUCED_COMMUNICATIONS:
DumpPccSubspaceType1 (
PccSubspacePtr,
*PccSubspaceLength
);
break;
- case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_2_HW_REDUCED_COMMUNICATIONS:
+ case EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_2_HW_REDUCED_COMMUNICATIONS:
DumpPccSubspaceType2 (
PccSubspacePtr,
*PccSubspaceLength
);
break;
- case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_3_EXTENDED_PCC:
+ case EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_3_EXTENDED_PCC:
DumpPccSubspaceType3 (
PccSubspacePtr,
*PccSubspaceLength
);
break;
- case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC:
+ case EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC:
DumpPccSubspaceType4 (
PccSubspacePtr,
*PccSubspaceLength
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index b30ed3fc8597b229dd15b6ad4f2aab2e3d0ca583..c81e5220272ae94448203ee02ea5caacb606842c 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -1,7 +1,7 @@
/** @file
Main file for 'acpiview' Shell command function.

- Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.<BR>
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

@@ -60,7 +60,7 @@ ACPI_TABLE_PARSER ParserList[] = {
{EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiMadt},
{EFI_ACPI_6_2_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE,
ParseAcpiMcfg},
- {EFI_ACPI_6_2_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE,
+ {EFI_ACPI_6_4_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE,
ParseAcpiPcct},
{EFI_ACPI_6_2_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE,
ParseAcpiPptt},
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")


[PATCH v1 2/2] ShellPkg: Add Type 5 PCC Subspace Structure parser

Chris Jones
 

Bugzilla: 3563 (https://bugzilla.tianocore.org/show_bug.cgi?id=3563)

Update the Acpiview PCCT parser with the HW Registers based
Communications Subspace Structure (Type 5) as defined in Section 14.1.7
of the ACPI 6.4 specification.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
---
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c | 58 +++++++++++++++++++-
1 file changed, 55 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
index 7d3a2dd10dc928265bad3711e929d96c1ed40b1d..6beee70b23a3b32992efa0edac48fe236591b9f5 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
@@ -77,7 +77,7 @@ ValidateRangeLength8 (
}

/**
- This function validates address space for type 0 structure.
+ This function validates address space for Memory/IO GAS.

@param [in] Ptr Pointer to the start of the field data.
@param [in] Context Pointer to context specific information e.g. this
@@ -86,7 +86,7 @@ ValidateRangeLength8 (
STATIC
VOID
EFIAPI
-ValidatePccType0Gas (
+ValidatePccMemoryIoGas (
IN UINT8* Ptr,
IN VOID* Context
)
@@ -274,7 +274,7 @@ STATIC CONST ACPI_PARSER PccSubspaceType0Parser[] = {
{L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL},
{L"Memory Range Length", 8, 16, L"0x%lx", NULL, NULL, ValidateRangeLength8,
NULL},
- {L"Doorbell Register", 12, 24, NULL, DumpGas, NULL, ValidatePccType0Gas,
+ {L"Doorbell Register", 12, 24, NULL, DumpGas, NULL, ValidatePccMemoryIoGas,
NULL},
{L"Doorbell Preserve", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL},
{L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL},
@@ -367,6 +367,29 @@ STATIC CONST ACPI_PARSER PccSubspaceType3Parser[] = {
{L"Error Status Mask", 8, 156, L"0x%lx", NULL, NULL, NULL, NULL},
};

+/**
+ An ACPI_PARSER array describing the HW Registers based Communications
+ Subspace Structure - Type 5
+*/
+STATIC CONST ACPI_PARSER PccSubspaceType5Parser[] = {
+ PCC_SUBSPACE_HEADER (),
+ {L"Version", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Base Address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL},
+ {L"Shared Memory Range Length", 8, 12, L"0x%lx", NULL, NULL, NULL, NULL},
+ {L"Doorbell Register", 12, 20, NULL, DumpGas, NULL,
+ ValidatePccMemoryIoGas, NULL},
+ {L"Doorbell Preserve", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL},
+ {L"Doorbell Write", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL},
+ {L"Command Complete Check Register", 12, 48, NULL, DumpGas, NULL,
+ ValidatePccMemoryIoGas, NULL},
+ {L"Command Complete Check Mask", 8, 60, L"0x%lx", NULL, NULL, NULL, NULL},
+ {L"Error Status Register", 12, 68, NULL, DumpGas, NULL,
+ ValidatePccMemoryIoGas, NULL},
+ {L"Error Status Mask", 8, 80, L"0x%lx", NULL, NULL, NULL, NULL},
+ {L"Nominal Latency", 4, 88, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Minimum Request Turnaround Time", 4, 92, L"0x%x", NULL, NULL, NULL, NULL}
+};
+
/**
This function parses the PCC Subspace type 0.

@@ -482,6 +505,29 @@ DumpPccSubspaceType4 (
);
}

+/**
+ This function parses the PCC Subspace type 5.
+
+ @param [in] Ptr Pointer to the start of the Subspace Structure.
+ @param [in] Length Length of the Subspace Structure.
+**/
+STATIC
+VOID
+DumpPccSubspaceType5 (
+ IN UINT8* Ptr,
+ IN UINT8 Length
+ )
+{
+ ParseAcpi (
+ TRUE,
+ 2,
+ "Subspace Type 5",
+ Ptr,
+ Length,
+ PARSER_PARAMS (PccSubspaceType5Parser)
+ );
+}
+
/**
This function parses the ACPI PCCT table including its sub-structures
of type 0 through 4.
@@ -593,6 +639,12 @@ ParseAcpiPcct (
*PccSubspaceLength
);
break;
+ case EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_5_HW_REGISTERS_COMMUNICATIONS:
+ DumpPccSubspaceType5 (
+ PccSubspacePtr,
+ *PccSubspaceLength
+ );
+ break;
default:
IncrementErrorCount ();
Print (
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")


[PATCH v1 0/2] Support ACPI 6.4 in Acpiview PCCT parser

Chris Jones
 

Bugzilla: 3563 (https://bugzilla.tianocore.org/show_bug.cgi?id=3563)

This patch series adds support for ACPI 6.4 to the Acpiview PCCT parser
by using Acpi64.h and adding parsing, validation and printing support
for the new 'Type 5' subspace structure.

The changes can be seen at: https://github.com/chris-jones-arm/edk2/tree/1825_64_acpi_pcct_update_v1

Chris Jones (2):
ShellPkg: Update Acpiview PCCT parser to ACPI 6.4
ShellPkg: Add Type 5 PCC Subspace Structure parser

.../Parsers/Pcct/PcctParser.c | 104 +++++++++++++-----
.../UefiShellAcpiViewCommandLib.c | 4 +-
2 files changed, 80 insertions(+), 28 deletions(-)

--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")


Re: SecCore evacuation in PeiCore?

Michael Kubacki
 

Hi Marvin,

I apologize for the delayed response, I missed this message earlier. The function was called from EvacuateTempRam() in the initial set of patches:
[PATCH 1/6] MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore (CVE-2019-11098) (groups.io) <https://edk2.groups.io/g/devel/message/61823>

I was not involved in the patch series on the mailing list (job role change at the time) but as a comment in that patch notes, there was an inconsistency observed in PE32 section alignment in SEC modules. I don't see where this was resolved other than the calls being removed later in the series. SecCore migration would not occur implicitly in the PeiCore flow but there is functionality for SEC data migration in UefiCpuPkg/SecMigrationPei.

Based on what I see now, I'd be happy to send a patch to remove MigrateSecModulesInFv().

Thanks,
Michael

On 8/7/2021 2:54 PM, Marvin Häuser wrote:
Good day everyone,
Good day Michael,

The commit that introduced T-RAM evacuation [1] also introduced the function "MigrateSecModulesInFv()". It also is explicitly mentioned as part of the control flow in the commit message. As far as I can see, since then till today this function has never been called anywhere. Was this some draft function that accidentally made it into the patch, or did the caller get lost somewhere? The description makes sense to me and I'm not experienced enough with the PeiCore control flow to tell whether the PEIM migration somehow covers SecCore implicitly. Also I noticed it only supports SecCore in a PE/COFF section, not a TE section. Is there a rationale for that?

Thank you for your time!

Best regards,
Marvin


[1] https://github.com/tianocore/edk2/commit/9bedaec05b7b8ba9aee248361bb61a85a26726cb



[edk2-libc Patch] StdLib/Include/sys/syslimits.h: Increase OPEN_MAX from 20 to 255

Michael D Kinney
 

From: Jayaprakash Nevara <n.jayaprakash@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3548

A port of Python 3.6.8 interpreter for UEFI uses the
standard C Library from the edk2-libc project. The python
interpreter fails with the following error when the
python interpreter is launched:

"IOError: [Errno 24] Too many open files"

Python 3.6.8 interpreter opens and loads many python modules
(files) when it is boot strapped and this is leading to the
too many open files error.

To fix the issue the OPEN_MAX limit value is increased from
20 to 255.

Cc: Daryl McDaniel <edk2-lists@mc2research.org>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Rebecca Cran <rebecca@nuviainc.com>
Signed-off-by: Jayaprakash Nevara <n.jayaprakash@intel.com>
---
StdLib/Include/sys/syslimits.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/StdLib/Include/sys/syslimits.h b/StdLib/Include/sys/syslimits.h
index 9515e8f..70ec619 100644
--- a/StdLib/Include/sys/syslimits.h
+++ b/StdLib/Include/sys/syslimits.h
@@ -53,7 +53,7 @@
#define MAX_OUTPUT 255 ///< Maximum bytes in terminal output.
#define NAME_MAX 255 ///< Maximum bytes in a file name.
#ifndef OPEN_MAX
- #define OPEN_MAX 20 ///< Maximum open files per process.
+ #define OPEN_MAX 255 ///< Maximum open files per process.
#endif
#define PATH_MAX 1024 ///< Maximum bytes in pathname.
#define PIPE_BUF 512 ///< Maximum bytes for atomic pipe writes.
--
2.32.0.windows.1


Re: [Patch 2/2] BaseTools: a new build option for variable default value generation

Andrew Fish
 



On Aug 13, 2021, at 4:45 AM, Bob Feng <bob.c.feng@...> wrote:

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3562

Create a new build option to enable vfrcompile to generate Json
format EFI variable information file and read it to generate
the EFI variable default value binary file.

Signed-off-by: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>
---
BaseTools/Source/Python/AutoGen/DataPipe.py   |   2 +
.../Source/Python/AutoGen/GenDefaultVar.py    | 498 ++++++++++++++++++
.../Source/Python/AutoGen/ModuleAutoGen.py    |   9 +
.../Python/AutoGen/ModuleAutoGenHelper.py     |   4 +
BaseTools/Source/Python/Common/GlobalData.py  |   5 +
BaseTools/Source/Python/build/build.py        |  18 +
BaseTools/Source/Python/build/buildoptions.py |   1 +
7 files changed, 537 insertions(+)
create mode 100644 BaseTools/Source/Python/AutoGen/GenDefaultVar.py

diff --git a/BaseTools/Source/Python/AutoGen/DataPipe.py b/BaseTools/Source/Python/AutoGen/DataPipe.py
index 86ac2b928d9c..fa0c36b98f21 100755
--- a/BaseTools/Source/Python/AutoGen/DataPipe.py
+++ b/BaseTools/Source/Python/AutoGen/DataPipe.py
@@ -165,5 +165,7 @@ class MemoryDataPipe(DataPipe):
        self.DataContainer = {"BinCacheSource":GlobalData.gBinCacheSource}

        self.DataContainer = {"BinCacheDest":GlobalData.gBinCacheDest}

        self.DataContainer = {"EnableGenfdsMultiThread":GlobalData.gEnableGenfdsMultiThread}
+
+        self.DataContainer = {"GenDefaultVarBin": GlobalData.gGenDefaultVarBin}
diff --git a/BaseTools/Source/Python/AutoGen/GenDefaultVar.py b/BaseTools/Source/Python/AutoGen/GenDefaultVar.py
new file mode 100644
index 000000000000..b82cce18ed26
--- /dev/null
+++ b/BaseTools/Source/Python/AutoGen/GenDefaultVar.py
@@ -0,0 +1,498 @@
+import json
+from ctypes import *
+import re
+import copy
+from struct import unpack
+import os
+
+class GUID(Structure):

We should use (LittleEndianStructure) vs. (Structure). Structure is the endian of the Host, and EFI is little endian. Same comment for all the ctype structs. LittleEndianStructure is like using < with struct.pack()/struct.unpack(). 

+    _fields_ = [
+        ('Guid1',            c_uint32),
+        ('Guid2',            c_uint16),
+        ('Guid3',            c_uint16),
+        ('Guid4',            ARRAY(c_uint8, 8)),
+    ]
+

I think it would be better to use the same field names as the EFI C structures. 

typedef struct {
UINT32 Data1;
UINT16 Data2;
UINT16 Data3;
UINT8 Data4[8];
} GUID

Longer term I think the BaseBools should have a GUID class that can be shared that abstracts things GUIDs. It should store GUIDs as Python uuid.UUID() or at least in the common string form, and have useful operations. 

I’ve got an example GUID class in my gdb patch set, but it also loads the GUID database and deals with C name, C GUID structure init form, and strings. But it feels like we could pull out a common lower level GUID class out of that. 

+    def from_list(self, listformat):
+        self.Guid1 = listformat[0]
+        self.Guid2 = listformat[1]
+        self.Guid3 = listformat[2]
+        for i in range(8):
+            self.Guid4[i] = listformat[i+3]
+
+    def __cmp__(self, otherguid):
+        if isinstance(otherguid, GUID):
+            return 1
+        rt = False
+        if self.Guid1 == otherguid.Guid1 and self.Guid2 == otherguid.Guid2 and self.Guid3 == otherguid.Guid3:
+            rt = True
+            for i in range(8):
+                rt = rt & (self.Guid4[i] == otherguid.Guid4[i])
+        return rt
+
+
+class TIME(Structure):
+    _fields_ = [
+        ('Year',             c_uint16),
+        ('Month',            c_uint8),
+        ('Day',              c_uint8),
+        ('Hour',             c_uint8),
+        ('Minute',           c_uint8),
+        ('Second',           c_uint8),
+        ('Pad1',             c_uint8),
+        ('Nanosecond',       c_uint32),
+        ('TimeZone',         c_uint16),
+        ('Daylight',         c_uint8),
+        ('Pad2',             c_uint8),
+    ]
+    def __init__(self):
+        self.Year = 0x0
+        self.Month = 0x0
+        self.Day = 0x0
+        self.Hour = 0x0
+        self.Minute = 0x0
+        self.Second = 0x0
+        self.Pad1 = 0x0
+        self.Nanosecond = 0x0
+        self.TimeZone = 0x0
+        self.Daylight = 0x0
+        self.Pad2 = 0x0
+
+
+EFI_VARIABLE_GUID = [0xddcf3616, 0x3275, 0x4164,
+                     0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d]
+EFI_AUTHENTICATED_VARIABLE_GUID = [
+    0xaaf32c78, 0x947b, 0x439a, 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92]
+
+AuthVarGuid = GUID()
+AuthVarGuid.from_list(EFI_AUTHENTICATED_VARIABLE_GUID)
+VarGuid = GUID()
+VarGuid.from_list(EFI_VARIABLE_GUID)
+
+# Variable Store Header Format.
+VARIABLE_STORE_FORMATTED = 0x5a
+# Variable Store Header State.
+VARIABLE_STORE_HEALTHY = 0xfe
+
+
+class VARIABLE_STORE_HEADER(Structure):
+    _fields_ = [
+        ('Signature',                GUID),
+        ('Size',                     c_uint32),
+        ('Format',                   c_uint8),
+        ('State',                    c_uint8),
+        ('Reserved',                 c_uint16),
+        ('Reserved1',                c_uint32),
+    ]
+
+
+# Variable data start flag.
+VARIABLE_DATA = 0x55AA
+
+# Variable State flags.
+VAR_IN_DELETED_TRANSITION = 0xfe
+VAR_DELETED = 0xfd
+VAR_HEADER_VALID_ONLY = 0x7f
+VAR_ADDED = 0x3f
+
+
+class VARIABLE_HEADER(Structure):
+    _fields_ = [
+        ('StartId',                  c_uint16),
+        ('State',                    c_uint8),
+        ('Reserved',                 c_uint8),
+        ('Attributes',               c_uint32),
+        ('NameSize',                 c_uint32),
+        ('DataSize',                 c_uint32),
+        ('VendorGuid',               GUID),
+    ]
+
+
+class AUTHENTICATED_VARIABLE_HEADER(Structure):
+    _fields_ = [
+        ('StartId',                  c_uint16),
+        ('State',                    c_uint8),
+        ('Reserved',                 c_uint8),
+        ('Attributes',               c_uint32),
+        ('MonotonicCount',           c_uint64),
+        ('TimeStamp',                TIME),
+        ('PubKeyIndex',              c_uint32),
+        ('NameSize',                 c_uint32),
+        ('DataSize',                 c_uint32),
+        ('VendorGuid',               GUID),
+    ]
+    _pack_ = 1
+
+
+# Alignment of Variable Data Header in Variable Store region.
+HEADER_ALIGNMENT = 4
+
+
+class DEFAULT_INFO(Structure):
+    _fields_ = [
+        ('DefaultId',                c_uint16),
+        ('BoardId',                  c_uint16),
+    ]
+
+
+class DEFAULT_DATA(Structure):
+    _fields_ = [
+        ('HeaderSize',               c_uint16),
+        ('DefaultInfo',              DEFAULT_INFO),
+    ]
+
+class DELTA_DATA(Structure):
+    _fields_ = [
+        ('Offset', c_uint16),
+        ('Value', c_uint8),
+    ]
+    _pack_ = 1
+
+array_re = re.compile(
+    "(?P<mType>[a-z_A-Z][a-z_A-Z0-9]*)\[(?P<mSize>[1-9][0-9]*)\]")
+
+
+class VarField():
+    def __init__(self):
+        self.Offset = 0
+        self.Value = 0
+        self.Size = 0
+
+    @property
+    def Type(self):
+        if self.Size == 1:
+            return "UINT8"
+        if self.Size == 2:
+            return "UINT16"
+        if self.Size == 4:
+            return "UINT32"
+        if self.Size == 8:
+            return "UINT64"
+
+        return "UINT8"
+
+
+BASIC_TYPE = {
+    "BOOLEAN": 1,
+    "UINT8": 1,
+    "UINT16": 2,
+    "UINT32": 4,
+    "UINT64": 8
+}

This might be more of a phase 2….

I think you made a lot of extra work by inventing your own type system. You should just convert to ctype as fast as you can. 

BASIC_TYPE = {
    "BOOLEAN": c_uint8,
    "UINT8": c_uint8,
    "UINT16": c_uint16,
    "UINT32": c_uint32,
    "UINT64": c_uint64
}

Then you can just sizeof() to get the size

FYI I wrote this ctype dumper in case it is useful debugging this code.  It picks off EFI_GUID so it can print it as a proper UUID using the GUID class I mentioned above, so basically a nicer print option. 

def ctype_to_str(ctype, indent='', hide_list=[]):
    '''
    Given a ctype object print out as a string by walking the _fields_
    in the cstring Class
     '''
    result = ''
    for field in ctype._fields_:
        attr = getattr(ctype, field[0])
        tname = type(attr).__name__
        if field[0] in hide_list:
            continue

        result += indent + f'{field[0]} = '
        if tname == 'EFI_GUID':
            result += GuidNames.to_name(GuidNames.to_uuid(attr)) + '\n'
        elif issubclass(type(attr), Structure):
            result += f'{tname}\n' + \
                ctype_to_str(attr, indent + '  ', hide_list)
        elif isinstance(attr, int):
            result += f'0x{attr:x}\n'
        else:
            result += f'{attr}\n'

    return result

Thanks,

Andrew Fish

+class CStruct():
+
+
+    def __init__(self, typedefs):
+        self.TypeDefs = typedefs
+        self.TypeStack = copy.deepcopy(typedefs)
+        self.finalDefs = {}
+
+    def CalStuctSize(self, sType):
+        rt = 0
+        if sType in BASIC_TYPE:
+            return BASIC_TYPE[sType]
+
+        ma = array_re.match(sType)
+        if ma:
+            mType = ma.group('mType')
+            mSize = ma.group('mSize')
+            rt += int(mSize) * self.CalStuctSize(mType)
+        else:
+            for subType in self.TypeDefs[sType]:
+                rt += self.CalStuctSize(subType['Type'])
+
+        return rt
+
+    def expend(self, fielditem):
+        fieldname = fielditem['Name']
+        fieldType = fielditem['Type']
+        fieldOffset = fielditem['Offset']
+
+        ma = array_re.match(fieldType)
+        if ma:
+            mType = ma.group('mType')
+            mSize = ma.group('mSize')
+            return [{"Name": "%s[%d]" % (fieldname, i), "Type": mType, "Offset": (fieldOffset + i*self.CalStuctSize(mType))} for i in range(int(mSize))]
+        else:
+            return [{"Name": "%s.%s" % (fieldname, item['Name']), "Type":item['Type'], "Offset": (fieldOffset + item['Offset'])} for item in self.TypeDefs[fielditem['Type']]]
+
+    def ExpandTypes(self):
+        if not self.finalDefs:
+            for datatype in self.TypeStack:
+                result = []
+                mTypeStack = self.TypeStack[datatype]
+                while len(mTypeStack) > 0:
+                    item = mTypeStack.pop()
+                    if item['Type'] in self.BASIC_TYPE:
+                        result.append(item)
+                    elif item['Type'] == '(null)':
+                        continue
+                    else:
+                        for expand_item in self.expend(item):
+                            mTypeStack.append(expand_item)
+                self.finalDefs[datatype] = result
+            self.finalDefs
+        return self.finalDefs
+
+def Get_Occupied_Size(FileLength, alignment):
+    if FileLength % alignment == 0:
+        return FileLength
+    return FileLength + (alignment-(FileLength % alignment))
+
+def Occupied_Size(buffer, alignment):
+    FileLength = len(buffer)
+    if FileLength % alignment != 0:
+        buffer += b'\0' * (alignment-(FileLength % alignment))
+    return buffer
+
+def PackStruct(cStruct):
+    length = sizeof(cStruct)
+    p = cast(pointer(cStruct), POINTER(c_char * length))
+    return p.contents.raw
+
+def calculate_delta(default, theother):
+
+    if len(default) - len(theother) != 0:
+        return []
+
+    data_delta = []
+    for i in range(len(default)):
+        if default[i] != theother[i]:
+            data_delta.append([i, theother[i]])
+    return data_delta
+
+class Variable():
+    def __init__(self):
+        self.mAlign = 1
+        self.mTotalSize = 1
+        self.mValue = {}  # {defaultstore: value}
+        self.mBin = {}
+        self.fields = {}  # {defaultstore: fileds}
+        self.delta = {}
+        self.attributes = 0
+        self.mType = ''
+        self.guid = ''
+        self.mName = ''
+        self.cDefs = None
+
+    @property
+    def GuidArray(self):
+
+        guid_array = []
+        guid = self.guid.strip().strip("{").strip("}")
+        for item in guid.split(","):
+            field = item.strip().strip("{").strip("}")
+            guid_array.append(int(field,16))
+        return guid_array
+
+    def update_delta_offset(self,base):
+        for default_id in self.delta:
+            for delta_list in self.delta[default_id]:
+                delta_list[0] += base
+
+    def pack(self):
+
+        for defaultid in self.mValue:
+            var_value = self.mValue[defaultid]
+            auth_var = AUTHENTICATED_VARIABLE_HEADER()
+            auth_var.StartId = VARIABLE_DATA
+            auth_var.State = VAR_ADDED
+            auth_var.Reserved = 0x00
+            auth_var.Attributes = 0x00000007
+            auth_var.MonotonicCount = 0x0
+            auth_var.TimeStamp = TIME()
+            auth_var.PubKeyIndex = 0x0
+            var_name_buffer = self.mName.encode('utf-16le') + b'\0\0'
+            auth_var.NameSize = len(var_name_buffer)
+            auth_var.DataSize = len(var_value)
+            vendor_guid = GUID()
+            vendor_guid.from_list(self.GuidArray)
+            auth_var.VendorGuid = vendor_guid
+
+            self.mBin[defaultid] = PackStruct(auth_var) + Occupied_Size(var_name_buffer + var_value, 4)
+
+    def TypeCheck(self,data_type, data_size):
+        if BASIC_TYPE[data_type] == data_size:
+            return True
+        return False
+
+    def ValueToBytes(self,data_type,data_value,data_size):
+
+        rt = b''
+        if not self.TypeCheck(data_type, data_size):
+            print(data_type,data_value,data_size)
+
+        if data_type == "BOOLEAN" or data_type == 'UINT8':
+            p = cast(pointer(c_uint8(int(data_value,16))), POINTER(c_char * 1))
+            rt = p.contents.raw
+        elif data_type == 'UINT16':
+            p = cast(pointer(c_uint16(int(data_value,16))), POINTER(c_char * 2))
+            rt = p.contents.raw
+        elif data_type == 'UINT32':
+            p = cast(pointer(c_uint32(int(data_value,16))), POINTER(c_char * 4))
+            rt = p.contents.raw
+        elif data_type == 'UINT64':
+            p = cast(pointer(c_uint64(int(data_value,16))), POINTER(c_char * 8))
+            rt = p.contents.raw
+
+        return rt
+
+    def serial(self):
+        for defaultstore in self.fields:
+            vValue = b''
+            vfields = {vf.Offset: vf for vf in self.fields[defaultstore]}
+            i = 0
+            while i < self.mTotalSize:
+                if i in vfields:
+                    vfield = vfields[i]
+                    vValue += self.ValueToBytes(vfield.Type, vfield.Value,vfield.Size)
+                    i += vfield.Size
+                else:
+                    vValue += self.ValueToBytes('UINT8','0x00',1)
+                    i += 1
+
+            self.mValue[defaultstore] = vValue
+        standard_default = self.mValue[0]
+
+        for defaultid in self.mValue:
+            if defaultid == 0:
+                continue
+            others_default = self.mValue[defaultid]
+
+            self.delta.setdefault(defaultid, []).extend(calculate_delta(
+                standard_default, others_default))
+
+class DefaultVariableGenerator():
+    def __init__(self):
+        self.NvVarInfo = []
+
+    def LoadNvVariableInfo(self, VarInfoFilelist):
+
+        VarDataDict = {}
+        DataStruct = {}
+        VarDefine = {}
+        VarAttributes = {}
+        for VarInfoFile in VarInfoFilelist:
+            with open(VarInfoFile.strip(), "r") as fd:
+                data = json.load(fd)
+
+            DataStruct.update(data.get("DataStruct", {}))
+            Data = data.get("Data")
+            VarDefine.update(data.get("VarDefine"))
+            VarAttributes.update(data.get("DataStructAttribute"))
+
+            for vardata in Data:
+                if vardata['VendorGuid'] == 'NA':
+                    continue
+                VarDataDict.setdefault(
+                    (vardata['VendorGuid'], vardata["VarName"]), []).append(vardata)
+
+        cStructDefs = CStruct(DataStruct)
+        for guid, varname in VarDataDict:
+            v = Variable()
+            v.guid = guid
+            vardef = VarDefine.get(varname)
+            if vardef is None:
+                for var in VarDefine:
+                    if VarDefine[var]['Type'] == varname:
+                        vardef = VarDefine[var]
+                        break
+                else:
+                    continue
+            v.attributes = vardef['Attributes']
+            v.mType = vardef['Type']
+            v.mAlign = VarAttributes[v.mType]['Alignment']
+            v.mTotalSize = VarAttributes[v.mType]['TotalSize']
+            v.Struct = DataStruct[v.mType]
+            v.mName = varname
+            v.cDefs = cStructDefs
+            for fieldinfo in VarDataDict.get((guid, varname), []):
+                vf = VarField()
+                vf.Offset = fieldinfo['Offset']
+                vf.Value = fieldinfo['Value']
+                vf.Size = fieldinfo['Size']
+                v.fields.setdefault(
+                    int(fieldinfo['DefaultStore'], 10), []).append(vf)
+            v.serial()
+            v.pack()
+            self.NvVarInfo.append(v)
+
+    def PackDeltaData(self):
+
+        default_id_set = set()
+        for v in self.NvVarInfo:
+            default_id_set |= set(v.mBin.keys())
+
+        if default_id_set:
+            default_id_set.remove(0)
+        delta_buff_set = {}
+        for defaultid in default_id_set:
+            delta_buff = b''
+            for v in self.NvVarInfo:
+                delta_list = v.delta.get(defaultid,[])
+                for delta in delta_list:
+                    delta_data = DELTA_DATA()
+                    delta_data.Offset, delta_data.Value = delta
+                    delta_buff += PackStruct(delta_data)
+            delta_buff_set[defaultid] = delta_buff
+
+        return delta_buff_set
+
+    def PackDefaultData(self):
+
+        default_data_header = DEFAULT_DATA()
+        default_data_header.HeaderSize = sizeof(DEFAULT_DATA)
+        default_data_header.DefaultInfo.DefaultId = 0x0
+        default_data_header.DefaultInfo.BoardId = 0x0
+        default_data_header_buffer = PackStruct(default_data_header)
+
+
+        variable_store = VARIABLE_STORE_HEADER()
+        variable_store.Signature = AuthVarGuid
+
+        variable_store_size = Get_Occupied_Size(sizeof(DEFAULT_DATA) + sizeof(VARIABLE_STORE_HEADER), 4)
+        for v in self.NvVarInfo:
+            variable_store_size += Get_Occupied_Size(len(v.mBin[0]), 4)
+
+        variable_store.Size = variable_store_size
+        variable_store.Format = VARIABLE_STORE_FORMATTED
+        variable_store.State = VARIABLE_STORE_HEALTHY
+        variable_store.Reserved = 0x0
+        variable_store.Reserved2 = 0x0
+
+        variable_storage_header_buffer = PackStruct(variable_store)
+
+        variable_data = b''
+        v_offset = 0
+        for v in self.NvVarInfo:
+            v.update_delta_offset(v_offset)
+            variable_data += Occupied_Size(v.mBin[0],4)
+            v_offset += Get_Occupied_Size(len(v.mBin[0]),4)
+
+
+        final_buff = Occupied_Size(default_data_header_buffer + variable_storage_header_buffer,4) + variable_data
+
+        return final_buff
+
+    def generate(self, jsonlistfile,output_folder):
+        if not os.path.exists(jsonlistfile):
+            return
+        if not os.path.exists(output_folder):
+            os.makedirs(output_folder)
+        try:
+            with open(jsonlistfile,"r") as fd:
+                filelist = fd.readlines()
+            genVar = DefaultVariableGenerator()
+            genVar.LoadNvVariableInfo(filelist)
+            with open(os.path.join(output_folder, "default.bin"), "wb") as fd:
+                fd.write(genVar.PackDefaultData())
+
+            delta_set = genVar.PackDeltaData()
+            for default_id in delta_set:
+                with open(os.path.join(output_folder, "defaultdelta_%s.bin" % default_id), "wb") as fd:
+                    fd.write(delta_set[default_id])
+        except:
+            print("generate varbin file failed")
+
+
+
diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
index d70b0d7ae828..0daf3352f91b 100755
--- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
@@ -433,10 +433,19 @@ class ModuleAutoGen(AutoGen):
    ## Return the directory to store auto-gened source files of the module
    @cached_property
    def DebugDir(self):
        return _MakeDir((self.BuildDir, "DEBUG"))

+
+    @cached_property
+    def DefaultVarJsonFiles(self):
+        rt = []
+        for SrcFile in self.SourceFileList:
+            if SrcFile.Ext.lower() == '.vfr':
+                rt.append(os.path.join(self.DebugDir,os.path.join(os.path.dirname(SrcFile.File), "{}_var.json".format(SrcFile.BaseName))))
+        return rt
+
    ## Return the path of custom file
    @cached_property
    def CustomMakefile(self):
        RetVal = {}
        for Type in self.Module.CustomMakefile:
diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
index 036fdac3d7df..b46d041f58ab 100644
--- a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
+++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
@@ -644,10 +644,14 @@ class PlatformInfo(AutoGenInfo):
                            if Attr != 'PATH':
                                BuildOptions[ExpandedTool][Attr] += " " + mws.handleWsMacro(Value)
                            else:
                                BuildOptions[ExpandedTool][Attr] = mws.handleWsMacro(Value)

+        if self.DataPipe.Get("GenDefaultVarBin"):
+            if BuildOptions.get('VFR',{}).get('FLAGS'):
+                BuildOptions['VFR']['FLAGS'] += " " + "--variable"
+
        return BuildOptions, BuildRuleOrder

    def ApplyLibraryInstance(self,module):
        alldeps = self.DataPipe.Get("DEPS")
        if alldeps is None:
diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py
index 61ab3f7e24cd..c68ca8fbb3f7 100755
--- a/BaseTools/Source/Python/Common/GlobalData.py
+++ b/BaseTools/Source/Python/Common/GlobalData.py
@@ -88,10 +88,15 @@ gIgnoreSource = False
#
gFdfParser = None

BuildOptionPcd = []

+#
+# Build flag for generate default variable binary file
+#
+gGenDefaultVarBin = False
+
#
# Mixed PCD name dict
#
MixedPcd = {}

diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 02b489892422..2f6fc6b20faf 100755
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -750,10 +750,11 @@ class Build():
        GlobalData.gUseHashCache = BuildOptions.UseHashCache
        GlobalData.gBinCacheDest   = BuildOptions.BinCacheDest
        GlobalData.gBinCacheSource = BuildOptions.BinCacheSource
        GlobalData.gEnableGenfdsMultiThread = not BuildOptions.NoGenfdsMultiThread
        GlobalData.gDisableIncludePathCheck = BuildOptions.DisableIncludePathCheck
+        GlobalData.gGenDefaultVarBin = BuildOptions.GenDefaultVarBin

        if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache:
            EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData="--binary-destination must be used together with --hash.")

        if GlobalData.gBinCacheSource and not GlobalData.gUseHashCache:
@@ -1459,10 +1460,14 @@ class Build():
            self.BuildModules = []
            return True

        # genfds
        if Target == 'fds':
+            if GlobalData.gGenDefaultVarBin:
+                from AutoGen.GenDefaultVar import DefaultVariableGenerator
+                variable_info_filelist = os.path.join(AutoGenObject.BuildDir,"variable_info_filelist.txt")
+                DefaultVariableGenerator().generate(variable_info_filelist,AutoGenObject.FvDir)
            if GenFdsApi(AutoGenObject.GenFdsCommandDict, self.Db):
                EdkLogger.error("build", COMMAND_FAILURE)
            Threshold = self.GetFreeSizeThreshold()
            if Threshold:
                self.CheckFreeSizeThreshold(Threshold, AutoGenObject.FvDir)
@@ -2247,10 +2252,19 @@ class Build():
        AutoGenIdFile = os.path.join(GlobalData.gConfDirectory,".AutoGenIdFile.txt")
        with open(AutoGenIdFile,"w") as fw:
            fw.write("Arch=%s\n" % "|".join((Wa.ArchList)))
            fw.write("BuildDir=%s\n" % Wa.BuildDir)
            fw.write("PlatformGuid=%s\n" % str(Wa.AutoGenObjectList[0].Guid))
+        variable_info_filelist = os.path.join(Wa.BuildDir,"variable_info_filelist.txt")
+        vfr_var_json = []
+        if GlobalData.gGenDefaultVarBin:
+            for ma in self.AllModules:
+                vfr_var_json.extend(ma.DefaultVarJsonFiles)
+            SaveFileOnChange(variable_info_filelist, "\n".join(vfr_var_json), False)
+        else:
+            if os.path.exists(variable_info_filelist):
+                os.remove(variable_info_filelist)

        if GlobalData.gBinCacheSource:
            BuildModules.extend(self.MakeCacheMiss)
        elif GlobalData.gUseHashCache and not GlobalData.gBinCacheDest:
            BuildModules.extend(self.PreMakeCacheMiss)
@@ -2359,10 +2373,14 @@ class Build():

                    if self.Fdf:
                        #
                        # Generate FD image if there's a FDF file found
                        #
+                        if GlobalData.gGenDefaultVarBin:
+                            from AutoGen.GenDefaultVar import DefaultVariableGenerator
+                            variable_info_filelist = os.path.join(Wa.BuildDir,"variable_info_filelist.txt")
+                            DefaultVariableGenerator().generate(variable_info_filelist,Wa.FvDir)
                        GenFdsStart = time.time()
                        if GenFdsApi(Wa.GenFdsCommandDict, self.Db):
                            EdkLogger.error("build", COMMAND_FAILURE)
                        Threshold = self.GetFreeSizeThreshold()
                        if Threshold:
diff --git a/BaseTools/Source/Python/build/buildoptions.py b/BaseTools/Source/Python/build/buildoptions.py
index 39d92cff209d..6886ba7f8eb6 100644
--- a/BaseTools/Source/Python/build/buildoptions.py
+++ b/BaseTools/Source/Python/build/buildoptions.py
@@ -99,7 +99,8 @@ class MyOptionParser():
        Parser.add_option("--hash", action="store_true", dest="UseHashCache", default=False, help="Enable hash-based caching during build process.")
        Parser.add_option("--binary-destination", action="store", type="string", dest="BinCacheDest", help="Generate a cache of binary files in the specified directory.")
        Parser.add_option("--binary-source", action="store", type="string", dest="BinCacheSource", help="Consume a cache of binary files from the specified directory.")
        Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=True, help="Enable GenFds multi thread to generate ffs file.")
        Parser.add_option("--no-genfds-multi-thread", action="store_true", dest="NoGenfdsMultiThread", default=False, help="Disable GenFds multi thread to generate ffs file.")
+        Parser.add_option("--gen-default-variable-bin", action="store_true", dest="GenDefaultVarBin", default=False, help="Generate default variable binary file.")
        Parser.add_option("--disable-include-path-check", action="store_true", dest="DisableIncludePathCheck", default=False, help="Disable the include path check for outside of package.")
        self.BuildOption, self.BuildTarget = Parser.parse_args()
--
2.18.0.windows.1








Re: [edk2-platforms PATCH] Platform/RaspberryPi: Remove unnecessary files

Samer El-Haj-Mahmoud
 

Thanks!

Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>

-----Original Message-----
From: Marcin Wojtas <mw@semihalf.com>
Sent: Friday, August 13, 2021 10:42 AM
To: devel@edk2.groups.io
Cc: leif@nuviainc.com; ardb+tianocore@kernel.org; Samer El-Haj-Mahmoud
<Samer.El-Haj-Mahmoud@arm.com>; Sunny Wang
<Sunny.Wang@arm.com>; gjb@semihalf.com; upstream@semihalf.com;
pete@akeo.ie; Marcin Wojtas <mw@semihalf.com>
Subject: [edk2-platforms PATCH] Platform/RaspberryPi: Remove
unnecessary files

Commit 2f0188b56ef4 ("Revert "Platform/RaspberryPi: Setup option for...")
mistakenly introduced to files which are residues from a
conflict resolution. Fix that.

Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
Platform/RaspberryPi/RPi4/RPi4.dsc.orig | 760 --------------------
Platform/RaspberryPi/RPi4/RPi4.dsc.rej | 29 -
2 files changed, 789 deletions(-)
delete mode 100644 Platform/RaspberryPi/RPi4/RPi4.dsc.orig
delete mode 100644 Platform/RaspberryPi/RPi4/RPi4.dsc.rej

diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc.orig
b/Platform/RaspberryPi/RPi4/RPi4.dsc.orig
deleted file mode 100644
index 2c05c31118..0000000000
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc.orig
+++ /dev/null
@@ -1,760 +0,0 @@
-# @file

-#

-# Copyright (c) 2011 - 2020, ARM Limited. All rights reserved.

-# Copyright (c) 2017 - 2018, Andrei Warkentin
<andrey.warkentin@gmail.com>

-# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.

-# Copyright (c) 2014, Linaro Limited. All rights reserved.

-#

-# SPDX-License-Identifier: BSD-2-Clause-Patent

-#

-##

-

-
##########################################################
######################

-#

-# Defines Section - statements that will be processed to create a Makefile.

-#

-
##########################################################
######################

-[Defines]

- PLATFORM_NAME = RPi4

- PLATFORM_GUID = a7eca3b4-21b0-4989-8c18-c08f3ae87837

- PLATFORM_VERSION = 1.0

- DSC_SPECIFICATION = 0x0001001A

- OUTPUT_DIRECTORY = Build/$(PLATFORM_NAME)

- SUPPORTED_ARCHITECTURES = AARCH64

- BUILD_TARGETS = DEBUG|RELEASE|NOOPT

- SKUID_IDENTIFIER = DEFAULT

- FLASH_DEFINITION =
Platform/RaspberryPi/$(PLATFORM_NAME)/$(PLATFORM_NAME).fdf

-

- #

- # Defines for default states. These can be changed on the command line.

- # -D FLAG=VALUE

- #

- DEFINE SECURE_BOOT_ENABLE = FALSE

- DEFINE INCLUDE_TFTP_COMMAND = FALSE

- DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x8000004F

-

-!ifndef TFA_BUILD_ARTIFACTS

- #

- # Default TF-A binary checked into edk2-non-osi.

- #

- DEFINE TFA_BUILD_BL31 =
Platform/RaspberryPi/$(PLATFORM_NAME)/TrustedFirmware/bl31.bin

-!else

- #

- # Usually we use the checked-in binaries, but for developers working

- # on the firmware, being able to use a local TF-A build without extra copy

- # operations ends up being very helpful.

- #

- DEFINE TFA_BUILD_BL31 = $(TFA_BUILD_ARTIFACTS)/bl31.bin

-!endif

-

-
##########################################################
######################

-#

-# Library Class section - list of all Library Classes needed by this Platform.

-#

-
##########################################################
######################

-

-!include MdePkg/MdeLibs.dsc.inc

-

-[LibraryClasses.common]

-!if $(TARGET) == RELEASE

- DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf

-!else

-
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.
inf

-!endif

-
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/Bas
eDebugPrintErrorLevelLib.inf

-

- BaseLib|MdePkg/Library/BaseLib/BaseLib.inf

- SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf

-
BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupp
ortLib.inf

-
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniz
ationLib.inf

-
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanc
eLibNull.inf

-
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseR
eportStatusCodeLibNull.inf

- PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf

-
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/Base
PeCoffGetEntryPointLib.inf

- PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf

- IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf

-
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDeco
mpressLib.inf

- CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf

-

- UefiLib|MdePkg/Library/UefiLib/UefiLib.inf

- HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf

-
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib
/UefiRuntimeServicesTableLib.inf

- DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf

-
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBo
otServicesTableLib.inf

-
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTabl
eLib.inf

- DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf

-
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry
Point.inf

-
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiA
pplicationEntryPoint.inf

- HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf

-
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiService
sLib.inf

- SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf

-

- UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf

-
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeL
ib/BaseOrderedCollectionRedBlackTreeLib.inf

-

- #

- # Ramdisk Requirements

- #

- FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf

-

- # Allow dynamic PCDs

- #

- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf

-

- # use the accelerated BaseMemoryLibOptDxe by default, overrides for
SEC/PEI below

-
BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLib
OptDxe.inf

-

- #

- # It is not possible to prevent the ARM compiler from inserting calls to
intrinsic functions.

- # This library provides the instrinsic functions such a compiler may generate
calls to.

- #

- NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf

-

- # Add support for GCC stack protector

- NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf

-

- # ARM Architectural Libraries

-
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCach
eMaintenanceLib.inf

-
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/D
efaultExceptionHandlerLib.inf

-
CpuExceptionHandlerLib|ArmPkg/Library/ArmExceptionLib/ArmExceptionLib
.inf

-
ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler
Lib.inf

- ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf

- ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf

-
DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.i
nf

- TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf

-
ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPla
tformStackLib.inf

- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf

- ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf

-
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounter
Lib/ArmGenericTimerPhyCounterLib.inf

-

- # Dual serial port library

-
PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClo
ckLib.inf

- PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf

-
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DebugDualSeri
alPortLib.inf

-

- # Cryptographic libraries

- RngLib|MdePkg/Library/DxeRngLib/DxeRngLib.inf

- IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf

- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf

- OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf

- TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf

-

- #

- # Uncomment (and comment out the next line) For RealView Debugger.
The Standard IO window

- # in the debugger will show load and unload commands for symbols. You
can cut and paste this

- # into the command window to load symbols. We should be able to use a
script to do this, but

- # the version of RVD I have does not support scripts accessing system
memory.

- #

-
#PeCoffExtraActionLib|ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoff
ExtraActionLib.inf

-
PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPe
CoffExtraActionLib.inf

-
#PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/Base
PeCoffExtraActionLibNull.inf

-

-
DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLi
bNull.inf

-
DebugAgentTimerLib|EmbeddedPkg/Library/DebugAgentTimerLibNull/Debu
gAgentTimerLibNull.inf

-

- # Flattened Device Tree (FDT) access library

- FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf

-

- # USB Libraries

- UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf

-

- #

- # Secure Boot dependencies

- #

-!if $(SECURE_BOOT_ENABLE) == TRUE

-
TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTp
mMeasurementLib.inf

- AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf

-

- # re-use the UserPhysicalPresent() dummy implementation from the ovmf
tree

-
PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.i
nf

-!else

-
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/Tp
mMeasurementLibNull.inf

-
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableL
ibNull.inf

-!endif

- VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf

-
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLi
b.inf

-
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Va
riablePolicyHelperLib.inf

- GpioLib|Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.inf

-

- #

- # PCI dependencies

- #

- # PCI root port configuation and description

-
PciHostBridgeLib|Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciHostBridge
Lib/Bcm2711PciHostBridgeLib.inf

- # The "segment lib" provides the CAM accessors/etc when they aren't
ECAM standard

-
PciSegmentLib|Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/
PciSegmentLib.inf

-

-[LibraryClasses.common.SEC]

- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf

- BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf

-
MemoryInitPeiLib|Platform/RaspberryPi/Library/MemoryInitPeiLib/Memory
InitPeiLib.inf

- PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf

-
ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionL
ib/PrePiExtractGuidedSectionLib.inf

-
LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/L
zmaCustomDecompressLib.inf

- PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf

- HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf

-
PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/Pre
PiHobListPointerLib.inf

-
MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/Pre
PiMemoryAllocationLib.inf

-

-[LibraryClasses.common.DXE_CORE]

- HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf

-
MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLi
b/DxeCoreMemoryAllocationLib.inf

-
DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint
.inf

-
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeE
xtractGuidedSectionLib.inf

-
PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCore
PerformanceLib.inf

-

-[LibraryClasses.common.DXE_DRIVER]

-
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementL
ib/DxeSecurityManagementLib.inf

-
PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerforma
nceLib.inf

-
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemo
ryAllocationLib.inf

-!if $(INCLUDE_TFTP_COMMAND) == TRUE

- ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf

- FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf

-!endif

-

-[LibraryClasses.common.UEFI_APPLICATION]

-
PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerforma
nceLib.inf

-
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemo
ryAllocationLib.inf

- HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf

- ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf

- FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf

-

-[LibraryClasses.common.UEFI_DRIVER]

-
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeE
xtractGuidedSectionLib.inf

-
PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerforma
nceLib.inf

-
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemo
ryAllocationLib.inf

-

-[LibraryClasses.common.DXE_RUNTIME_DRIVER]

- # Runtime debug messages may crash an OS unless serial output to MMIO
mapped UARTs is inhibited

-
DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDeb
ugLibSerialPort.inf

-
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemo
ryAllocationLib.inf

-
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.i
nf

- EfiResetSystemLib|Platform/RaspberryPi/Library/ResetLib/ResetLib.inf

- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf

-
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLi
bRuntimeDxe.inf

-

-!if $(SECURE_BOOT_ENABLE) == TRUE

- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf

-!endif

-

-
##########################################################
#########################################

-# BuildOptions Section - Define the module specific tool chain flags that
should be used as

-# the default flags for a module. These flags are appended to any

-# standard flags that are defined by the build process.

-
##########################################################
#########################################

-

-[BuildOptions]

- GCC:*_*_*_CC_FLAGS = -DRPI_MODEL=4

- GCC:*_*_*_PP_FLAGS = -DRPI_MODEL=4

- GCC:*_*_*_ASLPP_FLAGS = -DRPI_MODEL=4

- GCC:*_*_*_ASLCC_FLAGS = -DRPI_MODEL=4

- GCC:*_*_*_VFRPP_FLAGS = -DRPI_MODEL=4

- GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG -DNDEBUG

-

-[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]

- GCC:*_*_AARCH64_DLINK_FLAGS = -z common-page-size=0x10000

-

-
##########################################################
######################

-#

-# Pcd Section - list of all EDK II PCD Entries defined by this Platform

-#

-
##########################################################
######################

-

-[PcdsFeatureFlag.common]

- # Use the Vector Table location in CpuDxe. We will not copy the Vector
Table at PcdCpuVectorBaseAddress

- gArmTokenSpaceGuid.PcdRelocateVectorTable|FALSE

-

-
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
|TRUE

- gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE

-

- ## If TRUE, Graphics Output Protocol will be installed on virtual handle
created by ConsplitterDxe.

- # It could be set FALSE to save size.

- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE

- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE

- gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|FALSE

-

-[PcdsFixedAtBuild.common]

- gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000

- gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000

- gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000

- gEfiMdePkgTokenSpaceGuid.PcdSpinLockTimeout|10000000

- gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue|0xAF

- gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|1

- gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0

- gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320

-

- # DEBUG_ASSERT_ENABLED 0x01

- # DEBUG_PRINT_ENABLED 0x02

- # DEBUG_CODE_ENABLED 0x04

- # CLEAR_MEMORY_ENABLED 0x08

- # ASSERT_BREAKPOINT_ENABLED 0x10

- # ASSERT_DEADLOOP_ENABLED 0x20

-!if $(TARGET) == RELEASE

- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x21

-!else

- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2f

-!endif

-

- # DEBUG_INIT 0x00000001 // Initialization

- # DEBUG_WARN 0x00000002 // Warnings

- # DEBUG_LOAD 0x00000004 // Load events

- # DEBUG_FS 0x00000008 // EFI File system

- # DEBUG_POOL 0x00000010 // Alloc & Free (pool)

- # DEBUG_PAGE 0x00000020 // Alloc & Free (page)

- # DEBUG_INFO 0x00000040 // Informational debug messages

- # DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers

- # DEBUG_VARIABLE 0x00000100 // Variable

- # DEBUG_BM 0x00000400 // Boot Manager

- # DEBUG_BLKIO 0x00001000 // BlkIo Driver

- # DEBUG_NET 0x00004000 // SNP Driver

- # DEBUG_UNDI 0x00010000 // UNDI Driver

- # DEBUG_LOADFILE 0x00020000 // LoadFile

- # DEBUG_EVENT 0x00080000 // Event messages

- # DEBUG_GCD 0x00100000 // Global Coherency Database changes

- # DEBUG_CACHE 0x00200000 // Memory range cachability changes

- # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may

- # // significantly impact boot performance

- # DEBUG_ERROR 0x80000000 // Error

-
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|$(DEBUG_PRINT_ER
ROR_LEVEL)

-

- gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07

-

- #

- # Optional feature to help prevent EFI memory map fragments

- # Turned on and off via: PcdPrePiProduceMemoryTypeInformationHob

- # Values are in EFI Pages (4K). DXE Core will make sure that

- # at least this much of each type of memory can be allocated

- # from a single memory range. This way you only end up with

- # maximum of two fragments for each type in the memory map

- # (the memory used, and the free memory that was prereserved

- # but not used).

- #

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0

-!if $(SECURE_BOOT_ENABLE) == TRUE

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|600

-
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|400

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|1500

-!else

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|300

-
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|150

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|1000

-!endif

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData|12000

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|20

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0

-

- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0xc0000000

- gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xffffffff

-

- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"EDK2-
DEV"

-

-!if $(SECURE_BOOT_ENABLE) == TRUE

- # override the default values from SecurityPkg to ensure images from all
sources are verified in secure boot

-
gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x04

-
gEfiSecurityPkgTokenSpaceGuid.PcdFixedMediaImageVerificationPolicy|0x0
4

-
gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolic
y|0x04

-!endif

-

- gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE

-

- # Default platform supported RFC 4646 languages: (American) English

-
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLangCodes|"e
n-US"

-

-[LibraryClasses.common]

- ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf

- ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf

- ArmPlatformLib|Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf

- TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf

-
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.i
nf

-
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBoo
tManagerLib.inf

- BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf

-
PlatformBootManagerLib|Platform/RaspberryPi/Library/PlatformBootManag
erLib/PlatformBootManagerLib.inf

-
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/Custo
mizedDisplayLib.inf

- FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf

- AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf

-

-[LibraryClasses.common.UEFI_DRIVER]

- UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf

-

-
##########################################################
######################

-#

-# Pcd Section - list of all EDK II PCD Entries defined by this Platform

-#

-
##########################################################
######################

-

-[PcdsFeatureFlag.common]

- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE

- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE

- gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE

-

-[PcdsFixedAtBuild.common]

- gArmPlatformTokenSpaceGuid.PcdCoreCount|4

- gArmTokenSpaceGuid.PcdVFPEnabled|1

-

- gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x4000

- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000

- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800

-

- # Size of the region used by UEFI in permanent memory (Reserved 64MB)

-
gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x040000
00

- #

- # 0x00000000 - 0x001F0000 FD (PcdFdBaseAddress, PcdFdSize)

- # 0x001F0000 - 0x00200000 DTB (PcdFdtBaseAddress, PcdFdtSize)

- # 0x00200000 - ... RAM (PcdSystemMemoryBase,
PcdSystemMemorySize)

- #

- # This matches PcdFvBaseAddress, since everything less is the FD, and

- # will be reserved away.

- #

- gArmTokenSpaceGuid.PcdSystemMemoryBase|0x00200000

- gArmTokenSpaceGuid.PcdSystemMemorySize|0x3fe00000

-

- #

- # Device specific addresses

- #

- gBcm27xxTokenSpaceGuid.PcdBcm27xxRegistersAddress|0xfc000000

- gBcm27xxTokenSpaceGuid.PcdBcmGenetRegistersAddress|0xfd580000

- gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress|0xfe000000

-

- # PCIe specific addresses

- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciRegBase|0xfd500000

- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioAdr|0xf8000000

- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioLen|0x3ffffff

- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr|0x600000000

-

- # UARTs

- gArmPlatformTokenSpaceGuid.PL011UartInteger|0

- gArmPlatformTokenSpaceGuid.PL011UartFractional|0

- gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000

- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE

- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4

- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1000000000

- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27

- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8

- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200

- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0

-

- #

- # ARM General Interrupt Controller

- #

- gArmTokenSpaceGuid.PcdGicDistributorBase|0xFF841000

- gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0xFF842000

- gRaspberryPiTokenSpaceGuid.PcdGicInterruptInterfaceHBase|0xFF844000

- gRaspberryPiTokenSpaceGuid.PcdGicInterruptInterfaceVBase|0xFF846000

- gRaspberryPiTokenSpaceGuid.PcdGicGsivId|0x19

- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq0|0x30

- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq1|0x31

- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq2|0x32

- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq3|0x33

-

- #

- # Fixed CPU settings.

- #

- gRaspberryPiTokenSpaceGuid.PcdCpuLowSpeedMHz|800

- gRaspberryPiTokenSpaceGuid.PcdCpuDefSpeedMHz|1500

- gRaspberryPiTokenSpaceGuid.PcdCpuMaxSpeedMHz|2200

-

- ## Default Terminal Type

- ## 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM

- gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4

-

-
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationC
hange|FALSE

- gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21,
0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66,
0x23, 0x31 }

-

- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2"

- gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE

-

-[PcdsDynamicHii.common.DEFAULT]

-

- #

- # Clock overrides.

- #

-

-
gRaspberryPiTokenSpaceGuid.PcdCpuClock|L"CpuClock"|gConfigDxeFormSe
tGuid|0x0|1

-
gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|L"CustomCpuClock"|gCo
nfigDxeFormSetGuid|0x0|gRaspberryPiTokenSpaceGuid.PcdCpuDefSpeedM
Hz

-

- #

- # SD-related.

- #

-

-
gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|L"SdIsArasan"|gConfigDxeFor
mSetGuid|0x0|0

-
gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|L"MmcForce1Bit"|gConfig
DxeFormSetGuid|0x0|0

-
gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|L"MmcForceDef
aultSpeed"|gConfigDxeFormSetGuid|0x0|0

-
gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefau
ltSpeedMHz"|gConfigDxeFormSetGuid|0x0|25

-
gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpe
edMHz"|gConfigDxeFormSetGuid|0x0|50

-
gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gC
onfigDxeFormSetGuid|0x0|0

-
gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gCo
nfigDxeFormSetGuid|0x0|0

-

- #

- # Debug-related.

- #

-

-
gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|L"DebugEnableJTAG"|
gConfigDxeFormSetGuid|0x0|0

-

- #

- # Display-related.

- #

-

- #

- # Just enable native resolution by default.

- #

-
gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes|L"DisplayEna
bleScaledVModes"|gConfigDxeFormSetGuid|0x0|0x20

-
gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot|L"DisplayEnableSShot
"|gConfigDxeFormSetGuid|0x0|1

-

- #

- # Supporting > 3GB of memory.

- #

-
gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB|L"RamMoreThan3GB"
|gConfigDxeFormSetGuid|0x0|0

-
gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB|L"RamLimitTo3GB"|gConf
igDxeFormSetGuid|0x0|1

-

- #

- # Device Tree and ACPI selection.

- #

- # 0 - SYSTEM_TABLE_MODE_ACPI (default)

- # 1 - SYSTEM_TABLE_MODE_BOTH

- # 2 - SYSTEM_TABLE_MODE_DT

- #

-
gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|L"SystemTableMode"
|gConfigDxeFormSetGuid|0x0|0

-

- #

- # Enable a fan in the ACPI thermal zone on GPIO pin #

- #

- # 0 - DISABLED

- # 19 - Enabled on pin 19

- #

-
gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFor
mSetGuid|0x0|0

-
gRaspberryPiTokenSpaceGuid.PcdFanTemp|L"FanTemp"|gConfigDxeFormS
etGuid|0x0|60

-

- #

- # Reset-related.

- #

-

-
gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|L"ResetDelay"|gRasp
berryPiTokenSpaceGuid|0x0|0

-

- #

- # Common UEFI ones.

- #

-

-
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlo
balVariableGuid|0x0|5

- #

- # This is silly, but by pointing SetupConXXX and ConXXX PCDs to

- # the same variables, I can use the graphical configuration to

- # change the mode used by ConSplitter.

- #

-
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn|L"Columns"|
gRaspberryPiTokenSpaceGuid|0x0|80

-
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Columns"|gRasp
berryPiTokenSpaceGuid|0x0|80

-
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|L"Rows"|gRaspb
erryPiTokenSpaceGuid|0x0|25

-
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|L"Rows"|gRaspberryPi
TokenSpaceGuid|0x0|25

-

-[PcdsDynamicDefault.common]

- #

- # Set video resolution for boot options and for text setup.

- #

- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0

- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0

-
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|64
0

-
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480

- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0

-
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0

- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0

-

-
##########################################################
######################

-#

-# Components Section - list of all EDK II Modules needed by this Platform

-#

-
##########################################################
######################

-[Components.common]

- #

- # PEI Phase modules

- #

- ArmPlatformPkg/PrePi/PeiUniCore.inf {

- <LibraryClasses>

-
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortL
ib.inf

- }

-

- #

- # DXE

- #

- MdeModulePkg/Core/Dxe/DxeMain.inf {

- <LibraryClasses>

-
NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32G
uidedSectionExtractLib.inf

- }

- MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {

- <LibraryClasses>

- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf

- }

-

- #

- # Architectural Protocols

- #

- ArmPkg/Drivers/CpuDxe/CpuDxe.inf

- MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf

- Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf

-
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.in
f

- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
{

- <LibraryClasses>

- NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf

- DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf

- }

-!if $(SECURE_BOOT_ENABLE) == TRUE

- MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {

- <LibraryClasses>

-
NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib
.inf

- }

-
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfi
gDxe.inf

-!else

- MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf

-!endif

- MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf

-
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCoun
terRuntimeDxe.inf

- EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf

- EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf {

- <LibraryClasses>

-
RealTimeClockLib|EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRea
lTimeClockLib.inf

- }

- EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf

-

- MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf

- MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

-
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
xe.inf

- MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf

- MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {

- <LibraryClasses>

-
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortL
ib.inf

- }

- Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf

- EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf

-

- MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf

-

- ArmPkg/Drivers/ArmGic/ArmGicDxe.inf

- Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf

- Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf

- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf

- ArmPkg/Drivers/TimerDxe/TimerDxe.inf

- MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf

- MdeModulePkg/Universal/EbcDxe/EbcDxe.inf

-

- #

- # FAT filesystem + GPT/MBR partitioning

- #

- MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf

- MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf

-
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf

- FatPkg/EnhancedFatDxe/Fat.inf

-

- #

- # ACPI Support

- #

- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf

-
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraph
icsResourceTableDxe.inf

- Platform/RaspberryPi/AcpiTables/AcpiTables.inf

-

- #

- # SMBIOS Support

- #

- Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf

- MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf

-

- #

- # RAM Disk Support

- #

- MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf

-

- #

- # Bds

- #

- MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf

- MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf

- MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf

-
MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManager
Dxe.inf

- MdeModulePkg/Universal/BdsDxe/BdsDxe.inf

- Platform/RaspberryPi/Drivers/LogoDxe/LogoDxe.inf

- MdeModulePkg/Application/UiApp/UiApp.inf {

- <LibraryClasses>

-
NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf

- NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf

-
NULL|Platform/RaspberryPi/Library/PlatformUiAppLib/PlatformUiAppLib.inf

-
NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMainte
nanceManagerUiLib.inf

- }

-

- #

- # SCSI Bus and Disk Driver

- #

- MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf

- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf

-

- #

- # USB Support

- #

- MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf

- Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf

- MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf

- MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf

- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf

-

- #

- # SD/MMC support

- #

- # Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.inf

-
Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf

- Platform/RaspberryPi/Drivers/MmcDxe/MmcDxe.inf

-

- #

- # Networking stack

- #

-!include NetworkPkg/Network.dsc.inc

- Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf {

- <PcdsFixedAtBuild>

- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x00000000

- gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xffffffff

- }

-

- #

- # RNG

- #

- Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf

-

- #

- # PCI Support

- #

- ArmPkg/Drivers/ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf

- MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf

- MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf

-
EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.i
nf {

- <PcdsFixedAtBuild>

- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x00000000

- gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xbfffffff

- }

-

- #

- # UEFI application (Shell Embedded Boot Loader)

- #

- ShellPkg/Application/Shell/Shell.inf {

- <LibraryClasses>

-
ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellComma
ndLib.inf

-
NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Comma
ndsLib.inf

-
NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1Comma
ndsLib.inf

-
NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3Comma
ndsLib.inf

-
NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Com
mandsLib.inf

-
NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Com
mandsLib.inf

-
NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1Com
mandsLib.inf

-
NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1
CommandsLib.inf

-
NULL|ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCo
mmandLib.inf

-
HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingL
ib.inf

- PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf

-
BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfg
CommandLib.inf

-

- <PcdsFixedAtBuild>

- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF

- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE

- gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000

- gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x200000

- }

-!if $(INCLUDE_TFTP_COMMAND) == TRUE

-
ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.
inf {

- <PcdsFixedAtBuild>

- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE

- }

-!endif

diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc.rej
b/Platform/RaspberryPi/RPi4/RPi4.dsc.rej
deleted file mode 100644
index 0b40df6896..0000000000
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc.rej
+++ /dev/null
@@ -1,29 +0,0 @@
---- Platform/RaspberryPi/RPi4/RPi4.dsc
-+++ Platform/RaspberryPi/RPi4/RPi4.dsc
-@@ -429,7 +429,6 @@ [PcdsFixedAtBuild.common]
- gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4
-- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1000000000
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
-@@ -465,6 +464,9 @@ [PcdsFixedAtBuild.common]
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2"
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
-
-+[PcdsPatchableInModule]
-+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|500000000
-+
- [PcdsDynamicHii.common.DEFAULT]
-
- #
-@@ -621,7 +623,7 @@ [Components.common]
- MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
- MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {
- <LibraryClasses>
--
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortL
ib.inf
-+
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPort
DxeLib.inf
- }
- Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf
- EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf
--
2.29.0
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


[edk2-platforms PATCH] Platform/RaspberryPi: Remove unnecessary files

Marcin Wojtas
 

Commit 2f0188b56ef4 ("Revert "Platform/RaspberryPi: Setup option for...")
mistakenly introduced to files which are residues from a
conflict resolution. Fix that.

Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
Platform/RaspberryPi/RPi4/RPi4.dsc.orig | 760 --------------------
Platform/RaspberryPi/RPi4/RPi4.dsc.rej | 29 -
2 files changed, 789 deletions(-)
delete mode 100644 Platform/RaspberryPi/RPi4/RPi4.dsc.orig
delete mode 100644 Platform/RaspberryPi/RPi4/RPi4.dsc.rej

diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc.orig b/Platform/RaspberryPi=
/RPi4/RPi4.dsc.orig
deleted file mode 100644
index 2c05c31118..0000000000
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc.orig
+++ /dev/null
@@ -1,760 +0,0 @@
-# @file=0D
-#=0D
-# Copyright (c) 2011 - 2020, ARM Limited. All rights reserved.=0D
-# Copyright (c) 2017 - 2018, Andrei Warkentin <andrey.warkentin@gmail.com=
=0D
-# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.=0D
-# Copyright (c) 2014, Linaro Limited. All rights reserved.=0D
-#=0D
-# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
-#=0D
-##=0D
-=0D
-##########################################################################=
######=0D
-#=0D
-# Defines Section - statements that will be processed to create a Makefile=
.=0D
-#=0D
-##########################################################################=
######=0D
-[Defines]=0D
- PLATFORM_NAME =3D RPi4=0D
- PLATFORM_GUID =3D a7eca3b4-21b0-4989-8c18-c08f3ae87837=
=0D
- PLATFORM_VERSION =3D 1.0=0D
- DSC_SPECIFICATION =3D 0x0001001A=0D
- OUTPUT_DIRECTORY =3D Build/$(PLATFORM_NAME)=0D
- SUPPORTED_ARCHITECTURES =3D AARCH64=0D
- BUILD_TARGETS =3D DEBUG|RELEASE|NOOPT=0D
- SKUID_IDENTIFIER =3D DEFAULT=0D
- FLASH_DEFINITION =3D Platform/RaspberryPi/$(PLATFORM_NAME)=
/$(PLATFORM_NAME).fdf=0D
-=0D
- #=0D
- # Defines for default states. These can be changed on the command line.=
=0D
- # -D FLAG=3DVALUE=0D
- #=0D
- DEFINE SECURE_BOOT_ENABLE =3D FALSE=0D
- DEFINE INCLUDE_TFTP_COMMAND =3D FALSE=0D
- DEFINE DEBUG_PRINT_ERROR_LEVEL =3D 0x8000004F=0D
-=0D
-!ifndef TFA_BUILD_ARTIFACTS=0D
- #=0D
- # Default TF-A binary checked into edk2-non-osi.=0D
- #=0D
- DEFINE TFA_BUILD_BL31 =3D Platform/RaspberryPi/$(PLATFORM_NAME)/TrustedF=
irmware/bl31.bin=0D
-!else=0D
- #=0D
- # Usually we use the checked-in binaries, but for developers working=0D
- # on the firmware, being able to use a local TF-A build without extra co=
py=0D
- # operations ends up being very helpful.=0D
- #=0D
- DEFINE TFA_BUILD_BL31 =3D $(TFA_BUILD_ARTIFACTS)/bl31.bin=0D
-!endif=0D
-=0D
-##########################################################################=
######=0D
-#=0D
-# Library Class section - list of all Library Classes needed by this Platf=
orm.=0D
-#=0D
-##########################################################################=
######=0D
-=0D
-!include MdePkg/MdeLibs.dsc.inc=0D
-=0D
-[LibraryClasses.common]=0D
-!if $(TARGET) =3D=3D RELEASE=0D
- DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf=0D
-!else=0D
- DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.in=
f=0D
-!endif=0D
- DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseD=
ebugPrintErrorLevelLib.inf=0D
-=0D
- BaseLib|MdePkg/Library/BaseLib/BaseLib.inf=0D
- SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf=0D
- BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i=
nf=0D
- SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniza=
tionLib.inf=0D
- PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibN=
ull.inf=0D
- ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseRepor=
tStatusCodeLibNull.inf=0D
- PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf=0D
- PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeC=
offGetEntryPointLib.inf=0D
- PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf=0D
- IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf=0D
- UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompres=
sLib.inf=0D
- CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf=0D
-=0D
- UefiLib|MdePkg/Library/UefiLib/UefiLib.inf=0D
- HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf=0D
- UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/U=
efiRuntimeServicesTableLib.inf=0D
- DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf=0D
- UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBoo=
tServicesTableLib.inf=0D
- DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableL=
ib.inf=0D
- DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf=0D
- UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry=
Point.inf=0D
- UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiA=
pplicationEntryPoint.inf=0D
- HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf=0D
- UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServic=
esLib.inf=0D
- SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf=0D
-=0D
- UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf=0D
- OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib=
/BaseOrderedCollectionRedBlackTreeLib.inf=0D
-=0D
- #=0D
- # Ramdisk Requirements=0D
- #=0D
- FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf=
=0D
-=0D
- # Allow dynamic PCDs=0D
- #=0D
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf=0D
-=0D
- # use the accelerated BaseMemoryLibOptDxe by default, overrides for SEC/=
PEI below=0D
- BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf=
=0D
-=0D
- #=0D
- # It is not possible to prevent the ARM compiler from inserting calls to=
intrinsic functions.=0D
- # This library provides the instrinsic functions such a compiler may gen=
erate calls to.=0D
- #=0D
- NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf=0D
-=0D
- # Add support for GCC stack protector=0D
- NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf=0D
-=0D
- # ARM Architectural Libraries=0D
- CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMainte=
nanceLib.inf=0D
- DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/Def=
aultExceptionHandlerLib.inf=0D
- CpuExceptionHandlerLib|ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.in=
f=0D
- ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.=
inf=0D
- ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf=0D
- ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf=0D
- DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf=0D
- TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf=0D
- ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatfo=
rmStackLib.inf=0D
- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf=0D
- ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf=0D
- ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/Ar=
mGenericTimerPhyCounterLib.inf=0D
-=0D
- # Dual serial port library=0D
- PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartCloc=
kLib.inf=0D
- PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf=0D
- SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DebugDualSe=
rialPortLib.inf=0D
-=0D
- # Cryptographic libraries=0D
- RngLib|MdePkg/Library/DxeRngLib/DxeRngLib.inf=0D
- IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf=0D
- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf=0D
- OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf=0D
- TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf=0D
-=0D
- #=0D
- # Uncomment (and comment out the next line) For RealView Debugger. The S=
tandard IO window=0D
- # in the debugger will show load and unload commands for symbols. You ca=
n cut and paste this=0D
- # into the command window to load symbols. We should be able to use a sc=
ript to do this, but=0D
- # the version of RVD I have does not support scripts accessing system me=
mory.=0D
- #=0D
- #PeCoffExtraActionLib|ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffEx=
traActionLib.inf=0D
- PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCof=
fExtraActionLib.inf=0D
- #PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePe=
CoffExtraActionLibNull.inf=0D
-=0D
- DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.i=
nf=0D
- DebugAgentTimerLib|EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgent=
TimerLibNull.inf=0D
-=0D
- # Flattened Device Tree (FDT) access library=0D
- FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf=0D
-=0D
- # USB Libraries=0D
- UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf=0D
-=0D
- #=0D
- # Secure Boot dependencies=0D
- #=0D
-!if $(SECURE_BOOT_ENABLE) =3D=3D TRUE=0D
- TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasure=
mentLib.inf=0D
- AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf=
=0D
-=0D
- # re-use the UserPhysicalPresent() dummy implementation from the ovmf tr=
ee=0D
- PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.in=
f=0D
-!else=0D
- TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurem=
entLibNull.inf=0D
- AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLib=
Null.inf=0D
-!endif=0D
- VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf=0D
- VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyL=
ib.inf=0D
- VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Var=
iablePolicyHelperLib.inf=0D
- GpioLib|Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.inf=0D
-=0D
- #=0D
- # PCI dependencies=0D
- #=0D
- # PCI root port configuation and description=0D
- PciHostBridgeLib|Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciHostBridgeLi=
b/Bcm2711PciHostBridgeLib.inf=0D
- # The "segment lib" provides the CAM accessors/etc when they aren't ECAM=
standard=0D
- PciSegmentLib|Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciS=
egmentLib.inf=0D
-=0D
-[LibraryClasses.common.SEC]=0D
- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf=0D
- BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf=0D
- MemoryInitPeiLib|Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryIni=
tPeiLib.inf=0D
- PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf=0D
- ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib=
/PrePiExtractGuidedSectionLib.inf=0D
- LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCusto=
mDecompressLib.inf=0D
- PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf=0D
- HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf=0D
- PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/Pre=
PiHobListPointerLib.inf=0D
- MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMe=
moryAllocationLib.inf=0D
-=0D
-[LibraryClasses.common.DXE_CORE]=0D
- HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf=0D
- MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeC=
oreMemoryAllocationLib.inf=0D
- DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf=
=0D
- ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExt=
ractGuidedSectionLib.inf=0D
- PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerform=
anceLib.inf=0D
-=0D
-[LibraryClasses.common.DXE_DRIVER]=0D
- SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeS=
ecurityManagementLib.inf=0D
- PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.=
inf=0D
- MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll=
ocationLib.inf=0D
-!if $(INCLUDE_TFTP_COMMAND) =3D=3D TRUE=0D
- ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf=0D
- FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf=0D
-!endif=0D
-=0D
-[LibraryClasses.common.UEFI_APPLICATION]=0D
- PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.=
inf=0D
- MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll=
ocationLib.inf=0D
- HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf=0D
- ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf=0D
- FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf=0D
-=0D
-[LibraryClasses.common.UEFI_DRIVER]=0D
- ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExt=
ractGuidedSectionLib.inf=0D
- PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.=
inf=0D
- MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll=
ocationLib.inf=0D
-=0D
-[LibraryClasses.common.DXE_RUNTIME_DRIVER]=0D
- # Runtime debug messages may crash an OS unless serial output to MMIO ma=
pped UARTs is inhibited=0D
- DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibS=
erialPort.inf=0D
- MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll=
ocationLib.inf=0D
- CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf=
=0D
- EfiResetSystemLib|Platform/RaspberryPi/Library/ResetLib/ResetLib.inf=0D
- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf=0D
- VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyL=
ibRuntimeDxe.inf=0D
-=0D
-!if $(SECURE_BOOT_ENABLE) =3D=3D TRUE=0D
- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf=0D
-!endif=0D
-=0D
-##########################################################################=
#########################=0D
-# BuildOptions Section - Define the module specific tool chain flags that =
should be used as=0D
-# the default flags for a module. These flags are a=
ppended to any=0D
-# standard flags that are defined by the build proc=
ess.=0D
-##########################################################################=
#########################=0D
-=0D
-[BuildOptions]=0D
- GCC:*_*_*_CC_FLAGS =3D -DRPI_MODEL=3D4=0D
- GCC:*_*_*_PP_FLAGS =3D -DRPI_MODEL=3D4=0D
- GCC:*_*_*_ASLPP_FLAGS =3D -DRPI_MODEL=3D4=0D
- GCC:*_*_*_ASLCC_FLAGS =3D -DRPI_MODEL=3D4=0D
- GCC:*_*_*_VFRPP_FLAGS =3D -DRPI_MODEL=3D4=0D
- GCC:RELEASE_*_*_CC_FLAGS =3D -DMDEPKG_NDEBUG -DNDEBUG=0D
-=0D
-[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]=0D
- GCC:*_*_AARCH64_DLINK_FLAGS =3D -z common-page-size=3D0x10000=0D
-=0D
-##########################################################################=
######=0D
-#=0D
-# Pcd Section - list of all EDK II PCD Entries defined by this Platform=0D
-#=0D
-##########################################################################=
######=0D
-=0D
-[PcdsFeatureFlag.common]=0D
- # Use the Vector Table location in CpuDxe. We will not copy the Vector T=
able at PcdCpuVectorBaseAddress=0D
- gArmTokenSpaceGuid.PcdRelocateVectorTable|FALSE=0D
-=0D
- gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|TRUE=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE=0D
-=0D
- ## If TRUE, Graphics Output Protocol will be installed on virtual handle=
created by ConsplitterDxe.=0D
- # It could be set FALSE to save size.=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE=0D
- gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|FALSE=0D
-=0D
-[PcdsFixedAtBuild.common]=0D
- gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000=0D
- gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000=0D
- gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000=0D
- gEfiMdePkgTokenSpaceGuid.PcdSpinLockTimeout|10000000=0D
- gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue|0xAF=0D
- gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|1=0D
- gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0=0D
- gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320=0D
-=0D
- # DEBUG_ASSERT_ENABLED 0x01=0D
- # DEBUG_PRINT_ENABLED 0x02=0D
- # DEBUG_CODE_ENABLED 0x04=0D
- # CLEAR_MEMORY_ENABLED 0x08=0D
- # ASSERT_BREAKPOINT_ENABLED 0x10=0D
- # ASSERT_DEADLOOP_ENABLED 0x20=0D
-!if $(TARGET) =3D=3D RELEASE=0D
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x21=0D
-!else=0D
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2f=0D
-!endif=0D
-=0D
- # DEBUG_INIT 0x00000001 // Initialization=0D
- # DEBUG_WARN 0x00000002 // Warnings=0D
- # DEBUG_LOAD 0x00000004 // Load events=0D
- # DEBUG_FS 0x00000008 // EFI File system=0D
- # DEBUG_POOL 0x00000010 // Alloc & Free (pool)=0D
- # DEBUG_PAGE 0x00000020 // Alloc & Free (page)=0D
- # DEBUG_INFO 0x00000040 // Informational debug messages=0D
- # DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers=0D
- # DEBUG_VARIABLE 0x00000100 // Variable=0D
- # DEBUG_BM 0x00000400 // Boot Manager=0D
- # DEBUG_BLKIO 0x00001000 // BlkIo Driver=0D
- # DEBUG_NET 0x00004000 // SNP Driver=0D
- # DEBUG_UNDI 0x00010000 // UNDI Driver=0D
- # DEBUG_LOADFILE 0x00020000 // LoadFile=0D
- # DEBUG_EVENT 0x00080000 // Event messages=0D
- # DEBUG_GCD 0x00100000 // Global Coherency Database changes=0D
- # DEBUG_CACHE 0x00200000 // Memory range cachability changes=0D
- # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may=0D
- # // significantly impact boot performance=
=0D
- # DEBUG_ERROR 0x80000000 // Error=0D
- gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|$(DEBUG_PRINT_ERROR_LEV=
EL)=0D
-=0D
- gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07=0D
-=0D
- #=0D
- # Optional feature to help prevent EFI memory map fragments=0D
- # Turned on and off via: PcdPrePiProduceMemoryTypeInformationHob=0D
- # Values are in EFI Pages (4K). DXE Core will make sure that=0D
- # at least this much of each type of memory can be allocated=0D
- # from a single memory range. This way you only end up with=0D
- # maximum of two fragments for each type in the memory map=0D
- # (the memory used, and the free memory that was prereserved=0D
- # but not used).=0D
- #=0D
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0=0D
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0=0D
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0=0D
-!if $(SECURE_BOOT_ENABLE) =3D=3D TRUE=0D
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|600=0D
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|400=0D
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|1500=0D
-!else=0D
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|300=0D
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|150=0D
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|1000=0D
-!endif=0D
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData|12000=0D
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|20=0D
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0=0D
-=0D
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0xc0000000=0D
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xffffffff=0D
-=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"EDK2-DEV"=0D
-=0D
-!if $(SECURE_BOOT_ENABLE) =3D=3D TRUE=0D
- # override the default values from SecurityPkg to ensure images from all=
sources are verified in secure boot=0D
- gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x04=0D
- gEfiSecurityPkgTokenSpaceGuid.PcdFixedMediaImageVerificationPolicy|0x04=
=0D
- gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolicy|0=
x04=0D
-!endif=0D
-=0D
- gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE=0D
-=0D
- # Default platform supported RFC 4646 languages: (American) English=0D
- gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLangCodes|"en-US"=
=0D
-=0D
-[LibraryClasses.common]=0D
- ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf=0D
- ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf=0D
- ArmPlatformLib|Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf=
=0D
- TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf=0D
- CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf=
=0D
- UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManag=
erLib.inf=0D
- BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf=0D
- PlatformBootManagerLib|Platform/RaspberryPi/Library/PlatformBootManagerL=
ib/PlatformBootManagerLib.inf=0D
- CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/Customize=
dDisplayLib.inf=0D
- FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf=
=0D
- AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf=0D
-=0D
-[LibraryClasses.common.UEFI_DRIVER]=0D
- UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf=0D
-=0D
-##########################################################################=
######=0D
-#=0D
-# Pcd Section - list of all EDK II PCD Entries defined by this Platform=0D
-#=0D
-##########################################################################=
######=0D
-=0D
-[PcdsFeatureFlag.common]=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE=0D
-=0D
-[PcdsFixedAtBuild.common]=0D
- gArmPlatformTokenSpaceGuid.PcdCoreCount|4=0D
- gArmTokenSpaceGuid.PcdVFPEnabled|1=0D
-=0D
- gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x4000=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800=0D
-=0D
- # Size of the region used by UEFI in permanent memory (Reserved 64MB)=0D
- gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000=0D
- #=0D
- # 0x00000000 - 0x001F0000 FD (PcdFdBaseAddress, PcdFdSize)=0D
- # 0x001F0000 - 0x00200000 DTB (PcdFdtBaseAddress, PcdFdtSize)=0D
- # 0x00200000 - ... RAM (PcdSystemMemoryBase, PcdSystemMemorySize)=
=0D
- #=0D
- # This matches PcdFvBaseAddress, since everything less is the FD, and=0D
- # will be reserved away.=0D
- #=0D
- gArmTokenSpaceGuid.PcdSystemMemoryBase|0x00200000=0D
- gArmTokenSpaceGuid.PcdSystemMemorySize|0x3fe00000=0D
-=0D
- #=0D
- # Device specific addresses=0D
- #=0D
- gBcm27xxTokenSpaceGuid.PcdBcm27xxRegistersAddress|0xfc000000=0D
- gBcm27xxTokenSpaceGuid.PcdBcmGenetRegistersAddress|0xfd580000=0D
- gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress|0xfe000000=0D
-=0D
- # PCIe specific addresses=0D
- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciRegBase|0xfd500000=0D
- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioAdr|0xf8000000=0D
- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioLen|0x3ffffff=0D
- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr|0x600000000=0D
-=0D
- # UARTs=0D
- gArmPlatformTokenSpaceGuid.PL011UartInteger|0=0D
- gArmPlatformTokenSpaceGuid.PL011UartFractional|0=0D
- gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1000000000=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8=0D
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200=0D
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0=0D
-=0D
- #=0D
- # ARM General Interrupt Controller=0D
- #=0D
- gArmTokenSpaceGuid.PcdGicDistributorBase|0xFF841000=0D
- gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0xFF842000=0D
- gRaspberryPiTokenSpaceGuid.PcdGicInterruptInterfaceHBase|0xFF844000=0D
- gRaspberryPiTokenSpaceGuid.PcdGicInterruptInterfaceVBase|0xFF846000=0D
- gRaspberryPiTokenSpaceGuid.PcdGicGsivId|0x19=0D
- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq0|0x30=0D
- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq1|0x31=0D
- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq2|0x32=0D
- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq3|0x33=0D
-=0D
- #=0D
- # Fixed CPU settings.=0D
- #=0D
- gRaspberryPiTokenSpaceGuid.PcdCpuLowSpeedMHz|800=0D
- gRaspberryPiTokenSpaceGuid.PcdCpuDefSpeedMHz|1500=0D
- gRaspberryPiTokenSpaceGuid.PcdCpuMaxSpeedMHz|2200=0D
-=0D
- ## Default Terminal Type=0D
- ## 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM=0D
- gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4=0D
-=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FAL=
SE=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c=
, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0=
x31 }=0D
-=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2"=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE=0D
-=0D
-[PcdsDynamicHii.common.DEFAULT]=0D
-=0D
- #=0D
- # Clock overrides.=0D
- #=0D
-=0D
- gRaspberryPiTokenSpaceGuid.PcdCpuClock|L"CpuClock"|gConfigDxeFormSetGuid=
|0x0|1=0D
- gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|L"CustomCpuClock"|gConfigDx=
eFormSetGuid|0x0|gRaspberryPiTokenSpaceGuid.PcdCpuDefSpeedMHz=0D
-=0D
- #=0D
- # SD-related.=0D
- #=0D
-=0D
- gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|L"SdIsArasan"|gConfigDxeFormSet=
Guid|0x0|0=0D
- gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|L"MmcForce1Bit"|gConfigDxeFor=
mSetGuid|0x0|0=0D
- gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|L"MmcForceDefaultSpee=
d"|gConfigDxeFormSetGuid|0x0|0=0D
- gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMH=
z"|gConfigDxeFormSetGuid|0x0|25=0D
- gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpeedMHz"|gCo=
nfigDxeFormSetGuid|0x0|50=0D
- gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gConfig=
DxeFormSetGuid|0x0|0=0D
- gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gConfigDxeFor=
mSetGuid|0x0|0=0D
-=0D
- #=0D
- # Debug-related.=0D
- #=0D
-=0D
- gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|L"DebugEnableJTAG"|gConfig=
DxeFormSetGuid|0x0|0=0D
-=0D
- #=0D
- # Display-related.=0D
- #=0D
-=0D
- #=0D
- # Just enable native resolution by default.=0D
- #=0D
- gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes|L"DisplayEnableS=
caledVModes"|gConfigDxeFormSetGuid|0x0|0x20=0D
- gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot|L"DisplayEnableSShot"|g=
ConfigDxeFormSetGuid|0x0|1=0D
-=0D
- #=0D
- # Supporting > 3GB of memory.=0D
- #=0D
- gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB|L"RamMoreThan3GB"|gConfigDx=
eFormSetGuid|0x0|0=0D
- gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB|L"RamLimitTo3GB"|gConfigDxeF=
ormSetGuid|0x0|1=0D
-=0D
- #=0D
- # Device Tree and ACPI selection.=0D
- #=0D
- # 0 - SYSTEM_TABLE_MODE_ACPI (default)=0D
- # 1 - SYSTEM_TABLE_MODE_BOTH=0D
- # 2 - SYSTEM_TABLE_MODE_DT=0D
- #=0D
- gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|L"SystemTableMode"|gConfig=
DxeFormSetGuid|0x0|0=0D
-=0D
- #=0D
- # Enable a fan in the ACPI thermal zone on GPIO pin #=0D
- #=0D
- # 0 - DISABLED=0D
- # 19 - Enabled on pin 19=0D
- #=0D
- gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFormSetGu=
id|0x0|0=0D
- gRaspberryPiTokenSpaceGuid.PcdFanTemp|L"FanTemp"|gConfigDxeFormSetGuid|0=
x0|60=0D
-=0D
- #=0D
- # Reset-related.=0D
- #=0D
-=0D
- gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|L"ResetDelay"|gRaspberr=
yPiTokenSpaceGuid|0x0|0=0D
-=0D
- #=0D
- # Common UEFI ones.=0D
- #=0D
-=0D
- gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVar=
iableGuid|0x0|5=0D
- #=0D
- # This is silly, but by pointing SetupConXXX and ConXXX PCDs to=0D
- # the same variables, I can use the graphical configuration to=0D
- # change the mode used by ConSplitter.=0D
- #=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn|L"Columns"|gRaspberr=
yPiTokenSpaceGuid|0x0|80=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Columns"|gRaspberryPiTo=
kenSpaceGuid|0x0|80=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|L"Rows"|gRaspberryPiTok=
enSpaceGuid|0x0|25=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|L"Rows"|gRaspberryPiTokenSpa=
ceGuid|0x0|25=0D
-=0D
-[PcdsDynamicDefault.common]=0D
- #=0D
- # Set video resolution for boot options and for text setup.=0D
- #=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0=0D
-=0D
-##########################################################################=
######=0D
-#=0D
-# Components Section - list of all EDK II Modules needed by this Platform=
=0D
-#=0D
-##########################################################################=
######=0D
-[Components.common]=0D
- #=0D
- # PEI Phase modules=0D
- #=0D
- ArmPlatformPkg/PrePi/PeiUniCore.inf {=0D
- <LibraryClasses>=0D
- SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSer=
ialPortLib.inf=0D
- }=0D
-=0D
- #=0D
- # DXE=0D
- #=0D
- MdeModulePkg/Core/Dxe/DxeMain.inf {=0D
- <LibraryClasses>=0D
- NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32Gu=
idedSectionExtractLib.inf=0D
- }=0D
- MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {=0D
- <LibraryClasses>=0D
- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf=0D
- }=0D
-=0D
- #=0D
- # Architectural Protocols=0D
- #=0D
- ArmPkg/Drivers/CpuDxe/CpuDxe.inf=0D
- MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf=0D
- Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf=0D
- MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf=0D
- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {=0D
- <LibraryClasses>=0D
- NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf=0D
- DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf=0D
- }=0D
-!if $(SECURE_BOOT_ENABLE) =3D=3D TRUE=0D
- MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {=0D
- <LibraryClasses>=0D
- NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificatio=
nLib.inf=0D
- }=0D
- SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDx=
e.inf=0D
-!else=0D
- MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf=0D
-!endif=0D
- MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf=0D
- MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim=
eDxe.inf=0D
- EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf=0D
- EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf {=0D
- <LibraryClasses>=0D
- RealTimeClockLib|EmbeddedPkg/Library/VirtualRealTimeClockLib/Virtual=
RealTimeClockLib.inf=0D
- }=0D
- EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf=0D
-=0D
- MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf=0D
- MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf=0D
- MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf=
=0D
- MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf=0D
- MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {=0D
- <LibraryClasses>=0D
- SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSer=
ialPortLib.inf=0D
- }=0D
- Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf=0D
- EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf=0D
-=0D
- MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf=0D
-=0D
- ArmPkg/Drivers/ArmGic/ArmGicDxe.inf=0D
- Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf=0D
- Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf=0D
- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf=0D
- ArmPkg/Drivers/TimerDxe/TimerDxe.inf=0D
- MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf=0D
- MdeModulePkg/Universal/EbcDxe/EbcDxe.inf=0D
-=0D
- #=0D
- # FAT filesystem + GPT/MBR partitioning=0D
- #=0D
- MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf=0D
- MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf=0D
- MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf=0D
- FatPkg/EnhancedFatDxe/Fat.inf=0D
-=0D
- #=0D
- # ACPI Support=0D
- #=0D
- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf=0D
- MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsRes=
ourceTableDxe.inf=0D
- Platform/RaspberryPi/AcpiTables/AcpiTables.inf=0D
-=0D
- #=0D
- # SMBIOS Support=0D
- #=0D
- Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf=0D
- MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf=0D
-=0D
- #=0D
- # RAM Disk Support=0D
- #=0D
- MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf=0D
-=0D
- #=0D
- # Bds=0D
- #=0D
- MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf=0D
- MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf=0D
- MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf=0D
- MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf=
=0D
- MdeModulePkg/Universal/BdsDxe/BdsDxe.inf=0D
- Platform/RaspberryPi/Drivers/LogoDxe/LogoDxe.inf=0D
- MdeModulePkg/Application/UiApp/UiApp.inf {=0D
- <LibraryClasses>=0D
- NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf=
=0D
- NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf=0D
- NULL|Platform/RaspberryPi/Library/PlatformUiAppLib/PlatformUiAppLib.=
inf=0D
- NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanc=
eManagerUiLib.inf=0D
- }=0D
-=0D
- #=0D
- # SCSI Bus and Disk Driver=0D
- #=0D
- MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf=0D
- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf=0D
-=0D
- #=0D
- # USB Support=0D
- #=0D
- MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf=0D
- Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf=0D
- MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf=0D
- MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf=0D
- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf=0D
-=0D
- #=0D
- # SD/MMC support=0D
- #=0D
- # Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.inf=0D
- Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf=0D
- Platform/RaspberryPi/Drivers/MmcDxe/MmcDxe.inf=0D
-=0D
- #=0D
- # Networking stack=0D
- #=0D
-!include NetworkPkg/Network.dsc.inc=0D
- Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf {=0D
- <PcdsFixedAtBuild>=0D
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x00000000=0D
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xffffffff=0D
- }=0D
-=0D
- #=0D
- # RNG=0D
- #=0D
- Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf=0D
-=0D
- #=0D
- # PCI Support=0D
- #=0D
- ArmPkg/Drivers/ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf=0D
- MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf=0D
- MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf=0D
- EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.inf {=0D
- <PcdsFixedAtBuild>=0D
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x00000000=0D
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xbfffffff=0D
- }=0D
-=0D
- #=0D
- # UEFI application (Shell Embedded Boot Loader)=0D
- #=0D
- ShellPkg/Application/Shell/Shell.inf {=0D
- <LibraryClasses>=0D
- ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellComman=
dLib.inf=0D
- NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Comm=
andsLib.inf=0D
- NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1Comm=
andsLib.inf=0D
- NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3Comm=
andsLib.inf=0D
- NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Co=
mmandsLib.inf=0D
- NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comm=
andsLib.inf=0D
- NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1=
CommandsLib.inf=0D
- NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1=
CommandsLib.inf=0D
- NULL|ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewC=
ommandLib.inf=0D
- HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandlePar=
singLib.inf=0D
- PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf=0D
- BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcf=
gCommandLib.inf=0D
-=0D
- <PcdsFixedAtBuild>=0D
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF=0D
- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE=0D
- gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000=0D
- gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x200000=0D
- }=0D
-!if $(INCLUDE_TFTP_COMMAND) =3D=3D TRUE=0D
- ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf {=0D
- <PcdsFixedAtBuild>=0D
- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE=0D
- }=0D
-!endif=0D
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc.rej b/Platform/RaspberryPi/=
RPi4/RPi4.dsc.rej
deleted file mode 100644
index 0b40df6896..0000000000
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc.rej
+++ /dev/null
@@ -1,29 +0,0 @@
---- Platform/RaspberryPi/RPi4/RPi4.dsc
-+++ Platform/RaspberryPi/RPi4/RPi4.dsc
-@@ -429,7 +429,6 @@ [PcdsFixedAtBuild.common]
- gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4
-- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1000000000
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
-@@ -465,6 +464,9 @@ [PcdsFixedAtBuild.common]
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2"
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
-=20
-+[PcdsPatchableInModule]
-+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|500000000
-+
- [PcdsDynamicHii.common.DEFAULT]
-=20
- #
-@@ -621,7 +623,7 @@ [Components.common]
- MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
- MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {
- <LibraryClasses>
-- SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSe=
rialPortLib.inf
-+ SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSe=
rialPortDxeLib.inf
- }
- Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf
- EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf
--=20
2.29.0


[PATCH v2] UefiCpuPkg/CpuCacheInfoLib: Correct logical for identifying cache type

Jason Lou
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3265

Correct the logical for identifying "Direct mapped" cache type.

Signed-off-by: Jason Lou <yun.lou@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
---
UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c b/UefiCpu=
Pkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c
index ae81ea9ce2..c0077d6770 100644
--- a/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c
+++ b/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c
@@ -237,7 +237,7 @@ CpuCacheInfoCollectCoreAndCacheData (
CacheData[CacheParamLeafIndex].CacheType =3D (UINT8)CacheP=
aramEax.Bits.CacheType;=0D
CacheData[CacheParamLeafIndex].CacheWays =3D (UINT16)Cache=
ParamEbx.Bits.Ways;=0D
CacheData[CacheParamLeafIndex].FullyAssociativeCache =3D (UINT8)CacheP=
aramEax.Bits.FullyAssociativeCache;=0D
- CacheData[CacheParamLeafIndex].DirectMappedCache =3D (UINT8)CacheP=
aramEdx.Bits.ComplexCacheIndexing;=0D
+ CacheData[CacheParamLeafIndex].DirectMappedCache =3D (UINT8)(Cache=
ParamEdx.Bits.ComplexCacheIndexing =3D=3D 0);=0D
CacheData[CacheParamLeafIndex].CacheShareBits =3D (UINT16)Cache=
ParamEax.Bits.MaximumAddressableIdsForLogicalProcessors;=0D
CacheData[CacheParamLeafIndex].CacheSizeinKB =3D (CacheParamEb=
x.Bits.Ways + 1) *=0D
(CacheParamEbx.Bits.LinePartitions + 1) * (CacheParamEbx.Bits.Line=
Size + 1) * (CacheParamEcx + 1) / SIZE_1KB;=0D
--=20
2.28.0.windows.1


Bug #3522 patch

jameswang@...
 

Hi,

 

Refer to: Bug #3522

 

There is a problem in RegisterStaticHotkey() of BoardBootOption.c that it still RegisterBootOptionHotkey() for F7 key on Boot0000 if mBootMenuOptionNumber is not assigned.

 

mBootMenuOptionNumber is not assigned (LoadOptionNumberUnassigned) because error happened in RegisterFvBootOption().

 

I think we need to check if mBootMenuOptionNumber valid before registering F7.  I have provided a simple patch as attached.

 

-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


Re: [2021-gsoc-llvm-gnumake]: proposal for building using llvm/gnumake

Steven Shi
 

Liming,

The MSVC is required only because the Windows SDK Universal C runtime (UCRT) library depends on the MSVC.  Please see the dependency description here: “When you install Visual C++, Visual Studio setup installs the subset of the Windows 10 SDK required to use the UCRT.” https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-160.

 

If the MSVC is not installed, the ucrt will complain cannot find the msvc header files. Below is an example:

C:\Program Files\LLVM\bin\clang  -c  -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/ -I "" -MD -fshort-wchar -fno-strict-aliasing -fwrapv -fno-delete-null-pointer-checks -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -Wno-unused-function -g -m32 -O2  BasePeCoff.c -o BasePeCoff.o

In file included from BasePeCoff.c:13:

In file included from ../Common\CommonLib.h:14:

In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\assert.h:12:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\corecrt.h:10:10: fatal error: 'vcruntime.h' file not

      found

#include <vcruntime.h>

         ^~~~~~~~~~~~~

1 error generated.

 

 

 

BTW, the compiler dependency requirement also exists in Linux side. Below is the Linux GCC CRT library example. Although I build with clang, it still needs link the crt libraries in GCC installation. Below is an example:

$ /home/jshi19/llvm/clang+llvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang -o ../bin/LzmaCompress   LzmaCompress.o Sdk/C/Alloc.o Sdk/C/LzFind.o Sdk/C/LzmaDec.o Sdk/C/LzmaEnc.o Sdk/C/7zFile.o Sdk/C/7zStream.o Sdk/C/Bra86.o -L../libs -lCommon -###

clang version 11.0.0 (https://github.com/llvm/llvm-project.git 0160ad802e899c2922bc9b29564080c22eb0908c)

Target: x86_64-unknown-linux-gnu

Thread model: posix

InstalledDir: /home/jshi19/llvm/clang+llvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04/bin

"/usr/bin/ld" "-z" "relro" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "../bin/LzmaCompress" "/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crt1.o" "/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crti.o" "/usr/lib/gcc/x86_64-linux-gnu/10/crtbegin.o" "-L../libs" "-L/usr/lib/gcc/x86_64-linux-gnu/10" "-L/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/lib/../lib64" "-L/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu" "-L/lib/x86_64-linux-gnu" "-L/lib/../lib64" "-L/usr/lib/x86_64-linux-gnu" "-L/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/lib" "-L/usr/lib/gcc/x86_64-linux-gnu/10/../../.." "-L/home/jshi19/llvm/clang+llvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/../lib" "-L/lib" "-L/usr/lib" "LzmaCompress.o" "Sdk/C/Alloc.o" "Sdk/C/LzFind.o" "Sdk/C/LzmaDec.o" "Sdk/C/LzmaEnc.o" "Sdk/C/7zFile.o" "Sdk/C/7zStream.o" "Sdk/C/Bra86.o" "-lCommon" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/gcc/x86_64-linux-gnu/10/crtend.o" "/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crtn.o"

 

 

 

 

Thanks

 

Steven Shi

Intel\SATG\SFP\FIA (Firmware Infrastructure Automation)

 

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of gaoliming
Sent: Friday, August 13, 2021 9:18 AM
To: devel@edk2.groups.io; yuqi.chen@...
Subject: 回复: [edk2-devel] [2021-gsoc-llvm-gnumake]: proposal for building using llvm/gnumake

 

Yuqi:

 On Windows, can Clang + make combination drop the dependency of Visual studio? If I dont install Visual studio 2015 or 2017, I only install LLVM, can I fully compile BaseTools and Edk2 code?

 

Thanks

Liming

发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Yuqi Chen
发送时间: 2021812 9:52
收件人: devel@edk2.groups.io
主题: [edk2-devel] [2021-gsoc-llvm-gnumake]: proposal for building using llvm/gnumake

 

Hi,

 

I want to push my change to my codes to edk2-staging, yet it seems like I don’t have permission to do so:

 

My mentor and I have enabled edk2 building using llvm+make and gnumake+clang in windows command prompt. The attached patch indicates changes we made to make this happen.

 

I also attach the readme file to go through the steps to build Basetools.

 

Please review our codes and thank you very much for your time.

 

Best regards,

Yuqi

 


Re: [PATCH v1] UefiCpuPkg/CpuCacheInfoLib: Correct logical for identifying cache type

Jason Lou
 

Sure, I will change it in next version patch.


Re: [PATCH v4 0/6] Ovmf: Disable the TPM2 platform hierarchy

Stefan Berger
 

Yao,

  do you have any comments on this series? Would SecurityPkg be a better place for it?


    Stefan

On 8/12/21 12:59 PM, Stefan Berger wrote:
This series imports code from the edk2-platforms project related to
changing the password of the TPM2 platform hierarchy and uses it to
disable the TPM2 platform hierarchy in Ovmf and ArmVirtPkg. It
addresses the Ovmf aspects of the following bugs:

https://bugzilla.tianocore.org/show_bug.cgi?id=3510
https://bugzilla.tianocore.org/show_bug.cgi?id=3499

I have patched the .dsc files and successfully test-built with most of
them. Some I could not build because they failed for other reasons
unrelated to this series.

I tested the changes with QEMU on x86 following the build of
ArmVirtQemu.dsc and OvmfPkgX64.dsc.

The disablement of the platform hierarchy is done after possibly
handling PPI. Following TPM 2 logs on Arm, only PCR extensions are
following afterwards until GRUB takes over.

Neither one of the following commands should work anymore on first
try:

With IBM tss2 tools:
tsshierarchychangeauth -hi p -pwdn newpass

With Intel tss2 tools:
tpm2_changeauth -c platform newpass

Regards,
Stefan

v4:
- Fixed and simplified code imported from edk2-platforms

v3:
- Referencing Null implementation on Bhyve and Xen platforms
- Add support in ArmVirtPkg

Stefan Berger (6):
OvmfPkg/TPM: Import PeiDxeTpmPlatformHierarchyLib.c from
edk2-platforms
OvmfPkg/TPM: Add a NULL implementation of TpmPlatformHierarchyLib
OvmfPkg: Reference new TPM classes in the build system for compilation
OvmfPkg: Disable the TPM2 platform hierarchy
ArmVirtPkg: Reference new TPM classes in the build system for
compilation
ArmVirtPkg: Disable the TPM2 platform hierarchy

ArmVirtPkg/ArmVirtCloudHv.dsc | 1 +
ArmVirtPkg/ArmVirtQemu.dsc | 3 +
ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 +
ArmVirtPkg/ArmVirtXen.dsc | 1 +
.../PlatformBootManagerLib/PlatformBm.c | 6 +
.../PlatformBootManagerLib.inf | 1 +
OvmfPkg/AmdSev/AmdSevX64.dsc | 3 +
OvmfPkg/Bhyve/BhyveX64.dsc | 1 +
.../Include/Library/TpmPlatformHierarchyLib.h | 27 +++
.../PeiDxeTpmPlatformHierarchyLib.c | 200 ++++++++++++++++++
.../PeiDxeTpmPlatformHierarchyLib.inf | 40 ++++
.../PeiDxeTpmPlatformHierarchyLib.c | 19 ++
.../PeiDxeTpmPlatformHierarchyLib.inf | 31 +++
.../PlatformBootManagerLib/BdsPlatform.c | 6 +
.../PlatformBootManagerLib.inf | 1 +
.../PlatformBootManagerLibBhyve/BdsPlatform.c | 7 +
.../PlatformBootManagerLibGrub/BdsPlatform.c | 7 +
OvmfPkg/OvmfPkgIa32.dsc | 3 +
OvmfPkg/OvmfPkgIa32X64.dsc | 3 +
OvmfPkg/OvmfPkgX64.dsc | 3 +
OvmfPkg/OvmfXen.dsc | 1 +
21 files changed, 365 insertions(+)
create mode 100644 OvmfPkg/Include/Library/TpmPlatformHierarchyLib.h
create mode 100644 OvmfPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c
create mode 100644 OvmfPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
create mode 100644 OvmfPkg/Library/PeiDxeTpmPlatformHierarchyLibNull/PeiDxeTpmPlatformHierarchyLib.c
create mode 100644 OvmfPkg/Library/PeiDxeTpmPlatformHierarchyLibNull/PeiDxeTpmPlatformHierarchyLib.inf


Re: [PATCH V2] RedfishClientPkg/ConvertLib: Common code and header files

Nickle Wang
 

Reviewed-by: Nickle Wang <nickle.wang@hpe.com>

Thanks,
Nickle

-----Original Message-----
From: Chang, Abner (HPS SW/FW Technologist) <abner.chang@hpe.com>
Sent: Friday, August 13, 2021 6:22 PM
To: devel@edk2.groups.io
Cc: Wang, Nickle (HPS SW) <nickle.wang@hpe.com>; Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH V2] RedfishClientPkg/ConvertLib: Common code and header files

ConverterLib/ is the folder of script-generated JSON to C library
for the each Redfish schema. The common code and header files in
this patch are used by those libraries.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
.../ConverterLib/include/RedfishCsCommon.h | 125 ++
.../ConverterLib/include/RedfishDataTypeDef.h | 46 +
.../src/RedfishCsMemoryInternal.h | 40 +
.../ConverterLib/src/RedfishCsCommon.c | 1169 +++++++++++++++++
.../ConverterLib/src/RedfishCsMemory.c | 197 +++
5 files changed, 1577 insertions(+)
create mode 100644 RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
create mode 100644 RedfishClientPkg/ConverterLib/include/RedfishDataTypeDef.h
create mode 100644 RedfishClientPkg/ConverterLib/src/RedfishCsMemoryInternal.h
create mode 100644 RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
create mode 100644 RedfishClientPkg/ConverterLib/src/RedfishCsMemory.c

diff --git a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
new file mode 100644
index 0000000000..3084977cdf
--- /dev/null
+++ b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h
@@ -0,0 +1,125 @@
+/** @file
+
+ (C) Copyright 2018-2021 Hewlett Packard Enterprise Development LP<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ Copyright Notice:
+ Copyright 2019-2021 Distributed Management Task Force, Inc. All rights reserved.
+ License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-JSON-C-Struct-Converter/blob/master/LICENSE.md
+**/
+#ifndef REDFISH_CS_COMMON_H_
+#define REDFISH_CS_COMMON_H_
+
+#include "RedfishDataTypeDef.h"
+
+RedfishCS_Link * InitializeLinkHead (RedfishCS_Link *LinkHead);
+RedfishCS_Link * InsertHeadLink (RedfishCS_Link *ListHead, RedfishCS_Link *Entry);
+RedfishCS_Link * InsertTailLink (RedfishCS_Link *ListHead, RedfishCS_Link *Entry);
+RedfishCS_Link * GetFirstLink (const RedfishCS_Link *List);
+RedfishCS_Link * GetLastLink (const RedfishCS_Link *List);
+RedfishCS_Link * GetNextLink (const RedfishCS_Link *List, const RedfishCS_Link *Node);
+RedfishCS_Link * GetPreviousLink ( const RedfishCS_Link *List, const RedfishCS_Link *Node);
+RedfishCS_Link *RemoveLink ( const RedfishCS_Link *Link);
+RedfishCS_bool IsLinkEmpty (const RedfishCS_Link *LinkHead);
+RedfishCS_bool IsLinkAtEnd (const RedfishCS_Link *LinkHead, const RedfishCS_Link *ThisLink);
+RedfishCS_status recordCsRootMemory (void *memCs);
+RedfishCS_status allocateRecordCsMemory (RedfishCS_void *rootCs, RedfishCS_uint32 size, RedfishCS_void **Dst);
+RedfishCS_status allocateRecordCsZeroMemory (RedfishCS_void *rootCs, RedfishCS_uint32 size, RedfishCS_void **Dst);
+RedfishCS_status allocateArrayRecordCsMemory(RedfishCS_void *rootCs, RedfishCS_uint32 ArrayInstanceSize, RedfishCS_uint64 ArraySize, RedfishCS_void **Dst);
+RedfishCS_status allocateDuplicateStr (void *Cs, char *Str, void **DstBuffer);
+RedfishCS_status DestoryCsMemory (RedfishCS_void *rootCs);
+
+typedef struct _RedfishCS_char_Array RedfishCS_char_Array;
+typedef struct _RedfishCS_int64_Array RedfishCS_int64_Array;
+typedef struct _RedfishCS_bool_Array RedfishCS_bool_Array;
+typedef struct _RedfishCS_Link_Array RedfishCS_Link_Array;
+typedef struct _RedfishCS_EmptyProp_KeyValue RedfishCS_EmptyProp_KeyValue;
+
+typedef enum {
+ RedfishCS_Type_CS = 1,
+ RedfishCS_Type_CS_EmptyProp,
+ RedfishCS_Type_JSON,
+ RedfishCS_Type_Uri
+} RedfishCS_Type;
+
+typedef struct _RedfishCS_Header {
+ RedfishCS_Link LinkEntry;
+ RedfishCS_Type ResourceType;
+ RedfishCS_char *KeyName;
+ RedfishCS_char *ThisUri;
+} RedfishCS_Header;
+
+typedef struct _RedfishCS_Type_Uri_Data {
+ RedfishCS_Header Header;
+ RedfishCS_char *Uri;
+} RedfishCS_Type_Uri_Data;
+
+typedef struct _RedfishCS_Type_CS_Data {
+ RedfishCS_Header Header;
+ //
+ // Followed by C structure of resource.
+ //
+} RedfishCS_Type_CS_Data;
+
+typedef struct _RedfishCS_Type_JSON_Data {
+ RedfishCS_Header Header;
+ RedfishCS_char *JsonText;
+} RedfishCS_Type_JSON_Data;
+
+typedef struct _RedfishCS_Number {
+ RedfishCS_uint16 Value;
+ RedfishCS_uint16 MaxValue;
+ RedfishCS_uint16 MinValue;
+} RedfishCS_Number;
+
+typedef struct _RedfishCS_char_Array {
+ RedfishCS_char_Array *Next;
+ RedfishCS_char *ArrayValue;
+} RedfishCS_char_Array;
+
+typedef struct _RedfishCS_int64_Array {
+ RedfishCS_int64_Array *Next;
+ RedfishCS_int64 *ArrayValue;
+} RedfishCS_int64_Array;
+
+typedef struct _RedfishCS_bool_Array {
+ RedfishCS_bool_Array *Next;
+ RedfishCS_bool *ArrayValue;
+} RedfishCS_bool_Array;
+
+typedef struct _RedfishCS_Link_Array {
+ RedfishCS_Link_Array *Next;
+ RedfishCS_Link *ArrayValue;
+} RedfishCS_Link_Array;
+
+typedef enum {
+ RedfishCS_Vague_DataType_String = 1,
+ RedfishCS_Vague_DataType_Int64,
+ RedfishCS_Vague_DataType_Bool
+} RedfishCS_Vague_DataType;
+
+typedef union {
+ RedfishCS_char *CharPtr;
+ RedfishCS_bool *BoolPtr;
+ RedfishCS_int64 *Int64Ptr;
+} RedfishCS_Vague_Ptr;
+
+typedef struct _RedfishCS_Vague {
+ RedfishCS_Vague_DataType DataType;
+ RedfishCS_Vague_Ptr DataValue;
+} RedfishCS_Vague;
+
+typedef struct _RedfishCS_EmptyProp_KeyValue {
+ RedfishCS_EmptyProp_KeyValue *NextKeyValuePtr;
+ RedfishCS_char *KeyNamePtr;
+ RedfishCS_Vague *Value;
+} RedfishCS_EmptyProp_KeyValue;
+
+typedef struct _RedfishCS_Type_EmptyProp_CS_Data {
+ RedfishCS_Header Header;
+ RedfishCS_uint32 NunmOfProperties;
+ RedfishCS_EmptyProp_KeyValue *KeyValuePtr;
+} RedfishCS_Type_EmptyProp_CS_Data;
+
+#endif
diff --git a/RedfishClientPkg/ConverterLib/include/RedfishDataTypeDef.h b/RedfishClientPkg/ConverterLib/include/RedfishDataTypeDef.h
new file mode 100644
index 0000000000..23d13a854c
--- /dev/null
+++ b/RedfishClientPkg/ConverterLib/include/RedfishDataTypeDef.h
@@ -0,0 +1,46 @@
+/** @file
+
+ (C) Copyright 2018-2021 Hewlett Packard Enterprise Development LP<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ Copyright Notice:
+ Copyright 2019-2021 Distributed Management Task Force, Inc. All rights reserved.
+ License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-JSON-C-Struct-Converter/blob/master/LICENSE.md
+**/
+#ifndef REDFISH_CS_DATA_TYPE_H_
+#define REDFISH_CS_DATA_TYPE_H_
+
+#include <jansson.h>
+
+typedef char RedfishCS_char;
+typedef int RedfishCS_bool;
+typedef signed char RedfishCS_int8;
+typedef unsigned char RedfishCS_uint8;
+typedef int RedfishCS_int16;
+typedef int RedfishCS_int;
+typedef unsigned int RedfishCS_uint16;
+typedef long int RedfishCS_int32;
+typedef unsigned long int RedfishCS_uint32;
+typedef long long RedfishCS_int64;
+typedef unsigned long long RedfishCS_uint64;
+typedef void RedfishCS_void;
+
+#define RedfishCS_boolean_false 0
+#define RedfishCS_boolean_true 1
+
+typedef RedfishCS_int64 RedfishCS_status;
+#define RedfishCS_status_success 0
+#define RedfishCS_status_unsupported -1
+#define RedfishCS_status_invalid_parameter -2
+#define RedfishCS_status_insufficient_memory -3
+#define RedfishCS_status_not_found -4
+#define RedfishCS_status_unknown_error -5
+
+typedef struct _RedfishCS_Link RedfishCS_Link;
+struct _RedfishCS_Link {
+ RedfishCS_Link *BackLink;
+ RedfishCS_Link *ForwardLink;
+};
+
+#endif
diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsMemoryInternal.h b/RedfishClientPkg/ConverterLib/src/RedfishCsMemoryInternal.h
new file mode 100644
index 0000000000..9d248bfd9f
--- /dev/null
+++ b/RedfishClientPkg/ConverterLib/src/RedfishCsMemoryInternal.h
@@ -0,0 +1,40 @@
+/** @file
+
+ (C) Copyright 2018-2021 Hewlett Packard Enterprise Development LP<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ Copyright Notice:
+ Copyright 2019-2021 Distributed Management Task Force, Inc. All rights reserved.
+ License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-JSON-C-Struct-Converter/blob/master/LICENSE.md
+**/
+#ifndef REDFISH_CS_MEMORY_INTERNAL_H_
+#define REDFISH_CS_MEMORY_INTERNAL_H_
+
+#include "RedfishDataTypeDef.h"
+
+RedfishCS_Link * InitializeLinkHead (RedfishCS_Link *LinkHead);
+RedfishCS_Link * InsertHeadLink (RedfishCS_Link *ListHead, RedfishCS_Link *Entry);
+RedfishCS_Link * InsertTailLink (RedfishCS_Link *ListHead, RedfishCS_Link *Entry);
+RedfishCS_Link * GetFirstLink (const RedfishCS_Link *List);
+RedfishCS_Link * GetLastLink (const RedfishCS_Link *List);
+RedfishCS_Link * GetNextLink (const RedfishCS_Link *List, const RedfishCS_Link *Node);
+RedfishCS_Link * GetPreviousLink ( const RedfishCS_Link *List, const RedfishCS_Link *Node);
+RedfishCS_Link *RemoveLink ( const RedfishCS_Link *Link);
+RedfishCS_bool IsLinkEmpty (const RedfishCS_Link *LinkHead);
+RedfishCS_bool IsLinkAtEnd (const RedfishCS_Link *LinkHead, const RedfishCS_Link *ThisLink);
+
+typedef struct _RedfishCS_Internal_memory_link {
+ RedfishCS_Link nextLink;
+ void *memoryPtr;
+} RedfishCS_Internal_memory_link;
+
+typedef struct _RedfishCS_Internal_memory_root {
+ RedfishCS_Link nextRoot;
+ RedfishCS_Link memBlocks;
+ void *CsPtr;
+} RedfishCS_Internal_memory_root;
+
+#endif
+
+
diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
new file mode 100644
index 0000000000..6064dde3e4
--- /dev/null
+++ b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
@@ -0,0 +1,1169 @@
+/** @file
+
+ (C) Copyright 2018-2021 Hewlett Packard Enterprise Development LP<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ Copyright Notice:
+ Copyright 2019-2021 Distributed Management Task Force, Inc. All rights reserved.
+ License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-JSON-C-Struct-Converter/blob/master/LICENSE.md
+**/
+
+#include "RedfishCsCommon.h"
+#include "RedfishCsMemoryInternal.h"
+#include <jansson.h>
+#include <stdlib.h>
+#include <string.h>
+
+RedfishCS_status GetRedfishPropertyVague(void *Cs, json_t *JsonObj, char *Key, RedfishCS_Vague **DstBuffer);
+
+/**
+ This function initiates a Redfish C Structure link.
+
+ ListHead The link list entry.
+ Return the list head.
+
+**/
+RedfishCS_Link *InitializeLinkHead (RedfishCS_Link *ListHead)
+{
+ ListHead->ForwardLink = ListHead;
+ ListHead->BackLink = ListHead;
+ return ListHead;
+}
+
+/**
+ This function inserts the list to list head.
+
+ ListHead The link list head.
+ Entry The list to insert.
+
+ Return the list head.
+
+**/
+RedfishCS_Link *InsertHeadLink (RedfishCS_Link *ListHead, RedfishCS_Link *Entry)
+{
+ Entry->ForwardLink = ListHead->ForwardLink;
+ Entry->BackLink = ListHead;
+ Entry->ForwardLink->BackLink = Entry;
+ ListHead->ForwardLink = Entry;
+ return ListHead;
+}
+
+/**
+ This function inserts the list to list tail.
+
+ ListHead The link list head.
+ Entry The list to insert.
+
+ Return the list head.
+
+**/
+RedfishCS_Link *InsertTailLink (RedfishCS_Link *ListHead, RedfishCS_Link *Entry)
+{
+ Entry->ForwardLink = ListHead;
+ Entry->BackLink = ListHead->BackLink;
+ Entry->BackLink->ForwardLink = Entry;
+ ListHead->BackLink = Entry;
+ return ListHead;
+}
+
+/**
+ This function gets the first list from the list head.
+
+ List The link list head.
+
+ Return the first list *
+
+**/
+RedfishCS_Link *GetFirstLink (const RedfishCS_Link *List)
+{
+ return List->ForwardLink;
+}
+
+/**
+ This function gets the last list from the list head.
+
+ List The link list head.
+
+ Return the last list.
+
+**/
+RedfishCS_Link *GetLastLink (const RedfishCS_Link *List)
+{
+ return List->BackLink;
+}
+
+/**
+ This function gets the next list of Node.
+
+ List The link list head.
+ Node The list we will get the next list from.
+
+ Return the next list.
+
+**/
+RedfishCS_Link *GetNextLink (const RedfishCS_Link *List, const RedfishCS_Link *Node)
+{
+ return Node->ForwardLink;
+}
+
+/**
+ This function gets the previous list of Node.
+
+ List The link list head.
+ Node The list we will get the previous list from.
+
+ Return the previous RedfishCS_Link *
+
+**/
+RedfishCS_Link *GetPreviousLink (const RedfishCS_Link *List, const RedfishCS_Link *Node)
+{
+ return Node->BackLink;
+}
+/**
+ This function removes a list.
+
+ Link The list to be removed.
+
+ Return the next list.
+
+**/
+RedfishCS_Link *RemoveLink (const RedfishCS_Link *Link)
+{
+ Link->ForwardLink->BackLink = Link->BackLink;
+ Link->BackLink->ForwardLink = Link->ForwardLink;
+ return Link->ForwardLink;
+}
+
+/**
+ This function checks if the list is empty.
+
+ LinkHead The list head.
+
+ Return true if it is empty otherwise it is not empty.
+
+**/
+RedfishCS_bool IsLinkEmpty (const RedfishCS_Link *LinkHead)
+{
+ return (RedfishCS_bool)(LinkHead->ForwardLink == LinkHead);
+}
+
+/**
+ This function checks if the list is at the end.
+
+ LinkHead The list head.
+ ThisLink The list to check.
+
+ Return true if it is at the end otherwise it is not.
+
+**/
+RedfishCS_bool IsLinkAtEnd (const RedfishCS_Link *LinkHead, const RedfishCS_Link *ThisLink)
+{
+ return (RedfishCS_bool)(ThisLink->ForwardLink == LinkHead);
+}
+
+/**
+ This function duplicates a string.
+
+ Cs The CStructure instance that owns the string.
+ Str String to be duplicated.
+ DstBuffer The buffer to retrieve the string.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status allocateDuplicateStr (void *Cs, char *Str, void **DstBuffer)
+{
+ RedfishCS_status Status;
+
+ if (Str == NULL || strlen(Str) == 0) {
+ *DstBuffer = NULL;
+ return RedfishCS_status_success;
+ }
+ Status = allocateRecordCsMemory(Cs, (RedfishCS_int)strlen(Str) + 1, (void **)DstBuffer);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+ memcpy (*DstBuffer, Str, strlen(Str) + 1);
+ return RedfishCS_status_success;
+}
+
+/**
+ This function creates an URI type CS by the Odata ID.
+
+ JsonOj JSON object which has odata ID key.
+ ParentUri The parent URI of odata ID.
+ CsTypeUriData The pointer to retrieve the RedfishCS_Type_Uri_Data.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status CreateCsUriByOdataId (json_t *JsonOj, RedfishCS_char *ParentUri, RedfishCS_Type_Uri_Data **CsTypeUriData)
+{
+ json_t *TempJsonObj;
+ RedfishCS_Type_Uri_Data *CsTypeUri;
+
+ CsTypeUri = NULL;
+ TempJsonObj = json_object_get(JsonOj, "@odata.id");
+ if (TempJsonObj == NULL) {
+ return RedfishCS_status_not_found;
+ }
+ CsTypeUri = malloc (sizeof (RedfishCS_Type_Uri_Data));
+ if (CsTypeUri == NULL) {
+ return RedfishCS_status_insufficient_memory;
+ }
+ InitializeLinkHead (&CsTypeUri->Header.LinkEntry);
+ CsTypeUri->Header.ResourceType = RedfishCS_Type_Uri;
+ CsTypeUri->Header.ThisUri = ParentUri;
+ CsTypeUri->Header.KeyName = (RedfishCS_char *)strdup ("@odata.id");
+ CsTypeUri->Uri = (RedfishCS_char *)strdup (json_string_value (TempJsonObj));
+ *CsTypeUriData = CsTypeUri;
+ return RedfishCS_status_success;
+}
+
+/**
+ This function creates URI type CS by node.
+
+ Cs The CStructure instance owns the string.
+ JsonOj JSON object which has NodeName key.
+ NodeName The JSON key name.
+ ParentUri The parent URI of odata ID.
+ CsTypeUriData The pointer to retrieve the RedfishCS_Type_Uri_Data.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status CreateCsUriByNode (void *Cs, json_t *JsonOj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Type_Uri_Data **CsTypeUriData)
+{
+ json_t *TempJsonObj;
+ json_t *TempJsonObj2;
+ RedfishCS_Type_Uri_Data *CsTypeUri;
+ RedfishCS_status Status;
+
+ CsTypeUri = NULL;
+
+ if (NodeName != NULL) {
+ TempJsonObj = json_object_get(JsonOj, NodeName);
+ if (TempJsonObj == NULL) {
+ return RedfishCS_status_not_found;
+ }
+ } else {
+ if (JsonOj == NULL) {
+ return RedfishCS_status_not_found;
+ }
+ TempJsonObj = JsonOj;
+ }
+
+ TempJsonObj2 = json_object_get(TempJsonObj, "@odata.id");
+ if (TempJsonObj2 != NULL) {
+ Status = allocateRecordCsMemory (Cs, sizeof (RedfishCS_Type_Uri_Data), (void **)&CsTypeUri);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+ InitializeLinkHead (&CsTypeUri->Header.LinkEntry);
+ CsTypeUri->Header.ResourceType = RedfishCS_Type_Uri;
+ CsTypeUri->Header.ThisUri = ParentUri;
+ Status = allocateDuplicateStr (Cs, NodeName, (void **)&CsTypeUri->Header.KeyName);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+ *CsTypeUriData = CsTypeUri;
+ Status = allocateDuplicateStr (Cs, (char *)json_string_value (TempJsonObj2), (void **)&CsTypeUri->Uri);
+ return Status;
+ }
+ return RedfishCS_status_invalid_parameter;
+}
+/**
+ This function creates JSON type CS by node.
+
+ Cs The CStructure instance owns the string.
+ JsonOj JSON object which has NodeName key.
+ NodeName The JSON key name.
+ ParentUri The parent URI of odata ID.
+ CsTypeJsonData The pointer to retrieve the RedfishCS_Type_JSON_Data.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status CreateCsJsonByNode (void *Cs, json_t *JsonObj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Type_JSON_Data **CsTypeJsonData)
+{
+ json_t *TempJsonObj;
+ RedfishCS_Type_JSON_Data *CsTypeJson;
+ RedfishCS_char *TempChar;
+ RedfishCS_char *DumpStr;
+ RedfishCS_status Status;
+
+ CsTypeJson = NULL;
+ if (NodeName != NULL) {
+ TempJsonObj = json_object_get(JsonObj, NodeName);
+ if (TempJsonObj == NULL) {
+ return RedfishCS_status_not_found;
+ }
+ } else {
+ // Dump JSON from JsonObj.
+ TempJsonObj = JsonObj;
+ }
+ TempChar = json_dumps ((const json_t *)TempJsonObj, JSON_INDENT (2));
+ if (TempChar != NULL) {
+ Status = allocateRecordCsMemory (Cs, sizeof (RedfishCS_Type_JSON_Data), (void **)&CsTypeJson);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+ Status = allocateRecordCsMemory (Cs, (RedfishCS_int)strlen (TempChar) + 1, (void **)&DumpStr);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+ strncpy (DumpStr, TempChar, strlen (TempChar) + 1);
+ InitializeLinkHead(&CsTypeJson->Header.LinkEntry);
+ CsTypeJson->Header.ResourceType = RedfishCS_Type_JSON;
+ CsTypeJson->Header.ThisUri = ParentUri;
+ Status = allocateDuplicateStr (Cs, NodeName, (void **)&CsTypeJson->Header.KeyName);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+ CsTypeJson->JsonText = DumpStr;
+ *CsTypeJsonData = CsTypeJson;
+ return RedfishCS_status_success;
+ }
+ return RedfishCS_status_invalid_parameter;
+}
+
+/**
+ This function creates an empty property type CS by node.
+
+ Cs The CStructure instance owns the string.
+ JsonOj JSON object which has the NodeName.
+ NodeName The JSON key name.
+ ParentUri The parent URI of odata ID.
+ CsTypeEmptyPropCSData The pointer to retrieve the CsTypeEmptyPropCSData.
+ NunmOfProperties Number of properties in CS.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status CreateEmptyPropCsJson(RedfishCS_void *Cs, json_t *JsonObj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Type_EmptyProp_CS_Data **CsTypeEmptyPropCSData, RedfishCS_uint32 NunmOfProperties) {
+ json_t *TempJsonObj;
+ RedfishCS_status Status;
+ RedfishCS_Type_EmptyProp_CS_Data *CsTypeEmptyPropCS;
+ RedfishCS_char *KeyName;
+ json_t *KeyValueObj;
+ RedfishCS_void *n;
+ RedfishCS_EmptyProp_KeyValue **KeyValuePtr;
+ RedfishCS_EmptyProp_KeyValue *KeyValue;
+
+ CsTypeEmptyPropCS = NULL;
+ if (NodeName != NULL) {
+ TempJsonObj = json_object_get(JsonObj, NodeName);
+ if (TempJsonObj == NULL) {
+ return RedfishCS_status_not_found;
+ }
+ }
+ Status = allocateRecordCsMemory(Cs, sizeof(RedfishCS_Type_EmptyProp_CS_Data), (void **)&CsTypeEmptyPropCS);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+ InitializeLinkHead(&CsTypeEmptyPropCS->Header.LinkEntry);
+ CsTypeEmptyPropCS->Header.ResourceType = RedfishCS_Type_CS_EmptyProp;
+ CsTypeEmptyPropCS->Header.ThisUri = ParentUri;
+ Status = allocateDuplicateStr(Cs, NodeName, (void **)&CsTypeEmptyPropCS->Header.KeyName);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+ CsTypeEmptyPropCS->NunmOfProperties = NunmOfProperties;
+ //
+ // Create instance for each key-value.
+ //
+ KeyValuePtr = &CsTypeEmptyPropCS->KeyValuePtr;
+ json_object_foreach_safe(TempJsonObj, n, KeyName, KeyValueObj) {
+ Status = allocateRecordCsMemory(Cs, sizeof(RedfishCS_EmptyProp_KeyValue), (void **)&KeyValue);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+ Status = allocateDuplicateStr(Cs, (char *)KeyName, (void **)&KeyValue->KeyNamePtr);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+ Status = GetRedfishPropertyVague(Cs, TempJsonObj, (char *)KeyName, &KeyValue->Value);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+
+ *KeyValuePtr = KeyValue;
+ KeyValuePtr = &KeyValue->NextKeyValuePtr;
+ }
+
+ *CsTypeEmptyPropCSData = CsTypeEmptyPropCS;
+ return RedfishCS_status_success;
+}
+/**
+ This function checks if property type is supported.
+
+ JsonOj JSON object of this property.
+
+ Return RedfishCS_bool.
+
+**/
+RedfishCS_bool CheckSupportedPropTypeInEmptyProperty(json_t *JsonObj) {
+ //
+ // Only support below property types for the property is declared as
+ // empty property in schema.
+ // e.g. "properties": {}
+ //
+ if (json_is_string(JsonObj) ||
+ json_is_integer(JsonObj) ||
+ //json_is_real(JsonObj) ||
+ json_is_number(JsonObj) ||
+ json_is_boolean(JsonObj)) {
+ return RedfishCS_boolean_true;
+ }
+ return RedfishCS_boolean_false;
+}
+
+/**
+ This function checks the properties in a empty property type JSON object.
+ Also returns the number of properties in NumOfProperty.
+
+ JsonOj JSON object
+ NumOfProperty Pointer to retrieve the number of property in JSON object.
+
+ Return RedfishCS_bool.
+
+**/
+RedfishCS_bool CheckEmptyPropJsonObject(json_t *JsonObj, RedfishCS_uint32 *NumOfProperty)
+{
+ RedfishCS_char *NewKey;
+ json_t *Value;
+ RedfishCS_void *n;
+ RedfishCS_uint32 Num;
+
+ Num = 0;
+ json_object_foreach_safe(JsonObj, n, NewKey, Value) {
+ if (!CheckSupportedPropTypeInEmptyProperty(Value)) {
+ return RedfishCS_boolean_false;
+ }
+ Num ++;
+ }
+ if (NumOfProperty != NULL) {
+ *NumOfProperty = Num;
+ }
+ return RedfishCS_boolean_true;
+}
+/**
+ This function checks if this is a supported Redfish resource.
+
+ Odata_Type The string to Odata type.
+ NameSpace The string to the Redfish schema name space.
+ Version The string to the Redfish schema version.
+ DataType The string to the data type defined in Redfish schema.
+
+ Return RedfishCS_bool.
+
+**/
+RedfishCS_bool SupportedRedfishResource (RedfishCS_char *Odata_Type, RedfishCS_char *NameSpace, RedfishCS_char *Version, RedfishCS_char *DataType)
+{
+ RedfishCS_char *TargetDataType;
+
+ if (Odata_Type == NULL || NameSpace == NULL || DataType == NULL) {
+ return RedfishCS_boolean_false;
+ }
+ if (Version != NULL) {
+ TargetDataType = malloc(strlen(NameSpace) + strlen(Version) + strlen(DataType) + 16); // Plus 16 bytes to make more room.
+ // Actually we just need 1 byte for "#"
+ // Two bytes for "." and one byte for NULL terminator.
+ } else {
+ TargetDataType = malloc(strlen(NameSpace) + strlen(DataType) + 16); // Plus 16 bytes to make more room.
+ // Actually we just need 1 byte for "#"
+ // Two bytes for "." and one byte for NULL terminator.
+ }
+ if (TargetDataType == NULL) {
+ return RedfishCS_boolean_false;
+ }
+ TargetDataType [0] = 0; // Insert NULL terminator.
+ strcat (TargetDataType, "#");
+ strcat (TargetDataType, NameSpace);
+ strcat (TargetDataType, ".");
+ if (Version != NULL && (strcmp (Version, "noversioned") != 0)) {
+ strcat(TargetDataType, Version);
+ strcat (TargetDataType, ".");
+ }
+ strcat (TargetDataType, DataType);
+ if (strcmp (Odata_Type, TargetDataType) == 0) {
+ return RedfishCS_boolean_true;
+ }
+ free (TargetDataType);
+ return RedfishCS_boolean_false;
+}
+/**
+ This function creates JSON or URI type CS according to the
+ number of properties in JSON object.
+
+ Cs he CStructure instance owns the new created CS.
+ JsonObj JSON object which has NodeName key.
+ NodeName The key name in JSON object.
+ ParentUri The parent URI.
+ LinkHead The list head to link with the new CS.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status
+CreateCsUriOrJsonByNode (void *Cs, json_t *JsonObj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Link *LinkHead)
+{
+ json_t *JsonObjTemp;
+ RedfishCS_Type_Uri_Data *CsTypeUri;
+ RedfishCS_Type_JSON_Data *CsTypeJson;
+ RedfishCS_status Status;
+
+ Status = RedfishCS_status_invalid_parameter;
+ JsonObjTemp = json_object_get (JsonObj, NodeName);
+ if (JsonObjTemp == NULL) {
+ return RedfishCS_status_not_found;
+ }
+ if (json_object_size(JsonObjTemp) == 1) {
+ Status = CreateCsUriByNode (Cs, JsonObj, NodeName, ParentUri, &CsTypeUri);
+ if (Status == RedfishCS_status_success) {
+ InsertTailLink (LinkHead, &CsTypeUri->Header.LinkEntry);
+ return RedfishCS_status_success;
+ }
+ } else {
+ Status = CreateCsJsonByNode (Cs, JsonObj, NodeName, ParentUri, &CsTypeJson);
+ if (Status == RedfishCS_status_success) {
+ InsertTailLink (LinkHead, &CsTypeJson->Header.LinkEntry);
+ return RedfishCS_status_success;
+ }
+ }
+ return Status;
+}
+/**
+ This function creates JSON or URI array type CS according to the
+ number of properties in JSON object.
+
+ Cs he CStructure instance owns the new created CS.
+ JsonObj JSON object which has NodeName.
+ NodeName The key name in JSON object.
+ ParentUri The parent URI.
+ LinkHead The list head to link with the new CS.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status
+CreateCsUriOrJsonByNodeArray (void *Cs, json_t *JsonObj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Link *LinkHead)
+{
+ json_t *JsonObjTemp;
+ json_t *JsonObjArray;
+ RedfishCS_Type_Uri_Data *CsTypeUri;
+ RedfishCS_Type_JSON_Data *CsTypeJson;
+ RedfishCS_status Status;
+ RedfishCS_uint16 ArrayIndex;
+
+ Status = RedfishCS_status_invalid_parameter;
+ JsonObjTemp = json_object_get (JsonObj, NodeName);
+ if (JsonObjTemp == NULL) {
+ return RedfishCS_status_not_found;
+ }
+ if (json_array_size (JsonObjTemp) == 0) {
+ return RedfishCS_status_success;
+ }
+ for (ArrayIndex = 0; ArrayIndex < (RedfishCS_uint16)json_array_size (JsonObjTemp); ArrayIndex ++) {
+ JsonObjArray = json_array_get (JsonObjTemp, (size_t)ArrayIndex);
+ if (JsonObjArray == NULL) {
+ continue;
+ }
+ if (json_object_size(JsonObjArray) == 1) {
+ Status = CreateCsUriByNode (Cs, JsonObjArray, NULL, ParentUri, &CsTypeUri);
+ if (Status == RedfishCS_status_success) {
+ InsertTailLink (LinkHead, &CsTypeUri->Header.LinkEntry);
+ }
+ } else {
+ Status = CreateCsJsonByNode (Cs, JsonObjArray, NULL, ParentUri, &CsTypeJson);
+ if (Status == RedfishCS_status_success) {
+ InsertTailLink (LinkHead, &CsTypeJson->Header.LinkEntry);
+ }
+ }
+ }
+ return RedfishCS_status_success;
+}
+/**
+ This function creates JSON object and CS.
+
+ JsonRawText JSON raw text.
+ ResourceType The Redfish resource type.
+ ResourceVersion The Redfish resource version.
+ TypeName The Redfish type name.
+ JsonObjReturned Pointer to retrieve JSON object.
+ Cs Pointer to retrieve CS.
+ size The size of CS.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status
+CreateJsonPayloadAndCs (char *JsonRawText, char *ResourceType, char *ResourceVersion, char *TypeName, json_t **JsonObjReturned, void **Cs, int size)
+{
+ json_t *TempJsonObj;
+ RedfishCS_char *TempChar;
+ RedfishCS_Header *Header;
+ void *TempCS;
+
+ if (JsonRawText == NULL ||
+ ResourceType == NULL ||
+ TypeName == NULL ||
+ Cs == NULL ||
+ size == 0
+ ) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ *JsonObjReturned = json_loads(JsonRawText, 0, NULL);
+ if (*JsonObjReturned == NULL) {
+ return RedfishCS_status_unknown_error;
+ }
+ TempJsonObj = json_object_get(*JsonObjReturned, "@odata.type");
+ if (TempJsonObj == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ TempChar = (RedfishCS_char *)json_string_value(TempJsonObj);
+ if (TempChar == NULL || ! SupportedRedfishResource (TempChar, ResourceType, ResourceVersion, TypeName)) {
+ return RedfishCS_status_unsupported;
+ }
+ TempCS = malloc (size);
+ if (TempCS == NULL) {
+ return RedfishCS_status_insufficient_memory;
+ }
+ memset (TempCS, 0, size);
+ Header = (RedfishCS_Header *)TempCS;
+ Header->ResourceType = RedfishCS_Type_CS;
+ Header->KeyName = NULL;
+ InitializeLinkHead (&Header->LinkEntry);
+ *Cs = TempCS;
+ return recordCsRootMemory (TempCS);
+}
+/**
+ This function returns a Redfish string property.
+
+ Cs The owner of this property.
+ JsonObj The JSON object has the Key.
+ Key The key in JSON object.
+ DstBuffer Pointer to retrieve a string.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status GetRedfishPropertyStr (void *Cs, json_t *JsonObj, char *Key, RedfishCS_char **DstBuffer)
+{
+ json_t *TempJsonObj;
+ RedfishCS_status Status;
+
+ if (DstBuffer == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ *DstBuffer = NULL;
+
+ TempJsonObj = json_object_get(JsonObj, Key);
+ if (TempJsonObj == NULL){
+ return RedfishCS_status_not_found;
+ }
+ Status = allocateDuplicateStr (Cs, (char *)json_string_value(TempJsonObj), (void **)DstBuffer);
+ return Status;
+}
+/**
+ This function returns a Redfish bool property.
+
+ Cs The owner of this property.
+ JsonObj The JSON object has the Key.
+ Key The key in JSON object.
+ DstBuffer Pointer to retrieve a boolean.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status GetRedfishPropertyBoolean (void *Cs, json_t *JsonObj, char *Key, RedfishCS_bool **DstBuffer)
+{
+ json_t *TempJsonObj;
+ RedfishCS_status Status;
+
+ if (DstBuffer == NULL) {
+ return RedfishCS_status_not_found;
+ }
+ TempJsonObj = json_object_get(JsonObj, Key);
+ if (TempJsonObj == NULL){
+ return RedfishCS_status_not_found;
+ }
+ Status = allocateRecordCsMemory(Cs, sizeof(RedfishCS_bool), (void **)DstBuffer);
+ if (Status != RedfishCS_status_success){
+ return Status;
+ }
+ if (json_is_true(TempJsonObj)) {
+ **DstBuffer = RedfishCS_boolean_true;
+ } else {
+ **DstBuffer = RedfishCS_boolean_false;
+ }
+ return RedfishCS_status_success;
+}
+
+/**
+ This function returns Redfish a long long property.
+
+ Cs The owner of this property.
+ JsonObj The JSON object has the Key.
+ Key The key in JSON object.
+ DstBuffer Pointer to retrieve a long long value.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status GetRedfishPropertyInt64 (void *Cs, json_t *JsonObj, char *Key, RedfishCS_int64 **Dst)
+{
+ RedfishCS_status Status;
+ const json_t *TempJsonObj;
+
+ if (Dst == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+
+ TempJsonObj = json_object_get(JsonObj, Key);
+ if (TempJsonObj == NULL) {
+ return RedfishCS_status_not_found;
+ }
+ Status = allocateRecordCsMemory(Cs, sizeof(RedfishCS_int64), (void **)Dst);
+ if (Status != RedfishCS_status_success){
+ return Status;
+ }
+ **Dst = (RedfishCS_int64)json_integer_value(TempJsonObj);
+ return RedfishCS_status_success;
+}
+/**
+ This function returns a type-agnostic property.
+
+ Cs The owner of this property.
+ JsonObj The JSON object has the Key.
+ Key The key in JSON object.
+ DstBuffer Pointer to retrieve a type agnostic value.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status GetRedfishPropertyVague (void *Cs, json_t *JsonObj, char *Key, RedfishCS_Vague **DstBuffer)
+{
+ json_t *TempJsonObj;
+ RedfishCS_status Status;
+ RedfishCS_Vague *VagueData;
+
+ if (DstBuffer == NULL) {
+ return RedfishCS_status_not_found;
+ }
+ TempJsonObj = json_object_get(JsonObj, Key);
+ if (TempJsonObj == NULL){
+ return RedfishCS_status_not_found;
+ }
+ Status = allocateRecordCsMemory(Cs, sizeof(RedfishCS_Vague), (void **)&VagueData);
+ if (Status != RedfishCS_status_success){
+ return Status;
+ }
+
+ if (json_is_string(TempJsonObj)) {
+ VagueData->DataType = RedfishCS_Vague_DataType_String;
+ Status = GetRedfishPropertyStr (Cs, JsonObj, Key, &VagueData->DataValue.CharPtr);
+ } else if (json_is_integer(TempJsonObj)) {
+ VagueData->DataType = RedfishCS_Vague_DataType_Int64;
+ Status = GetRedfishPropertyInt64 (Cs, JsonObj, Key, &VagueData->DataValue.Int64Ptr);
+ } else if (json_is_boolean(TempJsonObj)) {
+ VagueData->DataType = RedfishCS_Vague_DataType_Bool;
+ Status = GetRedfishPropertyBoolean (Cs, JsonObj, Key, &VagueData->DataValue.BoolPtr);
+ } else if (json_is_null(TempJsonObj)) {
+ *DstBuffer = NULL; // No value for this key
+ free (VagueData);
+ return RedfishCS_status_success;
+ } else {
+ return RedfishCS_status_unsupported;
+ }
+ if (Status == RedfishCS_status_success) {
+ *DstBuffer = VagueData;
+ }
+ return Status;
+}
+/**
+ This function inserts a string JSON object.
+
+ ParentJsonObj The parent JSON object
+ Key JSON key to insert.
+ StringValue Value of string to insert.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status InsertJsonStringObj (json_t *ParentJsonObj, char *Key, RedfishCS_char *StringValue)
+{
+ json_t *JsonValue;
+ RedfishCS_char NullStr[] = "";
+ RedfishCS_char *InsertStr;
+
+ InsertStr = StringValue;
+ if (ParentJsonObj == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ if (InsertStr == (char *)NULL) {
+ InsertStr = NullStr;
+ }
+ JsonValue = json_string(InsertStr);
+ if (JsonValue == NULL) {
+ return RedfishCS_status_unsupported;
+ }
+ if (json_object_set_new (ParentJsonObj, Key, JsonValue) == -1) {
+ return RedfishCS_status_unsupported;
+ }
+ return RedfishCS_status_success;
+}
+/**
+ This function inserts a bool JSON object.
+
+ ParentJsonObj The parent JSON object
+ Key JSON key to insert.
+ BoolValue Value of a bool to insert.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status InsertJsonBoolObj (json_t *ParentJsonObj, char *Key, RedfishCS_bool *BoolValue)
+{
+ json_t *JsonValue;
+
+ if (ParentJsonObj == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ if (BoolValue == (RedfishCS_bool *)NULL) {
+ return RedfishCS_status_success; // No value for this key.
+ }
+ JsonValue = json_boolean((BOOLEAN)*BoolValue);
+ if (JsonValue == NULL) {
+ return RedfishCS_status_unsupported;
+ }
+ if (json_object_set_new (ParentJsonObj, Key, JsonValue) == -1) {
+ return RedfishCS_status_unsupported;
+ }
+ return RedfishCS_status_success;
+}
+/**
+ This function inserts a long long value JSON object.
+
+ ParentJsonObj The parent JSON object
+ Key JSON key to insert.
+ Int64Value Value of a long long to insert.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status InsertJsonInt64Obj (json_t *ParentJsonObj, char *Key, RedfishCS_int64 *Int64Value)
+{
+ json_t *JsonValue;
+
+ if (ParentJsonObj == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ if (Int64Value == (RedfishCS_int64 *)NULL) {
+ return RedfishCS_status_success; // No value for this key.
+ }
+ JsonValue = json_integer((json_int_t)*Int64Value);
+ if (JsonValue == NULL) {
+ return RedfishCS_status_unsupported;
+ }
+ if (json_object_set_new (ParentJsonObj, Key, JsonValue) == -1) {
+ return RedfishCS_status_unsupported;
+ }
+ return RedfishCS_status_success;
+}
+/**
+ This function inserts a type-agnostic JSON object.
+
+ ParentJsonObj The parent JSON object
+ Key JSON key to insert.
+ VagueValue Value of a type agnostic value to insert.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status InsertJsonVagueObj (json_t *ParentJsonObj, char *Key, RedfishCS_Vague *VagueValue)
+{
+ json_t *JsonValue;
+ RedfishCS_char NullStr[] = "";
+
+ if (ParentJsonObj == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ if (VagueValue == (RedfishCS_Vague *)NULL) {
+ JsonValue = json_null(); // No value for this key.
+ } else if (VagueValue->DataType == RedfishCS_Vague_DataType_String) {
+ if (VagueValue->DataValue.CharPtr == NULL) {
+ JsonValue = json_string(NullStr);
+ } else {
+ JsonValue = json_string(VagueValue->DataValue.CharPtr);
+ }
+ } else if (VagueValue->DataType == RedfishCS_Vague_DataType_Int64) {
+ JsonValue = json_integer((json_int_t)*VagueValue->DataValue.Int64Ptr);
+ } else if (VagueValue->DataType == RedfishCS_Vague_DataType_Bool) {
+ JsonValue = json_boolean((BOOLEAN)*VagueValue->DataValue.BoolPtr);
+ } else {
+ return RedfishCS_status_invalid_parameter;
+ }
+ if (json_object_set_new (ParentJsonObj, Key, JsonValue) == -1) {
+ return RedfishCS_status_unsupported;
+ }
+ return RedfishCS_status_success;
+}
+/**
+ This function inserts a link type JSON object.
+
+ ParentJsonObj The parent JSON object
+ Key JSON key to insert.
+ Link Value of a link type to insert.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status InsertJsonLinkObj (json_t *JsonObj, char *Key, RedfishCS_Link *Link)
+{
+ json_t *JsonTextObj;
+ RedfishCS_Type_JSON_Data *CsJsonHeader;
+
+ if (Link == NULL || JsonObj == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ if (IsLinkEmpty (Link)) {
+ return RedfishCS_status_success;
+ }
+
+ CsJsonHeader = (RedfishCS_Type_JSON_Data *)GetFirstLink (Link);
+ if (CsJsonHeader->Header.ResourceType != RedfishCS_Type_JSON &&
+ CsJsonHeader->Header.ResourceType != RedfishCS_Type_Uri) {
+ // Only support JSON/URI property for CStructure to JSON
+ return RedfishCS_status_unsupported;
+ }
+ if (CsJsonHeader->JsonText == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+
+ if (CsJsonHeader->Header.ResourceType == RedfishCS_Type_JSON) {
+ JsonTextObj = json_loads(CsJsonHeader->JsonText, 0, NULL);
+ if (json_object_set_new (JsonObj, Key, JsonTextObj) == -1) {
+ return RedfishCS_status_unsupported;
+ }
+ } else {
+ JsonTextObj = json_string (CsJsonHeader->JsonText);
+ if (json_object_set_new (JsonObj, Key, JsonTextObj) == -1) {
+ return RedfishCS_status_unsupported;
+ }
+ }
+
+ return RedfishCS_status_success;
+}
+/**
+ This function inserts an array of string JSON object.
+
+ ParentJsonObj The parent JSON object
+ Key JSON key to insert.
+ StringValueArray Value of a string array to insert.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status InsertJsonStringArrayObj (json_t *ParentJsonObj, char *Key, RedfishCS_char_Array *StringValueArray)
+{
+ json_t *ArrayJson;
+ json_t *ArrayMember;
+ RedfishCS_char_Array *NextArray;
+ RedfishCS_char NullStr[] = "";
+
+ if (ParentJsonObj == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ if (StringValueArray == (RedfishCS_char_Array *)NULL) {
+ return RedfishCS_status_success; // No value for this key.
+ }
+ ArrayJson = json_array();
+ if (ArrayJson == NULL) {
+ return RedfishCS_status_unsupported;
+ }
+ NextArray = StringValueArray;
+ do {
+ if (NextArray->ArrayValue == NULL) {
+ ArrayMember = json_string(NullStr);
+ } else {
+ ArrayMember = json_string(NextArray->ArrayValue);
+ }
+ if (json_array_append_new (ArrayJson, ArrayMember) != 0) {
+ return RedfishCS_status_unsupported;
+ }
+ NextArray = NextArray->Next;
+ } while (NextArray != NULL);
+
+ if (json_object_set_new (ParentJsonObj, Key, ArrayJson) == -1) {
+ return RedfishCS_status_unsupported;
+ }
+ return RedfishCS_status_success;
+}
+/**
+ This function inserts an array of bool JSON object.
+
+ ParentJsonObj The parent JSON object
+ Key JSON key to insert.
+ BoolValueArray Value of a bool array to insert.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status InsertJsonBoolArrayObj (json_t *ParentJsonObj, char *Key, RedfishCS_bool_Array *BoolValueArray)
+{
+ json_t *ArrayJson;
+ json_t *ArrayMember;
+ RedfishCS_bool_Array *NextArray;
+
+ if (ParentJsonObj == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ if (BoolValueArray == (RedfishCS_bool_Array *)NULL) {
+ return RedfishCS_status_success; // No value for this key.
+ }
+ ArrayJson = json_array();
+ if (ArrayJson == NULL) {
+ return RedfishCS_status_unsupported;
+ }
+ NextArray = BoolValueArray;
+ do {
+ ArrayMember = json_boolean((BOOLEAN)*NextArray->ArrayValue);
+ if (json_array_append_new (ArrayJson, ArrayMember) != 0) {
+ return RedfishCS_status_unsupported;
+ }
+ NextArray = NextArray->Next;
+ } while (NextArray != NULL);
+
+ if (json_object_set_new (ParentJsonObj, Key, ArrayJson) == -1) {
+ return RedfishCS_status_unsupported;
+ }
+ return RedfishCS_status_success;
+}
+/**
+ This function inserts an array of long long value JSON object.
+
+ ParentJsonObj The parent JSON object
+ Key JSON key to insert.
+ Int64ValueArray Value of a long long array to insert.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status InsertJsonInt64ArrayObj (json_t *ParentJsonObj, char *Key, RedfishCS_int64_Array *Int64ValueArray)
+{
+ json_t *ArrayJson;
+ json_t *ArrayMember;
+ RedfishCS_int64_Array *NextArray;
+
+ if (ParentJsonObj == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ if (Int64ValueArray == (RedfishCS_int64_Array *)NULL) {
+ return RedfishCS_status_success; // No value for this key.
+ }
+ ArrayJson = json_array();
+ if (ArrayJson == NULL) {
+ return RedfishCS_status_unsupported;
+ }
+ NextArray = Int64ValueArray;
+ do {
+ ArrayMember = json_integer(*NextArray->ArrayValue);
+ if (json_array_append_new (ArrayJson, ArrayMember) != 0) {
+ return RedfishCS_status_unsupported;
+ }
+ NextArray = NextArray->Next;
+ } while (NextArray != NULL);
+
+ if (json_object_set_new (ParentJsonObj, Key, ArrayJson) == -1) {
+ return RedfishCS_status_unsupported;
+ }
+ return RedfishCS_status_success;
+}
+/**
+ This function inserts an array of link JSON object.
+
+ ParentJsonObj The parent JSON object
+ Key JSON key to insert.
+ LinkArray Value of a link array to insert.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status InsertJsonLinkArrayObj (json_t *ParentJsonObj, char *Key, RedfishCS_Link *LinkArray)
+{
+ json_t *ArrayJson;
+ json_t *ArrayMember;
+ RedfishCS_Type_Uri_Data *ThisLink;
+
+ if (ParentJsonObj == NULL) {
+ return RedfishCS_status_invalid_parameter;
+ }
+
+ if (IsLinkEmpty (LinkArray)) {
+ return RedfishCS_status_success;
+ }
+
+ ArrayJson = json_array();
+ if (ArrayJson == NULL) {
+ return RedfishCS_status_unsupported;
+ }
+ ThisLink = (RedfishCS_Type_Uri_Data *)GetFirstLink (LinkArray);
+ while (RedfishCS_boolean_true){
+ if (ThisLink->Header.ResourceType != RedfishCS_Type_Uri) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ if (ThisLink->Uri != (RedfishCS_char *)NULL) {
+ ArrayMember = json_string(ThisLink->Uri);
+ if (json_array_append_new (ArrayJson, ArrayMember) != 0) {
+ return RedfishCS_status_unsupported;
+ }
+ }
+ if (IsLinkAtEnd (LinkArray, &ThisLink->Header.LinkEntry)) {
+ if (json_object_set_new (ParentJsonObj, Key, ArrayJson) == -1) {
+ return RedfishCS_status_unsupported;
+ }
+ return RedfishCS_status_success;
+ }
+ ThisLink = (RedfishCS_Type_Uri_Data *)GetNextLink(LinkArray, &ThisLink->Header.LinkEntry);
+ };
+ return RedfishCS_status_success;
+}
+/**
+ This function inserts an empty property type JSON object.
+
+ ParentJsonObj The parent JSON object
+ Key JSON key to insert.
+ Link Value of an empty property type link.
+
+ Return RedfishCS_status.
+
+**/
+RedfishCS_status CsEmptyPropLinkToJson(json_t *ParentJsonObj, char *Key, RedfishCS_Link *Link) {
+ RedfishCS_uint32 Index;
+ RedfishCS_Type_EmptyProp_CS_Data *EmptyProp_CS_Ptr;
+ RedfishCS_EmptyProp_KeyValue *KeyValuePtr;
+ json_t *JsonObj;
+ RedfishCS_status Status;
+
+ EmptyProp_CS_Ptr = (RedfishCS_Type_EmptyProp_CS_Data *)GetFirstLink(Link);
+ if (EmptyProp_CS_Ptr->Header.ResourceType != RedfishCS_Type_CS_EmptyProp) {
+ return RedfishCS_status_unsupported;
+ }
+
+ JsonObj = json_object();
+ KeyValuePtr = EmptyProp_CS_Ptr->KeyValuePtr;
+ for (Index = 0; Index < EmptyProp_CS_Ptr->NunmOfProperties; Index++) {
+ Status = InsertJsonVagueObj(JsonObj, KeyValuePtr->KeyNamePtr, KeyValuePtr->Value);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+ KeyValuePtr = KeyValuePtr->NextKeyValuePtr;
+ }
+ if (json_object_set_new(ParentJsonObj, Key, JsonObj) != 0) {
+ return RedfishCS_status_unknown_error;
+ }
+ return RedfishCS_status_success;
+}
+
diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsMemory.c b/RedfishClientPkg/ConverterLib/src/RedfishCsMemory.c
new file mode 100644
index 0000000000..186de531eb
--- /dev/null
+++ b/RedfishClientPkg/ConverterLib/src/RedfishCsMemory.c
@@ -0,0 +1,197 @@
+/** @file
+
+ (C) Copyright 2018-2021 Hewlett Packard Enterprise Development LP<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ Copyright Notice:
+ Copyright 2019-2021 Distributed Management Task Force, Inc. All rights reserved.
+ License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-JSON-C-Struct-Converter/blob/master/LICENSE.md
+**/
+
+#include "RedfishCsMemoryInternal.h"
+#include <stdlib.h>
+#include <string.h>
+
+RedfishCS_Link CsMemRoot = {&CsMemRoot, &CsMemRoot};
+
+/**
+ This function records the memory allocation to
+ the C Structure instance that owns the memory block.
+
+ memCs C Structure instance.
+ Return RedfishCS_status
+
+**/
+RedfishCS_status recordCsRootMemory (void *memCs)
+{
+ RedfishCS_Internal_memory_root *memRoot;
+
+ memRoot = malloc (sizeof(RedfishCS_Internal_memory_root));
+ if (memRoot == NULL) {
+ return RedfishCS_status_insufficient_memory;
+ }
+ InitializeLinkHead (&memRoot->nextRoot);
+ InitializeLinkHead (&memRoot->memBlocks);
+ memRoot->CsPtr = memCs;
+ InsertTailLink (&CsMemRoot, &memRoot->nextRoot);
+ return RedfishCS_status_success;
+}
+/**
+ This function allocates and records the memory allocation
+ to the C Structure instance that owns the memory block.
+
+ rootCs C Structure instance.
+ size The size to allocate.
+ Dst Pointer to retrieve the pointer to memory
+ block.
+ Return RedfishCS_status
+
+**/
+RedfishCS_status allocateRecordCsMemory (RedfishCS_void *rootCs, RedfishCS_uint32 size, RedfishCS_void **Dst)
+{
+ RedfishCS_Internal_memory_root *memRoot;
+ RedfishCS_Internal_memory_link *memLink;
+
+ if (IsLinkEmpty (&CsMemRoot)) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ memRoot = (RedfishCS_Internal_memory_root *)GetFirstLink (&CsMemRoot);
+ while (RedfishCS_boolean_true){
+ if (memRoot->CsPtr == rootCs) {
+ // Allocation memory and record it.
+ memLink = malloc (sizeof(RedfishCS_Internal_memory_link));
+ if (memLink == NULL) {
+ return RedfishCS_status_insufficient_memory;
+ }
+ *Dst = malloc (size);
+ if (*Dst == NULL) {
+ free (memLink);
+ return RedfishCS_status_insufficient_memory;
+ }
+ memset (*Dst, 0, size);
+ memset (memLink, 0, sizeof(RedfishCS_Internal_memory_link));
+ InitializeLinkHead (&memLink->nextLink);
+ memLink->memoryPtr = *Dst;
+ InsertTailLink (&memRoot->memBlocks, &memLink->nextLink);
+ return RedfishCS_status_success;
+ }
+ if (IsLinkAtEnd (&CsMemRoot, (RedfishCS_Link *)&memRoot->nextRoot)) {
+ break;
+ }
+ memRoot = (RedfishCS_Internal_memory_root *)GetNextLink (&CsMemRoot, &memRoot->nextRoot);
+ };
+
+ return RedfishCS_status_invalid_parameter;
+}
+/**
+ This function allocates, records and zero out the memory
+ to the C Structure instance that owns the memory block.
+
+ rootCs C Structure instance.
+ size The size to allocate.
+ Dst Pointer to retrieve the pointer to memory
+ block.
+ Return RedfishCS_status
+
+**/
+RedfishCS_status allocateRecordCsZeroMemory (RedfishCS_void *rootCs, RedfishCS_uint32 size, RedfishCS_void **Dst)
+{
+ RedfishCS_status Status;
+
+ Status = allocateRecordCsMemory (rootCs, size, Dst);
+ if (Status != RedfishCS_status_success || *Dst == NULL) {
+ return Status;
+ }
+ memset (*Dst, 0, size);
+ return RedfishCS_status_success;
+}
+/**
+ This function destroies all memory allocations belong
+ to the C Structure instance.
+
+ rootCs C Structure instance.
+
+ Return RedfishCS_status
+
+**/
+RedfishCS_status DestoryCsMemory (RedfishCS_void *rootCs)
+{
+ RedfishCS_Internal_memory_root *memRoot;
+ RedfishCS_Internal_memory_link *memLink;
+
+ if (IsLinkEmpty (&CsMemRoot)) {
+ return RedfishCS_status_invalid_parameter;
+ }
+ memRoot = (RedfishCS_Internal_memory_root *)GetFirstLink (&CsMemRoot);
+ while (RedfishCS_boolean_true){
+ if (memRoot->CsPtr == rootCs) {
+ if (IsLinkEmpty (&memRoot->memBlocks)) {
+ return RedfishCS_status_success;
+ }
+ while (RedfishCS_boolean_true) {
+ memLink = (RedfishCS_Internal_memory_link *)GetLastLink(&memRoot->memBlocks);
+ if (memLink->memoryPtr != NULL) {
+ free (memLink->memoryPtr);
+ RemoveLink (&memLink->nextLink);
+ free (memLink);
+ }
+ if (IsLinkEmpty (&memRoot->memBlocks)) {
+ RemoveLink (&memRoot->nextRoot);
+ free (memRoot);
+ free (rootCs);
+ return RedfishCS_status_success;
+ }
+ }
+ }
+ if (IsLinkAtEnd (&CsMemRoot, (RedfishCS_Link *)&memRoot->nextRoot)) {
+ break;
+ }
+ memRoot = (RedfishCS_Internal_memory_root *)GetNextLink (&CsMemRoot, &memRoot->nextRoot);
+ };
+ return RedfishCS_status_invalid_parameter;
+}
+
+/**
+ This function allocates an array of memory blocks owned
+ by the C Structure instance.
+
+ rootCs C Structure instance.
+ ArrayInstanceSize Number of items in array.
+ ArraySize The size of each array.
+ Dst Pointer to retrieve the pointer to memory
+ block.
+
+ Return RedfishCS_status
+
+**/
+RedfishCS_status allocateArrayRecordCsMemory(RedfishCS_void *rootCs, RedfishCS_uint32 ArrayInstanceSize, RedfishCS_uint64 ArraySize, RedfishCS_void **Dst)
+{
+ RedfishCS_uint16 Index;
+ RedfishCS_void *ArrayInstance;
+ RedfishCS_void *PreArrayInstance;
+ RedfishCS_status Status;
+ RedfishCS_uint16 SizeOfVoid;
+
+ for (Index = 0; Index < ArraySize; Index ++) {
+ Status = allocateRecordCsMemory(rootCs, ArrayInstanceSize, &ArrayInstance);
+ if (Status != RedfishCS_status_success) {
+ return Status;
+ }
+ memset (ArrayInstance, 0, ArrayInstanceSize);
+ if (Index == 0) {
+ *Dst = ArrayInstance;
+ } else {
+ SizeOfVoid = sizeof (RedfishCS_void *);
+ if (SizeOfVoid == sizeof (RedfishCS_uint32)) {
+ *((RedfishCS_uint32 *)PreArrayInstance) = (RedfishCS_uint32)(unsigned long long)ArrayInstance; // Next link.
+ } else if (SizeOfVoid == sizeof (RedfishCS_uint64)){
+ *((RedfishCS_uint64 *)PreArrayInstance) = (RedfishCS_uint64)ArrayInstance; // Next link.
+ } else {
+ return RedfishCS_status_invalid_parameter;
+ }
+ }
+ PreArrayInstance = ArrayInstance;
+ }
+ return RedfishCS_status_success;
+}
--
2.17.1


[Patch 2/2] BaseTools: a new build option for variable default value generation

Bob Feng
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3562

Create a new build option to enable vfrcompile to generate Json
format EFI variable information file and read it to generate=20
the EFI variable default value binary file.

Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
---
BaseTools/Source/Python/AutoGen/DataPipe.py | 2 +
.../Source/Python/AutoGen/GenDefaultVar.py | 498 ++++++++++++++++++
.../Source/Python/AutoGen/ModuleAutoGen.py | 9 +
.../Python/AutoGen/ModuleAutoGenHelper.py | 4 +
BaseTools/Source/Python/Common/GlobalData.py | 5 +
BaseTools/Source/Python/build/build.py | 18 +
BaseTools/Source/Python/build/buildoptions.py | 1 +
7 files changed, 537 insertions(+)
create mode 100644 BaseTools/Source/Python/AutoGen/GenDefaultVar.py

diff --git a/BaseTools/Source/Python/AutoGen/DataPipe.py b/BaseTools/Source=
/Python/AutoGen/DataPipe.py
index 86ac2b928d9c..fa0c36b98f21 100755
--- a/BaseTools/Source/Python/AutoGen/DataPipe.py
+++ b/BaseTools/Source/Python/AutoGen/DataPipe.py
@@ -165,5 +165,7 @@ class MemoryDataPipe(DataPipe):
self.DataContainer =3D {"BinCacheSource":GlobalData.gBinCacheSourc=
e}=0D
=0D
self.DataContainer =3D {"BinCacheDest":GlobalData.gBinCacheDest}=0D
=0D
self.DataContainer =3D {"EnableGenfdsMultiThread":GlobalData.gEnab=
leGenfdsMultiThread}=0D
+=0D
+ self.DataContainer =3D {"GenDefaultVarBin": GlobalData.gGenDefault=
VarBin}=0D
diff --git a/BaseTools/Source/Python/AutoGen/GenDefaultVar.py b/BaseTools/S=
ource/Python/AutoGen/GenDefaultVar.py
new file mode 100644
index 000000000000..b82cce18ed26
--- /dev/null
+++ b/BaseTools/Source/Python/AutoGen/GenDefaultVar.py
@@ -0,0 +1,498 @@
+import json=0D
+from ctypes import *=0D
+import re=0D
+import copy=0D
+from struct import unpack=0D
+import os=0D
+=0D
+class GUID(Structure):=0D
+ _fields_ =3D [=0D
+ ('Guid1', c_uint32),=0D
+ ('Guid2', c_uint16),=0D
+ ('Guid3', c_uint16),=0D
+ ('Guid4', ARRAY(c_uint8, 8)),=0D
+ ]=0D
+=0D
+ def from_list(self, listformat):=0D
+ self.Guid1 =3D listformat[0]=0D
+ self.Guid2 =3D listformat[1]=0D
+ self.Guid3 =3D listformat[2]=0D
+ for i in range(8):=0D
+ self.Guid4[i] =3D listformat[i+3]=0D
+=0D
+ def __cmp__(self, otherguid):=0D
+ if isinstance(otherguid, GUID):=0D
+ return 1=0D
+ rt =3D False=0D
+ if self.Guid1 =3D=3D otherguid.Guid1 and self.Guid2 =3D=3D othergu=
id.Guid2 and self.Guid3 =3D=3D otherguid.Guid3:=0D
+ rt =3D True=0D
+ for i in range(8):=0D
+ rt =3D rt & (self.Guid4[i] =3D=3D otherguid.Guid4[i])=0D
+ return rt=0D
+=0D
+=0D
+class TIME(Structure):=0D
+ _fields_ =3D [=0D
+ ('Year', c_uint16),=0D
+ ('Month', c_uint8),=0D
+ ('Day', c_uint8),=0D
+ ('Hour', c_uint8),=0D
+ ('Minute', c_uint8),=0D
+ ('Second', c_uint8),=0D
+ ('Pad1', c_uint8),=0D
+ ('Nanosecond', c_uint32),=0D
+ ('TimeZone', c_uint16),=0D
+ ('Daylight', c_uint8),=0D
+ ('Pad2', c_uint8),=0D
+ ]=0D
+ def __init__(self):=0D
+ self.Year =3D 0x0=0D
+ self.Month =3D 0x0=0D
+ self.Day =3D 0x0=0D
+ self.Hour =3D 0x0=0D
+ self.Minute =3D 0x0=0D
+ self.Second =3D 0x0=0D
+ self.Pad1 =3D 0x0=0D
+ self.Nanosecond =3D 0x0=0D
+ self.TimeZone =3D 0x0=0D
+ self.Daylight =3D 0x0=0D
+ self.Pad2 =3D 0x0=0D
+=0D
+=0D
+EFI_VARIABLE_GUID =3D [0xddcf3616, 0x3275, 0x4164,=0D
+ 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d]=0D
+EFI_AUTHENTICATED_VARIABLE_GUID =3D [=0D
+ 0xaaf32c78, 0x947b, 0x439a, 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, =
0x92]=0D
+=0D
+AuthVarGuid =3D GUID()=0D
+AuthVarGuid.from_list(EFI_AUTHENTICATED_VARIABLE_GUID)=0D
+VarGuid =3D GUID()=0D
+VarGuid.from_list(EFI_VARIABLE_GUID)=0D
+=0D
+# Variable Store Header Format.=0D
+VARIABLE_STORE_FORMATTED =3D 0x5a=0D
+# Variable Store Header State.=0D
+VARIABLE_STORE_HEALTHY =3D 0xfe=0D
+=0D
+=0D
+class VARIABLE_STORE_HEADER(Structure):=0D
+ _fields_ =3D [=0D
+ ('Signature', GUID),=0D
+ ('Size', c_uint32),=0D
+ ('Format', c_uint8),=0D
+ ('State', c_uint8),=0D
+ ('Reserved', c_uint16),=0D
+ ('Reserved1', c_uint32),=0D
+ ]=0D
+=0D
+=0D
+# Variable data start flag.=0D
+VARIABLE_DATA =3D 0x55AA=0D
+=0D
+# Variable State flags.=0D
+VAR_IN_DELETED_TRANSITION =3D 0xfe=0D
+VAR_DELETED =3D 0xfd=0D
+VAR_HEADER_VALID_ONLY =3D 0x7f=0D
+VAR_ADDED =3D 0x3f=0D
+=0D
+=0D
+class VARIABLE_HEADER(Structure):=0D
+ _fields_ =3D [=0D
+ ('StartId', c_uint16),=0D
+ ('State', c_uint8),=0D
+ ('Reserved', c_uint8),=0D
+ ('Attributes', c_uint32),=0D
+ ('NameSize', c_uint32),=0D
+ ('DataSize', c_uint32),=0D
+ ('VendorGuid', GUID),=0D
+ ]=0D
+=0D
+=0D
+class AUTHENTICATED_VARIABLE_HEADER(Structure):=0D
+ _fields_ =3D [=0D
+ ('StartId', c_uint16),=0D
+ ('State', c_uint8),=0D
+ ('Reserved', c_uint8),=0D
+ ('Attributes', c_uint32),=0D
+ ('MonotonicCount', c_uint64),=0D
+ ('TimeStamp', TIME),=0D
+ ('PubKeyIndex', c_uint32),=0D
+ ('NameSize', c_uint32),=0D
+ ('DataSize', c_uint32),=0D
+ ('VendorGuid', GUID),=0D
+ ]=0D
+ _pack_ =3D 1=0D
+=0D
+=0D
+# Alignment of Variable Data Header in Variable Store region.=0D
+HEADER_ALIGNMENT =3D 4=0D
+=0D
+=0D
+class DEFAULT_INFO(Structure):=0D
+ _fields_ =3D [=0D
+ ('DefaultId', c_uint16),=0D
+ ('BoardId', c_uint16),=0D
+ ]=0D
+=0D
+=0D
+class DEFAULT_DATA(Structure):=0D
+ _fields_ =3D [=0D
+ ('HeaderSize', c_uint16),=0D
+ ('DefaultInfo', DEFAULT_INFO),=0D
+ ]=0D
+=0D
+class DELTA_DATA(Structure):=0D
+ _fields_ =3D [=0D
+ ('Offset', c_uint16),=0D
+ ('Value', c_uint8),=0D
+ ]=0D
+ _pack_ =3D 1=0D
+=0D
+array_re =3D re.compile(=0D
+ "(?P<mType>[a-z_A-Z][a-z_A-Z0-9]*)\[(?P<mSize>[1-9][0-9]*)\]")=0D
+=0D
+=0D
+class VarField():=0D
+ def __init__(self):=0D
+ self.Offset =3D 0=0D
+ self.Value =3D 0=0D
+ self.Size =3D 0=0D
+=0D
+ @property=0D
+ def Type(self):=0D
+ if self.Size =3D=3D 1:=0D
+ return "UINT8"=0D
+ if self.Size =3D=3D 2:=0D
+ return "UINT16"=0D
+ if self.Size =3D=3D 4:=0D
+ return "UINT32"=0D
+ if self.Size =3D=3D 8:=0D
+ return "UINT64"=0D
+=0D
+ return "UINT8"=0D
+=0D
+=0D
+BASIC_TYPE =3D {=0D
+ "BOOLEAN": 1,=0D
+ "UINT8": 1,=0D
+ "UINT16": 2,=0D
+ "UINT32": 4,=0D
+ "UINT64": 8=0D
+}=0D
+class CStruct():=0D
+=0D
+=0D
+ def __init__(self, typedefs):=0D
+ self.TypeDefs =3D typedefs=0D
+ self.TypeStack =3D copy.deepcopy(typedefs)=0D
+ self.finalDefs =3D {}=0D
+=0D
+ def CalStuctSize(self, sType):=0D
+ rt =3D 0=0D
+ if sType in BASIC_TYPE:=0D
+ return BASIC_TYPE[sType]=0D
+=0D
+ ma =3D array_re.match(sType)=0D
+ if ma:=0D
+ mType =3D ma.group('mType')=0D
+ mSize =3D ma.group('mSize')=0D
+ rt +=3D int(mSize) * self.CalStuctSize(mType)=0D
+ else:=0D
+ for subType in self.TypeDefs[sType]:=0D
+ rt +=3D self.CalStuctSize(subType['Type'])=0D
+=0D
+ return rt=0D
+=0D
+ def expend(self, fielditem):=0D
+ fieldname =3D fielditem['Name']=0D
+ fieldType =3D fielditem['Type']=0D
+ fieldOffset =3D fielditem['Offset']=0D
+=0D
+ ma =3D array_re.match(fieldType)=0D
+ if ma:=0D
+ mType =3D ma.group('mType')=0D
+ mSize =3D ma.group('mSize')=0D
+ return [{"Name": "%s[%d]" % (fieldname, i), "Type": mType, "Of=
fset": (fieldOffset + i*self.CalStuctSize(mType))} for i in range(int(mSize=
))]=0D
+ else:=0D
+ return [{"Name": "%s.%s" % (fieldname, item['Name']), "Type":i=
tem['Type'], "Offset": (fieldOffset + item['Offset'])} for item in self.Typ=
eDefs[fielditem['Type']]]=0D
+=0D
+ def ExpandTypes(self):=0D
+ if not self.finalDefs:=0D
+ for datatype in self.TypeStack:=0D
+ result =3D []=0D
+ mTypeStack =3D self.TypeStack[datatype]=0D
+ while len(mTypeStack) > 0:=0D
+ item =3D mTypeStack.pop()=0D
+ if item['Type'] in self.BASIC_TYPE:=0D
+ result.append(item)=0D
+ elif item['Type'] =3D=3D '(null)':=0D
+ continue=0D
+ else:=0D
+ for expand_item in self.expend(item):=0D
+ mTypeStack.append(expand_item)=0D
+ self.finalDefs[datatype] =3D result=0D
+ self.finalDefs=0D
+ return self.finalDefs=0D
+=0D
+def Get_Occupied_Size(FileLength, alignment):=0D
+ if FileLength % alignment =3D=3D 0:=0D
+ return FileLength=0D
+ return FileLength + (alignment-(FileLength % alignment))=0D
+=0D
+def Occupied_Size(buffer, alignment):=0D
+ FileLength =3D len(buffer)=0D
+ if FileLength % alignment !=3D 0:=0D
+ buffer +=3D b'\0' * (alignment-(FileLength % alignment))=0D
+ return buffer=0D
+=0D
+def PackStruct(cStruct):=0D
+ length =3D sizeof(cStruct)=0D
+ p =3D cast(pointer(cStruct), POINTER(c_char * length))=0D
+ return p.contents.raw=0D
+=0D
+def calculate_delta(default, theother):=0D
+=0D
+ if len(default) - len(theother) !=3D 0:=0D
+ return []=0D
+=0D
+ data_delta =3D []=0D
+ for i in range(len(default)):=0D
+ if default[i] !=3D theother[i]:=0D
+ data_delta.append([i, theother[i]])=0D
+ return data_delta=0D
+=0D
+class Variable():=0D
+ def __init__(self):=0D
+ self.mAlign =3D 1=0D
+ self.mTotalSize =3D 1=0D
+ self.mValue =3D {} # {defaultstore: value}=0D
+ self.mBin =3D {}=0D
+ self.fields =3D {} # {defaultstore: fileds}=0D
+ self.delta =3D {}=0D
+ self.attributes =3D 0=0D
+ self.mType =3D ''=0D
+ self.guid =3D ''=0D
+ self.mName =3D ''=0D
+ self.cDefs =3D None=0D
+=0D
+ @property=0D
+ def GuidArray(self):=0D
+=0D
+ guid_array =3D []=0D
+ guid =3D self.guid.strip().strip("{").strip("}")=0D
+ for item in guid.split(","):=0D
+ field =3D item.strip().strip("{").strip("}")=0D
+ guid_array.append(int(field,16))=0D
+ return guid_array=0D
+=0D
+ def update_delta_offset(self,base):=0D
+ for default_id in self.delta:=0D
+ for delta_list in self.delta[default_id]:=0D
+ delta_list[0] +=3D base=0D
+=0D
+ def pack(self):=0D
+=0D
+ for defaultid in self.mValue:=0D
+ var_value =3D self.mValue[defaultid]=0D
+ auth_var =3D AUTHENTICATED_VARIABLE_HEADER()=0D
+ auth_var.StartId =3D VARIABLE_DATA=0D
+ auth_var.State =3D VAR_ADDED=0D
+ auth_var.Reserved =3D 0x00=0D
+ auth_var.Attributes =3D 0x00000007=0D
+ auth_var.MonotonicCount =3D 0x0=0D
+ auth_var.TimeStamp =3D TIME()=0D
+ auth_var.PubKeyIndex =3D 0x0=0D
+ var_name_buffer =3D self.mName.encode('utf-16le') + b'\0\0'=0D
+ auth_var.NameSize =3D len(var_name_buffer)=0D
+ auth_var.DataSize =3D len(var_value)=0D
+ vendor_guid =3D GUID()=0D
+ vendor_guid.from_list(self.GuidArray)=0D
+ auth_var.VendorGuid =3D vendor_guid=0D
+=0D
+ self.mBin[defaultid] =3D PackStruct(auth_var) + Occupied_Size(=
var_name_buffer + var_value, 4)=0D
+=0D
+ def TypeCheck(self,data_type, data_size):=0D
+ if BASIC_TYPE[data_type] =3D=3D data_size:=0D
+ return True=0D
+ return False=0D
+=0D
+ def ValueToBytes(self,data_type,data_value,data_size):=0D
+=0D
+ rt =3D b''=0D
+ if not self.TypeCheck(data_type, data_size):=0D
+ print(data_type,data_value,data_size)=0D
+=0D
+ if data_type =3D=3D "BOOLEAN" or data_type =3D=3D 'UINT8':=0D
+ p =3D cast(pointer(c_uint8(int(data_value,16))), POINTER(c_cha=
r * 1))=0D
+ rt =3D p.contents.raw=0D
+ elif data_type =3D=3D 'UINT16':=0D
+ p =3D cast(pointer(c_uint16(int(data_value,16))), POINTER(c_ch=
ar * 2))=0D
+ rt =3D p.contents.raw=0D
+ elif data_type =3D=3D 'UINT32':=0D
+ p =3D cast(pointer(c_uint32(int(data_value,16))), POINTER(c_ch=
ar * 4))=0D
+ rt =3D p.contents.raw=0D
+ elif data_type =3D=3D 'UINT64':=0D
+ p =3D cast(pointer(c_uint64(int(data_value,16))), POINTER(c_ch=
ar * 8))=0D
+ rt =3D p.contents.raw=0D
+=0D
+ return rt=0D
+=0D
+ def serial(self):=0D
+ for defaultstore in self.fields:=0D
+ vValue =3D b''=0D
+ vfields =3D {vf.Offset: vf for vf in self.fields[defaultstore]=
}=0D
+ i =3D 0=0D
+ while i < self.mTotalSize:=0D
+ if i in vfields:=0D
+ vfield =3D vfields[i]=0D
+ vValue +=3D self.ValueToBytes(vfield.Type, vfield.Valu=
e,vfield.Size)=0D
+ i +=3D vfield.Size=0D
+ else:=0D
+ vValue +=3D self.ValueToBytes('UINT8','0x00',1)=0D
+ i +=3D 1=0D
+=0D
+ self.mValue[defaultstore] =3D vValue=0D
+ standard_default =3D self.mValue[0]=0D
+=0D
+ for defaultid in self.mValue:=0D
+ if defaultid =3D=3D 0:=0D
+ continue=0D
+ others_default =3D self.mValue[defaultid]=0D
+=0D
+ self.delta.setdefault(defaultid, []).extend(calculate_delta(=0D
+ standard_default, others_default))=0D
+=0D
+class DefaultVariableGenerator():=0D
+ def __init__(self):=0D
+ self.NvVarInfo =3D []=0D
+=0D
+ def LoadNvVariableInfo(self, VarInfoFilelist):=0D
+=0D
+ VarDataDict =3D {}=0D
+ DataStruct =3D {}=0D
+ VarDefine =3D {}=0D
+ VarAttributes =3D {}=0D
+ for VarInfoFile in VarInfoFilelist:=0D
+ with open(VarInfoFile.strip(), "r") as fd:=0D
+ data =3D json.load(fd)=0D
+=0D
+ DataStruct.update(data.get("DataStruct", {}))=0D
+ Data =3D data.get("Data")=0D
+ VarDefine.update(data.get("VarDefine"))=0D
+ VarAttributes.update(data.get("DataStructAttribute"))=0D
+=0D
+ for vardata in Data:=0D
+ if vardata['VendorGuid'] =3D=3D 'NA':=0D
+ continue=0D
+ VarDataDict.setdefault(=0D
+ (vardata['VendorGuid'], vardata["VarName"]), []).appen=
d(vardata)=0D
+=0D
+ cStructDefs =3D CStruct(DataStruct)=0D
+ for guid, varname in VarDataDict:=0D
+ v =3D Variable()=0D
+ v.guid =3D guid=0D
+ vardef =3D VarDefine.get(varname)=0D
+ if vardef is None:=0D
+ for var in VarDefine:=0D
+ if VarDefine[var]['Type'] =3D=3D varname:=0D
+ vardef =3D VarDefine[var]=0D
+ break=0D
+ else:=0D
+ continue=0D
+ v.attributes =3D vardef['Attributes']=0D
+ v.mType =3D vardef['Type']=0D
+ v.mAlign =3D VarAttributes[v.mType]['Alignment']=0D
+ v.mTotalSize =3D VarAttributes[v.mType]['TotalSize']=0D
+ v.Struct =3D DataStruct[v.mType]=0D
+ v.mName =3D varname=0D
+ v.cDefs =3D cStructDefs=0D
+ for fieldinfo in VarDataDict.get((guid, varname), []):=0D
+ vf =3D VarField()=0D
+ vf.Offset =3D fieldinfo['Offset']=0D
+ vf.Value =3D fieldinfo['Value']=0D
+ vf.Size =3D fieldinfo['Size']=0D
+ v.fields.setdefault(=0D
+ int(fieldinfo['DefaultStore'], 10), []).append(vf)=0D
+ v.serial()=0D
+ v.pack()=0D
+ self.NvVarInfo.append(v)=0D
+=0D
+ def PackDeltaData(self):=0D
+=0D
+ default_id_set =3D set()=0D
+ for v in self.NvVarInfo:=0D
+ default_id_set |=3D set(v.mBin.keys())=0D
+=0D
+ if default_id_set:=0D
+ default_id_set.remove(0)=0D
+ delta_buff_set =3D {}=0D
+ for defaultid in default_id_set:=0D
+ delta_buff =3D b''=0D
+ for v in self.NvVarInfo:=0D
+ delta_list =3D v.delta.get(defaultid,[])=0D
+ for delta in delta_list:=0D
+ delta_data =3D DELTA_DATA()=0D
+ delta_data.Offset, delta_data.Value =3D delta=0D
+ delta_buff +=3D PackStruct(delta_data)=0D
+ delta_buff_set[defaultid] =3D delta_buff=0D
+=0D
+ return delta_buff_set=0D
+=0D
+ def PackDefaultData(self):=0D
+=0D
+ default_data_header =3D DEFAULT_DATA()=0D
+ default_data_header.HeaderSize =3D sizeof(DEFAULT_DATA)=0D
+ default_data_header.DefaultInfo.DefaultId =3D 0x0=0D
+ default_data_header.DefaultInfo.BoardId =3D 0x0=0D
+ default_data_header_buffer =3D PackStruct(default_data_header)=0D
+=0D
+=0D
+ variable_store =3D VARIABLE_STORE_HEADER()=0D
+ variable_store.Signature =3D AuthVarGuid=0D
+=0D
+ variable_store_size =3D Get_Occupied_Size(sizeof(DEFAULT_DATA) + s=
izeof(VARIABLE_STORE_HEADER), 4)=0D
+ for v in self.NvVarInfo:=0D
+ variable_store_size +=3D Get_Occupied_Size(len(v.mBin[0]), 4)=
=0D
+=0D
+ variable_store.Size =3D variable_store_size=0D
+ variable_store.Format =3D VARIABLE_STORE_FORMATTED=0D
+ variable_store.State =3D VARIABLE_STORE_HEALTHY=0D
+ variable_store.Reserved =3D 0x0=0D
+ variable_store.Reserved2 =3D 0x0=0D
+=0D
+ variable_storage_header_buffer =3D PackStruct(variable_store)=0D
+=0D
+ variable_data =3D b''=0D
+ v_offset =3D 0=0D
+ for v in self.NvVarInfo:=0D
+ v.update_delta_offset(v_offset)=0D
+ variable_data +=3D Occupied_Size(v.mBin[0],4)=0D
+ v_offset +=3D Get_Occupied_Size(len(v.mBin[0]),4)=0D
+=0D
+=0D
+ final_buff =3D Occupied_Size(default_data_header_buffer + variable=
_storage_header_buffer,4) + variable_data=0D
+=0D
+ return final_buff=0D
+=0D
+ def generate(self, jsonlistfile,output_folder):=0D
+ if not os.path.exists(jsonlistfile):=0D
+ return=0D
+ if not os.path.exists(output_folder):=0D
+ os.makedirs(output_folder)=0D
+ try:=0D
+ with open(jsonlistfile,"r") as fd:=0D
+ filelist =3D fd.readlines()=0D
+ genVar =3D DefaultVariableGenerator()=0D
+ genVar.LoadNvVariableInfo(filelist)=0D
+ with open(os.path.join(output_folder, "default.bin"), "wb") as=
fd:=0D
+ fd.write(genVar.PackDefaultData())=0D
+=0D
+ delta_set =3D genVar.PackDeltaData()=0D
+ for default_id in delta_set:=0D
+ with open(os.path.join(output_folder, "defaultdelta_%s.bin=
" % default_id), "wb") as fd:=0D
+ fd.write(delta_set[default_id])=0D
+ except:=0D
+ print("generate varbin file failed")=0D
+=0D
+=0D
+=0D
diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/S=
ource/Python/AutoGen/ModuleAutoGen.py
index d70b0d7ae828..0daf3352f91b 100755
--- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
@@ -433,10 +433,19 @@ class ModuleAutoGen(AutoGen):
## Return the directory to store auto-gened source files of the module=
=0D
@cached_property=0D
def DebugDir(self):=0D
return _MakeDir((self.BuildDir, "DEBUG"))=0D
=0D
+=0D
+ @cached_property=0D
+ def DefaultVarJsonFiles(self):=0D
+ rt =3D []=0D
+ for SrcFile in self.SourceFileList:=0D
+ if SrcFile.Ext.lower() =3D=3D '.vfr':=0D
+ rt.append(os.path.join(self.DebugDir,os.path.join(os.path.=
dirname(SrcFile.File), "{}_var.json".format(SrcFile.BaseName))))=0D
+ return rt=0D
+=0D
## Return the path of custom file=0D
@cached_property=0D
def CustomMakefile(self):=0D
RetVal =3D {}=0D
for Type in self.Module.CustomMakefile:=0D
diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py b/BaseT=
ools/Source/Python/AutoGen/ModuleAutoGenHelper.py
index 036fdac3d7df..b46d041f58ab 100644
--- a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
+++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
@@ -644,10 +644,14 @@ class PlatformInfo(AutoGenInfo):
if Attr !=3D 'PATH':=0D
BuildOptions[ExpandedTool][Attr] +=3D " " =
+ mws.handleWsMacro(Value)=0D
else:=0D
BuildOptions[ExpandedTool][Attr] =3D mws.h=
andleWsMacro(Value)=0D
=0D
+ if self.DataPipe.Get("GenDefaultVarBin"):=0D
+ if BuildOptions.get('VFR',{}).get('FLAGS'):=0D
+ BuildOptions['VFR']['FLAGS'] +=3D " " + "--variable"=0D
+=0D
return BuildOptions, BuildRuleOrder=0D
=0D
def ApplyLibraryInstance(self,module):=0D
alldeps =3D self.DataPipe.Get("DEPS")=0D
if alldeps is None:=0D
diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Sourc=
e/Python/Common/GlobalData.py
index 61ab3f7e24cd..c68ca8fbb3f7 100755
--- a/BaseTools/Source/Python/Common/GlobalData.py
+++ b/BaseTools/Source/Python/Common/GlobalData.py
@@ -88,10 +88,15 @@ gIgnoreSource =3D False
#=0D
gFdfParser =3D None=0D
=0D
BuildOptionPcd =3D []=0D
=0D
+#=0D
+# Build flag for generate default variable binary file=0D
+#=0D
+gGenDefaultVarBin =3D False=0D
+=0D
#=0D
# Mixed PCD name dict=0D
#=0D
MixedPcd =3D {}=0D
=0D
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth=
on/build/build.py
index 02b489892422..2f6fc6b20faf 100755
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -750,10 +750,11 @@ class Build():
GlobalData.gUseHashCache =3D BuildOptions.UseHashCache=0D
GlobalData.gBinCacheDest =3D BuildOptions.BinCacheDest=0D
GlobalData.gBinCacheSource =3D BuildOptions.BinCacheSource=0D
GlobalData.gEnableGenfdsMultiThread =3D not BuildOptions.NoGenfdsM=
ultiThread=0D
GlobalData.gDisableIncludePathCheck =3D BuildOptions.DisableInclud=
ePathCheck=0D
+ GlobalData.gGenDefaultVarBin =3D BuildOptions.GenDefaultVarBin=0D
=0D
if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache:=0D
EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData=3D"--=
binary-destination must be used together with --hash.")=0D
=0D
if GlobalData.gBinCacheSource and not GlobalData.gUseHashCache:=0D
@@ -1459,10 +1460,14 @@ class Build():
self.BuildModules =3D []=0D
return True=0D
=0D
# genfds=0D
if Target =3D=3D 'fds':=0D
+ if GlobalData.gGenDefaultVarBin:=0D
+ from AutoGen.GenDefaultVar import DefaultVariableGenerator=
=0D
+ variable_info_filelist =3D os.path.join(AutoGenObject.Buil=
dDir,"variable_info_filelist.txt")=0D
+ DefaultVariableGenerator().generate(variable_info_filelist=
,AutoGenObject.FvDir)=0D
if GenFdsApi(AutoGenObject.GenFdsCommandDict, self.Db):=0D
EdkLogger.error("build", COMMAND_FAILURE)=0D
Threshold =3D self.GetFreeSizeThreshold()=0D
if Threshold:=0D
self.CheckFreeSizeThreshold(Threshold, AutoGenObject.FvDir=
)=0D
@@ -2247,10 +2252,19 @@ class Build():
AutoGenIdFile =3D os.path.join(GlobalData.gConfDirectory,".AutoGen=
IdFile.txt")=0D
with open(AutoGenIdFile,"w") as fw:=0D
fw.write("Arch=3D%s\n" % "|".join((Wa.ArchList)))=0D
fw.write("BuildDir=3D%s\n" % Wa.BuildDir)=0D
fw.write("PlatformGuid=3D%s\n" % str(Wa.AutoGenObjectList[0].G=
uid))=0D
+ variable_info_filelist =3D os.path.join(Wa.BuildDir,"variable_info=
_filelist.txt")=0D
+ vfr_var_json =3D []=0D
+ if GlobalData.gGenDefaultVarBin:=0D
+ for ma in self.AllModules:=0D
+ vfr_var_json.extend(ma.DefaultVarJsonFiles)=0D
+ SaveFileOnChange(variable_info_filelist, "\n".join(vfr_var_jso=
n), False)=0D
+ else:=0D
+ if os.path.exists(variable_info_filelist):=0D
+ os.remove(variable_info_filelist)=0D
=0D
if GlobalData.gBinCacheSource:=0D
BuildModules.extend(self.MakeCacheMiss)=0D
elif GlobalData.gUseHashCache and not GlobalData.gBinCacheDest:=0D
BuildModules.extend(self.PreMakeCacheMiss)=0D
@@ -2359,10 +2373,14 @@ class Build():
=0D
if self.Fdf:=0D
#=0D
# Generate FD image if there's a FDF file found=0D
#=0D
+ if GlobalData.gGenDefaultVarBin:=0D
+ from AutoGen.GenDefaultVar import DefaultVaria=
bleGenerator=0D
+ variable_info_filelist =3D os.path.join(Wa.Bui=
ldDir,"variable_info_filelist.txt")=0D
+ DefaultVariableGenerator().generate(variable_i=
nfo_filelist,Wa.FvDir)=0D
GenFdsStart =3D time.time()=0D
if GenFdsApi(Wa.GenFdsCommandDict, self.Db):=0D
EdkLogger.error("build", COMMAND_FAILURE)=0D
Threshold =3D self.GetFreeSizeThreshold()=0D
if Threshold:=0D
diff --git a/BaseTools/Source/Python/build/buildoptions.py b/BaseTools/Sour=
ce/Python/build/buildoptions.py
index 39d92cff209d..6886ba7f8eb6 100644
--- a/BaseTools/Source/Python/build/buildoptions.py
+++ b/BaseTools/Source/Python/build/buildoptions.py
@@ -99,7 +99,8 @@ class MyOptionParser():
Parser.add_option("--hash", action=3D"store_true", dest=3D"UseHash=
Cache", default=3DFalse, help=3D"Enable hash-based caching during build pro=
cess.")=0D
Parser.add_option("--binary-destination", action=3D"store", type=
=3D"string", dest=3D"BinCacheDest", help=3D"Generate a cache of binary file=
s in the specified directory.")=0D
Parser.add_option("--binary-source", action=3D"store", type=3D"str=
ing", dest=3D"BinCacheSource", help=3D"Consume a cache of binary files from=
the specified directory.")=0D
Parser.add_option("--genfds-multi-thread", action=3D"store_true", =
dest=3D"GenfdsMultiThread", default=3DTrue, help=3D"Enable GenFds multi thr=
ead to generate ffs file.")=0D
Parser.add_option("--no-genfds-multi-thread", action=3D"store_true=
", dest=3D"NoGenfdsMultiThread", default=3DFalse, help=3D"Disable GenFds mu=
lti thread to generate ffs file.")=0D
+ Parser.add_option("--gen-default-variable-bin", action=3D"store_tr=
ue", dest=3D"GenDefaultVarBin", default=3DFalse, help=3D"Generate default v=
ariable binary file.")=0D
Parser.add_option("--disable-include-path-check", action=3D"store_=
true", dest=3D"DisableIncludePathCheck", default=3DFalse, help=3D"Disable t=
he include path check for outside of package.")=0D
self.BuildOption, self.BuildTarget =3D Parser.parse_args()=0D
--=20
2.18.0.windows.1


[Patch 1/2] BaseTools: Enable VfrCompile to dump variable default value

Bob Feng
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3562

Create new command line option to have VfrCompile generate
a Json format file that contains the EFI Variable related
information including:
1. The C struct associate the EFI variable
2. The variable vendor Guid, name and attribute
3. The variable field's default value

Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>

---
BaseTools/Source/C/VfrCompile/VfrCompiler.cpp | 54 +++++++
BaseTools/Source/C/VfrCompile/VfrCompiler.h | 5 +
BaseTools/Source/C/VfrCompile/VfrSyntax.g | 6 +-
.../Source/C/VfrCompile/VfrUtilityLib.cpp | 145 +++++++++++++++++-
BaseTools/Source/C/VfrCompile/VfrUtilityLib.h | 14 +-
5 files changed, 219 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp b/BaseTools/Sour=
ce/C/VfrCompile/VfrCompiler.cpp
index 5f4d262d85c5..f13562be6727 100644
--- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
@@ -76,10 +76,11 @@ CVfrCompiler::OptionInitialization (
mOptions.CPreprocessorOptions =3D NULL;=0D
mOptions.HasOverrideClassGuid =3D FALSE;=0D
mOptions.WarningAsError =3D FALSE;=0D
mOptions.AutoDefault =3D FALSE;=0D
mOptions.CheckDefault =3D FALSE;=0D
+ mOptions.GenJson =3D FALSE;=0D
memset (&mOptions.OverrideClassGuid, 0, sizeof (EFI_GUID));=0D
=0D
if (Argc =3D=3D 1) {=0D
Usage ();=0D
SET_RUN_STATUS (STATUS_DEAD);=0D
@@ -93,10 +94,12 @@ CVfrCompiler::OptionInitialization (
return;=0D
} else if (stricmp(Argv[Index], "--version") =3D=3D 0) {=0D
Version ();=0D
SET_RUN_STATUS (STATUS_DEAD);=0D
return;=0D
+ } else if (stricmp(Argv[Index], "--variable") =3D=3D 0) {=0D
+ mOptions.GenJson =3D TRUE;=0D
} else if (stricmp(Argv[Index], "-l") =3D=3D 0) {=0D
mOptions.CreateRecordListFile =3D TRUE;=0D
gCIfrRecordInfoDB.TurnOn ();=0D
} else if (stricmp(Argv[Index], "-i") =3D=3D 0) {=0D
Index++;=0D
@@ -203,10 +206,13 @@ CVfrCompiler::OptionInitialization (
goto Fail;=0D
}=0D
if (SetRecordListFileName () !=3D 0) {=0D
goto Fail;=0D
}=0D
+ if (SetRecordListJsonFileName () !=3D 0) {=0D
+ goto Fail;=0D
+ }=0D
return;=0D
=0D
Fail:=0D
SET_RUN_STATUS (STATUS_DEAD);=0D
=0D
@@ -458,10 +464,38 @@ CVfrCompiler::SetRecordListFileName (
=0D
strcpy (mOptions.RecordListFile, mOptions.OutputDirectory);=0D
strcat (mOptions.RecordListFile, mOptions.VfrBaseFileName);=0D
strcat (mOptions.RecordListFile, VFR_RECORDLIST_FILENAME_EXTENSION);=0D
=0D
+ return 0;=0D
+}=0D
+INT8=0D
+CVfrCompiler::SetRecordListJsonFileName (=0D
+ VOID=0D
+ )=0D
+{=0D
+ INTN Length;=0D
+=0D
+ if (mOptions.VfrBaseFileName =3D=3D NULL) {=0D
+ return -1;=0D
+ }=0D
+=0D
+ Length =3D strlen (mOptions.OutputDirectory) +=0D
+ strlen (mOptions.VfrBaseFileName) +=0D
+ strlen (VFR_RECORDLIST_JSON_FILENAME_EXTENSION) +=0D
+ 1;=0D
+=0D
+ mOptions.RecordListJsonFile =3D (CHAR8 *) malloc (Length);=0D
+ if (mOptions.RecordListJsonFile =3D=3D NULL) {=0D
+ return -1;=0D
+ }=0D
+=0D
+ strcpy (mOptions.RecordListJsonFile, mOptions.OutputDirectory);=0D
+ strcat (mOptions.RecordListJsonFile, mOptions.VfrBaseFileName);=0D
+ strcat (mOptions.RecordListJsonFile, VFR_RECORDLIST_JSON_FILENAME_EXTENS=
ION);=0D
+=0D
+=0D
return 0;=0D
}=0D
=0D
CVfrCompiler::CVfrCompiler (=0D
IN INT32 Argc,=0D
@@ -565,10 +599,11 @@ CVfrCompiler::Usage (
" format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",=0D
" -w --warning-as-error",=0D
" treat warning as an error",=0D
" -a --autodefaut generate default value for question opcode if s=
ome default is missing",=0D
" -d --checkdefault check the default information in a question opc=
ode",=0D
+ " --variable generate default_data binary",=0D
NULL=0D
};=0D
for (Index =3D 0; Help[Index] !=3D NULL; Index++) {=0D
fprintf (stdout, "%s\n", Help[Index]);=0D
}=0D
@@ -902,10 +937,28 @@ CVfrCompiler::GenRecordListFile (
=0D
Err1:=0D
fclose (pInFile);=0D
}=0D
=0D
+VOID=0D
+CVfrCompiler::GenRecordListJsonFile(=0D
+ VOID=0D
+ )=0D
+{=0D
+ if (!mOptions.GenJson)=0D
+ return;=0D
+=0D
+ FILE *pOutFile2 =3D NULL;=0D
+ if ((pOutFile2 =3D fopen (LongFilePath (mOptions.RecordListJsonFile), "w=
")) =3D=3D NULL) {=0D
+ DebugError (NULL, 0, 0001, "Error opening the record list file", "%s",=
mOptions.RecordListJsonFile );=0D
+ }=0D
+ gCVfrBufferConfig.DumpJson(pOutFile2);=0D
+ fclose (pOutFile2);=0D
+=0D
+ return;=0D
+=0D
+}=0D
int=0D
main (=0D
IN int Argc,=0D
IN char **Argv=0D
)=0D
@@ -919,10 +972,11 @@ main (
Compiler.Compile();=0D
Compiler.AdjustBin();=0D
Compiler.GenBinary();=0D
Compiler.GenCFile();=0D
Compiler.GenRecordListFile ();=0D
+ Compiler.GenRecordListJsonFile ();=0D
=0D
Status =3D Compiler.RunStatus ();=0D
if ((Status =3D=3D STATUS_DEAD) || (Status =3D=3D STATUS_FAILED)) {=0D
return 2;=0D
}=0D
diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.h b/BaseTools/Source=
/C/VfrCompile/VfrCompiler.h
index b6e207d2ce1a..04fa4ed8eaf5 100644
--- a/BaseTools/Source/C/VfrCompile/VfrCompiler.h
+++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.h
@@ -31,18 +31,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Specify the filename extensions for the files we generate.=0D
//=0D
#define VFR_PREPROCESS_FILENAME_EXTENSION ".i"=0D
#define VFR_PACKAGE_FILENAME_EXTENSION ".hpk"=0D
#define VFR_RECORDLIST_FILENAME_EXTENSION ".lst"=0D
+#define VFR_RECORDLIST_JSON_FILENAME_EXTENSION "_var.json"=0D
=0D
typedef struct {=0D
CHAR8 *VfrFileName;=0D
CHAR8 *RecordListFile;=0D
+ CHAR8 *RecordListJsonFile;=0D
CHAR8 *PkgOutputFileName;=0D
CHAR8 *COutputFileName;=0D
bool CreateRecordListFile;=0D
bool CreateIfrPkgFile;=0D
+ bool GenJson;=0D
CHAR8 *OutputDirectory;=0D
CHAR8 *PreprocessorOutputFileName;=0D
CHAR8 *VfrBaseFileName; // name of input VFR file with no path or ext=
ension=0D
CHAR8 *IncludePaths;=0D
bool SkipCPreprocessor;=0D
@@ -78,10 +81,11 @@ class CVfrCompiler {
INT8 SetBaseFileName (VOID);=0D
INT8 SetPkgOutputFileName (VOID);=0D
INT8 SetCOutputFileName(VOID);=0D
INT8 SetPreprocessorOutputFileName (VOID);=0D
INT8 SetRecordListFileName (VOID);=0D
+ INT8 SetRecordListJsonFileName (VOID);=0D
=0D
VOID SET_RUN_STATUS (IN COMPILER_RUN_STATUS);=0D
BOOLEAN IS_RUN_STATUS (IN COMPILER_RUN_STATUS);=0D
=0D
public:=0D
@@ -100,9 +104,10 @@ class CVfrCompiler {
VOID Compile (VOID);=0D
VOID AdjustBin (VOID);=0D
VOID GenBinary (VOID);=0D
VOID GenCFile (VOID);=0D
VOID GenRecordListFile (VOID);=0D
+ VOID GenRecordListJsonFile (VOID);=0D
VOID DebugError (IN CHAR8*, IN UINT32, IN UINT32, IN CONS=
T CHAR8*, IN CONST CHAR8*, ...);=0D
};=0D
=0D
#endif=0D
diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C=
/VfrCompile/VfrSyntax.g
index 3f896c6f1acc..81a40d44cb36 100644
--- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
+++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
@@ -1130,22 +1130,24 @@ vfrStatementVarStoreEfi :
=
StoreName,=0D
=
&Guid,=0D
=
&gCVfrVarDataTypeDB,=0D
=
TypeName,=0D
=
VarStoreId,=0D
- =
IsBitVarStore=0D
+ =
IsBitVarStore,=0D
+ =
Attr=0D
=
), LineNum);=0D
_PCATCH(gCVfrData=
Storage.GetVarStoreId(StoreName, &VarStoreId, &Guid), SN);=0D
_PCATCH(gCVfrVarD=
ataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);=0D
} else {=0D
_PCATCH(gCVfrDataSt=
orage.DeclareBufferVarStore (=0D
=
TN->getText(),=0D
=
&Guid,=0D
=
&gCVfrVarDataTypeDB,=0D
=
TypeName,=0D
=
VarStoreId,=0D
- =
FALSE=0D
+ =
FALSE,=0D
+ =
Attr=0D
=
), LineNum);=0D
_PCATCH(gCVfrData=
Storage.GetVarStoreId(TN->getText(), &VarStoreId, &Guid), VN);=0D
_PCATCH(gCVfrVarD=
ataTypeDB.GetDataTypeSize(TypeName, &Size), N->getLine());=0D
}=0D
VSEObj.SetGuid (&Gu=
id);=0D
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/So=
urce/C/VfrCompile/VfrUtilityLib.cpp
index 2b9b5dbb1ca5..0cf2b950de74 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -283,10 +283,150 @@ CVfrBufferConfig::Select (
}=0D
=0D
return 1;=0D
}=0D
=0D
+VOID=0D
+CVfrBufferConfig::DumpJson (=0D
+ IN FILE *pFile=0D
+ )=0D
+{=0D
+ SVfrDataType *pTNode;=0D
+ SVfrDataField *pFNode;=0D
+ SConfigItem *pItem;=0D
+ SConfigInfo *pInfo;=0D
+ SConfigInfo *pInfoIndex =3D NULL;=0D
+ SVfrVarStorageNode *pVsNode;=0D
+ CHAR8 *DefaultStoreId =3D "0000";=0D
+ UINT8 indentation =3D 0;=0D
+=0D
+=0D
+ fprintf (pFile, "{\n");=0D
+ fprintf (pFile, "%*c\"DataStruct\" : {\n", 2 , ' ');=0D
+ for (pTNode =3D gCVfrVarDataTypeDB.GetDataTypeList(); pTNode !=3D NULL; =
pTNode =3D pTNode->mNext) {=0D
+ fprintf (pFile, "%*c\"%s\" : [\n", 4, ' ',pTNode->mTypeName);=0D
+ for (pFNode =3D pTNode->mMembers; pFNode !=3D NULL; pFNode =3D pFNode-=
mNext) {=0D
+ fprintf (pFile, "%*c{ \n", 6 ,' ');=0D
+ fprintf (pFile,"%*c\"Name\": \"%s\",\n", 8 , ' ', pFNode->mFieldName=
);=0D
+ if (pFNode->mArrayNum > 0) {=0D
+ fprintf (pFile,"%*c\"Type\": \"%s[%d]\",\n", 8 , ' ', pFNode->mFie=
ldType->mTypeName,pFNode->mArrayNum);=0D
+ } else {=0D
+ fprintf (pFile,"%*c\"Type\": \"%s\",\n", 8 , ' ', pFNode->mFieldTy=
pe->mTypeName);=0D
+ }=0D
+ fprintf (pFile,"%*c\"Offset\": %d\n", 8 , ' ', pFNode->mOffset);=0D
+=0D
+ if (pFNode->mNext =3D=3D NULL) {=0D
+ fprintf (pFile, "%*c}\n", 6 ,' ');=0D
+ }=0D
+ else {=0D
+ fprintf (pFile, "%*c},\n", 6 ,' ');=0D
+ }=0D
+ }=0D
+ if (pTNode->mNext =3D=3D NULL) {=0D
+ fprintf (pFile, "%*c]\n", 4, ' ');=0D
+ }=0D
+ else {=0D
+ fprintf (pFile, "%*c],\n", 4, ' ');=0D
+ }=0D
+ }=0D
+ fprintf (pFile, "%*c},\n", 2, ' ');=0D
+=0D
+ fprintf(pFile, "%*c\"DataStructAttribute\": {\n", 2, ' ');=0D
+ for (pTNode =3D gCVfrVarDataTypeDB.GetDataTypeList(); pTNode !=3D NULL; =
pTNode =3D pTNode->mNext) {=0D
+ fprintf(pFile, "%*c\"%s\": {\n", 4, ' ', pTNode->mTypeName);=0D
+ fprintf(pFile, "%*c\"Alignment\": %u,\n", 6, ' ',pTNode->mAlign);=0D
+ fprintf(pFile, "%*c\"TotalSize\": %u\n", 6, ' ',pTNode->mTotalSize);=0D
+ if (pTNode->mNext =3D=3D NULL) {=0D
+ fprintf(pFile, "%*c}\n", 4, ' ');=0D
+ }=0D
+ else {=0D
+ fprintf(pFile, "%*c},\n", 4, ' ');=0D
+ }=0D
+ }=0D
+ fprintf (pFile, "%*c},\n", 2, ' ');=0D
+=0D
+ fprintf (pFile, "%*c\"VarDefine\": {\n", 2, ' ');=0D
+ for (pVsNode =3D gCVfrDataStorage.GetBufferVarStoreList(); pVsNode !=3D =
NULL; pVsNode =3D pVsNode->mNext) {=0D
+ fprintf (pFile, "%*c\"%s\" : {\n", 4, ' ', pVsNode->mVarStoreName);=0D
+ fprintf (pFile, "%*c\"Type\" : \"%s\",\n", 6, ' ', pVsNode->mStorageIn=
fo.mDataType->mTypeName);=0D
+ fprintf (pFile, "%*c\"Attributes\" : %d\n", 6, ' ', pVsNode->mAttribut=
es);=0D
+ if (pVsNode->mNext =3D=3D NULL) {=0D
+ fprintf(pFile, "%*c}\n", 4, ' ');=0D
+ }=0D
+ else {=0D
+ fprintf(pFile, "%*c},\n", 4, ' ');=0D
+ }=0D
+ }=0D
+ fprintf (pFile, "%*c},\n", 2, ' ');=0D
+=0D
+ indentation =3D 0;=0D
+ fprintf (pFile, "%*c\"Data\" : [\n",2, ' ');=0D
+ for (pItem =3D mItemListHead; pItem!=3DNULL; pItem =3D pItem->mNext) {=0D
+ if (pItem->mId =3D=3D NULL) {=0D
+ continue;=0D
+ }=0D
+=0D
+ DefaultStoreId =3D pItem->mId;=0D
+ //find the last pInfo whose value is not 0=0D
+ if (pItem->mNext =3D=3D NULL) {=0D
+ for (pInfo =3D pItem->mInfoStrList; pInfo !=3D NULL; pInfo =3D pInfo=
->mNext) {=0D
+ if(*pInfo->mValue !=3D0) {=0D
+ pInfoIndex =3D pInfo;=0D
+ }=0D
+ }=0D
+ }=0D
+ for (pInfo =3D pItem->mInfoStrList; pInfo !=3D NULL; pInfo =3D pInfo->=
mNext) {=0D
+ bool pass =3D 1;=0D
+ for (int i=3D0;i<pInfo->mWidth;i++){=0D
+ pass &=3D (*(pInfo->mValue+i) =3D=3D 0);=0D
+ }=0D
+ if (pass) {=0D
+ continue;=0D
+ }=0D
+ fprintf (pFile, "%*c{\n",4, ' ');=0D
+ fprintf(pFile, "%*c\"VendorGuid\": \"{0x%02x, 0x%02x, 0x%02x, { 0x%0=
2x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x}}\",\n",=0D
+ 6,=0D
+ ' ',=0D
+ pItem->mGuid->Data1,=0D
+ pItem->mGuid->Data2,=0D
+ pItem->mGuid->Data3,=0D
+ pItem->mGuid->Data4[0],=0D
+ pItem->mGuid->Data4[1],=0D
+ pItem->mGuid->Data4[2],=0D
+ pItem->mGuid->Data4[3],=0D
+ pItem->mGuid->Data4[4],=0D
+ pItem->mGuid->Data4[5],=0D
+ pItem->mGuid->Data4[6],=0D
+ pItem->mGuid->Data4[7]=0D
+ );=0D
+ fprintf (pFile, "%*c\"VarName\": \"%s\",\n", 6, ' ', pItem->mName);=
=0D
+ fprintf (pFile, "%*c\"DefaultStore\": \"%s\",\n", 6, ' ', DefaultSto=
reId);=0D
+ fprintf (pFile, "%*c\"Size\": %u,\n", 6, ' ', pInfo->mWidth);=0D
+ fprintf (pFile, "%*c\"Offset\": %u,\n", 6, ' ',pInfo->mOffset);=0D
+ fprintf (pFile, "%*c\"Value\": \"0x", 6, ' ');=0D
+ for (int i =3D pInfo->mWidth -1 ; i>=3D0; i--) {=0D
+ fprintf (pFile, "%02x", *(pInfo->mValue+i));=0D
+ }=0D
+ fprintf (pFile,"\"\n");=0D
+ fprintf(pFile, "%*c},\n", 4, ' ');=0D
+ }=0D
+ }=0D
+ //End item=0D
+ fprintf (pFile, "%*c{\n",4, ' ');=0D
+ fprintf(pFile, "%*c\"VendorGuid\": \"NA\",\n", 6, ' ');=0D
+ fprintf (pFile, "%*c\"VarName\": \"NA\",\n", 6, ' ');=0D
+ fprintf (pFile, "%*c\"DefaultStore\": \"NA\",\n", 6, ' ');=0D
+ fprintf (pFile, "%*c\"Size\": 0,\n", 6, ' ');=0D
+ fprintf (pFile, "%*c\"Offset\": 0,\n", 6, ' ');=0D
+ fprintf (pFile, "%*c\"Value\": \"0x00\"\n", 6, ' ');=0D
+ fprintf(pFile, "%*c}\n", 4, ' ');=0D
+ //End item=0D
+=0D
+ fprintf (pFile, "%*c]\n", 2, ' ');=0D
+=0D
+ fprintf (pFile, "}\n");=0D
+}=0D
UINT8=0D
CVfrBufferConfig::Write (=0D
IN CONST CHAR8 Mode,=0D
IN CHAR8 *Name,=0D
IN EFI_GUID *Guid,=0D
@@ -1557,10 +1697,11 @@ SVfrVarStorageNode::SVfrVarStorageNode (
IN EFI_GUID *Guid,=0D
IN CHAR8 *StoreName,=0D
IN EFI_VARSTORE_ID VarStoreId,=0D
IN SVfrDataType *DataType,=0D
IN BOOLEAN BitsVarstore,=0D
+ IN UINT32 Attributes,=0D
IN BOOLEAN Flag=0D
)=0D
{=0D
if (Guid !=3D NULL) {=0D
mGuid =3D *Guid;=0D
@@ -1580,10 +1721,11 @@ SVfrVarStorageNode::SVfrVarStorageNode (
} else {=0D
mVarStoreType =3D EFI_VFR_VARSTORE_BUFFER;=0D
}=0D
mStorageInfo.mDataType =3D DataType;=0D
mAssignedFlag =3D Flag;=0D
+ mAttributes =3D Attributes;=0D
}=0D
=0D
SVfrVarStorageNode::SVfrVarStorageNode (=0D
IN CHAR8 *StoreName,=0D
IN EFI_VARSTORE_ID VarStoreId=0D
@@ -1842,10 +1984,11 @@ CVfrDataStorage::DeclareBufferVarStore (
IN EFI_GUID *Guid,=0D
IN CVfrVarDataTypeDB *DataTypeDB,=0D
IN CHAR8 *TypeName,=0D
IN EFI_VARSTORE_ID VarStoreId,=0D
IN BOOLEAN IsBitVarStore,=0D
+ IN UINT32 Attr,=0D
IN BOOLEAN Flag=0D
)=0D
{=0D
SVfrVarStorageNode *pNew =3D NULL;=0D
SVfrDataType *pDataType =3D NULL;=0D
@@ -1868,11 +2011,11 @@ CVfrDataStorage::DeclareBufferVarStore (
return VFR_RETURN_VARSTOREID_REDEFINED;=0D
}=0D
MarkVarStoreIdUsed (VarStoreId);=0D
}=0D
=0D
- if ((pNew =3D new SVfrVarStorageNode (Guid, StoreName, VarStoreId, pData=
Type, IsBitVarStore, Flag)) =3D=3D NULL) {=0D
+ if ((pNew =3D new SVfrVarStorageNode (Guid, StoreName, VarStoreId, pData=
Type, IsBitVarStore, Attr, Flag)) =3D=3D NULL) {=0D
return VFR_RETURN_OUT_FOR_RESOURCES;=0D
}=0D
=0D
pNew->mNext =3D mBufferVarStoreList;=0D
mBufferVarStoreList =3D pNew;=0D
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h b/BaseTools/Sour=
ce/C/VfrCompile/VfrUtilityLib.h
index 57bb0c424daf..d3842aebb13b 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
@@ -86,10 +86,11 @@ class CVfrBufferConfig {
virtual UINT8 Register (IN CHAR8 *, IN EFI_GUID *,IN CHAR8 *Info =3D N=
ULL);=0D
virtual VOID Open (VOID);=0D
virtual BOOLEAN Eof(VOID);=0D
virtual UINT8 Select (IN CHAR8 *, IN EFI_GUID *, IN CHAR8 *Info =3D NU=
LL);=0D
virtual UINT8 Write (IN CONST CHAR8, IN CHAR8 *, IN EFI_GUID *, IN CHA=
R8 *, IN UINT8, IN UINT16, IN UINT32, IN EFI_IFR_TYPE_VALUE);=0D
+ virtual VOID DumpJson(IN FILE *);=0D
#if 0=0D
virtual UINT8 Read (OUT CHAR8 **, OUT CHAR8 **, OUT CHAR8 **, OUT CHAR=
8 **, OUT CHAR8 **);=0D
#endif=0D
virtual VOID Close (VOID);=0D
virtual VOID OutputCFile (IN FILE *, IN CHAR8 *);=0D
@@ -200,10 +201,18 @@ class CVfrVarDataTypeDB {
=0D
public:=0D
CVfrVarDataTypeDB (VOID);=0D
~CVfrVarDataTypeDB (VOID);=0D
=0D
+ inline SVfrDataType * GetDataTypeList(VOID) {=0D
+ return mDataTypeList;=0D
+ }=0D
+=0D
+ inline UINT32 GetPackAlign(VOID) {=0D
+ return mPackAlign;=0D
+ }=0D
+=0D
VOID DeclareDataTypeBegin (VOID);=0D
EFI_VFR_RETURN_CODE SetNewTypeName (IN CHAR8 *);=0D
EFI_VFR_RETURN_CODE DataTypeAddField (IN CHAR8 *, IN CHAR8 *, IN UINT32,=
IN BOOLEAN);=0D
EFI_VFR_RETURN_CODE DataTypeAddBitField (IN CHAR8 *, IN CHAR8 *, IN UINT=
32, IN BOOLEAN);=0D
VOID DeclareDataTypeEnd (VOID);=0D
@@ -247,10 +256,11 @@ typedef enum {
struct SVfrVarStorageNode {=0D
EFI_GUID mGuid;=0D
CHAR8 *mVarStoreName;=0D
EFI_VARSTORE_ID mVarStoreId;=0D
BOOLEAN mAssignedFlag; //Create varstore opcode=0D
+ UINT32 mAttributes;=0D
struct SVfrVarStorageNode *mNext;=0D
=0D
EFI_VFR_VARSTORE_TYPE mVarStoreType;=0D
union {=0D
// EFI Variable=0D
@@ -269,11 +279,11 @@ struct SVfrVarStorageNode {
} mNameSpace;=0D
} mStorageInfo;=0D
=0D
public:=0D
SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN EF=
I_STRING_ID, IN UINT32, IN BOOLEAN Flag =3D TRUE);=0D
- SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN SV=
frDataType *,IN BOOLEAN, IN BOOLEAN Flag =3D TRUE);=0D
+ SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN SV=
frDataType *,IN BOOLEAN, IN UINT32, IN BOOLEAN Flag =3D TRUE);=0D
SVfrVarStorageNode (IN CHAR8 *, IN EFI_VARSTORE_ID);=0D
~SVfrVarStorageNode (VOID);=0D
=0D
private:=0D
SVfrVarStorageNode (IN CONST SVfrVarStorageNode&); // Preven=
t copy-construction=0D
@@ -345,11 +355,11 @@ class CVfrDataStorage {
EFI_VFR_RETURN_CODE NameTableAddItem (EFI_STRING_ID);=0D
EFI_VFR_RETURN_CODE DeclareNameVarStoreEnd (EFI_GUID *);=0D
=0D
EFI_VFR_RETURN_CODE DeclareEfiVarStore (IN CHAR8 *, IN EFI_GUID *, IN EF=
I_STRING_ID, IN UINT32, IN BOOLEAN Flag =3D TRUE);=0D
=0D
- EFI_VFR_RETURN_CODE DeclareBufferVarStore (IN CHAR8 *, IN EFI_GUID *, IN=
CVfrVarDataTypeDB *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN BOOLEAN, IN BOOLEA=
N Flag =3D TRUE);=0D
+ EFI_VFR_RETURN_CODE DeclareBufferVarStore (IN CHAR8 *, IN EFI_GUID *, IN=
CVfrVarDataTypeDB *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN BOOLEAN, IN UINT32=
Attr =3D 0, IN BOOLEAN Flag =3D TRUE);=0D
=0D
EFI_VFR_RETURN_CODE GetVarStoreId (IN CHAR8 *, OUT EFI_VARSTORE_ID *, IN=
EFI_GUID *VarGuid =3D NULL);=0D
EFI_VFR_VARSTORE_TYPE GetVarStoreType (IN EFI_VARSTORE_ID);=0D
EFI_GUID * GetVarStoreGuid (IN EFI_VARSTORE_ID);=0D
EFI_VFR_RETURN_CODE GetVarStoreName (IN EFI_VARSTORE_ID, OUT CHAR8 **);=
=0D
--=20
2.18.0.windows.1

10481 - 10500 of 89696