[edk2] [PATCH v3] BaseTools: Skip module AutoGen by comparing timestamp.
[Introduction] The BaseTool Build.py AutoGen parse INF meta-file and generate AutoGen.c/AutoGen.h/makefile. When we only change .c .h code, the AutoGen might be not necessary, but Build.py spend a lot of time on it. There's a -u flag to skip all module's AutoGen. In my environment, it save 35%~50% of time in rebuild a ROM. However, if user change one .INF meta-file, then -u flag is not available. [Idea] AutoGen can compare meta-file's timestamp and decide if the module's AutoGen can be skipped. With this, when a module's INF is changed, we only run this module's AutoGen, we don't need to run other module's. [Implementation] In the end of a module's AutoGen, we create a AutoGenTimeStamp. The file save a file list that related to this module's AutoGen. In other word, the file list in AutoGenTimeStamp is INPUT files of module AutoGen, AutoGenTimeStamp file is OUTPUT. During rebuild, we compare time stamp between INPUT and OUTPUT, and decide if we can skip it. Below is the Input/Output of a module's AutoGen. [Input] 1. All the DSC/DEC/FDF used by the platform. 2. Macro and PCD defined by Build Options such as "build -D AAA=TRUE --pcd BbbPcd=0". 3. INF file of a module. 4. Source files of a module, list in [Sources] section of INF. 5. All the library link by the module. 6. All the .h files included by the module's sources. [Output] AutoGen.c/AutoGen.h/makefile/AutoGenTimeStamp [Testing] This patch save my build time. When I make a change without touching DSC/DEC/FDF, it is absolutely much faster than original rebuild, 35%~50% time saving in my environment (compare to original tool rebuild time). If I change any DSC/DEC/FDF, there's no performance improve, because it can't skip any module's AutoGen. Please note that if your environment will generate DSC/FDF during prebuild, it will not skip any AutoGen because of DSC timestamp is changed. This will require prebuild script not to update metafile when content is not changed. --- Changes in v3: - Consider BuildOption such as -D AAA=TRUE --pcd BbbPcd=0, add BuildOption meta-file. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Derek Lin <derek.l...@hpe.com> --- BaseTools/Source/Python/AutoGen/AutoGen.py | 136 + BaseTools/Source/Python/AutoGen/GenMake.py | 3 + BaseTools/Source/Python/GenFds/FdfParser.py| 4 + .../Source/Python/Workspace/MetaFileParser.py | 4 + 4 files changed, 147 insertions(+) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index f35ae252b0..6a2ea7d7ca 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -42,6 +42,7 @@ from GenPcdDb import CreatePcdDatabaseCode from Workspace.MetaFileCommentParser import UsageList from Common.MultipleWorkspace import MultipleWorkspace as mws import InfSectionParser +import datetime ## Regular expression for splitting Dependency Expression string into tokens gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)") @@ -640,6 +641,41 @@ class WorkspaceAutoGen(AutoGen): self._MakeFileDir = None self._BuildCommand = None +# +# Create BuildOptions Macro & PCD metafile. +# +content = 'gCommandLineDefines: ' +content += str(GlobalData.gCommandLineDefines) +content += os.linesep +content += 'BuildOptionPcd: ' +content += str(GlobalData.BuildOptionPcd) +SaveFileOnChange(os.path.join(self.BuildDir, 'BuildOptions'), content, False) + +# +# Get set of workspace metafiles +# +AllWorkSpaceMetaFiles = self._GetMetaFiles(Target, Toolchain, Arch) + +# +# Retrieve latest modified time of all metafiles +# +SrcTimeStamp = 0 +for f in AllWorkSpaceMetaFiles: +if os.stat(f)[8] > SrcTimeStamp: +SrcTimeStamp = os.stat(f)[8] +self._SrcTimeStamp = SrcTimeStamp + +# +# Write metafile list to build directory +# +AutoGenFilePath = os.path.join(self.BuildDir, 'AutoGen') +if os.path.exists (AutoGenFilePath): +os.remove(AutoGenFilePath) +if not os.path.exists(self.BuildDir): +os.makedirs(self.BuildDir) +with open(os.path.join(self.BuildDir, 'AutoGen'), 'w+') as file: +for f in AllWorkSpaceMetaFiles: +print >> file, f return True def _BuildOptionPcdValueFormat(self, TokenSpaceGuidCName, TokenCName, PcdDatumType, Value): @@ -668,6 +704,45 @@ class WorkspaceAutoGen(AutoGen): Value = '0' return Value +def _GetMetaFiles(self, Target, Toolchain, Arch): +AllWorkSpaceMetaFiles = set() +# +# add fdf +# +if self.FdfFile: +AllWorkSpaceMetaFiles.add (self.FdfFile.Path) +if
[edk2] [PATCH v2] BaseTools: Skip module AutoGen by comparing timestamp.
[Introduction] The BaseTool Build.py AutoGen parse INF meta-file and generate AutoGen.c/AutoGen.h/makefile. When we only change .c .h code, the AutoGen might be not necessary, but Build.py spend a lot of time on it. There's a -u flag to skip all module's AutoGen. In my environment, it save 35%~50% of time in rebuild a ROM. However, if user change one .INF meta-file, then -u flag is not available. [Idea] AutoGen can compare meta-file's timestamp and decide if the module's AutoGen can be skipped. With this, when a module's INF is changed, we only run this module's AutoGen, we don't need to run other module's. [Implementation] In the end of a module's AutoGen, we create a AutoGenTimeStamp. The file save a file list that related to this module's AutoGen. In other word, the file list in AutoGenTimeStamp is INPUT files of module AutoGen, AutoGenTimeStamp file is OUTPUT. During rebuild, we compare time stamp between INPUT and OUTPUT, and decide if we can skip it. Below is the Input/Output of a module's AutoGen. [Input] 1. All the DSC/DEC/FDF used by the platform. 2. INF file of a module. 3. Source files of a module, list in [Sources] section of INF. 4. All the library link by the module. 5. All the .h files included by the module's sources. [Output] AutoGen.c/AutoGen.h/makefile/AutoGenTimeStamp [Testing] This patch save my build time. When I make a change without touching DSC/DEC/FDF, it is absolutely much faster than original rebuild, 35%~50% time saving in my environment (compare to original tool rebuild time). If I change any DSC/DEC/FDF, there's no performance improve, because it can't skip any module's AutoGen. Please note that if your environment will generate DSC/FDF during prebuild, it will not skip any AutoGen because of DSC timestamp is changed. This will require prebuild script not to update metafile when content is not changed. --- Changes in v2: - Support building a target without fdf file such as MdeModulePkg.dsc - Coding style change to pass PatchCheck.py. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Derek Lin <derek.l...@hpe.com> --- BaseTools/Source/Python/AutoGen/AutoGen.py | 121 + BaseTools/Source/Python/AutoGen/GenMake.py | 3 + BaseTools/Source/Python/GenFds/FdfParser.py| 4 + .../Source/Python/Workspace/MetaFileParser.py | 4 + 4 files changed, 132 insertions(+) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index f35ae25..e012835 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -42,6 +42,7 @@ from GenPcdDb import CreatePcdDatabaseCode from Workspace.MetaFileCommentParser import UsageList from Common.MultipleWorkspace import MultipleWorkspace as mws import InfSectionParser +import datetime ## Regular expression for splitting Dependency Expression string into tokens gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)") @@ -640,6 +641,31 @@ class WorkspaceAutoGen(AutoGen): self._MakeFileDir = None self._BuildCommand = None +# +# Get set of workspace metafiles +# +AllWorkSpaceMetaFiles = self._GetMetaFiles(Target, Toolchain, Arch) + +# +# Retrieve latest modified time of all metafiles +# +SrcTimeStamp = 0 +for f in AllWorkSpaceMetaFiles: +if os.stat(f)[8] > SrcTimeStamp: +SrcTimeStamp = os.stat(f)[8] +self._SrcTimeStamp = SrcTimeStamp + +# +# Write metafile list to build directory +# +AutoGenFilePath = os.path.join(self.BuildDir, 'AutoGen') +if os.path.exists (AutoGenFilePath): +os.remove(AutoGenFilePath) +if not os.path.exists(self.BuildDir): +os.makedirs(self.BuildDir) +with open(os.path.join(self.BuildDir, 'AutoGen'), 'w+') as file: +for f in AllWorkSpaceMetaFiles: +print >> file, f return True def _BuildOptionPcdValueFormat(self, TokenSpaceGuidCName, TokenCName, PcdDatumType, Value): @@ -668,6 +694,40 @@ class WorkspaceAutoGen(AutoGen): Value = '0' return Value +def _GetMetaFiles(self, Target, Toolchain, Arch): +AllWorkSpaceMetaFiles = set() +# +# add fdf +# +if self.FdfFile: +AllWorkSpaceMetaFiles.add (self.FdfFile.Path) +if self.FdfFile: +FdfFiles = GlobalData.gFdfParser.GetAllIncludedFile() +for f in FdfFiles: +AllWorkSpaceMetaFiles.add (f.FileName) +# +# add dsc +# +AllWorkSpaceMetaFiles.add(self.MetaFile.Path) + +for Arch in self.ArchList: +Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain] +PGen = PlatformAutoGen(self, self.MetaFile,
[edk2] [PATCH] BaseTools: Skip module AutoGen by comparing timestamp.
[Introduction] The BaseTool Build.py AutoGen parse INF meta-file and generate AutoGen.c/AutoGen.h/makefile. When we only change .c .h code, the AutoGen might be not necessary, but Build.py spend a lot of time on it. There's a -u flag to skip all module's AutoGen. In my environment, it save 35%~50% of time in rebuild a ROM. However, if user change one .INF meta-file, then -u flag is not available. [Idea] AutoGen can compare meta-file's timestamp and decide if the module's AutoGen can be skipped. With this, when a module's INF is changed, we only run this module's AutoGen, we don't need to run other module's. [Implementation] In the end of a module's AutoGen, we create a AutoGenTimeStamp. The file save a file list that related to this module's AutoGen. In other word, the file list in AutoGenTimeStamp is INPUT files of module AutoGen, AutoGenTimeStamp file is OUTPUT. During rebuild, we compare time stamp between INPUT and OUTPUT, and decide if we can skip it. Below is the Input/Output of a module's AutoGen. [Input] 1. All the DSC/DEC/FDF used by the platform. 2. INF file of a module. 3. Source files of a module, list in [Sources] section of INF. 4. All the library link by the module. 5. All the .h files included by the module's sources. [Output] AutoGen.c/AutoGen.h/makefile/AutoGenTimeStamp [Testing] This patch save my build time. When I make a change without touching DSC/DEC/FDF, it is absolutely much faster than original rebuild, 35%~50% time saving in my environment (compare to original tool rebuild time). If I change any DSC/DEC/FDF, there's no performance improve, because it can't skip any module's AutoGen. Please note that if your environment will generate DSC/FDF during prebuild, it will not skip any AutoGen because of DSC timestamp is changed. This will require prebuild script not to update meta file when content is not changed. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Derek Lin <derek.l...@hpe.com> --- BaseTools/Source/Python/AutoGen/AutoGen.py | 110 + BaseTools/Source/Python/AutoGen/GenMake.py | 3 + BaseTools/Source/Python/GenFds/FdfParser.py| 4 + .../Source/Python/Workspace/MetaFileParser.py | 4 + 4 files changed, 121 insertions(+) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index f35ae25..daa5b35 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -42,6 +42,7 @@ from GenPcdDb import CreatePcdDatabaseCode from Workspace.MetaFileCommentParser import UsageList from Common.MultipleWorkspace import MultipleWorkspace as mws import InfSectionParser +import datetime ## Regular expression for splitting Dependency Expression string into tokens gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)") @@ -640,6 +641,31 @@ class WorkspaceAutoGen(AutoGen): self._MakeFileDir = None self._BuildCommand = None +# +# Create list of metafiles of the workspace +# +AllWorkSpaceMetaFiles = self._CreateMetaFileList() + +# +# Retrieve latest modified time of all metafiles +# +SrcTimeStamp = 0 +for f in AllWorkSpaceMetaFiles: +if os.stat(f)[8] > SrcTimeStamp: +SrcTimeStamp = os.stat(f)[8] +self._SrcTimeStamp = SrcTimeStamp + +# +# Write metafile list to build directory +# +AutoGenFilePath = os.path.join(self.BuildDir, 'AutoGen') +if os.path.exists (AutoGenFilePath): +os.remove(AutoGenFilePath) +if not os.path.exists(self.BuildDir): +os.makedirs(self.BuildDir) +with open(os.path.join(self.BuildDir, 'AutoGen'), 'w+') as file: +for f in AllWorkSpaceMetaFiles: +print >> file, f return True def _BuildOptionPcdValueFormat(self, TokenSpaceGuidCName, TokenCName, PcdDatumType, Value): @@ -668,6 +694,29 @@ class WorkspaceAutoGen(AutoGen): Value = '0' return Value +def _CreateMetaFileList(self): +AllWorkSpaceMetaFiles = [] +# +# add fdf +# +AllWorkSpaceMetaFiles.append (self.FdfFile.Path) +if self.FdfFile: +FdfFiles = GlobalData.gFdfParser.GetAllIncludedFile() +for f in FdfFiles: +AllWorkSpaceMetaFiles.append (f.FileName) +# +# add dsc & dec +# +for BuildData in self.BuildDatabase._CACHE_.values(): +if 'dsc' is BuildData.MetaFile.Ext: +AllWorkSpaceMetaFiles.append(BuildData.MetaFile.Path) +for filePath in BuildData._RawData.IncludedFiles: +AllWorkSpaceMetaFiles.append(filePath.Path) +if 'dec' is BuildData.MetaFile.Ext: +AllWorkSpaceMetaFiles.a
[edk2] [PATCH] BaseTools/Genfds: Fix Guid.xref missing GUIDs defined in Library.
The original Guid.xref lost some Guid which only defined in Library. When the library is used by a driver, its Guids were not listed in Guid.xref. Now they will. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Derek Lin <derek.l...@hpe.com> --- BaseTools/Source/Python/GenFds/GenFds.py | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index c2e9418..9c2f0ad 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -2,6 +2,7 @@ # generate flash image # # Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved. +# (C) Copyright 2016 Hewlett Packard Enterprise Development LP # # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -698,18 +699,22 @@ class GenFds : def GenerateGuidXRefFile(BuildDb, ArchList): GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir, "Guid.xref") GuidXRefFile = StringIO.StringIO('') +ModuleGuidDict = {} GuidDict = {} for Arch in ArchList: PlatformDataBase = BuildDb.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] -for ModuleFile in PlatformDataBase.Modules: +for ModuleFile in [x for x in PlatformDataBase.Modules] + [x for x in PlatformDataBase.LibraryInstances]: Module = BuildDb.BuildObject[ModuleFile, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] -GuidXRefFile.write("%s %s\n" % (Module.Guid, Module.BaseName)) +ModuleGuidDict[Module.BaseName] = Module.Guid for key, item in Module.Protocols.items(): GuidDict[key] = item for key, item in Module.Guids.items(): GuidDict[key] = item for key, item in Module.Ppis.items(): GuidDict[key] = item +# Append Module/Lib Guid to the Xref file +for key, item in ModuleGuidDict.items(): +GuidXRefFile.write("%s %s\n" % (item.upper(), key)) # Append GUIDs, Protocols, and PPIs to the Xref file GuidXRefFile.write("\n") for key, item in GuidDict.items(): -- 2.7.4.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] SecurityPkg: Reduce DEBUG verbosity in Tcg2Dxe
Reduce several DEBUG messages verbosity from INFO to VERBOSE, so that will not see debug message around each driver loading when TPM 2.0 part present. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Derek Lin <derek.l...@hpe.com> --- SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c index 07f76af..bdff5bd 100644 --- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c +++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c @@ -2,6 +2,7 @@ This module implements Tcg2 Protocol. Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved. +(C) Copyright 2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -332,14 +333,14 @@ Tcg2GetCapability ( IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability ) { - DEBUG ((EFI_D_INFO, "Tcg2GetCapability ...\n")); + DEBUG ((DEBUG_VERBOSE, "Tcg2GetCapability ...\n")); if ((This == NULL) || (ProtocolCapability == NULL)) { return EFI_INVALID_PARAMETER; } - DEBUG ((EFI_D_INFO, "Size - 0x%x\n", ProtocolCapability->Size)); - DEBUG ((EFI_D_INFO, " 1.1 - 0x%x, 1.0 - 0x%x\n", sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY), sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0))); + DEBUG ((DEBUG_VERBOSE, "Size - 0x%x\n", ProtocolCapability->Size)); + DEBUG ((DEBUG_VERBOSE, " 1.1 - 0x%x, 1.0 - 0x%x\n", sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY), sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0))); if (ProtocolCapability->Size < mTcgDxeData.BsCap.Size) { // @@ -363,7 +364,7 @@ Tcg2GetCapability ( } CopyMem (ProtocolCapability, , mTcgDxeData.BsCap.Size); - DEBUG ((EFI_D_INFO, "Tcg2GetCapability - %r\n", EFI_SUCCESS)); + DEBUG ((DEBUG_VERBOSE, "Tcg2GetCapability - %r\n", EFI_SUCCESS)); return EFI_SUCCESS; } @@ -1237,7 +1238,7 @@ Tcg2HashLogExtendEvent ( TCG_PCR_EVENT_HDR NewEventHdr; TPML_DIGEST_VALUES DigestList; - DEBUG ((EFI_D_INFO, "Tcg2HashLogExtendEvent ...\n")); + DEBUG ((DEBUG_VERBOSE, "Tcg2HashLogExtendEvent ...\n")); if ((This == NULL) || (DataToHash == 0) || (Event == NULL)) { return EFI_INVALID_PARAMETER; @@ -1287,7 +1288,7 @@ Tcg2HashLogExtendEvent ( Event->Event ); } - DEBUG ((EFI_D_INFO, "Tcg2HashLogExtendEvent - %r\n", Status)); + DEBUG ((DEBUG_VERBOSE, "Tcg2HashLogExtendEvent - %r\n", Status)); return Status; } -- 2.7.4.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] SecurityPkg/Tpm12CommandLib: Fix Tpm12NvWriteValue cmd.
Fix command length endian. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Derek Lin <derek.l...@hpe.com> --- SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c b/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c index 7baafa8..e176b00 100644 --- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c +++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c @@ -2,6 +2,7 @@ Implement TPM1.2 NV storage related command. Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved. +(C) Copyright 2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -199,8 +200,9 @@ Tpm12NvWriteValue ( { EFI_STATUS Status; TPM_CMD_NV_WRITE_VALUE Command; + UINT32 CommandLength; TPM_RSP_COMMAND_HDR Response; - UINT32 Length; + UINT32 ResponseLength; if (DataSize > sizeof (Command.Data)) { return EFI_UNSUPPORTED; @@ -210,14 +212,15 @@ Tpm12NvWriteValue ( // send Tpm command TPM_ORD_NV_WriteValue // Command.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND); - Command.Hdr.paramSize = SwapBytes32 (sizeof (Command) - sizeof(Command.Data) + DataSize); + CommandLength = sizeof (Command) - sizeof(Command.Data) + DataSize; + Command.Hdr.paramSize = SwapBytes32 (CommandLength); Command.Hdr.ordinal = SwapBytes32 (TPM_ORD_NV_WriteValue); Command.NvIndex = SwapBytes32 (NvIndex); Command.Offset= SwapBytes32 (Offset); Command.DataSize = SwapBytes32 (DataSize); CopyMem (Command.Data, Data, DataSize); - Length = sizeof (Response); - Status = Tpm12SubmitCommand (Command.Hdr.paramSize, (UINT8 *), , (UINT8 *)); + ResponseLength = sizeof (Response); + Status = Tpm12SubmitCommand (CommandLength, (UINT8 *), , (UINT8 *)); if (EFI_ERROR (Status)) { return Status; } -- 2.7.4.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] MdeModulePkg: Rescale ConSplitter Absolute Pointer.
ConSplitter's Absolute Pointer should scale virtual device's resolution like what Simple Pointer do. Before this change, caller will get Virtual device's resolution but physical device's current point. This change let caller get Virtual device's resolution with virtual device's current point. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Derek Lin <derek.l...@hpe.com> --- .../Universal/Console/ConSplitterDxe/ConSplitter.c | 43 ++ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c index dae97b0..af90d5e 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c @@ -17,6 +17,7 @@ device situation. Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. +(C) Copyright 2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -4096,7 +4097,18 @@ ConSplitterAbsolutePointerGetState ( EFI_STATUSReturnStatus; UINTN Index; EFI_ABSOLUTE_POINTER_STATECurrentState; - + UINT64MinX; + UINT64MinY; + UINT64MinZ; + UINT64MaxX; + UINT64MaxY; + UINT64MaxZ; + UINT64VirtualMinX; + UINT64VirtualMinY; + UINT64VirtualMinZ; + UINT64VirtualMaxX; + UINT64VirtualMaxY; + UINT64VirtualMaxZ; Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This); @@ -4107,6 +4119,13 @@ ConSplitterAbsolutePointerGetState ( State->CurrentZ= 0; State->ActiveButtons = 0; + VirtualMinX = Private->AbsolutePointerMode.AbsoluteMinX; + VirtualMinY = Private->AbsolutePointerMode.AbsoluteMinY; + VirtualMinZ = Private->AbsolutePointerMode.AbsoluteMinZ; + VirtualMaxX = Private->AbsolutePointerMode.AbsoluteMaxX; + VirtualMaxY = Private->AbsolutePointerMode.AbsoluteMaxY; + VirtualMaxZ = Private->AbsolutePointerMode.AbsoluteMaxZ; + // // if no physical pointer device exists, return EFI_NOT_READY; // if any physical pointer device has changed state, @@ -4124,16 +4143,26 @@ ConSplitterAbsolutePointerGetState ( ReturnStatus = EFI_SUCCESS; } + MinX = Private->AbsolutePointerList[Index]->Mode->AbsoluteMinX; + MinY = Private->AbsolutePointerList[Index]->Mode->AbsoluteMinY; + MinZ = Private->AbsolutePointerList[Index]->Mode->AbsoluteMinZ; + MaxX = Private->AbsolutePointerList[Index]->Mode->AbsoluteMaxX; + MaxY = Private->AbsolutePointerList[Index]->Mode->AbsoluteMaxY; + MaxZ = Private->AbsolutePointerList[Index]->Mode->AbsoluteMaxZ; + State->ActiveButtons = CurrentState.ActiveButtons; - if (!(Private->AbsolutePointerMode.AbsoluteMinX == 0 && Private->AbsolutePointerMode.AbsoluteMaxX == 0)) { -State->CurrentX = CurrentState.CurrentX; + // + // Rescale to Con Splitter virtual Absolute Pointer's resolution. + // + if (!(MinX == 0 && MaxX == 0)) { +State->CurrentX = VirtualMinX + (CurrentState.CurrentX * (VirtualMaxX - VirtualMinX)) / (MaxX - MinX); } - if (!(Private->AbsolutePointerMode.AbsoluteMinY == 0 && Private->AbsolutePointerMode.AbsoluteMaxY == 0)) { -State->CurrentY = CurrentState.CurrentY; + if (!(MinY == 0 && MaxY == 0)) { +State->CurrentY = VirtualMinY + (CurrentState.CurrentY * (VirtualMaxY - VirtualMinY)) / (MaxY - MinY); } - if (!(Private->AbsolutePointerMode.AbsoluteMinZ == 0 && Private->AbsolutePointerMode.AbsoluteMaxZ == 0)) { -State->CurrentZ = CurrentState.CurrentZ; + if (!(MinZ == 0 && MaxZ == 0)) { +State->CurrentZ = VirtualMinZ + (CurrentState.CurrentZ * (VirtualMaxZ - VirtualMinZ)) / (MaxZ - MinZ); } } else if (Status == EFI_DEVICE_ERROR) { -- 2.6.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH v2] SecurityPkg: Fix TPM 1.2 SelfTest command bug.
Specify command response length. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Derek Lin <derek.l...@hpe.com> --- Changes in v2: Fix patch message. --- SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c index cd08d19..8e232ee 100644 --- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c +++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c @@ -2,6 +2,7 @@ Implement TPM1.2 NV Self Test related commands. Copyright (c) 2016, Intel Corporation. All rights reserved. +(C) Copyright 2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -42,5 +43,6 @@ Tpm12ContinueSelfTest ( Command.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND); Command.paramSize = SwapBytes32 (sizeof (Command)); Command.ordinal = SwapBytes32 (TPM_ORD_ContinueSelfTest); + Length = sizeof (Response); return Tpm12SubmitCommand (sizeof (Command), (UINT8 *), , (UINT8 *)); } -- 2.6.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] SecurityPkg: Fix TPM 1.2 SelfTest command bug. Specify command response length.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Derek Lin <derek.l...@hpe.com> --- SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c index cd08d19..8e232ee 100644 --- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c +++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c @@ -2,6 +2,7 @@ Implement TPM1.2 NV Self Test related commands. Copyright (c) 2016, Intel Corporation. All rights reserved. +(C) Copyright 2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -42,5 +43,6 @@ Tpm12ContinueSelfTest ( Command.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND); Command.paramSize = SwapBytes32 (sizeof (Command)); Command.ordinal = SwapBytes32 (TPM_ORD_ContinueSelfTest); + Length = sizeof (Response); return Tpm12SubmitCommand (sizeof (Command), (UINT8 *), , (UINT8 *)); } -- 2.6.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH v2] MdeModulePkg Variable: Enhance variable performance by reading from existed memory cache.
Current variable driver already have memory cache to improve performance. Change the code which read from physical MMIO address to read from memory cache. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Derek Lin <derek.l...@hpe.com> --- Changes in v2: - change one calculation according to Star Zeng's suggestion. - remove unused VariableStoreHeader declaration. --- .../Universal/Variable/RuntimeDxe/Variable.c | 52 +- .../Universal/Variable/RuntimeDxe/VariableDxe.c| 27 ++- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 31e1937..aad9303 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -17,6 +17,7 @@ integer overflow. It should also check attribute to avoid authentication bypass. Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. +(C) Copyright 2015 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -37,6 +38,11 @@ VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal; VARIABLE_STORE_HEADER *mNvVariableCache = NULL; /// +/// Memory cache of Fv Header. +/// +EFI_FIRMWARE_VOLUME_HEADER *mNvFvHeaderCache= NULL; + +/// /// The memory entry used for variable statistics data. /// VARIABLE_INFO_ENTRY*gVariableInfo = NULL; @@ -333,7 +339,7 @@ UpdateVariableStore ( return EFI_INVALID_PARAMETER; } - for (PtrBlockMapEntry = FwVolHeader->BlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) { + for (PtrBlockMapEntry = mNvFvHeaderCache->BlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) { for (BlockIndex2 = 0; BlockIndex2 < PtrBlockMapEntry->NumBlocks; BlockIndex2++) { // // Check to see if the Variable Writes are spanning through multiple @@ -2209,7 +2215,8 @@ UpdateVariable ( VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINTN) mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase); Variable = Variable->StartPtr = GetStartPointer (VariableStoreHeader); -Variable->EndPtr = GetEndPointer (VariableStoreHeader); +Variable->EndPtr = (VARIABLE_HEADER *)((UINTN)Variable->StartPtr + ((UINTN)CacheVariable->EndPtr - (UINTN)CacheVariable->StartPtr)); + Variable->CurrPtr = (VARIABLE_HEADER *)((UINTN)Variable->StartPtr + ((UINTN)CacheVariable->CurrPtr - (UINTN)CacheVariable->StartPtr)); if (CacheVariable->InDeletedTransitionPtr != NULL) { Variable->InDeletedTransitionPtr = (VARIABLE_HEADER *)((UINTN)Variable->StartPtr + ((UINTN)CacheVariable->InDeletedTransitionPtr - (UINTN)CacheVariable->StartPtr)); @@ -2247,7 +2254,7 @@ UpdateVariable ( // // Only variable that have NV attributes can be updated/deleted in Runtime. // - if ((Variable->CurrPtr->Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) { + if ((CacheVariable->CurrPtr->Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -2255,7 +2262,7 @@ UpdateVariable ( // // Only variable that have RT attributes can be updated/deleted in Runtime. // - if ((Variable->CurrPtr->Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0) { + if ((CacheVariable->CurrPtr->Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -2273,7 +2280,7 @@ UpdateVariable ( // Both ADDED and IN_DELETED_TRANSITION variable are present, // set IN_DELETED_TRANSITION one to DELETED state first. // -State = Variable->InDeletedTransitionPtr->State; +State = CacheVariable->InDeletedTransitionPtr->State; State &= VAR_DELETED; Status = UpdateVariableStore ( >VariableGlobal, @@ -2294,7 +2301,7 @@ UpdateVariable ( } } - State = Variable->CurrPtr->State; + State = CacheVariable->CurrPtr->State; State &= VAR_DELETED; Status = UpdateVariableStore ( @@ -2319,8 +2326,8 @@ UpdateVariable ( // If the variable is marked valid, and the same data has been passed in, // then return to the caller immediately. // -if (DataSizeOfVariable (Variable->CurrPtr) == DataSize && -(CompareMem (Data, GetVariableDataPtr (Variable->CurrPtr), DataSize) == 0) && +if (DataSizeOfVariable (CacheVariable->CurrPtr) == DataSize && +(CompareMem (Data, GetVariableDataPtr (Cac
[edk2] [PATCH] MdeModulePkg Variable: Enhance variable performance by reading from existed memory cache.
Current variable driver already have memory cache to improve performance. Change the code which read from physical MMIO address to read from memory cache. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Derek Lin <derek.l...@hpe.com> --- .../Universal/Variable/RuntimeDxe/Variable.c | 49 +- .../Universal/Variable/RuntimeDxe/VariableDxe.c| 27 ++-- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 31e1937..aac3942 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -17,6 +17,7 @@ integer overflow. It should also check attribute to avoid authentication bypass. Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. +(C) Copyright 2015 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -37,6 +38,11 @@ VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal; VARIABLE_STORE_HEADER *mNvVariableCache = NULL; /// +/// Memory cache of Fv Header. +/// +EFI_FIRMWARE_VOLUME_HEADER *mNvFvHeaderCache= NULL; + +/// /// The memory entry used for variable statistics data. /// VARIABLE_INFO_ENTRY*gVariableInfo = NULL; @@ -333,7 +339,7 @@ UpdateVariableStore ( return EFI_INVALID_PARAMETER; } - for (PtrBlockMapEntry = FwVolHeader->BlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) { + for (PtrBlockMapEntry = mNvFvHeaderCache->BlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) { for (BlockIndex2 = 0; BlockIndex2 < PtrBlockMapEntry->NumBlocks; BlockIndex2++) { // // Check to see if the Variable Writes are spanning through multiple @@ -2209,7 +2215,7 @@ UpdateVariable ( VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINTN) mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase); Variable = Variable->StartPtr = GetStartPointer (VariableStoreHeader); -Variable->EndPtr = GetEndPointer (VariableStoreHeader); +Variable->EndPtr = (VARIABLE_HEADER *) ((UINT8 *) VariableStoreHeader + ((UINTN) GetEndPointer (mNvVariableCache) - (UINTN) mNvVariableCache)); Variable->CurrPtr = (VARIABLE_HEADER *)((UINTN)Variable->StartPtr + ((UINTN)CacheVariable->CurrPtr - (UINTN)CacheVariable->StartPtr)); if (CacheVariable->InDeletedTransitionPtr != NULL) { Variable->InDeletedTransitionPtr = (VARIABLE_HEADER *)((UINTN)Variable->StartPtr + ((UINTN)CacheVariable->InDeletedTransitionPtr - (UINTN)CacheVariable->StartPtr)); @@ -2247,7 +2253,7 @@ UpdateVariable ( // // Only variable that have NV attributes can be updated/deleted in Runtime. // - if ((Variable->CurrPtr->Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) { + if ((CacheVariable->CurrPtr->Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -2255,7 +2261,7 @@ UpdateVariable ( // // Only variable that have RT attributes can be updated/deleted in Runtime. // - if ((Variable->CurrPtr->Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0) { + if ((CacheVariable->CurrPtr->Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -2273,7 +2279,7 @@ UpdateVariable ( // Both ADDED and IN_DELETED_TRANSITION variable are present, // set IN_DELETED_TRANSITION one to DELETED state first. // -State = Variable->InDeletedTransitionPtr->State; +State = CacheVariable->InDeletedTransitionPtr->State; State &= VAR_DELETED; Status = UpdateVariableStore ( >VariableGlobal, @@ -2294,7 +2300,7 @@ UpdateVariable ( } } - State = Variable->CurrPtr->State; + State = CacheVariable->CurrPtr->State; State &= VAR_DELETED; Status = UpdateVariableStore ( @@ -2319,8 +2325,8 @@ UpdateVariable ( // If the variable is marked valid, and the same data has been passed in, // then return to the caller immediately. // -if (DataSizeOfVariable (Variable->CurrPtr) == DataSize && -(CompareMem (Data, GetVariableDataPtr (Variable->CurrPtr), DataSize) == 0) && +if (DataSizeOfVariable (CacheVariable->CurrPtr) == DataSize && +(CompareMem (Data, GetVariableDataPtr (CacheVariable->CurrPtr), DataSize) == 0) && ((Attributes & EFI_VARIABLE_APPEND_WRITE) == 0) && (TimeSt