Re: [edk2] VFR validation of IP address and iSCSI IQN

2018-01-10 Thread Atul Gupta
Thanks for the reply,

My code works if INTERACTIVE flag is used and iqn validated using 
IScsiNormalizeName. I was looking for a way to validate iqn/ip-address within 
the vfr i.e use " flags   = 0" and have appropriate expression included in vfr.

Thanks
Atul

-Original Message-
From: Bi, Dandan [mailto:dandan...@intel.com] 
Sent: Thursday, January 11, 2018 1:02 PM
To: Atul Gupta ; edk2-devel@lists.01.org
Subject: RE: VFR validation of IP address and iSCSI IQN

Hi,

(1) If you want the string can only be set with the one in STR_STRING_CHECK, 
you can add  following codes within the string opcode: 

   inconsistentif prompt = STRING_TOKEN(STR_INVALID_IQN),
   pushthis != stringref(STRING_TOKEN(STR_STRING_CHECK))
   endif;

(2) If you want the string only cannot be set with the one in STR_STRING_CHECK, 
you can add following codes within the string opcode:

   inconsistentif prompt = STRING_TOKEN(STR_INVALID_IQN),
   pushthis == stringref(STRING_TOKEN(STR_STRING_CHECK))
   endif;

For more examples you can refer to the vfr file in: 
edk2\MdeModulePkg\Universal\DriverSampleDxe\ Vfr.vfr.


Thanks,
Dandan

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Atul 
Gupta
Sent: Thursday, January 11, 2018 2:52 PM
To: edk2-devel@lists.01.org
Subject: [edk2] VFR validation of IP address and iSCSI IQN

Hi,

I want to validate IP address and iSCSI IQN within the vfr form. Want to avoid 
callback hence removed the INTERACTIVE flags, tried few things but none seems 
to work except for input length check, how to validate the input buffer.

Eg:

string  name= iqn,
varid   = UD_CONFIG_IFR_NVDATA.InitiatorName,
prompt  = STRING_TOKEN(STR_ISCSI_CONFIG_INIT_NAME),
help= STRING_TOKEN(STR_ISCSI_CONFIG_INIT_NAME_HELP),
flags   = 0,
key = KEY_INITIATOR_NAME2,
minsize = 8,
maxsize = ISCSI_NAME_IFR_MAX_SIZE,
 inconsistentif prompt = 
STRING_TOKEN(STR_INVALID_IQN),
 NOT
 pushthis != 
stringref(STRING_TOKEN(STR_STRING_CHECK))
 endif
endstring;

also tried
span (flags = LAST_NON_MATCH, pushthis, 
stringref(STRING_TOKEN(STR_STRING_CHECK)), 0) != 0, but did not help.

Any reference to validate the input buffer?

Thanks
Atul
___
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] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual().

2018-01-10 Thread Wu, Jiaxin
Hi Fan,

I think we need to update the below ASSERT if apply you patch:

ASSERT ((Ip1 != NULL) && (Ip2 != NULL) && (PrefixLength <= 
IP6_PREFIX_MAX));

Update To: 

ASSERT ((Ip1 != NULL) && (Ip2 != NULL) && (PrefixLength < 
IP6_PREFIX_MAX));


If PrefixLength is IP6_PREFIX_MAX(128), then the Byte can be 16:

Byte = (UINT8) (PrefixLength / 8);

So, it will conflict with your patch ASSERT:

ASSERT (Byte < 16);

Thanks,
Jiaxin

> -Original Message-
> From: Wang, Fan
> Sent: Thursday, January 11, 2018 10:39 AM
> To: edk2-devel@lists.01.org
> Cc: Fu, Siyuan ; Wu, Jiaxin ; Wu,
> Hao A 
> Subject: [Patch] MdeModulePkg/DxeNetLib: Add array range check in
> NetIp6IsNetEqual().
> 
> * The library API use array elements without any index range check, this
>   patch is to fix this issue to avoid null pointer reference.
> 
> Cc: Fu Siyuan 
> Cc: Jiaxin Wu 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wang Fan 
> ---
>  MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> index cbce28f..34e11a8 100644
> --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> @@ -840,10 +840,14 @@ NetIp6IsNetEqual (
>}
> 
>if (Bit > 0) {
>  Mask = (UINT8) (0xFF << (8 - Bit));
> 
> +ASSERT (Byte < 16);
> +if (Byte >= 16) {
> +  return FALSE;
> +}
>  if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) {
>return FALSE;
>  }
>}
> 
> --
> 1.9.5.msysgit.1

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


Re: [edk2] VFR validation of IP address and iSCSI IQN

2018-01-10 Thread Bi, Dandan
Hi,

(1) If you want the string can only be set with the one in STR_STRING_CHECK, 
you can add  following codes within the string opcode: 

   inconsistentif prompt = STRING_TOKEN(STR_INVALID_IQN),
   pushthis != stringref(STRING_TOKEN(STR_STRING_CHECK))
   endif;

(2) If you want the string only cannot be set with the one in STR_STRING_CHECK, 
you can add following codes within the string opcode:

   inconsistentif prompt = STRING_TOKEN(STR_INVALID_IQN),
   pushthis == stringref(STRING_TOKEN(STR_STRING_CHECK))
   endif;

For more examples you can refer to the vfr file in: 
edk2\MdeModulePkg\Universal\DriverSampleDxe\ Vfr.vfr.


Thanks,
Dandan

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Atul 
Gupta
Sent: Thursday, January 11, 2018 2:52 PM
To: edk2-devel@lists.01.org
Subject: [edk2] VFR validation of IP address and iSCSI IQN

Hi,

I want to validate IP address and iSCSI IQN within the vfr form. Want to avoid 
callback hence removed the INTERACTIVE flags, tried few things but none seems 
to work except for input length check, how to validate the input buffer.

Eg:

string  name= iqn,
varid   = UD_CONFIG_IFR_NVDATA.InitiatorName,
prompt  = STRING_TOKEN(STR_ISCSI_CONFIG_INIT_NAME),
help= STRING_TOKEN(STR_ISCSI_CONFIG_INIT_NAME_HELP),
flags   = 0,
key = KEY_INITIATOR_NAME2,
minsize = 8,
maxsize = ISCSI_NAME_IFR_MAX_SIZE,
 inconsistentif prompt = 
STRING_TOKEN(STR_INVALID_IQN),
 NOT
 pushthis != 
stringref(STRING_TOKEN(STR_STRING_CHECK))
 endif
endstring;

also tried
span (flags = LAST_NON_MATCH, pushthis, 
stringref(STRING_TOKEN(STR_STRING_CHECK)), 0) != 0, but did not help.

Any reference to validate the input buffer?

Thanks
Atul
___
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] VFR validation of IP address and iSCSI IQN

2018-01-10 Thread Atul Gupta
Hi,

I want to validate IP address and iSCSI IQN within the vfr form. Want to avoid 
callback hence removed the INTERACTIVE flags, tried few things but none seems 
to work except for input length check, how to validate the input buffer.

Eg:

string  name= iqn,
varid   = UD_CONFIG_IFR_NVDATA.InitiatorName,
prompt  = STRING_TOKEN(STR_ISCSI_CONFIG_INIT_NAME),
help= STRING_TOKEN(STR_ISCSI_CONFIG_INIT_NAME_HELP),
flags   = 0,
key = KEY_INITIATOR_NAME2,
minsize = 8,
maxsize = ISCSI_NAME_IFR_MAX_SIZE,
 inconsistentif prompt = 
STRING_TOKEN(STR_INVALID_IQN),
 NOT
 pushthis != 
stringref(STRING_TOKEN(STR_STRING_CHECK))
 endif
endstring;

also tried
span (flags = LAST_NON_MATCH, pushthis, 
stringref(STRING_TOKEN(STR_STRING_CHECK)), 0) != 0, but did not help.

Any reference to validate the input buffer?

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


Re: [edk2] [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement GetElapsedTime function of TimerLib

2018-01-10 Thread Pankaj Bansal
Hi Laszlo,

> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Wednesday, January 10, 2018 10:34 PM
> To: Pankaj Bansal ; edk2-devel@lists.01.org
> Cc: Leif Lindholm ; Ard Biesheuvel
> ; Michael Kinney 
> Subject: Re: [edk2] [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement
> GetElapsedTime function of TimerLib
> 
> Hi Pankaj,
> 
> On 01/10/18 17:05, Pankaj Bansal wrote:
> > Hi Laszlo,
> >
> > Thanks for reviewing my changes and thanks for pointing me to the thread
> that you worked on.
> > It was really helpful. please see my response inline ..
> >
> >> -Original Message-
> >> From: Laszlo Ersek [mailto:ler...@redhat.com]
> >> Sent: Wednesday, January 10, 2018 7:46 PM
> >> To: Pankaj Bansal ; edk2-devel@lists.01.org
> >> Cc: Leif Lindholm ; Ard Biesheuvel
> >> ; Michael Kinney
> >> 
> >> Subject: Re: [edk2] [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement
> >> GetElapsedTime function of TimerLib
> >>
> >> Hello Pankaj,
> >>
> >> On 01/10/18 10:31, Pankaj Bansal wrote:
> >>> This function calculates the time elaped in Naoseconds between call
> >>> to this function and BaseTime, which is passed as argument.
> >>>
> >>> This is particularly useful in detecting timeout conditions.
> >>>
> >>> Cc: Leif Lindholm 
> >>> Cc: Ard Biesheuvel 
> >>> Contributed-under: TianoCore Contribution Agreement 1.1
> >>> Signed-off-by: Pankaj Bansal 
> >>>
> >>> diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
> >>> b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
> >>> index b81293c..0898339 100644
> >>> --- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
> >>> +++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
> >>> @@ -290,3 +290,39 @@ GetTimeInNanoSecond (
> >>>
> >>>return NanoSeconds;
> >>>  }
> >>> +
> >>> +/**
> >>> +  Get Elapsed time in Nanoseonds w.r.t BaseTime
> >>> +
> >>> +  This function calculates the time elaped in Naoseconds between
> >>> + call to this  function and BaseTime, which is passed as argument.
> >>> +
> >>> +  @param  BaseTime BaseTime in NanoSeconds.
> >>> +
> >>> +  @return The elapsed time in nanoseconds.
> >>> +
> >>> +**/
> >>> +UINT64
> >>> +EFIAPI
> >>> +GetElapsedTime (
> >>> +  IN  UINT64 BaseTime
> >>> +  )
> >>> +{
> >>> +  UINT64  NanoSeconds;
> >>> +  UINT64  Ticks;
> >>> +
> >>> +  //
> >>> +  // Get current Ticks.
> >>> +  //
> >>> +  Ticks = GetPerformanceCounter();
> >>> +
> >>> +  //
> >>> +  // Convert Ticks to Nanoseconds
> >>> +  //
> >>> +  NanoSeconds = GetTimeInNanoSecond (Ticks);
> >>> +
> >>> +  //
> >>> +  // return the difference
> >>> +  //
> >>> +  return (NanoSeconds - BaseTime);
> >>> +}
> >>>
> >>
> >> There are two problems with this patch set:
> >>
> >> (1) The TimerLib.h file (in the first patch) is a public library
> >> class header, for which several library instances (implementations)
> >> exist. So, introducing a new API requires adding an implementation
> >> (the same implementation, or different ones, as necessary) to *all*
> instances in the edk2 tree.
> >
> > I agree with your intent to prevent code duplication. But I still feel that 
> > we
> should enhance TimerLib.
> > Because, a user intending to use various timer functionalities, should
> include only one header file (TimerLib.h) and one Library.
> > Like Mike pointed out in your thread to enhance the TimerTickDiffLib,
> > in future if someone wishes to add some new functionality related to
> > timer and if he writes a new library for it, then its added cumbersome
> > for users (user has to include 3 header files and libraries 3.)
> >
> > To prevent code duplication, can we look at other ways like using weak
> symbols for such functions that are platform agnostic.
> > Or putting these generic functions in one .c file in MdePkg and include that
> file in inf file of TimerLib implementation?
> >
> >>
> >> (2) The calculation in your GetElapsedTime() function is wrong.
> >> GetTimeInNanoSecond() converts a small *difference* of ticks to time.
> >> It does not convert an absolute tick value to an absolute time.
> >
> > The GetTimeInNanoSecond() is only concerned with the ticks. Those ticks
> can be a difference of ticks or absolute ticks from counter start.
> > The *difference* part of GetElapsedTime would depend on its usage. Like
> this :
> > Start = GetElapsedTime (0);
> > // do something
> > End = GetElapsedTime (Start);
> >
> >>
> >> Furthermore, tick differences are less trivial to calculate than one
> >> might imagine, because (a) a performance counter may count down, and
> >> *independently*, (b) the numeric low bound of the counter range may
> >> not be zero.
> >>
> >
> > This is nice observation. It was an oversight on my 

[edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017] DMIC NHLT Entry.

2018-01-10 Thread zwei4
Customize DMIC NHLT entry for boards.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: zwei4 
---
 .../Board/AuroraGlacier/BoardInitPostMem/BoardInit.c | 5 +
 .../Board/AuroraGlacier/BoardInitPostMem/BoardInitPostMem.inf| 3 ++-
 .../Board/BensonGlacier/BoardInitPostMem/BoardInit.c | 7 ++-
 .../Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf| 3 ++-
 .../Board/LeafHill/BoardInitPostMem/BoardInit.c  | 9 +++--
 .../Board/LeafHill/BoardInitPostMem/BoardInitPostMem.inf | 3 ++-
 .../Board/MinnowBoard3/BoardInitPostMem/BoardInit.c  | 7 ++-
 .../Board/MinnowBoard3/BoardInitPostMem/BoardInitPostMem.inf | 3 ++-
 .../PlatformSettings/PlatformSetupDxe/SouthClusterConfig.vfi | 6 +++---
 Silicon/BroxtonSoC/BroxtonSiPkg/BroxtonSiPkg.dec | 8 ++--
 Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/ScInit/Dxe/ScHda.c  | 6 +-
 .../BroxtonSiPkg/SouthCluster/ScInit/Dxe/ScInitDxe.inf   | 4 +++-
 12 files changed, 49 insertions(+), 15 deletions(-)

diff --git 
a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPostMem/BoardInit.c 
b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPostMem/BoardInit.c
index 2f33bfe21..5ede1f114 100644
--- 
a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPostMem/BoardInit.c
+++ 
b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPostMem/BoardInit.c
@@ -144,6 +144,11 @@ AuroraGlacierPostMemInitCallback (
   PcdSet8(HdaEndpointI2sRenderHPVirtualBusId, 1);  // I2S2
   PcdSet8(HdaEndpointI2sCaptureVirtualBusId, 1);   // I2S2
 
+  //
+  // DMIC
+  //
+  PcdSet8(NhltEndpointDmic, (UINT8) 
SystemConfiguration.ScHdAudioNhltEndpointDmic);
+
   //
   // Add init steps here
   //
diff --git 
a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPostMem/BoardInitPostMem.inf
 
b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPostMem/BoardInitPostMem.inf
index f47cb4f28..ec30b262c 100644
--- 
a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPostMem/BoardInitPostMem.inf
+++ 
b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPostMem/BoardInitPostMem.inf
@@ -72,7 +72,8 @@
   gEfiBxtTokenSpaceGuid.HdaEndpointI2sRenderSKPVirtualBusId
   gEfiBxtTokenSpaceGuid.HdaEndpointI2sRenderHPVirtualBusId
   gEfiBxtTokenSpaceGuid.HdaEndpointI2sCaptureVirtualBusId
-
+  gEfiBxtTokenSpaceGuid.NhltEndpointDmic
+  
 [Guids]
   gEfiPlatformInfoGuid
   gEfiAuthenticatedVariableGuid
diff --git 
a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.c 
b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.c
index aabb350e8..deb36c610 100644
--- 
a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.c
+++ 
b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.c
@@ -1,7 +1,7 @@
 /** @file
   Board Init driver.
 
-  Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2010 - 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
@@ -143,6 +143,11 @@ BensonGlacierPostMemInitCallback (
   PcdSet8(HdaEndpointI2sRenderSKPVirtualBusId, 1); // I2S2
   PcdSet8(HdaEndpointI2sRenderHPVirtualBusId, 1);  // I2S2
   PcdSet8(HdaEndpointI2sCaptureVirtualBusId, 1);   // I2S2
+  
+  //
+  // DMIC
+  //
+  PcdSet8(NhltEndpointDmic, (UINT8) 
SystemConfiguration.ScHdAudioNhltEndpointDmic);
 
   //
   // Add init steps here
diff --git 
a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf
 
b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf
index c7499b564..53fa6756f 100644
--- 
a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf
+++ 
b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf
@@ -2,7 +2,7 @@
 #  Board detected module for Intel(R) Atom(TM) x5 Processor Series.
 #  It will detect the board ID.
 #
-#  Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
+#  Copyright (c) 2014 - 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
@@ -72,6 +72,7 @@
   gEfiBxtTokenSpaceGuid.HdaEndpointI2sRenderSKPVirtualBusId
   gEfiBxtTokenSpaceGuid.HdaEndpointI2sRenderHPVirtualBusId
   gEfiBxtTokenSpaceGuid.HdaEndpointI2sCaptureVirtualBusId
+  gEfiBxtTokenSpaceGuid.NhltEndpointDmic
 
 [Guids]
   gEfiPlatformInfoGuid
diff --git 
a/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPostMem/BoardInit.c 
b/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPostMem/BoardInit.c
index fdf2c7eaa..fdd6b4de6 100644
--- a/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPostMem/BoardInit.c
+++ 

Re: [edk2] [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual().

2018-01-10 Thread Wu, Hao A
Reviewed-by: Hao Wu 


Best Regards,
Hao Wu


> -Original Message-
> From: Wang, Fan
> Sent: Thursday, January 11, 2018 10:39 AM
> To: edk2-devel@lists.01.org
> Cc: Fu, Siyuan; Wu, Jiaxin; Wu, Hao A
> Subject: [Patch] MdeModulePkg/DxeNetLib: Add array range check in
> NetIp6IsNetEqual().
> 
> * The library API use array elements without any index range check, this
>   patch is to fix this issue to avoid null pointer reference.
> 
> Cc: Fu Siyuan 
> Cc: Jiaxin Wu 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wang Fan 
> ---
>  MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> index cbce28f..34e11a8 100644
> --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> @@ -840,10 +840,14 @@ NetIp6IsNetEqual (
>}
> 
>if (Bit > 0) {
>  Mask = (UINT8) (0xFF << (8 - Bit));
> 
> +ASSERT (Byte < 16);
> +if (Byte >= 16) {
> +  return FALSE;
> +}
>  if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) {
>return FALSE;
>  }
>}
> 
> --
> 1.9.5.msysgit.1

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


Re: [edk2] [Patch 0/4] Fix some issues in Udp6Dxe

2018-01-10 Thread Wu, Jiaxin
Series Reviewed-by: Jiaxin Wu 


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> fanwang2
> Sent: Thursday, January 4, 2018 11:20 AM
> To: edk2-devel@lists.01.org
> Cc: Wang, Fan 
> Subject: [edk2] [Patch 0/4] Fix some issues in Udp6Dxe
> 
> From: Wang Fan 
> 
> See descriptions in each patch.
> 
> Wang Fan (4):
>   NetworkPkg: Add ASSERT error handling for UDP6 driver
>   NetworkPkg: Fix a memory leak issue in UDP6 driver
>   NetworkPkg: Fix some coding style issues in UDP6 driver
>   NetworkPkg: Add more parameter or return status check in UDP6 driver
> 
>  NetworkPkg/Udp6Dxe/Udp6Driver.c | 68 ++---
> 
>  NetworkPkg/Udp6Dxe/Udp6Impl.c   | 43 +++---
>  NetworkPkg/Udp6Dxe/Udp6Main.c   | 14 +++--
>  3 files changed, 86 insertions(+), 39 deletions(-)
> 
> --
> 1.9.5.msysgit.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] MdeModulePkg/DebugLib: Print partial when format string is too long

2018-01-10 Thread Ruiyu Ni
Today's implementation prints nothing when the format string cannot
fit in the report status extended data buffer.
It confuses user.
The patch changes to print partial message by truncating the format
string when it's too long.

The missing enhancement is the extended data buffer only reserves 96
bytes for the var-args. When the format string is not very long but
contains 13 %lx or %p, the var-args buffer is too small. Today's
implementation prints nothing for this case.
This patch doesn't change such behavior.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Liming Gao 
---
 .../PeiDxeDebugLibReportStatusCode/DebugLib.c   | 21 +++--
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c 
b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
index 163d530ae5..785e231cf2 100644
--- a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
+++ b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
@@ -4,7 +4,7 @@
   Note that if the debug message length is larger than the maximum allowable
   record length, then the debug message will be ignored directly.
 
-  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 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
@@ -55,7 +55,6 @@ DebugPrint (
 {
   UINT64  Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)) + 
1];
   EFI_DEBUG_INFO  *DebugInfo;
-  UINTN   TotalSize;
   VA_LIST VaListMarker;
   BASE_LIST   BaseListMarker;
   CHAR8   *FormatString;
@@ -74,7 +73,6 @@ DebugPrint (
   }
 
   //
-  // Compute the total size of the record.
   // Note that the passing-in format string and variable parameters will be 
constructed to 
   // the following layout:
   //
@@ -90,14 +88,6 @@ DebugPrint (
   // |   Format String|
   // ||<- (UINT8 *)Buffer + 
sizeof(Buffer)
   //
-  TotalSize = 4 + sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + 
AsciiStrSize (Format);
-
-  //
-  // If the TotalSize is larger than the maximum record size, then return
-  //
-  if (TotalSize > sizeof (Buffer)) {
-return;
-  }
 
   //
   // Fill in EFI_DEBUG_INFO
@@ -113,9 +103,12 @@ DebugPrint (
   FormatString  = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);
 
   //
-  // Copy the Format string into the record
+  // Copy the Format string into the record. It will be truncated if it's too 
long.
   //
-  AsciiStrCpyS (FormatString, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 
12 * sizeof(UINT64)), Format);
+  AsciiStrnCpyS (
+FormatString, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 * 
sizeof(UINT64)),
+Format,   sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 * 
sizeof(UINT64)) - 1
+);
 
   //
   // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for 
variable arguments
@@ -223,7 +216,7 @@ DebugPrint (
 NULL,
 ,
 DebugInfo,
-TotalSize
+sizeof (Buffer)
 );
 }
 
-- 
2.15.1.windows.2

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


Re: [edk2] [PATCH 0/5] BaseTools/Common & DevicePath: Code refinements

2018-01-10 Thread Zhu, Yonghong
Please help to update copyright year when push it.

Reviewed-by: Yonghong Zhu 

Best Regards,
Zhu Yonghong


-Original Message-
From: Wu, Hao A 
Sent: Monday, January 08, 2018 1:31 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Ni, Ruiyu ; Zhu, 
Yonghong ; Gao, Liming 
Subject: [PATCH 0/5] BaseTools/Common & DevicePath: Code refinements

The series refines the C/C++ source codes within BaseTools/C/Source/Common/ and 
BaseTools/Source/C/DevicePath/ for the below catagories:

* Resolve possible resource/memory leaks

* Resolve possible NULL pointer dereferences

Cc: Ruiyu Ni 
Cc: Yonghong Zhu 
Cc: Liming Gao 

Hao Wu (5):
  BaseTools/C/Common: Fix code to be more readable
  BaseTools/C/Common: Fix potential memory leak
  BaseTools/DevicePath: Fix potential memory leak
  BaseTools/C/Common: Fix potential null pointer dereference
  BaseTools/DevicePath: Fix potential null pointer dereference

 BaseTools/Source/C/Common/CommonLib.c  |  2 +-
 BaseTools/Source/C/Common/PcdValueCommon.c | 10 ++
 BaseTools/Source/C/DevicePath/DevicePath.c |  6 ++
 BaseTools/Source/C/DevicePath/DevicePathFromText.c | 11 +++
 4 files changed, 28 insertions(+), 1 deletion(-)

--
2.12.0.windows.1

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


[edk2] [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual().

2018-01-10 Thread Wang Fan
* The library API use array elements without any index range check, this
  patch is to fix this issue to avoid null pointer reference.

Cc: Fu Siyuan 
Cc: Jiaxin Wu 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan 
---
 MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c 
b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index cbce28f..34e11a8 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -840,10 +840,14 @@ NetIp6IsNetEqual (
   }
 
   if (Bit > 0) {
 Mask = (UINT8) (0xFF << (8 - Bit));
 
+ASSERT (Byte < 16);
+if (Byte >= 16) {
+  return FALSE;
+}
 if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) {
   return FALSE;
 }
   }
 
-- 
1.9.5.msysgit.1

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


Re: [edk2] [Patch 3/7] MdeModulePkg: Update DebugSupportDxe to pass XCODE5 build

2018-01-10 Thread Zeng, Star
Reviewed-by: Star Zeng 


Thanks,
Star
-Original Message-
From: Gao, Liming 
Sent: Wednesday, January 10, 2018 11:24 PM
To: edk2-devel@lists.01.org
Cc: Andrew Fish ; Zeng, Star 
Subject: [Patch 3/7] MdeModulePkg: Update DebugSupportDxe to pass XCODE5 build

XCODE5 doesn't support absolute addressing in the assembly code.
This change uses lea instruction to get the address.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Andrew Fish 
Cc: Star Zeng 
---
 MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.nasm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.nasm 
b/MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.nasm
index 134842a68a..31d8b0a717 100644
--- a/MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.nasm
+++ b/MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.nasm
@@ -1,7 +1,7 @@
 ;/** @file
 ;  Low level x64 routines used by the debug support driver.
 ;
-;  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+;  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 @@ 
-226,7 +226,7 @@ ASM_PFX(CommonIdtEntry):
 pop rax
 add rsp, 8   ; pop vector number
 mov [AppRsp], rsp; save stack top
-mov rsp, DebugStackBegin ; switch to debugger 
stack
+lea rsp, [DebugStackBegin]   ; switch to debugger 
stack
 sub rsp, 8   ; leave space for 
vector number
 
 ;; UINT64  Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; @@ -529,7 +529,7 @@ Chain:
 pushrbx
 mov rax, cs
 pushrax
-mov rax, PhonyIretq
+lea rax, [PhonyIretq]
 pushrax
 iretq
 PhonyIretq:
--
2.11.0.windows.1

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


Re: [edk2] [RFC] SATA : Implemented NXP errata A008402

2018-01-10 Thread Ni, Ruiyu

On 1/10/2018 5:52 PM, Ard Biesheuvel wrote:

On 10 January 2018 at 09:43, Udit Kumar  wrote:

Hi Ruiyu,


-Original Message-


And this change will not impact any other hardware so no one is basically

impacted by this change.

Your buggy HW only need the value zero. But the addition of PCD exposes
an interface that can use any size of PRD.
I am not sure the AtaAtapiPassThru can work if some platform sets the PCD
value to others than 0 or 3F_h.


I don't see someone using this driver will set Pcd randomly, but I agree on this
point other value should be handled.
Error or Assert could be added, if Pcd value is not 0 or 3F_h.


Can you please
   just duplicate the AtaAtapiPassThru in your platform?
Because the driver is very stable today, not much code sync effort will be
needed if core version is changed.


Duplicating is always a possibility :), but When we will push this duplicated 
driver
(just for one line change) for upstreaming.
will this be acceptable ??


My main concern with this (and with using a PCD) is that the setting
affects all SATA controllers in the system, including ones the you
stick into a PCIe slot.

So I think forking the driver is the only possible solution, but it
will not be a one-line change: you need to ensure that you apply the
workaround only to the SATA controllers in the SoC.



Depending on the new driver's location. The package owner decides
whether forking is acceptable :)


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


Re: [edk2] [Patch 4/7] UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool chain

2018-01-10 Thread Gao, Liming
Mike:
  Thanks for your comments. The style "mov rax, strict qword 0" works. I 
will use it.

> -Original Message-
> From: Kinney, Michael D
> Sent: Thursday, January 11, 2018 5:58 AM
> To: Gao, Liming ; edk2-devel@lists.01.org; Kinney, 
> Michael D 
> Cc: Andrew Fish ; Yao, Jiewen ; Dong, 
> Eric ; Laszlo Ersek
> 
> Subject: RE: [Patch 4/7] UefiCpuPkg: Update CpuExceptionHandlerLib pass 
> XCODE5 tool chain
> 
> Liming,
> 
> Here is a previous patch email series that demonstrates
> this technique.
> 
> https://lists.01.org/pipermail/edk2-devel/2017-September/015109.html
> 
> https://github.com/tianocore/edk2/commit/4c34a8ea191155f438901e635bd87810072b19a4#diff-5d3b0f5982124c722c30f6d0e6b87
> 11d
> 
> Thanks,
> 
> Mike
> 
> > -Original Message-
> > From: Kinney, Michael D
> > Sent: Wednesday, January 10, 2018 11:22 AM
> > To: Gao, Liming ; edk2-
> > de...@lists.01.org; Kinney, Michael D
> > 
> > Cc: Andrew Fish ; Yao, Jiewen
> > ; Dong, Eric ;
> > Laszlo Ersek 
> > Subject: RE: [Patch 4/7] UefiCpuPkg: Update
> > CpuExceptionHandlerLib pass XCODE5 tool chain
> >
> > Liming,
> >
> > Can we use NASM syntax for instructions instead of db
> > bytes?
> >
> > If you put the label for the fixup after the instruction,
> > you
> > can patch by subtracting the size of the patch value from
> > the
> > label.
> >
> > For example, instead of:
> >
> > > +db  0x48, 0xB8
> > > +JmpAbsoluteAddress:
> > > +dq  0 ; mov rax,
> > HookAfterStubHeaderEnd
> >
> > Use:
> >
> > movqrax, 0
> > JmpAbsoluteAddress:
> >
> > And in the patch loop:
> >
> > movqword [rcx + (JmpAbsoluteAddress - 8 -
> > HookAfterStubHeaderBegin)], rax
> >
> >
> > If this works, then please use this technique to remove
> > use of db for instructions throughout this series.
> >
> > Mike
> >
> > > -Original Message-
> > > From: Gao, Liming
> > > Sent: Wednesday, January 10, 2018 7:24 AM
> > > To: edk2-devel@lists.01.org
> > > Cc: Andrew Fish ; Yao, Jiewen
> > > ; Dong, Eric
> > ;
> > > Laszlo Ersek ; Kinney, Michael D
> > > 
> > > Subject: [Patch 4/7] UefiCpuPkg: Update
> > > CpuExceptionHandlerLib pass XCODE5 tool chain
> > >
> > > Use the dummy address as jmp destination, and add the
> > > logic to fix up
> > > the address to the absolute address at boot time.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Liming Gao 
> > > Cc: Andrew Fish 
> > > Cc: Jiewen Yao 
> > > Cc: Eric Dong 
> > > Cc: Laszlo Ersek 
> > > Cc: Michael Kinney 
> > > ---
> > >  .../X64/ExceptionHandlerAsm.nasm   |
> > 29
> > > --
> > >  1 file changed, 22 insertions(+), 7 deletions(-)
> > >
> > > diff --git
> > >
> > a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Exception
> > > HandlerAsm.nasm
> > >
> > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Exception
> > > HandlerAsm.nasm
> > > index ba8993d84b..a5fde0a875 100644
> > > ---
> > >
> > a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Exception
> > > HandlerAsm.nasm
> > > +++
> > >
> > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Exception
> > > HandlerAsm.nasm
> > > @@ -1,5 +1,5 @@
> > >  ;-
> > --
> > > --- ;
> > > -; Copyright (c) 2012 - 2014, Intel Corporation. All
> > > rights reserved.
> > > +; Copyright (c) 2012 - 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
> > > @@ -40,7 +40,8 @@ AsmIdtVectorBegin:
> > >  db  0x6a; push  #VectorNum
> > >  db  ($ - AsmIdtVectorBegin) /
> > ((AsmIdtVectorEnd
> > > - AsmIdtVectorBegin) / 32) ; VectorNum
> > >  pushrax
> > > -mov rax, ASM_PFX(CommonInterruptEntry)
> > > +db  0x48, 0xB8
> > > +dq  0 ; mov rax,
> > > ASM_PFX(CommonInterruptEntry)
> > >  jmp rax
> > >  %endrep
> > >  AsmIdtVectorEnd:
> > > @@ -50,7 +51,9 @@ HookAfterStubHeaderBegin:
> > >  @VectorNum:
> > >  db  0  ; 0 will be fixed
> > >  pushrax
> > > -mov rax, HookAfterStubHeaderEnd
> > > +db  0x48, 0xB8
> > > +JmpAbsoluteAddress:
> > > +dq  0 ; mov rax,
> > HookAfterStubHeaderEnd
> > >  jmp rax
> > >  HookAfterStubHeaderEnd:
> > >  

Re: [edk2] [PATCH] UefiCpuPkg/MpInitLib: fix 32-bit build error

2018-01-10 Thread Bi, Dandan
Reviewed-by: Dandan Bi 

Thanks,
Dandan
-Original Message-
From: Wang, Jian J 
Sent: Thursday, January 11, 2018 9:02 AM
To: edk2-devel@lists.01.org
Cc: Bi, Dandan ; Dong, Eric ; Laszlo 
Ersek 
Subject: [PATCH] UefiCpuPkg/MpInitLib: fix 32-bit build error

Cc: Dandan Bi 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index e832c16eca..d2bcef53d6 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -326,7 +326,7 @@ InitMpGlobalData (
 CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
 for (Index = 0; Index < CpuMpData->CpuCount; ++Index) {
   if (CpuInfoInHob != NULL && CpuInfoInHob[Index].ApTopOfStack != 0) {
-StackBase = CpuInfoInHob[Index].ApTopOfStack - 
CpuMpData->CpuApStackSize;
+StackBase = (UINTN)CpuInfoInHob[Index].ApTopOfStack - 
CpuMpData->CpuApStackSize;
   } else {
 StackBase = CpuMpData->Buffer + Index * CpuMpData->CpuApStackSize;
   }
-- 
2.15.1.windows.2

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


Re: [edk2] [PATCH] UefiCpuPkg/MpInitLib: fix 32-bit build error

2018-01-10 Thread Dong, Eric
Reviewed-by: Eric Dong 

-Original Message-
From: Wang, Jian J 
Sent: Thursday, January 11, 2018 9:02 AM
To: edk2-devel@lists.01.org
Cc: Bi, Dandan ; Dong, Eric ; Laszlo 
Ersek 
Subject: [PATCH] UefiCpuPkg/MpInitLib: fix 32-bit build error

Cc: Dandan Bi 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index e832c16eca..d2bcef53d6 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -326,7 +326,7 @@ InitMpGlobalData (
 CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
 for (Index = 0; Index < CpuMpData->CpuCount; ++Index) {
   if (CpuInfoInHob != NULL && CpuInfoInHob[Index].ApTopOfStack != 0) {
-StackBase = CpuInfoInHob[Index].ApTopOfStack - 
CpuMpData->CpuApStackSize;
+StackBase = (UINTN)CpuInfoInHob[Index].ApTopOfStack - 
CpuMpData->CpuApStackSize;
   } else {
 StackBase = CpuMpData->Buffer + Index * CpuMpData->CpuApStackSize;
   }
-- 
2.15.1.windows.2

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


[edk2] [PATCH] UefiCpuPkg/MpInitLib: fix 32-bit build error

2018-01-10 Thread Jian J Wang
Cc: Dandan Bi 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index e832c16eca..d2bcef53d6 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -326,7 +326,7 @@ InitMpGlobalData (
 CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
 for (Index = 0; Index < CpuMpData->CpuCount; ++Index) {
   if (CpuInfoInHob != NULL && CpuInfoInHob[Index].ApTopOfStack != 0) {
-StackBase = CpuInfoInHob[Index].ApTopOfStack - 
CpuMpData->CpuApStackSize;
+StackBase = (UINTN)CpuInfoInHob[Index].ApTopOfStack - 
CpuMpData->CpuApStackSize;
   } else {
 StackBase = CpuMpData->Buffer + Index * CpuMpData->CpuApStackSize;
   }
-- 
2.15.1.windows.2

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


Re: [edk2] Communicate with soft-smi-handler with uefi-application question.

2018-01-10 Thread krishnaLee
Hi,Star:
Yes,that's what I needed,now I understand the buffer has some restriction.
 
thank you very much!
by krishna





At 2018-01-10 17:26:28, "Zeng, Star"  wrote:
>The trusted smm communication buffer needs to be allocated as 
>EfiReservedMemoryType, EfiACPIMemoryNVS, or EfiRuntimeServicesData before 
>EndOfDxe.
>There is a generic smm communication buffer can be used if 
>MdeModulePkg\Universal\SmmCommunicationBufferDxe is included in dsc and fdf.
>
>You can refer 
>https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c#L90
> to know how it be used.
>
>
>Thanks,
>Star
>-Original Message-
>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
>krishnaLee
>Sent: Wednesday, January 10, 2018 3:44 PM
>To: edk2-devel@lists.01.org
>Subject: [edk2] Communicate with soft-smi-handler with uefi-application 
>question.
>
>Hi,
>I'm learning  to write and register some soft-Smi-Handler in smm-mode; then 
>using QEMU to boot my ovmf.fd,run into uefi shell; then write uefi-application 
>using EFI_SMM_COMMUNICATION_PROTOCOL to Communicate to my Smi-Handler,but 
>failed when run my uefi-application,the log show error.
>I don't know why,maybe I do not full understand uefi-smm,but how to 
>communicate to my smi handler?
>
>
>//error-message
>[Security] 3rd party image[0] can be loaded after EndOfDxe: 
>PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0x,0x0)/HD(1,MBR,0xBE1AFDFA,0x3F,0xFBFC1)/\mytestsmm.efi.
>InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 65FC4A8 Loading 
>driver at 0x62B EntryPoint=0x62B10F5 mytestsmm.efi
>InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 65FCB10 
>ProtectUefiImageCommon - 0x65FC4A8
>  - 0x062B - 0x7000
>InstallProtocolInterface: 752F3136-4E16-4FDC-A22A-E5F46812F4CA 7700CFC
>InstallProtocolInterface: 4C8A2451-C207-405B-9694-99EA13251341 62B40B0 Locate 
>EfiSmmCommunicationProtocol success
>SmmIsBufferOutsideSmmValid: Not in ValidCommunicationRegion: Buffer 
>(0x7700C94) - Length (0x2A), ASSERT [PiSmmCore] 
>d:\edk2-vudk2017\MdePkg\Library\SmmMemLib\SmmMemLib.c(178): ((BOOLEAN)(0==1)) 
>//error-message-end
>
>
>//my register-smi-handler code:
>//edk2-vUDK2017\MdeModulePkg\Universal\LockBox\SmmLockBox\SmmLockBox.c
>
>EFI_STATUS
>
>EFIAPI
>
>MyTestSmmHandler (
>
>IN EFI_HANDLE DispatchHandle,
>
>IN CONST VOID *Context OPTIONAL,
>
>IN OUT VOID *CommBuffer OPTIONAL,
>
>IN OUT UINTN *CommBufferSize OPTIONAL
>
>)
>
>{
>
>DEBUG ((DEBUG_INFO, "My Test Smm Handler Enter\n"));
>
>DEBUG ((DEBUG_INFO, "My Test Smm Handler exit\n"));
>
>return EFI_SUCCESS;
>
>}
>
>
>
>
>EFI_STATUS
>
>EFIAPI
>
>SmmLockBoxEntryPoint (
>
>IN EFI_HANDLE ImageHandle,
>
>IN EFI_SYSTEM_TABLE *SystemTable
>
>)
>
>{...
>
>//Register My Test Smm handler
>
>Status = gSmst->SmiHandlerRegister (
>
>MyTestSmmHandler,
>
>,
>
>
>
>);
>
>ASSERT_EFI_ERROR (Status);
>
>...
>
>}
>
>
>
>//the uefi-application code
>EFI_STATUS
>EFIAPI
>UefiMain (
>IN EFI_HANDLE ImageHandle,
>IN EFI_SYSTEM_TABLE *SystemTable
>)
>{
>EFI_STATUS Status;
>EFI_SMM_COMMUNICATION_PROTOCOL *mSmmCommunication; EFI_SMM_COMMUNICATE_HEADER 
>*SmmCommunicateHeader;
>UINT8 *buffer;
>UINTN bufferSize;
>
>
>bufferSize=sizeof(EFI_SMM_COMMUNICATE_HEADER)*2;
>gBS->AllocatePool (EfiRuntimeServicesData,bufferSize,);
>if(buffer==NULL)
>{
>Print(L"EFI_OUT_OF_RESOURCES, return\n"); return EFI_OUT_OF_RESOURCES; }
>
>
>SmmCommunicateHeader=(EFI_SMM_COMMUNICATE_HEADER*)buffer;
>CopyGuid(>HeaderGuid,);
>SmmCommunicateHeader->MessageLength=sizeof(EFI_SMM_COMMUNICATE_HEADER);
>
>
>Status = gBS->LocateProtocol (, NULL, (VOID 
>**) );
>if(Status==EFI_SUCCESS)
>{
>Print(L"Locate EfiSmmCommunicationProtocol success\n"); }else { Print(L"Locate 
>EfiSmmCommunicationProtocol failed return\n"); return EFI_SUCCESS; }
>
>
>Status=mSmmCommunication->Communicate(mSmmCommunication,,);
>if(Status==EFI_SUCCESS)
>{
>Print(L"Communication success\n");
>}else
>{
>Print(L"Communication failed\n");
>return EFI_SUCCESS;
>}
>
>
>gBS->FreePool(buffer);
>
>
>return EFI_SUCCESS;
>}
>
>
>any help will be appreciated!
>by krishna
>
>___
>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 4/7] UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool chain

2018-01-10 Thread Kinney, Michael D
Liming,

Here is a previous patch email series that demonstrates 
this technique.

https://lists.01.org/pipermail/edk2-devel/2017-September/015109.html

https://github.com/tianocore/edk2/commit/4c34a8ea191155f438901e635bd87810072b19a4#diff-5d3b0f5982124c722c30f6d0e6b8711d

Thanks,

Mike

> -Original Message-
> From: Kinney, Michael D
> Sent: Wednesday, January 10, 2018 11:22 AM
> To: Gao, Liming ; edk2-
> de...@lists.01.org; Kinney, Michael D
> 
> Cc: Andrew Fish ; Yao, Jiewen
> ; Dong, Eric ;
> Laszlo Ersek 
> Subject: RE: [Patch 4/7] UefiCpuPkg: Update
> CpuExceptionHandlerLib pass XCODE5 tool chain
> 
> Liming,
> 
> Can we use NASM syntax for instructions instead of db
> bytes?
> 
> If you put the label for the fixup after the instruction,
> you
> can patch by subtracting the size of the patch value from
> the
> label.
> 
> For example, instead of:
> 
> > +db  0x48, 0xB8
> > +JmpAbsoluteAddress:
> > +dq  0 ; mov rax,
> HookAfterStubHeaderEnd
> 
> Use:
> 
>   movqrax, 0
> JmpAbsoluteAddress:
> 
> And in the patch loop:
> 
> movqword [rcx + (JmpAbsoluteAddress - 8 -
> HookAfterStubHeaderBegin)], rax
> 
> 
> If this works, then please use this technique to remove
> use of db for instructions throughout this series.
> 
> Mike
> 
> > -Original Message-
> > From: Gao, Liming
> > Sent: Wednesday, January 10, 2018 7:24 AM
> > To: edk2-devel@lists.01.org
> > Cc: Andrew Fish ; Yao, Jiewen
> > ; Dong, Eric
> ;
> > Laszlo Ersek ; Kinney, Michael D
> > 
> > Subject: [Patch 4/7] UefiCpuPkg: Update
> > CpuExceptionHandlerLib pass XCODE5 tool chain
> >
> > Use the dummy address as jmp destination, and add the
> > logic to fix up
> > the address to the absolute address at boot time.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Liming Gao 
> > Cc: Andrew Fish 
> > Cc: Jiewen Yao 
> > Cc: Eric Dong 
> > Cc: Laszlo Ersek 
> > Cc: Michael Kinney 
> > ---
> >  .../X64/ExceptionHandlerAsm.nasm   |
> 29
> > --
> >  1 file changed, 22 insertions(+), 7 deletions(-)
> >
> > diff --git
> >
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Exception
> > HandlerAsm.nasm
> >
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Exception
> > HandlerAsm.nasm
> > index ba8993d84b..a5fde0a875 100644
> > ---
> >
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Exception
> > HandlerAsm.nasm
> > +++
> >
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Exception
> > HandlerAsm.nasm
> > @@ -1,5 +1,5 @@
> >  ;-
> --
> > --- ;
> > -; Copyright (c) 2012 - 2014, Intel Corporation. All
> > rights reserved.
> > +; Copyright (c) 2012 - 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
> > @@ -40,7 +40,8 @@ AsmIdtVectorBegin:
> >  db  0x6a; push  #VectorNum
> >  db  ($ - AsmIdtVectorBegin) /
> ((AsmIdtVectorEnd
> > - AsmIdtVectorBegin) / 32) ; VectorNum
> >  pushrax
> > -mov rax, ASM_PFX(CommonInterruptEntry)
> > +db  0x48, 0xB8
> > +dq  0 ; mov rax,
> > ASM_PFX(CommonInterruptEntry)
> >  jmp rax
> >  %endrep
> >  AsmIdtVectorEnd:
> > @@ -50,7 +51,9 @@ HookAfterStubHeaderBegin:
> >  @VectorNum:
> >  db  0  ; 0 will be fixed
> >  pushrax
> > -mov rax, HookAfterStubHeaderEnd
> > +db  0x48, 0xB8
> > +JmpAbsoluteAddress:
> > +dq  0 ; mov rax,
> HookAfterStubHeaderEnd
> >  jmp rax
> >  HookAfterStubHeaderEnd:
> >  mov rax, rsp
> > @@ -260,8 +263,7 @@ HasErrorCode:
> >  ; and make sure RSP is 16-byte aligned
> >  ;
> >  sub rsp, 4 * 8 + 8
> > -mov rax, ASM_PFX(CommonExceptionHandler)
> > -callrax
> > +callASM_PFX(CommonExceptionHandler)
> >  add rsp, 4 * 8 + 8
> >
> >  cli
> > @@ -369,11 +371,24 @@ DoIret:
> >  ; comments here for definition of address map
> >  global ASM_PFX(AsmGetTemplateAddressMap)
> >  ASM_PFX(AsmGetTemplateAddressMap):
> > -mov rax, AsmIdtVectorBegin
> > +lea rax, [AsmIdtVectorBegin]
> >  mov qword [rcx], rax
> >  mov qword [rcx + 0x8],  (AsmIdtVectorEnd -
> > AsmIdtVectorBegin) / 32
> > -mov rax, HookAfterStubHeaderBegin
> > +lea rax, [HookAfterStubHeaderBegin]
> >  mov qword [rcx + 0x10], rax
> 

Re: [edk2] [Patch 4/7] UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool chain

2018-01-10 Thread Kinney, Michael D
Liming,

Can we use NASM syntax for instructions instead of db bytes?

If you put the label for the fixup after the instruction, you
can patch by subtracting the size of the patch value from the
label.

For example, instead of:

> +db  0x48, 0xB8
> +JmpAbsoluteAddress:
> +dq  0 ; mov rax, HookAfterStubHeaderEnd

Use:

movqrax, 0
JmpAbsoluteAddress:

And in the patch loop:

movqword [rcx + (JmpAbsoluteAddress - 8 - HookAfterStubHeaderBegin)], 
rax


If this works, then please use this technique to remove
use of db for instructions throughout this series.

Mike

> -Original Message-
> From: Gao, Liming
> Sent: Wednesday, January 10, 2018 7:24 AM
> To: edk2-devel@lists.01.org
> Cc: Andrew Fish ; Yao, Jiewen
> ; Dong, Eric ;
> Laszlo Ersek ; Kinney, Michael D
> 
> Subject: [Patch 4/7] UefiCpuPkg: Update
> CpuExceptionHandlerLib pass XCODE5 tool chain
> 
> Use the dummy address as jmp destination, and add the
> logic to fix up
> the address to the absolute address at boot time.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Liming Gao 
> Cc: Andrew Fish 
> Cc: Jiewen Yao 
> Cc: Eric Dong 
> Cc: Laszlo Ersek 
> Cc: Michael Kinney 
> ---
>  .../X64/ExceptionHandlerAsm.nasm   | 29
> --
>  1 file changed, 22 insertions(+), 7 deletions(-)
> 
> diff --git
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Exception
> HandlerAsm.nasm
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Exception
> HandlerAsm.nasm
> index ba8993d84b..a5fde0a875 100644
> ---
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Exception
> HandlerAsm.nasm
> +++
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Exception
> HandlerAsm.nasm
> @@ -1,5 +1,5 @@
>  ;---
> --- ;
> -; Copyright (c) 2012 - 2014, Intel Corporation. All
> rights reserved.
> +; Copyright (c) 2012 - 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
> @@ -40,7 +40,8 @@ AsmIdtVectorBegin:
>  db  0x6a; push  #VectorNum
>  db  ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd
> - AsmIdtVectorBegin) / 32) ; VectorNum
>  pushrax
> -mov rax, ASM_PFX(CommonInterruptEntry)
> +db  0x48, 0xB8
> +dq  0 ; mov rax,
> ASM_PFX(CommonInterruptEntry)
>  jmp rax
>  %endrep
>  AsmIdtVectorEnd:
> @@ -50,7 +51,9 @@ HookAfterStubHeaderBegin:
>  @VectorNum:
>  db  0  ; 0 will be fixed
>  pushrax
> -mov rax, HookAfterStubHeaderEnd
> +db  0x48, 0xB8
> +JmpAbsoluteAddress:
> +dq  0 ; mov rax, HookAfterStubHeaderEnd
>  jmp rax
>  HookAfterStubHeaderEnd:
>  mov rax, rsp
> @@ -260,8 +263,7 @@ HasErrorCode:
>  ; and make sure RSP is 16-byte aligned
>  ;
>  sub rsp, 4 * 8 + 8
> -mov rax, ASM_PFX(CommonExceptionHandler)
> -callrax
> +callASM_PFX(CommonExceptionHandler)
>  add rsp, 4 * 8 + 8
> 
>  cli
> @@ -369,11 +371,24 @@ DoIret:
>  ; comments here for definition of address map
>  global ASM_PFX(AsmGetTemplateAddressMap)
>  ASM_PFX(AsmGetTemplateAddressMap):
> -mov rax, AsmIdtVectorBegin
> +lea rax, [AsmIdtVectorBegin]
>  mov qword [rcx], rax
>  mov qword [rcx + 0x8],  (AsmIdtVectorEnd -
> AsmIdtVectorBegin) / 32
> -mov rax, HookAfterStubHeaderBegin
> +lea rax, [HookAfterStubHeaderBegin]
>  mov qword [rcx + 0x10], rax
> +
> +; Fix up CommonInterruptEntry address
> +learax, [ASM_PFX(CommonInterruptEntry)]
> +learcx, [AsmIdtVectorBegin]
> +%rep  32
> +movqword [rcx + (JmpAbsoluteAddress -
> HookAfterStubHeaderBegin)], rax
> +addrcx, (AsmIdtVectorEnd - AsmIdtVectorBegin) /
> 32
> +%endrep
> +; Fix up HookAfterStubHeaderEnd
> +learax, [HookAfterStubHeaderEnd]
> +learcx, [JmpAbsoluteAddress]
> +movqword [rcx], rax
> +
>  ret
> 
>  ;---
> --
> --
> 2.11.0.windows.1

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


Re: [edk2] [Patch 7/7] OvmfPkg: Don't add -mno-mmx -mno-sse option for XCODE5 tool chain

2018-01-10 Thread Laszlo Ersek
On 01/10/18 16:24, Liming Gao wrote:
> Ovmf appended option -mno-mmx -mno-sse, but these two options were enabled
> in Openssl. The compiler option becomes -mmmx –msse -mno-mmx -mno-sse. It
> trig mac clang compiler hang when compile one source file in openssl.
> This issue is found when SECURE_BOOT_ENABLE is TRUE. This may be the compiler
> issue. To work around it, don't add these two options for XCODE5 tool chain.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Liming Gao 
> Cc: Andrew Fish 
> Cc: Laszlo Ersek 
> ---
>  OvmfPkg/OvmfPkgIa32.dsc| 4 +++-
>  OvmfPkg/OvmfPkgIa32X64.dsc | 4 +++-
>  OvmfPkg/OvmfPkgX64.dsc | 4 +++-
>  3 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 9d23f8c162..d762955c5d 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -1,7 +1,7 @@
>  ## @file
>  #  EFI/Framework Open Virtual Machine Firmware (OVMF) platform
>  #
> -#  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
>  #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
>  #
>  #  This program and the accompanying materials
> @@ -64,7 +64,9 @@
>GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
>INTEL:RELEASE_*_*_CC_FLAGS   = /D MDEPKG_NDEBUG
>MSFT:RELEASE_*_*_CC_FLAGS= /D MDEPKG_NDEBUG
> +!if $(TOOL_CHAIN_TAG) != "XCODE5"
>GCC:*_*_*_CC_FLAGS   = -mno-mmx -mno-sse
> +!endif
>  
>#
># Disable deprecated APIs.
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index a9c667fed8..6bcbe70d64 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -1,7 +1,7 @@
>  ## @file
>  #  EFI/Framework Open Virtual Machine Firmware (OVMF) platform
>  #
> -#  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
>  #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
>  #
>  #  This program and the accompanying materials
> @@ -64,7 +64,9 @@
>GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
>INTEL:RELEASE_*_*_CC_FLAGS   = /D MDEPKG_NDEBUG
>MSFT:RELEASE_*_*_CC_FLAGS= /D MDEPKG_NDEBUG
> +!if $(TOOL_CHAIN_TAG) != "XCODE5"
>GCC:*_*_*_CC_FLAGS   = -mno-mmx -mno-sse
> +!endif
>  !ifdef $(SOURCE_DEBUG_ENABLE)
>MSFT:*_*_X64_GENFW_FLAGS  = --keepexceptiontable
>GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index abf570512a..70fcdcba11 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -1,7 +1,7 @@
>  ## @file
>  #  EFI/Framework Open Virtual Machine Firmware (OVMF) platform
>  #
> -#  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
>  #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
>  #
>  #  This program and the accompanying materials
> @@ -64,7 +64,9 @@
>GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
>INTEL:RELEASE_*_*_CC_FLAGS   = /D MDEPKG_NDEBUG
>MSFT:RELEASE_*_*_CC_FLAGS= /D MDEPKG_NDEBUG
> +!if $(TOOL_CHAIN_TAG) != "XCODE5"
>GCC:*_*_*_CC_FLAGS   = -mno-mmx -mno-sse
> +!endif
>  !ifdef $(SOURCE_DEBUG_ENABLE)
>MSFT:*_*_X64_GENFW_FLAGS  = --keepexceptiontable
>GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
> 

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


Re: [edk2] [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement GetElapsedTime function of TimerLib

2018-01-10 Thread Laszlo Ersek
Hi Pankaj,

On 01/10/18 17:05, Pankaj Bansal wrote:
> Hi Laszlo,
> 
> Thanks for reviewing my changes and thanks for pointing me to the thread that 
> you worked on.
> It was really helpful. please see my response inline ..
> 
>> -Original Message-
>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>> Sent: Wednesday, January 10, 2018 7:46 PM
>> To: Pankaj Bansal ; edk2-devel@lists.01.org
>> Cc: Leif Lindholm ; Ard Biesheuvel
>> ; Michael Kinney 
>> Subject: Re: [edk2] [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement
>> GetElapsedTime function of TimerLib
>>
>> Hello Pankaj,
>>
>> On 01/10/18 10:31, Pankaj Bansal wrote:
>>> This function calculates the time elaped in Naoseconds between call to
>>> this function and BaseTime, which is passed as argument.
>>>
>>> This is particularly useful in detecting timeout conditions.
>>>
>>> Cc: Leif Lindholm 
>>> Cc: Ard Biesheuvel 
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Pankaj Bansal 
>>>
>>> diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
>>> b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
>>> index b81293c..0898339 100644
>>> --- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
>>> +++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
>>> @@ -290,3 +290,39 @@ GetTimeInNanoSecond (
>>>
>>>return NanoSeconds;
>>>  }
>>> +
>>> +/**
>>> +  Get Elapsed time in Nanoseonds w.r.t BaseTime
>>> +
>>> +  This function calculates the time elaped in Naoseconds between call
>>> + to this  function and BaseTime, which is passed as argument.
>>> +
>>> +  @param  BaseTime BaseTime in NanoSeconds.
>>> +
>>> +  @return The elapsed time in nanoseconds.
>>> +
>>> +**/
>>> +UINT64
>>> +EFIAPI
>>> +GetElapsedTime (
>>> +  IN  UINT64 BaseTime
>>> +  )
>>> +{
>>> +  UINT64  NanoSeconds;
>>> +  UINT64  Ticks;
>>> +
>>> +  //
>>> +  // Get current Ticks.
>>> +  //
>>> +  Ticks = GetPerformanceCounter();
>>> +
>>> +  //
>>> +  // Convert Ticks to Nanoseconds
>>> +  //
>>> +  NanoSeconds = GetTimeInNanoSecond (Ticks);
>>> +
>>> +  //
>>> +  // return the difference
>>> +  //
>>> +  return (NanoSeconds - BaseTime);
>>> +}
>>>
>>
>> There are two problems with this patch set:
>>
>> (1) The TimerLib.h file (in the first patch) is a public library class 
>> header, for
>> which several library instances (implementations) exist. So, introducing a
>> new API requires adding an implementation (the same implementation, or
>> different ones, as necessary) to *all* instances in the edk2 tree.
> 
> I agree with your intent to prevent code duplication. But I still feel that 
> we should enhance TimerLib.
> Because, a user intending to use various timer functionalities, should 
> include only one header file (TimerLib.h) and one Library.
> Like Mike pointed out in your thread to enhance the TimerTickDiffLib, in 
> future if someone wishes to add some new functionality related
> to timer and if he writes a new library for it, then its added cumbersome for 
> users (user has to include 3 header files and libraries 3.)
> 
> To prevent code duplication, can we look at other ways like using weak 
> symbols for such functions that are platform agnostic.
> Or putting these generic functions in one .c file in MdePkg and include that 
> file in inf file of TimerLib implementation?
> 
>>
>> (2) The calculation in your GetElapsedTime() function is wrong.
>> GetTimeInNanoSecond() converts a small *difference* of ticks to time. It
>> does not convert an absolute tick value to an absolute time.
> 
> The GetTimeInNanoSecond() is only concerned with the ticks. Those ticks can 
> be a difference of ticks or absolute ticks from counter start.
> The *difference* part of GetElapsedTime would depend on its usage. Like this :
> Start = GetElapsedTime (0);
> // do something 
> End = GetElapsedTime (Start);
> 
>>
>> Furthermore, tick differences are less trivial to calculate than one might
>> imagine, because (a) a performance counter may count down, and
>> *independently*, (b) the numeric low bound of the counter range may not
>> be zero.
>>
> 
> This is nice observation. It was an oversight on my part.
> 
>> Earlier I proposed a new TimerTickDiffLib class (and implementation) for
>> centralizing exactly this kind of calculation. Please see the thread at:
>>
>>   [edk2] TimerTickDiffLib for MdePkg?
>>
>> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmid.
>> mail-archive.com%2F8cba2a58-1333-7733-031d-
>> 0883dbd844c6%40redhat.com=02%7C01%7Cpankaj.bansal%40nxp.co
>> m%7C17efb96f35f0456be43108d55834c721%7C686ea1d3bc2b4c6fa92cd99c5
>> c301635%7C0%7C0%7C636511906063092098=AIqII9VcJEQXrJmM79G
>> DS%2BzBu3%2BCUva%2FZESawMRndzA%3D=0
>>
> 
> Your library has everything that I need. Can we work on to include this in 
> MdePkg ?
> Then I won't need 

[edk2] [PATCH v4 5/6] MdePkg/Include: Add VA list support for VS2017/ARM

2018-01-10 Thread Pete Batard
VA_START, VA_END and VA_COPY are the same as the generic macros.
VA_ARG was reverse engineered from MS ARM assembly output.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard 
---
 MdePkg/Include/Base.h | 13 +
 1 file changed, 13 insertions(+)

diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index 29db8a253e2f..7152ccda9764 100644
--- a/MdePkg/Include/Base.h
+++ b/MdePkg/Include/Base.h
@@ -660,6 +660,19 @@ struct _LIST_ENTRY {
 
 #define VA_COPY(Dest, Start)  __va_copy (Dest, Start)
 
+#elif defined(_M_ARM)
+//
+// MSFT ARM variable argument list support.
+// Same as the generic macros below, except for VA_ARG that needs extra 
adjustment.
+//
+
+typedef char* VA_LIST;
+
+#define VA_START(Marker, Parameter) (Marker = (VA_LIST) ((UINTN) & 
(Parameter) + _INT_SIZE_OF(Parameter)))
+#define VA_ARG(Marker, TYPE)(*(TYPE *) ((Marker += 
_INT_SIZE_OF(TYPE) + ((-(INTN)Marker) & (sizeof(TYPE) - 1))) - _INT_SIZE_OF 
(TYPE)))
+#define VA_END(Marker)  (Marker = (VA_LIST) 0)
+#define VA_COPY(Dest, Start)((void)((Dest) = (Start)))
+
 #elif defined(__GNUC__)
 
 #if defined(MDE_CPU_X64) && !defined(NO_MSABI_VA_FUNCS)
-- 
2.9.3.windows.2

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


[edk2] [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds

2018-01-10 Thread Pete Batard
Introduce CRT assembly replacements for __rt_sdiv, __rt_udiv,
__rt_udiv64, __rt_sdiv64, __rt_srsh (by reusing the RVCT code)
as well as memcpy and memset.
For MSFT compatibility, some of the code needs to be explicitly
forced to ARM, and the /oldit assembly flag needs to be added.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard 
---
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm   | 43 
+---
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm   | 40 
+-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm  | 22 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm | 29 
+++--
 ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | 16 +++-
 ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c   | 34 

 ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c   | 33 
+++
 7 files changed, 185 insertions(+), 32 deletions(-)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
index b539e516892d..f9e0107395f2 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
@@ -1,6 +1,7 @@
 
//--
 //
 // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+// Copyright (c) 2018, Pete Batard. All rights reserved.
 //
 // This program and the accompanying materials
 // are licensed and made available under the terms and conditions of the BSD 
License
@@ -17,18 +18,19 @@
 EXPORT  __aeabi_uidivmod
 EXPORT  __aeabi_idiv
 EXPORT  __aeabi_idivmod
+EXPORT  __rt_udiv
+EXPORT  __rt_sdiv
 
 AREA  Math, CODE, READONLY
 
 ;
 ;UINT32
 ;EFIAPI
-;__aeabi_uidivmode (
-;  IN UINT32  Dividen
+;__aeabi_uidivmod (
+;  IN UINT32  Dividend
 ;  IN UINT32  Divisor
 ;  );
 ;
-
 __aeabi_uidiv
 __aeabi_uidivmod
 RSBSr12, r1, r0, LSR #4
@@ -40,10 +42,40 @@ __aeabi_uidivmod
 B   __arm_div_large
 
 ;
+;UINT64
+;EFIAPI
+;__rt_udiv (
+;  IN UINT32  Divisor,
+;  IN UINT32  Dividend
+;  );
+;
+__rt_udiv
+; Swap R0 and R1
+MOV r12, r0
+MOV r0, r1
+MOV r1, r12
+B   __aeabi_uidivmod
+
+;
+;UINT64
+;EFIAPI
+;__rt_sdiv (
+;  IN INT32  Divisor,
+;  IN INT32  Dividend
+;  );
+;
+__rt_sdiv
+; Swap R0 and R1
+MOV r12, r0
+MOV r0, r1
+MOV r1, r12
+B   __aeabi_idivmod
+
+;
 ;INT32
 ;EFIAPI
-;__aeabi_idivmode (
-;  IN INT32  Dividen
+;__aeabi_idivmod (
+;  IN INT32  Dividend
 ;  IN INT32  Divisor
 ;  );
 ;
@@ -152,4 +184,3 @@ __aeabi_idiv0
 BX  r14
 
 END
-
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
index c71bd59e4520..3794cac35eed 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
@@ -1,6 +1,7 @@
 
//--
 //
 // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+// Copyright (c) 2018, Pete Batard. All rights reserved.
 //
 // This program and the accompanying materials
 // are licensed and made available under the terms and conditions of the BSD 
License
@@ -13,20 +14,41 @@
 
//--
 
 
-EXTERN  __aeabi_uldivmod
+IMPORT  __aeabi_uldivmod
+EXPORT  __aeabi_ldivmod
+EXPORT  __rt_sdiv64
 
-INCLUDE AsmMacroExport.inc
+AREA  Math, CODE, READONLY, ARM
+
+ARM
 
 ;
-;UINT32
+;INT64
 ;EFIAPI
-;__aeabi_uidivmode (
-;  IN UINT32  Dividen
-;  IN UINT32  Divisor
+;__rt_sdiv64 (
+;  IN  INT64  Divisor
+;  IN  INT64  Dividend
 ;  );
 ;
+__rt_sdiv64
+; Swap r0-r1 and r2-r3
+MOV r12, r0
+MOV r0, r2
+MOV r2, r12
+MOV r12, r1
+MOV r1, r3
+MOV r3, r12
+B   __aeabi_ldivmod
 
- RVCT_ASM_EXPORT __aeabi_ldivmod
+;
+;INT64
+;EFIAPI
+;__aeabi_ldivmod (
+;  IN  INT64  Dividend
+;  IN  INT64  Divisor
+;  );
+;
+__aeabi_ldivmod
 PUSH {r4,lr}
 ASRS r4,r1,#1
 EOR  r4,r4,r3,LSR #1
@@ -39,7 +61,7 @@ L_Test1
 RSBS r2,r2,#0
 RSC  r3,r3,#0
 L_Test2
-BL   __aeabi_uldivmod  ;
+BL   __aeabi_uldivmod
 TST  r4,#0x4000
 BEQ  L_Test3
 RSBS r0,r0,#0
@@ -53,5 +75,3 @@ L_Exit
 POP  {r4,pc}
 
 END
-
-
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
index 881db106d9d7..db2fd5057832 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
@@ -1,6 +1,7 @@
 
//--
 //
 // Copyright (c) 2008 - 2009, Apple Inc. 

[edk2] [PATCH v4 6/6] BaseTools/Conf: Add VS2017/ARM support

2018-01-10 Thread Pete Batard
We duplicate the Assembly-Code-File section from build_rule.template
because --convert-hex cannot be used with the MSFT ARM assembler.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard 
---
 BaseTools/Conf/build_rule.template | 31 +++-
 BaseTools/Conf/tools_def.template  | 31 
 2 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Conf/build_rule.template 
b/BaseTools/Conf/build_rule.template
index 3e6aa8ff0f34..6ea14fb7aa02 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -182,7 +182,6 @@
 
 
 
-
 [Assembly-Code-File.COMMON.COMMON]
 
 ?.asm, ?.Asm, ?.ASM
@@ -207,6 +206,36 @@
 # For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues
 "$(ASM)" $(ASM_FLAGS) -o ${dst} $(INC) ${d_path}(+)${s_base}.iii
 
+[Assembly-Code-File.COMMON.ARM]
+# Remove --convert-hex for ARM as it breaks MSFT assemblers
+
+?.asm, ?.Asm, ?.ASM
+
+
+?.S, ?.s
+
+
+$(MAKE_FILE)
+
+
+$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+
+
+"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
+Trim --source-code --convert-hex --trim-long -o 
${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
+"$(ASM)" /Fo${dst} $(ASM_FLAGS) /I${s_path} $(INC) 
${d_path}(+)${s_base}.iii
+
+
+"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
+Trim --source-code --trim-long -o ${d_path}(+)${s_base}.iii 
${d_path}(+)${s_base}.i
+"$(ASM)" /Fo${dst} $(ASM_FLAGS) /I${s_path} $(INC) 
${d_path}(+)${s_base}.iii
+
+
+"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
+Trim --trim-long --source-code -o ${d_path}(+)${s_base}.iii 
${d_path}(+)${s_base}.i
+# For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues
+"$(ASM)" $(ASM_FLAGS) -o ${dst} $(INC) ${d_path}(+)${s_base}.iii
+
 [Nasm-Assembly-Code-File.COMMON.COMMON]
 
 ?.nasm
diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 98ab6dd45e81..f76c4da05938 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -79,6 +79,7 @@ DEFINE VS2017_HOST= x86
 DEFINE VS2017_BIN_HOST= 
DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\DEF(VS2017_HOST)
 DEFINE VS2017_BIN_IA32= DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\x86
 DEFINE VS2017_BIN_X64 = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\x64
+DEFINE VS2017_BIN_ARM = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\arm
 
 DEFINE WINSDK_BIN   = ENV(WINSDK_PREFIX)
 DEFINE WINSDKx86_BIN= ENV(WINSDKx86_PREFIX)
@@ -335,6 +336,9 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
 # Required to build platforms or ACPI tables:
 #   Intel(r) ACPI Compiler (iasl.exe) from
 #   https://acpica.org/downloads
+#Note:
+# Building of XIP firmware images for ARM is not 
currently supported (only applications).
+# /FILEALIGN:4096 and other changes are needed for 
ARM firmware builds.
 #   DDK3790 -win32-  Requires:
 # Microsoft Windows Server 2003 Driver Development 
Kit (Microsoft WINDDK) version 3790.1830
 #Optional:
@@ -4169,6 +4173,33 @@ NOOPT_VS2017_X64_NASM_FLAGS = -O0 -f win64 -g
 RELEASE_VS2017_X64_DLINK_FLAGS  = /NOLOGO /NODEFAULTLIB /IGNORE:4001 
/IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D 
/SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) 
/SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER 
/MERGE:.rdata=.data
 NOOPT_VS2017_X64_DLINK_FLAGS= /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF 
/OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 
/LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER 
/SAFESEH:NO /BASE:0 /DRIVER /DEBUG
 
+#
+# ARM definitions
+#
+*_VS2017_ARM_CC_PATH  = DEF(VS2017_BIN_ARM)\cl.exe
+*_VS2017_ARM_VFRPP_PATH   = DEF(VS2017_BIN_ARM)\cl.exe
+*_VS2017_ARM_SLINK_PATH   = DEF(VS2017_BIN_ARM)\lib.exe
+*_VS2017_ARM_DLINK_PATH   = DEF(VS2017_BIN_ARM)\link.exe
+*_VS2017_ARM_APP_PATH = DEF(VS2017_BIN_ARM)\cl.exe
+*_VS2017_ARM_PP_PATH  = DEF(VS2017_BIN_ARM)\cl.exe
+*_VS2017_ARM_ASM_PATH = DEF(VS2017_BIN_ARM)\armasm.exe
+*_VS2017_ARM_ASLCC_PATH   = DEF(VS2017_BIN_ARM)\cl.exe
+*_VS2017_ARM_ASLPP_PATH   = DEF(VS2017_BIN_ARM)\cl.exe
+*_VS2017_ARM_ASLDLINK_PATH= DEF(VS2017_BIN_ARM)\link.exe
+
+  *_VS2017_ARM_MAKE_FLAGS = 

[edk2] [PATCH v4 2/6] MdePkg/Library/BaseStackCheckLib: Add Null handler for VS2017/ARM

2018-01-10 Thread Pete Batard
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard 
---
 MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf |  5 +++--
 MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c  | 18 ++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf 
b/MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
index d02d97107b08..e280651b1199 100644
--- a/MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
+++ b/MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
@@ -30,8 +30,9 @@ [Defines]
 #
 
 [Sources]
-  BaseStackCheckGcc.c | GCC
-  BaseStackCheckGcc.c | RVCT
+  BaseStackCheckGcc.c  | GCC
+  BaseStackCheckGcc.c  | RVCT
+  BaseStackCheckNull.c | MSFT
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c 
b/MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c
new file mode 100644
index ..ebb387fee5e1
--- /dev/null
+++ b/MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c
@@ -0,0 +1,18 @@
+/*++
+
+ 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.
+
+Abstract:
+
+  This file is purely empty as a work around for BaseStackCheck to pass MSVC 
build.
+
+**/
+
+extern int __BaseStackCheckNull;
-- 
2.9.3.windows.2

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


[edk2] [PATCH v4 1/6] MdePkg: Disable some Level 4 warnings for VS2017/ARM

2018-01-10 Thread Pete Batard
We disable the exact same warnings as IA32 and X64.

Also create a dummy macro for PRESERVE8, as this is not supported by
the Microsoft ARM assembler.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard 
---
 MdePkg/Include/Arm/ProcessorBind.h | 96 +++-
 1 file changed, 75 insertions(+), 21 deletions(-)

diff --git a/MdePkg/Include/Arm/ProcessorBind.h 
b/MdePkg/Include/Arm/ProcessorBind.h
index 42ea2f3055f3..afb2f05446f0 100644
--- a/MdePkg/Include/Arm/ProcessorBind.h
+++ b/MdePkg/Include/Arm/ProcessorBind.h
@@ -1,15 +1,15 @@
 /** @file
   Processor or Compiler specific defines and types for ARM.
 
-  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
   Portions copyright (c) 2008 - 2009, Apple Inc. 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   
 
+  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. 
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 
@@ -28,14 +28,63 @@
 #pragma pack()
 #endif
 
+#if defined(_MSC_EXTENSIONS)
+
 //
-// RVCT does not support the __builtin_unreachable() macro
+// Disable some level 4 compilation warnings (same as IA32 and X64)
 //
-#ifdef __ARMCC_VERSION
+
+//
+// Disabling bitfield type checking warnings.
+//
+#pragma warning ( disable : 4214 )
+
+//
+// Disabling the unreferenced formal parameter warnings.
+//
+#pragma warning ( disable : 4100 )
+
+//
+// Disable slightly different base types warning as CHAR8 * can not be set
+// to a constant string.
+//
+#pragma warning ( disable : 4057 )
+
+//
+// ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning
+//
+#pragma warning ( disable : 4127 )
+
+//
+// This warning is caused by functions defined but not used. For precompiled 
header only.
+//
+#pragma warning ( disable : 4505 )
+
+//
+// This warning is caused by empty (after preprocessing) source file. For 
precompiled header only.
+//
+#pragma warning ( disable : 4206 )
+
+//
+// Disable 'potentially uninitialized local variable X used' warnings
+//
+#pragma warning ( disable : 4701 )
+
+//
+// Disable 'potentially uninitialized local pointer variable X used' warnings
+//
+#pragma warning ( disable : 4703 )
+
+#endif
+
+//
+// RVCT and MSFT don't support the __builtin_unreachable() macro
+//
+#if defined(__ARMCC_VERSION) || defined(_MSC_EXTENSIONS)
 #define UNREACHABLE()
 #endif
 
-#if _MSC_EXTENSIONS 
+#if defined(_MSC_EXTENSIONS)
   //
   // use Microsoft* C compiler dependent integer width types
   //
@@ -52,7 +101,7 @@
   typedef signed char INT8;
 #else
   //
-  // Assume standard ARM alignment. 
+  // Assume standard ARM alignment.
   // Need to check portability of long long
   //
   typedef unsigned long long  UINT64;
@@ -121,7 +170,7 @@ typedef INT32   INTN;
 // use the correct C calling convention. All protocol member functions and
 // EFI intrinsics are required to modify their member functions with EFIAPI.
 //
-#define EFIAPI
+#define EFIAPI
 
 // When compiling with Clang, we still use GNU as for the assembler, so we 
still
 // need to define the GCC_ASM* macros.
@@ -142,34 +191,39 @@ typedef INT32   INTN;
 
 #define GCC_ASM_EXPORT(func__)  \
  .global  _CONCATENATE (__USER_LABEL_PREFIX__, func__);\
- .type ASM_PFX(func__), %function  
+ .type ASM_PFX(func__), %function
 
 #define GCC_ASM_IMPORT(func__)  \
  .extern  _CONCATENATE (__USER_LABEL_PREFIX__, func__)
- 
+
   #else
 //
-// .type not supported by Apple Xcode tools 
+// .type not supported by Apple Xcode tools
 //
-#define INTERWORK_FUNC(func__)  
+#define INTERWORK_FUNC(func__)
 
 #define GCC_ASM_EXPORT(func__)  \
  .globl  _CONCATENATE (__USER_LABEL_PREFIX__, func__)\
-  
-#define GCC_ASM_IMPORT(name)  
+
+#define GCC_ASM_IMPORT(name)
 
   #endif
+#elif defined(_MSC_EXTENSIONS)
+  //
+  // PRESERVE8 is not supported by the MSFT assembler.
+  //
+  #define PRESERVE8
 #endif
 
 /**
   Return the pointer to the first instruction of a function given a function 

[edk2] [PATCH v4 0/6] Add ARM support for VS2017

2018-01-10 Thread Pete Batard
(This v4 is the same as v3 from 2017-12-08, except to take into account Ard's
remarks and reuse the existing RVCT assembly for the MSFT compiler intrinsics)


The following series adds ARM compilation support for the VS2017 toolchain.
* PATCH 1 targets the disabling of VS Level 4 warnings. The disabled warnings
  for ARM are now aligned with IA32 and X64.
* PATCH 2 adds a NULL handler for the base stack check, since this is a GCC
  functionality.
* PATCH 3 updates MdePkg/Library/BaseLib so that the RVCT assembly sources
  are also used for MSFT.
* PATCH 4 adds the required compiler intrinsics replacements for division,
  shift, by reusing the RVCT code, as well as memset/memcpy.
* PATCH 5 adds variable argument handlers for print output. Note that this
  is done without relying on any external headers, with the VA_ARG macro
  having been reverse engineered from MSFT ARM assembly output.
* PATCH 6 enables the selection of ARM in the conf templates.

With these patches, VS2017 toolchain users should be able to compile
regular UEFI ARM applications using EDK2. Note that, unlike ARM64 support,
ARM support does not require a specific update of Visual Studio 2017, as
the ARM toolchain has been available from the very first release.

Additional notes:

We tested compiling and running the full UEFI Shell with this series, as
well as a small set of applications and drivers, and found no issues.
With an additional patch [1], it is also possible to use this proposal to
compile a complete QEMU ARM firmware. As the patch shows, the changes that
need to be applied to the EDK2 sources to achieve this are actually very
minimal.

However, the generated firmware does not currently boot, possibly because
of the following warnings being generated by the MS compiler:
- ArmCpuDxe.dll : warning LNK4072: section count 118 exceeds max (96); image 
may not run
- UiApp.dll : warning LNK4072: section count 113 exceeds max (96); image may 
not run

As far as I could see, the section count max is hardcoded so a workaround
would be needed to address those.

Also, because the VS2017 ARM compiler forces a section alignment of 4096
bytes (which in turn forces use to use /FILEALIGN:4096 as a linker option
for the firmware generation), the generated firmware exceeds 2MB and we
had to double its size to 4MB.

At this stage, since the goal of this series is to allow users to compile
regular ARM UEFI applications using the VS2017 toolchain, I have no plans
to spend more time on the QEMU firmware issues, especially as I suspect 
that reducing the firmware size back to 2 MB may not be achievable without
Microsoft altering their compiler. I am however hopeful that ARM
specialists can take this matter over eventually...

Regards,

/Pete

[1] 
https://github.com/pbatard/edk2/commit/c4ce41094a46f4f3dc7ccc64a90604813f037b13

Pete Batard (6):
  MdePkg: Disable some Level 4 warnings for VS2017/ARM
  MdePkg/Library/BaseStackCheckLib: Add Null handler for VS2017/ARM
  MdePkg/Library/BaseLib: Enable VS2017/ARM builds
  ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds
  MdePkg/Include: Add VA list support for VS2017/ARM
  BaseTools/Conf: Add VS2017/ARM support

 ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm   | 43 +++--
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm   | 40 ++--
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm  | 22 +++--
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm | 29 +-
 ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | 16 +++-
 ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c   | 34 +++
 ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c   | 33 +++
 BaseTools/Conf/build_rule.template | 31 ++-
 BaseTools/Conf/tools_def.template  | 31 +++
 MdePkg/Include/Arm/ProcessorBind.h | 96 
+++-
 MdePkg/Include/Base.h  | 13 +++
 MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm   |  5 +-
 MdePkg/Library/BaseLib/BaseLib.inf | 16 +++-
 MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf |  5 +-
 MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c  | 18 
 15 files changed, 372 insertions(+), 60 deletions(-)
 create mode 100644 ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
 create mode 100644 ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
 create mode 100644 MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c

-- 
2.9.3.windows.2

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


[edk2] [PATCH v4 3/6] MdePkg/Library/BaseLib: Enable VS2017/ARM builds

2018-01-10 Thread Pete Batard
Most of the RVCT assembly can be reused as is for MSFT except
for CpuBreakpoint.asm, which we need to force to Arm mode.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard 
---
 MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm |  5 -
 MdePkg/Library/BaseLib/BaseLib.inf   | 16 +---
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm 
b/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm
index 8a8065159bf2..e7490b09d3dc 100644
--- a/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm
+++ b/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm
@@ -16,7 +16,10 @@
 
 EXPORT CpuBreakpoint
 
-  AREA Cpu_Breakpoint, CODE, READONLY
+; Force ARM mode for this section, as MSFT assembler defaults to THUMB
+  AREA Cpu_Breakpoint, CODE, READONLY, ARM
+
+  ARM
 
 ;/**
 ;  Generates a breakpoint on the CPU.
diff --git a/MdePkg/Library/BaseLib/BaseLib.inf 
b/MdePkg/Library/BaseLib/BaseLib.inf
index fbfb0063b75f..3c07e6bad977 100644
--- a/MdePkg/Library/BaseLib/BaseLib.inf
+++ b/MdePkg/Library/BaseLib/BaseLib.inf
@@ -824,8 +824,9 @@ [Sources.EBC]
 [Sources.ARM]
   Arm/InternalSwitchStack.c
   Arm/Unaligned.c
-  Math64.c   | RVCT 
-
+  Math64.c   | RVCT
+  Math64.c   | MSFT
+
   Arm/SwitchStack.asm| RVCT
   Arm/SetJumpLongJump.asm| RVCT
   Arm/DisableInterrupts.asm  | RVCT
@@ -834,7 +835,16 @@ [Sources.ARM]
   Arm/CpuPause.asm   | RVCT
   Arm/CpuBreakpoint.asm  | RVCT
   Arm/MemoryFence.asm| RVCT
- 
+
+  Arm/SwitchStack.asm| MSFT
+  Arm/SetJumpLongJump.asm| MSFT
+  Arm/DisableInterrupts.asm  | MSFT
+  Arm/EnableInterrupts.asm   | MSFT
+  Arm/GetInterruptsState.asm | MSFT
+  Arm/CpuPause.asm   | MSFT
+  Arm/CpuBreakpoint.asm  | MSFT
+  Arm/MemoryFence.asm| MSFT
+
   Arm/Math64.S  | GCC
   Arm/SwitchStack.S | GCC
   Arm/EnableInterrupts.S| GCC
-- 
2.9.3.windows.2

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


Re: [edk2] [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement GetElapsedTime function of TimerLib

2018-01-10 Thread Pankaj Bansal
Hi Laszlo,

Thanks for reviewing my changes and thanks for pointing me to the thread that 
you worked on.
It was really helpful. please see my response inline ..

> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Wednesday, January 10, 2018 7:46 PM
> To: Pankaj Bansal ; edk2-devel@lists.01.org
> Cc: Leif Lindholm ; Ard Biesheuvel
> ; Michael Kinney 
> Subject: Re: [edk2] [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement
> GetElapsedTime function of TimerLib
> 
> Hello Pankaj,
> 
> On 01/10/18 10:31, Pankaj Bansal wrote:
> > This function calculates the time elaped in Naoseconds between call to
> > this function and BaseTime, which is passed as argument.
> >
> > This is particularly useful in detecting timeout conditions.
> >
> > Cc: Leif Lindholm 
> > Cc: Ard Biesheuvel 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Pankaj Bansal 
> >
> > diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
> > b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
> > index b81293c..0898339 100644
> > --- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
> > +++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
> > @@ -290,3 +290,39 @@ GetTimeInNanoSecond (
> >
> >return NanoSeconds;
> >  }
> > +
> > +/**
> > +  Get Elapsed time in Nanoseonds w.r.t BaseTime
> > +
> > +  This function calculates the time elaped in Naoseconds between call
> > + to this  function and BaseTime, which is passed as argument.
> > +
> > +  @param  BaseTime BaseTime in NanoSeconds.
> > +
> > +  @return The elapsed time in nanoseconds.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +GetElapsedTime (
> > +  IN  UINT64 BaseTime
> > +  )
> > +{
> > +  UINT64  NanoSeconds;
> > +  UINT64  Ticks;
> > +
> > +  //
> > +  // Get current Ticks.
> > +  //
> > +  Ticks = GetPerformanceCounter();
> > +
> > +  //
> > +  // Convert Ticks to Nanoseconds
> > +  //
> > +  NanoSeconds = GetTimeInNanoSecond (Ticks);
> > +
> > +  //
> > +  // return the difference
> > +  //
> > +  return (NanoSeconds - BaseTime);
> > +}
> >
> 
> There are two problems with this patch set:
> 
> (1) The TimerLib.h file (in the first patch) is a public library class 
> header, for
> which several library instances (implementations) exist. So, introducing a
> new API requires adding an implementation (the same implementation, or
> different ones, as necessary) to *all* instances in the edk2 tree.

I agree with your intent to prevent code duplication. But I still feel that we 
should enhance TimerLib.
Because, a user intending to use various timer functionalities, should include 
only one header file (TimerLib.h) and one Library.
Like Mike pointed out in your thread to enhance the TimerTickDiffLib, in future 
if someone wishes to add some new functionality related
to timer and if he writes a new library for it, then its added cumbersome for 
users (user has to include 3 header files and libraries 3.)

To prevent code duplication, can we look at other ways like using weak symbols 
for such functions that are platform agnostic.
Or putting these generic functions in one .c file in MdePkg and include that 
file in inf file of TimerLib implementation?

> 
> (2) The calculation in your GetElapsedTime() function is wrong.
> GetTimeInNanoSecond() converts a small *difference* of ticks to time. It
> does not convert an absolute tick value to an absolute time.

The GetTimeInNanoSecond() is only concerned with the ticks. Those ticks can be 
a difference of ticks or absolute ticks from counter start.
The *difference* part of GetElapsedTime would depend on its usage. Like this :
Start = GetElapsedTime (0);
// do something 
End = GetElapsedTime (Start);

> 
> Furthermore, tick differences are less trivial to calculate than one might
> imagine, because (a) a performance counter may count down, and
> *independently*, (b) the numeric low bound of the counter range may not
> be zero.
> 

This is nice observation. It was an oversight on my part.

> Earlier I proposed a new TimerTickDiffLib class (and implementation) for
> centralizing exactly this kind of calculation. Please see the thread at:
> 
>   [edk2] TimerTickDiffLib for MdePkg?
> 
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmid.
> mail-archive.com%2F8cba2a58-1333-7733-031d-
> 0883dbd844c6%40redhat.com=02%7C01%7Cpankaj.bansal%40nxp.co
> m%7C17efb96f35f0456be43108d55834c721%7C686ea1d3bc2b4c6fa92cd99c5
> c301635%7C0%7C0%7C636511906063092098=AIqII9VcJEQXrJmM79G
> DS%2BzBu3%2BCUva%2FZESawMRndzA%3D=0
> 

Your library has everything that I need. Can we work on to include this in 
MdePkg ?
Then I won't need my changes.

> Thanks
> Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org

[edk2] [Patch 7/7] OvmfPkg: Don't add -mno-mmx -mno-sse option for XCODE5 tool chain

2018-01-10 Thread Liming Gao
Ovmf appended option -mno-mmx -mno-sse, but these two options were enabled
in Openssl. The compiler option becomes -mmmx –msse -mno-mmx -mno-sse. It
trig mac clang compiler hang when compile one source file in openssl.
This issue is found when SECURE_BOOT_ENABLE is TRUE. This may be the compiler
issue. To work around it, don't add these two options for XCODE5 tool chain.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Andrew Fish 
Cc: Laszlo Ersek 
---
 OvmfPkg/OvmfPkgIa32.dsc| 4 +++-
 OvmfPkg/OvmfPkgIa32X64.dsc | 4 +++-
 OvmfPkg/OvmfPkgX64.dsc | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 9d23f8c162..d762955c5d 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  EFI/Framework Open Virtual Machine Firmware (OVMF) platform
 #
-#  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #
 #  This program and the accompanying materials
@@ -64,7 +64,9 @@
   GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
   INTEL:RELEASE_*_*_CC_FLAGS   = /D MDEPKG_NDEBUG
   MSFT:RELEASE_*_*_CC_FLAGS= /D MDEPKG_NDEBUG
+!if $(TOOL_CHAIN_TAG) != "XCODE5"
   GCC:*_*_*_CC_FLAGS   = -mno-mmx -mno-sse
+!endif
 
   #
   # Disable deprecated APIs.
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index a9c667fed8..6bcbe70d64 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  EFI/Framework Open Virtual Machine Firmware (OVMF) platform
 #
-#  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #
 #  This program and the accompanying materials
@@ -64,7 +64,9 @@
   GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
   INTEL:RELEASE_*_*_CC_FLAGS   = /D MDEPKG_NDEBUG
   MSFT:RELEASE_*_*_CC_FLAGS= /D MDEPKG_NDEBUG
+!if $(TOOL_CHAIN_TAG) != "XCODE5"
   GCC:*_*_*_CC_FLAGS   = -mno-mmx -mno-sse
+!endif
 !ifdef $(SOURCE_DEBUG_ENABLE)
   MSFT:*_*_X64_GENFW_FLAGS  = --keepexceptiontable
   GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index abf570512a..70fcdcba11 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  EFI/Framework Open Virtual Machine Firmware (OVMF) platform
 #
-#  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #
 #  This program and the accompanying materials
@@ -64,7 +64,9 @@
   GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
   INTEL:RELEASE_*_*_CC_FLAGS   = /D MDEPKG_NDEBUG
   MSFT:RELEASE_*_*_CC_FLAGS= /D MDEPKG_NDEBUG
+!if $(TOOL_CHAIN_TAG) != "XCODE5"
   GCC:*_*_*_CC_FLAGS   = -mno-mmx -mno-sse
+!endif
 !ifdef $(SOURCE_DEBUG_ENABLE)
   MSFT:*_*_X64_GENFW_FLAGS  = --keepexceptiontable
   GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
-- 
2.11.0.windows.1

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


[edk2] [Patch 6/7] UefiCpuPkg: Update PiSmmCpuDxeSmm pass XCODE5 tool chain

2018-01-10 Thread Liming Gao
1. Use lea instruction to get the address instead of mov instruction.
2. Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.
3. On MpFuncs.nasm, use ExchangeInfo to record InitializeFloatingPointUnits.
This way is same to MpInitLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Andrew Fish 
Cc: Jiewen Yao 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Michael Kinney 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c   |  6 -
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm|  5 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm |  6 -
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c  |  8 ++-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h  | 20 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm  |  9 ---
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm | 32 +
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm |  4 ++--
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm  | 17 ++---
 9 files changed, 82 insertions(+), 25 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 94e5ab2c0e..554629536a 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -1,7 +1,7 @@
 /** @file
 Code for Processor S3 restoration
 
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 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
@@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 #include "PiSmmCpuDxeSmm.h"
 
+#pragma pack(1)
 typedef struct {
   UINTN Lock;
   VOID  *StackStart;
@@ -23,7 +24,9 @@ typedef struct {
   IA32_DESCRIPTOR   IdtrProfile;
   UINT32BufferStart;
   UINT32Cr3;
+  UINTN InitializeFloatingPointUnitsAddress;
 } MP_CPU_EXCHANGE_INFO;
+#pragma pack()
 
 typedef struct {
   UINT8 *RendezvousFunnelAddress;
@@ -456,6 +459,7 @@ PrepareApStartupVector (
   mExchangeInfo->StackSize   = mAcpiCpuData.StackSize;
   mExchangeInfo->BufferStart = (UINT32) StartupVector;
   mExchangeInfo->Cr3 = (UINT32) (AsmReadCr3 ());
+  mExchangeInfo->InitializeFloatingPointUnitsAddress = 
(UINTN)InitializeFloatingPointUnits;
 }
 
 /**
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm
index 4d2383ff97..a8324a7f4a 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm
@@ -1,5 +1,5 @@
 
;-- 
;
-; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 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
@@ -207,3 +207,6 @@ ASM_PFX(SmiHandler):
 
 ASM_PFX(gcSmiHandlerSize): DW $ - _SmiEntryPoint
 
+global ASM_PFX(PiSmmCpuSmiEntryFixupAddress)
+ASM_PFX(PiSmmCpuSmiEntryFixupAddress):
+ret
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm
index d9df3626c7..a5c62e77ce 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm
@@ -1,5 +1,5 @@
 
;-- 
;
-; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 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
@@ -85,3 +85,7 @@ ASM_PFX(SmmRelocationSemaphoreComplete):
 mov byte [eax], 1
 pop eax
 jmp [ASM_PFX(mSmmRelocationOriginalAddress)]
+
+global ASM_PFX(PiSmmCpuSmmInitFixupAddress)
+ASM_PFX(PiSmmCpuSmmInitFixupAddress):
+ret
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
index 4b66a0dfd9..a27d1f4684 100755
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
@@ -1,7 +1,7 @@
 /** @file
 Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU.
 
-Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
 

[edk2] [Patch 0/7] EDK2: Enable XCODE5 tool chain with NASM source

2018-01-10 Thread Liming Gao
1. Use nasm source file for X86 tool chain, then ASM and S file can be removed.
2. Update Nasm source file to resolve the absolute addressing.
3. Verify OVMF IA32, IA32X64 and X64 boot to shell functionality with XCODE5
   Here is build command.
   build -p OvmfPkg\OvmfPkgIa32X64.dsc -a IA32 -a X64 -DSMM_REQUIRE=TRUE 
   -DSECURE_BOOT_ENABLE=TRUE -DUSE_OLD_SHELL
   build -p OvmfPkg\OvmfPkgIa32.dsc -a IA32 -a X64 -DSMM_REQUIRE=TRUE 
   -DSECURE_BOOT_ENABLE=TRUE -DUSE_OLD_SHELL
   build -p OvmfPkg\OvmfPkgX64.dsc -a IA32 -a X64 -DSMM_REQUIRE=TRUE 
   -DSECURE_BOOT_ENABLE=TRUE -DUSE_OLD_SHELL
4. Known limitation is XCODE5 doesn't support HII resource section generation. 
   So, new UEFI shell application tftp can't be used. Old shell is used.

Liming Gao (7):
  BaseTools: Disable -Wno-unused-const-variable in XCODE5 RELEASE target
  BaseTools: Use nasm as the preferred assembly source files for XCODE5
tool
  MdeModulePkg: Update DebugSupportDxe to pass XCODE5 build
  UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool chain
  UefiCpuPkg: Update SmmCpuFeatureLib pass XCODE5 tool chain
  UefiCpuPkg: Update PiSmmCpuDxeSmm pass XCODE5 tool chain
  OvmfPkg: Don't add -mno-mmx -mno-sse option for XCODE5 tool chain

 BaseTools/Conf/tools_def.template  |  7 ++--
 .../Universal/DebugSupportDxe/X64/AsmFuncs.nasm|  6 ++--
 OvmfPkg/OvmfPkgIa32.dsc|  4 ++-
 OvmfPkg/OvmfPkgIa32X64.dsc |  4 ++-
 OvmfPkg/OvmfPkgX64.dsc |  4 ++-
 .../X64/ExceptionHandlerAsm.nasm   | 29 +++
 .../Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm   |  6 +++-
 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c  |  8 +++--
 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h  | 11 +-
 .../Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm| 42 +++---
 .../SmmCpuFeaturesLib/X64/SmiException.nasm| 10 +++---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c  |  6 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm   |  5 ++-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm|  6 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c |  8 -
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 20 ++-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm |  9 +++--
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm| 32 +++--
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm|  4 +--
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm | 17 +++--
 20 files changed, 174 insertions(+), 64 deletions(-)

-- 
2.11.0.windows.1

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


[edk2] [Patch 4/7] UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool chain

2018-01-10 Thread Liming Gao
Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Andrew Fish 
Cc: Jiewen Yao 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Michael Kinney 
---
 .../X64/ExceptionHandlerAsm.nasm   | 29 --
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
index ba8993d84b..a5fde0a875 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
@@ -1,5 +1,5 @@
 
;-- 
;
-; Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
+; Copyright (c) 2012 - 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
@@ -40,7 +40,8 @@ AsmIdtVectorBegin:
 db  0x6a; push  #VectorNum
 db  ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 
32) ; VectorNum
 pushrax
-mov rax, ASM_PFX(CommonInterruptEntry)
+db  0x48, 0xB8
+dq  0 ; mov rax, ASM_PFX(CommonInterruptEntry)
 jmp rax
 %endrep
 AsmIdtVectorEnd:
@@ -50,7 +51,9 @@ HookAfterStubHeaderBegin:
 @VectorNum:
 db  0  ; 0 will be fixed
 pushrax
-mov rax, HookAfterStubHeaderEnd
+db  0x48, 0xB8
+JmpAbsoluteAddress:
+dq  0 ; mov rax, HookAfterStubHeaderEnd
 jmp rax
 HookAfterStubHeaderEnd:
 mov rax, rsp
@@ -260,8 +263,7 @@ HasErrorCode:
 ; and make sure RSP is 16-byte aligned
 ;
 sub rsp, 4 * 8 + 8
-mov rax, ASM_PFX(CommonExceptionHandler)
-callrax
+callASM_PFX(CommonExceptionHandler)
 add rsp, 4 * 8 + 8
 
 cli
@@ -369,11 +371,24 @@ DoIret:
 ; comments here for definition of address map
 global ASM_PFX(AsmGetTemplateAddressMap)
 ASM_PFX(AsmGetTemplateAddressMap):
-mov rax, AsmIdtVectorBegin
+lea rax, [AsmIdtVectorBegin]
 mov qword [rcx], rax
 mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
-mov rax, HookAfterStubHeaderBegin
+lea rax, [HookAfterStubHeaderBegin]
 mov qword [rcx + 0x10], rax
+
+; Fix up CommonInterruptEntry address
+learax, [ASM_PFX(CommonInterruptEntry)]
+learcx, [AsmIdtVectorBegin]
+%rep  32
+movqword [rcx + (JmpAbsoluteAddress - HookAfterStubHeaderBegin)], rax
+addrcx, (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
+%endrep
+; Fix up HookAfterStubHeaderEnd
+learax, [HookAfterStubHeaderEnd]
+learcx, [JmpAbsoluteAddress]
+movqword [rcx], rax
+
 ret
 
 
;-
-- 
2.11.0.windows.1

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


[edk2] [Patch 5/7] UefiCpuPkg: Update SmmCpuFeatureLib pass XCODE5 tool chain

2018-01-10 Thread Liming Gao
1. Use lea instruction to get the address instead of mov instruction.
2. Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Andrew Fish 
Cc: Jiewen Yao 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Michael Kinney 
---
 .../Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm   |  6 +++-
 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c  |  8 +++--
 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h  | 11 +-
 .../Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm| 42 +++---
 .../SmmCpuFeaturesLib/X64/SmiException.nasm| 10 +++---
 5 files changed, 55 insertions(+), 22 deletions(-)

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm
index 00c0f0672c..057ec6d105 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm
@@ -1,5 +1,5 @@
 
;-- 
;
-; Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 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
@@ -273,3 +273,7 @@ _StmSmiHandler:
 
 ASM_PFX(gcStmSmiHandlerSize)   : DW$ - _StmSmiEntryPoint
 ASM_PFX(gcStmSmiHandlerOffset) : DW_StmSmiHandler - _StmSmiEntryPoint
+
+global ASM_PFX(SmmCpuFeaturesLibStmSmiEntryFixupAddress)
+ASM_PFX(SmmCpuFeaturesLibStmSmiEntryFixupAddress):
+ret
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
index 45015b8da4..8dc2d70527 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
@@ -1,7 +1,7 @@
 /** @file
   SMM STM support functions
 
-  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 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
@@ -116,7 +116,6 @@ UINTN  mMsegSize = 0;
 
 BOOLEAN  mStmConfigurationTableInitialized = FALSE;
 
-
 /**
   The constructor function
 
@@ -139,6 +138,11 @@ SmmCpuFeaturesLibStmConstructor (
   EFI_SMRAM_DESCRIPTOR*SmramDescriptor;
 
   //
+  // Initialize address fixup
+  //
+  SmmCpuFeaturesLibStmSmiEntryFixupAddress ();
+
+  //
   // Call the common constructor function
   //
   Status = SmmCpuFeaturesLibConstructor (ImageHandle, SystemTable);
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h
index 92a4dc00eb..c98b660ecb 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h
@@ -1,7 +1,7 @@
 /** @file
   SMM STM support
 
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 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
@@ -173,4 +173,13 @@ GetStmResource (
   VOID
   );
 
+/**
+  This function fixes up the address of the global variable or function
+  referred in SmiEntry assembly files to be the absoute address.
+**/
+VOID
+EFIAPI
+SmmCpuFeaturesLibStmSmiEntryFixupAddress (
+ );
+
 #endif
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm
index ea2d2970bd..e9c1306265 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm
@@ -1,5 +1,5 @@
 
;-- 
;
-; Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 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
@@ -164,7 +164,9 @@ Base:
 mov cr0, rbx
 retf
 @LongMode:  ; long mode (64-bit code) starts here
-mov rax, ASM_PFX(gStmSmiHandlerIdtr)
+db  0x48, 0xB8
+StmSmiEntrySmiHandlerIdtrAbsAddr:
+dq  0  

[edk2] [Patch 2/7] BaseTools: Use nasm as the preferred assembly source files for XCODE5 tool

2018-01-10 Thread Liming Gao
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Andrew Fish 
Cc: Yonghong Zhu 
---
 BaseTools/Conf/tools_def.template | 1 -
 1 file changed, 1 deletion(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index a961048288..d8fde02ea3 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -7500,7 +7500,6 @@ NOOPT_MYTOOLS_IPF_DLINK_FLAGS= /NOLOGO 
/NODEFAULTLIB /LTCG /DLL /OPT
 
 *_XCODE5_*_*_FAMILY= GCC
 *_XCODE5_*_*_BUILDRULEFAMILY   = XCODE
-*_XCODE5_*_*_BUILDRULEORDER= S s nasm
 
 #
 # use xcode-select to change Xcode version of command line tools
-- 
2.11.0.windows.1

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


[edk2] [Patch 3/7] MdeModulePkg: Update DebugSupportDxe to pass XCODE5 build

2018-01-10 Thread Liming Gao
XCODE5 doesn't support absolute addressing in the assembly code.
This change uses lea instruction to get the address.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Andrew Fish 
Cc: Star Zeng 
---
 MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.nasm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.nasm 
b/MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.nasm
index 134842a68a..31d8b0a717 100644
--- a/MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.nasm
+++ b/MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.nasm
@@ -1,7 +1,7 @@
 ;/** @file
 ;  Low level x64 routines used by the debug support driver.
 ;
-;  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+;  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
@@ -226,7 +226,7 @@ ASM_PFX(CommonIdtEntry):
 pop rax
 add rsp, 8   ; pop vector number
 mov [AppRsp], rsp; save stack top
-mov rsp, DebugStackBegin ; switch to debugger 
stack
+lea rsp, [DebugStackBegin]   ; switch to debugger 
stack
 sub rsp, 8   ; leave space for 
vector number
 
 ;; UINT64  Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax;
@@ -529,7 +529,7 @@ Chain:
 pushrbx
 mov rax, cs
 pushrax
-mov rax, PhonyIretq
+lea rax, [PhonyIretq]
 pushrax
 iretq
 PhonyIretq:
-- 
2.11.0.windows.1

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


[edk2] [Patch 1/7] BaseTools: Disable -Wno-unused-const-variable in XCODE5 RELEASE target

2018-01-10 Thread Liming Gao
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Yonghong Zhu 
Cc: Andrew Fish 
---
 BaseTools/Conf/tools_def.template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 12278302b3..a961048288 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
 #  Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
 #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
@@ -7551,7 +7551,7 @@ RELEASE_XCODE5_IA32_ASM_FLAGS  = -arch i386
 
 
   DEBUG_XCODE5_IA32_CC_FLAGS   = -arch i386 -c -g -Os   -Wall -Werror 
-include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin 
-fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields 
-msoft-float -Wno-unused-parameter -Wno-missing-braces 
-Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare 
-Wno-varargs 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang 
$(PLATFORM_FLAGS)
-RELEASE_XCODE5_IA32_CC_FLAGS   = -arch i386 -c-Os   -Wall -Werror 
-include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin 
-fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields 
-msoft-float -Wno-unused-parameter -Wno-missing-braces 
-Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare 
-Wno-varargs 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang 
$(PLATFORM_FLAGS)
+RELEASE_XCODE5_IA32_CC_FLAGS   = -arch i386 -c-Os   -Wall -Werror 
-include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin 
-fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields 
-msoft-float -Wno-unused-parameter -Wno-missing-braces 
-Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare 
-Wno-varargs -Wno-unused-const-variable 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang 
$(PLATFORM_FLAGS)
   NOOPT_XCODE5_IA32_CC_FLAGS   = -arch i386 -c -g -O0   -Wall -Werror 
-include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin 
-fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields 
-msoft-float -Wno-unused-parameter -Wno-missing-braces 
-Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare 
-Wno-varargs 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang 
$(PLATFORM_FLAGS)
 
 ##
@@ -7571,7 +7571,7 @@ RELEASE_XCODE5_X64_ASM_FLAGS  = -arch x86_64
 
   DEBUG_XCODE5_X64_CC_FLAGS   = -target x86_64-pc-win32-macho -c -g -Os   
-Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions 
-fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float 
-mms-bitfields -Wno-unused-parameter -Wno-missing-braces 
-Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare 
-Wno-varargs 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D 
NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
   NOOPT_XCODE5_X64_CC_FLAGS   = -target x86_64-pc-win32-macho -c -g -O0   
-Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions 
-fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float 
-mms-bitfields -Wno-unused-parameter -Wno-missing-braces 
-Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare 
-Wno-varargs 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D 
NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
-RELEASE_XCODE5_X64_CC_FLAGS   = -target x86_64-pc-win32-macho -c-Os   
-Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions 
-fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float 
-mms-bitfields -Wno-unused-parameter -Wno-missing-braces 
-Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare 
-Wno-varargs 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D 
NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
+RELEASE_XCODE5_X64_CC_FLAGS   = -target x86_64-pc-win32-macho -c-Os   
-Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions 
-fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float 
-mms-bitfields -Wno-unused-parameter -Wno-missing-braces 
-Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare 
-Wno-varargs -Wno-unused-const-variable 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D 
NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
 
 

 #
-- 
2.11.0.windows.1

___

Re: [edk2] [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement GetElapsedTime function of TimerLib

2018-01-10 Thread Laszlo Ersek
Hello Pankaj,

On 01/10/18 10:31, Pankaj Bansal wrote:
> This function calculates the time elaped in Naoseconds between call to
> this function and BaseTime, which is passed as argument.
>
> This is particularly useful in detecting timeout conditions.
>
> Cc: Leif Lindholm 
> Cc: Ard Biesheuvel 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Pankaj Bansal 
>
> diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c 
> b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
> index b81293c..0898339 100644
> --- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
> +++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
> @@ -290,3 +290,39 @@ GetTimeInNanoSecond (
>
>return NanoSeconds;
>  }
> +
> +/**
> +  Get Elapsed time in Nanoseonds w.r.t BaseTime
> +
> +  This function calculates the time elaped in Naoseconds between call to this
> +  function and BaseTime, which is passed as argument.
> +
> +  @param  BaseTime BaseTime in NanoSeconds.
> +
> +  @return The elapsed time in nanoseconds.
> +
> +**/
> +UINT64
> +EFIAPI
> +GetElapsedTime (
> +  IN  UINT64 BaseTime
> +  )
> +{
> +  UINT64  NanoSeconds;
> +  UINT64  Ticks;
> +
> +  //
> +  // Get current Ticks.
> +  //
> +  Ticks = GetPerformanceCounter();
> +
> +  //
> +  // Convert Ticks to Nanoseconds
> +  //
> +  NanoSeconds = GetTimeInNanoSecond (Ticks);
> +
> +  //
> +  // return the difference
> +  //
> +  return (NanoSeconds - BaseTime);
> +}
>

There are two problems with this patch set:

(1) The TimerLib.h file (in the first patch) is a public library class
header, for which several library instances (implementations) exist. So,
introducing a new API requires adding an implementation (the same
implementation, or different ones, as necessary) to *all* instances in
the edk2 tree.

(2) The calculation in your GetElapsedTime() function is wrong.
GetTimeInNanoSecond() converts a small *difference* of ticks to time. It
does not convert an absolute tick value to an absolute time.

Furthermore, tick differences are less trivial to calculate than one
might imagine, because (a) a performance counter may count down, and
*independently*, (b) the numeric low bound of the counter range may not
be zero.

Earlier I proposed a new TimerTickDiffLib class (and implementation) for
centralizing exactly this kind of calculation. Please see the thread at:

  [edk2] TimerTickDiffLib for MdePkg?
  http://mid.mail-archive.com/8cba2a58-1333-7733-031d-0883dbd844c6@redhat.com

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


Re: [edk2] [PATCH 0/2] Quality improvement of MtrrLib

2018-01-10 Thread Dong, Eric
Reviewed-by: Eric Dong 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Wednesday, January 10, 2018 1:40 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH 0/2] Quality improvement of MtrrLib

The patch set fixes two bugs in MtrrLib.
With the two fixes, randomly generated 1000 memory settings can be set 
correctly.

Ruiyu Ni (2):
  UefiCpuPkg/MtrrLib: Fix a MTRR calculation bug
  UefiCpuPkg/MtrrLib: Fix an assertion bug

 UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

--
2.15.1.windows.2

___
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 edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library

2018-01-10 Thread Ard Biesheuvel
On 10 January 2018 at 11:45, Alexei Fedorov  wrote:
> Hi Ard,
>
>
> You wrote
>
> "Well, the fact that you need to override the BaseMemoryLib
> implementation is telling. This means the region is treated as memory
> in the code, but mapped with device semantics. So this is not about
> performance, but about the face that the UEFI spec stipulates that
> unaligned access to memory are allowed on AArch64, and so if the
> contents of these regions are dereferenced as memory, they should be
> mapped as memory. If they are mapped as device, you should only use
> MmioRead32/MmioWrite32 accessors."
>
>
> In that case could you comment on the following commits:
>
> "The BaseMemoryLib has switch to use BaseMemoryLibOptDxe at OPP, but the
> flash module is device attributes and have to be alignment accessed. so we
> change the flash related drivers to use generic BaseMemoryLib which is
> alignment access. "
>
>
> Hisilicon/D02: flash related drivers switch to use generic BaseMemoryLib:
> https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D02/Pv660D02.dsc?id=e3c520596d9ebdc525f284a9da95f080af815ec9
>
>
> Hisilicon/D03: flash related drivers switch to use generic BaseMemoryLib:
> https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D03/D03.dsc?id=337713801cceb684326bfde22975310ca1bd0cc0
>
>
> Hisilicon/D05: flash related drivers switch to use generic BaseMemoryLib:
> https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D05/D05.dsc?id=0749464022407f11c0c6a46cb8eb293fc74ef236
>

NOR flash can only be mapped as device memory, because it switches
between array mode and command mode, and in the latter mode, we
require device semantics.

Ideally, we should be able to switch between cacheable and device
mappings in this case (because we also switch between modes), but this
is not possible when running under the OS, and VariableRuntimeDxe is a
DXE_RUNTIME_DRIVER type module.

In general, memory should not be mapped with device semantics and vice
versa. NOR flash is arguably a corner case, especially because the
generic variable driver is shared with x86 which doesn't care about
any of this, and so the code is quite sloppy when it comes to
dereferencing pointers that may point outside of memory.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library

2018-01-10 Thread Alexei Fedorov
Hi Ard,


You wrote

"Well, the fact that you need to override the BaseMemoryLib
implementation is telling. This means the region is treated as memory
in the code, but mapped with device semantics. So this is not about
performance, but about the face that the UEFI spec stipulates that
unaligned access to memory are allowed on AArch64, and so if the
contents of these regions are dereferenced as memory, they should be
mapped as memory. If they are mapped as device, you should only use
MmioRead32/MmioWrite32 accessors."


In that case could you comment on the following commits:

"The BaseMemoryLib has switch to use BaseMemoryLibOptDxe at OPP, but the flash 
module is device attributes and have to be alignment accessed. so we change the 
flash related drivers to use generic BaseMemoryLib which is alignment access. "


Hisilicon/D02: flash related drivers switch to use generic BaseMemoryLib:
https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D02/Pv660D02.dsc?id=e3c520596d9ebdc525f284a9da95f080af815ec9


Hisilicon/D03: flash related drivers switch to use generic BaseMemoryLib:
https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D03/D03.dsc?id=337713801cceb684326bfde22975310ca1bd0cc0


Hisilicon/D05: flash related drivers switch to use generic BaseMemoryLib:
https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D05/D05.dsc?id=0749464022407f11c0c6a46cb8eb293fc74ef236


Alexei.



From: edk2-devel  on behalf of Ard Biesheuvel 

Sent: 09 January 2018 18:26:57
To: Evan Lloyd
Cc: matteo.carl...@arm.com@arm.com; leif.lindh...@linaro.org@arm.com; 
n...@arm.com@arm.com; edk2-devel@lists.01.org; Arvind Chauhan; 
ard.biesheu...@linaro.org@arm.com; Thomas Abraham
Subject: Re: [edk2] [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD 
platform library

On 9 January 2018 at 18:21, Evan Lloyd  wrote:
>
>
>> -Original Message-
>> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
>> Sent: 23 December 2017 16:23
>> To: Evan Lloyd 
>> Cc: edk2-devel@lists.01.org; Arvind Chauhan ;
>> Daniil Egranov ; Thomas Abraham
>> ; "ard.biesheu...@linaro.org"@arm.com;
>> "leif.lindh...@linaro.org"@arm.com;
>> "matteo.carl...@arm.com"@arm.com; "n...@arm.com"@arm.com
>> Subject: Re: [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD
>> platform library
>>
>> On 22 December 2017 at 19:08,   wrote:
>> > From: Girish Pathak 
>> >
>> > This change adds the HDLCD platform lib for the Juno plaform. This
>> > library will be instantiated as a LcdPlatformLib to link with
>> > LcdGraphicsOutputDxe for the Juno platform.
>> >
>> > HDLCD platform library depends on the Arm SCMI DXE driver for
>> > communication with the SCP for clock setting. Therefore this change
>> > also enables building of Arm SCMI DXE driver for the Juno platform.
>> >
>> > Contributed-under: TianoCore Contribution Agreement 1.1
>> > Signed-off-by: Girish Pathak 
>>
>> Missing signoff?
> [[Evan Lloyd]] Yes.  Oops.
>
>>
>> > ---
>> >  Platform/ARM/JunoPkg/ArmJuno.dec |   8 +
>> >  Platform/ARM/JunoPkg/ArmJuno.dsc |  29 +
>> >  Platform/ARM/JunoPkg/ArmJuno.fdf |  12 +-
>> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf   |   5 +-
>> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
>> |  40 ++
>> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c |
>> 18 +-
>> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c  |
>> 559 
>> >  7 files changed, 668 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec
>> > b/Platform/ARM/JunoPkg/ArmJuno.dec
>> > index
>> >
>> b733480c3198d135df16ca024b5e85ff350e11c7..cd6710feb2faf0bd17b5ea
>> 39a21d
>> > be5406cd4ffd 100644
>> > --- a/Platform/ARM/JunoPkg/ArmJuno.dec
>> > +++ b/Platform/ARM/JunoPkg/ArmJuno.dec
>> > @@ -53,3 +53,11 @@ [PcdsFixedAtBuild.common]
>> >
>> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E00|UINT64|0
>> x0025
>> >
>> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x0
>> 026
>> >
>> > +  # MaxMode must be one number higher than the actual max mode,  #
>> > + i.e. for actual maximum mode 2, set the value to 3.
>> > +  #
>> > +  # Default value zero allows platform to enumerate maximum
>> supported mode.
>> > +  #
>> > +  # For a list of mode numbers look in HdLcdArmJuno.c
>> > +
>> gArmJunoTokenSpaceGuid.PcdArmHdLcdMaxMode|0|UINT32|0x001
>> 7
>> > +
>> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > b/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > index
>> >
>> fe860956a4dc497cac52be70bab3657246a08bd0..9027c5b0728a6941f850
>> 636b3bc3
>> > 

Re: [edk2] [RFC] SATA : Implemented NXP errata A008402

2018-01-10 Thread Udit Kumar


> -Original Message-
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: Wednesday, January 10, 2018 3:23 PM
> To: Udit Kumar 
> Cc: Ni, Ruiyu ; Meenakshi Aggarwal
> ; edk2-devel@lists.01.org; Zeng, Star
> ; leif.lindh...@linaro.org
> Subject: Re: [edk2] [RFC] SATA : Implemented NXP errata A008402
> 
> On 10 January 2018 at 09:43, Udit Kumar  wrote:
> > Hi Ruiyu,
> >
> >> -Original Message-
> >> >
> >> > And this change will not impact any other hardware so no one is
> >> > basically
> >> impacted by this change.
> >>
> >> Your buggy HW only need the value zero. But the addition of PCD
> >> exposes an interface that can use any size of PRD.
> >> I am not sure the AtaAtapiPassThru can work if some platform sets the
> >> PCD value to others than 0 or 3F_h.
> >
> > I don't see someone using this driver will set Pcd randomly, but I
> > agree on this point other value should be handled.
> > Error or Assert could be added, if Pcd value is not 0 or 3F_h.
> >
> >> Can you please
> >>   just duplicate the AtaAtapiPassThru in your platform?
> >> Because the driver is very stable today, not much code sync effort
> >> will be needed if core version is changed.
> >
> > Duplicating is always a possibility :), but When we will push this
> > duplicated driver (just for one line change) for upstreaming.
> > will this be acceptable ??
> 
> My main concern with this (and with using a PCD) is that the setting affects
> all SATA controllers in the system, including ones the you stick into a PCIe
> slot.

Agreed,  If two types of Sata controllers are used then this patch 
may break one controller. 
At present, we don’t have anyone asking SATA controller behind PCIe
but we shouldn’t ignore this. This is valid use case. 

> So I think forking the driver is the only possible solution, but it will not 
> be a
> one-line change: you need to ensure that you apply the workaround only to
> the SATA controllers in the SoC.

Yes, Considering unrelated SATA controllers this will be more than copy 

> --
> Ard.

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


Re: [edk2] [RFC] SATA : Implemented NXP errata A008402

2018-01-10 Thread Ard Biesheuvel
On 10 January 2018 at 09:43, Udit Kumar  wrote:
> Hi Ruiyu,
>
>> -Original Message-
>> >
>> > And this change will not impact any other hardware so no one is basically
>> impacted by this change.
>>
>> Your buggy HW only need the value zero. But the addition of PCD exposes
>> an interface that can use any size of PRD.
>> I am not sure the AtaAtapiPassThru can work if some platform sets the PCD
>> value to others than 0 or 3F_h.
>
> I don't see someone using this driver will set Pcd randomly, but I agree on 
> this
> point other value should be handled.
> Error or Assert could be added, if Pcd value is not 0 or 3F_h.
>
>> Can you please
>>   just duplicate the AtaAtapiPassThru in your platform?
>> Because the driver is very stable today, not much code sync effort will be
>> needed if core version is changed.
>
> Duplicating is always a possibility :), but When we will push this duplicated 
> driver
> (just for one line change) for upstreaming.
> will this be acceptable ??

My main concern with this (and with using a PCD) is that the setting
affects all SATA controllers in the system, including ones the you
stick into a PCIe slot.

So I think forking the driver is the only possible solution, but it
will not be a one-line change: you need to ensure that you apply the
workaround only to the SATA controllers in the SoC.

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


Re: [edk2] [RFC] SATA : Implemented NXP errata A008402

2018-01-10 Thread Udit Kumar
Hi Ruiyu, 

> -Original Message-
> >
> > And this change will not impact any other hardware so no one is basically
> impacted by this change.
> 
> Your buggy HW only need the value zero. But the addition of PCD exposes
> an interface that can use any size of PRD.
> I am not sure the AtaAtapiPassThru can work if some platform sets the PCD
> value to others than 0 or 3F_h.

I don't see someone using this driver will set Pcd randomly, but I agree on this
point other value should be handled. 
Error or Assert could be added, if Pcd value is not 0 or 3F_h.

> Can you please
>   just duplicate the AtaAtapiPassThru in your platform?
> Because the driver is very stable today, not much code sync effort will be
> needed if core version is changed.

Duplicating is always a possibility :), but When we will push this duplicated 
driver
(just for one line change) for upstreaming.
will this be acceptable ??

Thanks

 
> >
> >>>
> >>> Workaround:
> >>> Set PRD length to 0 when creating a PRD entry for a maximum data
> >>> transfer size of 4 MB to fix the erratum.
> >>>
> >>> Contributed-under: TianoCore Contribution Agreement 1.1
> >>> Signed-off-by: Meenakshi Aggarwal 
> >>> ---
> >>>MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c   | 2 +-
> >>>MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf | 1 +
> >>>MdeModulePkg/MdeModulePkg.dec  | 3 +++
> >>>3 files changed, 5 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> >> b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> >>> index e6de5d6..fb6dc0b 100644
> >>> --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> >>> +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> >>> @@ -591,7 +591,7 @@ AhciBuildCommand (
> >>>if (RemainedData < EFI_AHCI_MAX_DATA_PER_PRDT) {
> >>>  AhciRegisters->AhciCommandTable-
> >>> PrdtTable[PrdtIndex].AhciPrdtDbc = (UINT32)RemainedData - 1;
> >>>} else {
> >>> -  AhciRegisters->AhciCommandTable-
> >>> PrdtTable[PrdtIndex].AhciPrdtDbc = EFI_AHCI_MAX_DATA_PER_PRDT - 1;
> >>> +  AhciRegisters->AhciCommandTable-
> >>> PrdtTable[PrdtIndex].AhciPrdtDbc = PcdGet32 (PcdPrdtMaxDataLength);
> >>>}
> >>>
> >>>Data64.Uint64 = (UINT64)MemAddr; diff --git
> >> a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> >> b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> >>> index 82d5f7a..8921dd5 100644
> >>> --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> >>> +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> >>> @@ -70,6 +70,7 @@
> >>>
> >>>[Pcd]
> >>>  gEfiMdeModulePkgTokenSpaceGuid.PcdAtaSmartEnable   ##
> >> SOMETIMES_CONSUMES
> >>> +  gEfiMdeModulePkgTokenSpaceGuid.PcdPrdtMaxDataLength
> >>>
> >>># [Event]
> >>># EVENT_TYPE_PERIODIC_TIMER ## SOMETIMES_CONSUMES diff --git
> >>> a/MdeModulePkg/MdeModulePkg.dec
> >> b/MdeModulePkg/MdeModulePkg.dec
> >>> index 8efad57..b2f9f2b 100644
> >>> --- a/MdeModulePkg/MdeModulePkg.dec
> >>> +++ b/MdeModulePkg/MdeModulePkg.dec
> >>> @@ -1434,6 +1434,9 @@
> >>>  # @Prompt Console Output Row of Text Setup
> >>>
> >>
> gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|25|UINT32|0x40
> >> 0e
> >>>
> >>> +  ## This PCD specifies the Maximum data length for a PRD Entry
> >>> +
> >>
> gEfiMdeModulePkgTokenSpaceGuid.PcdPrdtMaxDataLength|0x3F|UIN
> >> T32|0x400f
> >>> +
> >>>[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic,
> >> PcdsDynamicEx]
> >>>  ## UART clock frequency is for the baud rate configuration.
> >>>  # @Prompt Serial Port Clock Rate.
> >>>
> >>
> >>
> >> --
> >> Thanks,
> >> Ray
> >> ___
> >> edk2-devel mailing list
> >> edk2-devel@lists.01.org
> >> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fli
> >> st
> >> s.01.org%2Fmailman%2Flistinfo%2Fedk2-
> >>
> devel=02%7C01%7Cmeenakshi.aggarwal%40nxp.com%7C60cadf13ac95
> >>
> 48486c4908d55712d85c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0
> %
> >>
> 7C636510660888390946=4oW2agf8z869IMz%2F7%2B2di9vC%2BB3js7K
> >> hJx1LR2b4Tc4%3D=0
> > ___
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flis
> > ts.01.org%2Fmailman%2Flistinfo%2Fedk2-
> devel=02%7C01%7Cudit.kumar%
> >
> 40nxp.com%7C0b697e2364f348745a7c08d5580cf5bf%7C686ea1d3bc2b4c6fa9
> 2cd99
> >
> c5c301635%7C0%7C0%7C636511735060291299=eWI7ueE5wzr2oSNv0t
> CP5hBE0
> > uEfB9S0PyABHWocBaA%3D=0
> >
> 
> 
> --
> Thanks,
> Ray
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.
> 01.org%2Fmailman%2Flistinfo%2Fedk2-
> devel=02%7C01%7Cudit.kumar%40nxp.com%7C0b697e2364f348745a7c
> 

[edk2] [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement GetElapsedTime function of TimerLib

2018-01-10 Thread Pankaj Bansal
This function calculates the time elaped in Naoseconds between call to
this function and BaseTime, which is passed as argument.

This is particularly useful in detecting timeout conditions.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pankaj Bansal 

diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c 
b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
index b81293c..0898339 100644
--- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
+++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
@@ -290,3 +290,39 @@ GetTimeInNanoSecond (
 
   return NanoSeconds;
 }
+
+/**
+  Get Elapsed time in Nanoseonds w.r.t BaseTime
+
+  This function calculates the time elaped in Naoseconds between call to this
+  function and BaseTime, which is passed as argument.
+
+  @param  BaseTime BaseTime in NanoSeconds.
+
+  @return The elapsed time in nanoseconds.
+
+**/
+UINT64
+EFIAPI
+GetElapsedTime (
+  IN  UINT64 BaseTime
+  )
+{
+  UINT64  NanoSeconds;
+  UINT64  Ticks;
+
+  //
+  // Get current Ticks.
+  //
+  Ticks = GetPerformanceCounter();
+
+  //
+  // Convert Ticks to Nanoseconds
+  //
+  NanoSeconds = GetTimeInNanoSecond (Ticks);
+
+  //
+  // return the difference
+  //
+  return (NanoSeconds - BaseTime);
+}
-- 
2.7.4

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


[edk2] [PATCH 1/2] MdePkg/TimerLib: Add a function to calculate elapsed time

2018-01-10 Thread Pankaj Bansal
This function calculates the time elaped in Naoseconds between call to
this function and BaseTime, which is passed as argument.

This is particularly useful in detecting timeout conditions.

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pankaj Bansal 

diff --git a/MdePkg/Include/Library/TimerLib.h 
b/MdePkg/Include/Library/TimerLib.h
index ecc3ad3..82a5c5c 100644
--- a/MdePkg/Include/Library/TimerLib.h
+++ b/MdePkg/Include/Library/TimerLib.h
@@ -111,4 +111,20 @@ GetTimeInNanoSecond (
   IN  UINT64 Ticks
   );
 
+/**
+  Get Elapsed time in Nanoseonds w.r.t BaseTime
+
+  This function calculates the time elaped in Naoseconds between call to this
+  function and BaseTime, which is passed as argument.
+
+  @param  BaseTime BaseTime in NanoSeconds.
+
+  @return The elapsed time in nanoseconds.
+
+**/
+UINT64
+EFIAPI
+GetElapsedTime (
+  IN  UINT64 BaseTime
+  );
 #endif
-- 
2.7.4

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


Re: [edk2] [RFC] SATA : Implemented NXP errata A008402

2018-01-10 Thread Ni, Ruiyu

On 1/10/2018 4:56 PM, Meenakshi Aggarwal wrote:



-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ni,
Ruiyu
Sent: Tuesday, January 09, 2018 9:11 AM
To: edk2-devel@lists.01.org
Subject: Re: [edk2] [RFC] SATA : Implemented NXP errata A008402

On 1/8/2018 7:16 PM, Meenakshi Aggarwal wrote:

Description:
Commands with 4 MB PRD length entries fail if PRD[DBC] is
set to the value according to AHCI standard spec.
Due to a logic error, 3F_h is misinterpreted by the
device as zero length.


Is the logic error mentioned here is the error in HW?
Then I do not prefer to add such PCD for a HW workaround.


Yes, the error is in hardware.
There is no other option visible to implement this errata if we want to use the 
existing AHCI framework.

I completely agree with you, but no other solution seems to exist in this case.

And this change will not impact any other hardware so no one is basically 
impacted by this change.


Your buggy HW only need the value zero. But the addition of PCD
exposes an interface that can use any size of PRD.
I am not sure the AtaAtapiPassThru can work if some platform
sets the PCD value to others than 0 or 3F_h.

Can you please
 just duplicate the AtaAtapiPassThru in your platform?
Because the driver is very stable today, not much code sync effort
will be needed if core version is changed.





Workaround:
Set PRD length to 0 when creating a PRD entry for
a maximum data transfer size of 4 MB to fix the erratum.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Meenakshi Aggarwal 
---
   MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c   | 2 +-
   MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf | 1 +
   MdeModulePkg/MdeModulePkg.dec  | 3 +++
   3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c

b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c

index e6de5d6..fb6dc0b 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
@@ -591,7 +591,7 @@ AhciBuildCommand (
   if (RemainedData < EFI_AHCI_MAX_DATA_PER_PRDT) {
 AhciRegisters->AhciCommandTable-
PrdtTable[PrdtIndex].AhciPrdtDbc = (UINT32)RemainedData - 1;
   } else {
-  AhciRegisters->AhciCommandTable-
PrdtTable[PrdtIndex].AhciPrdtDbc = EFI_AHCI_MAX_DATA_PER_PRDT - 1;
+  AhciRegisters->AhciCommandTable-
PrdtTable[PrdtIndex].AhciPrdtDbc = PcdGet32 (PcdPrdtMaxDataLength);
   }

   Data64.Uint64 = (UINT64)MemAddr;
diff --git

a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf

index 82d5f7a..8921dd5 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
@@ -70,6 +70,7 @@

   [Pcd]
 gEfiMdeModulePkgTokenSpaceGuid.PcdAtaSmartEnable   ##

SOMETIMES_CONSUMES

+  gEfiMdeModulePkgTokenSpaceGuid.PcdPrdtMaxDataLength

   # [Event]
   # EVENT_TYPE_PERIODIC_TIMER ## SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/MdeModulePkg.dec

b/MdeModulePkg/MdeModulePkg.dec

index 8efad57..b2f9f2b 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1434,6 +1434,9 @@
 # @Prompt Console Output Row of Text Setup


gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|25|UINT32|0x40
0e


+  ## This PCD specifies the Maximum data length for a PRD Entry
+

gEfiMdeModulePkgTokenSpaceGuid.PcdPrdtMaxDataLength|0x3F|UIN
T32|0x400f

+
   [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic,

PcdsDynamicEx]

 ## UART clock frequency is for the baud rate configuration.
 # @Prompt Serial Port Clock Rate.




--
Thanks,
Ray
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
s.01.org%2Fmailman%2Flistinfo%2Fedk2-
devel=02%7C01%7Cmeenakshi.aggarwal%40nxp.com%7C60cadf13ac95
48486c4908d55712d85c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%
7C636510660888390946=4oW2agf8z869IMz%2F7%2B2di9vC%2BB3js7K
hJx1LR2b4Tc4%3D=0

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




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


Re: [edk2] Communicate with soft-smi-handler with uefi-application question.

2018-01-10 Thread Zeng, Star
The trusted smm communication buffer needs to be allocated as 
EfiReservedMemoryType, EfiACPIMemoryNVS, or EfiRuntimeServicesData before 
EndOfDxe.
There is a generic smm communication buffer can be used if 
MdeModulePkg\Universal\SmmCommunicationBufferDxe is included in dsc and fdf.

You can refer 
https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c#L90
 to know how it be used.


Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
krishnaLee
Sent: Wednesday, January 10, 2018 3:44 PM
To: edk2-devel@lists.01.org
Subject: [edk2] Communicate with soft-smi-handler with uefi-application 
question.

Hi,
I'm learning  to write and register some soft-Smi-Handler in smm-mode; then 
using QEMU to boot my ovmf.fd,run into uefi shell; then write uefi-application 
using EFI_SMM_COMMUNICATION_PROTOCOL to Communicate to my Smi-Handler,but 
failed when run my uefi-application,the log show error.
I don't know why,maybe I do not full understand uefi-smm,but how to communicate 
to my smi handler?


//error-message
[Security] 3rd party image[0] can be loaded after EndOfDxe: 
PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0x,0x0)/HD(1,MBR,0xBE1AFDFA,0x3F,0xFBFC1)/\mytestsmm.efi.
InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 65FC4A8 Loading 
driver at 0x62B EntryPoint=0x62B10F5 mytestsmm.efi
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 65FCB10 
ProtectUefiImageCommon - 0x65FC4A8
  - 0x062B - 0x7000
InstallProtocolInterface: 752F3136-4E16-4FDC-A22A-E5F46812F4CA 7700CFC
InstallProtocolInterface: 4C8A2451-C207-405B-9694-99EA13251341 62B40B0 Locate 
EfiSmmCommunicationProtocol success
SmmIsBufferOutsideSmmValid: Not in ValidCommunicationRegion: Buffer (0x7700C94) 
- Length (0x2A), ASSERT [PiSmmCore] 
d:\edk2-vudk2017\MdePkg\Library\SmmMemLib\SmmMemLib.c(178): ((BOOLEAN)(0==1)) 
//error-message-end


//my register-smi-handler code:
//edk2-vUDK2017\MdeModulePkg\Universal\LockBox\SmmLockBox\SmmLockBox.c

EFI_STATUS

EFIAPI

MyTestSmmHandler (

IN EFI_HANDLE DispatchHandle,

IN CONST VOID *Context OPTIONAL,

IN OUT VOID *CommBuffer OPTIONAL,

IN OUT UINTN *CommBufferSize OPTIONAL

)

{

DEBUG ((DEBUG_INFO, "My Test Smm Handler Enter\n"));

DEBUG ((DEBUG_INFO, "My Test Smm Handler exit\n"));

return EFI_SUCCESS;

}




EFI_STATUS

EFIAPI

SmmLockBoxEntryPoint (

IN EFI_HANDLE ImageHandle,

IN EFI_SYSTEM_TABLE *SystemTable

)

{...

//Register My Test Smm handler

Status = gSmst->SmiHandlerRegister (

MyTestSmmHandler,

,



);

ASSERT_EFI_ERROR (Status);

...

}



//the uefi-application code
EFI_STATUS
EFIAPI
UefiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_SMM_COMMUNICATION_PROTOCOL *mSmmCommunication; EFI_SMM_COMMUNICATE_HEADER 
*SmmCommunicateHeader;
UINT8 *buffer;
UINTN bufferSize;


bufferSize=sizeof(EFI_SMM_COMMUNICATE_HEADER)*2;
gBS->AllocatePool (EfiRuntimeServicesData,bufferSize,);
if(buffer==NULL)
{
Print(L"EFI_OUT_OF_RESOURCES, return\n"); return EFI_OUT_OF_RESOURCES; }


SmmCommunicateHeader=(EFI_SMM_COMMUNICATE_HEADER*)buffer;
CopyGuid(>HeaderGuid,);
SmmCommunicateHeader->MessageLength=sizeof(EFI_SMM_COMMUNICATE_HEADER);


Status = gBS->LocateProtocol (, NULL, (VOID 
**) );
if(Status==EFI_SUCCESS)
{
Print(L"Locate EfiSmmCommunicationProtocol success\n"); }else { Print(L"Locate 
EfiSmmCommunicationProtocol failed return\n"); return EFI_SUCCESS; }


Status=mSmmCommunication->Communicate(mSmmCommunication,,);
if(Status==EFI_SUCCESS)
{
Print(L"Communication success\n");
}else
{
Print(L"Communication failed\n");
return EFI_SUCCESS;
}


gBS->FreePool(buffer);


return EFI_SUCCESS;
}


any help will be appreciated!
by krishna

___
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][edk2-platforms/devel-MinnowBoard3-UDK2017 2/2] Change BIOS Version.

2018-01-10 Thread zwei4
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: zwei4 
---
 Platform/BroxtonPlatformPkg/BiosId.env | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Platform/BroxtonPlatformPkg/BiosId.env 
b/Platform/BroxtonPlatformPkg/BiosId.env
index fc9d10eaa..ed144815c 100644
--- a/Platform/BroxtonPlatformPkg/BiosId.env
+++ b/Platform/BroxtonPlatformPkg/BiosId.env
@@ -31,5 +31,5 @@ BOARD_ID  = APLKRVP
 BOARD_REV = 3
 BUILD_TYPE= D
 VERSION_MAJOR = 0068
-VERSION_MINOR = 03
+VERSION_MINOR = 04
 BOARD_EXT = X64
-- 
2.14.1.windows.1

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


[edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 1/2] FAB ID.

2018-01-10 Thread zwei4
Add code to detect FAB ID of Aurora Glacier.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: zwei4 
---
 .../Board/AuroraGlacier/BoardInitPreMem/BoardInit.c  | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git 
a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInit.c 
b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInit.c
index bda774cb2..41d1c5af3 100644
--- 
a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInit.c
+++ 
b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInit.c
@@ -73,15 +73,13 @@ AuroraGlacierPreMemInit (
 
   DEBUG ((EFI_D_INFO,  "This is Aurora Glacier board.\n"));
   
-  //
-  //Status = AuroraGetFabId (PeiServices, );
-  //if (FabId == 1) {
-  //  DEBUG ((EFI_D_INFO,  "This is Aurora Glacier FAB B.\n"));
-  //} else if (FabId == 0) {
-  //  DEBUG ((EFI_D_INFO,  "This is Aurora Glacier FAB A.\n"));
-  //}
-  //
-  FabId = 0;
+  
+  Status = AuroraGetFabId (PeiServices, );
+  if (FabId == 1) {
+DEBUG ((EFI_D_INFO,  "This is Aurora Glacier FAB B.\n"));
+  } else if (FabId == 0) {
+DEBUG ((EFI_D_INFO,  "This is Aurora Glacier FAB A.\n"));
+  }
   
   PcdSet8 (PcdBoardId, BoardId);
   PcdSet8 (PcdFabId, FabId);
-- 
2.14.1.windows.1

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


Re: [edk2] [RFC] SATA : Implemented NXP errata A008402

2018-01-10 Thread Meenakshi Aggarwal

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ni,
> Ruiyu
> Sent: Tuesday, January 09, 2018 9:11 AM
> To: edk2-devel@lists.01.org
> Subject: Re: [edk2] [RFC] SATA : Implemented NXP errata A008402
> 
> On 1/8/2018 7:16 PM, Meenakshi Aggarwal wrote:
> > Description:
> > Commands with 4 MB PRD length entries fail if PRD[DBC] is
> > set to the value according to AHCI standard spec.
> > Due to a logic error, 3F_h is misinterpreted by the
> > device as zero length.
> 
> Is the logic error mentioned here is the error in HW?
> Then I do not prefer to add such PCD for a HW workaround.
> 
Yes, the error is in hardware.
There is no other option visible to implement this errata if we want to use the 
existing AHCI framework.

I completely agree with you, but no other solution seems to exist in this case.

And this change will not impact any other hardware so no one is basically 
impacted by this change.

> >
> > Workaround:
> > Set PRD length to 0 when creating a PRD entry for
> > a maximum data transfer size of 4 MB to fix the erratum.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Meenakshi Aggarwal 
> > ---
> >   MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c   | 2 +-
> >   MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf | 1 +
> >   MdeModulePkg/MdeModulePkg.dec  | 3 +++
> >   3 files changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > index e6de5d6..fb6dc0b 100644
> > --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > @@ -591,7 +591,7 @@ AhciBuildCommand (
> >   if (RemainedData < EFI_AHCI_MAX_DATA_PER_PRDT) {
> > AhciRegisters->AhciCommandTable-
> >PrdtTable[PrdtIndex].AhciPrdtDbc = (UINT32)RemainedData - 1;
> >   } else {
> > -  AhciRegisters->AhciCommandTable-
> >PrdtTable[PrdtIndex].AhciPrdtDbc = EFI_AHCI_MAX_DATA_PER_PRDT - 1;
> > +  AhciRegisters->AhciCommandTable-
> >PrdtTable[PrdtIndex].AhciPrdtDbc = PcdGet32 (PcdPrdtMaxDataLength);
> >   }
> >
> >   Data64.Uint64 = (UINT64)MemAddr;
> > diff --git
> a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> > index 82d5f7a..8921dd5 100644
> > --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> > +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> > @@ -70,6 +70,7 @@
> >
> >   [Pcd]
> > gEfiMdeModulePkgTokenSpaceGuid.PcdAtaSmartEnable   ##
> SOMETIMES_CONSUMES
> > +  gEfiMdeModulePkgTokenSpaceGuid.PcdPrdtMaxDataLength
> >
> >   # [Event]
> >   # EVENT_TYPE_PERIODIC_TIMER ## SOMETIMES_CONSUMES
> > diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> > index 8efad57..b2f9f2b 100644
> > --- a/MdeModulePkg/MdeModulePkg.dec
> > +++ b/MdeModulePkg/MdeModulePkg.dec
> > @@ -1434,6 +1434,9 @@
> > # @Prompt Console Output Row of Text Setup
> >
> gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|25|UINT32|0x40
> 0e
> >
> > +  ## This PCD specifies the Maximum data length for a PRD Entry
> > +
> gEfiMdeModulePkgTokenSpaceGuid.PcdPrdtMaxDataLength|0x3F|UIN
> T32|0x400f
> > +
> >   [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic,
> PcdsDynamicEx]
> > ## UART clock frequency is for the baud rate configuration.
> > # @Prompt Serial Port Clock Rate.
> >
> 
> 
> --
> Thanks,
> Ray
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
> s.01.org%2Fmailman%2Flistinfo%2Fedk2-
> devel=02%7C01%7Cmeenakshi.aggarwal%40nxp.com%7C60cadf13ac95
> 48486c4908d55712d85c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%
> 7C636510660888390946=4oW2agf8z869IMz%2F7%2B2di9vC%2BB3js7K
> hJx1LR2b4Tc4%3D=0
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel