[edk2] [PATCH v5 0/1] Add ArmPkg/Optee library APIs

2018-10-21 Thread Sumit Garg
Changes in v5:
Define RFC4122_UUID struct using network byte order instead of 16 byte
octects for passing Trusted Application UUID.

Changes in v4:
Replaced abbreviations with full name which are not defined in [1]. Also
used EFI_GUID for Trusted Application UUIDs.

[1] 
https://edk2-docs.gitbooks.io/edk-ii-c-coding-standards-specification/content/v/release/2.20/4_naming_conventions/#table-2-efi-supported-abbreviations

Changes in v3:
Removed GlobalPlatform TEE return codes (IndustryStandard/GlobalPlatform.h)
that were rejected by EDK2 maintainers. Rather used custom ones for this
OP-TEE driver.

Changes in v2:
1. Separate patch for MdePkg/Include/IndustryStandard/GlobalPlatform.h.
2. Correct comments style for struct members.
3. Update commit message.

Sumit Garg (1):
  ArmPkg/OpteeLib: Add APIs to communicate with OP-TEE

 ArmPkg/Library/OpteeLib/OpteeLib.inf |   2 +
 ArmPkg/Include/Library/OpteeLib.h|  88 +
 ArmPkg/Library/OpteeLib/OpteeSmc.h   |  53 +++
 ArmPkg/Library/OpteeLib/Optee.c  | 392 
 4 files changed, 535 insertions(+)
 create mode 100644 ArmPkg/Library/OpteeLib/OpteeSmc.h

-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v5 1/1] ArmPkg/OpteeLib: Add APIs to communicate with OP-TEE

2018-10-21 Thread Sumit Garg
Add following APIs to communicate with OP-TEE pseudo/early TAs:
1. OpteeInit
2. OpteeOpenSession
3. OpteeCloseSession
4. OpteeInvokeFunc

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sumit Garg 
---
 ArmPkg/Library/OpteeLib/OpteeLib.inf |   2 +
 ArmPkg/Include/Library/OpteeLib.h|  88 +
 ArmPkg/Library/OpteeLib/OpteeSmc.h   |  53 +++
 ArmPkg/Library/OpteeLib/Optee.c  | 392 
 4 files changed, 535 insertions(+)

diff --git a/ArmPkg/Library/OpteeLib/OpteeLib.inf 
b/ArmPkg/Library/OpteeLib/OpteeLib.inf
index 5abd427379cc..e03054a7167d 100644
--- a/ArmPkg/Library/OpteeLib/OpteeLib.inf
+++ b/ArmPkg/Library/OpteeLib/OpteeLib.inf
@@ -23,11 +23,13 @@ [Defines]
 
 [Sources]
   Optee.c
+  OpteeSmc.h
 
 [Packages]
   ArmPkg/ArmPkg.dec
   MdePkg/MdePkg.dec
 
 [LibraryClasses]
+  ArmMmuLib
   ArmSmcLib
   BaseLib
diff --git a/ArmPkg/Include/Library/OpteeLib.h 
b/ArmPkg/Include/Library/OpteeLib.h
index f65d8674d9b8..6884d5681831 100644
--- a/ArmPkg/Include/Library/OpteeLib.h
+++ b/ArmPkg/Include/Library/OpteeLib.h
@@ -25,10 +25,98 @@
 #define OPTEE_OS_UID2  0xaf630002
 #define OPTEE_OS_UID3  0xa5d5c51b
 
+#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE0x0
+#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INPUT 0x1
+#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_OUTPUT0x2
+#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INOUT 0x3
+#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INPUT0x9
+#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_OUTPUT   0xa
+#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INOUT0xb
+
+#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MASK0xff
+
+#define OPTEE_ORIGIN_COMMUNICATION  0x0002
+#define OPTEE_ERROR_COMMUNICATION   0x000E
+
+typedef struct {
+  UINT64BufferAddress;
+  UINT64Size;
+  UINT64SharedMemoryReference;
+} OPTEE_MESSAGE_PARAM_MEMORY;
+
+typedef struct {
+  UINT64A;
+  UINT64B;
+  UINT64C;
+} OPTEE_MESSAGE_PARAM_VALUE;
+
+typedef struct {
+  UINT64 Attribute;
+  union {
+OPTEE_MESSAGE_PARAM_MEMORY   Memory;
+OPTEE_MESSAGE_PARAM_VALUEValue;
+  } Union;
+} OPTEE_MESSAGE_PARAM;
+
+#define OPTEE_MAX_CALL_PARAMS   4
+
+typedef struct {
+  UINT32Command;
+  UINT32Function;
+  UINT32Session;
+  UINT32CancelId;
+  UINT32Pad;
+  UINT32Return;
+  UINT32ReturnOrigin;
+  UINT32NumParams;
+
+  // NumParams tells the actual number of element in Params
+  OPTEE_MESSAGE_PARAM  Params[OPTEE_MAX_CALL_PARAMS];
+} OPTEE_MESSAGE_ARG;
+
+typedef struct {
+  EFI_GUID  Uuid;   // [in] GUID/UUID of the Trusted Application
+  UINT32Session;// [out] Session id
+  UINT32Return; // [out] Return value
+  UINT32ReturnOrigin;   // [out] Origin of the return value
+} OPTEE_OPEN_SESSION_ARG;
+
+typedef struct {
+  UINT32Function;   // [in] Trusted Application function, specific to 
the TA
+  UINT32Session;// [in] Session id
+  UINT32Return; // [out] Return value
+  UINT32ReturnOrigin;   // [out] Origin of the return value
+  OPTEE_MESSAGE_PARAM  Params[OPTEE_MAX_CALL_PARAMS]; // Params for function 
to be invoked
+} OPTEE_INVOKE_FUNCTION_ARG;
+
 BOOLEAN
 EFIAPI
 IsOpteePresent (
   VOID
   );
 
+EFI_STATUS
+EFIAPI
+OpteeInit (
+  VOID
+  );
+
+EFI_STATUS
+EFIAPI
+OpteeOpenSession (
+  IN OUT OPTEE_OPEN_SESSION_ARG  *OpenSessionArg
+  );
+
+EFI_STATUS
+EFIAPI
+OpteeCloseSession (
+  IN UINT32  Session
+  );
+
+EFI_STATUS
+EFIAPI
+OpteeInvokeFunction (
+  IN OUT OPTEE_INVOKE_FUNCTION_ARG   *InvokeFunctionArg
+  );
+
 #endif
diff --git a/ArmPkg/Library/OpteeLib/OpteeSmc.h 
b/ArmPkg/Library/OpteeLib/OpteeSmc.h
new file mode 100644
index ..9cccd81810c9
--- /dev/null
+++ b/ArmPkg/Library/OpteeLib/OpteeSmc.h
@@ -0,0 +1,53 @@
+/** @file
+  OP-TEE SMC header file.
+
+  Copyright (c) 2018, Linaro Ltd. All rights reserved.
+
+  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
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _OPTEE_SMC_H_
+#define _OPTEE_SMC_H_
+
+/* Returned in Arg0 only from Trusted OS functions */
+#define OPTEE_SMC_RETURN_OK 0x0
+
+#define OPTEE_SMC_RETURN_FROM_RPC   0x3203
+#define OPTEE_SMC_CALL_WITH_ARG 0x3204
+#define OPTEE_SMC_GET_SHARED_MEMORY_CONFIG  0xb207
+
+#define OPTEE_SMC_SHARED_MEMORY_CACHED  1
+
+#define OPTEE_SMC_RETURN_RPC_FOREIGN_INTERRUPT  0x0004
+
+#define OPTEE_MESSAGE_COMMAND_OPEN_SESSION  0
+#defin

Re: [edk2] [staging/MicroPythonTestFramework]: MicroPython Test Framework for UEFI

2018-10-21 Thread Long, Qin
Hi, Leif,

Yes, we missed clear descriptions about these two external projects in 
staging/MicroPythonTestFramework. Sorry about that.

The MicroPython and Oniguruma projects were used as git submodule in this 
project. So you can use “git submodule” to know the specific commit information:
$ git submodule
-d4e4bd2a8163f355fa8a3884077eaec7adc75ff7 CryptoPkg/Library/OpensslLib/openssl
-421b84af9968e582f324899934f52b3df60381ee MicroPythonPkg/MicroPython
   --> MicroPython-v1.9.4
-dba71710cd657ebd886ab2b712931542507fadb8 MicroPythonPkg/Oniguruma  
 --> Oniguruma-v6.8.2

And use update command to init and sync-up all submodules:
$ git submodule update --init --recursive

(Will update the README for more clear information later . Thanks)


Best Regards & Thanks,
LONG, Qin


From: Leif Lindholm [mailto:leif.lindh...@linaro.org]
Sent: Saturday, October 20, 2018 6:10 PM
To: Long, Qin 
Cc: Richardson, Brian ; edk2-devel@lists.01.org
Subject: Re: [edk2] [staging/MicroPythonTestFramework]: MicroPython Test 
Framework for UEFI

Thanks Brian,

Long, could you please
1) Send me the commit hashes of micropython and oniguruma that you
   have tested with the overrides?
2) Add a top-level Readme.md to the MicroPythonTestFramework branch,
   mentioning yourself as maintainer and the commit hashes of any
   external projects used?

Best Regards,

Leif

On Fri, Oct 19, 2018 at 06:18:35AM +, Richardson, Brian wrote:
> Leif:
>
> Thank you for your feedback. Long Qin is a good starting contact for 
> MicroPython issues.
>
> There are readme files for the sub-components, but I agree that the missing 
> top-level readme file is an issue.
> https://github.com/tianocore/edk2-staging/tree/MicroPythonTestFramework/MpyTestFrameworkPkg
> https://github.com/tianocore/edk2-staging/tree/MicroPythonTestFramework/MicroPythonPkg
>
> Thanks … br
> ---
> Brian Richardson, Firmware Ecosystem Development, Intel Software
> brian.richard...@intel.com>
>  -- @intel_brian (Twitter & WeChat)
> https://software.intel.com/en-us/meet-the-developers/evangelists/team/brian-richardson
>
> From: Leif Lindholm 
> mailto:leif.lindh...@linaro.org>>
> Sent: Friday, October 19, 2018 12:34 AM
> To: Richardson, Brian 
> mailto:brian.richard...@intel.com>>
> Cc: edk2-devel@lists.01.org
> Subject: Re: [edk2] [staging/MicroPythonTestFramework]: MicroPython Test 
> Framework for UEFI
>
> Hi Brian,
>
> I've started having a look at this, and have a few comments:
> - There is no Readme.md at the top level, as set out in 
> https://github.com/tianocore/edk2-staging/blob/about/README
>   Mainly, this means I don't know who I should cc on any comments I have.
> - There have been substantial changes to oniguruma, and the module no longer 
> builds. Can we have exact commit hashes for the two external projects added 
> to the toplevel Readme.md?
> - At least Uefi/modets.c and Uefi/modos.c contain Ia32/X64-specific bits. 
> Could these bits be put in architecture-specific subdirectories?
>
> Regards,
>
> Leif
>
> On 10 August 2018 at 03:44, Richardson, Brian 
> mailto:brian.richard...@intel.com>>
>  wrote:
> The "MicroPython Test Framework for UEFI" project has been added to 
> edk2-staging for community feedback.
> https://github.com/tianocore/edk2-staging/tree/MicroPythonTestFramework
>
> This includes a port of MicroPython to UEFI and a test execution environment 
> that can run from the UEFI Shell.
> https://github.com/tianocore/edk2-staging/tree/MicroPythonTestFramework/MicroPythonPkg
> https://github.com/tianocore/edk2-staging/tree/MicroPythonTestFramework/MpyTestFrameworkPkg
>
> Additional Info:
> https://github.com/tianocore/tianocore.github.io/wiki/MicroPython-Test-Framework-for-UEFI
>
> Thanks ... br
> ---
> Brian Richardson, Senior Technical Marketing Engineer, Intel Software
> brian.richard...@intel.com>>
>  -- @intel_brian (Twitter & WeChat)
> https://software.intel.com/en-us/meet-the-developers/evangelists/team/brian-richardson
>
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org>
> https://lists.01.org/mailman/listinfo/edk2-devel
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] BaseTools: Move PcdValueInit to platform build folder

2018-10-21 Thread BobCF
PcdValueInit tool is platform scope.
It should be generated into Platform output directory.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob C Feng 
Cc: Liming Gao 
---
 .../Source/Python/Workspace/DscBuildData.py   | 25 +--
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 17e6f62cac..6fe03ff91a 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -84,10 +84,16 @@ PcdMakefileEnd = '''
 LIBS = $(LIB_PATH)\Common.lib
 
 !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app
 '''
 
+AppTarget = '''
+all: $(APPFILE)
+$(APPFILE): $(OBJECTS)
+%s
+'''
+
 PcdGccMakefile = '''
 MAKEROOT ?= $(EDK_TOOLS_PATH)/Source/C
 LIBS = -lCommon
 '''
 
@@ -2253,14 +2259,14 @@ class DscBuildData(PlatformBuildClassObject):
 CAppBaseFileName = os.path.join(self.OutputPath, PcdValueInitName)
 SaveFileOnChange(CAppBaseFileName + '.c', CApp, False)
 
 MakeApp = PcdMakefileHeader
 if sys.platform == "win32":
-MakeApp = MakeApp + 'APPNAME = %s\n' % (PcdValueInitName) + 
'OBJECTS = %s\%s.obj\n' % (self.OutputPath, PcdValueInitName) + 'INC = '
+MakeApp = MakeApp + 'APPFILE = %s\%s.exe\n' % (self.OutputPath, 
PcdValueInitName) + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = 
%s\%s.obj\n' % (self.OutputPath, PcdValueInitName) + 'INC = '
 else:
 MakeApp = MakeApp + PcdGccMakefile
-MakeApp = MakeApp + 'APPNAME = %s\n' % (PcdValueInitName) + 
'OBJECTS = %s/%s.o\n' % (self.OutputPath, PcdValueInitName) + \
+MakeApp = MakeApp + 'APPFILE = %s/%s\n' % (self.OutputPath, 
PcdValueInitName) + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = 
%s/%s.o\n' % (self.OutputPath, PcdValueInitName) + \
   'include $(MAKEROOT)/Makefiles/app.makefile\n' + 
'INCLUDE +='
 
 IncSearchList = []
 PlatformInc = OrderedDict()
 for Cache in self._Bdb._CACHE_.values():
@@ -2332,10 +2338,13 @@ class DscBuildData(PlatformBuildClassObject):
 CC_FLAGS += ' ' + Item
 MakeApp += CC_FLAGS
 
 if sys.platform == "win32":
 MakeApp = MakeApp + PcdMakefileEnd
+MakeApp = MakeApp + AppTarget % ("""\tcopy $(APPLICATION) 
$(APPFILE) /y """)
+else:
+MakeApp = MakeApp + AppTarget % ("""\tcp $(APPLICATION) $(APPFILE) 
""")
 MakeApp = MakeApp + '\n'
 IncludeFileFullPaths = []
 for includefile in IncludeFiles:
 for includepath in IncSearchList:
 includefullpath = os.path.join(str(includepath), includefile)
@@ -2355,25 +2364,25 @@ class DscBuildData(PlatformBuildClassObject):
 
 InputValueFile = os.path.join(self.OutputPath, 'Input.txt')
 OutputValueFile = os.path.join(self.OutputPath, 'Output.txt')
 SaveFileOnChange(InputValueFile, InitByteValue, False)
 
-PcdValueInitExe = PcdValueInitName
+Dest_PcdValueInitExe = PcdValueInitName
 if not sys.platform == "win32":
-PcdValueInitExe = os.path.join(os.getenv("EDK_TOOLS_PATH"), 
'Source', 'C', 'bin', PcdValueInitName)
+Dest_PcdValueInitExe = os.path.join(self.OutputPath, 
PcdValueInitName)
 else:
-PcdValueInitExe = os.path.join(os.getenv("EDK_TOOLS_PATH"), 'Bin', 
'Win32', PcdValueInitName) +".exe"
-
+Dest_PcdValueInitExe = os.path.join(self.OutputPath, 
PcdValueInitName) +".exe"
 Messages = ''
 if sys.platform == "win32":
 MakeCommand = 'nmake -f %s' % (MakeFileName)
 returncode, StdOut, StdErr = DscBuildData.ExecuteCommand 
(MakeCommand)
 Messages = StdOut
 else:
 MakeCommand = 'make -f %s' % (MakeFileName)
 returncode, StdOut, StdErr = DscBuildData.ExecuteCommand 
(MakeCommand)
 Messages = StdErr
+
 Messages = Messages.split('\n')
 MessageGroup = []
 if returncode != 0:
 CAppBaseFileName = os.path.join(self.OutputPath, PcdValueInitName)
 File = open (CAppBaseFileName + '.c', 'r')
@@ -2414,12 +2423,12 @@ class DscBuildData(PlatformBuildClassObject):
 if MessageGroup:
 EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, 
"\n".join(MessageGroup) )
 else:
 EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute 
command: %s' % MakeCommand)
 
-if DscBuildData.NeedUpdateOutput(OutputValueFile, PcdValueInitExe, 
InputValueFile):
-Command = PcdValueInitExe + ' -i %s -o %s' % (InputValueFile, 
OutputValueFile)
+if DscBuildData.NeedUpdateOutput(OutputValueFile, 
Dest_PcdValueInitExe, InputValueFile):
+Command = Dest_PcdValueInitExe + ' -i %s -o %s' % (InputValueFile, 
OutputValueFile)

Re: [edk2] [PATCH v2] Edk2Platforms: Replace FatBinPkg with FatPkg

2018-10-21 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com


> -Original Message-
> From: Zhang, Shenglei
> Sent: Monday, October 22, 2018 11:03 AM
> To: Yao, Jiewen ; 'edk2-devel@lists.01.org'
> 
> Cc: Zhang, Shenglei 
> Subject: RE: [edk2] [PATCH v2] Edk2Platforms: Replace FatBinPkg with
> FatPkg
> 
> Hi Jiewen,
> 
> After my test, the KabyLake Platform based on my changes can be booted to
> Shell successfully. And a disk can be recognized correctly.
> 
> Thanks,
> Shenglei
> 
> > -Original Message-
> > From: Zhang, Shenglei
> > Sent: Thursday, October 18, 2018 4:38 PM
> > To: Yao, Jiewen ; edk2-devel@lists.01.org
> > Subject: RE: [edk2] [PATCH v2] Edk2Platforms: Replace FatBinPkg with
> FatPkg
> >
> >
> >
> > > -Original Message-
> > > From: Yao, Jiewen
> > > Sent: Thursday, October 18, 2018 11:00 AM
> > > To: Zhang, Shenglei ;
> edk2-devel@lists.01.org
> > > Cc: Yao, Jiewen 
> > > Subject: RE: [edk2] [PATCH v2] Edk2Platforms: Replace FatBinPkg with
> > FatPkg
> > >
> > > Hi
> > > Would you please share what test has been done?
> >
> > I build edk2-platfroms for MinKabylake according to "readme" in edk2-
> > platforms.
> > And the EDKII BIOS build has successfully completed.
> >
> > Thanks,
> > Shenglei
> >
> > >
> > > Thank you
> > > Yao Jiewen
> > >
> > >
> > > > -Original Message-
> > > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf
> Of
> > > > shenglei
> > > > Sent: Thursday, October 18, 2018 10:35 AM
> > > > To: edk2-devel@lists.01.org
> > > > Subject: [edk2] [PATCH v2] Edk2Platforms: Replace FatBinPkg with
> FatPkg
> > > >
> > > > In order to remove FatBinPkg, relationships depend on
> > > > FatBinPkg need to be replaced by FatPkg.
> > > >
> > > > v2:
> > > > 1.Replace FatBinPkg with FatPkg in CoreUefiBootInclude.fdf.
> > > > 2.Update the subject.
> > > >
> > > > Change-Id: I8949ad1c7d18abc56deac2d4b4381e00f030dcb2
> > > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > > Signed-off-by: Shenglei Zhang 
> > > > ---
> > > >  Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc
> | 2 +-
> > > >  .../Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf|
> 2 +-
> > > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git
> > > a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc
> > > > b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc
> > > > index 73aafce141..9b033f43a6 100644
> > > > --- a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc
> > > > +++ b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc
> > > > @@ -84,7 +84,7 @@
> > > >MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
> > > >MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
> > > >
> > > >
> > >
> >
> MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
> > > > -  FatBinPkg/EnhancedFatDxe/Fat.inf
> > > > +  FatPkg/EnhancedFatDxe/Fat.inf
> > > >
> > > >
> > > >
> > >
> > #MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputD
> > > x
> > > > e.inf
> > > >
> > > >
> > >
> >
> MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
> > > > xe.inf
> > > > diff --git
> > > >
> a/Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf
> > > >
> b/Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf
> > > > index 6406192443..da5ca76197 100644
> > > > ---
> > a/Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf
> > > > +++
> > > b/Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf
> > > > @@ -58,7 +58,7 @@ INF
> > > > MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
> > > >  INF  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
> > > >  INF  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
> > > >  INF
> > > >
> > >
> >
> MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
> > > > -INF  FatBinPkg/EnhancedFatDxe/Fat.inf
> > > > +INF  FatPkg/EnhancedFatDxe/Fat.inf
> > > >
> > > >  #INF
> > > >
> > >
> > MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDx
> > > e.
> > > > inf
> > > >  INF
> > > >
> > >
> >
> MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
> > > > xe.inf
> > > > --
> > > > 2.18.0.windows.1
> > > >
> > > > ___
> > > > edk2-devel mailing list
> > > > edk2-devel@lists.01.org
> > > > https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2] Edk2Platforms: Replace FatBinPkg with FatPkg

2018-10-21 Thread Zhang, Shenglei
Hi Jiewen,

After my test, the KabyLake Platform based on my changes can be booted to Shell 
successfully. And a disk can be recognized correctly.

Thanks,
Shenglei

> -Original Message-
> From: Zhang, Shenglei
> Sent: Thursday, October 18, 2018 4:38 PM
> To: Yao, Jiewen ; edk2-devel@lists.01.org
> Subject: RE: [edk2] [PATCH v2] Edk2Platforms: Replace FatBinPkg with FatPkg
> 
> 
> 
> > -Original Message-
> > From: Yao, Jiewen
> > Sent: Thursday, October 18, 2018 11:00 AM
> > To: Zhang, Shenglei ; edk2-devel@lists.01.org
> > Cc: Yao, Jiewen 
> > Subject: RE: [edk2] [PATCH v2] Edk2Platforms: Replace FatBinPkg with
> FatPkg
> >
> > Hi
> > Would you please share what test has been done?
> 
> I build edk2-platfroms for MinKabylake according to "readme" in edk2-
> platforms.
> And the EDKII BIOS build has successfully completed.
> 
> Thanks,
> Shenglei
> 
> >
> > Thank you
> > Yao Jiewen
> >
> >
> > > -Original Message-
> > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > > shenglei
> > > Sent: Thursday, October 18, 2018 10:35 AM
> > > To: edk2-devel@lists.01.org
> > > Subject: [edk2] [PATCH v2] Edk2Platforms: Replace FatBinPkg with FatPkg
> > >
> > > In order to remove FatBinPkg, relationships depend on
> > > FatBinPkg need to be replaced by FatPkg.
> > >
> > > v2:
> > > 1.Replace FatBinPkg with FatPkg in CoreUefiBootInclude.fdf.
> > > 2.Update the subject.
> > >
> > > Change-Id: I8949ad1c7d18abc56deac2d4b4381e00f030dcb2
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Shenglei Zhang 
> > > ---
> > >  Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc| 2 +-
> > >  .../Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf| 2 +-
> > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git
> > a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc
> > > b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc
> > > index 73aafce141..9b033f43a6 100644
> > > --- a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc
> > > +++ b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc
> > > @@ -84,7 +84,7 @@
> > >MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
> > >MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
> > >
> > >
> >
> MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
> > > -  FatBinPkg/EnhancedFatDxe/Fat.inf
> > > +  FatPkg/EnhancedFatDxe/Fat.inf
> > >
> > >
> > >
> >
> #MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputD
> > x
> > > e.inf
> > >
> > >
> >
> MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
> > > xe.inf
> > > diff --git
> > > a/Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf
> > > b/Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf
> > > index 6406192443..da5ca76197 100644
> > > ---
> a/Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf
> > > +++
> > b/Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf
> > > @@ -58,7 +58,7 @@ INF
> > > MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
> > >  INF  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
> > >  INF  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
> > >  INF
> > >
> >
> MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
> > > -INF  FatBinPkg/EnhancedFatDxe/Fat.inf
> > > +INF  FatPkg/EnhancedFatDxe/Fat.inf
> > >
> > >  #INF
> > >
> >
> MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDx
> > e.
> > > inf
> > >  INF
> > >
> >
> MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
> > > xe.inf
> > > --
> > > 2.18.0.windows.1
> > >
> > > ___
> > > edk2-devel mailing list
> > > edk2-devel@lists.01.org
> > > https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 3/3] MdeModulePkg/Core: add use-after-free memory detection

2018-10-21 Thread Zeng, Star

On 2018/10/19 9:50, Jian J Wang wrote:

UAF (Use-After-Free) memory detection is new feature introduced to
detect illegal access to memory which has been freed. The principle
behind is similar to heap guard feature, that is the core turn all pool
memory allocation to page allocation and mark them to be not-present
once they are freed.

This also implies that, once a page is allocated and freed, it cannot
be re-allocated. This will bring another issue, which is that there's
risk that memory space will be used out. To address it, the memory
service add logic to put part (at most 64 pages a time) of freed pages
back into page pool, so that the memory service can still have memory
to allocate, when all memory space have been allocated once. This is
called memory promotion. The promoted pages are always from the eldest
pages which haven been freed.

To use this feature, one can simply set following PCD to 1
   gEfiMdeModulePkgTokenSpaceGuid.PcdUseAfterFreeDetectionPropertyMask

Please note this feature cannot be used with heap guard feature controlled
by PCD gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask.

Cc: Star Zeng 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Cc: Ruiyu Ni 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 


I did not review the whole patch thoroughly. But I suggest that putting 
the code for UAF in a separated file if it is feasible. I am aware that 
UAF will be sharing much code with HeapGuard, so could we have Uaf.c, 
HeapGuard.c and GuardPage.c (this file name is just for example)?



---
  MdeModulePkg/Core/Dxe/DxeMain.h  |   1 +
  MdeModulePkg/Core/Dxe/DxeMain.inf|   1 +
  MdeModulePkg/Core/Dxe/Gcd/Gcd.c  |   8 +
  MdeModulePkg/Core/Dxe/Mem/HeapGuard.c| 393 ++-
  MdeModulePkg/Core/Dxe/Mem/HeapGuard.h|  66 +
  MdeModulePkg/Core/Dxe/Mem/Page.c |  39 ++-
  MdeModulePkg/Core/Dxe/Mem/Pool.c |  21 +-
  MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c |  16 +-
  8 files changed, 519 insertions(+), 26 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h
index 2dec9da5e3..ae75cc5b25 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.h
+++ b/MdeModulePkg/Core/Dxe/DxeMain.h
@@ -92,6 +92,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
  #include 
  #include 
  #include 
+#include 
  
  
  //

diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf 
b/MdeModulePkg/Core/Dxe/DxeMain.inf
index 10375443c0..d91258c087 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -198,6 +198,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPoolType   
## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask   
## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard   
## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseAfterFreeDetectionPropertyMask   ## 
CONSUMES
  
  # [Hob]

  # RESOURCE_DESCRIPTOR   ## CONSUMES
diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index d9c65a8045..e43ec74010 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -160,6 +160,10 @@ CoreDumpGcdMemorySpaceMap (
  EFI_GCD_MEMORY_SPACE_DESCRIPTOR  *MemorySpaceMap;
  UINTNIndex;
  
+if ((GetDebugPrintErrorLevel () & DEBUG_GCD) == 0) {

+  return;
+}


I am aware the purpose of this change to optimize some code when 
DEBUG_GCD is not set.
But I do not suggest we newly introduce the dependency to 
DebugPrintErrorLevelLib, I think this check should be hidden in the 
instance of DebugLib. Maybe a new macro DEBUG_CODE_ERROR_LEVEL (this 
macro name is just for example) can be introduced if we really want to 
do that.



Thanks,
Star


+
  Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
  ASSERT (Status == EFI_SUCCESS && MemorySpaceMap != NULL);
  
@@ -202,6 +206,10 @@ CoreDumpGcdIoSpaceMap (

  EFI_GCD_IO_SPACE_DESCRIPTOR  *IoSpaceMap;
  UINTNIndex;
  
+if ((GetDebugPrintErrorLevel () & DEBUG_GCD) == 0) {

+  return;
+}
+
  Status = CoreGetIoSpaceMap (&NumberOfDescriptors, &IoSpaceMap);
  ASSERT (Status == EFI_SUCCESS && IoSpaceMap != NULL);
  
diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c

index 663f969c0d..b120c04f8f 100644
--- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
+++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
@@ -44,6 +44,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED UINTN 
mLevelShift[GUARDED_HEAP_MAP_TABLE_DEPTH]
  GLOBAL_REMOVE_IF_UNREFERENCED UINTN mLevelMask[GUARDED_HEAP_MAP_TABLE_DEPTH]
  = GUARDED_HEAP_MAP_TABLE_DEPTH_MASKS;
  
+//

+// Used for Use-After-Free memory detection to promote freed but not used 
pages.
+//
+GLOBAL_REMOVE_IF_U

Re: [edk2] [PATCH v1 2/2] EmbeddedPkg/Drivers: add DwUsb3Dxe driver

2018-10-21 Thread Haojian Zhuang
On Fri, 5 Oct 2018 at 00:32, Leif Lindholm  wrote:
>
> On Mon, Aug 20, 2018 at 06:31:25PM +0800, Haojian Zhuang wrote:
> > Add Designware USB 3.0 device driver. It's focus on USB device
> > functionality, not USB Host functionality. The USB driver is
> > mainly used for Android Fastboot application.
> >
> > Cc: Leif Lindholm 
> > Cc: Ard Biesheuvel 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Haojian Zhuang 
> > ---
> >  EmbeddedPkg/Drivers/DwUsb3Dxe/DwUsb3Dxe.dec |   44 +
> >  EmbeddedPkg/Drivers/DwUsb3Dxe/DwUsb3Dxe.inf |   52 +
> >  EmbeddedPkg/Drivers/DwUsb3Dxe/DwUsb3Dxe.h   |  632 +
> >  EmbeddedPkg/Drivers/DwUsb3Dxe/DwUsb3Dxe.c   | 2434 
> >  4 files changed, 3162 insertions(+)
> >
> > diff --git a/EmbeddedPkg/Drivers/DwUsb3Dxe/DwUsb3Dxe.dec 
> > b/EmbeddedPkg/Drivers/DwUsb3Dxe/DwUsb3Dxe.dec
> > new file mode 100644
> > index ..038e4881a948
> > --- /dev/null
> > +++ b/EmbeddedPkg/Drivers/DwUsb3Dxe/DwUsb3Dxe.dec
> > @@ -0,0 +1,44 @@
> > +#/** @file
> > +# Framework Module Development Environment Industry Standards
>
> Please change this to reflect this package rather than EmbeddedPkg one
> (which appears to have stolen it from an old version of MdePkg.dec :)
>

OK
> > +#
> > +# This Package provides headers and libraries that conform to EFI/PI 
> > Industry standards.
> > +# Copyright (c) 2007, Intel Corporation. All rights reserved.
> > +# Copyright (c) 2012-2014, ARM Ltd. All rights reserved.
>
> I see no need to keep these copyright statements.
>
OK

> > +# Copyright (c) 2018, Linaro. All rights reserved.
> > +#
> > +#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
> > +#http://opensource.org/licenses/bsd-license.php
> > +#
> > +#THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> > +#WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> > IMPLIED.
> > +#
> > +#**/
> > +
> > +[Defines]
> > +  DEC_SPECIFICATION  = 0x00010019
> > +  PACKAGE_NAME   = DwUsb3DxePkg
> > +  PACKAGE_GUID   = 9b7aa6fe-405b-4955-af1f-5faf183aedec
> > +  PACKAGE_VERSION= 0.1
> > +
> > +
> > +
> > +#
> > +# Include Section - list of Include Paths that are provided by this 
> > package.
> > +#   Comments are used for Keywords and Module Types.
> > +#
> > +# Supported Module Types:
> > +#  BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER 
> > DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
> > +#
> > +
> > +
> > +[Guids.common]
> > +  gDwUsb3DxeTokenSpaceGuid  = { 0x098a50d3, 0x92e2, 0x461a, { 0xb6, 
> > 0xba, 0xf8, 0x5d, 0x9d, 0x89, 0x49, 0xf5 }}
> > +
> > +[Protocols.common]
> > +  gDwUsbProtocolGuid= { 0x109fa264, 0x7811, 0x4862, { 0xa9, 
> > 0x73, 0x4a, 0xb2, 0xef, 0x2e, 0xe2, 0xff }}
>
> Please make this file a common .dec for DwUsb and DwUsb3 instead of
> duplicating guid information.
> (If we weren't moving it to edk2-platforms, it would still have been
> better to add it to EmbeddedPkg.dec.)
>
OK

> > +
> > +[PcdsFixedAtBuild.common]
> > +  # DwUsb Driver PCDs
> > +  gDwUsb3DxeTokenSpaceGuid.PcdDwUsb3DxeBaseAddress|0x0|UINT32|0x0001
> > diff --git a/EmbeddedPkg/Drivers/DwUsb3Dxe/DwUsb3Dxe.inf 
> > b/EmbeddedPkg/Drivers/DwUsb3Dxe/DwUsb3Dxe.inf
> > new file mode 100644
> > index ..510b51a34de7
> > --- /dev/null
> > +++ b/EmbeddedPkg/Drivers/DwUsb3Dxe/DwUsb3Dxe.inf
> > @@ -0,0 +1,52 @@
> > +#/** @file
> > +#
> > +#  Copyright (c) 2018, Linaro Limited. All rights reserved.
> > +#
> > +#  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
> > +#  http://opensource.org/licenses/bsd-license.php
> > +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> > +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> > IMPLIED.
> > +#
> > +#
> > +#**/
> > +
> > +[Defines]
> > +  INF_VERSION= 0x00010019
> > +  BASE_NAME  = DwUsb3Dxe
> > +  FILE_GUID  = 0879cd34-c399-4315-9891-56024072e711
> > +  MODULE_TYPE= UEFI_DRIVER
> > +  VERSION_STRING = 1.0
> > +  ENTRY_POINT= DwUsb3EntryPoint
> > +
> > +[Sources.common]
> > +  DwUsb3Dxe.c
> > +
> > +[LibraryClasses]
> > +  CacheMaintenanceLib
> > +  DebugLib
> > +  DmaLib
> > +  IoLib
> > +  MemoryAllocationLib
> > +  TimerLib
> > +  UefiBootServicesTableLib
> > +  Ue

Re: [edk2] [PATCH v1 1/2] EmbeddedPkg: add DwUsb protocol

2018-10-21 Thread Haojian Zhuang
On Thu, 4 Oct 2018 at 22:49, Leif Lindholm  wrote:
>
> On Mon, Aug 20, 2018 at 06:31:24PM +0800, Haojian Zhuang wrote:
> > The protocol defines the callbacks that could be implemented in
> > platform driver. DwUsb device driver needs these callbacks to
> > implement USB device functionality.
> >
> > Cc: Leif Lindholm 
> > Cc: Ard Biesheuvel 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Haojian Zhuang 
> > ---
> >  EmbeddedPkg/Include/Protocol/DwUsb.h | 81 
> >  1 file changed, 81 insertions(+)
> >
> > diff --git a/EmbeddedPkg/Include/Protocol/DwUsb.h 
> > b/EmbeddedPkg/Include/Protocol/DwUsb.h
> > new file mode 100644
> > index ..b9fb776f9258
> > --- /dev/null
> > +++ b/EmbeddedPkg/Include/Protocol/DwUsb.h
> > @@ -0,0 +1,81 @@
> > +/** @file
> > +
> > +  Copyright (c) 2018, Linaro. All rights reserved.
> > +
> > +  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
> > +  http://opensource.org/licenses/bsd-license.php
> > +
> > +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> > +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> > IMPLIED.
> > +
> > +**/
> > +
> > +#ifndef __DW_USB_H__
> > +#define __DW_USB_H__
>
> Can you expand all instances of public interfaces to DESIGNWARE?
>

OK

> > +
> > +//
> > +// Protocol GUID
> > +//
> > +#define DW_USB_PROTOCOL_GUID { 0x109fa264, 0x7811, 0x4862, { 0xa9, 0x73, 
> > 0x4a, 0xb2, 0xef, 0x2e, 0xe2, 0xff }}
> > +
> > +//
> > +// Protocol interface structure
> > +//
> > +typedef struct _DW_USB_PROTOCOL  DW_USB_PROTOCOL;
> > +
> > +#define USB_HOST_MODE 0
> > +#define USB_DEVICE_MODE   1
> > +#define USB_CABLE_NOT_ATTACHED2
>
> And add a DESIGNWARE_ prefix to these?
>
OK

> > +
> > +#define LANG_LENGTH   8
> > +#define MANU_FACTURER_STRING_LENGTH   32
>
> MANUFACTURER.
>
OK

> Why the hardcoded string lengths?
> Are they mandated somewhere?
>
> > +#define PRODUCT_STRING_LENGTH 32
> > +#define SERIAL_STRING_LENGTH  17
> > +
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *DW_USB_GET_LANG) (
> > +  OUT CHAR16   *Lang,
> > +  OUT UINT8*Length
> > +  );
> > +
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *DW_USB_GET_MANU_FACTURER) (
> > +  OUT CHAR16   *ManuFacturer,
>
> ManuFacturer ->
> Manufacturer.
>
OK

> > +  OUT UINT8*Length
> > +  );
> > +
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *DW_USB_GET_PRODUCT) (
> > +  OUT CHAR16   *Product,
> > +  OUT UINT8*Length
> > +  );
> > +
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *DW_USB_GET_SERIAL_NO) (
>
> SERIAL_NUMBER
>
> > +  OUT CHAR16   *SerialNo,
>
> SerialNumber.
>
OK

> > +  OUT UINT8*Length
> > +  );
> > +
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *DW_USB_PHY_INIT) (
> > +  IN UINT8 Mode
> > +  );
> > +
> > +struct _DW_USB_PROTOCOL {
> > +  DW_USB_GET_LANG  GetLang;
> > +  DW_USB_GET_MANU_FACTURER GetManuFacturer;
>
> GetManuFacturer ->
> GetManufacturer.
>
OK

> > +  DW_USB_GET_PRODUCT   GetProduct;
> > +  DW_USB_GET_SERIAL_NO GetSerialNo;
> > +  DW_USB_PHY_INIT  PhyInit;
> > +};
> > +
> > +extern EFI_GUID gDwUsbProtocolGuid;
>
> gDesignWareUsbProtocolGuid.
>
OK

Best Regards
Haojian
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v1 1/1] EmbeddedPkg/Drivers: add DwUsbDxe

2018-10-21 Thread Haojian Zhuang
On Fri, 5 Oct 2018 at 23:46, Leif Lindholm  wrote:
>
> On Tue, Aug 21, 2018 at 07:35:13PM +0800, Haojian Zhuang wrote:
> > Add Designware USB 2.0 device driver that is used on HiKey platform.
> >
> > Cc: Leif Lindholm 
> > Cc: Ard Biesheuvel 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Haojian Zhuang 
> > ---
> >  EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.dec |  45 +
> >  EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.inf |  52 ++
> >  EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.h   | 655 ++
> >  EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.c   | 912 
> >  4 files changed, 1664 insertions(+)
>
> Could it be renamed DwUsb2? This seems to match how Synopsys
> themselves refer to it, and what the Linux driver is called.
>
OK

> Other than that, same comments as for DwUsb3Dxe - please move it to
> edk2-platforms and convert it to UEFI driver model with
> NonDiscoverableDeviceRegistrationLib.
UsbDevice isn't supported by NonDiscoverableDeviceRegistrationLib.
Could I add a new type?

>
> Hmm, it also looks to me like there are plenty of things here
> hardcoded for the use as a device for fastboot. I don't object to
> that being the only support submitted, you made it clear when you
> posted it. But the code is completely geared towards this, and I feel
> if someone comes along and want to add the functionality to run it in
> host mode.

I hope to support device first.
>
> I expect I will find the same when I look at the reworked version of 
> DwUsb3Dxe.
>
> Is there anything you can do to break out the generic device
> configuration bits from the bits that assume there are two endpoints
> and they are being used for fastboot?

Let me investigate.

>
> >
> > diff --git a/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.dec 
> > b/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.dec
> > new file mode 100644
> > index ..7eb65e498c04
> > --- /dev/null
> > +++ b/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.dec
> > @@ -0,0 +1,45 @@
> > +#/** @file
> > +# Framework Module Development Environment Industry Standards
> > +#
> > +# This Package provides headers and libraries that conform to EFI/PI 
> > Industry standards.
> > +# Copyright (c) 2007, Intel Corporation. All rights reserved.
> > +# Copyright (c) 2012-2014, ARM Ltd. All rights reserved.
> > +# Copyright (c) 2018, Linaro. All rights reserved.
>
> Same comments as for DwUsb3 - please merge these two into a common one
> for both drivers (if still needed).
>
> > +#
> > +#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
> > +#http://opensource.org/licenses/bsd-license.php
> > +#
> > +#THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> > +#WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> > IMPLIED.
> > +#
> > +#**/
> > +
> > +[Defines]
> > +  DEC_SPECIFICATION  = 0x00010019
> > +  PACKAGE_NAME   = DwUsbDxePkg
> > +  PACKAGE_GUID   = 114a3be9-10f7-4bf1-81ca-09ac52d4c3d5
> > +  PACKAGE_VERSION= 0.1
> > +
> > +
> > +
> > +#
> > +# Include Section - list of Include Paths that are provided by this 
> > package.
> > +#   Comments are used for Keywords and Module Types.
> > +#
> > +# Supported Module Types:
> > +#  BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER 
> > DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
> > +#
> > +
> > +
> > +[Guids.common]
> > +  gDwUsbDxeTokenSpaceGuid   = { 0x131c4d02, 0x9449, 0x4ee9, { 0xba, 
> > 0x3d, 0x69, 0x50, 0x21, 0x89, 0x26, 0x0b }}
> > +
> > +[Protocols.common]
> > +  gDwUsbProtocolGuid= { 0x109fa264, 0x7811, 0x4862, { 0xa9, 
> > 0x73, 0x4a, 0xb2, 0xef, 0x2e, 0xe2, 0xff }}
> > +
> > +[PcdsFixedAtBuild.common]
> > +  # DwUsb Driver PCDs
> > +  gDwUsbDxeTokenSpaceGuid.PcdDwUsbDxeBaseAddress|0x0|UINT32|0x0001
> > +  gDwUsbDxeTokenSpaceGuid.PcdSysCtrlBaseAddress|0x0|UINT32|0x0002
>
> I don't see PcdSysCtrlBaseAddress used anywhere in this patch? It also
> doesn't sound like something that should be an aspect of the USB
> controller driver.
>
Yes, PcdSysCtrlBaseAddress isn't used. We could remove it now.

> > diff --git a/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.inf 
> > b/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.inf
> > new file mode 100644
> > index ..56d518c27c32
> > --- /dev/null
> > +++ b/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.inf
> > @@ -0,0 +1,52 @@
> > +#/** @file
> > +#
> > +#  Copyright (c) 2018, Linaro. All rights reserved.
> > +#
> > +#  This program and the accompanying materials are licensed and made 
> > available
> > +#  under the terms and conditions of the BSD License 

Re: [edk2] [PATCH 1/3] MdeModulePkg/MdeModulePkg.dec: add new PCD for UAF detection feature

2018-10-21 Thread Zeng, Star

On 2018/10/19 9:50, Jian J Wang wrote:

UAF (Use-After-Free) memory detection is new feature introduced to
detect illegal access to memory which has been freed. The principle
behind is similar to heap guard feature, that is we'll turn all pool
memory allocation to page allocation and mark them to be not-present
once they are freed.

This also implies that, once a page is allocated and freed, it cannot
be re-allocated. This will bring another issue, which is that there's
risk that memory space will be used out. To address it, this patch
series add logic put part (at most 64 pages a time) of freed pages
back into page pool, so that the memory service can still have memory
to allocate, when all memory space have been allocated once. This is
called memory promotion. The promoted pages are always from the eldest
pages freed.

To use this feature, one can simply set following PCD to 1
   gEfiMdeModulePkgTokenSpaceGuid.PcdUseAfterFreeDetectionPropertyMask

Please note this feature cannot be used with heap guard feature controlled
by PCD gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask.


How about adding this sentence into the description of 
PcdUseAfterFreeDetectionPropertyMask, and correspondingly adding some 
information in the description of PcdHeapGuardPropertyMask?




Cc: Star Zeng 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Cc: Ruiyu Ni 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
  MdeModulePkg/MdeModulePkg.dec | 6 ++
  1 file changed, 6 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 6037504fa7..83736cd761 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1029,6 +1029,12 @@
# @Prompt Enable UEFI Stack Guard.
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055
  
+  ## This mask is to control Use-After-Free Memory Detection behavior.

+  #   BIT0- Enable Use-After-Free memory detection for UEFI modules.
+  #   BIT1..7 - Reserved for future uses.
+  # @Prompt The Use-After-Free Memory Detection feature mask
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdUseAfterFreeDetectionPropertyMask|0x0|UINT8|0x30001056


Remember to update MdeModulePkg.uni for it.

Thanks,
Star


+
  [PcdsFixedAtBuild, PcdsPatchableInModule]
## Dynamic type PCD can be registered callback function for Pcd setting 
action.
#  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of 
callback function



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v1 0/2] add DwUsb3Dxe driver

2018-10-21 Thread Haojian Zhuang
On Thu, 4 Oct 2018 at 22:15, Leif Lindholm  wrote:
>
> Hi Haojian,
>
> I will start with a few high-level requests:
> - Could you rework this for inclusion in edk2-platforms instead?
>   Silicon/Synopsys I guess?

Sure. I'll rework it into edk2-platforms.

> - Could you submit Usb2 and Usb3 support in a single set for v2?

No problem.

> - Can you convert these to UEFI driver model with
>   NonDiscoverableDeviceRegistrationLib instead of a hard-coded base
>   address?
>

The only problem is related on Usb Device. Could I append a new type
"UsbDevice" into NonDiscoverableDeviceRegistrationLib?

Best Regards
Haojian
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v1 1/1] BaseTools: delete unused file

2018-10-21 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Thursday, October 11, 2018 7:30 AM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 1/1] BaseTools: delete unused file

this file is not imported/used.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/Common/Database.py | 120 
 1 file changed, 120 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Database.py 
b/BaseTools/Source/Python/Common/Database.py
deleted file mode 100644
index 1c543aeb41b1..
--- a/BaseTools/Source/Python/Common/Database.py
+++ /dev/null
@@ -1,120 +0,0 @@
-## @file
-# This file is used to create a database used by ECC tool -# -# Copyright (c) 
2007 - 2018, Intel Corporation. All rights reserved. -# 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 -# 
http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# 
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-from __future__ import absolute_import
-import sqlite3
-import Common.LongFilePathOs as os
-
-from . import EdkLogger as EdkLogger
-from CommonDataClass.DataClass import * -from .StringUtils import * -from 
.DataType import *
-
-from Table.TableDataModel import TableDataModel -from Table.TableFile import 
TableFile -from Table.TableInf import TableInf -from Table.TableDec import 
TableDec -from Table.TableDsc import TableDsc
-
-## Database
-#
-# This class defined the build databse
-# During the phase of initialization, the database will create all tables and 
-# insert all records of table DataModel -#
-# @param object:  Inherited from object class
-# @param DbPath:  A string for the path of the ECC database
-#
-# @var Conn:  Connection of the ECC database
-# @var Cur:   Cursor of the connection
-# @var TblDataModel:  Local instance for TableDataModel -# -class 
Database(object):
-def __init__(self, DbPath):
-if os.path.exists(DbPath):
-os.remove(DbPath)
-self.Conn = sqlite3.connect(DbPath, isolation_level = 'DEFERRED')
-self.Conn.execute("PRAGMA page_size=8192")
-self.Conn.execute("PRAGMA synchronous=OFF")
-self.Cur = self.Conn.cursor()
-self.TblDataModel = TableDataModel(self.Cur)
-self.TblFile = TableFile(self.Cur)
-self.TblInf = TableInf(self.Cur)
-self.TblDec = TableDec(self.Cur)
-self.TblDsc = TableDsc(self.Cur)
-
-## Initialize build database
-#
-# 1. Delete all old existing tables
-# 2. Create new tables
-# 3. Initialize table DataModel
-#
-def InitDatabase(self):
-EdkLogger.verbose("\nInitialize ECC database started ...")
-#
-# Drop all old existing tables
-#
-#self.TblDataModel.Drop()
-#self.TblDsc.Drop()
-#self.TblFile.Drop()
-
-#
-# Create new tables
-#
-self.TblDataModel.Create()
-self.TblFile.Create()
-self.TblInf.Create()
-self.TblDec.Create()
-self.TblDsc.Create()
-
-#
-# Initialize table DataModel
-#
-self.TblDataModel.InitTable()
-EdkLogger.verbose("Initialize ECC database ... DONE!")
-
-## Query a table
-#
-# @param Table:  The instance of the table to be queried
-#
-def QueryTable(self, Table):
-Table.Query()
-
-## Close entire database
-#
-# Commit all first
-# Close the connection and cursor
-#
-def Close(self):
-self.Conn.commit()
-self.Cur.close()
-self.Conn.close()
-
-##
-#
-# This acts like the main() function for the script, unless it is 'import'ed 
into another -# script.
-#
-if __name__ == '__main__':
-EdkLogger.Initialize()
-EdkLogger.SetLevel(EdkLogger.DEBUG_0)
-
-Db = Database(DATABASE_PATH)
-Db.InitDatabase()
-Db.QueryTable(Db.TblDataModel)
-Db.QueryTable(Db.TblFile)
-Db.QueryTable(Db.TblDsc)
-Db.Close()
--
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] BaseTools: Fixed a key error code bug.

2018-10-21 Thread Feng, Bob C
Cool.

-Original Message-
From: Zhu, Yonghong 
Sent: Sunday, October 21, 2018 7:50 PM
To: Feng, Bob C ; edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: RE: [edk2] [Patch] BaseTools: Fixed a key error code bug.

Hi Bob,

I fixed this issue by below patch,  I will check in the patch soon.
https://lists.01.org/pipermail/edk2-devel/2018-October/031161.html 

Best Regards,
Zhu Yonghong


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of BobCF
Sent: Sunday, October 21, 2018 7:42 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming 
Subject: [edk2] [Patch] BaseTools: Fixed a key error code bug.

There is a code bug that used a wrong key. This Patch is to correct it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index f2146a7790..87d6107035 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -567,12 +567,12 @@ class WorkspaceAutoGen(AutoGen):
 if (Name, Guid) not in DecPcds:
 EdkLogger.error(
 'build',
 PARSER_ERROR,
 "PCD (%s.%s) used in FDF is not declared in DEC 
files." % (Guid, Name),
-File = self.FdfProfile.PcdFileLineDict[Name, Guid][0],
-Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1]
+File = self.FdfProfile.PcdFileLineDict[Name, 
Guid,Fileds][0],
+Line = self.FdfProfile.PcdFileLineDict[Name,
+ Guid,Fileds][1]
 )
 else:
 # Check whether Dynamic or DynamicEx PCD used in FDF file. 
If used, build break and give a error message.
 if (Name, Guid, TAB_PCDS_FIXED_AT_BUILD) in DecPcdsKey \
 or (Name, Guid, TAB_PCDS_PATCHABLE_IN_MODULE) in 
DecPcdsKey \ @@ -581,12 +581,12 @@ class WorkspaceAutoGen(AutoGen):
 elif (Name, Guid, TAB_PCDS_DYNAMIC) in DecPcdsKey or 
(Name, Guid, TAB_PCDS_DYNAMIC_EX) in DecPcdsKey:
 EdkLogger.error(
 'build',
 PARSER_ERROR,
 "Using Dynamic or DynamicEx type of PCD 
[%s.%s] in FDF file is not allowed." % (Guid, Name),
-File = self.FdfProfile.PcdFileLineDict[Name, 
Guid][0],
-Line = self.FdfProfile.PcdFileLineDict[Name, 
Guid][1]
+File = self.FdfProfile.PcdFileLineDict[Name, 
Guid,Fileds][0],
+Line = 
+ self.FdfProfile.PcdFileLineDict[Name, Guid,Fileds][1]
 )
 
 Pa = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)
 #
 # Explicitly collect platform's dynamic PCDs
--
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] BaseTools: Fixed a key error code bug.

2018-10-21 Thread Zhu, Yonghong
Hi Bob,

I fixed this issue by below patch,  I will check in the patch soon.
https://lists.01.org/pipermail/edk2-devel/2018-October/031161.html 

Best Regards,
Zhu Yonghong


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of BobCF
Sent: Sunday, October 21, 2018 7:42 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming 
Subject: [edk2] [Patch] BaseTools: Fixed a key error code bug.

There is a code bug that used a wrong key. This Patch is to correct it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index f2146a7790..87d6107035 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -567,12 +567,12 @@ class WorkspaceAutoGen(AutoGen):
 if (Name, Guid) not in DecPcds:
 EdkLogger.error(
 'build',
 PARSER_ERROR,
 "PCD (%s.%s) used in FDF is not declared in DEC 
files." % (Guid, Name),
-File = self.FdfProfile.PcdFileLineDict[Name, Guid][0],
-Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1]
+File = self.FdfProfile.PcdFileLineDict[Name, 
Guid,Fileds][0],
+Line = self.FdfProfile.PcdFileLineDict[Name, 
+ Guid,Fileds][1]
 )
 else:
 # Check whether Dynamic or DynamicEx PCD used in FDF file. 
If used, build break and give a error message.
 if (Name, Guid, TAB_PCDS_FIXED_AT_BUILD) in DecPcdsKey \
 or (Name, Guid, TAB_PCDS_PATCHABLE_IN_MODULE) in 
DecPcdsKey \ @@ -581,12 +581,12 @@ class WorkspaceAutoGen(AutoGen):
 elif (Name, Guid, TAB_PCDS_DYNAMIC) in DecPcdsKey or 
(Name, Guid, TAB_PCDS_DYNAMIC_EX) in DecPcdsKey:
 EdkLogger.error(
 'build',
 PARSER_ERROR,
 "Using Dynamic or DynamicEx type of PCD 
[%s.%s] in FDF file is not allowed." % (Guid, Name),
-File = self.FdfProfile.PcdFileLineDict[Name, 
Guid][0],
-Line = self.FdfProfile.PcdFileLineDict[Name, 
Guid][1]
+File = self.FdfProfile.PcdFileLineDict[Name, 
Guid,Fileds][0],
+Line = 
+ self.FdfProfile.PcdFileLineDict[Name, Guid,Fileds][1]
 )
 
 Pa = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)
 #
 # Explicitly collect platform's dynamic PCDs
--
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] BaseTools: Fixed a key error code bug.

2018-10-21 Thread BobCF
There is a code bug that used a wrong key. This
Patch is to correct it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index f2146a7790..87d6107035 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -567,12 +567,12 @@ class WorkspaceAutoGen(AutoGen):
 if (Name, Guid) not in DecPcds:
 EdkLogger.error(
 'build',
 PARSER_ERROR,
 "PCD (%s.%s) used in FDF is not declared in DEC 
files." % (Guid, Name),
-File = self.FdfProfile.PcdFileLineDict[Name, Guid][0],
-Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1]
+File = self.FdfProfile.PcdFileLineDict[Name, 
Guid,Fileds][0],
+Line = self.FdfProfile.PcdFileLineDict[Name, 
Guid,Fileds][1]
 )
 else:
 # Check whether Dynamic or DynamicEx PCD used in FDF file. 
If used, build break and give a error message.
 if (Name, Guid, TAB_PCDS_FIXED_AT_BUILD) in DecPcdsKey \
 or (Name, Guid, TAB_PCDS_PATCHABLE_IN_MODULE) in 
DecPcdsKey \
@@ -581,12 +581,12 @@ class WorkspaceAutoGen(AutoGen):
 elif (Name, Guid, TAB_PCDS_DYNAMIC) in DecPcdsKey or 
(Name, Guid, TAB_PCDS_DYNAMIC_EX) in DecPcdsKey:
 EdkLogger.error(
 'build',
 PARSER_ERROR,
 "Using Dynamic or DynamicEx type of PCD 
[%s.%s] in FDF file is not allowed." % (Guid, Name),
-File = self.FdfProfile.PcdFileLineDict[Name, 
Guid][0],
-Line = self.FdfProfile.PcdFileLineDict[Name, 
Guid][1]
+File = self.FdfProfile.PcdFileLineDict[Name, 
Guid,Fileds][0],
+Line = self.FdfProfile.PcdFileLineDict[Name, 
Guid,Fileds][1]
 )
 
 Pa = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)
 #
 # Explicitly collect platform's dynamic PCDs
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2] BaseTools: Convert "Unicode string" to "byte array" if value type diff

2018-10-21 Thread Feng, Bob C
Reviewed-by: Bob Feng 

-Original Message-
From: Zhao, ZhiqiangX 
Sent: Thursday, October 18, 2018 1:09 PM
To: edk2-devel@lists.01.org
Cc: Zhao, ZhiqiangX ; Gao, Liming 
; Zhu, Yonghong ; Feng, Bob C 

Subject: [PATCH V2] BaseTools: Convert "Unicode string" to "byte array" if 
value type diff

V2:
Fixed 3 typo.
Use startswith(('L"',"L'")) to check if a string is Unicode string.
Use a set PcdValueTypeSet instead of a list PcdValueTypeList to save memory.

V1:
For the same one VOID* pcd, if the default value type of one SKU is "Unicode 
string", the other SKUs are "OtherVOID*"(ASCII string or byte array),Then 
convert "Unicode string" to "byte array".

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Bob Feng 
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 9 +
 1 file changed, 9 insertions(+)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 7854e71db6..9b9ace9b56 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -2877,6 +2877,15 @@ class DscBuildData(PlatformBuildClassObject):
 elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in 
pcd.SkuInfoList:
 del pcd.SkuInfoList[TAB_COMMON]
 
+#For the same one VOID* pcd, if the default value type of one SKU is 
"Unicode string",
+#the other SKUs are "OtherVOID*"(ASCII string or byte array),Then 
convert "Unicode string" to "byte array".
+for pcd in Pcds.values():
+PcdValueTypeSet = set()
+for sku in pcd.SkuInfoList.values():
+PcdValueTypeSet.add("UnicodeString" if 
sku.DefaultValue.startswith(('L"',"L'")) else "OtherVOID*")
+if len(PcdValueTypeSet) > 1:
+for sku in pcd.SkuInfoList.values():
+sku.DefaultValue = StringToArray(sku.DefaultValue) 
+ if sku.DefaultValue.startswith(('L"',"L'")) else sku.DefaultValue
 
 map(self.FilterSkuSettings, Pcds.values())
 return Pcds
--
2.14.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2] BaseTool: Support different PCDs that refers to the same EFI variable.

2018-10-21 Thread Feng, Bob C
Reviewed-by: Bob Feng 

-Original Message-
From: Zhao, ZhiqiangX 
Sent: Thursday, October 18, 2018 3:12 PM
To: edk2-devel@lists.01.org
Cc: Zhao, ZhiqiangX ; Gao, Liming 
; Zhu, Yonghong ; Feng, Bob C 

Subject: [PATCH V2] BaseTool: Support different PCDs that refers to the same 
EFI variable.

V2:
Make the code of patch both compatible for Python2 and Python3.

V1:
If different PCDs refer to the same EFI variable, then do EFI variable 
combination, according to the VariableOffset of different PCDS.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Bob Feng 
---
 BaseTools/Source/Python/AutoGen/GenVar.py | 97 ++-
 1 file changed, 30 insertions(+), 67 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py 
b/BaseTools/Source/Python/AutoGen/GenVar.py
index 036f00e2bb..98f88e2497 100644
--- a/BaseTools/Source/Python/AutoGen/GenVar.py
+++ b/BaseTools/Source/Python/AutoGen/GenVar.py
@@ -56,51 +56,7 @@ class VariableMgr(object):
 value_str += ",".join(default_var_bin_strip)
 value_str += "}"
 return value_str
-def Do_combine(self,sku_var_info_offset_list):
-newvalue = {}
-for item in sku_var_info_offset_list:
-data_type = item.data_type
-value_list = item.default_value.strip("{").strip("}").split(",")
-if data_type in DataType.TAB_PCD_NUMERIC_TYPES:
-data_flag = 
DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE[data_type]]
-data = value_list[0]
-value_list = []
-for data_byte in pack(data_flag, int(data, 16) if 
data.upper().startswith('0X') else int(data)):
-value_list.append(hex(unpack("B", data_byte)[0]))
-newvalue[int(item.var_offset, 16) if 
item.var_offset.upper().startswith("0X") else int(item.var_offset)] = value_list
-try:
-newvaluestr = "{" + 
",".join(VariableMgr.assemble_variable(newvalue)) +"}"
-except:
-EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset conflict 
in PCDs: %s \n" % (" and ".join(item.pcdname for item in 
sku_var_info_offset_list)))
-return newvaluestr
-def Do_Merge(self,sku_var_info_offset_list):
-StructrurePcds = sorted([item for item in sku_var_info_offset_list if 
item.StructurePcd], key = lambda x: x.PcdDscLine, reverse =True )
-Base = StructrurePcds[0]
-BaseValue = Base.default_value.strip("{").strip("}").split(",")
-Override = [item for item in sku_var_info_offset_list if not 
item.StructurePcd and item.PcdDscLine > Base.PcdDscLine]
-newvalue = {}
-for item in Override:
-data_type = item.data_type
-value_list = item.default_value.strip("{").strip("}").split(",")
-if data_type in DataType.TAB_PCD_NUMERIC_TYPES:
-data_flag = 
DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE[data_type]]
-data = value_list[0]
-value_list = []
-for data_byte in pack(data_flag, int(data, 16) if 
data.upper().startswith('0X') else int(data)):
-value_list.append(hex(unpack("B", data_byte)[0]))
-newvalue[int(item.var_offset, 16) if 
item.var_offset.upper().startswith("0X") else int(item.var_offset)] = 
(value_list,item.pcdname,item.PcdDscLine)
-for offset in newvalue:
-value_list,itemPcdname,itemPcdDscLine = newvalue[offset]
-if offset > len(BaseValue) or (offset + len(value_list) > 
len(BaseValue)):
-EdkLogger.error("build", AUTOGEN_ERROR, "The EFI Variable 
referred by PCD %s in line %s exceeds variable size: %s\n" % 
(itemPcdname,itemPcdDscLine,hex(len(BaseValue
-for i in xrange(len(value_list)):
-BaseValue[offset + i] = value_list[i]
-newvaluestr =  "{" + ",".join(BaseValue) +"}"
-return newvaluestr
-def NeedMerge(self,sku_var_info_offset_list):
-if [item for item in sku_var_info_offset_list if item.StructurePcd]:
-return True
-return False
+
 def combine_variable(self):
 indexedvarinfo = collections.OrderedDict()
 for item in self.VarInfo:
@@ -109,30 +65,37 @@ class VariableMgr(object):
 indexedvarinfo[(item.skuname, item.defaultstoragename, 
item.var_name, item.var_guid)].append(item)
 for key in indexedvarinfo:
 sku_var_info_offset_list = indexedvarinfo[key]
-if len(sku_var_info_offset_list) == 1:
-continue
-
+sku_var_info_offset_list.sort(key=lambda x:x.PcdDscLine)
+FirstOffset = int(sku_var_info_offset_list[0].var_offset, 16) if 
sku_var_info_offset_list[0].var_offset.upper().startswith("0X") else 
int(sku_var_info_offset_list[0].var_offset)
+fisrtvalue_list = 
sku_var_info_offset_list[0].default_value.strip("{").strip("}").split(",")
+