Re: [edk2] Performance enabling of Event handler

2018-09-07 Thread Bi, Dandan
Hi,

DP tool will filter some entries in which the time duration < 1ms by default.
And you can  use the" dp -t 0  "to dump all the Perf entries.
Then to double check whether the entry you care exists or not.


Thanks,
Dandan
-Original Message-
From: prabin ca [mailto:prabinc...@gmail.com] 
Sent: Friday, September 7, 2018 11:57 PM
To: Bi, Dandan 
Cc: Laszlo Ersek ; edk2-devel@lists.01.org; af...@apple.com
Subject: Re: [edk2] Performance enabling of Event handler

Hi 

Yes it is included in same module (both event handler and function handler), 
and I’m not perf_start and perf_end only two times (one is by event handler and 
one is by normal function handler).

And I’m trying to print result using DP.efi, it shows entry for normal function.

> On 07-Sep-2018, at 8:46 AM, Bi, Dandan  wrote:
> 
> Hi Prabin,
> 
> The Performance logging for the normal functions handlers and event handlers 
> should be the same.
> Are the normal function calls and the event handler function calls you tested 
> in the same module?
> If not, please double check to make sure the performance library instance 
> used correctly for each module.
> 
> 
> Thanks,
> Dandan
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> prabin ca
> Sent: Friday, September 7, 2018 10:30 AM
> To: Laszlo Ersek 
> Cc: Bi, Dandan ; edk2-devel@lists.01.org; 
> af...@apple.com
> Subject: Re: [edk2] Performance enabling of Event handler
> 
> Hi,
> PerformancePkg is not working with event handlers, but it’s working with 
> normal functions handlers. 
> 
>>> On 06-Sep-2018, at 3:28 PM, Laszlo Ersek  wrote:
>>> 
>>> On 09/06/18 08:10, prabin ca wrote:
>>> Hi Team,
>>> 
>>> I’m used edk2 PerformancePkg for profiling cpu execution time taken by a 
>>> event handler. Event is created successfully and event handler is also 
>>> called successfully, but I can capture the performance of this event 
>>> handler with PerformancePkg (by using perf_start and perf_end check 
>>> points). This PerformancePkg is working fine with normal function calls.
>> 
>> Do you mean "can not", instead of "can"? (Sorry, I don't understand.)
>> 
>>> 
>>> Please help me to enable PerformancePkg action on event handler also.
>>> 
>> 
>> Hmmm, even with the suggested typo correction, I wouldn't know what 
>> to suggest. Sorry!
>> 
>> Laszlo
> ___
> 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] UefiCpuPkg/CpuDxe: fix ECC reported issues

2018-09-07 Thread Bi, Dandan
Reviewed-by: Dandan Bi 


Thanks,
Dandan

-Original Message-
From: Wang, Jian J 
Sent: Saturday, September 8, 2018 11:24 AM
To: edk2-devel ; edk2-devel@lists.01.org
Cc: Bi, Dandan 
Subject: RE: [edk2] [PATCH] UefiCpuPkg/CpuDxe: fix ECC reported issues

Forgot to mention the BZ info:

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

Regards,
Jian

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org]
> Sent: Saturday, September 08, 2018 10:22 AM
> To: edk2-devel@lists.01.org
> Cc: Bi, Dandan 
> Subject: [edk2] [PATCH] UefiCpuPkg/CpuDxe: fix ECC reported issues
> 
> There're two parameters which have different name in comment and prototype.
> 
> Cc: Dandan Bi 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang 
> ---
>  UefiCpuPkg/CpuDxe/CpuDxe.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h 
> index 7d65e39e90..064ea05bba 100644
> --- a/UefiCpuPkg/CpuDxe/CpuDxe.h
> +++ b/UefiCpuPkg/CpuDxe/CpuDxe.h
> @@ -291,7 +291,7 @@ RefreshGcdMemoryAttributesFromPaging (  VOID  
> EFIAPI  DebugExceptionHandler (
> -  IN EFI_EXCEPTION_TYPE   InterruptType,
> +  IN EFI_EXCEPTION_TYPE   ExceptionType,
>IN EFI_SYSTEM_CONTEXT   SystemContext
>);
> 
> @@ -307,7 +307,7 @@ DebugExceptionHandler (  VOID  EFIAPI  
> PageFaultExceptionHandler (
> -  IN EFI_EXCEPTION_TYPE   InterruptType,
> +  IN EFI_EXCEPTION_TYPE   ExceptionType,
>IN EFI_SYSTEM_CONTEXT   SystemContext
>);
> 
> --
> 2.16.2.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] SecurityPkg: HashLib: Change dos format

2018-09-07 Thread Bi, Dandan
Reviewed-by: Dandan Bi 
One minor comment that please remove the additional " Signed-off-by: Zhang, 
Chao B ",
which can't pass the PatchCheck script.

Thanks,
Dandan

-Original Message-
From: Zhang, Chao B 
Sent: Friday, September 7, 2018 4:50 PM
To: edk2-devel@lists.01.org
Cc: Bi, Dandan ; Zhang, Chao B 
Subject: [Patch] SecurityPkg: HashLib: Change dos format

Change file format to DOS

Cc: Bi Dandan 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhang Chao B 
Signed-off-by: Zhang, Chao B 
---
 .../HashInstanceLibSha384/HashInstanceLibSha384.c  | 310 ++---
 .../HashInstanceLibSha384.inf  |  90 +++---
 .../HashInstanceLibSha384.uni  |  42 +--
 .../HashInstanceLibSha512/HashInstanceLibSha512.c  | 308 ++--
 .../HashInstanceLibSha512.inf  |  90 +++---
 .../HashInstanceLibSha512.uni  |  42 +--
 6 files changed, 441 insertions(+), 441 deletions(-)

diff --git a/SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.c 
b/SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.c
index 54bc687425..c750273bdc 100644
--- a/SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.c
+++ b/SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.c
@@ -1,155 +1,155 @@
-/** @file
-  This library is BaseCrypto SHA384 hash instance.
-  It can be registered to BaseCrypto router, to serve as hash engine.
-
-Copyright (c) 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.
-
-**/
-
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include  -#include 
-
-/**
-  The function set SHA384 to digest list.
-
-  @param DigestList   digest list
-  @param Sha384Digest SHA384 digest
-**/
-VOID
-Tpm2SetSha384ToDigestList (
-  IN TPML_DIGEST_VALUES *DigestList,
-  IN UINT8  *Sha384Digest
-  )
-{
-  DigestList->count = 1;
-  DigestList->digests[0].hashAlg = TPM_ALG_SHA384;
-  CopyMem (
-DigestList->digests[0].digest.sha384,
-Sha384Digest,
-SHA384_DIGEST_SIZE
-);
-}
-
-/**
-  Start hash sequence.
-
-  @param HashHandle Hash handle.
-
-  @retval EFI_SUCCESS  Hash sequence start and HandleHandle returned.
-  @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
-**/
-EFI_STATUS
-EFIAPI
-Sha384HashInit (
-  OUT HASH_HANDLE*HashHandle
-  )
-{
-  VOID *Sha384Ctx;
-  UINTNCtxSize;
-
-  CtxSize = Sha384GetContextSize ();
-  Sha384Ctx = AllocatePool (CtxSize);
-  ASSERT (Sha384Ctx != NULL);
-
-  Sha384Init (Sha384Ctx);
-
-  *HashHandle = (HASH_HANDLE)Sha384Ctx;
-
-  return EFI_SUCCESS;
-}
-
-/**
-  Update hash sequence data.
-
-  @param HashHandleHash handle.
-  @param DataToHashData to be hashed.
-  @param DataToHashLen Data size.
-
-  @retval EFI_SUCCESS Hash sequence updated.
-**/
-EFI_STATUS
-EFIAPI
-Sha384HashUpdate (
-  IN HASH_HANDLEHashHandle,
-  IN VOID   *DataToHash,
-  IN UINTN  DataToHashLen
-  )
-{
-  VOID *Sha384Ctx;
-
-  Sha384Ctx = (VOID *)HashHandle;
-  Sha384Update (Sha384Ctx, DataToHash, DataToHashLen);
-
-  return EFI_SUCCESS;
-}
-
-/**
-  Complete hash sequence complete.
-
-  @param HashHandleHash handle.
-  @param DigestListDigest list.
-
-  @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
-**/
-EFI_STATUS
-EFIAPI
-Sha384HashFinal (
-  IN HASH_HANDLE HashHandle,
-  OUT TPML_DIGEST_VALUES *DigestList
-  )
-{
-  UINT8 Digest[SHA384_DIGEST_SIZE];
-  VOID  *Sha384Ctx;
-
-  Sha384Ctx = (VOID *)HashHandle;
-  Sha384Final (Sha384Ctx, Digest);
-
-  FreePool (Sha384Ctx);
-
-  Tpm2SetSha384ToDigestList (DigestList, Digest);
-
-  return EFI_SUCCESS;
-}
-
-HASH_INTERFACE  mSha384InternalHashInstance = {
-  HASH_ALGORITHM_SHA384_GUID,
-  Sha384HashInit,
-  Sha384HashUpdate,
-  Sha384HashFinal,
-};
-
-/**
-  The function register SHA384 instance.
-  
-  @retval EFI_SUCCESS   SHA384 instance is registered, or system dose not 
surpport registr SHA384 instance
-**/
-EFI_STATUS
-EFIAPI
-HashInstanceLibSha384Constructor (
-  VOID
-  )
-{
-  EFI_STATUS  Status;
-
-  Status = RegisterHashInterfaceLib (&mSha384InternalHashInstance);
-  if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) {
-//
-// Unsupported means platform policy does not need this instance enabled.
-//
-return EFI_SUCCESS;
-  }
-  return Status;
-}
\ No newline at end of file
+/** @file
+  This library is BaseCrypto SHA384 hash instance.
+  It can be registered to BaseCrypto router, to serve as hash engine.
+
+Copyright (

Re: [edk2] [PATCH] UefiCpuPkg/PeiCpuException: Fix coding style issue

2018-09-07 Thread Bi, Dandan
Reviewed-by: Dandan Bi 

Thanks,
Dandan

-Original Message-
From: Ni, Ruiyu 
Sent: Friday, September 7, 2018 6:13 PM
To: edk2-devel@lists.01.org
Cc: Bi, Dandan 
Subject: [PATCH] UefiCpuPkg/PeiCpuException: Fix coding style issue

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Dandan Bi 
---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
index 5dd8423d2f..8f4d5b5e0a 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
@@ -45,7 +45,7 @@ GetExceptionHandlerData (
 
   AsmReadIdtr (&IdtDescriptor);
   IdtTable = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor.Base;
-  
+
   Exception0StubHeader = (EXCEPTION0_STUB_HEADER *)ArchGetIdtHandler 
(&IdtTable[0]);
   return Exception0StubHeader->ExceptionHandlerData;
 }
@@ -57,7 +57,7 @@ GetExceptionHandlerData (
   exception handler data. The new allocated memory layout follows structure 
EXCEPTION0_STUB_HEADER.
   The code assumes that all processors uses the same exception handler for #0 
exception.
 
-  @param  pointer to exception handler data.
+  @param ExceptionHandlerData  pointer to exception handler data.
 **/
 VOID
 SetExceptionHandlerData (
@@ -73,7 +73,7 @@ SetExceptionHandlerData (
   //
   AsmReadIdtr (&IdtDescriptor);
   IdtTable = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor.Base;
-  
+
   Exception0StubHeader = AllocatePool (sizeof (*Exception0StubHeader));
   ASSERT (Exception0StubHeader != NULL);
   CopyMem (
-- 
2.16.1.windows.1

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


Re: [edk2] [PATCH] UefiCpuPkg/CpuDxe: fix an incorrect bit-wise operation

2018-09-07 Thread Wang, Jian J
And BZ#1164: https://bugzilla.tianocore.org/show_bug.cgi?id=1164

Regards,
Jian

From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org]
Sent: Saturday, September 08, 2018 11:25 AM
To: edk2-devel ; edk2-devel@lists.01.org
Cc: Wu, Hao A 
Subject: Re: [edk2] [PATCH] UefiCpuPkg/CpuDxe: fix an incorrect bit-wise 
operation

Forgot to mention BZ info:
https://bugzilla.tianocore.org/show_bug.cgi?id=1095

Regards,
Jian


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org]
> Sent: Saturday, September 08, 2018 10:48 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A mailto:hao.a...@intel.com>>
> Subject: [edk2] [PATCH] UefiCpuPkg/CpuDxe: fix an incorrect bit-wise operation
>
> The left operand is 64-bit but right operand could be 32-bit.
> A typecast is a must because of '~' op before it.
>
> Cc: Hao A Wu mailto:hao.a...@intel.com>>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang 
> mailto:jian.j.w...@intel.com>>
> ---
>  UefiCpuPkg/CpuDxe/CpuPageTable.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c
> b/UefiCpuPkg/CpuDxe/CpuPageTable.c
> index ef6e080a07..0a980b9753 100644
> --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c
> +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c
> @@ -1181,7 +1181,7 @@ DebugExceptionHandler (
>
>for (PFEntry = 0; PFEntry < mPFEntryCount[CpuIndex]; PFEntry++) {
>  if (mLastPFEntryPointer[CpuIndex][PFEntry] != NULL) {
> -  *mLastPFEntryPointer[CpuIndex][PFEntry] &= ~IA32_PG_P;
> +  *mLastPFEntryPointer[CpuIndex][PFEntry] &= ~(UINT64)IA32_PG_P;
>  }
>}
>
> --
> 2.16.2.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-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] UefiCpuPkg/CpuDxe: fix an incorrect bit-wise operation

2018-09-07 Thread Wang, Jian J
Forgot to mention BZ info:
https://bugzilla.tianocore.org/show_bug.cgi?id=1095

Regards,
Jian


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org]
> Sent: Saturday, September 08, 2018 10:48 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A 
> Subject: [edk2] [PATCH] UefiCpuPkg/CpuDxe: fix an incorrect bit-wise operation
> 
> The left operand is 64-bit but right operand could be 32-bit.
> A typecast is a must because of '~' op before it.
> 
> Cc: Hao A Wu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang 
> ---
>  UefiCpuPkg/CpuDxe/CpuPageTable.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c
> b/UefiCpuPkg/CpuDxe/CpuPageTable.c
> index ef6e080a07..0a980b9753 100644
> --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c
> +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c
> @@ -1181,7 +1181,7 @@ DebugExceptionHandler (
> 
>for (PFEntry = 0; PFEntry < mPFEntryCount[CpuIndex]; PFEntry++) {
>  if (mLastPFEntryPointer[CpuIndex][PFEntry] != NULL) {
> -  *mLastPFEntryPointer[CpuIndex][PFEntry] &= ~IA32_PG_P;
> +  *mLastPFEntryPointer[CpuIndex][PFEntry] &= ~(UINT64)IA32_PG_P;
>  }
>}
> 
> --
> 2.16.2.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] UefiCpuPkg/CpuDxe: fix ECC reported issues

2018-09-07 Thread Wang, Jian J
Forgot to mention the BZ info:

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

Regards,
Jian

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org]
> Sent: Saturday, September 08, 2018 10:22 AM
> To: edk2-devel@lists.01.org
> Cc: Bi, Dandan 
> Subject: [edk2] [PATCH] UefiCpuPkg/CpuDxe: fix ECC reported issues
> 
> There're two parameters which have different name in comment and prototype.
> 
> Cc: Dandan Bi 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang 
> ---
>  UefiCpuPkg/CpuDxe/CpuDxe.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h
> index 7d65e39e90..064ea05bba 100644
> --- a/UefiCpuPkg/CpuDxe/CpuDxe.h
> +++ b/UefiCpuPkg/CpuDxe/CpuDxe.h
> @@ -291,7 +291,7 @@ RefreshGcdMemoryAttributesFromPaging (
>  VOID
>  EFIAPI
>  DebugExceptionHandler (
> -  IN EFI_EXCEPTION_TYPE   InterruptType,
> +  IN EFI_EXCEPTION_TYPE   ExceptionType,
>IN EFI_SYSTEM_CONTEXT   SystemContext
>);
> 
> @@ -307,7 +307,7 @@ DebugExceptionHandler (
>  VOID
>  EFIAPI
>  PageFaultExceptionHandler (
> -  IN EFI_EXCEPTION_TYPE   InterruptType,
> +  IN EFI_EXCEPTION_TYPE   ExceptionType,
>IN EFI_SYSTEM_CONTEXT   SystemContext
>);
> 
> --
> 2.16.2.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] UefiCpuPkg/CpuDxe: fix an incorrect bit-wise operation

2018-09-07 Thread Jian J Wang
The left operand is 64-bit but right operand could be 32-bit.
A typecast is a must because of '~' op before it.

Cc: Hao A Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
 UefiCpuPkg/CpuDxe/CpuPageTable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTable.c
index ef6e080a07..0a980b9753 100644
--- a/UefiCpuPkg/CpuDxe/CpuPageTable.c
+++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c
@@ -1181,7 +1181,7 @@ DebugExceptionHandler (
 
   for (PFEntry = 0; PFEntry < mPFEntryCount[CpuIndex]; PFEntry++) {
 if (mLastPFEntryPointer[CpuIndex][PFEntry] != NULL) {
-  *mLastPFEntryPointer[CpuIndex][PFEntry] &= ~IA32_PG_P;
+  *mLastPFEntryPointer[CpuIndex][PFEntry] &= ~(UINT64)IA32_PG_P;
 }
   }
 
-- 
2.16.2.windows.1

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


[edk2] [PATCH] UefiCpuPkg/CpuDxe: fix ECC reported issues

2018-09-07 Thread Jian J Wang
There're two parameters which have different name in comment and prototype.

Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
 UefiCpuPkg/CpuDxe/CpuDxe.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h
index 7d65e39e90..064ea05bba 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.h
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.h
@@ -291,7 +291,7 @@ RefreshGcdMemoryAttributesFromPaging (
 VOID
 EFIAPI
 DebugExceptionHandler (
-  IN EFI_EXCEPTION_TYPE   InterruptType,
+  IN EFI_EXCEPTION_TYPE   ExceptionType,
   IN EFI_SYSTEM_CONTEXT   SystemContext
   );
 
@@ -307,7 +307,7 @@ DebugExceptionHandler (
 VOID
 EFIAPI
 PageFaultExceptionHandler (
-  IN EFI_EXCEPTION_TYPE   InterruptType,
+  IN EFI_EXCEPTION_TYPE   ExceptionType,
   IN EFI_SYSTEM_CONTEXT   SystemContext
   );
 
-- 
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] Maintainer.txt: Add Ray to be co-maintainer of EmulatorPkg

2018-09-07 Thread Andrew Fish
Reviewed-by: Andrew Fish mailto:jordan.l.jus...@intel.com>pple.com>

> On Sep 6, 2018, at 6:27 AM, Ruiyu Ni  wrote:
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Andrew Fish 
> ---
> Maintainers.txt | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/Maintainers.txt b/Maintainers.txt
> index 61df6e198b..7ebd53f662 100644
> --- a/Maintainers.txt
> +++ b/Maintainers.txt
> @@ -124,6 +124,7 @@ EmulatorPkg
> W: https://github.com/tianocore/tianocore.github.io/wiki/EmulatorPkg
> M: Jordan Justen 
> M: Andrew Fish 
> +M: Ruiyu Ni 
> S: Maintained
> 
> FatPkg, FatBinPkg
> -- 
> 2.16.1.windows.1
> 

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


Re: [edk2] PciBusDxe: PCI-Express bug with dynamic PcdPciExpressBaseAddress

2018-09-07 Thread Liran Alon


> On 7 Sep 2018, at 11:44, Laszlo Ersek  wrote:
> 
> (+Ard)
> 
> On 09/06/18 21:08, Nikita Leshenko wrote:
>> Hi,
>> 
>> We ran into a bug in EDK2 relating to PCI-Express in PciBusDxe. Here's the 
>> flow
>> of the bug:
>> 
>> 1. PciBusDxe/PciEnumeratorSupport.c: Function BarExisted probes a BAR. It 
>> raises
>>   TPL to TPL_HIGH_LEVEL to avoid timer interrupts while probing the BAR and
>>   calls PciIo->Pci.Write.
>> 2. BasePciExpressLib/PciExpressLib.c: The write reaches PciExpressWrite32, 
>> which
>>   calls GetPciExpressBaseAddress.
>> 3. GetPciExpressBaseAddress retrieves the address from 
>> PcdPciExpressBaseAddress.
>> 4. Reading the PCD calls DxePcdGet64 -> GetWorker ->
>>   EfiAcquireLock(&mPcdDatabaseLock), which is at TPL_NOTIFY level. This 
>> crashes
>>   the firmware because step 1 raised the TPL to TPL_HIGH_LEVEL.
>> 
>> This doesn't happen when PcdPciExpressBaseAddress is fixed at build (because
>> then the read is optimized to a static global variable), but when the PCD is
>> dynamic PCI-Express is broken.
>> 
>> Does anybody have a suggestion for fixing it?
>> 
>> Options we thought about:
>> - Change mPcdDatabaseLock.Tpl to TPL_HIGH_LEVEL
>> - Don't use a PCD for the base address, put it in a static global variable 
>> and
>>  create functions to set and retrieve it.
> 
> In the ArmVirtPkg platforms, we also set "PcdPciExpressBaseAddress"
> dynamically. And, we implemented your second option above; see:
> 
>  ArmVirtPkg/Library/BaseCachingPciExpressLib/
> 
> Relevant commits:
> 
> - ad3359eb43a9 ("ArmVirtualizationPkg: clone BasePciExpressLib, cache
> PCIe config base", 2015-02-23)
> - a06d0bb58eb9 ("ArmVirtPkg/BaseCachingPciExpressLib: depend on
> PciPcdProducerLib", 2016-04-12)
> 
> (In fact, commit ad3359eb43a9 documents the exact issue you report here.)
> 
> Thanks
> Laszlo

Thanks Lazlo. Weren’t aware of this solution in the ArmVirtPkg platforms.

However, I wonder why the solution was to clone the 
MdePkg/Library/BasePciExpressLib rather than
change the original library itself?

That is, what was the reason for not just adding a library constructor to 
MdePkg/Library/BasePciExpressLib
to cache PcdPciExpressBaseAddress in a global var? This seem to solve the 
issues for all platforms.
If PcdPciExpressBaseAddress is fixed and doesn’t change dynamically, then the 
caching of the value in a global var
should be harmless (besides adding an extra read from global-var). If it does 
change dynamically, 
MdePkg/Library/BasePciExpressLib have the issue discussed in this email thread.

Thanks,
-Liran

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


Re: [edk2] Performance enabling of Event handler

2018-09-07 Thread prabin ca
Hi 

Yes it is included in same module (both event handler and function handler), 
and I’m not perf_start and perf_end only two times (one is by event handler and 
one is by normal function handler).

And I’m trying to print result using DP.efi, it shows entry for normal function.

> On 07-Sep-2018, at 8:46 AM, Bi, Dandan  wrote:
> 
> Hi Prabin,
> 
> The Performance logging for the normal functions handlers and event handlers 
> should be the same.
> Are the normal function calls and the event handler function calls you tested 
> in the same module?
> If not, please double check to make sure the performance library instance 
> used correctly for each module.
> 
> 
> Thanks,
> Dandan
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of prabin 
> ca
> Sent: Friday, September 7, 2018 10:30 AM
> To: Laszlo Ersek 
> Cc: Bi, Dandan ; edk2-devel@lists.01.org; af...@apple.com
> Subject: Re: [edk2] Performance enabling of Event handler
> 
> Hi,
> PerformancePkg is not working with event handlers, but it’s working with 
> normal functions handlers. 
> 
>>> On 06-Sep-2018, at 3:28 PM, Laszlo Ersek  wrote:
>>> 
>>> On 09/06/18 08:10, prabin ca wrote:
>>> Hi Team,
>>> 
>>> I’m used edk2 PerformancePkg for profiling cpu execution time taken by a 
>>> event handler. Event is created successfully and event handler is also 
>>> called successfully, but I can capture the performance of this event 
>>> handler with PerformancePkg (by using perf_start and perf_end check 
>>> points). This PerformancePkg is working fine with normal function calls.
>> 
>> Do you mean "can not", instead of "can"? (Sorry, I don't understand.)
>> 
>>> 
>>> Please help me to enable PerformancePkg action on event handler also.
>>> 
>> 
>> Hmmm, even with the suggested typo correction, I wouldn't know what to 
>> suggest. Sorry!
>> 
>> Laszlo
> ___
> 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] MdeModulePkg RegularExpressionDxe: Update Oniguruma to 6.9.0

2018-09-07 Thread Liming Gao
From: Dongao Guo 

The change is in https://github.com/lgao4/edk2/tree/Oniguruma

Update Oniguruma to the latest version v6.9.0.
Oniguruma https://github.com/kkos/oniguruma
Verify VS2017, GCC5 build.
Verify RegularExpressionProtocol GetInfo() and Match() function.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dongao Guo 
Reviewed-by: Liming Gao 
Cc: Cecil Sheng 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [platforms: PATCH 1/7] Silicon/SynQuacer/PlatformDxe: Modify initialization of SdMmcOverride

2018-09-07 Thread Marcin Wojtas
Hi Ard,

pt., 7 wrz 2018 o 13:29 Ard Biesheuvel  napisał(a):
>
> On 6 September 2018 at 16:45, Ard Biesheuvel  
> wrote:
> > On 6 September 2018 at 16:38, Marcin Wojtas  wrote:
> >> czw., 6 wrz 2018 o 16:31 Ard Biesheuvel  
> >> napisał(a):
> >>>
> >>> On 6 September 2018 at 16:26, Marcin Wojtas  wrote:
> >>> > czw., 6 wrz 2018 o 16:04 Ard Biesheuvel  
> >>> > napisał(a):
> >>> >>
> >>> >> On 3 September 2018 at 06:53, Marcin Wojtas  wrote:
> >>> >> > From: Tomasz Michalec 
> >>> >> >
> >>> >> > This patch changes way the EDKII_SD_MMC_OVERRIDE protocol
> >>> >> > sturcture is allocated. Using AllocateZeroPool and then
> >>> >> > seting callbacks in the structure allow driver to be immune to
> >>> >> > adding new callbacks in SdMmcOveride protocol in future.
> >>> >> >
> >>> >>
> >>> >> What is the point of this patch?
> >>> >>
> >>> >> Statically allocating the structure will zero initialize the members
> >>> >> that are not initialized explicitly, but only the members that are
> >>> >> known to exist at compile time.
> >>> >>
> >>> >
> >>> > In such case this patch is really not needed.
> >>> >
> >>> >> I guess the idea of this patch is to work around the latter
> >>> >> limitation, but unfortunately, using sizeof(EDKII_SD_MMC_OVERRIDE)
> >>> >> puts you in the exact same situation.
> >>> >
> >>> > If the newly added callback are zero-initialized, the situation is
> >>> > fine as they won't be executed.
> >>> >
> >>>
> >>> Yes, but this patch does not change that situation at all.
> >>>
> >>> So please, explain which problem is fixed by this patch?
> >>
> >> None, we only forgot, the static initializer will zero non-declared
> >> fields by default.
> >>
> >>>
> >>> >>
> >>> >> This is the reason I added the version field. New hooks should only be
> >>> >> added after incrementing the version, and calling the new hooks should
> >>> >> only occur if the runtime version of the protocol implementation is
> >>> >> greater than or equal to the version where those hooks were first
> >>> >> introduced.
> >>> >>
> >>> >
> >>> > So even if the given SdMmcOverride protocol callback will be NULL for
> >>> > Synquacer controller, is there still a risk that anything could be
> >>> > broken without the version check?
> >>> >
> >>>
> >>> Yes. In EDK2, you can combine binary drivers with drivers build from
> >>> source. If a binary driver was built against an older version of the
> >>> SdMmcOverride header, it may have non-NULL values in the locations of
> >>> the new methods. This patch does not help against that scenario.
> >>
> >> Indeed, this is why it will disappear from v2. So, when adding the new
> >> callbacks, the version should be increased and checked in relevant
> >> places of the main EDK2 driver, right?
> >>
> >> Because a couple of the new callbacks are introduced, would it be ok,
> >> to increment the version only once, i.e. v2 of the SdMmcOverride will
> >> support 4 new routines?
> >>
> >
> > Yes, that is preferred in my opinion.
> >
> > Also, perhaps add some helper macros, e.g.,
> >
> > #define EDKII_SD_MMC_OVERRIDE_HAVE_POST_CLOCK_FREQ_SWITCH(p) \
> >   ((p)->Version >= 0x2 && (p)->SwitchClockFreqPost != NULL)
> >
> > so that the version handling is completely contained in the header file.
>
> Actually, would it be possible to define a new phase for this and use
> the existing NotifyPhase hook? I know you need the timing parameter,
> but I'm not thrilled by all the API changes you require there, so
> perhaps we can solve that differently.

Actually the NotifyPhase was the first choice, but the problem I faced
was additional parameters to be passed in the callbacks. I think
adding a new generic field (VOID *) would solve the problem for xenon
and all future controllers. I wanted to avoid the need of modifying
your driver. Please see answer to the second question, in order to get
better understanding.

>
> In any case, it might be useful if you could provide an overview of
> all the quirks needed by Xenon

There are a couple of quirks required:
1. Quirked initialization - done via existing SdMmcNotifyPhase -
EdkiiSdMmcInitHostPre

2. Capabilities update depending on voltage supply, SlotType, and
controller type (so called "SlowMode")
- done via existing SdMmcCapability

3. Custom value of UHS Mode field in Host Control 2 Register - done
with the new UhsSignaling callback.
Additional Parameter needed - Timing.

4. Additional HW configuration after switching clock frequency - done
with the new SwitchClockFreqPost.
   Additional Parameter needed - Timing.

5. BaseClockFreq = 400MHz. Maximum available in the Capability
register is 255[MHz] stored in 7bit field.
  This is done with the new callback and new *Private structure field.
If we were able to pass
  *Private instead of &Private->Capability[Slot], the new callback
could be replaced with new usage
  of mOverride->Capability. However this would also force updating
your driver...

I hope now the Xenon demands are clear. I'm lookin

Re: [edk2] [platforms: PATCH 1/7] Silicon/SynQuacer/PlatformDxe: Modify initialization of SdMmcOverride

2018-09-07 Thread Ard Biesheuvel
On 6 September 2018 at 16:45, Ard Biesheuvel  wrote:
> On 6 September 2018 at 16:38, Marcin Wojtas  wrote:
>> czw., 6 wrz 2018 o 16:31 Ard Biesheuvel  
>> napisał(a):
>>>
>>> On 6 September 2018 at 16:26, Marcin Wojtas  wrote:
>>> > czw., 6 wrz 2018 o 16:04 Ard Biesheuvel  
>>> > napisał(a):
>>> >>
>>> >> On 3 September 2018 at 06:53, Marcin Wojtas  wrote:
>>> >> > From: Tomasz Michalec 
>>> >> >
>>> >> > This patch changes way the EDKII_SD_MMC_OVERRIDE protocol
>>> >> > sturcture is allocated. Using AllocateZeroPool and then
>>> >> > seting callbacks in the structure allow driver to be immune to
>>> >> > adding new callbacks in SdMmcOveride protocol in future.
>>> >> >
>>> >>
>>> >> What is the point of this patch?
>>> >>
>>> >> Statically allocating the structure will zero initialize the members
>>> >> that are not initialized explicitly, but only the members that are
>>> >> known to exist at compile time.
>>> >>
>>> >
>>> > In such case this patch is really not needed.
>>> >
>>> >> I guess the idea of this patch is to work around the latter
>>> >> limitation, but unfortunately, using sizeof(EDKII_SD_MMC_OVERRIDE)
>>> >> puts you in the exact same situation.
>>> >
>>> > If the newly added callback are zero-initialized, the situation is
>>> > fine as they won't be executed.
>>> >
>>>
>>> Yes, but this patch does not change that situation at all.
>>>
>>> So please, explain which problem is fixed by this patch?
>>
>> None, we only forgot, the static initializer will zero non-declared
>> fields by default.
>>
>>>
>>> >>
>>> >> This is the reason I added the version field. New hooks should only be
>>> >> added after incrementing the version, and calling the new hooks should
>>> >> only occur if the runtime version of the protocol implementation is
>>> >> greater than or equal to the version where those hooks were first
>>> >> introduced.
>>> >>
>>> >
>>> > So even if the given SdMmcOverride protocol callback will be NULL for
>>> > Synquacer controller, is there still a risk that anything could be
>>> > broken without the version check?
>>> >
>>>
>>> Yes. In EDK2, you can combine binary drivers with drivers build from
>>> source. If a binary driver was built against an older version of the
>>> SdMmcOverride header, it may have non-NULL values in the locations of
>>> the new methods. This patch does not help against that scenario.
>>
>> Indeed, this is why it will disappear from v2. So, when adding the new
>> callbacks, the version should be increased and checked in relevant
>> places of the main EDK2 driver, right?
>>
>> Because a couple of the new callbacks are introduced, would it be ok,
>> to increment the version only once, i.e. v2 of the SdMmcOverride will
>> support 4 new routines?
>>
>
> Yes, that is preferred in my opinion.
>
> Also, perhaps add some helper macros, e.g.,
>
> #define EDKII_SD_MMC_OVERRIDE_HAVE_POST_CLOCK_FREQ_SWITCH(p) \
>   ((p)->Version >= 0x2 && (p)->SwitchClockFreqPost != NULL)
>
> so that the version handling is completely contained in the header file.

Actually, would it be possible to define a new phase for this and use
the existing NotifyPhase hook? I know you need the timing parameter,
but I'm not thrilled by all the API changes you require there, so
perhaps we can solve that differently.

In any case, it might be useful if you could provide an overview of
all the quirks needed by Xenon
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] ShellPkg Shell: Remove an unused global variable

2018-09-07 Thread Laszlo Ersek
On 09/07/18 06:39, Ni, Ruiyu wrote:
> Reviewed-by: Ruiyu Ni 

Commit 98257f982072.

Thanks
Laszlo


>> -Original Message-
>> From: edk2-devel  On Behalf Of shenglei
>> Sent: Friday, September 7, 2018 9:52 AM
>> To: edk2-devel@lists.01.org
>> Cc: Carsey, Jaben ; Ni, Ruiyu 
>> Subject: [edk2] [PATCH] ShellPkg Shell: Remove an unused global variable
>>
>> The unused global variable InvalidChars is removed.
>> It is only used in the function IsValidCommandName which was removed
>> previously.
>> https://bugzilla.tianocore.org/show_bug.cgi?id=1066
>>
>> Cc: Jaben Carsey 
>> Cc: Ruiyu Ni 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: shenglei 
>> ---
>>  ShellPkg/Application/Shell/Shell.c | 3 ---
>>  1 file changed, 3 deletions(-)
>>
>> diff --git a/ShellPkg/Application/Shell/Shell.c
>> b/ShellPkg/Application/Shell/Shell.c
>> index 397cfd1994..3f3bcbb4b0 100644
>> --- a/ShellPkg/Application/Shell/Shell.c
>> +++ b/ShellPkg/Application/Shell/Shell.c
>> @@ -2750,9 +2750,6 @@ RunCommand(
>>return (RunShellCommand(CmdLine, NULL));  }
>>
>> -
>> -STATIC CONST UINT16 InvalidChars[] = {L'*', L'?', L'<', L'>', L'\\', L'/', 
>> L'\"',
>> 0x0001, 0x0002};
>> -
>>  /**
>>Function to process a NSH script file via SHELL_FILE_HANDLE.
>>
>> --
>> 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-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 3/4] MdeModulePkg/SdMmcPciHcDxe: Fix SdMmcHcReset to set only necesery bits

2018-09-07 Thread Ard Biesheuvel
On 7 September 2018 at 11:10, Marcin Wojtas  wrote:
> From: Tomasz Michalec 
>
> SdMmcHcReset used to set all bits of Software Reset Register to 1
> including reserved ones.
>
> Now only first bit is set which means "Software Reset for All".
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 
> ---
>  MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h | 5 +
>  MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 6 +++---
>  2 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h 
> b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h
> index e3fadb5..ec90d1e 100644
> --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h
> +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h
> @@ -68,6 +68,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
> EXPRESS OR IMPLIED.
>  #define SD_MMC_HC_HOST_CTRL1_HS_ENABLE  (1 << 2)
>
>  //
> +// SD Software Reset Register bits description
> +//
> +#define SD_MMC_HC_SW_RST_ALL(1 << 0)

Please use BIT0 here

> +
> +//
>  // The transfer modes supported by SD Host Controller
>  // Simplified Spec 3.0 Table 1-2
>  //
> diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c 
> b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
> index 9672b5b..9d9bca8 100644
> --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
> +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
> @@ -454,8 +454,8 @@ SdMmcHcReset (
>}
>
>PciIo   = Private->PciIo;
> -  SwReset = 0xFF;
> -  Status  = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_SW_RST, FALSE, sizeof 
> (SwReset), &SwReset);
> +  SwReset = SD_MMC_HC_SW_RST_ALL;
> +  Status  = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_SW_RST, sizeof (SwReset), 
> &SwReset);
>
>if (EFI_ERROR (Status)) {
>  DEBUG ((DEBUG_ERROR, "SdMmcHcReset: write full 1 fails: %r\n", Status));
> @@ -467,7 +467,7 @@ SdMmcHcReset (
>   Slot,
>   SD_MMC_HC_SW_RST,
>   sizeof (SwReset),
> - 0xFF,
> + SD_MMC_HC_SW_RST_ALL,
>   0x00,
>   SD_MMC_HC_GENERIC_TIMEOUT
>   );
> --
> 2.7.4
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 0/4] SdMmc fixes

2018-09-07 Thread Ard Biesheuvel
+Hao

On 7 September 2018 at 11:10, Marcin Wojtas  wrote:
> Hi,
>
> Answering the review request, I extracted SdMmcPciHcDxe driver fixes
> from SdMmcOverride protocol modification. Comparing to v1,
> patches are rebased onto the newest master branch and also a macro
> is used instead of the raw value in SdMmcHcReset.
>
> Patches are available in the github:
> https://github.com/MarvellEmbeddedProcessors/edk2-open-platform/commits/sdmmc-fixes-r20180907
>
> I'm looking forward to the comments and remarks.
>
> Best regards,
> Marcin
>
> Changelog:
> v1 -> v2
>  * rebase on top of the newest master
>  * resolve conflicts after taking fixes out from new features
>  * 3/4 - use macro instead of raw value in SdMmcHcReset
>
> Marcin Wojtas (3):
>   MdeModulePkg/SdMmcPciHcDxe: Fix HS200 operation
>   MdeModulePkg/SdMmcPciHcDxe: Adjust eMMC clock and bus width sequence
>   MdeModulePkg/SdMmcPciHcDxe: Execute card detect only for RemovableSlot
>
> Tomasz Michalec (1):
>   MdeModulePkg/SdMmcPciHcDxe: Fix SdMmcHcReset to set only necesery bits
>
>  MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h   | 10 +
>  MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c| 39 +---
>  MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 18 ++---
>  MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c   |  6 +--
>  4 files changed, 34 insertions(+), 39 deletions(-)
>
> --
> 2.7.4
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 1/3] EmbeddedPkg/CoherentDmaLib: Fix typo in DmaAlignedBuffer

2018-09-07 Thread Ard Biesheuvel
On 6 September 2018 at 20:55, Vladimir Olovyannikov
 wrote:
> The only valid memory types for DmaAlignedBuffer should be
> EfiBootServicesData and EfiRuntimeServicesData. However due to the typo,
> there is no way to allocate runtime pages, and INVALID_PARAMETER is
> always returned. Fix the typo.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Vladimir Olovyannikov 

Patches #1 and #2

Reviewed-by: Ard Biesheuvel 

Pushed as 4d621893471c..c4709260f62f

Thanks!

> ---
>  EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c 
> b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c
> index 564db83c901c..8ca9e6aa5b1b 100644
> --- a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c
> +++ b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c
> @@ -154,7 +154,7 @@ DmaAllocateAlignedBuffer (
>//
>if (MemoryType == EfiBootServicesData) {
>  *HostAddress = AllocateAlignedPages (Pages, Alignment);
> -  } else if (MemoryType != EfiRuntimeServicesData) {
> +  } else if (MemoryType == EfiRuntimeServicesData) {
>  *HostAddress = AllocateAlignedRuntimePages (Pages, Alignment);
>} else {
>  return EFI_INVALID_PARAMETER;
> --
> 2.18.0
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 3/3] MdeModulePkg/NonDiscoverablePciDeviceDxe: add missing validation

2018-09-07 Thread Ard Biesheuvel
On 6 September 2018 at 20:55, Vladimir Olovyannikov
 wrote:
> UEFI SCT crashed and failed in NonDiscoverablePciDeviceDxe becase
> required checks were not performed. Perform parameters validation in
> NonDiscoverablePciDeviceDxe.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Vladimir Olovyannikov 

Reviewed-by: Ard Biesheuvel 

> ---
>  .../NonDiscoverablePciDeviceIo.c  | 50 ++-
>  1 file changed, 49 insertions(+), 1 deletion(-)
>
> diff --git 
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
>  
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
> index 0e42ae4bf6ec..07118d59fd68 100644
> --- 
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
> +++ 
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
> @@ -52,6 +52,10 @@ GetBarResource (
>
>BarIndex -= (UINT8)Dev->BarOffset;
>
> +  if (BarIndex >= Dev->BarCount) {
> +return EFI_UNSUPPORTED;
> +  }
> +
>for (Desc = Dev->Device->Resources;
> Desc->Desc != ACPI_END_TAG_DESCRIPTOR;
> Desc = (VOID *)((UINT8 *)Desc + Desc->Len + 3)) {
> @@ -597,6 +601,19 @@ CoherentPciIoMap (
>EFI_STATUSStatus;
>NON_DISCOVERABLE_PCI_DEVICE_MAP_INFO  *MapInfo;
>
> +  if (Operation != EfiPciIoOperationBusMasterRead &&
> +  Operation != EfiPciIoOperationBusMasterWrite &&
> +  Operation != EfiPciIoOperationBusMasterCommonBuffer) {
> +return EFI_INVALID_PARAMETER;
> +  }
> +
> +  if (HostAddress   == NULL ||
> +  NumberOfBytes == NULL ||
> +  DeviceAddress == NULL ||
> +  Mapping   == NULL) {
> +return EFI_INVALID_PARAMETER;
> +  }
> +
>//
>// If HostAddress exceeds 4 GB, and this device does not support 64-bit DMA
>// addressing, we need to allocate a bounce buffer and copy over the data.
> @@ -720,6 +737,11 @@ CoherentPciIoAllocateBuffer (
>  return EFI_UNSUPPORTED;
>}
>
> +  if ((MemoryType != EfiBootServicesData) &&
> +  (MemoryType != EfiRuntimeServicesData)) {
> +return EFI_INVALID_PARAMETER;
> +  }
> +
>//
>// Allocate below 4 GB if the dual address cycle attribute has not
>// been set. If the system has no memory available below 4 GB, there
> @@ -877,6 +899,10 @@ NonCoherentPciIoAllocateBuffer (
>NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION *Alloc;
>VOID*AllocAddress;
>
> +  if (HostAddress == NULL) {
> +return EFI_INVALID_PARAMETER;
> +  }
> +
>Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
>
>Status = CoherentPciIoAllocateBuffer (This, Type, MemoryType, Pages,
> @@ -995,6 +1021,19 @@ NonCoherentPciIoMap (
>EFI_GCD_MEMORY_SPACE_DESCRIPTOR   GcdDescriptor;
>BOOLEAN   Bounce;
>
> +  if (HostAddress   == NULL ||
> +  NumberOfBytes == NULL ||
> +  DeviceAddress == NULL ||
> +  Mapping   == NULL) {
> +return EFI_INVALID_PARAMETER;
> +  }
> +
> +  if (Operation != EfiPciIoOperationBusMasterRead &&
> +  Operation != EfiPciIoOperationBusMasterWrite &&
> +  Operation != EfiPciIoOperationBusMasterCommonBuffer) {
> +return EFI_INVALID_PARAMETER;
> +  }
> +
>MapInfo = AllocatePool (sizeof *MapInfo);
>if (MapInfo == NULL) {
>  return EFI_OUT_OF_RESOURCES;
> @@ -1228,8 +1267,17 @@ PciIoAttributes (
>NON_DISCOVERABLE_PCI_DEVICE   *Dev;
>BOOLEAN   Enable;
>
> +  #define DEV_SUPPORTED_ATTRIBUTES \
> +(EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE)
> +
>Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
>
> +  if (Attributes) {
> +  if ((Attributes & (~(DEV_SUPPORTED_ATTRIBUTES))) != 0) {
> +return EFI_UNSUPPORTED;
> +  }
> +}
> +
>Enable = FALSE;
>switch (Operation) {
>case EfiPciIoAttributeOperationGet:
> @@ -1243,7 +1291,7 @@ PciIoAttributes (
>  if (Result == NULL) {
>return EFI_INVALID_PARAMETER;
>  }
> -*Result = EFI_PCI_DEVICE_ENABLE | 
> EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE;
> +*Result = DEV_SUPPORTED_ATTRIBUTES;
>  break;
>
>case EfiPciIoAttributeOperationEnable:
> --
> 2.18.0
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] UefiCpuPkg/PeiCpuException: Fix coding style issue

2018-09-07 Thread Laszlo Ersek
On 09/07/18 12:13, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni 
> Cc: Dandan Bi 
> ---
>  UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c 
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
> index 5dd8423d2f..8f4d5b5e0a 100644
> --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
> +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
> @@ -45,7 +45,7 @@ GetExceptionHandlerData (
>  
>AsmReadIdtr (&IdtDescriptor);
>IdtTable = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor.Base;
> -  
> +
>Exception0StubHeader = (EXCEPTION0_STUB_HEADER *)ArchGetIdtHandler 
> (&IdtTable[0]);
>return Exception0StubHeader->ExceptionHandlerData;
>  }
> @@ -57,7 +57,7 @@ GetExceptionHandlerData (
>exception handler data. The new allocated memory layout follows structure 
> EXCEPTION0_STUB_HEADER.
>The code assumes that all processors uses the same exception handler for 
> #0 exception.
>  
> -  @param  pointer to exception handler data.
> +  @param ExceptionHandlerData  pointer to exception handler data.
>  **/
>  VOID
>  SetExceptionHandlerData (
> @@ -73,7 +73,7 @@ SetExceptionHandlerData (
>//
>AsmReadIdtr (&IdtDescriptor);
>IdtTable = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor.Base;
> -  
> +
>Exception0StubHeader = AllocatePool (sizeof (*Exception0StubHeader));
>ASSERT (Exception0StubHeader != NULL);
>CopyMem (
> 

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


Re: [edk2] [Patch] ShellPkg: Remove trailing white space

2018-09-07 Thread Ni, Ruiyu
Reviewed-by: Ruiyu Ni 

Thanks/Ray

> -Original Message-
> From: Fu, Siyuan
> Sent: Friday, September 7, 2018 4:48 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu ; Carsey, Jaben 
> Subject: [Patch] ShellPkg: Remove trailing white space
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1158
> 
> Cc: Ruiyu Ni 
> Cc: Jaben Carsey 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Fu Siyuan 
> ---
>  ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
> b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
> index e9f644c739..cdc6db69c3 100644
> --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
> +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
> @@ -1032,7 +1032,7 @@ IfConfigSetInterfaceInfo (
>SubnetMask  = NTOHL (SubnetMask);
>TempGateway = NTOHL (TempGateway);
>if ((SubnetMask != 0) &&
> -  (SubnetMask != 0xu) &&
> +  (SubnetMask != 0xu) &&
>!NetIp4IsUnicast (TempGateway, SubnetMask)) {
>  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG_INVALID_GATEWAY), gShellNetwork1HiiHandle, VarArg-
> >Arg);
>  ShellStatus = SHELL_INVALID_PARAMETER;
> --
> 2.18.0.windows.1

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


[edk2] [PATCH] UefiCpuPkg/PeiCpuException: Fix coding style issue

2018-09-07 Thread Ruiyu Ni
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Dandan Bi 
---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
index 5dd8423d2f..8f4d5b5e0a 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
@@ -45,7 +45,7 @@ GetExceptionHandlerData (
 
   AsmReadIdtr (&IdtDescriptor);
   IdtTable = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor.Base;
-  
+
   Exception0StubHeader = (EXCEPTION0_STUB_HEADER *)ArchGetIdtHandler 
(&IdtTable[0]);
   return Exception0StubHeader->ExceptionHandlerData;
 }
@@ -57,7 +57,7 @@ GetExceptionHandlerData (
   exception handler data. The new allocated memory layout follows structure 
EXCEPTION0_STUB_HEADER.
   The code assumes that all processors uses the same exception handler for #0 
exception.
 
-  @param  pointer to exception handler data.
+  @param ExceptionHandlerData  pointer to exception handler data.
 **/
 VOID
 SetExceptionHandlerData (
@@ -73,7 +73,7 @@ SetExceptionHandlerData (
   //
   AsmReadIdtr (&IdtDescriptor);
   IdtTable = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor.Base;
-  
+
   Exception0StubHeader = AllocatePool (sizeof (*Exception0StubHeader));
   ASSERT (Exception0StubHeader != NULL);
   CopyMem (
-- 
2.16.1.windows.1

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


[edk2] [PATCH v2 4/4] MdeModulePkg/SdMmcPciHcDxe: Execute card detect only for RemovableSlot

2018-09-07 Thread Marcin Wojtas
Some devices can be non removable (such as eMMC) and checking
Present State Register on host controller may falsely return
an information that device is not present. Execute this
check conditionally on the SloType field value.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas 
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
index f923930..bf9869d 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
@@ -661,12 +661,18 @@ SdMmcPciHcDriverBindingStart (
 //
 // Check whether there is a SD/MMC card attached
 //
-Status = SdMmcHcCardDetect (PciIo, Slot, &MediaPresent);
-if (EFI_ERROR (Status) && (Status != EFI_MEDIA_CHANGED)) {
-  continue;
-} else if (!MediaPresent) {
-  DEBUG ((DEBUG_INFO, "SdMmcHcCardDetect: No device attached in 
Slot[%d]!!!\n", Slot));
-  continue;
+if (Private->Slot[Slot].SlotType == RemovableSlot) {
+  Status = SdMmcHcCardDetect (PciIo, Slot, &MediaPresent);
+  if (EFI_ERROR (Status) && (Status != EFI_MEDIA_CHANGED)) {
+continue;
+  } else if (!MediaPresent) {
+DEBUG ((
+  DEBUG_INFO,
+  "SdMmcHcCardDetect: No device attached in Slot[%d]!!!\n",
+  Slot
+  ));
+continue;
+  }
 }
 
 Status = SdMmcHcInitHost (Private, Slot);
-- 
2.7.4

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


[edk2] [PATCH v2 3/4] MdeModulePkg/SdMmcPciHcDxe: Fix SdMmcHcReset to set only necesery bits

2018-09-07 Thread Marcin Wojtas
From: Tomasz Michalec 

SdMmcHcReset used to set all bits of Software Reset Register to 1
including reserved ones.

Now only first bit is set which means "Software Reset for All".

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas 
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h | 5 +
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h
index e3fadb5..ec90d1e 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h
@@ -68,6 +68,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #define SD_MMC_HC_HOST_CTRL1_HS_ENABLE  (1 << 2)
 
 //
+// SD Software Reset Register bits description
+//
+#define SD_MMC_HC_SW_RST_ALL(1 << 0)
+
+//
 // The transfer modes supported by SD Host Controller
 // Simplified Spec 3.0 Table 1-2
 //
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
index 9672b5b..9d9bca8 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
@@ -454,8 +454,8 @@ SdMmcHcReset (
   }
 
   PciIo   = Private->PciIo;
-  SwReset = 0xFF;
-  Status  = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_SW_RST, FALSE, sizeof 
(SwReset), &SwReset);
+  SwReset = SD_MMC_HC_SW_RST_ALL;
+  Status  = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_SW_RST, sizeof (SwReset), 
&SwReset);
 
   if (EFI_ERROR (Status)) {
 DEBUG ((DEBUG_ERROR, "SdMmcHcReset: write full 1 fails: %r\n", Status));
@@ -467,7 +467,7 @@ SdMmcHcReset (
  Slot,
  SD_MMC_HC_SW_RST,
  sizeof (SwReset),
- 0xFF,
+ SD_MMC_HC_SW_RST_ALL,
  0x00,
  SD_MMC_HC_GENERIC_TIMEOUT
  );
-- 
2.7.4

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


[edk2] [PATCH v2 1/4] MdeModulePkg/SdMmcPciHcDxe: Fix HS200 operation

2018-09-07 Thread Marcin Wojtas
When switching to any of high speed modes (HS, HS200, HS400)
there is need to set HS_ENABLE bit in Host Control 1 register
which allow Host Controller to output CMD and DAT lines on
both edges of clock. In Linux it is done after switching bus
width in sdhci_set_ios().

Also according to JESD84-B50-1 chapter 6.6.4 "HS200 timing mode
selection" (documentation about eMMC4.5 standard) there is
no need to disable clock when switching to HS200.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas 
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h |  5 
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c  | 30 +++-
 2 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h
index e389d52..e3fadb5 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h
@@ -63,6 +63,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #define SD_MMC_HC_CTRL_VER0xFE
 
 //
+// SD Host Control 1 Register bits description
+//
+#define SD_MMC_HC_HOST_CTRL1_HS_ENABLE  (1 << 2)
+
+//
 // The transfer modes supported by SD Host Controller
 // Simplified Spec 3.0 Table 1-2
 //
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
index c5fd214..b3903b4 100755
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
@@ -816,8 +816,8 @@ EmmcSwitchToHS200 (
 {
   EFI_STATUS  Status;
   UINT8   HsTiming;
+  UINT8   HostCtrl1;
   UINT8   HostCtrl2;
-  UINT16  ClockCtrl;
 
   if ((BusWidth != 4) && (BusWidth != 8)) {
 return EFI_INVALID_PARAMETER;
@@ -828,12 +828,10 @@ EmmcSwitchToHS200 (
 return Status;
   }
   //
-  // Set to HS200/SDR104 timing
-  //
-  //
-  // Stop bus clock at first
+  // Set to High Speed timing
   //
-  Status = SdMmcHcStopClock (PciIo, Slot);
+  HostCtrl1 = SD_MMC_HC_HOST_CTRL1_HS_ENABLE;
+  Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL1, sizeof 
(HostCtrl1), &HostCtrl1);
   if (EFI_ERROR (Status)) {
 return Status;
   }
@@ -853,26 +851,6 @@ EmmcSwitchToHS200 (
   if (EFI_ERROR (Status)) {
 return Status;
   }
-  //
-  // Wait Internal Clock Stable in the Clock Control register to be 1 before 
set SD Clock Enable bit
-  //
-  Status = SdMmcHcWaitMmioSet (
- PciIo,
- Slot,
- SD_MMC_HC_CLOCK_CTRL,
- sizeof (ClockCtrl),
- BIT1,
- BIT1,
- SD_MMC_HC_GENERIC_TIMEOUT
- );
-  if (EFI_ERROR (Status)) {
-return Status;
-  }
-  //
-  // Set SD Clock Enable in the Clock Control register to 1
-  //
-  ClockCtrl = BIT2;
-  Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_CLOCK_CTRL, sizeof 
(ClockCtrl), &ClockCtrl);
 
   HsTiming = 2;
   Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, 
ClockFreq);
-- 
2.7.4

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


[edk2] [PATCH v2 2/4] MdeModulePkg/SdMmcPciHcDxe: Adjust eMMC clock and bus width sequence

2018-09-07 Thread Marcin Wojtas
According to JESD84-B50-1 chapter A.6 (documentation about eMMC4.5
standard) step "Changing the data bus width" (A.6.3) should be
execute after step "Switching to high-speed mode" (A.6.2).

This patch fixes the bus-width/clock-setting sequence
in EmmcSwitchToHighSpeed ().

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas 
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
index b3903b4..87027b8 100755
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
@@ -745,10 +745,6 @@ EmmcSwitchToHighSpeed (
   UINT8   HostCtrl1;
   UINT8   HostCtrl2;
 
-  Status = EmmcSwitchBusWidth (PciIo, PassThru, Slot, Rca, IsDdr, BusWidth);
-  if (EFI_ERROR (Status)) {
-return Status;
-  }
   //
   // Set to Hight Speed timing
   //
@@ -783,6 +779,11 @@ EmmcSwitchToHighSpeed (
 
   HsTiming = 1;
   Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, 
ClockFreq);
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  Status = EmmcSwitchBusWidth (PciIo, PassThru, Slot, Rca, IsDdr, BusWidth);
 
   return Status;
 }
-- 
2.7.4

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


[edk2] [PATCH v2 0/4] SdMmc fixes

2018-09-07 Thread Marcin Wojtas
Hi,

Answering the review request, I extracted SdMmcPciHcDxe driver fixes
from SdMmcOverride protocol modification. Comparing to v1,
patches are rebased onto the newest master branch and also a macro
is used instead of the raw value in SdMmcHcReset.

Patches are available in the github:
https://github.com/MarvellEmbeddedProcessors/edk2-open-platform/commits/sdmmc-fixes-r20180907

I'm looking forward to the comments and remarks.

Best regards,
Marcin

Changelog:
v1 -> v2
 * rebase on top of the newest master
 * resolve conflicts after taking fixes out from new features
 * 3/4 - use macro instead of raw value in SdMmcHcReset

Marcin Wojtas (3):
  MdeModulePkg/SdMmcPciHcDxe: Fix HS200 operation
  MdeModulePkg/SdMmcPciHcDxe: Adjust eMMC clock and bus width sequence
  MdeModulePkg/SdMmcPciHcDxe: Execute card detect only for RemovableSlot

Tomasz Michalec (1):
  MdeModulePkg/SdMmcPciHcDxe: Fix SdMmcHcReset to set only necesery bits

 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h   | 10 +
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c| 39 +---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 18 ++---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c   |  6 +--
 4 files changed, 34 insertions(+), 39 deletions(-)

-- 
2.7.4

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


[edk2] [Patch] SecurityPkg: HashLib: Change dos format

2018-09-07 Thread Zhang, Chao B
Change file format to DOS

Cc: Bi Dandan 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhang Chao B 
Signed-off-by: Zhang, Chao B 
---
 .../HashInstanceLibSha384/HashInstanceLibSha384.c  | 310 ++---
 .../HashInstanceLibSha384.inf  |  90 +++---
 .../HashInstanceLibSha384.uni  |  42 +--
 .../HashInstanceLibSha512/HashInstanceLibSha512.c  | 308 ++--
 .../HashInstanceLibSha512.inf  |  90 +++---
 .../HashInstanceLibSha512.uni  |  42 +--
 6 files changed, 441 insertions(+), 441 deletions(-)

diff --git a/SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.c 
b/SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.c
index 54bc687425..c750273bdc 100644
--- a/SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.c
+++ b/SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.c
@@ -1,155 +1,155 @@
-/** @file
-  This library is BaseCrypto SHA384 hash instance.
-  It can be registered to BaseCrypto router, to serve as hash engine.
-
-Copyright (c) 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.
-
-**/
-
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/**
-  The function set SHA384 to digest list.
-
-  @param DigestList   digest list
-  @param Sha384Digest SHA384 digest
-**/
-VOID
-Tpm2SetSha384ToDigestList (
-  IN TPML_DIGEST_VALUES *DigestList,
-  IN UINT8  *Sha384Digest
-  )
-{
-  DigestList->count = 1;
-  DigestList->digests[0].hashAlg = TPM_ALG_SHA384;
-  CopyMem (
-DigestList->digests[0].digest.sha384,
-Sha384Digest,
-SHA384_DIGEST_SIZE
-);
-}
-
-/**
-  Start hash sequence.
-
-  @param HashHandle Hash handle.
-
-  @retval EFI_SUCCESS  Hash sequence start and HandleHandle returned.
-  @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
-**/
-EFI_STATUS
-EFIAPI
-Sha384HashInit (
-  OUT HASH_HANDLE*HashHandle
-  )
-{
-  VOID *Sha384Ctx;
-  UINTNCtxSize;
-
-  CtxSize = Sha384GetContextSize ();
-  Sha384Ctx = AllocatePool (CtxSize);
-  ASSERT (Sha384Ctx != NULL);
-
-  Sha384Init (Sha384Ctx);
-
-  *HashHandle = (HASH_HANDLE)Sha384Ctx;
-
-  return EFI_SUCCESS;
-}
-
-/**
-  Update hash sequence data.
-
-  @param HashHandleHash handle.
-  @param DataToHashData to be hashed.
-  @param DataToHashLen Data size.
-
-  @retval EFI_SUCCESS Hash sequence updated.
-**/
-EFI_STATUS
-EFIAPI
-Sha384HashUpdate (
-  IN HASH_HANDLEHashHandle,
-  IN VOID   *DataToHash,
-  IN UINTN  DataToHashLen
-  )
-{
-  VOID *Sha384Ctx;
-
-  Sha384Ctx = (VOID *)HashHandle;
-  Sha384Update (Sha384Ctx, DataToHash, DataToHashLen);
-
-  return EFI_SUCCESS;
-}
-
-/**
-  Complete hash sequence complete.
-
-  @param HashHandleHash handle.
-  @param DigestListDigest list.
-
-  @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
-**/
-EFI_STATUS
-EFIAPI
-Sha384HashFinal (
-  IN HASH_HANDLE HashHandle,
-  OUT TPML_DIGEST_VALUES *DigestList
-  )
-{
-  UINT8 Digest[SHA384_DIGEST_SIZE];
-  VOID  *Sha384Ctx;
-
-  Sha384Ctx = (VOID *)HashHandle;
-  Sha384Final (Sha384Ctx, Digest);
-
-  FreePool (Sha384Ctx);
-  
-  Tpm2SetSha384ToDigestList (DigestList, Digest);
-
-  return EFI_SUCCESS;
-}
-
-HASH_INTERFACE  mSha384InternalHashInstance = {
-  HASH_ALGORITHM_SHA384_GUID,
-  Sha384HashInit,
-  Sha384HashUpdate,
-  Sha384HashFinal,
-};
-
-/**
-  The function register SHA384 instance.
-  
-  @retval EFI_SUCCESS   SHA384 instance is registered, or system dose not 
surpport registr SHA384 instance
-**/
-EFI_STATUS
-EFIAPI
-HashInstanceLibSha384Constructor (
-  VOID
-  )
-{
-  EFI_STATUS  Status;
-
-  Status = RegisterHashInterfaceLib (&mSha384InternalHashInstance);
-  if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) {
-//
-// Unsupported means platform policy does not need this instance enabled.
-//
-return EFI_SUCCESS;
-  }
-  return Status;
-}
\ No newline at end of file
+/** @file
+  This library is BaseCrypto SHA384 hash instance.
+  It can be registered to BaseCrypto router, to serve as hash engine.
+
+Copyright (c) 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 I

[edk2] [Patch] ShellPkg: Remove trailing white space

2018-09-07 Thread Fu Siyuan
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1158

Cc: Ruiyu Ni 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Fu Siyuan 
---
 ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c 
b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index e9f644c739..cdc6db69c3 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -1032,7 +1032,7 @@ IfConfigSetInterfaceInfo (
   SubnetMask  = NTOHL (SubnetMask);
   TempGateway = NTOHL (TempGateway);
   if ((SubnetMask != 0) &&
-  (SubnetMask != 0xu) && 
+  (SubnetMask != 0xu) &&
   !NetIp4IsUnicast (TempGateway, SubnetMask)) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INVALID_GATEWAY), gShellNetwork1HiiHandle, VarArg->Arg);
 ShellStatus = SHELL_INVALID_PARAMETER;
-- 
2.18.0.windows.1

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


Re: [edk2] PciBusDxe: PCI-Express bug with dynamic PcdPciExpressBaseAddress

2018-09-07 Thread Laszlo Ersek
(+Ard)

On 09/06/18 21:08, Nikita Leshenko wrote:
> Hi,
> 
> We ran into a bug in EDK2 relating to PCI-Express in PciBusDxe. Here's the 
> flow
> of the bug:
> 
> 1. PciBusDxe/PciEnumeratorSupport.c: Function BarExisted probes a BAR. It 
> raises
>TPL to TPL_HIGH_LEVEL to avoid timer interrupts while probing the BAR and
>calls PciIo->Pci.Write.
> 2. BasePciExpressLib/PciExpressLib.c: The write reaches PciExpressWrite32, 
> which
>calls GetPciExpressBaseAddress.
> 3. GetPciExpressBaseAddress retrieves the address from 
> PcdPciExpressBaseAddress.
> 4. Reading the PCD calls DxePcdGet64 -> GetWorker ->
>EfiAcquireLock(&mPcdDatabaseLock), which is at TPL_NOTIFY level. This 
> crashes
>the firmware because step 1 raised the TPL to TPL_HIGH_LEVEL.
> 
> This doesn't happen when PcdPciExpressBaseAddress is fixed at build (because
> then the read is optimized to a static global variable), but when the PCD is
> dynamic PCI-Express is broken.
> 
> Does anybody have a suggestion for fixing it?
> 
> Options we thought about:
> - Change mPcdDatabaseLock.Tpl to TPL_HIGH_LEVEL
> - Don't use a PCD for the base address, put it in a static global variable and
>   create functions to set and retrieve it.

In the ArmVirtPkg platforms, we also set "PcdPciExpressBaseAddress"
dynamically. And, we implemented your second option above; see:

  ArmVirtPkg/Library/BaseCachingPciExpressLib/

Relevant commits:

- ad3359eb43a9 ("ArmVirtualizationPkg: clone BasePciExpressLib, cache
PCIe config base", 2015-02-23)
- a06d0bb58eb9 ("ArmVirtPkg/BaseCachingPciExpressLib: depend on
PciPcdProducerLib", 2016-04-12)

(In fact, commit ad3359eb43a9 documents the exact issue you report here.)

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


Re: [edk2] [PATCH v2 3/3] SecurityPkg: remove PE/COFF header workaround for ELILO on IPF

2018-09-07 Thread Laszlo Ersek
On 09/07/18 07:42, Ard Biesheuvel wrote:
> Now that Itanium support has been dropped, we can remove the various
> occurrences of the ELILO on Itanium PE/COFF header workaround.
> 
> Link: https://bugzilla.tianocore.org/show_bug.cgi?id=816
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
> | 47 
>  SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c  
> | 27 +++
>  SecurityPkg/Tcg/Tcg2Dxe/MeasureBootPeCoff.c  
> | 27 +++
>  SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c 
> | 25 +++
>  4 files changed, 25 insertions(+), 101 deletions(-)

Reviewed-by: Laszlo Ersek 

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


[edk2] [edk2-platforms] Remove branches from edk2-platforms

2018-09-07 Thread Guo, Mang
Propose removing below branches from edk2-platforms since these branches will 
not be maintained. If you have any comments on this change, please reply to 
this email.

https://github.com/tianocore/edk2-platforms/tree/devel-MinnowBoard3-UDK2017

https://github.com/tianocore/edk2-platforms/tree/devel-MinnowBoard3

https://github.com/tianocore/edk2-platforms/tree/minnowboard-max-udk2015



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


[edk2] [Patch] Build spec: correct the Operator used in the expression for Table 12

2018-09-07 Thread Yonghong Zhu
Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=598
Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 .../82_auto-generation_process.md  | 34 +++---
 README.md  |  1 +
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/8_pre-build_autogen_stage/82_auto-generation_process.md 
b/8_pre-build_autogen_stage/82_auto-generation_process.md
index 6ce1710..9b61e0d 100644
--- a/8_pre-build_autogen_stage/82_auto-generation_process.md
+++ b/8_pre-build_autogen_stage/82_auto-generation_process.md
@@ -657,15 +657,11 @@ Refer to the DSC and FDF file form specifications 
"_Conditional Directive
 Blocks_" section for additional details of how directives must be processed.
 
  8.2.4.6 Expressions
 
 Expressions can be used in conditional directive comparison statements and in
-value fields for PCDs in the DSC and FDF files.
-
-**
-**Note:** Expressions are not supported in the INF and DEC files.
-**
+value fields for PCDs in the meta-data files.
 
 Expressions follow C relation, equality, logical and bitwise precedence and
 associativity. Not all C operators are supported, only operators in the
 following list can be used.
 
@@ -681,22 +677,26 @@ Use of parenthesis is encouraged to remove ambiguity.
 Additional scripting style operators may be used in place of C operators as
 shown in the table below.
 
 ## Table 12 Operator Precedence and Supported Operands
 
-| Operator | Use with Data Types   | Notes 


| Priority |
-|  | - | 
-
 |  |
-| `or`, `OR`, ||| Number, Boolean   |   


| Lowest   |
-| `and`, `AND`, `&&`   | Number, Boolean   |   


|  |
-| |  | Number, Boolean   | 
Bitwise OR  

  |  |
-| `^`, `xor`, `XOR`| Number, Boolean   | 
Exclusive OR

  |  |
-| `&`  | Number, Boolean   | 
Bitwise AND 

  |  |
-| `==`, `!=`, `EQ`, `NE`, `IN` | All   | The 
IN operator can only be used to test a quoted unary literal string for 
membership in a list.   
   |  |
-|  |   | Space 
characters must be used before and after the letter operators Strings compared 
to boolean or numeric values using "==" or "EQ" will always return FALSE, while 
using the "!=" or "NE" operators will always return TRUE |  |
-| `<=`, `>=`, `<`, `>`, `LE`, `GE`, `LT`, `GT` | All   | Space 
characters must be used before and after the letter operators.  

|  |
-| `+`, `-` | Number, Boolean   | 
Cannot be used with strings - the system does not automatically do 
concatenation. Tools should report a warning message if these operators are 
used with both a boolean and number value  
|  |
-| `!`, `not`, `NOT` 

[edk2] [Patch] BaseTool: Variable Merge.

2018-09-07 Thread BobCF
If Structure PCD and Normal Pcd refer to the
same variable, do variable merge.

Enhance error message.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py |  3 +-
 BaseTools/Source/Python/AutoGen/GenVar.py  | 71 --
 .../Source/Python/Workspace/BuildClassObject.py|  2 +
 BaseTools/Source/Python/Workspace/DscBuildData.py  |  3 +-
 4 files changed, 60 insertions(+), 19 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 95370d1821..d1bd1b1d4c 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1211,11 +1211,11 @@ class PlatformAutoGen(AutoGen):
 continue
 if len(Sku.VariableName) > 0:
 VariableGuidStructure = Sku.VariableGuidValue
 VariableGuid = 
GuidStructureStringToGuidString(VariableGuidStructure)
 for StorageName in Sku.DefaultStoreDict:
-VariableInfo.append_variable(var_info(Index, pcdname, 
StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, 
Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, 
Sku.DefaultStoreDict[StorageName], Pcd.DatumType))
+VariableInfo.append_variable(var_info(Index, pcdname, 
StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, 
Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, 
Sku.DefaultStoreDict[StorageName], Pcd.DatumType, 
Pcd.CustomAttribute['DscPosition'], Pcd.CustomAttribute.get('IsStru',False)))
 Index += 1
 return VariableInfo
 
 def UpdateNVStoreMaxSize(self, OrgVpdFile):
 if self.VariableInfo:
@@ -2104,10 +2104,11 @@ class PlatformAutoGen(AutoGen):
 EdkLogger.error('build', FORMAT_INVALID, Cause, 
File=self.MetaFile,
 ExtraData="%s.%s" % 
(ToPcd.TokenSpaceGuidCName, TokenCName))
 ToPcd.validateranges = FromPcd.validateranges
 ToPcd.validlists = FromPcd.validlists
 ToPcd.expressions = FromPcd.expressions
+ToPcd.CustomAttribute = FromPcd.CustomAttribute
 
 if FromPcd is not None and ToPcd.DatumType == TAB_VOID and not 
ToPcd.MaxDatumSize:
 EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for 
PCD %s.%s" \
 % (ToPcd.TokenSpaceGuidCName, TokenCName))
 Value = ToPcd.DefaultValue
diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py 
b/BaseTools/Source/Python/AutoGen/GenVar.py
index 75d455b407..036f00e2bb 100644
--- a/BaseTools/Source/Python/AutoGen/GenVar.py
+++ b/BaseTools/Source/Python/AutoGen/GenVar.py
@@ -20,11 +20,11 @@ import copy
 from Common.VariableAttributes import VariableAttributes
 from Common.Misc import *
 import collections
 import Common.DataType as DataType
 
-var_info = collections.namedtuple("uefi_var", 
"pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, 
var_offset,var_attribute,pcd_default_value, default_value, data_type")
+var_info = collections.namedtuple("uefi_var", 
"pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, 
var_offset,var_attribute,pcd_default_value, default_value, 
data_type,PcdDscLine,StructurePcd")
 NvStorageHeaderSize = 28
 VariableHeaderSize = 32
 
 class VariableMgr(object):
 def __init__(self, DefaultStoreMap, SkuIdMap):
@@ -54,37 +54,74 @@ class VariableMgr(object):
 value_str = "{"
 default_var_bin_strip = [ data.strip("""'""") for data in 
default_var_bin]
 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 

[edk2] [Patch] INF spec: Correct some items in the Table 1 EDK II [Defines] Section

2018-09-07 Thread Yonghong Zhu
Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=1162
Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 2_inf_overview/24_[defines]_section.md   | 59 
 3_edk_ii_inf_file_format/34_[defines]_section.md |  2 +-
 README.md|  1 +
 3 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/2_inf_overview/24_[defines]_section.md 
b/2_inf_overview/24_[defines]_section.md
index 37b0135..0afdfed 100644
--- a/2_inf_overview/24_[defines]_section.md
+++ b/2_inf_overview/24_[defines]_section.md
@@ -106,35 +106,34 @@ the PEI Core or the Dxe Core. EDK II only references the 
first possible
 dispatch instance.
 **
 
 ## Table 1 EDK II [Defines] Section Elements
 
-| Tag  | Required  
   | Value | 
Notes   




|
-|  | 
 | 
- | 
---
 |
-| `INF_VERSION`| REQUIRED  
   | 1.27 or 0x0001001B| 
This identifies the INF spec. version. It is decimal value with fraction or 
two-nibble hexadecimal representation of the same, for example: 1.27. Tools use 
this value to handle parsing of previous releases of the specification if there 
are incompatible changes.   


   |
-| `BASE_NAME`  | REQUIRED  
   | A single word | 
This is a single word identifier that will be used for the component name.  




|
-| `EDK_RELEASE_VERSION`| Not required  
   | Hex Double Word   | 
The minimum revision value across the module and all its dependent libraries. 
If a revision value is not declared in the module or any of the dependent 
libraries, then the tool may use the value of 0, which disables checking.   


|
-| `PI_SPECIFICATION_VERSION`   | Not required  
   | Decimal or special format of hex  | 
The minimum revision value across the module and all its dependent libraries. 
If a revision value is not declared in the module or any of the dependent 
libraries, then tools may use the value of 0, which disables checking.  


|
-|  |   
   |   | 
The `PI_SPECIFICATION_VERSION` must only be set in the INF file if the module 
depends on services or system table fields or PI core behaviors that are not 
present in the PI 1.0 version. For example, if a module depends on definitions 
in PI 1.1 that are not in PI 1.0, then `P