[edk2] FW: IP4 Config Troubles with DHCP

2016-08-10 Thread Wu, Jiaxin
Eugene,

I want to confirm with you the steps to reproduce the issue:

1. Set policy to DHCP.
2. If DHCP process is not complete yet, then run one App to invoke the UDP4 
Configure with "UseDefaultAddress = TRUE" (loop to keep calling Udp4->Configure 
until Ip4Mode.IsConfigured changes to TRUE)
3. Even DHCP succeed but Ip4Mode.IsConfigured flag never set to TRUE  
failure here!!!

Above steps right? 

Actually, you don't need to retry the UDP configuration loop according the 
Ip4Mode.IsConfigured flag. You are only recommended to set a timer to check the 
mapping status after the configuration:

For example:
  Status = Nlc->Udp4->Configure(Nlc->Udp4, &Nlc->UdpConfig);
  if (EFI_ERROR (Status) && (Status != EFI_NO_MAPPING)) {
  return  Status;
  }
  if (Status == EFI_NO_MAPPING && !UdpGetMapping (Nlc->Udp4)) {
  return  Status;
  }

In UdpGetMapping () function, create one timer to check Ip4Mode.IsConfigured:

For example:
UdpGetMapping () {
  IsMapDone = FALSE;
  gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK, NULL, NULL, &TimeoutEvent);
  gBS->SetTimer (TimeoutEvent, TimerRelative, AnyValue);
  while (EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) {
Udp4->Poll (Udp4);
Udp4->GetModeData (Udp4, &Udp4Mode, & Ip4Mode, NULL, NULL);
if (Ip4Mode.IsConfigured) {
  IsMapDone = TRUE;
  break;
}
  }
  return IsMapDone;
}

If DHCP process succeed, Ip4Mode.IsConfigured should be updated. If not, any 
bug may be existed.

Thanks,
Jiaxin

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Cohen, 
Eugene
Sent: Thursday, August 11, 2016 2:14 AM
To: edk2-devel@lists.01.org; Wu, Jiaxin 
Subject: [edk2] IP4 Config Troubles with DHCP

We have been running into an issue when trying to configure an interface as 
DHCP where if the DHCP process is not yet complete (Ip4Mode.IsConfigured is 
FALSE) the configure process will never succeed.

We have a case where we attempt to invoke the UDP4 Configure:

Status = Nlc->Udp4->Configure(Nlc->Udp4, &Nlc->UdpConfig);

We had a retry loop where we keep calling Udp4->Configure until we finally see 
Ip4Mode.IsConfigured go TRUE (similar to what you see in Mtftp4GetMapping) - 
this has worked for many years but recently something broke this.   Now, even 
when DHCP succeeds the Ip4Mode.IsConfigured flag is set to FALSE.  

Only if we retry by destroying and re-creating new service binding children can 
we actually get this logic to succeed.  This logic is getting ridiculously 
complicated so I'm thinking there has to be a better way of doing this.

Do you have an example of specifically how a driver/app should handle the case 
where the DHCP process is not yet complete and wants to wait?

Thanks,

Eugene



___
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] NetworkPkg: Refine codes of iSCSI driver

2016-08-10 Thread Ye, Ting
Hi Lubo,

Could you please describe the changes introduced by this patch in your log 
message?

Thanks,
Ting

-Original Message-
From: Zhang, Lubo 
Sent: Thursday, August 11, 2016 10:27 AM
To: edk2-devel@lists.01.org
Cc: Dong, Eric ; Ye, Ting ; Fu, Siyuan 

Subject: [patch] NetworkPkg: Refine codes of iSCSI driver

The RSDT is only used when the bios need to support ACPI 1.0 version. When 
change PcdAcpiExposedTableVersions to 0x3C, it will not support ACPI 1.0. The 
default is 0x3E.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Eric Dong 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 NetworkPkg/IScsiDxe/IScsiIbft.c | 35 ---
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiIbft.c b/NetworkPkg/IScsiDxe/IScsiIbft.c 
index 3c179bf..27d098d 100644
--- a/NetworkPkg/IScsiDxe/IScsiIbft.c
+++ b/NetworkPkg/IScsiDxe/IScsiIbft.c
@@ -454,42 +454,42 @@ IScsiPublishIbft (
   EFI_STATUSStatus;
   EFI_ACPI_TABLE_PROTOCOL   *AcpiTableProtocol;
   EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table;
   EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
   EFI_ACPI_DESCRIPTION_HEADER   *Rsdt;
+  EFI_ACPI_DESCRIPTION_HEADER   *Xsdt;
   UINT8 *Heap;
   UINT8 Checksum;
-  UINTN Index;
 
+  Rsdt = NULL;
+  Xsdt = NULL;
 
   Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) 
&AcpiTableProtocol);
   if (EFI_ERROR (Status)) {
 return ;
   }
 
   //
   // Find ACPI table RSD_PTR from the system table.
   //
-  for (Index = 0, Rsdp = NULL; Index < gST->NumberOfTableEntries; Index++) {
-if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi20TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi10TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpiTableGuid)
-  ) {
-  //
-  // A match was found.
-  //
-  Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) 
gST->ConfigurationTable[Index].VendorTable;
-  break;
-}
+  Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID 
+ **) &Rsdp);  if (EFI_ERROR (Status)) {
+Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, 
+ (VOID **) &Rsdp);
   }
 
-  if (Rsdp == NULL) {
+  if (EFI_ERROR (Status) || (Rsdp == NULL)) {
 return ;
-  } else {
+  } else if (Rsdp->Revision >= 
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 
0) {
+Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress;  
+ } else if (Rsdp->RsdtAddress != 0) {
 Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;
   }
 
+  if ((Xsdt == NULL) && (Rsdt == NULL)) {
+return ;
+  }
+
   if (mIbftInstalled) {
 Status = AcpiTableProtocol->UninstallAcpiTable (
   AcpiTableProtocol,
   mTableKey
   );
@@ -518,11 +518,16 @@ IScsiPublishIbft (
   Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET;
 
   //
   // Fill in the various section of the iSCSI Boot Firmware Table.
   //
-  IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
+  if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) 
{
+IScsiInitIbfTableHeader (Table, Xsdt->OemId, &Xsdt->OemTableId);  } 
+ else {
+IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);  }
+
   IScsiInitControlSection (Table);
   IScsiFillInitiatorSection (Table, &Heap);
   IScsiFillNICAndTargetSections (Table, &Heap);
 
   Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length);
--
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 11/11] MdeModulePkg/ResetSystemRuntimeDxe: Support EfiResetPlatformSpecific

2016-08-10 Thread Jordan Justen
On 2016-08-10 19:43:03, Ni, Ruiyu wrote:
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > Jordan Justen
> > 
> > On 2016-08-09 22:56:11, Ruiyu Ni wrote:
> > > +indicate the reason for the system 
> > > reset. ResetData is only
> > > +valid if ResetStatus is something other 
> > > than EFI_SUCCESS
> > > +unless the ResetType is 
> > > EfiResetPlatformSpecific
> > > +where a minimum amount of ResetData is 
> > > always
> > required.
> > 
> > Most of the patches in this series have lines that are longer than 80 
> > columns.
> > Can you fix that?
> 
> Do we have rule to limit the line to 80 columns? I saw many files have long
> lines.
> Or I can change OvmfPkg changes to follow the 80 rule. What do you think?

Yes, it is in the code style document. You should update all patches
for it. It looks like most of them will just be copy/paste.

> 
> > 
> > I think you should move patch 11 before patch 09 "OvmfPkg: Use
> > MdeModulePkg/ResetSystemRuntimeDxe". I think this should allow reset to
> > continue working through the entire series for OVMF. (right?)
> 
> Reset works using my current order.
> But I agree moving #11 before #9 can move ResetPlatformSpecific support
> earilier, and group the ResetPlatformSpecific patches together. I will do 
> that.

Oh, I see. I guess this patch updates the ResetPlatformSpecific type,
so it probably won't be too important for OVMF. I think it might be a
little better earlier, but you can decide if you want to move it or
not.

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


Re: [edk2] DHCP Automatic Configure at Driver Connect

2016-08-10 Thread Wu, Jiaxin
Thanks Ting's more background clarification. 

I assume the difference you mentioned is between "SHA-1: 
3d0a49ad47619c30c84bbee8a33f54b64dddbcec" and "SHA-1: 
7648748e99eeeadec38fda7568adb260c4acc861". The two commits does cause the 
different behavior as Ting said below. Git version 3d0a49ad will only set the 
policy to dhcp but don't trigger D.O.R.A while 7648748e always trigger D.O.R.A 
if policy is DHCP.

Version 7648748e commit is also the current behavior of Ip4Config2: DHCP policy 
together with D.O.R.A process, which is similar to the old Ip4Config behavior. 
The version 3d0a49ad did was trying to resolve the Ip4Dxe performance but it's 
not workable for IPv6, so we reverted it. 

Thanks,
Jiaxin

> -Original Message-
> From: Ye, Ting
> Sent: Thursday, August 11, 2016 11:03 AM
> To: Cohen, Eugene ; edk2-devel@lists.01.org; Wu, Jiaxin
> 
> Subject: RE: DHCP Automatic Configure at Driver Connect
> 
> Hi Eugene,
> 
> Actually this is exactly the problem Samer raised to the mailing list in Aug 
> 2015.
> We ever fixed it with following patch:
> 
> SHA-1: 3d0a49ad47619c30c84bbee8a33f54b64dddbcec
> 
> * MdeModulePkg: Fix issue about current Ip4Dxe implementation for DHCP
> DORA process
> 
> DHCP policy is applied as default at boot time on all NICs in the system, 
> which
> results in all NIC ports attempting DHCP and trying to acquire IP addresses
> during boot.
> Ip4 driver should only set dhcp as default policy, and not trigger DORA at
> driver binding start(). We should start DORA until one IP child is configured 
> to
> use default address.
> 
> Later HP raised the same performance impact in IPv6 stack. We realized we
> couldn't use the same logic to defer DHCP6 SARR process.
> Instead, we discussed the issue in spec group and we removed the
> restriction from UEFI specification that the default policy should be
> Ip4Config2PolicyDhcp or Ip6ConfigPolicyAutomatic. It's up to
> implementation's choice.
> The EDKII implementation was later updated that the default policy was
> changed to Ip4Config2PolicyStatic and IP6ConfigPolicyManual. Also the
> previous change was reverted, in order to keep IP4/IP6 solution consistent.
> See patch (also reviewed by Samer):
> 
> SHA-1: 7648748e99eeeadec38fda7568adb260c4acc861
> 
> * MdeModulePkg: Change the default IPv4 config policy
> 
> Git version '3d0a49ad' commit provided a scenario to resolve the
> performance issue for IPv4, but it's not workable for IPv6. To avoid IPv4 and
> IPv6 inconsistency, we decided to revert that version fix.
> 
> If so, the default policy for Ip4Config2 is Ip4Config2PolicyDhcp, which 
> results
> in all NIC ports attempting DHCP. So, this patch is used to changes the the
> default IPv4 config policy to Ip4Config2PolicyStatic and also defer the 
> SetData
> operation after Ip4Config2Protocol installed. This update let the other
> platform drivers have chance to change the default config data by consume
> Ip4Config2Protocol.
> 
> 
> Current implementation recommends that the system should stay in default
> policy - static to not initialize DHCP process, unless the system needs to 
> start
> DHCP -- it should change the policy to IP4Config2PolicyDhcp.
> 
> Best Regards,
> Ye Ting
> 
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Cohen, Eugene
> Sent: Thursday, August 11, 2016 2:17 AM
> To: edk2-devel@lists.01.org; Wu, Jiaxin 
> Subject: [edk2] DHCP Automatic Configure at Driver Connect
> 
> With this commit:
> 
> Revision: 1f6729ffe98095107ce82e67a4a0209674601a90
> Author: jiaxinwu 
> Date: 7/7/2015 2:19:55 AM
> Message:
> MdeModulePkg: Update Ip4Dxe driver to support Ip4Config2 protocol,
> 
> a new behavior seemed to come in to the network stack that was not
> present before: It appears now that as soon as the DHCP Service Binding
> protocol is installed the DHCP process will be initiated (see
> Ip4Config2OnDhcp4SbInstalled).  This differs from past behavior where DHCP
> would only occur if a driver or application specifically did Configure() on 
> the
> network interface.
> 
> For some systems this is problematic because they need to defer DHCP until
> it is certain that the network interface will be used for something.
> 
> Can you provide the reason for this change?  Can we have a policy (PCD) to
> disable this mode of operation?
> 
> Thanks,
> 
> Eugene
> 
> 
> ___
> 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] PcAtChipsetPkg AcpiTimerLib: Get more accurate TSC Frequency

2016-08-10 Thread Kinney, Michael D
Reviewed-by: : Michael D Kinney 

> -Original Message-
> From: Zeng, Star
> Sent: Wednesday, August 10, 2016 7:38 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Kinney, Michael D 
> ;
> Gao, Liming ; Lohr, Paul A 
> Subject: [PATCH] PcAtChipsetPkg AcpiTimerLib: Get more accurate TSC Frequency
> 
> Minimize the code overhead between the two TSC reads by adding
> new internal API to calculate TSC Frequency instead of reusing
> MicroSecondDelay ().
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Paul A Lohr 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng 
> ---
>  PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c | 56 
> +-
>  .../Library/AcpiTimerLib/BaseAcpiTimerLib.c| 33 -
>  .../Library/AcpiTimerLib/DxeAcpiTimerLib.c | 31 
>  3 files changed, 99 insertions(+), 21 deletions(-)
> 
> diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
> b/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
> index 806a4f7ce24c..e6fea231123d 100644
> --- a/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
> +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
> @@ -1,7 +1,7 @@
>  /** @file
>ACPI Timer implements one instance of Timer Library.
> 
> -  Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
> +  Copyright (c) 2013 - 2016, 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
> @@ -335,3 +335,57 @@ GetTimeInNanoSecond (
> 
>return NanoSeconds;
>  }
> +
> +/**
> +  Calculate TSC frequency.
> +
> +  The TSC counting frequency is determined by comparing how far it counts
> +  during a 100us period as determined by the ACPI timer. The ACPI timer is
> +  used because it counts at a known frequency.
> +  The TSC is sampled, followed by waiting for ACPI_TIMER_FREQUENCY / 1
> +  clocks of the ACPI timer, or 100us. The TSC is then sampled again. The
> +  difference multiplied by 1 is the TSC frequency. There will be a small
> +  error because of the overhead of reading the ACPI timer. An attempt is
> +  made to determine and compensate for this error.
> +
> +  @return The number of TSC counts per second.
> +
> +**/
> +UINT64
> +InternalCalculateTscFrequency (
> +  VOID
> +  )
> +{
> +  UINT64  StartTSC;
> +  UINT64  EndTSC;
> +  UINT16  TimerAddr;
> +  UINT32  Ticks;
> +  UINT64  TscFrequency;
> +  BOOLEAN InterruptState;
> +
> +  InterruptState = SaveAndDisableInterrupts ();
> +
> +  TimerAddr = InternalAcpiGetAcpiTimerIoPort ();
> +  Ticks = IoRead32 (TimerAddr) + (ACPI_TIMER_FREQUENCY / 1);// Set 
> Ticks to
> 100us in the future
> +
> +  StartTSC = AsmReadTsc (); // Get 
> base
> value for the TSC
> +  //
> +  // Wait until the ACPI timer has counted 100us.
> +  // Timer wrap-arounds are handled correctly by this function.
> +  // When the current ACPI timer value is greater than 'Ticks', the while 
> loop will
> exit.
> +  //
> +  while (((Ticks - IoRead32 (TimerAddr)) & BIT23) == 0) {
> +CpuPause();
> +  }
> +  EndTSC = AsmReadTsc ();   // TSC 
> value
> 100us later
> +
> +  TscFrequency = MultU64x32 (
> +   (EndTSC - StartTSC), // 
> Number of TSC
> counts in 100us
> +   1// 
> Number of
> 100us in a second
> +   );
> +
> +  SetInterruptState (InterruptState);
> +
> +  return TscFrequency;
> +}
> +
> diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
> b/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
> index 21fdb79908b8..8819ebcfccef 100644
> --- a/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
> +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
> @@ -1,7 +1,7 @@
>  /** @file
>ACPI Timer implements one instance of Timer Library.
> 
> -  Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
> +  Copyright (c) 2013 - 2016, 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
> @@ -17,6 +17,26 @@
>  #include 
> 
>  /**
> +  Calculate TSC frequency.
> +
> +  The TSC counting frequency is determined by comparing how far it counts
> +  during a 100us period as determined by the ACPI timer. The ACPI timer is
> +  used because it counts at a known frequency.
> +  The TSC is sampled, followed by waiting for ACPI_TIMER_FREQUENCY / 1
> +  clocks of the ACPI timer, or 100us. The TSC is then sampled again. The
> +  difference multiplied by 1 i

Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to DxeReportStatusCodeLib assuming the state of the BootService Memory at runtime.

2016-08-10 Thread Zeng, Star

On 2016/8/11 9:59, Andrew Fish wrote:



On Aug 10, 2016, at 6:53 PM, Zeng, Star  wrote:

If a DXE_RUNTIME_DRIVER driver just wants to report status code at boot phase 
and links to DxeReportStatusCodeLib, is it a bug?

How about just to add notes for DxeReportStatusCodeLib like DxePcdLib.inf?



Star,

This is point about lack of rules around this. I think the difference is the 
PCD protocol is defined as boot service only. I guess you could argue that 
depending on how things are constructed you could access some (FixedAtBuild) 
PCD things at runtime.

I don't think it is a good idea to produce a runtime service that does not work 
at runtime. Mike seems to agree.

But I agree better rules about this would be helpful.


Andrew,

I see the point, and I also agree it is helpful with good rules.
I just thought about a possible valid use case from user, and propose to 
reduce the negative impact.
Adding notes like DxePcdLib.inf is a possible approach to state the 
limitation, and there are also similar notes in SecPeiDxeTimerLibCpu.inf 
and SecPeiDxeTimerLibUefiCpu.inf.



Thanks,
Star



Thanks,

Andrew Fish


DxePcdLib.inf:
"
# Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can only use 
this DxePcdLib
#  in their initialization without any issues to access Dynamic and DynamicEx 
PCD. They can't
#  access Dynamic and DynamicEx PCD in the implementation of runtime services 
and SMI handlers.
#  Because EFI_PCD_PROTOCOL is DXE protocol that is not aviable in OS runtime 
phase.
"

Thanks,
Star
-Original Message-
From: af...@apple.com [mailto:af...@apple.com]
Sent: Thursday, August 11, 2016 3:04 AM
To: Kinney, Michael D 
Cc: Zeng, Star ; edk2-devel 
Subject: Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to 
DxeReportStatusCodeLib assuming the state of the BootService Memory at runtime.



On Aug 10, 2016, at 11:02 AM, Kinney, Michael D  
wrote:




-Original Message-
From: af...@apple.com [mailto:af...@apple.com]
Sent: Wednesday, August 10, 2016 10:35 AM
To: Kinney, Michael D 
Cc: Zeng, Star ; edk2-devel

Subject: Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due
to DxeReportStatusCodeLib assuming the state of the BootService Memory at 
runtime.



On Aug 10, 2016, at 10:22 AM, Kinney, Michael D  
wrote:

Hi Andrew,

I am staring at the code.  Something is not right here, but I am
concerned that there are use cases I am not considering yet.  Here
is my analysis so far.

Here are the lib instances I see:
(ignoring IntelFramework ones for the purposes of this discussion).

MdeModulePkg\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf(25):
LIBRARY_CLASS = ReportStatusCodeLib|DXE_CORE DXE_DRIVER
DXE_RUNTIME_DRIVER

DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE


MdeModulePkg\Library\PeiReportStatusCodeLib\PeiReportStatusCodeLib.inf(27):
LIBRARY_CLASS = ReportStatusCodeLib|SEC PEIM PEI_CORE



MdeModulePkg\Library\RuntimeDxeReportStatusCodeLib\RuntimeDxeReportSt
atusCodeLib.inf(
23):

LIBRARY_CLASS = ReportStatusCodeLib|DXE_RUNTIME_DRIVER
DXE_SAL_DRIVER

MdeModulePkg\Library\SmmReportStatusCodeLib\SmmReportStatusCodeLib.inf(26):
LIBRARY_CLASS = ReportStatusCodeLib|DXE_SMM_DRIVER SMM_CORE

MdePkg\Library\BaseReportStatusCodeLibNull\BaseReportStatusCodeLibNull.inf(23):
LIBRARY_CLASS = ReportStatusCodeLib

* The BASE one that is a Null instance makes sense when disabling
Report Status

Code.

* The PEI one makes sense for its module compatibility.
* The SMM one also makes sense its module compatibility.
* And the RuntimeDxe one also makes sense its module compatibility.
* The DXE one seems to be over specified and if we reduced its
module compatibility, the SMM and RuntimeDxe lib instances can be
used to cover those module types.

When I look at the source code in DxeReportStatusCodeLib, I see
comments that describe the use case where a module is dispatched
before the Report Status Code Protocol is available.

The use case you are describing is when the first call to Report
Status Code by a module occurs after ExitBootServices().  In that
case, we depend on the Boot Services table being zeroed to exit early.

I agree that no component should depend on Boot Services table being
cleared to zeros at ExitBootServices().  It is legal from UEFI/PI
spec to not zero at all, or in your example, fill with a pattern
other than zeros.

It appears that the use case of first call to Report Status Code
after
ExitBootServices() is not covered by the DXE lib instance, and we
have just been getting lucky due to zeroing behavior of boot services table.

I can think of a couple options:

* Update DXE INF to remove the DXE Runtime, DXE SAL, SMM, SMM Core
module types.  This may break platform builds if a platform is using
this lib mapping for modules of the types being removed.  However,
those could be considered platform DSC bugs.

* Update DXE lib instance to add ExitBootServices() and
SetVirtualAddressMap() events.  However, this would basically mak

Re: [edk2] DHCP Automatic Configure at Driver Connect

2016-08-10 Thread Ye, Ting
Hi Eugene,

Actually this is exactly the problem Samer raised to the mailing list in Aug 
2015. We ever fixed it with following patch:

SHA-1: 3d0a49ad47619c30c84bbee8a33f54b64dddbcec

* MdeModulePkg: Fix issue about current Ip4Dxe implementation for DHCP DORA 
process

DHCP policy is applied as default at boot time on all NICs in the system, which 
results
in all NIC ports attempting DHCP and trying to acquire IP addresses during boot.
Ip4 driver should only set dhcp as default policy, and not trigger DORA at 
driver binding
start(). We should start DORA until one IP child is configured to use default 
address.

Later HP raised the same performance impact in IPv6 stack. We realized we 
couldn't use the same logic to defer DHCP6 SARR process.
Instead, we discussed the issue in spec group and we removed the restriction 
from UEFI specification that the default policy should be Ip4Config2PolicyDhcp 
or Ip6ConfigPolicyAutomatic. It's up to implementation's choice.
The EDKII implementation was later updated that the default policy was changed 
to Ip4Config2PolicyStatic and IP6ConfigPolicyManual. Also the previous change 
was reverted, in order to keep IP4/IP6 solution consistent. See patch (also 
reviewed by Samer):

SHA-1: 7648748e99eeeadec38fda7568adb260c4acc861

* MdeModulePkg: Change the default IPv4 config policy

Git version '3d0a49ad' commit provided a scenario to resolve the
performance issue for IPv4, but it's not workable for IPv6. To
avoid IPv4 and IPv6 inconsistency, we decided to revert that version
fix.

If so, the default policy for Ip4Config2 is Ip4Config2PolicyDhcp,
which results in all NIC ports attempting DHCP. So, this patch is
used to changes the the default IPv4 config policy to
Ip4Config2PolicyStatic and also defer the SetData operation after
Ip4Config2Protocol installed. This update let the other platform
drivers have chance to change the default config data by consume
Ip4Config2Protocol.


Current implementation recommends that the system should stay in default policy 
- static to not initialize DHCP process, unless the system needs to start DHCP 
-- it should change the policy to IP4Config2PolicyDhcp.

Best Regards,
Ye Ting


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Cohen, 
Eugene
Sent: Thursday, August 11, 2016 2:17 AM
To: edk2-devel@lists.01.org; Wu, Jiaxin 
Subject: [edk2] DHCP Automatic Configure at Driver Connect

With this commit:

Revision: 1f6729ffe98095107ce82e67a4a0209674601a90
Author: jiaxinwu 
Date: 7/7/2015 2:19:55 AM
Message:
MdeModulePkg: Update Ip4Dxe driver to support Ip4Config2 protocol,

a new behavior seemed to come in to the network stack that was not present 
before: It appears now that as soon as the DHCP Service Binding protocol is 
installed the DHCP process will be initiated (see 
Ip4Config2OnDhcp4SbInstalled).  This differs from past behavior where DHCP 
would only occur if a driver or application specifically did Configure() on the 
network interface.

For some systems this is problematic because they need to defer DHCP until it 
is certain that the network interface will be used for something.

Can you provide the reason for this change?  Can we have a policy (PCD) to 
disable this mode of operation?

Thanks,

Eugene


___
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] PcAtChipsetPkg AcpiTimerLib: Get more accurate TSC Frequency

2016-08-10 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Zeng, Star
> Sent: Thursday, August 11, 2016 10:38 AM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Kinney, Michael D
> ; Gao, Liming ; Lohr,
> Paul A 
> Subject: [PATCH] PcAtChipsetPkg AcpiTimerLib: Get more accurate TSC
> Frequency
> 
> Minimize the code overhead between the two TSC reads by adding
> new internal API to calculate TSC Frequency instead of reusing
> MicroSecondDelay ().
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Paul A Lohr 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng 
> ---
>  PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c | 56
> +-
>  .../Library/AcpiTimerLib/BaseAcpiTimerLib.c| 33 -
>  .../Library/AcpiTimerLib/DxeAcpiTimerLib.c | 31 
>  3 files changed, 99 insertions(+), 21 deletions(-)
> 
> diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
> b/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
> index 806a4f7ce24c..e6fea231123d 100644
> --- a/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
> +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
> @@ -1,7 +1,7 @@
>  /** @file
>ACPI Timer implements one instance of Timer Library.
> 
> -  Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
> +  Copyright (c) 2013 - 2016, 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
> @@ -335,3 +335,57 @@ GetTimeInNanoSecond (
> 
>return NanoSeconds;
>  }
> +
> +/**
> +  Calculate TSC frequency.
> +
> +  The TSC counting frequency is determined by comparing how far it counts
> +  during a 100us period as determined by the ACPI timer. The ACPI timer is
> +  used because it counts at a known frequency.
> +  The TSC is sampled, followed by waiting for ACPI_TIMER_FREQUENCY /
> 1
> +  clocks of the ACPI timer, or 100us. The TSC is then sampled again. The
> +  difference multiplied by 1 is the TSC frequency. There will be a small
> +  error because of the overhead of reading the ACPI timer. An attempt is
> +  made to determine and compensate for this error.
> +
> +  @return The number of TSC counts per second.
> +
> +**/
> +UINT64
> +InternalCalculateTscFrequency (
> +  VOID
> +  )
> +{
> +  UINT64  StartTSC;
> +  UINT64  EndTSC;
> +  UINT16  TimerAddr;
> +  UINT32  Ticks;
> +  UINT64  TscFrequency;
> +  BOOLEAN InterruptState;
> +
> +  InterruptState = SaveAndDisableInterrupts ();
> +
> +  TimerAddr = InternalAcpiGetAcpiTimerIoPort ();
> +  Ticks = IoRead32 (TimerAddr) + (ACPI_TIMER_FREQUENCY / 1);//
> Set Ticks to 100us in the future
> +
> +  StartTSC = AsmReadTsc (); // Get 
> base value for the
> TSC
> +  //
> +  // Wait until the ACPI timer has counted 100us.
> +  // Timer wrap-arounds are handled correctly by this function.
> +  // When the current ACPI timer value is greater than 'Ticks', the while 
> loop
> will exit.
> +  //
> +  while (((Ticks - IoRead32 (TimerAddr)) & BIT23) == 0) {
> +CpuPause();
> +  }
> +  EndTSC = AsmReadTsc ();   // TSC 
> value 100us later
> +
> +  TscFrequency = MultU64x32 (
> +   (EndTSC - StartTSC), // 
> Number of TSC counts in
> 100us
> +   1// 
> Number of 100us in a second
> +   );
> +
> +  SetInterruptState (InterruptState);
> +
> +  return TscFrequency;
> +}
> +
> diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
> b/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
> index 21fdb79908b8..8819ebcfccef 100644
> --- a/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
> +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
> @@ -1,7 +1,7 @@
>  /** @file
>ACPI Timer implements one instance of Timer Library.
> 
> -  Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
> +  Copyright (c) 2013 - 2016, 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
> @@ -17,6 +17,26 @@
>  #include 
> 
>  /**
> +  Calculate TSC frequency.
> +
> +  The TSC counting frequency is determined by comparing how far it counts
> +  during a 100us period as determined by the ACPI timer. The ACPI timer is
> +  used because it counts at a known frequency.
> +  The TSC is sampled, followed by waiting for ACPI_TIMER_FREQUENCY /
> 1
> +  clocks of the ACPI timer, or 100us. The TSC is then sampled again. The
> +  difference multiplied by 1 is the TSC frequ

Re: [edk2] [PATCH 11/11] MdeModulePkg/ResetSystemRuntimeDxe: Support EfiResetPlatformSpecific

2016-08-10 Thread Ni, Ruiyu


Thanks/Ray

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Jordan Justen
> Sent: Thursday, August 11, 2016 1:33 AM
> To: Ni, Ruiyu ; edk2-devel@lists.01.org
> Cc: Tian, Feng ; Chan, Amy 
> Subject: Re: [edk2] [PATCH 11/11]
> MdeModulePkg/ResetSystemRuntimeDxe: Support EfiResetPlatformSpecific
> 
> On 2016-08-09 22:56:11, Ruiyu Ni wrote:
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Ruiyu Ni 
> > Cc: Feng Tian 
> > Cc: Amy Chan 
> > ---
> >  MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c | 14
> > +++---
> >  1 file changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git
> > a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
> > b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
> > index aa1ca16..f61e65e 100644
> > --- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
> > +++
> b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
> > @@ -1,7 +1,7 @@
> >  /** @file
> >Reset Architectural Protocol implementation
> >
> > -  Copyright (c) 2006 - 2012, Intel Corporation. All rights
> > reserved.
> > +  Copyright (c) 2006 - 2016, 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 @@ -86,11 +86,15 @@ DoS3 (
> >
> >@param[in] ResetType  The type of reset to perform.
> >@param[in] ResetStatusThe status code for the reset.
> > -  @param[in] DataSize   The size, in bytes, of WatchdogData.
> > +  @param[in] DataSize   The size, in bytes, of ResetData.
> >@param[in] ResetData  For a ResetType of EfiResetCold,
> EfiResetWarm, or
> >  EfiResetShutdown the data buffer starts 
> > with a Null-
> terminated
> >  string, optionally followed by additional 
> > binary data.
> > -
> > +The string is a description that the 
> > caller may use to
> further
> > +indicate the reason for the system reset. 
> > ResetData is only
> > +valid if ResetStatus is something other 
> > than EFI_SUCCESS
> > +unless the ResetType is 
> > EfiResetPlatformSpecific
> > +where a minimum amount of ResetData is 
> > always
> required.
> 
> Most of the patches in this series have lines that are longer than 80 columns.
> Can you fix that?

Do we have rule to limit the line to 80 columns? I saw many files have long
lines.
Or I can change OvmfPkg changes to follow the 80 rule. What do you think?

> 
> I think you should move patch 11 before patch 09 "OvmfPkg: Use
> MdeModulePkg/ResetSystemRuntimeDxe". I think this should allow reset to
> continue working through the entire series for OVMF. (right?)

Reset works using my current order.
But I agree moving #11 before #9 can move ResetPlatformSpecific support
earilier, and group the ResetPlatformSpecific patches together. I will do that.

> 
> With those changes,
> 
> Series Reviewed-by: Jordan Justen 
> 
> >  **/
> >  VOID
> >  EFIAPI
> > @@ -144,6 +148,10 @@ ResetSystem (
> >  ResetShutdown ();
> >  return ;
> >
> > +  case EfiResetPlatformSpecific:
> > +ResetPlatformSpecific (DataSize, ResetData);
> > +return;
> > +
> >default:
> >  return ;
> >}
> > --
> > 2.9.0.windows.1
> >
> > ___
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] PcAtChipsetPkg AcpiTimerLib: Get more accurate TSC Frequency

2016-08-10 Thread Star Zeng
Minimize the code overhead between the two TSC reads by adding
new internal API to calculate TSC Frequency instead of reusing
MicroSecondDelay ().

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Paul A Lohr 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c | 56 +-
 .../Library/AcpiTimerLib/BaseAcpiTimerLib.c| 33 -
 .../Library/AcpiTimerLib/DxeAcpiTimerLib.c | 31 
 3 files changed, 99 insertions(+), 21 deletions(-)

diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c 
b/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
index 806a4f7ce24c..e6fea231123d 100644
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
@@ -1,7 +1,7 @@
 /** @file
   ACPI Timer implements one instance of Timer Library.
 
-  Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
+  Copyright (c) 2013 - 2016, 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
@@ -335,3 +335,57 @@ GetTimeInNanoSecond (
 
   return NanoSeconds;
 }
+
+/**
+  Calculate TSC frequency.
+
+  The TSC counting frequency is determined by comparing how far it counts
+  during a 100us period as determined by the ACPI timer. The ACPI timer is
+  used because it counts at a known frequency.
+  The TSC is sampled, followed by waiting for ACPI_TIMER_FREQUENCY / 1
+  clocks of the ACPI timer, or 100us. The TSC is then sampled again. The
+  difference multiplied by 1 is the TSC frequency. There will be a small
+  error because of the overhead of reading the ACPI timer. An attempt is
+  made to determine and compensate for this error.
+
+  @return The number of TSC counts per second.
+
+**/
+UINT64
+InternalCalculateTscFrequency (
+  VOID
+  )
+{
+  UINT64  StartTSC;
+  UINT64  EndTSC;
+  UINT16  TimerAddr;
+  UINT32  Ticks;
+  UINT64  TscFrequency;
+  BOOLEAN InterruptState;
+
+  InterruptState = SaveAndDisableInterrupts ();
+
+  TimerAddr = InternalAcpiGetAcpiTimerIoPort ();
+  Ticks = IoRead32 (TimerAddr) + (ACPI_TIMER_FREQUENCY / 1);// Set 
Ticks to 100us in the future
+
+  StartTSC = AsmReadTsc (); // Get 
base value for the TSC
+  //
+  // Wait until the ACPI timer has counted 100us.
+  // Timer wrap-arounds are handled correctly by this function.
+  // When the current ACPI timer value is greater than 'Ticks', the while loop 
will exit.
+  //
+  while (((Ticks - IoRead32 (TimerAddr)) & BIT23) == 0) {
+CpuPause();
+  }
+  EndTSC = AsmReadTsc ();   // TSC 
value 100us later
+
+  TscFrequency = MultU64x32 (
+   (EndTSC - StartTSC), // Number 
of TSC counts in 100us
+   1// Number 
of 100us in a second
+   );
+
+  SetInterruptState (InterruptState);
+
+  return TscFrequency;
+}
+
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c 
b/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
index 21fdb79908b8..8819ebcfccef 100644
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
@@ -1,7 +1,7 @@
 /** @file
   ACPI Timer implements one instance of Timer Library.
 
-  Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+  Copyright (c) 2013 - 2016, 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
@@ -17,6 +17,26 @@
 #include 
 
 /**
+  Calculate TSC frequency.
+
+  The TSC counting frequency is determined by comparing how far it counts
+  during a 100us period as determined by the ACPI timer. The ACPI timer is
+  used because it counts at a known frequency.
+  The TSC is sampled, followed by waiting for ACPI_TIMER_FREQUENCY / 1
+  clocks of the ACPI timer, or 100us. The TSC is then sampled again. The
+  difference multiplied by 1 is the TSC frequency. There will be a small
+  error because of the overhead of reading the ACPI timer. An attempt is
+  made to determine and compensate for this error.
+
+  @return The number of TSC counts per second.
+
+**/
+UINT64
+InternalCalculateTscFrequency (
+  VOID
+  );
+
+/**
   Internal function to retrieves the 64-bit frequency in Hz.
 
   Internal function to retrieves the 64-bit frequency in Hz.
@@ -29,14 +49,5 @@ InternalGetPerformanceCounterFrequency (
   VOID
   ) 
 {
-  BOOLEAN  InterruptState;
-  UINT64   Count;
-  UINT64   Frequency;
-  

[edk2] [patch] MdeModulePkg: Refine codes of iSCSI driver

2016-08-10 Thread Zhang Lubo
The RSDT is only used when the bios need to support ACPI 1.0
version. When change PcdAcpiExposedTableVersions to 0x3C, it
will not support ACPI 1.0. The default is 0x3E.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Eric Dong 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 .../Universal/Network/IScsiDxe/IScsiIbft.c | 35 --
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c 
b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
index e5f685f..45d89a6 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
@@ -434,42 +434,42 @@ IScsiPublishIbft (
   EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table;
   UINTN HandleCount;
   EFI_HANDLE*HandleBuffer;
   UINT8 *Heap;
   UINT8 Checksum;
-  UINTN Index;
   EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
   EFI_ACPI_DESCRIPTION_HEADER   *Rsdt;
+  EFI_ACPI_DESCRIPTION_HEADER   *Xsdt;
+
+  Rsdt = NULL;
+  Xsdt = NULL;
 
   Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID 
**)&AcpiTableProtocol);
   if (EFI_ERROR (Status)) {
 return ;
   }
 
 
   //
   // Find ACPI table RSD_PTR from system table
   //
-  for (Index = 0, Rsdp = NULL; Index < gST->NumberOfTableEntries; Index++) {
-if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi20TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi10TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpiTableGuid)
-  ) {
-  //
-  // A match was found.
-  //
-  Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) 
gST->ConfigurationTable[Index].VendorTable;
-  break;
-}
+  Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) 
&Rsdp);
+  if (EFI_ERROR (Status)) {
+Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) 
&Rsdp);
   }
 
-  if (Rsdp == NULL) {
+  if (EFI_ERROR (Status) || (Rsdp == NULL)) {
 return ;
-  } else {
+  } else if (Rsdp->Revision >= 
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 
0) {
+Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress;
+  } else if (Rsdp->RsdtAddress != 0) {
 Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;
   }
 
+  if ((Xsdt == NULL) && (Rsdt == NULL)) {
+return ;
+  }
 
   if (mIbftInstalled) {
 Status = AcpiTableProtocol->UninstallAcpiTable (
   AcpiTableProtocol,
   mTableKey
@@ -504,11 +504,16 @@ IScsiPublishIbft (
   Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET;
 
   //
   // Fill in the various section of the iSCSI Boot Firmware Table.
   //
-  IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
+  if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) 
{
+IScsiInitIbfTableHeader (Table, Xsdt->OemId, &Xsdt->OemTableId);
+  } else {
+IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
+  }
+
   IScsiInitControlSection (Table, HandleCount);
   IScsiFillInitiatorSection (Table, &Heap, HandleBuffer[0]);
   IScsiFillNICAndTargetSections (Table, &Heap, HandleCount, HandleBuffer);
 
   Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length);
-- 
1.9.5.msysgit.1

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


[edk2] [patch] NetworkPkg: Refine codes of iSCSI driver

2016-08-10 Thread Zhang Lubo
The RSDT is only used when the bios need to support ACPI 1.0
version. When change PcdAcpiExposedTableVersions to 0x3C, it
will not support ACPI 1.0. The default is 0x3E.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Eric Dong 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 NetworkPkg/IScsiDxe/IScsiIbft.c | 35 ---
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiIbft.c b/NetworkPkg/IScsiDxe/IScsiIbft.c
index 3c179bf..27d098d 100644
--- a/NetworkPkg/IScsiDxe/IScsiIbft.c
+++ b/NetworkPkg/IScsiDxe/IScsiIbft.c
@@ -454,42 +454,42 @@ IScsiPublishIbft (
   EFI_STATUSStatus;
   EFI_ACPI_TABLE_PROTOCOL   *AcpiTableProtocol;
   EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table;
   EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
   EFI_ACPI_DESCRIPTION_HEADER   *Rsdt;
+  EFI_ACPI_DESCRIPTION_HEADER   *Xsdt;
   UINT8 *Heap;
   UINT8 Checksum;
-  UINTN Index;
 
+  Rsdt = NULL;
+  Xsdt = NULL;
 
   Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) 
&AcpiTableProtocol);
   if (EFI_ERROR (Status)) {
 return ;
   }
 
   //
   // Find ACPI table RSD_PTR from the system table.
   //
-  for (Index = 0, Rsdp = NULL; Index < gST->NumberOfTableEntries; Index++) {
-if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi20TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi10TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpiTableGuid)
-  ) {
-  //
-  // A match was found.
-  //
-  Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) 
gST->ConfigurationTable[Index].VendorTable;
-  break;
-}
+  Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) 
&Rsdp);
+  if (EFI_ERROR (Status)) {
+Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) 
&Rsdp);
   }
 
-  if (Rsdp == NULL) {
+  if (EFI_ERROR (Status) || (Rsdp == NULL)) {
 return ;
-  } else {
+  } else if (Rsdp->Revision >= 
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 
0) {
+Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress;
+  } else if (Rsdp->RsdtAddress != 0) {
 Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;
   }
 
+  if ((Xsdt == NULL) && (Rsdt == NULL)) {
+return ;
+  }
+
   if (mIbftInstalled) {
 Status = AcpiTableProtocol->UninstallAcpiTable (
   AcpiTableProtocol,
   mTableKey
   );
@@ -518,11 +518,16 @@ IScsiPublishIbft (
   Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET;
 
   //
   // Fill in the various section of the iSCSI Boot Firmware Table.
   //
-  IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
+  if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) 
{
+IScsiInitIbfTableHeader (Table, Xsdt->OemId, &Xsdt->OemTableId);
+  } else {
+IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
+  }
+
   IScsiInitControlSection (Table);
   IScsiFillInitiatorSection (Table, &Heap);
   IScsiFillNICAndTargetSections (Table, &Heap);
 
   Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length);
-- 
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 08/11] Vlv2TbltDevicePkg/ResetSystemLib: Implement ResetPlatformSpecific

2016-08-10 Thread Wei, David
Reviewed-by: David Wei 

Thanks,
David  Wei 

-Original Message-
From: Ni, Ruiyu 
Sent: Wednesday, August 10, 2016 1:56 PM
To: edk2-devel@lists.01.org
Cc: Wei, David 
Subject: [PATCH 08/11] Vlv2TbltDevicePkg/ResetSystemLib: Implement 
ResetPlatformSpecific

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni 
Cc: David Wei 
---
 .../Library/ResetSystemLib/ResetSystemLib.c| 23 --
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/Vlv2TbltDevicePkg/Library/ResetSystemLib/ResetSystemLib.c 
b/Vlv2TbltDevicePkg/Library/ResetSystemLib/ResetSystemLib.c
index 1a6da83..77f1b8b 100644
--- a/Vlv2TbltDevicePkg/Library/ResetSystemLib/ResetSystemLib.c
+++ b/Vlv2TbltDevicePkg/Library/ResetSystemLib/ResetSystemLib.c
@@ -1,7 +1,6 @@
 /** @file
 
-Copyright (c) 2007  - 2014, Intel Corporation. All rights reserved.
-   


+  Copyright (c) 2007 - 2016, 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 that accompanies this 
distribution.  

   The full text of the license may be found at 


@@ -176,3 +175,23 @@ EnterS3WithImmediateWake (
   ASSERT (FALSE);
 }
 
+/**
+  This function causes a systemwide reset. The exact type of the reset is 
defined
+  by the EFI_GUID that follows the Null-terminated Unicode string passed into 
ResetData.
+  If the platform does not recognize the EFI_GUID in ResetData the platform 
must pick a
+  supported reset type to perform.The platform may optionally log the 
parameters from
+  any non-normal reset that occurs.
+
+  @param[in]  DataSize   The size, in bytes, of ResetData.
+  @param[in]  ResetData  The data buffer starts with a Null-terminated string, 
followed
+ by the EFI_GUID.
+**/
+VOID
+EFIAPI
+ResetPlatformSpecific (
+  IN UINTN   DataSize,
+  IN VOID*ResetData
+  )
+{
+  ResetCold ();
+}
-- 
2.9.0.windows.1

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


Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to DxeReportStatusCodeLib assuming the state of the BootService Memory at runtime.

2016-08-10 Thread Andrew Fish

> On Aug 10, 2016, at 6:53 PM, Zeng, Star  wrote:
> 
> If a DXE_RUNTIME_DRIVER driver just wants to report status code at boot phase 
> and links to DxeReportStatusCodeLib, is it a bug?
> 
> How about just to add notes for DxeReportStatusCodeLib like DxePcdLib.inf?
> 

Star,

This is point about lack of rules around this. I think the difference is the 
PCD protocol is defined as boot service only. I guess you could argue that 
depending on how things are constructed you could access some (FixedAtBuild) 
PCD things at runtime. 

I don't think it is a good idea to produce a runtime service that does not work 
at runtime. Mike seems to agree. 

But I agree better rules about this would be helpful. 

Thanks,

Andrew Fish

> DxePcdLib.inf:
> "
> # Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can only use 
> this DxePcdLib 
> #  in their initialization without any issues to access Dynamic and DynamicEx 
> PCD. They can't 
> #  access Dynamic and DynamicEx PCD in the implementation of runtime services 
> and SMI handlers.
> #  Because EFI_PCD_PROTOCOL is DXE protocol that is not aviable in OS runtime 
> phase.  
> "
> 
> Thanks,
> Star
> -Original Message-
> From: af...@apple.com [mailto:af...@apple.com] 
> Sent: Thursday, August 11, 2016 3:04 AM
> To: Kinney, Michael D 
> Cc: Zeng, Star ; edk2-devel 
> Subject: Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to 
> DxeReportStatusCodeLib assuming the state of the BootService Memory at 
> runtime.
> 
> 
>> On Aug 10, 2016, at 11:02 AM, Kinney, Michael D  
>> wrote:
>> 
>> 
>> 
>>> -Original Message-
>>> From: af...@apple.com [mailto:af...@apple.com]
>>> Sent: Wednesday, August 10, 2016 10:35 AM
>>> To: Kinney, Michael D 
>>> Cc: Zeng, Star ; edk2-devel 
>>> 
>>> Subject: Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due 
>>> to DxeReportStatusCodeLib assuming the state of the BootService Memory at 
>>> runtime.
>>> 
>>> 
 On Aug 10, 2016, at 10:22 AM, Kinney, Michael D 
  wrote:
 
 Hi Andrew,
 
 I am staring at the code.  Something is not right here, but I am 
 concerned that there are use cases I am not considering yet.  Here 
 is my analysis so far.
 
 Here are the lib instances I see:
 (ignoring IntelFramework ones for the purposes of this discussion).
 
 MdeModulePkg\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf(25):
 LIBRARY_CLASS = ReportStatusCodeLib|DXE_CORE DXE_DRIVER 
 DXE_RUNTIME_DRIVER
>>> DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
 
 MdeModulePkg\Library\PeiReportStatusCodeLib\PeiReportStatusCodeLib.inf(27):
 LIBRARY_CLASS = ReportStatusCodeLib|SEC PEIM PEI_CORE
 
 
>>> MdeModulePkg\Library\RuntimeDxeReportStatusCodeLib\RuntimeDxeReportSt
>>> atusCodeLib.inf(
>>> 23):
 LIBRARY_CLASS = ReportStatusCodeLib|DXE_RUNTIME_DRIVER 
 DXE_SAL_DRIVER
 
 MdeModulePkg\Library\SmmReportStatusCodeLib\SmmReportStatusCodeLib.inf(26):
 LIBRARY_CLASS = ReportStatusCodeLib|DXE_SMM_DRIVER SMM_CORE
 
 MdePkg\Library\BaseReportStatusCodeLibNull\BaseReportStatusCodeLibNull.inf(23):
 LIBRARY_CLASS = ReportStatusCodeLib
 
 * The BASE one that is a Null instance makes sense when disabling 
 Report Status
>>> Code.
 * The PEI one makes sense for its module compatibility.
 * The SMM one also makes sense its module compatibility.
 * And the RuntimeDxe one also makes sense its module compatibility.
 * The DXE one seems to be over specified and if we reduced its 
 module compatibility, the SMM and RuntimeDxe lib instances can be 
 used to cover those module types.
 
 When I look at the source code in DxeReportStatusCodeLib, I see 
 comments that describe the use case where a module is dispatched 
 before the Report Status Code Protocol is available.
 
 The use case you are describing is when the first call to Report 
 Status Code by a module occurs after ExitBootServices().  In that 
 case, we depend on the Boot Services table being zeroed to exit early.
 
 I agree that no component should depend on Boot Services table being 
 cleared to zeros at ExitBootServices().  It is legal from UEFI/PI 
 spec to not zero at all, or in your example, fill with a pattern 
 other than zeros.
 
 It appears that the use case of first call to Report Status Code 
 after
 ExitBootServices() is not covered by the DXE lib instance, and we 
 have just been getting lucky due to zeroing behavior of boot services 
 table.
 
 I can think of a couple options:
 
 * Update DXE INF to remove the DXE Runtime, DXE SAL, SMM, SMM Core 
 module types.  This may break platform builds if a platform is using 
 this lib mapping for modules of the types being removed.  However, 
 those could be considered platform DSC bugs.
 
 * Update DXE lib instance to add ExitBootServices

Re: [edk2] SATA AHCI issue

2016-08-10 Thread Tian, Feng
Hi, Shaveta

I saw the Tftp implemention of UefiShell splits the whole procedure to two 
steps, read the file from tftp sever at first, then write the file to specified 
destination.

Do you know which step gets the timeout error?

The 1st step is total irrelevant with HDD access. And I didn't see any 
difference between the 2nd steps and other common write operations. So I am 
also curious on this. I would suggest you to add debug message to Tftp.c & 
AhciMode.c to see what happens.

Thanks
Feng

-Original Message-
From: Shaveta Leekha [mailto:shaveta.lee...@nxp.com] 
Sent: Wednesday, August 10, 2016 7:50 PM
To: Tian, Feng ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Subject: RE: SATA AHCI issue

Hi Feng,

PRD table entries are 16Byte aligned, as specified by AHCI spec also, it has 4 
DWs.

I have tried two HDD, but issue is same, TIMEOUT issue.
I have also tried copying one file on SATA HDD to another file on same SATA 
HDD(filesize > 4MB), No issue occur in this scenario.

USB support is not yet there on our platform, so couldn't try that scenario.

Still not sure, where could be the issue?

Thanks and Regards,
Shaveta



-Original Message-
From: Tian, Feng [mailto:feng.t...@intel.com]
Sent: Wednesday, August 10, 2016 10:49 AM
To: Shaveta Leekha ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Cc: Tian, Feng 
Subject: RE: SATA AHCI issue

PRD entries are organized like AHCI spec Figure 13 said.

Thanks
Feng

-Original Message-
From: Shaveta Leekha [mailto:shaveta.lee...@nxp.com]
Sent: Tuesday, August 9, 2016 7:40 PM
To: Tian, Feng ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Subject: RE: SATA AHCI issue

Hi Feng,

Yes, I am using Tftp to get the file on HDD.

Have tried only one HardDisk, will try SATA disk from other vendors also, to 
get to the root cause.
Will also try copying data from SATA to SATA.

Are PRD entries aligned in EDK2 code base? (I mean they are aligned on which 
boundary? 16 Byte? 4KB?)

Best Regards,
Shaveta

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Tian, 
Feng
Sent: Tuesday, August 09, 2016 1:38 PM
To: Shaveta Leekha ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Cc: Tian, Feng 
Subject: Re: [edk2] SATA AHCI issue

Hi, Shaveta

I saw you are using TFTP cmd to do the test? Did you ever test copying file 
from  usb stick to the SATA HDD?

I just copied a 70M file from usb to SATA and from SATA to SATA. It works well.

Does this issue happen at all of your HDDs or only one specific brand model? Do 
you have other helpful info for us to narrow down?

Thanks
Feng

-Original Message-
From: Shaveta Leekha [mailto:shaveta.lee...@nxp.com]
Sent: Tuesday, August 9, 2016 4:03 PM
To: Tian, Feng ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Subject: RE: SATA AHCI issue

Hi Feng,

Complete stack is:

  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
  FatPkg/FatPei/FatPei.inf
  FatPkg/EnhancedFatDxe/Fat.inf


Best Regards,
Shaveta

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Shaveta 
Leekha
Sent: Tuesday, August 09, 2016 1:07 PM
To: Tian, Feng ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Subject: Re: [edk2] SATA AHCI issue

Hi Feng,

Yes for 30MB file, multiple PRD entries would have been created.
But I able to write file only upto 4MB size.

The protocol stack I am using is:

Generic AtaBusDxe driver use EfiAtaPassThruProtocol Generic AtaAtapiPassThru 
driver consumes "EfiIdeControllerInitProtocol" and produces 
"EfiAtaPassThruProtocol" which is consumed by generic AtaBusDxe driver 
Platform-specific SATA driver that produces "EfiIdeControllerInitProtocol

I am writing SATA HDD at File level.
HDD is formatted with FAT32 which is identified as FileSytem by FATPKG.

Snippet of writing onto SATA HDD Filesystem is pasted below.

Thanks and Regards,
Shaveta


UEFI Interactive Shell v2.1
EDK II
UEFI v2.50 (LS2080a RDB board EFI Jul 25 2016 00:00:33, 0x) Mapping 
table
  FS0: Alias(s):F6a0a:;BLK0:
  PciRoot(0x0)/Pci(0x0,0x0)/Sata(0x0,0x0,0x0)
Shell>FS0:
FS0:\> tftp 192.168.3.161 test2 test
Downloading the file 'test2'
[===>]   0 Kb

-Original Message-
From: Tian, Feng [mailto:feng.t...@intel.com]
Sent: Tuesday, August 09, 2016 8:30 AM
To: Shaveta Leekha ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Cc: Tian, Feng 
Subject: RE: SATA AHCI issue

Hi, Shaveta

No, we will create multiple PRDs if the transfer length is larger than 4M. each 
PRD could represent a 4M transfer request and the maximum number of PRD for 
each command is 65535.

How do you access the HDD? At block level or file level? It happens at all HDDs 
or only one specific brand model?

Thanks
Feng

-Origina

Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to DxeReportStatusCodeLib assuming the state of the BootService Memory at runtime.

2016-08-10 Thread Zeng, Star
If a DXE_RUNTIME_DRIVER driver just wants to report status code at boot phase 
and links to DxeReportStatusCodeLib, is it a bug?

How about just to add notes for DxeReportStatusCodeLib like DxePcdLib.inf?

DxePcdLib.inf:
"
# Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can only use 
this DxePcdLib 
#  in their initialization without any issues to access Dynamic and DynamicEx 
PCD. They can't 
#  access Dynamic and DynamicEx PCD in the implementation of runtime services 
and SMI handlers.
#  Because EFI_PCD_PROTOCOL is DXE protocol that is not aviable in OS runtime 
phase.  
"

Thanks,
Star
-Original Message-
From: af...@apple.com [mailto:af...@apple.com] 
Sent: Thursday, August 11, 2016 3:04 AM
To: Kinney, Michael D 
Cc: Zeng, Star ; edk2-devel 
Subject: Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to 
DxeReportStatusCodeLib assuming the state of the BootService Memory at runtime.


> On Aug 10, 2016, at 11:02 AM, Kinney, Michael D  
> wrote:
> 
> 
> 
>> -Original Message-
>> From: af...@apple.com [mailto:af...@apple.com]
>> Sent: Wednesday, August 10, 2016 10:35 AM
>> To: Kinney, Michael D 
>> Cc: Zeng, Star ; edk2-devel 
>> 
>> Subject: Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due 
>> to DxeReportStatusCodeLib assuming the state of the BootService Memory at 
>> runtime.
>> 
>> 
>>> On Aug 10, 2016, at 10:22 AM, Kinney, Michael D 
>>>  wrote:
>>> 
>>> Hi Andrew,
>>> 
>>> I am staring at the code.  Something is not right here, but I am 
>>> concerned that there are use cases I am not considering yet.  Here 
>>> is my analysis so far.
>>> 
>>> Here are the lib instances I see:
>>> (ignoring IntelFramework ones for the purposes of this discussion).
>>> 
>>> MdeModulePkg\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf(25):
>>> LIBRARY_CLASS = ReportStatusCodeLib|DXE_CORE DXE_DRIVER 
>>> DXE_RUNTIME_DRIVER
>> DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
>>> 
>>> MdeModulePkg\Library\PeiReportStatusCodeLib\PeiReportStatusCodeLib.inf(27):
>>> LIBRARY_CLASS = ReportStatusCodeLib|SEC PEIM PEI_CORE
>>> 
>>> 
>> MdeModulePkg\Library\RuntimeDxeReportStatusCodeLib\RuntimeDxeReportSt
>> atusCodeLib.inf(
>> 23):
>>> LIBRARY_CLASS = ReportStatusCodeLib|DXE_RUNTIME_DRIVER 
>>> DXE_SAL_DRIVER
>>> 
>>> MdeModulePkg\Library\SmmReportStatusCodeLib\SmmReportStatusCodeLib.inf(26):
>>> LIBRARY_CLASS = ReportStatusCodeLib|DXE_SMM_DRIVER SMM_CORE
>>> 
>>> MdePkg\Library\BaseReportStatusCodeLibNull\BaseReportStatusCodeLibNull.inf(23):
>>> LIBRARY_CLASS = ReportStatusCodeLib
>>> 
>>> * The BASE one that is a Null instance makes sense when disabling 
>>> Report Status
>> Code.
>>> * The PEI one makes sense for its module compatibility.
>>> * The SMM one also makes sense its module compatibility.
>>> * And the RuntimeDxe one also makes sense its module compatibility.
>>> * The DXE one seems to be over specified and if we reduced its 
>>> module compatibility, the SMM and RuntimeDxe lib instances can be 
>>> used to cover those module types.
>>> 
>>> When I look at the source code in DxeReportStatusCodeLib, I see 
>>> comments that describe the use case where a module is dispatched 
>>> before the Report Status Code Protocol is available.
>>> 
>>> The use case you are describing is when the first call to Report 
>>> Status Code by a module occurs after ExitBootServices().  In that 
>>> case, we depend on the Boot Services table being zeroed to exit early.
>>> 
>>> I agree that no component should depend on Boot Services table being 
>>> cleared to zeros at ExitBootServices().  It is legal from UEFI/PI 
>>> spec to not zero at all, or in your example, fill with a pattern 
>>> other than zeros.
>>> 
>>> It appears that the use case of first call to Report Status Code 
>>> after
>>> ExitBootServices() is not covered by the DXE lib instance, and we 
>>> have just been getting lucky due to zeroing behavior of boot services table.
>>> 
>>> I can think of a couple options:
>>> 
>>> * Update DXE INF to remove the DXE Runtime, DXE SAL, SMM, SMM Core 
>>> module types.  This may break platform builds if a platform is using 
>>> this lib mapping for modules of the types being removed.  However, 
>>> those could be considered platform DSC bugs.
>>> 
>>> * Update DXE lib instance to add ExitBootServices() and 
>>> SetVirtualAddressMap() events.  However, this would basically make 
>>> the DXE lib instance the same as the DXE Runtime instance and would 
>>> increase size of non-RT components.
>>> 
>>> I would prefer the first option, but we would need to do some 
>>> testing to see how many platform DSC files break.
>>> 
>> 
>> Mike,
>> 
>> That seems to make the most sense, but I too was worried about compatibility.
>> 
>> I tried adding the UefiRuntimeLib to just fail calls at Runtime, but 
>> that breaks the build as DXE_CORE does not support UefiRuntimeLib.
>> 
>> I guess one option would be to only add the ExitBootServices event 
>> and fail calls a

Re: [edk2] DHCP Automatic Configure at Driver Connect

2016-08-10 Thread Wu, Jiaxin
Eugene,

The default policy is static,  DHCPSB will not be installed automatically. 
Currently, there are only two cases that DHCP process will be triggered. One is 
Ip4Config2 policy change to DHCP, and another one is any IP4 configure instance 
set UseDefaultAddress to TRUE, detailed see Ip4StartAutoConfig().  So, I don't 
quite understand your question about the differs behavior compared to before. I 
think the current behavior of Ip4Config2 DHCP also need the third specifically 
configuration.

Thanks,
Jiaxin

> -Original Message-
> From: Cohen, Eugene [mailto:eug...@hp.com]
> Sent: Thursday, August 11, 2016 2:17 AM
> To: edk2-devel@lists.01.org; Wu, Jiaxin 
> Subject: DHCP Automatic Configure at Driver Connect
> 
> With this commit:
> 
> Revision: 1f6729ffe98095107ce82e67a4a0209674601a90
> Author: jiaxinwu 
> Date: 7/7/2015 2:19:55 AM
> Message:
> MdeModulePkg: Update Ip4Dxe driver to support Ip4Config2 protocol,
> 
> a new behavior seemed to come in to the network stack that was not
> present before: It appears now that as soon as the DHCP Service Binding
> protocol is installed the DHCP process will be initiated (see
> Ip4Config2OnDhcp4SbInstalled).  This differs from past behavior where DHCP
> would only occur if a driver or application specifically did Configure() on 
> the
> network interface.
> 
> For some systems this is problematic because they need to defer DHCP until
> it is certain that the network interface will be used for something.
> 
> Can you provide the reason for this change?  Can we have a policy (PCD) to
> disable this mode of operation?
> 
> Thanks,
> 
> Eugene
> 

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


[edk2] AppPkg with python enabled - build fails

2016-08-10 Thread Kottilil, Vasudevan
Hi,
I am trying to build this and seeing this error. I was able to build another 
package without any errors using the same configuration.
Thanks much.
Vasudevan Kottilil

Build environment: Linux-4.0.4-301.fc22.x86_64-x86_64-with-fedora-22-Twenty_Two
Build start time: 15:21:44, Aug.10 2016

WORKSPACE= /home/vasu/edk2
ECP_SOURCE   = /home/vasu/edk2/EdkCompatibilityPkg
EDK_SOURCE   = /home/vasu/edk2/EdkCompatibilityPkg
EFI_SOURCE   = /home/vasu/edk2/EdkCompatibilityPkg
EDK_TOOLS_PATH   = /home/vasu/edk2/BaseTools


Architecture(s)  = X64
Build target = DEBUG
Toolchain= GCC5

Active Platform  = /home/vasu/edk2/AppPkg/AppPkg.dsc

Processing meta-data .. done!
Building ... /home/vasu/edk2/MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf 
[X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf 
[X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/MdePkg/Library/BaseLib/BaseLib.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... 
/home/vasu/edk2/MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... 
/home/vasu/edk2/MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
 [X64]
make: Nothing to be done for 'tbuild'.
Building ... 
/home/vasu/edk2/MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
 [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/MdePkg/Library/BasePrintLib/BasePrintLib.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... 
/home/vasu/edk2/MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
 [X64]
make: Nothing to be done for 'tbuild'.
Building ... 
/home/vasu/edk2/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... 
/home/vasu/edk2/MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
 [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/MdePkg/Library/UefiLib/UefiLib.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... 
/home/vasu/edk2/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/AppPkg/Applications/Hello/Hello.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/Signal/Signal.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/Uefi/Devices/daUtility.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/PosixLib/Gen/LibGen.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/Uefi/Uefi.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/Time/Time.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/String/String.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/StdLib/StdLib.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/Locale/Locale.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/gdtoa/gdtoa.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/Ctype/Ctype.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/Stdio/Stdio.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/LibC.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/Containers/ContainerLib.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/Uefi/InteractiveIO/IIO.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/Wchar/Wchar.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/StdLib/LibC/Uefi/Devices/daConsole.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf 
[X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf 
[X64]
make: Nothing to be done for 'tbuild'.
Building ... 
/home/vasu/edk2/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vasu/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.inf 
[X64]
make: Nothing to be done for 'tbuild'.
Building ... 
/home/vasu/edk2/MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf 
[X64]
make: Nothing to be done for 'tbuild'.
Building ... 
/home/vasu/edk2/MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
 [X64]
make: Nothing to be done for 'tbuild'.
Building ... 
/home/vasu/edk2/MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/vas

Re: [edk2] [PATCH] ArmPkg: Fix double GIC EIOR write per interrupt

2016-08-10 Thread Cohen, Eugene
> My description was not very clear, and the point is academic if you are
> happy with the solution.

I think it's important that we're aligned on how the GIC works so thanks for 
humoring me.

> However:
> The GIC spec has a state machine diagram (Figure 4.3), where:
> Transition D, pending to active and pending
> This transition occurs on acknowledgement of the interrupt by the PE
> for level-sensitive SPIs, SGIs,
> and PPIs.
> Transition B1 or B2, remove pending state
> This transition occurs when the interrupt has been deasserted by the
> peripheral, if the interrupt is a
> level-sensitive interrupt, or when software has changed the pending
> state.
> Transition E1 or E2, remove active state
> This transition occurs when software deactivates an interrupt for SPIs,
> SGIs, and PPIs.
> 
> I suspect that because we EOI ("deactivate" for E1/E2) without
> "deasserting" the peripheral interrupt then the GIC may restore the
> pending state (transition E2 instead of B2 then E1), which will look
> remarkably like a latch.

But no latching will occur because, for a level sensitive interrupt, the 
EOI-before deassert should manifest as transition E2 (caused by EOI) followed 
by transition B1 (caused by clearing the source).  This is per the text that 
transition B1 occurs if "the level-sensitive interrupt is pending only because 
of the assertion of an input signal, and that signal is deasserted".  So the 
transition is Active+Pending -> Pending -> Inactive for this odd ordering 
versus the more sensible Active+Pending -> Active -> Inactive.

> That looks like a pretty sensible way forward.  I'll vote for EFI_SUCCESS,
> white lies are sometimes needed.

Okay, what's the worst that can happen? :)

Perhaps the real test would be that a driver that uses HwInterrupt is shown to 
work equally well on a fake-EOI interface system as well as a real-EOI 
interface system.  I doubt if we have any common peripherals (timer block or 
serial port or whatever) to really test this.

Eugene

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


Re: [edk2] [PATCH] ArmPkg: Fix double GIC EIOR write per interrupt

2016-08-10 Thread Evan Lloyd
Hi Eugene.
Some responses inline below.

>-Original Message-
>From: Cohen, Eugene [mailto:eug...@hp.com]
>Sent: 10 August 2016 20:34
>To: Evan Lloyd; Ard Biesheuvel; Heyi Guo
>Cc: Alexei Fedorov; edk2-devel@lists.01.org; Andrew Fish (af...@apple.com);
>Leif Lindholm
>Subject: RE: [edk2] [PATCH] ArmPkg: Fix double GIC EIOR write per interrupt
>
>Evan,
>
>> I'd like to re-think our GIC EIOR changes in the light of comments from
>> Heyi Guo. (inserted before Eugene's e-mail below)
>> Despite Eugene's cogent advocacy of the change, and the fact that
>> Alexei's fix is now accepted, I have come to the conclusion that it is not
>> the best thing to do.  As Heyi points out, it opens a race condition
>> where the Timer interrupt line is still asserted after the GIC EIOR has
>> been written.
>> The timer IRQ needs to be de-asserted before the EIOR write, or the
>> GIC sees the IRQ and latches it ("active and pending").
>> This is clearly an error, and a minor mystery is that we do not see that
>> on our Juno boards.
>
>According to the GIC architecture spec for level-sensitive interrupts are 
>pending
>only based on the immediate state of the signal, there is no latching, see
>"Control of the pending status of level-sensitive interrupts" in the GICv2
>Architecture Specification:
>
>"
>For an edge-triggered interrupt, the includes pending status is latched on 
>either
>a write to the GICD_ISPENDRn or
>the assertion of the interrupt signal to the GIC. However, for a 
>level-sensitive
>interrupt, the includes pending status
>either:
>  * is latched on a write to the GICD_ISPENDRn
>  * follows the state of the interrupt signal to the GIC, without any latching.
>"
>
>So there's no "memory" for level sensitive interrupts and an edge triggered
>interrupt will only latch on an edge, not an EOI so I'm not sure there's an 
>issue.

My description was not very clear, and the point is academic if you are happy 
with the solution.  However:
The GIC spec has a state machine diagram (Figure 4.3), where:
Transition D, pending to active and pending
This transition occurs on acknowledgement of the interrupt by the PE for 
level-sensitive SPIs, SGIs,
and PPIs.
Transition B1 or B2, remove pending state
This transition occurs when the interrupt has been deasserted by the 
peripheral, if the interrupt is a
level-sensitive interrupt, or when software has changed the pending state.
Transition E1 or E2, remove active state
This transition occurs when software deactivates an interrupt for SPIs, SGIs, 
and PPIs.

I suspect that because we EOI ("deactivate" for E1/E2) without "deasserting" 
the peripheral interrupt then the GIC may restore the pending state (transition 
E2 instead of B2 then E1), which will look remarkably like a latch.


>
>From what I can tell the primary purpose of EOI is for interrupt priority
>management - when you issue the EOI a priority drop occurs allowing the next-
>highest priority interrupt to be serviced, if any.  But since we are not making
>use of nested interrupts (i.e. IRQ is masked the whole time during interrupt
>processing) I don't think the EOI sequencing matters.  This is based on about 
>10
>minutes of me reading this GIC spec so please correct any confusion I may
>have.  I agree the double-EOI has to go away no matter what.
>
>> This is very much at odds with Eugene's position (which, BTW,  is not a
>> stance I find comfortable).
>> Further, it implies removing any EIOR writes from extant interrupt
>> handlers - however, since they already have the "double write"
>> problem, that is not really a concern.  (BTW, the GIC spec is very clear
>> that "A write to this register must correspond to the most recent valid
>> read from an Interrupt Acknowledge Register... otherwise the system
>> behavior is UNPREDICTABLE", so the double write is not good.)
>
>I did some detective work and the double-write problem goes way back to the
>BeagleBoard/Omap35xx code from 2010 where the NEWIRQAGR register was
>written multiple times as well.  This code actually writes the EOI-like
>NEWIRQAGR register two times in addition to the additional EOI interface
>write:
>
>  // Needed to prevent infinite nesting when Time Driver lowers TPL
>  MmioWrite32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR);
>  ArmDataSynchronizationBarrier ();
>
>  InterruptHandler = gRegisteredInterruptHandlers[Vector];
>  if (InterruptHandler != NULL) {
>// Call the registered interrupt handler.
>InterruptHandler (Vector, SystemContext);
>  }
>
>  // Needed to clear after running the handler
>  MmioWrite32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR);
>  ArmDataSynchronizationBarrier ();
>
>Note the comment about infinite nesting - I don't know what this is referring 
>to
>since I would expect TPL to remain at HIGH_LEVEL for the duration of timer
>interrupt processing.  I'd really like to get Mr. Fish to chime in on this one.
>
>> A more elegant solution is for the GIC register access to be done as
>> part of the GIC handling (i.e. revert t

Re: [edk2] [PATCH] ArmPkg: Fix double GIC EIOR write per interrupt

2016-08-10 Thread Cohen, Eugene
Evan,
 
> I'd like to re-think our GIC EIOR changes in the light of comments from
> Heyi Guo. (inserted before Eugene's e-mail below)
> Despite Eugene's cogent advocacy of the change, and the fact that
> Alexei's fix is now accepted, I have come to the conclusion that it is not
> the best thing to do.  As Heyi points out, it opens a race condition
> where the Timer interrupt line is still asserted after the GIC EIOR has
> been written.
> The timer IRQ needs to be de-asserted before the EIOR write, or the
> GIC sees the IRQ and latches it ("active and pending").
> This is clearly an error, and a minor mystery is that we do not see that
> on our Juno boards.

According to the GIC architecture spec for level-sensitive interrupts are 
pending only based on the immediate state of the signal, there is no latching, 
see "Control of the pending status of level-sensitive interrupts" in the GICv2 
Architecture Specification:

"
For an edge-triggered interrupt, the includes pending status is latched on 
either a write to the GICD_ISPENDRn or
the assertion of the interrupt signal to the GIC. However, for a 
level-sensitive interrupt, the includes pending status
either:
  • is latched on a write to the GICD_ISPENDRn
  • follows the state of the interrupt signal to the GIC, without any latching.
"

So there's no "memory" for level sensitive interrupts and an edge triggered 
interrupt will only latch on an edge, not an EOI so I'm not sure there's an 
issue.

>From what I can tell the primary purpose of EOI is for interrupt priority 
>management - when you issue the EOI a priority drop occurs allowing the 
>next-highest priority interrupt to be serviced, if any.  But since we are not 
>making use of nested interrupts (i.e. IRQ is masked the whole time during 
>interrupt processing) I don't think the EOI sequencing matters.  This is based 
>on about 10 minutes of me reading this GIC spec so please correct any 
>confusion I may have.  I agree the double-EOI has to go away no matter what.

> This is very much at odds with Eugene's position (which, BTW,  is not a
> stance I find comfortable).
> Further, it implies removing any EIOR writes from extant interrupt
> handlers - however, since they already have the "double write"
> problem, that is not really a concern.  (BTW, the GIC spec is very clear
> that "A write to this register must correspond to the most recent valid
> read from an Interrupt Acknowledge Register... otherwise the system
> behavior is UNPREDICTABLE", so the double write is not good.)

I did some detective work and the double-write problem goes way back to the 
BeagleBoard/Omap35xx code from 2010 where the NEWIRQAGR register was written 
multiple times as well.  This code actually writes the EOI-like NEWIRQAGR 
register two times in addition to the additional EOI interface write:

  // Needed to prevent infinite nesting when Time Driver lowers TPL
  MmioWrite32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR);
  ArmDataSynchronizationBarrier ();

  InterruptHandler = gRegisteredInterruptHandlers[Vector];
  if (InterruptHandler != NULL) {
// Call the registered interrupt handler.
InterruptHandler (Vector, SystemContext);
  }

  // Needed to clear after running the handler
  MmioWrite32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR);
  ArmDataSynchronizationBarrier ();

Note the comment about infinite nesting - I don't know what this is referring 
to since I would expect TPL to remain at HIGH_LEVEL for the duration of timer 
interrupt processing.  I'd really like to get Mr. Fish to chime in on this one.

> A more elegant solution is for the GIC register access to be done as
> part of the GIC handling (i.e. revert the GIC code, and remove the EIOR
> from the Timer handling.)  This also caters for any surreptitious use of
> other interrupts "under the covers".
> As an additional benefit, it clearly partitions the peripheral specific
> handling from the GIC interface.

I have no specific objection to this - let's just find a way to do this that 
maintains compatibility with the existing HardwareInterrupt protocol definition 
- maybe return EFI_UNSUPPORTED (or perhaps just EFI_SUCCESS) for the EOI 
protocol interface on systems that don't want to expose this functionality.  
Then an old driver could try to use the EOI interface and on old systems it 
will issue the EOI and on new systems it will do nothing, deferring the real 
EOI to when the ISR returns.

Eugene

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


Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to DxeReportStatusCodeLib assuming the state of the BootService Memory at runtime.

2016-08-10 Thread Andrew Fish

> On Aug 10, 2016, at 11:02 AM, Kinney, Michael D  
> wrote:
> 
> 
> 
>> -Original Message-
>> From: af...@apple.com [mailto:af...@apple.com]
>> Sent: Wednesday, August 10, 2016 10:35 AM
>> To: Kinney, Michael D 
>> Cc: Zeng, Star ; edk2-devel 
>> Subject: Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to
>> DxeReportStatusCodeLib assuming the state of the BootService Memory at 
>> runtime.
>> 
>> 
>>> On Aug 10, 2016, at 10:22 AM, Kinney, Michael D 
>>>  wrote:
>>> 
>>> Hi Andrew,
>>> 
>>> I am staring at the code.  Something is not right here, but I am
>>> concerned that there are use cases I am not considering yet.  Here
>>> is my analysis so far.
>>> 
>>> Here are the lib instances I see:
>>> (ignoring IntelFramework ones for the purposes of this discussion).
>>> 
>>> MdeModulePkg\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf(25):
>>> LIBRARY_CLASS = ReportStatusCodeLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER
>> DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
>>> 
>>> MdeModulePkg\Library\PeiReportStatusCodeLib\PeiReportStatusCodeLib.inf(27):
>>> LIBRARY_CLASS = ReportStatusCodeLib|SEC PEIM PEI_CORE
>>> 
>>> 
>> MdeModulePkg\Library\RuntimeDxeReportStatusCodeLib\RuntimeDxeReportStatusCodeLib.inf(
>> 23):
>>> LIBRARY_CLASS = ReportStatusCodeLib|DXE_RUNTIME_DRIVER DXE_SAL_DRIVER
>>> 
>>> MdeModulePkg\Library\SmmReportStatusCodeLib\SmmReportStatusCodeLib.inf(26):
>>> LIBRARY_CLASS = ReportStatusCodeLib|DXE_SMM_DRIVER SMM_CORE
>>> 
>>> MdePkg\Library\BaseReportStatusCodeLibNull\BaseReportStatusCodeLibNull.inf(23):
>>> LIBRARY_CLASS = ReportStatusCodeLib
>>> 
>>> * The BASE one that is a Null instance makes sense when disabling Report 
>>> Status
>> Code.
>>> * The PEI one makes sense for its module compatibility.
>>> * The SMM one also makes sense its module compatibility.
>>> * And the RuntimeDxe one also makes sense its module compatibility.
>>> * The DXE one seems to be over specified and if we reduced its module
>>> compatibility, the SMM and RuntimeDxe lib instances can be used to cover
>>> those module types.
>>> 
>>> When I look at the source code in DxeReportStatusCodeLib, I see comments
>>> that describe the use case where a module is dispatched before the Report
>>> Status Code Protocol is available.
>>> 
>>> The use case you are describing is when the first call to Report Status
>>> Code by a module occurs after ExitBootServices().  In that case, we
>>> depend on the Boot Services table being zeroed to exit early.
>>> 
>>> I agree that no component should depend on Boot Services table being
>>> cleared to zeros at ExitBootServices().  It is legal from UEFI/PI spec
>>> to not zero at all, or in your example, fill with a pattern other than
>>> zeros.
>>> 
>>> It appears that the use case of first call to Report Status Code after
>>> ExitBootServices() is not covered by the DXE lib instance, and we have
>>> just been getting lucky due to zeroing behavior of boot services table.
>>> 
>>> I can think of a couple options:
>>> 
>>> * Update DXE INF to remove the DXE Runtime, DXE SAL, SMM, SMM Core module
>>> types.  This may break platform builds if a platform is using this lib
>>> mapping for modules of the types being removed.  However, those could
>>> be considered platform DSC bugs.
>>> 
>>> * Update DXE lib instance to add ExitBootServices() and 
>>> SetVirtualAddressMap()
>>> events.  However, this would basically make the DXE lib instance the
>>> same as the DXE Runtime instance and would increase size of non-RT
>>> components.
>>> 
>>> I would prefer the first option, but we would need to do some testing to
>>> see how many platform DSC files break.
>>> 
>> 
>> Mike,
>> 
>> That seems to make the most sense, but I too was worried about compatibility.
>> 
>> I tried adding the UefiRuntimeLib to just fail calls at Runtime, but that 
>> breaks the
>> build as DXE_CORE does not support UefiRuntimeLib.
>> 
>> I guess one option would be to only add the ExitBootServices event and fail 
>> calls at
>> runtime?
> 
> I agree this would remove the assumption that the boot services table is 
> zeroed.
> However, the only way this function can be called after ExitBootServices() is
> if the module is DXE_RUNTIME_DRIVER, DXE_SAL_DRIVER, or DXE_SMM_DRIVER.  If a 
> module is one of these types and they call Report Status Code, then they would
> want the status code to go out.  The current behavior of this lib instance
> silently ignores all status codes after ExitBootServices().  This silent 
> filtering
> is not good, and may be a good reason to move ahead with the first option and
> fix the platform DSC files.
> 

Mike,

I have to admit the assumption that it works at runtime is how I hit this issue 
in the first place so I'm fine with restricting the usage. 

I guess the rule is:
1) For BootServices only libraries it is OK to map as Runtime Services as there 
is an assumption that the calls will only be made at boot services time.
2) For RuntimeServices

Re: [edk2] [PATCH 12/26] ArmPkg/ArmLib: switch to ASM_FUNC() asm macro

2016-08-10 Thread Leif Lindholm
On Wed, Aug 10, 2016 at 05:17:48PM +0200, Ard Biesheuvel wrote:
> Annotate functions with ASM_FUNC() so that they are emitted into
> separate sections.

Also changes ConstantToReg -> MOV32.
Add a note on this to commit message and:
Reviewed-by: Leif Lindholm 

> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel 
> ---
>  ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimerSupport.S |  67 ---
>  ArmPkg/Library/ArmLib/AArch64/AArch64Support.S  | 121 
> +++-
>  ArmPkg/Library/ArmLib/AArch64/ArmLibSupportV8.S |  43 +++
>  ArmPkg/Library/ArmLib/ArmV7/ArmLibSupportV7.S   |  47 +++-
>  ArmPkg/Library/ArmLib/ArmV7/ArmV7ArchTimerSupport.S |  67 ---
>  ArmPkg/Library/ArmLib/ArmV7/ArmV7Support.S  | 113 
> ++
>  ArmPkg/Library/ArmLib/Common/AArch64/ArmLibSupport.S|  78 -
>  ArmPkg/Library/ArmLib/Common/Arm/ArmLibSupport.S|  89 +-
>  ArmPkg/Library/ArmLib/Common/Arm/ArmLibSupport.asm  |   4 +-
>  9 files changed, 205 insertions(+), 424 deletions(-)
> 
> diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimerSupport.S 
> b/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimerSupport.S
> index 3944d8bcb4f1..59e0bc9a0794 100644
> --- a/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimerSupport.S
> +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimerSupport.S
> @@ -1,6 +1,7 @@
>  
> #--
>  #
>  # Copyright (c) 2011 - 2013, ARM Limited. All rights reserved.
> +# Copyright (c) 2016, Linaro Limited. All rights reserved.
>  #
>  # This program and the accompanying materials
>  # are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -12,127 +13,105 @@
>  #
>  
> #--
>  
> -.text
> -.align 2
> -
> -GCC_ASM_EXPORT(ArmReadCntFrq)
> -GCC_ASM_EXPORT(ArmWriteCntFrq)
> -GCC_ASM_EXPORT(ArmReadCntPct)
> -GCC_ASM_EXPORT(ArmReadCntkCtl)
> -GCC_ASM_EXPORT(ArmWriteCntkCtl)
> -GCC_ASM_EXPORT(ArmReadCntpTval)
> -GCC_ASM_EXPORT(ArmWriteCntpTval)
> -GCC_ASM_EXPORT(ArmReadCntpCtl)
> -GCC_ASM_EXPORT(ArmWriteCntpCtl)
> -GCC_ASM_EXPORT(ArmReadCntvTval)
> -GCC_ASM_EXPORT(ArmWriteCntvTval)
> -GCC_ASM_EXPORT(ArmReadCntvCtl)
> -GCC_ASM_EXPORT(ArmWriteCntvCtl)
> -GCC_ASM_EXPORT(ArmReadCntvCt)
> -GCC_ASM_EXPORT(ArmReadCntpCval)
> -GCC_ASM_EXPORT(ArmWriteCntpCval)
> -GCC_ASM_EXPORT(ArmReadCntvCval)
> -GCC_ASM_EXPORT(ArmWriteCntvCval)
> -GCC_ASM_EXPORT(ArmReadCntvOff)
> -GCC_ASM_EXPORT(ArmWriteCntvOff)
> -
> -ASM_PFX(ArmReadCntFrq):
> +#include 
> +
> +ASM_FUNC(ArmReadCntFrq)
>mrs   x0, cntfrq_el0   // Read CNTFRQ
>ret
>  
>  
>  # NOTE - Can only write while at highest implemented EL level (EL3 on 
> model). Else ReadOnly (EL2, EL1, EL0)
> -ASM_PFX(ArmWriteCntFrq):
> +ASM_FUNC(ArmWriteCntFrq)
>msr   cntfrq_el0, x0   // Write to CNTFRQ
>ret
>  
>  
> -ASM_PFX(ArmReadCntPct):
> +ASM_FUNC(ArmReadCntPct)
>mrs   x0, cntpct_el0   // Read CNTPCT (Physical counter register)
>ret
>  
>  
> -ASM_PFX(ArmReadCntkCtl):
> +ASM_FUNC(ArmReadCntkCtl)
>mrs   x0, cntkctl_el1  // Read CNTK_CTL (Timer PL1 Control 
> Register)
>ret
>  
>  
> -ASM_PFX(ArmWriteCntkCtl):
> +ASM_FUNC(ArmWriteCntkCtl)
>msr   cntkctl_el1, x0  // Write to CNTK_CTL (Timer PL1 Control 
> Register)
>ret
>  
>  
> -ASM_PFX(ArmReadCntpTval):
> +ASM_FUNC(ArmReadCntpTval)
>mrs   x0, cntp_tval_el0// Read CNTP_TVAL (PL1 physical timer value 
> register)
>ret
>  
>  
> -ASM_PFX(ArmWriteCntpTval):
> +ASM_FUNC(ArmWriteCntpTval)
>msr   cntp_tval_el0, x0// Write to CNTP_TVAL (PL1 physical timer 
> value register)
>ret
>  
>  
> -ASM_PFX(ArmReadCntpCtl):
> +ASM_FUNC(ArmReadCntpCtl)
>mrs   x0, cntp_ctl_el0 // Read CNTP_CTL (PL1 Physical Timer 
> Control Register)
>ret
>  
>  
> -ASM_PFX(ArmWriteCntpCtl):
> +ASM_FUNC(ArmWriteCntpCtl)
>msr   cntp_ctl_el0, x0 // Write to  CNTP_CTL (PL1 Physical Timer 
> Control Register)
>ret
>  
>  
> -ASM_PFX(ArmReadCntvTval):
> +ASM_FUNC(ArmReadCntvTval)
>mrs   x0, cntv_tval_el0// Read CNTV_TVAL (Virtual Timer Value 
> register)
>ret
>  
>  
> -ASM_PFX(ArmWriteCntvTval):
> +ASM_FUNC(ArmWriteCntvTval)
>msr   cntv_tval_el0, x0// Write to CNTV_TVAL (Virtual Timer Value 
> register)
>ret
>  
>  
> -ASM_PFX(ArmReadCntvCtl):
> +ASM_FUNC(ArmReadCntvCtl)
>mrs   x0, cntv_ctl_el0 // Read CNTV_CTL (Virtual Timer Control 
> Register)
>ret
>  
>  
> -ASM_PFX(ArmWriteCntvCtl):
> +ASM_FUNC(ArmWriteCntvCtl)
>msr   cntv_ctl_el0, x0 // Write to CNTV_CTL (Virtual Timer Control 
> Register)
>ret
>  
>  
> -ASM_PFX(ArmReadCntvCt):
> +ASM_FUNC(ArmReadCntvCt)
>mrs  x0, cntvct_el0// Read CNTVCT  (Virtual Count Register)
>ret
>  
>  
> -ASM_P

Re: [edk2] [PATCH 05/26] ArmPkg: introduce ASM_FUNC, MOV32/MOV64 and ADRL/LDRL macros

2016-08-10 Thread Cohen, Eugene
> > Why does this work?  In my experimentation the C preprocessor
> would collapse the stuff onto a single line (the backslash being a
> continuation on the preprocessor input, but preprocessor output
> revealed the newlines being removed), thereby violating the assembly
> requirement that labels appear in column 1.
> >
> 
> I have tested this with both GNU as and Clang, and neither complains.
> Is this requirement documented anywhere?

Not sure - just the dusty recesses of my mind.  That and the fact that I 
thought I tried this already.  :)

Reviewed-by: Eugene Cohen 

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


Re: [edk2] [PATCH 05/26] ArmPkg: introduce ASM_FUNC, MOV32/MOV64 and ADRL/LDRL macros

2016-08-10 Thread Ard Biesheuvel
On 10 August 2016 at 20:26, Cohen, Eugene  wrote:
> Ard,
>
>> +#define _ASM_FUNC(Name, Section)\
>> +  .global   Name  ; \
>> +  .section  #Section, "ax"; \
>> +  .type Name, %function   ; \
>> +  Name:
>> +
>> +#define ASM_FUNC(Name)_ASM_FUNC(ASM_PFX(Name),
>> .text. ## Name)
>
> Why does this work?  In my experimentation the C preprocessor would collapse 
> the stuff onto a single line (the backslash being a continuation on the 
> preprocessor input, but preprocessor output revealed the newlines being 
> removed), thereby violating the assembly requirement that labels appear in 
> column 1.
>

I have tested this with both GNU as and Clang, and neither complains.
Is this requirement documented anywhere?

> Thanks for all your work on this, now I'm just trying to understand what I'm 
> looking at!
>

Sure, my pleasure :-)
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 05/26] ArmPkg: introduce ASM_FUNC, MOV32/MOV64 and ADRL/LDRL macros

2016-08-10 Thread Cohen, Eugene
Ard,

> +#define _ASM_FUNC(Name, Section)\
> +  .global   Name  ; \
> +  .section  #Section, "ax"; \
> +  .type Name, %function   ; \
> +  Name:
> +
> +#define ASM_FUNC(Name)_ASM_FUNC(ASM_PFX(Name),
> .text. ## Name)

Why does this work?  In my experimentation the C preprocessor would collapse 
the stuff onto a single line (the backslash being a continuation on the 
preprocessor input, but preprocessor output revealed the newlines being 
removed), thereby violating the assembly requirement that labels appear in 
column 1.

Thanks for all your work on this, now I'm just trying to understand what I'm 
looking at!

Eugene

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


[edk2] DHCP Automatic Configure at Driver Connect

2016-08-10 Thread Cohen, Eugene
With this commit:

Revision: 1f6729ffe98095107ce82e67a4a0209674601a90
Author: jiaxinwu 
Date: 7/7/2015 2:19:55 AM
Message:
MdeModulePkg: Update Ip4Dxe driver to support Ip4Config2 protocol,

a new behavior seemed to come in to the network stack that was not present 
before: It appears now that as soon as the DHCP Service Binding protocol is 
installed the DHCP process will be initiated (see 
Ip4Config2OnDhcp4SbInstalled).  This differs from past behavior where DHCP 
would only occur if a driver or application specifically did Configure() on the 
network interface.

For some systems this is problematic because they need to defer DHCP until it 
is certain that the network interface will be used for something.

Can you provide the reason for this change?  Can we have a policy (PCD) to 
disable this mode of operation?

Thanks,

Eugene


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


[edk2] IP4 Config Troubles with DHCP

2016-08-10 Thread Cohen, Eugene
We have been running into an issue when trying to configure an interface as 
DHCP where if the DHCP process is not yet complete (Ip4Mode.IsConfigured is 
FALSE) the configure process will never succeed.

We have a case where we attempt to invoke the UDP4 Configure:

Status = Nlc->Udp4->Configure(Nlc->Udp4, &Nlc->UdpConfig);

We had a retry loop where we keep calling Udp4->Configure until we finally see 
Ip4Mode.IsConfigured go TRUE (similar to what you see in Mtftp4GetMapping) - 
this has worked for many years but recently something broke this.   Now, even 
when DHCP succeeds the Ip4Mode.IsConfigured flag is set to FALSE.  

Only if we retry by destroying and re-creating new service binding children can 
we actually get this logic to succeed.  This logic is getting ridiculously 
complicated so I'm thinking there has to be a better way of doing this.

Do you have an example of specifically how a driver/app should handle the case 
where the DHCP process is not yet complete and wants to wait?

Thanks,

Eugene



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


Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to DxeReportStatusCodeLib assuming the state of the BootService Memory at runtime.

2016-08-10 Thread Kinney, Michael D


> -Original Message-
> From: af...@apple.com [mailto:af...@apple.com]
> Sent: Wednesday, August 10, 2016 10:35 AM
> To: Kinney, Michael D 
> Cc: Zeng, Star ; edk2-devel 
> Subject: Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to
> DxeReportStatusCodeLib assuming the state of the BootService Memory at 
> runtime.
> 
> 
> > On Aug 10, 2016, at 10:22 AM, Kinney, Michael D 
> >  wrote:
> >
> > Hi Andrew,
> >
> > I am staring at the code.  Something is not right here, but I am
> > concerned that there are use cases I am not considering yet.  Here
> > is my analysis so far.
> >
> > Here are the lib instances I see:
> > (ignoring IntelFramework ones for the purposes of this discussion).
> >
> > MdeModulePkg\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf(25):
> >  LIBRARY_CLASS = ReportStatusCodeLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER
> DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
> >
> > MdeModulePkg\Library\PeiReportStatusCodeLib\PeiReportStatusCodeLib.inf(27):
> >  LIBRARY_CLASS = ReportStatusCodeLib|SEC PEIM PEI_CORE
> >
> >
> MdeModulePkg\Library\RuntimeDxeReportStatusCodeLib\RuntimeDxeReportStatusCodeLib.inf(
> 23):
> >  LIBRARY_CLASS = ReportStatusCodeLib|DXE_RUNTIME_DRIVER DXE_SAL_DRIVER
> >
> > MdeModulePkg\Library\SmmReportStatusCodeLib\SmmReportStatusCodeLib.inf(26):
> >  LIBRARY_CLASS = ReportStatusCodeLib|DXE_SMM_DRIVER SMM_CORE
> >
> > MdePkg\Library\BaseReportStatusCodeLibNull\BaseReportStatusCodeLibNull.inf(23):
> >  LIBRARY_CLASS = ReportStatusCodeLib
> >
> > * The BASE one that is a Null instance makes sense when disabling Report 
> > Status
> Code.
> > * The PEI one makes sense for its module compatibility.
> > * The SMM one also makes sense its module compatibility.
> > * And the RuntimeDxe one also makes sense its module compatibility.
> > * The DXE one seems to be over specified and if we reduced its module
> >  compatibility, the SMM and RuntimeDxe lib instances can be used to cover
> >  those module types.
> >
> > When I look at the source code in DxeReportStatusCodeLib, I see comments
> > that describe the use case where a module is dispatched before the Report
> > Status Code Protocol is available.
> >
> > The use case you are describing is when the first call to Report Status
> > Code by a module occurs after ExitBootServices().  In that case, we
> > depend on the Boot Services table being zeroed to exit early.
> >
> > I agree that no component should depend on Boot Services table being
> > cleared to zeros at ExitBootServices().  It is legal from UEFI/PI spec
> > to not zero at all, or in your example, fill with a pattern other than
> > zeros.
> >
> > It appears that the use case of first call to Report Status Code after
> > ExitBootServices() is not covered by the DXE lib instance, and we have
> > just been getting lucky due to zeroing behavior of boot services table.
> >
> > I can think of a couple options:
> >
> > * Update DXE INF to remove the DXE Runtime, DXE SAL, SMM, SMM Core module
> >  types.  This may break platform builds if a platform is using this lib
> >  mapping for modules of the types being removed.  However, those could
> >  be considered platform DSC bugs.
> >
> > * Update DXE lib instance to add ExitBootServices() and 
> > SetVirtualAddressMap()
> >  events.  However, this would basically make the DXE lib instance the
> >  same as the DXE Runtime instance and would increase size of non-RT
> >  components.
> >
> > I would prefer the first option, but we would need to do some testing to
> > see how many platform DSC files break.
> >
> 
> Mike,
> 
> That seems to make the most sense, but I too was worried about compatibility.
> 
> I tried adding the UefiRuntimeLib to just fail calls at Runtime, but that 
> breaks the
> build as DXE_CORE does not support UefiRuntimeLib.
> 
> I guess one option would be to only add the ExitBootServices event and fail 
> calls at
> runtime?

I agree this would remove the assumption that the boot services table is zeroed.
However, the only way this function can be called after ExitBootServices() is
if the module is DXE_RUNTIME_DRIVER, DXE_SAL_DRIVER, or DXE_SMM_DRIVER.  If a 
module is one of these types and they call Report Status Code, then they would
want the status code to go out.  The current behavior of this lib instance
silently ignores all status codes after ExitBootServices().  This silent 
filtering
is not good, and may be a good reason to move ahead with the first option and
fix the platform DSC files.

> 
> Thanks,
> 
> Andrew Fish
> 
> > Mike
> >
> >> -Original Message-
> >> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> >> Andrew Fish
> >> Sent: Tuesday, August 9, 2016 7:50 AM
> >> To: Zeng, Star 
> >> Cc: edk2-devel 
> >> Subject: Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to
> >> DxeReportStatusCodeLib assuming the state of the BootService Memory at 
> >> runtime.
> >>
> >>
> >>> On Aug 8, 2016, at 7:26 PM, Zen

Re: [edk2] [PATCH] ArmPkg: Fix double GIC EIOR write per interrupt

2016-08-10 Thread Evan Lloyd
Hi.
(Note - this is not "top-posting", it is a discussion point, with references 
appended.)

I'd like to re-think our GIC EIOR changes in the light of comments from Heyi 
Guo. (inserted before Eugene's e-mail below)
Despite Eugene's cogent advocacy of the change, and the fact that Alexei's fix 
is now accepted, I have come to the conclusion that it is not the best thing to 
do.  As Heyi points out, it opens a race condition where the Timer interrupt 
line is still asserted after the GIC EIOR has been written.
The timer IRQ needs to be de-asserted before the EIOR write, or the GIC sees 
the IRQ and latches it ("active and pending").
This is clearly an error, and a minor mystery is that we do not see that on our 
Juno boards.

A more elegant solution is for the GIC register access to be done as part of 
the GIC handling (i.e. revert the GIC code, and remove the EIOR from the Timer 
handling.)  This also caters for any surreptitious use of other interrupts 
"under the covers".
As an additional benefit, it clearly partitions the peripheral specific 
handling from the GIC interface.

This is very much at odds with Eugene's position (which, BTW,  is not a stance 
I find comfortable).
Further, it implies removing any EIOR writes from extant interrupt handlers - 
however, since they already have the "double write" problem, that is not really 
a concern.  (BTW, the GIC spec is very clear that "A write to this register 
must correspond to the most recent valid read from an Interrupt Acknowledge 
Register... otherwise the system behavior is UNPREDICTABLE", so the double 
write is not good.)

Does anyone know of a concrete reason why we should not restore the EOI to the 
GIC handling and remove it from the timer ISR?
Eugene - you express a strongly reasoned case - can I talk you round here?

Regards,
Evan

> Hi Alexei,
>
> Thanks for your explanation. However, when I tested it on D02, it didn't act 
> as expected, i.e. we did see a subsequent interrupt triggered >immediately 
> when gBS->RestoreTPL was called in which IRQ is enabled, and I had set timer 
> interrupt period to some fairly large value (e.g. 5 >seconds).
>
> So I'd like to confirm, is it declared in GIC specification that clearing 
> interrupt source will also clear pending status in GICD?
>
> Thanks and regards.
>
> Heyi

...
> From: Linaro-uefi [mailto:linaro-uefi-boun...@lists.linaro.org] On Behalf Of 
> Heyi Guo
> Sent: 02 August 2016 02:28
> To: Ard Biesheuvel
> Cc: Linaro UEFI Mailman List
> Subject: Re: [Linaro-uefi] [linaro-uefi] Two write to EOIR in a single 
> interrupt
>
> Hi Leif and Ard,
>
> There might be another issue in timer interrupt handler. Timer interrupt 
> seems to be level triggered, so is it OK to write EOIR before clearing the > 
> > > interrupt source, i.e. updating compare value register?
>
> Heyi

>-Original Message-
>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ard
>Biesheuvel
>Sent: 08 August 2016 14:51
>To: Cohen, Eugene
>Cc: Alexei Fedorov; edk2-devel@lists.01.org; Leif Lindholm; Andrew Fish
>(af...@apple.com); Heyi Guo
>Subject: Re: [edk2] [PATCH] ArmPkg: Fix double GIC EIOR write per interrupt
>
>On 8 August 2016 at 15:42, Ard Biesheuvel  wrote:
>> On 8 August 2016 at 15:22, Cohen, Eugene  wrote:
>>> Guys, sorry to join so late, something about timezones...  Let me try to
>provide some context and history.
>>>
 > it does change the contract we have with registered interrupt handlers

 Looks like it does not:
 From edk2\EmbeddedPkg\Include\Protocol\HardwareInterrupt.h:

 " Abstraction for hardware based interrupt routine

   ...The driver implementing
   this protocol is responsible for clearing the pending interrupt in the
   interrupt routing hardware. The HARDWARE_INTERRUPT_HANDLER is
 responsible
   for clearing interrupt sources from individual devices."
>>>
>>> I think you are reading more deeply into this verbiage than was intended.
>From a separation-of-concerns perspective one driver is concerned with writing
>to the hardware that generates the interrupt (handler) and another is
>concerned with writing to the hardware for the interrupt controller to signal
>the end of interrupt.  So all this is saying is that "the code that touches the
>interrupt controller is implemented in the driver that publishes this 
>protocol".  It
>does not say how this code is activated, only who is responsible for poking the
>register.
>>>
>>> The historical expectation is that the handler driver calls the EOI 
>>> interface in
>the protocol.  (If it was the opposite then this interface wouldn't even exist
>since the interrupt controller driver could just do it implicitly.)  You're 
>next
>question will probably be why it was designed this way - for that we'll have to
>ask Andrew Fish (added).
>>>
>>> I did a little digging and see that the PC-AT chipset implemented an 8259
>interrupt protocol (IntelFrameworkPkg\Include\Protocol\Legacy8259.h) that is
>qu

Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to DxeReportStatusCodeLib assuming the state of the BootService Memory at runtime.

2016-08-10 Thread Andrew Fish

> On Aug 10, 2016, at 10:22 AM, Kinney, Michael D  
> wrote:
> 
> Hi Andrew,
> 
> I am staring at the code.  Something is not right here, but I am 
> concerned that there are use cases I am not considering yet.  Here
> is my analysis so far.
> 
> Here are the lib instances I see: 
> (ignoring IntelFramework ones for the purposes of this discussion).
> 
> MdeModulePkg\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf(25):  
>  LIBRARY_CLASS = ReportStatusCodeLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER 
> DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
> 
> MdeModulePkg\Library\PeiReportStatusCodeLib\PeiReportStatusCodeLib.inf(27):
>  LIBRARY_CLASS = ReportStatusCodeLib|SEC PEIM PEI_CORE
> 
> MdeModulePkg\Library\RuntimeDxeReportStatusCodeLib\RuntimeDxeReportStatusCodeLib.inf(23):
>  LIBRARY_CLASS = ReportStatusCodeLib|DXE_RUNTIME_DRIVER DXE_SAL_DRIVER
> 
> MdeModulePkg\Library\SmmReportStatusCodeLib\SmmReportStatusCodeLib.inf(26):
>  LIBRARY_CLASS = ReportStatusCodeLib|DXE_SMM_DRIVER SMM_CORE
> 
> MdePkg\Library\BaseReportStatusCodeLibNull\BaseReportStatusCodeLibNull.inf(23):
>  LIBRARY_CLASS = ReportStatusCodeLib
> 
> * The BASE one that is a Null instance makes sense when disabling Report 
> Status Code.
> * The PEI one makes sense for its module compatibility.
> * The SMM one also makes sense its module compatibility.
> * And the RuntimeDxe one also makes sense its module compatibility.
> * The DXE one seems to be over specified and if we reduced its module 
>  compatibility, the SMM and RuntimeDxe lib instances can be used to cover 
>  those module types.
> 
> When I look at the source code in DxeReportStatusCodeLib, I see comments
> that describe the use case where a module is dispatched before the Report
> Status Code Protocol is available.
> 
> The use case you are describing is when the first call to Report Status 
> Code by a module occurs after ExitBootServices().  In that case, we 
> depend on the Boot Services table being zeroed to exit early.
> 
> I agree that no component should depend on Boot Services table being 
> cleared to zeros at ExitBootServices().  It is legal from UEFI/PI spec 
> to not zero at all, or in your example, fill with a pattern other than
> zeros.
> 
> It appears that the use case of first call to Report Status Code after
> ExitBootServices() is not covered by the DXE lib instance, and we have
> just been getting lucky due to zeroing behavior of boot services table.
> 
> I can think of a couple options:
> 
> * Update DXE INF to remove the DXE Runtime, DXE SAL, SMM, SMM Core module
>  types.  This may break platform builds if a platform is using this lib
>  mapping for modules of the types being removed.  However, those could
>  be considered platform DSC bugs.
> 
> * Update DXE lib instance to add ExitBootServices() and SetVirtualAddressMap()
>  events.  However, this would basically make the DXE lib instance the
>  same as the DXE Runtime instance and would increase size of non-RT 
>  components.
> 
> I would prefer the first option, but we would need to do some testing to
> see how many platform DSC files break.
> 

Mike,

That seems to make the most sense, but I too was worried about compatibility. 

I tried adding the UefiRuntimeLib to just fail calls at Runtime, but that 
breaks the build as DXE_CORE does not support UefiRuntimeLib.

I guess one option would be to only add the ExitBootServices event and fail 
calls at runtime? 

Thanks,

Andrew Fish

> Mike
> 
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
>> Andrew Fish
>> Sent: Tuesday, August 9, 2016 7:50 AM
>> To: Zeng, Star 
>> Cc: edk2-devel 
>> Subject: Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to
>> DxeReportStatusCodeLib assuming the state of the BootService Memory at 
>> runtime.
>> 
>> 
>>> On Aug 8, 2016, at 7:26 PM, Zeng, Star  wrote:
>>> 
>>> On 2016/8/9 10:07, Andrew Fish wrote:
 
> On Aug 8, 2016, at 6:21 PM, Zeng, Star  wrote:
> 
> Andrew,
> 
> Should MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib be used for 
> your case
>> if there are really runtime status code reporting needed?
> 
 
 Star,
 
 If the Library instance does not fully support DXE_RUNTIME_DRIVER, why is 
 it
>> listed in the LIBRARY_CLASS as supported?
>>> 
>>> This kind of library can support DXE_RUNTIME_DRIVER at boot time, for 
>>> example
>> UefiHiiLib, UefiHiiServicesLib, UefiBootServicesTableLib, DxePcdLib and etc.
>>> 
>> 
>> Star,
>> 
>> I understand giving access to Boot Services resources to a Runtime Driver 
>> for its
>> constructor. I think the difference here is the DxeReportStatusCodeLib is 
>> abstracting
>> a runtime service, but not doing it in a way to really works properly at 
>> runtime in
>> all cases. I would expect that a library abstraction a runtime feature would 
>> work at
>> runtime. Which is why I ended up with a "bad" mapping in the first place.
>

Re: [edk2] [PATCH 11/11] MdeModulePkg/ResetSystemRuntimeDxe: Support EfiResetPlatformSpecific

2016-08-10 Thread Jordan Justen
On 2016-08-09 22:56:11, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Feng Tian 
> Cc: Amy Chan 
> ---
>  MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c | 14 
> +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c 
> b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
> index aa1ca16..f61e65e 100644
> --- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
> +++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
> @@ -1,7 +1,7 @@
>  /** @file
>Reset Architectural Protocol implementation
>  
> -  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
> +  Copyright (c) 2006 - 2016, 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
> @@ -86,11 +86,15 @@ DoS3 (
>  
>@param[in] ResetType  The type of reset to perform.
>@param[in] ResetStatusThe status code for the reset.
> -  @param[in] DataSize   The size, in bytes, of WatchdogData.
> +  @param[in] DataSize   The size, in bytes, of ResetData.
>@param[in] ResetData  For a ResetType of EfiResetCold, 
> EfiResetWarm, or
>  EfiResetShutdown the data buffer starts with 
> a Null-terminated
>  string, optionally followed by additional 
> binary data.
> -
> +The string is a description that the caller 
> may use to further
> +indicate the reason for the system reset. 
> ResetData is only
> +valid if ResetStatus is something other than 
> EFI_SUCCESS
> +unless the ResetType is 
> EfiResetPlatformSpecific
> +where a minimum amount of ResetData is 
> always required.

Most of the patches in this series have lines that are longer than 80
columns. Can you fix that?

I think you should move patch 11 before patch 09 "OvmfPkg: Use
MdeModulePkg/ResetSystemRuntimeDxe". I think this should allow reset
to continue working through the entire series for OVMF. (right?)

With those changes,

Series Reviewed-by: Jordan Justen 

>  **/
>  VOID
>  EFIAPI
> @@ -144,6 +148,10 @@ ResetSystem (
>  ResetShutdown ();
>  return ;
>  
> +  case EfiResetPlatformSpecific:
> +ResetPlatformSpecific (DataSize, ResetData);
> +return;
> +
>default:
>  return ;
>}
> -- 
> 2.9.0.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 01/26] ArmLib: remove ArmReplaceLiveTranslationEntry() implementation

2016-08-10 Thread Ard Biesheuvel
On 10 August 2016 at 18:56, Leif Lindholm  wrote:
> On Wed, Aug 10, 2016 at 05:17:37PM +0200, Ard Biesheuvel wrote:
>> The function ArmReplaceLiveTranslationEntry() has been moved to
>> ArmMmuLib, so remove the old implementation from ArmLib.
>
> Could you add a statement to this commit message that you're also
> fixing up the export attributes for the ArmMmuLib version to prepare
> for the new macros?
>

Actually, it is not quite that. The ArmMmuLib implementation was never
actually accessible, so the ArmLib version was still being used. That
is why it needs to be fixed in the same patch, or we'll end up with
either two or no implementations, causing breakage. I will add some
more explanation to the commit log

> If you do:
> Reviewed-by: Leif Lindholm 
>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ard Biesheuvel 
>> ---
>>  ArmPkg/Library/ArmLib/AArch64/AArch64Support.S   | 60 
>> 
>>  ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S |  4 ++
>>  2 files changed, 4 insertions(+), 60 deletions(-)
>>
>> diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S 
>> b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
>> index 9441f47e30ba..5cef98fd42a0 100644
>> --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
>> +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
>> @@ -488,64 +488,4 @@ ASM_PFX(ArmReadCurrentEL):
>>mrs   x0, CurrentEL
>>ret
>>
>> -
>> -  .macro __replace_entry, el
>> -
>> -  // disable the MMU
>> -  mrs   x8, sctlr_el\el
>> -  bic   x9, x8, #CTRL_M_BIT
>> -  msr   sctlr_el\el, x9
>> -  isb
>> -
>> -  // write updated entry
>> -  str   x1, [x0]
>> -
>> -  // invalidate again to get rid of stale clean cachelines that may
>> -  // have been filled speculatively since the last invalidate
>> -  dmb   sy
>> -  dcivac, x0
>> -
>> -  // flush the TLBs
>> -  .if   \el == 1
>> -  tlbi  vmalle1
>> -  .else
>> -  tlbi  alle\el
>> -  .endif
>> -  dsb   sy
>> -
>> -  // re-enable the MMU
>> -  msr   sctlr_el\el, x8
>> -  isb
>> -  .endm
>> -
>> -//VOID
>> -//ArmReplaceLiveTranslationEntry (
>> -//  IN  UINT64  *Entry,
>> -//  IN  UINT64  Value
>> -//  )
>> -ASM_PFX(ArmReplaceLiveTranslationEntry):
>> -
>> -  // disable interrupts
>> -  mrs   x2, daif
>> -  msr   daifset, #0xf
>> -  isb
>> -
>> -  // clean and invalidate first so that we don't clobber
>> -  // adjacent entries that are dirty in the caches
>> -  dccivac, x0
>> -  dsb   ish
>> -
>> -  EL1_OR_EL2_OR_EL3(x3)
>> -1:__replace_entry 1
>> -  b 4f
>> -2:__replace_entry 2
>> -  b 4f
>> -3:__replace_entry 3
>> -
>> -4:msr   daif, x2
>> -  ret
>> -
>> -ASM_PFX(ArmReplaceLiveTranslationEntrySize):
>> -  .long   . - ArmReplaceLiveTranslationEntry
>> -
>>  ASM_FUNCTION_REMOVE_IF_UNREFERENCED
>> diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S 
>> b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
>> index 7c5d205d940b..3834da7bfedd 100644
>> --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
>> +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
>> @@ -14,6 +14,8 @@
>>
>>  #include 
>>
>> +GCC_ASM_EXPORT(ArmReplaceLiveTranslationEntry)
>> +
>>.set CTRL_M_BIT,  (1 << 0)
>>
>>.macro __replace_entry, el
>> @@ -72,5 +74,7 @@ ASM_PFX(ArmReplaceLiveTranslationEntry):
>>  4:msr   daif, x2
>>ret
>>
>> +ASM_GLOBAL ASM_PFX(ArmReplaceLiveTranslationEntrySize)
>> +
>>  ASM_PFX(ArmReplaceLiveTranslationEntrySize):
>>.long   . - ArmReplaceLiveTranslationEntry
>> --
>> 2.7.4
>>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 03/26] ArmPkg/AsmMacroIoLib: remove unused obsolete MMIO and other asm macros

2016-08-10 Thread Ard Biesheuvel
On 10 August 2016 at 19:04, Leif Lindholm  wrote:
> On Wed, Aug 10, 2016 at 05:17:39PM +0200, Ard Biesheuvel wrote:
>> This removes the various Mmio ASM macros that are not used anywhere in
>> the code, and removes some variants of LoadConstant... () that are not
>> used anywhere either.
>
> If you say something about how the Mmio* functions are redundant due
> to the MdePkg implementations:

No, they are not. These are asm implementations, and completely unused.

> Reviewed-by: Leif Lindholm 
>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ard Biesheuvel 
>> ---
>>  ArmPkg/Include/AsmMacroIoLib.h   | 213 
>>  ArmPkg/Include/AsmMacroIoLib.inc |  54 -
>>  2 files changed, 267 deletions(-)
>>
>> diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h
>> index f94dcc619f7a..551b87803d19 100644
>> --- a/ArmPkg/Include/AsmMacroIoLib.h
>> +++ b/ArmPkg/Include/AsmMacroIoLib.h
>> @@ -24,88 +24,6 @@
>>  //  ldr reg, =expr does not work with current Apple tool chain. So do the 
>> work our selves
>>  //
>>
>> -// returns _Data in R0 and _Address in R1
>> -#define MmioWrite32(_Address, _Data) \
>> -  ldr  r1, [pc, #8] ;\
>> -  ldr  r0, [pc, #8] ;\
>> -  str  r0, [r1] ;\
>> -  b1f   ;\
>> -  .long (_Address)  ;\
>> -  .long (_Data) ;\
>> -1:
>> -
>> -// returns _Data in R0 and _Address in R1, and _OrData in r2
>> -#define MmioOr32(_Address, _OrData) \
>> -  ldr  r1, [pc, #16];   \
>> -  ldr  r2, [pc, #16];   \
>> -  ldr  r0, [r1] ;   \
>> -  orr  r0, r0, r2   ;   \
>> -  str  r0, [r1] ;   \
>> -  b1f   ;   \
>> -  .long (_Address)  ;   \
>> -  .long (_OrData)   ;   \
>> -1:
>> -
>> -// returns _Data in R0 and _Address in R1, and _OrData in r2
>> -#define MmioAnd32(_Address, _AndData) \
>> -  ldr  r1, [pc, #16]; \
>> -  ldr  r2, [pc, #16]; \
>> -  ldr  r0, [r1] ; \
>> -  and  r0, r0, r2   ; \
>> -  str  r0, [r1] ; \
>> -  b1f   ; \
>> -  .long (_Address)  ; \
>> -  .long (_AndData)   ; \
>> -1:
>> -
>> -// returns result in R0, _Address in R1, and _OrData in r2
>> -#define MmioAndThenOr32(_Address, _AndData, _OrData)  \
>> -  ldr  r1, [pc, #24]; \
>> -  ldr  r0, [r1] ; \
>> -  ldr  r2, [pc, #20]; \
>> -  and  r0, r0, r2   ; \
>> -  ldr  r2, [pc, #16]; \
>> -  orr  r0, r0, r2   ; \
>> -  str  r0, [r1] ; \
>> -  b1f   ; \
>> -  .long (_Address)  ; \
>> -  .long (_AndData)  ; \
>> -  .long (_OrData)   ; \
>> -1:
>> -
>> -// returns _Data in _Reg and _Address in R1
>> -#define MmioWriteFromReg32(_Address, _Reg) \
>> -  ldr  r1, [pc, #4] ;  \
>> -  str  _Reg, [r1]   ;  \
>> -  b1f   ;  \
>> -  .long (_Address)  ;  \
>> -1:
>> -
>> -
>> -// returns _Data in R0 and _Address in R1
>> -#define MmioRead32(_Address)   \
>> -  ldr  r1, [pc, #4] ;  \
>> -  ldr  r0, [r1] ;  \
>> -  b1f   ;  \
>> -  .long (_Address)  ;  \
>> -1:
>> -
>> -// returns _Data in Reg and _Address in R1
>> -#define MmioReadToReg32(_Address, _Reg) \
>> -  ldr  r1, [pc, #4] ;   \
>> -  ldr  _Reg, [r1]   ;   \
>> -  b1f   ;   \
>> -  .long (_Address)  ;   \
>> -1:
>> -
>> -
>> -// load R0 with _Data
>> -#define LoadConstant(_Data)  \
>> -  ldr  r0, [pc, #0] ;\
>> -  b1f   ;\
>> -  .long (_Data) ;\
>> -1:
>> -
>>  // load _Reg with _Data
>>  #define LoadConstantToReg(_Data, _Reg)  \
>>ldr  _Reg, [pc, #0]   ;   \
>> @@ -113,91 +31,8 @@
>>.long (_Data) ;   \
>>  1:
>>
>> -// load _Reg with _Data if eq
>> -#define LoadConstantToRegIfEq(_Data, _Reg)  \
>> -  ldreq  _Reg, [pc, #0]   ; \
>> -  b1f ; \
>> -  .long (_Data)   ; \
>> -1:
>> -
>> -// Reserve a region at the top of the Primary Core stack
>> -// for Global variables for the XIP phase
>> -#define SetPrimaryStack(StackTop, GlobalSize, Tmp)  \
>> -  and Tmp, GlobalSize, #7 ; \
>> -  rsbne   Tmp, Tmp, #8; \
>> -  add GlobalSize, GlobalSize, Tmp ; \
>> -  sub sp, S

Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to DxeReportStatusCodeLib assuming the state of the BootService Memory at runtime.

2016-08-10 Thread Kinney, Michael D
Hi Andrew,

I am staring at the code.  Something is not right here, but I am 
concerned that there are use cases I am not considering yet.  Here
is my analysis so far.

Here are the lib instances I see: 
(ignoring IntelFramework ones for the purposes of this discussion).

MdeModulePkg\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf(25):  
  LIBRARY_CLASS = ReportStatusCodeLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER 
DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE

MdeModulePkg\Library\PeiReportStatusCodeLib\PeiReportStatusCodeLib.inf(27):
  LIBRARY_CLASS = ReportStatusCodeLib|SEC PEIM PEI_CORE

MdeModulePkg\Library\RuntimeDxeReportStatusCodeLib\RuntimeDxeReportStatusCodeLib.inf(23):
  LIBRARY_CLASS = ReportStatusCodeLib|DXE_RUNTIME_DRIVER DXE_SAL_DRIVER

MdeModulePkg\Library\SmmReportStatusCodeLib\SmmReportStatusCodeLib.inf(26):
  LIBRARY_CLASS = ReportStatusCodeLib|DXE_SMM_DRIVER SMM_CORE

MdePkg\Library\BaseReportStatusCodeLibNull\BaseReportStatusCodeLibNull.inf(23):
  LIBRARY_CLASS = ReportStatusCodeLib

* The BASE one that is a Null instance makes sense when disabling Report Status 
Code.
* The PEI one makes sense for its module compatibility.
* The SMM one also makes sense its module compatibility.
* And the RuntimeDxe one also makes sense its module compatibility.
* The DXE one seems to be over specified and if we reduced its module 
  compatibility, the SMM and RuntimeDxe lib instances can be used to cover 
  those module types.

When I look at the source code in DxeReportStatusCodeLib, I see comments
that describe the use case where a module is dispatched before the Report
Status Code Protocol is available.

The use case you are describing is when the first call to Report Status 
Code by a module occurs after ExitBootServices().  In that case, we 
depend on the Boot Services table being zeroed to exit early.

I agree that no component should depend on Boot Services table being 
cleared to zeros at ExitBootServices().  It is legal from UEFI/PI spec 
to not zero at all, or in your example, fill with a pattern other than
zeros.

It appears that the use case of first call to Report Status Code after
ExitBootServices() is not covered by the DXE lib instance, and we have
just been getting lucky due to zeroing behavior of boot services table.

I can think of a couple options:

* Update DXE INF to remove the DXE Runtime, DXE SAL, SMM, SMM Core module
  types.  This may break platform builds if a platform is using this lib
  mapping for modules of the types being removed.  However, those could
  be considered platform DSC bugs.

* Update DXE lib instance to add ExitBootServices() and SetVirtualAddressMap()
  events.  However, this would basically make the DXE lib instance the
  same as the DXE Runtime instance and would increase size of non-RT 
  components.

I would prefer the first option, but we would need to do some testing to
see how many platform DSC files break.

Mike

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Andrew 
> Fish
> Sent: Tuesday, August 9, 2016 7:50 AM
> To: Zeng, Star 
> Cc: edk2-devel 
> Subject: Re: [edk2] [MdeModulePkg] SetVirtualAddressMap() crashed due to
> DxeReportStatusCodeLib assuming the state of the BootService Memory at 
> runtime.
> 
> 
> > On Aug 8, 2016, at 7:26 PM, Zeng, Star  wrote:
> >
> > On 2016/8/9 10:07, Andrew Fish wrote:
> >>
> >>> On Aug 8, 2016, at 6:21 PM, Zeng, Star  wrote:
> >>>
> >>> Andrew,
> >>>
> >>> Should MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib be used for 
> >>> your case
> if there are really runtime status code reporting needed?
> >>>
> >>
> >> Star,
> >>
> >> If the Library instance does not fully support DXE_RUNTIME_DRIVER, why is 
> >> it
> listed in the LIBRARY_CLASS as supported?
> >
> > This kind of library can support DXE_RUNTIME_DRIVER at boot time, for 
> > example
> UefiHiiLib, UefiHiiServicesLib, UefiBootServicesTableLib, DxePcdLib and etc.
> >
> 
> Star,
> 
> I understand giving access to Boot Services resources to a Runtime Driver for 
> its
> constructor. I think the difference here is the DxeReportStatusCodeLib is 
> abstracting
> a runtime service, but not doing it in a way to really works properly at 
> runtime in
> all cases. I would expect that a library abstraction a runtime feature would 
> work at
> runtime. Which is why I ended up with a "bad" mapping in the first place.
> 
> Thanks,
> 
> Andrew Fish
> 
> >>
> >>
> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Library/DxeReportStatusCod
> eLib/DxeReportStatusCodeLib.inf#L25
> >>
> >> LIBRARY_CLASS  = ReportStatusCodeLib|DXE_CORE DXE_DRIVER
> DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
> SMM_CORE
> >>
> >> Actually I tried to add the UefiRuntimeDriverLib and the build failed as
> UefiRuntimeDriverLib was not supported for the DXE_CORE type. Maybe the bug 
> is this
> library instance lists DXE_RUNTIME_DRIVER,  DXE_SAL_

Re: [edk2] [PATCH 03/26] ArmPkg/AsmMacroIoLib: remove unused obsolete MMIO and other asm macros

2016-08-10 Thread Leif Lindholm
On Wed, Aug 10, 2016 at 05:17:39PM +0200, Ard Biesheuvel wrote:
> This removes the various Mmio ASM macros that are not used anywhere in
> the code, and removes some variants of LoadConstant... () that are not
> used anywhere either.

If you say something about how the Mmio* functions are redundant due
to the MdePkg implementations:
Reviewed-by: Leif Lindholm 

> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel 
> ---
>  ArmPkg/Include/AsmMacroIoLib.h   | 213 
>  ArmPkg/Include/AsmMacroIoLib.inc |  54 -
>  2 files changed, 267 deletions(-)
> 
> diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h
> index f94dcc619f7a..551b87803d19 100644
> --- a/ArmPkg/Include/AsmMacroIoLib.h
> +++ b/ArmPkg/Include/AsmMacroIoLib.h
> @@ -24,88 +24,6 @@
>  //  ldr reg, =expr does not work with current Apple tool chain. So do the 
> work our selves
>  //
>  
> -// returns _Data in R0 and _Address in R1
> -#define MmioWrite32(_Address, _Data) \
> -  ldr  r1, [pc, #8] ;\
> -  ldr  r0, [pc, #8] ;\
> -  str  r0, [r1] ;\
> -  b1f   ;\
> -  .long (_Address)  ;\
> -  .long (_Data) ;\
> -1:
> -
> -// returns _Data in R0 and _Address in R1, and _OrData in r2
> -#define MmioOr32(_Address, _OrData) \
> -  ldr  r1, [pc, #16];   \
> -  ldr  r2, [pc, #16];   \
> -  ldr  r0, [r1] ;   \
> -  orr  r0, r0, r2   ;   \
> -  str  r0, [r1] ;   \
> -  b1f   ;   \
> -  .long (_Address)  ;   \
> -  .long (_OrData)   ;   \
> -1:
> -
> -// returns _Data in R0 and _Address in R1, and _OrData in r2
> -#define MmioAnd32(_Address, _AndData) \
> -  ldr  r1, [pc, #16]; \
> -  ldr  r2, [pc, #16]; \
> -  ldr  r0, [r1] ; \
> -  and  r0, r0, r2   ; \
> -  str  r0, [r1] ; \
> -  b1f   ; \
> -  .long (_Address)  ; \
> -  .long (_AndData)   ; \
> -1:
> -
> -// returns result in R0, _Address in R1, and _OrData in r2
> -#define MmioAndThenOr32(_Address, _AndData, _OrData)  \
> -  ldr  r1, [pc, #24]; \
> -  ldr  r0, [r1] ; \
> -  ldr  r2, [pc, #20]; \
> -  and  r0, r0, r2   ; \
> -  ldr  r2, [pc, #16]; \
> -  orr  r0, r0, r2   ; \
> -  str  r0, [r1] ; \
> -  b1f   ; \
> -  .long (_Address)  ; \
> -  .long (_AndData)  ; \
> -  .long (_OrData)   ; \
> -1:
> -
> -// returns _Data in _Reg and _Address in R1
> -#define MmioWriteFromReg32(_Address, _Reg) \
> -  ldr  r1, [pc, #4] ;  \
> -  str  _Reg, [r1]   ;  \
> -  b1f   ;  \
> -  .long (_Address)  ;  \
> -1:
> -
> -
> -// returns _Data in R0 and _Address in R1
> -#define MmioRead32(_Address)   \
> -  ldr  r1, [pc, #4] ;  \
> -  ldr  r0, [r1] ;  \
> -  b1f   ;  \
> -  .long (_Address)  ;  \
> -1:
> -
> -// returns _Data in Reg and _Address in R1
> -#define MmioReadToReg32(_Address, _Reg) \
> -  ldr  r1, [pc, #4] ;   \
> -  ldr  _Reg, [r1]   ;   \
> -  b1f   ;   \
> -  .long (_Address)  ;   \
> -1:
> -
> -
> -// load R0 with _Data
> -#define LoadConstant(_Data)  \
> -  ldr  r0, [pc, #0] ;\
> -  b1f   ;\
> -  .long (_Data) ;\
> -1:
> -
>  // load _Reg with _Data
>  #define LoadConstantToReg(_Data, _Reg)  \
>ldr  _Reg, [pc, #0]   ;   \
> @@ -113,91 +31,8 @@
>.long (_Data) ;   \
>  1:
>  
> -// load _Reg with _Data if eq
> -#define LoadConstantToRegIfEq(_Data, _Reg)  \
> -  ldreq  _Reg, [pc, #0]   ; \
> -  b1f ; \
> -  .long (_Data)   ; \
> -1:
> -
> -// Reserve a region at the top of the Primary Core stack
> -// for Global variables for the XIP phase
> -#define SetPrimaryStack(StackTop, GlobalSize, Tmp)  \
> -  and Tmp, GlobalSize, #7 ; \
> -  rsbne   Tmp, Tmp, #8; \
> -  add GlobalSize, GlobalSize, Tmp ; \
> -  sub sp, StackTop, GlobalSize; \
> -  ; \
> -  mov Tmp, sp ; \
> -  mov GlobalSize, #0x0; \
> -_SetPrimaryStackInitGlobals:  

Re: [edk2] [PATCH 01/26] ArmLib: remove ArmReplaceLiveTranslationEntry() implementation

2016-08-10 Thread Leif Lindholm
On Wed, Aug 10, 2016 at 05:17:37PM +0200, Ard Biesheuvel wrote:
> The function ArmReplaceLiveTranslationEntry() has been moved to
> ArmMmuLib, so remove the old implementation from ArmLib.

Could you add a statement to this commit message that you're also
fixing up the export attributes for the ArmMmuLib version to prepare
for the new macros?

If you do:
Reviewed-by: Leif Lindholm 

> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel 
> ---
>  ArmPkg/Library/ArmLib/AArch64/AArch64Support.S   | 60 
> 
>  ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S |  4 ++
>  2 files changed, 4 insertions(+), 60 deletions(-)
> 
> diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S 
> b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
> index 9441f47e30ba..5cef98fd42a0 100644
> --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
> +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
> @@ -488,64 +488,4 @@ ASM_PFX(ArmReadCurrentEL):
>mrs   x0, CurrentEL
>ret
>  
> -
> -  .macro __replace_entry, el
> -
> -  // disable the MMU
> -  mrs   x8, sctlr_el\el
> -  bic   x9, x8, #CTRL_M_BIT
> -  msr   sctlr_el\el, x9
> -  isb
> -
> -  // write updated entry
> -  str   x1, [x0]
> -
> -  // invalidate again to get rid of stale clean cachelines that may
> -  // have been filled speculatively since the last invalidate
> -  dmb   sy
> -  dcivac, x0
> -
> -  // flush the TLBs
> -  .if   \el == 1
> -  tlbi  vmalle1
> -  .else
> -  tlbi  alle\el
> -  .endif
> -  dsb   sy
> -
> -  // re-enable the MMU
> -  msr   sctlr_el\el, x8
> -  isb
> -  .endm
> -
> -//VOID
> -//ArmReplaceLiveTranslationEntry (
> -//  IN  UINT64  *Entry,
> -//  IN  UINT64  Value
> -//  )
> -ASM_PFX(ArmReplaceLiveTranslationEntry):
> -
> -  // disable interrupts
> -  mrs   x2, daif
> -  msr   daifset, #0xf
> -  isb
> -
> -  // clean and invalidate first so that we don't clobber
> -  // adjacent entries that are dirty in the caches
> -  dccivac, x0
> -  dsb   ish
> -
> -  EL1_OR_EL2_OR_EL3(x3)
> -1:__replace_entry 1
> -  b 4f
> -2:__replace_entry 2
> -  b 4f
> -3:__replace_entry 3
> -
> -4:msr   daif, x2
> -  ret
> -
> -ASM_PFX(ArmReplaceLiveTranslationEntrySize):
> -  .long   . - ArmReplaceLiveTranslationEntry
> -
>  ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S 
> b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
> index 7c5d205d940b..3834da7bfedd 100644
> --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
> +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
> @@ -14,6 +14,8 @@
>  
>  #include 
>  
> +GCC_ASM_EXPORT(ArmReplaceLiveTranslationEntry)
> +
>.set CTRL_M_BIT,  (1 << 0)
>  
>.macro __replace_entry, el
> @@ -72,5 +74,7 @@ ASM_PFX(ArmReplaceLiveTranslationEntry):
>  4:msr   daif, x2
>ret
>  
> +ASM_GLOBAL ASM_PFX(ArmReplaceLiveTranslationEntrySize)
> +
>  ASM_PFX(ArmReplaceLiveTranslationEntrySize):
>.long   . - ArmReplaceLiveTranslationEntry
> -- 
> 2.7.4
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 07/11] QuarkSocPkg/ResetSystemLib: Implement ResetPlatformSpecific

2016-08-10 Thread Kinney, Michael D
Reviewed-by: Michael D Kinney 

> -Original Message-
> From: Ni, Ruiyu
> Sent: Tuesday, August 9, 2016 10:56 PM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Steele, Kelly
> 
> Subject: [PATCH 07/11] QuarkSocPkg/ResetSystemLib: Implement 
> ResetPlatformSpecific
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Michael D Kinney 
> Cc: Kelly Steele 
> ---
>  .../Library/ResetSystemLib/ResetSystemLib.c| 22 
> +-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git 
> a/QuarkSocPkg/QuarkNorthCluster/Library/ResetSystemLib/ResetSystemLib.c
> b/QuarkSocPkg/QuarkNorthCluster/Library/ResetSystemLib/ResetSystemLib.c
> index c2ad7f3..3aa0f6d 100644
> --- a/QuarkSocPkg/QuarkNorthCluster/Library/ResetSystemLib/ResetSystemLib.c
> +++ b/QuarkSocPkg/QuarkNorthCluster/Library/ResetSystemLib/ResetSystemLib.c
> @@ -2,7 +2,7 @@
>  System reset Library Services.  This library class provides a set of
>  methods to reset whole system with manipulate QNC.
> 
> -Copyright (c) 2013-2015 Intel Corporation.
> +Copyright (c) 2013-2016 Intel Corporation.
> 
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -320,3 +320,23 @@ VOID
>}
>  }
> 
> +/**
> +  This function causes a systemwide reset. The exact type of the reset is 
> defined
> +  by the EFI_GUID that follows the Null-terminated Unicode string passed into
> ResetData.
> +  If the platform does not recognize the EFI_GUID in ResetData the platform 
> must
> pick a
> +  supported reset type to perform.The platform may optionally log the 
> parameters
> from
> +  any non-normal reset that occurs.
> +
> +  @param[in]  DataSize   The size, in bytes, of ResetData.
> +  @param[in]  ResetData  The data buffer starts with a Null-terminated 
> string,
> followed
> + by the EFI_GUID.
> +**/
> +VOID
> +EFIAPI
> +ResetPlatformSpecific (
> +  IN UINTN   DataSize,
> +  IN VOID*ResetData
> +  )
> +{
> +  ResetCold ();
> +}
> --
> 2.9.0.windows.1

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


[edk2] [PATCH 14/26] ArmPkg/ArmSmcLib: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S | 7 ++-
 ArmPkg/Library/ArmSmcLib/Arm/ArmSmc.S | 8 +++-
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S 
b/ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S
index 46c17674c199..a8dbb911de5e 100644
--- a/ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S
+++ b/ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S
@@ -11,12 +11,9 @@
 //
 //
 
-.text
-.align 3
+#include 
 
-GCC_ASM_EXPORT(ArmCallSmc)
-
-ASM_PFX(ArmCallSmc):
+ASM_FUNC(ArmCallSmc)
   // Push x0 on the stack - The stack must always be quad-word aligned
   str   x0, [sp, #-16]!
 
diff --git a/ArmPkg/Library/ArmSmcLib/Arm/ArmSmc.S 
b/ArmPkg/Library/ArmSmcLib/Arm/ArmSmc.S
index 260fb10fe86b..afb2e9bc901c 100644
--- a/ArmPkg/Library/ArmSmcLib/Arm/ArmSmc.S
+++ b/ArmPkg/Library/ArmSmcLib/Arm/ArmSmc.S
@@ -11,13 +11,11 @@
 //
 //
 
-.text
-.align 3
-.arch_extension sec
+#include 
 
-GCC_ASM_EXPORT(ArmCallSmc)
+.arch_extension sec
 
-ASM_PFX(ArmCallSmc):
+ASM_FUNC(ArmCallSmc)
 push{r4-r8}
 // r0 will be popped just after the SMC call
 push{r0}
-- 
2.7.4

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


[edk2] [PATCH 16/26] ArmPkg/BaseMemoryLibVstm: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.S | 8 +++-
 ArmPkg/Library/BaseMemoryLibVstm/Arm/SetMem.S  | 9 +++--
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.S 
b/ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.S
index 0a6e039af9dc..69de4c1fd48e 100644
--- a/ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.S
+++ b/ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.S
@@ -17,6 +17,8 @@
 #
 #--
 
+#include 
+
 /**
   Copy Length bytes from Source to Destination. Overlap is OK.
 
@@ -37,11 +39,7 @@ InternalMemCopyMem (
   IN  UINTN Length
   )
 **/
-.text
-.align 2
-GCC_ASM_EXPORT(InternalMemCopyMem)
-
-ASM_PFX(InternalMemCopyMem):
+ASM_FUNC(InternalMemCopyMem)
   stmfd  sp!, {r4, r9, lr}
   tst  r0, #3
   mov  r4, r0
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/Arm/SetMem.S 
b/ArmPkg/Library/BaseMemoryLibVstm/Arm/SetMem.S
index 6a6bb20ec14f..28ba38b79c6a 100644
--- a/ArmPkg/Library/BaseMemoryLibVstm/Arm/SetMem.S
+++ b/ArmPkg/Library/BaseMemoryLibVstm/Arm/SetMem.S
@@ -17,6 +17,8 @@
 #
 #--
 
+#include 
+
 /**
   Set Buffer to Value for Size bytes.
 
@@ -34,12 +36,7 @@ InternalMemSetMem (
   IN  UINT8 Value
   )
 **/
-
-.text
-.align 2
-GCC_ASM_EXPORT(InternalMemSetMem)
-
-ASM_PFX(InternalMemSetMem):
+ASM_FUNC(InternalMemSetMem)
   stmfd  sp!, {r4-r7, lr}
   tstr0, #3
   movne  r3, #0
-- 
2.7.4

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


[edk2] [PATCH 05/26] ArmPkg: introduce ASM_FUNC, MOV32/MOV64 and ADRL/LDRL macros

2016-08-10 Thread Ard Biesheuvel
This introduces the ASM_FUNC() macro to annotate function entry points
in assembler files. This allows us to add additional metadata that
marks a function entry point as a function, and allows us to emit
a .section directive for each function, which makes it possible for
the linker to drop unreferenced code.

In addition, introduce a couple of utility macros that we can use to
clean up the code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Include/AsmMacroIoLib.h   | 23 
 ArmPkg/Include/AsmMacroIoLibV8.h | 20 -
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h
index 551b87803d19..fb73ea9a4694 100644
--- a/ArmPkg/Include/AsmMacroIoLib.h
+++ b/ArmPkg/Include/AsmMacroIoLib.h
@@ -3,6 +3,7 @@
 
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
   Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
+  Copyright (c) 2016, Linaro Ltd. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -51,4 +52,26 @@
 
 #endif
 
+#define _ASM_FUNC(Name, Section)\
+  .global   Name  ; \
+  .section  #Section, "ax"; \
+  .type Name, %function   ; \
+  Name:
+
+#define ASM_FUNC(Name)_ASM_FUNC(ASM_PFX(Name), .text. ## Name)
+
+#define MOV32(Reg, Val)   \
+  movw  Reg, #(Val) & 0x; \
+  movt  Reg, #(Val) >> 16
+
+#define ADRL(Reg, Sym)\
+  movw  Reg, #:lower16:(Sym) - (. + 16) ; \
+  movt  Reg, #:upper16:(Sym) - (. + 12) ; \
+  add   Reg, Reg, pc
+
+#define LDRL(Reg, Sym)\
+  movw  Reg, #:lower16:(Sym) - (. + 16) ; \
+  movt  Reg, #:upper16:(Sym) - (. + 12) ; \
+  ldr   Reg, [pc, Reg]
+
 #endif
diff --git a/ArmPkg/Include/AsmMacroIoLibV8.h b/ArmPkg/Include/AsmMacroIoLibV8.h
index 37fa255f842e..e9285f78e7d6 100644
--- a/ArmPkg/Include/AsmMacroIoLibV8.h
+++ b/ArmPkg/Include/AsmMacroIoLibV8.h
@@ -3,6 +3,7 @@
 
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
   Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
+  Copyright (c) 2016, Linaro Ltd. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -71,5 +72,22 @@
 
 #endif // __GNUC__
 
-#endif // __MACRO_IO_LIBV8_H__
+#define _ASM_FUNC(Name, Section)\
+  .global   Name  ; \
+  .section  #Section, "ax"; \
+  .type Name, %function   ; \
+  Name:
+
+#define ASM_FUNC(Name)_ASM_FUNC(ASM_PFX(Name), .text. ## Name)
+
+#define MOV32(Reg, Val)   \
+  movz  Reg, (Val) >> 16, lsl #16   ; \
+  movk  Reg, (Val) & 0x
 
+#define MOV64(Reg, Val) \
+  movz  Reg, (Val) >> 48, lsl #48 ; \
+  movk  Reg, ((Val) >> 32) & 0x, lsl #32  ; \
+  movk  Reg, ((Val) >> 16) & 0x, lsl #16  ; \
+  movk  Reg, (Val) & 0x
+
+#endif // __MACRO_IO_LIBV8_H__
-- 
2.7.4

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


[edk2] [PATCH 07/26] ArmVirtPkg: clean up assembly source files

2016-08-10 Thread Ard Biesheuvel
This updates all assembly source files under ArmVirtPkg to mark
exported functions as ASM_FUNC(), which puts them in a separate
section, allowing the linker to prune code that is left unused.

At the same time, clean up the code to get rid of LoadConstantToReg()
instances involving symbol references, each of which emits an absolute
literal, and hence and entry in the PE/COFF .reloc table.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 
ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S
 | 36 +++
 ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ARM/RelocatableVirtHelper.S   
  | 50 +--
 ArmVirtPkg/Library/ArmVirtPlatformLib/AARCH64/VirtHelper.S 
  | 30 +++--
 ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.S 
  | 31 +++--
 ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.asm   
  | 10 +--
 
ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S 
 | 36 +++
 ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ARM/RelocatableVirtHelper.S
  | 47 +-
 ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
  | 41 
 ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
  | 66 ++--
 9 files changed, 97 insertions(+), 250 deletions(-)

diff --git 
a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S
 
b/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S
index 27ad07a1a197..ec6955cf0af8 100644
--- 
a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S
+++ 
b/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S
@@ -1,5 +1,6 @@
 #
 #  Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+#  Copyright (c) 2016, Linaro Limited. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -12,33 +13,14 @@
 #
 
 #include 
-#include 
 #include 
-#include 
-#include 
-
-.text
-.align 2
-
-GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
-GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
-GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
-GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
-GCC_ASM_EXPORT(ArmGetPhysAddrTop)
-
-GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
-GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
-GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdCoreCount)
-
-.LArm64LinuxMagic:
-  .byte   0x41, 0x52, 0x4d, 0x64
 
 // VOID
 // ArmPlatformPeiBootAction (
 //   VOID   *DeviceTreeBaseAddress,   // passed by loader in x0
 //   VOID   *ImageBase// passed by FDF trampoline in x1
 //   );
-ASM_PFX(ArmPlatformPeiBootAction):
+ASM_FUNC(ArmPlatformPeiBootAction)
   //
   // If we are booting from RAM using the Linux kernel boot protocol, x0 will
   // point to the DTB image in memory. Otherwise, use the default value defined
@@ -104,20 +86,22 @@ ASM_PFX(ArmPlatformPeiBootAction):
 .Lout:
   retx29
 
+.LArm64LinuxMagic:
+  .byte   0x41, 0x52, 0x4d, 0x64
+
 //UINTN
 //ArmPlatformGetPrimaryCoreMpId (
 //  VOID
 //  );
-ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, x0)
-  ldrh   w0, [x0]
+ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
+  MOV32  (w0, FixedPcdGet32 (PcdArmPrimaryCore))
   ret
 
 //UINTN
 //ArmPlatformIsPrimaryCore (
 //  IN UINTN MpId
 //  );
-ASM_PFX(ArmPlatformIsPrimaryCore):
+ASM_FUNC(ArmPlatformIsPrimaryCore)
   mov   x0, #1
   ret
 
@@ -126,7 +110,7 @@ ASM_PFX(ArmPlatformIsPrimaryCore):
 //  IN UINTN MpId
 //  );
 // With this function: CorePos = (ClusterId * 4) + CoreId
-ASM_PFX(ArmPlatformGetCorePosition):
+ASM_FUNC(ArmPlatformGetCorePosition)
   and   x1, x0, #ARM_CORE_MASK
   and   x0, x0, #ARM_CLUSTER_MASK
   add   x0, x1, x0, LSR #6
@@ -136,7 +120,7 @@ ASM_PFX(ArmPlatformGetCorePosition):
 //GetPhysAddrTop (
 //  VOID
 //  );
-ASM_PFX(ArmGetPhysAddrTop):
+ASM_FUNC(ArmGetPhysAddrTop)
   mrs   x0, id_aa64mmfr0_el1
   adr   x1, .LPARanges
   and   x0, x0, #7
diff --git 
a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ARM/RelocatableVirtHelper.S 
b/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ARM/RelocatableVirtHelper.S
index 097038806ecd..27af98970c16 100644
--- 
a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ARM/RelocatableVirtHelper.S
+++ 
b/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ARM/RelocatableVirtHelper.S
@@ -1,6 +1,6 @@
 #
 #  Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-#  Copyright (c) 2014, Linaro Limited. All rights reserved.
+#  Copyright (c) 2014-2016, Linaro Limited. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -13,28 +13,9 @@
 #
 
 #include 
-#include 
 #include 
-#include 
-#

[edk2] [PATCH 15/26] ArmPkg/BaseMemoryLibSm: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Library/BaseMemoryLibStm/Arm/CopyMem.S | 8 +++-
 ArmPkg/Library/BaseMemoryLibStm/Arm/SetMem.S  | 7 +++
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/ArmPkg/Library/BaseMemoryLibStm/Arm/CopyMem.S 
b/ArmPkg/Library/BaseMemoryLibStm/Arm/CopyMem.S
index 7985b59279ba..f90589c22594 100644
--- a/ArmPkg/Library/BaseMemoryLibStm/Arm/CopyMem.S
+++ b/ArmPkg/Library/BaseMemoryLibStm/Arm/CopyMem.S
@@ -17,6 +17,8 @@
 #
 #--
 
+#include 
+
 /**
   Copy Length bytes from Source to Destination. Overlap is OK.
 
@@ -37,11 +39,7 @@ InternalMemCopyMem (
   IN  UINTN Length
   )
 **/
-.text
-.align 2
-GCC_ASM_EXPORT(InternalMemCopyMem)
-
-ASM_PFX(InternalMemCopyMem):
+ASM_FUNC(InternalMemCopyMem)
   stmfd  sp!, {r4-r11, lr}
   // Save the input parameters in extra registers (r11 = destination, r14 = 
source, r12 = length)
   mov  r11, r0
diff --git a/ArmPkg/Library/BaseMemoryLibStm/Arm/SetMem.S 
b/ArmPkg/Library/BaseMemoryLibStm/Arm/SetMem.S
index 970d030ca368..242de95f74d1 100644
--- a/ArmPkg/Library/BaseMemoryLibStm/Arm/SetMem.S
+++ b/ArmPkg/Library/BaseMemoryLibStm/Arm/SetMem.S
@@ -17,6 +17,8 @@
 #
 #--
 
+#include 
+
 /**
   Set Buffer to Value for Size bytes.
 
@@ -35,12 +37,9 @@ InternalMemSetMem (
   )
 **/
 
-.text
 .syntax unified
-.align 2
-GCC_ASM_EXPORT(InternalMemSetMem)
 
-ASM_PFX(InternalMemSetMem):
+ASM_FUNC(InternalMemSetMem)
   stmfd  sp!, {r4-r11, lr}
   tstr0, #3
   movne  r3, #0
-- 
2.7.4

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


[edk2] [PATCH 13/26] ArmPkg/ArmMmuLib: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S 
b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
index 3834da7bfedd..90192df24f55 100644
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
@@ -14,8 +14,6 @@
 
 #include 
 
-GCC_ASM_EXPORT(ArmReplaceLiveTranslationEntry)
-
   .set CTRL_M_BIT,  (1 << 0)
 
   .macro __replace_entry, el
@@ -52,7 +50,7 @@ GCC_ASM_EXPORT(ArmReplaceLiveTranslationEntry)
 //  IN  UINT64  *Entry,
 //  IN  UINT64  Value
 //  )
-ASM_PFX(ArmReplaceLiveTranslationEntry):
+ASM_FUNC(ArmReplaceLiveTranslationEntry)
 
   // disable interrupts
   mrs   x2, daif
-- 
2.7.4

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


[edk2] [PATCH 22/26] ArmPlatformPkg/PrePi: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S | 49 ++-
 ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S | 50 ++--
 2 files changed, 29 insertions(+), 70 deletions(-)

diff --git a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S 
b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
index 9538c70a237c..d0530a874726 100644
--- a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
@@ -12,24 +12,10 @@
 //
 
 #include 
-#include 
-#include 
-#include 
-
-.text
-.align 3
-
-GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
-GCC_ASM_IMPORT(ArmReadMpidr)
-GCC_ASM_IMPORT(ArmPlatformPeiBootAction)
-GCC_ASM_IMPORT(ArmPlatformStackSet)
-GCC_ASM_EXPORT(_ModuleEntryPoint)
-ASM_GLOBAL ASM_PFX(mSystemMemoryEnd)
 
-StartupAddr:  .8byte ASM_PFX(CEntryPoint)
-ASM_PFX(mSystemMemoryEnd):.8byte 0
+ASM_GLOBAL ASM_PFX(mSystemMemoryEnd)
 
-ASM_PFX(_ModuleEntryPoint):
+ASM_FUNC(_ModuleEntryPoint)
   // Do early platform specific actions
   blASM_PFX(ArmPlatformPeiBootAction)
 
@@ -49,10 +35,8 @@ _SystemMemoryEndInit:
   cmp   x1, #0
   bne   _SetupStackPosition
 
-  LoadConstantToReg (FixedPcdGet64(PcdSystemMemoryBase), x1)
-  LoadConstantToReg (FixedPcdGet64(PcdSystemMemorySize), x2)
-  sub   x2, x2, #1
-  add   x1, x1, x2
+  MOV64 (x1, FixedPcdGet64(PcdSystemMemoryBase) + 
FixedPcdGet64(PcdSystemMemorySize) - 1)
+
   // Update the global variable
   adr   x2, mSystemMemoryEnd
   str   x1, [x2]
@@ -61,13 +45,13 @@ _SetupStackPosition:
   // r1 = SystemMemoryTop
 
   // Calculate Top of the Firmware Device
-  LoadConstantToReg (FixedPcdGet64(PcdFdBaseAddress), x2)
-  LoadConstantToReg (FixedPcdGet32(PcdFdSize), x3)
+  MOV64 (x2, FixedPcdGet64(PcdFdBaseAddress))
+  MOV32 (x3, FixedPcdGet32(PcdFdSize) - 1)
   sub   x3, x3, #1
   add   x3, x3, x2  // x3 = FdTop = PcdFdBaseAddress + PcdFdSize
 
   // UEFI Memory Size (stacks are allocated in this region)
-  LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryUefiRegionSize), x4)
+  MOV32 (x4, FixedPcdGet32(PcdSystemMemoryUefiRegionSize))
 
   //
   // Reserve the memory for the UEFI region (contain stacks on its top)
@@ -98,9 +82,7 @@ _SetupAlignedStack:
 _SetupOverflowStack:
   // Case memory at the top of the address space. Ensure the top of the stack 
is EFI_PAGE_SIZE
   // aligned (4KB)
-  LoadConstantToReg (EFI_PAGE_MASK, x11)
-  and   x11, x11, x1
-  sub   x1, x1, x11
+  and   x1, x1, ~EFI_PAGE_MASK
 
 _GetBaseUefiMemory:
   // Calculate the Base of the UEFI Memory
@@ -109,22 +91,19 @@ _GetBaseUefiMemory:
 _GetStackBase:
   // r1 = The top of the Mpcore Stacks
   // Stack for the primary core = PrimaryCoreStack
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), x2)
+  MOV32 (x2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
   sub   x12, x1, x2
 
   // Stack for the secondary core = Number of Cores - 1
-  LoadConstantToReg (FixedPcdGet32(PcdCoreCount), x0)
-  sub   x0, x0, #1
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x1)
-  mul   x1, x1, x0
+  MOV32 (x1, (FixedPcdGet32(PcdCoreCount) - 1) * 
FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
   sub   x12, x12, x1
 
   // x12 = The base of the MpCore Stacks (primary stack & secondary stacks)
   mov   x0, x12
   mov   x1, x10
   //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), x2)
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x3)
+  MOV32 (x2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
+  MOV32 (x3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
   blASM_PFX(ArmPlatformStackSet)
 
   // Is it the Primary Core ?
@@ -140,7 +119,7 @@ _PrepareArguments:
 
   // Move sec startup address into a data register
   // Ensure we're jumping to FV version of the code (not boot remapped alias)
-  ldr   x4, StartupAddr
+  ldr   x4, =ASM_PFX(CEntryPoint)
 
   // Jump to PrePiCore C code
   //x0 = MpId
@@ -150,3 +129,5 @@ _PrepareArguments:
 
 _NeverReturn:
   b _NeverReturn
+
+ASM_PFX(mSystemMemoryEnd):.8byte 0
diff --git a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S 
b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
index 1311efc5cb2c..b7127ce9fb4c 100644
--- a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
@@ -12,28 +12,12 @@
 //
 
 #include 
-#include 
-#include 
-#include 
 
 #include 
 
-.text
-.align 3
-
-GCC_ASM_IMPORT(CEntryPoint)
-GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
-GCC_ASM_IMPORT(ArmReadMpidr)
-GCC_ASM_IMPORT(ArmPlatformPeiBootAction)
-GCC_ASM_IMPORT(ArmPlatformStackSet)
-GCC_ASM_EXPORT(_ModuleEntryPoint)
 GCC_ASM_EXPORT(mSystemMemoryEnd)
 
-StartupAddr:   .word  CEntryPoint
-mSystemMemoryEnd:  .8byte 0
-
-
-ASM_PFX(_ModuleEntryPoint):
+ASM_FUNC(_ModuleEntryPoint)
   /

[edk2] [PATCH 26/26] ArmPlatformPkg/ArmPlatformStackLib: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/Library/ArmPlatformStackLib/AArch64/ArmPlatformStackLib.S | 35 
+---
 ArmPlatformPkg/Library/ArmPlatformStackLib/Arm/ArmPlatformStackLib.S | 25 
+++---
 2 files changed, 12 insertions(+), 48 deletions(-)

diff --git 
a/ArmPlatformPkg/Library/ArmPlatformStackLib/AArch64/ArmPlatformStackLib.S 
b/ArmPlatformPkg/Library/ArmPlatformStackLib/AArch64/ArmPlatformStackLib.S
index 485017f62013..65d7d6c6d686 100644
--- a/ArmPlatformPkg/Library/ArmPlatformStackLib/AArch64/ArmPlatformStackLib.S
+++ b/ArmPlatformPkg/Library/ArmPlatformStackLib/AArch64/ArmPlatformStackLib.S
@@ -12,21 +12,6 @@
 //
 
 #include 
-#include 
-#include 
-
-.text
-.align 3
-
-GCC_ASM_EXPORT(ArmPlatformStackSet)
-GCC_ASM_EXPORT(ArmPlatformStackSetPrimary)
-GCC_ASM_EXPORT(ArmPlatformStackSetSecondary)
-
-GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
-GCC_ASM_IMPORT(ArmPlatformGetCorePosition)
-GCC_ASM_IMPORT(ArmPlatformGetPrimaryCoreMpId)
-
-GCC_ASM_IMPORT(gPcd_FixedAtBuild_PcdCoreCount)
 
 //VOID
 //ArmPlatformStackSet (
@@ -35,7 +20,7 @@ GCC_ASM_IMPORT(gPcd_FixedAtBuild_PcdCoreCount)
 //  IN UINTN PrimaryStackSize,
 //  IN UINTN SecondaryStackSize
 //  );
-ASM_PFX(ArmPlatformStackSet):
+ASM_FUNC(ArmPlatformStackSet)
   // Save parameters
   mov   x6, x3
   mov   x5, x2
@@ -59,10 +44,10 @@ ASM_PFX(ArmPlatformStackSet):
   // Restore the Link register
   mov   x30, x7
 
-  // Should be ASM_PFX(ArmPlatformStackSetPrimary) but generate linker error 
'unsupported ELF EM_AARCH64'
-  b.eq  ArmPlatformStackSetPrimaryL
-  // Should be ASM_PFX(ArmPlatformStackSetSecondary) but generate linker error 
'unsupported ELF EM_AARCH64'
-  b.ne  ArmPlatformStackSetSecondaryL
+  b.ne  0f
+
+  b ASM_PFX(ArmPlatformStackSetPrimary)
+0:b ASM_PFX(ArmPlatformStackSetSecondary)
 
 //VOID
 //ArmPlatformStackSetPrimary (
@@ -71,8 +56,7 @@ ASM_PFX(ArmPlatformStackSet):
 //  IN UINTN PrimaryStackSize,
 //  IN UINTN SecondaryStackSize
 //  );
-ArmPlatformStackSetPrimaryL:
-ASM_PFX(ArmPlatformStackSetPrimary):
+ASM_FUNC(ArmPlatformStackSetPrimary)
   // Save the Link register
   mov   x4, x30
 
@@ -80,9 +64,7 @@ ASM_PFX(ArmPlatformStackSetPrimary):
   add   x0, x0, x2
 
   // Compute SecondaryCoresCount * SecondaryCoreStackSize
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdCoreCount, x1)
-  ldr   w1, [x1]
-  sub   x1, x1, #1
+  MOV32 (w1, FixedPcdGet32(PcdCoreCount) - 1)
   mul   x3, x3, x1
 
   // Set Primary Stack ((StackBase + PrimaryStackSize) + (SecondaryCoresCount 
* SecondaryCoreStackSize))
@@ -97,8 +79,7 @@ ASM_PFX(ArmPlatformStackSetPrimary):
 //  IN UINTN PrimaryStackSize,
 //  IN UINTN SecondaryStackSize
 //  );
-ArmPlatformStackSetSecondaryL:
-ASM_PFX(ArmPlatformStackSetSecondary):
+ASM_FUNC(ArmPlatformStackSetSecondary)
   // Save the Link register
   mov   x4, x30
   mov   sp, x0
diff --git 
a/ArmPlatformPkg/Library/ArmPlatformStackLib/Arm/ArmPlatformStackLib.S 
b/ArmPlatformPkg/Library/ArmPlatformStackLib/Arm/ArmPlatformStackLib.S
index 96e925981fca..bdd7a27b7cf9 100644
--- a/ArmPlatformPkg/Library/ArmPlatformStackLib/Arm/ArmPlatformStackLib.S
+++ b/ArmPlatformPkg/Library/ArmPlatformStackLib/Arm/ArmPlatformStackLib.S
@@ -12,21 +12,6 @@
 //
 
 #include 
-#include 
-#include 
-
-.text
-.align 3
-
-GCC_ASM_EXPORT(ArmPlatformStackSet)
-GCC_ASM_EXPORT(ArmPlatformStackSetPrimary)
-GCC_ASM_EXPORT(ArmPlatformStackSetSecondary)
-
-GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
-GCC_ASM_IMPORT(ArmPlatformGetCorePosition)
-GCC_ASM_IMPORT(ArmPlatformGetPrimaryCoreMpId)
-
-GCC_ASM_IMPORT(gPcd_FixedAtBuild_PcdCoreCount)
 
 //VOID
 //ArmPlatformStackSet (
@@ -35,7 +20,7 @@ GCC_ASM_IMPORT(gPcd_FixedAtBuild_PcdCoreCount)
 //  IN UINTN PrimaryStackSize,
 //  IN UINTN SecondaryStackSize
 //  );
-ASM_PFX(ArmPlatformStackSet):
+ASM_FUNC(ArmPlatformStackSet)
   // Save parameters
   mov   r6, r3
   mov   r5, r2
@@ -69,16 +54,14 @@ ASM_PFX(ArmPlatformStackSet):
 //  IN UINTN PrimaryStackSize,
 //  IN UINTN SecondaryStackSize
 //  );
-ASM_PFX(ArmPlatformStackSetPrimary):
+ASM_FUNC(ArmPlatformStackSetPrimary)
   mov   r4, lr
 
   // Add stack of primary stack to StackBase
   add   r0, r0, r2
 
   // Compute SecondaryCoresCount * SecondaryCoreStackSize
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdCoreCount, r1)
-  ldr   r1, [r1]
-  sub   r1, #1
+  MOV32 (r1, FixedPcdGet32(PcdCoreCount) - 1)
   mul   r3, r3, r1
 
   // Set Primary Stack ((StackBase + PrimaryStackSize) + (SecondaryCoresCount 
* SecondaryCoreStackSize))
@@ -93,7 +76,7 @@ ASM_PFX(ArmPlatformStackSetPrimary):
 //  IN UINTN PrimaryStackSize,
 //  IN UINTN SecondaryStackSize
 //  );
-ASM_PFX(ArmPlatformStackSetSecondary):
+ASM_FUNC(ArmPlatformStackSetSecondary)
   mov   r4, lr
   mov   sp, r0
 
-- 
2.7.4

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

[edk2] [PATCH 23/26] ArmPlatformPkg/PrePeiCore: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/PrePeiCore/AArch64/Helper.S   | 11 ++-
 ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S | 30 

 ArmPlatformPkg/PrePeiCore/AArch64/SwitchStack.S  |  9 ++
 ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S | 30 

 ArmPlatformPkg/PrePeiCore/Arm/SwitchStack.S  |  9 ++
 5 files changed, 18 insertions(+), 71 deletions(-)

diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/Helper.S 
b/ArmPlatformPkg/PrePeiCore/AArch64/Helper.S
index 8e23b0389653..5f35484b1259 100644
--- a/ArmPlatformPkg/PrePeiCore/AArch64/Helper.S
+++ b/ArmPlatformPkg/PrePeiCore/AArch64/Helper.S
@@ -14,15 +14,8 @@
 #include 
 #include 
 
-#start of the code section
-.text
-.align 3
-
-GCC_ASM_EXPORT(SetupExceptionLevel1)
-GCC_ASM_EXPORT(SetupExceptionLevel2)
-
 // Setup EL1 while in EL1
-ASM_PFX(SetupExceptionLevel1):
+ASM_FUNC(SetupExceptionLevel1)
mov  x5, x30   // Save LR
 
mov  x0, #CPACR_CP_FULL_ACCESS
@@ -31,7 +24,7 @@ ASM_PFX(SetupExceptionLevel1):
ret  x5
 
 // Setup EL2 while in EL2
-ASM_PFX(SetupExceptionLevel2):
+ASM_FUNC(SetupExceptionLevel2)
msr sctlr_el2, xzr
mrs x0, hcr_el2// Read EL2 Hypervisor configuration Register
 
diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S 
b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S
index 34bf3a4e6831..aab5edab0c42 100644
--- a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S
+++ b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S
@@ -12,23 +12,8 @@
 //
 
 #include 
-#include 
-#include 
-#include 
 
-.text
-.align 3
-
-GCC_ASM_IMPORT(CEntryPoint)
-GCC_ASM_IMPORT(ArmPlatformGetCorePosition)
-GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
-GCC_ASM_IMPORT(ArmReadMpidr)
-GCC_ASM_IMPORT(ArmPlatformPeiBootAction)
-GCC_ASM_EXPORT(_ModuleEntryPoint)
-
-StartupAddr: .8byte CEntryPoint
-
-ASM_PFX(_ModuleEntryPoint):
+ASM_FUNC(_ModuleEntryPoint)
   // Do early platform specific actions
   blASM_PFX(ArmPlatformPeiBootAction)
 
@@ -60,9 +45,7 @@ ASM_PFX(MainEntryPoint):
   blASM_PFX(ArmPlatformIsPrimaryCore)
 
   // Get the top of the primary stacks (and the base of the secondary stacks)
-  LoadConstantToReg (FixedPcdGet64(PcdCPUCoresStackBase), x1)
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), x2)
-  add   x1, x1, x2
+  MOV64 (x1, FixedPcdGet64(PcdCPUCoresStackBase) + 
FixedPcdGet32(PcdCPUCorePrimaryStackSize))
 
   // x0 is equal to 1 if I am the primary core
   cmp   x0, #1
@@ -79,20 +62,19 @@ _SetupSecondaryCoreStack:
   add   x0, x0, #1
 
   // StackOffset = CorePos * StackSize
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x2)
+  MOV32 (x2, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
   mul   x0, x0, x2
   // SP = StackBase + StackOffset
   add   sp, x6, x0
 
 _PrepareArguments:
   // The PEI Core Entry Point has been computed by GenFV and stored in the 
second entry of the Reset Vector
-  LoadConstantToReg (FixedPcdGet64(PcdFvBaseAddress), x2)
-  add   x2, x2, #8
-  ldr   x1, [x2]
+  MOV64 (x2, FixedPcdGet64(PcdFvBaseAddress))
+  ldr   x1, [x2, #8]
 
   // Move sec startup address into a data register
   // Ensure we're jumping to FV version of the code (not boot remapped alias)
-  ldr   x3, StartupAddr
+  ldr   x3, =ASM_PFX(CEntryPoint)
 
   // Jump to PrePeiCore C code
   //x0 = mp_id
diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/SwitchStack.S 
b/ArmPlatformPkg/PrePeiCore/AArch64/SwitchStack.S
index 8d83510517b4..89b98e630f5c 100644
--- a/ArmPlatformPkg/PrePeiCore/AArch64/SwitchStack.S
+++ b/ArmPlatformPkg/PrePeiCore/AArch64/SwitchStack.S
@@ -14,12 +14,7 @@
 #
 #--
 
-.text
-.align 3
-
-GCC_ASM_EXPORT(SecSwitchStack)
-
-
+#include 
 
 #/**
 #  This allows the caller to switch the stack and return
@@ -35,7 +30,7 @@ GCC_ASM_EXPORT(SecSwitchStack)
 #  VOID  *StackDelta
 #  )#
 #
-ASM_PFX(SecSwitchStack):
+ASM_FUNC(SecSwitchStack)
 mov   x1, sp
 add   x1, x0, x1
 mov   sp, x1
diff --git a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S 
b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
index 1693f52e26c8..14344425ad4c 100644
--- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
+++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
@@ -12,23 +12,8 @@
 //
 
 #include 
-#include 
-#include 
-#include 
 
-.text
-.align 3
-
-GCC_ASM_IMPORT(CEntryPoint)
-GCC_ASM_IMPORT(ArmPlatformGetCorePosition)
-GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
-GCC_ASM_IMPORT(ArmReadMpidr)
-GCC_ASM_IMPORT(ArmPlatformPeiBootAction)
-GCC_ASM_EXPORT(_ModuleEntryPoint)
-
-StartupAddr: .wordCEntryPoint
-
-ASM_PFX(_ModuleEntryPoint):
+ASM_FUNC(_ModuleEntryPoint)
   // Do early platform specific actio

[edk2] [PATCH 19/26] BeagleBoardPkg: remove unused Sec.inf module

2016-08-10 Thread Ard Biesheuvel
This module is not referenced anywhere, so remove it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.S   |  85 --
 BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.asm |  89 --
 BeagleBoardPkg/Sec/Cache.c  |  79 --
 BeagleBoardPkg/Sec/Clock.c  |  70 -
 BeagleBoardPkg/Sec/LzmaDecompress.h | 103 ---
 BeagleBoardPkg/Sec/PadConfiguration.c   | 282 
 BeagleBoardPkg/Sec/Sec.c| 186 -
 BeagleBoardPkg/Sec/Sec.inf  |  73 -
 8 files changed, 967 deletions(-)

diff --git a/BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.S 
b/BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.S
deleted file mode 100644
index b656c1e040c5..
--- a/BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.S
+++ /dev/null
@@ -1,85 +0,0 @@
-#--
-#
-# 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
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#--
-
-#include 
-#include 
-
-.text
-.align 3
-
-.globl ASM_PFX(CEntryPoint)
-GCC_ASM_EXPORT(_ModuleEntryPoint)
-
-ASM_PFX(_ModuleEntryPoint):
-
-  //Disable L2 cache
-  mrc p15, 0, r0, c1, c0, 1   // read Auxiliary Control Register
-  bic r0, r0, #0x0002 // disable L2 cache
-  mcr p15, 0, r0, c1, c0, 1   // store Auxiliary Control Register
-
-  //Enable Strict alignment checking & Instruction cache
-  mrc p15, 0, r0, c1, c0, 0
-  bic r0, r0, #0x2300 /* clear bits 13, 9:8 (--V- --RS) */
-  bic r0, r0, #0x0005 /* clear bits 0, 2 ( -C-M) */
-  orr r0, r0, #0x0002 /* set bit 1 (A) Align */
-  orr r0, r0, #0x1000 /* set bit 12 (I) enable I-Cache */
-  mcr p15, 0, r0, c1, c0, 0
-
-  // Enable NEON register in case folks want to use them for optimizations 
(CopyMem)
-  mrc p15, 0, r0, c1, c0, 2
-  orr r0, r0, #0x00f0   // Enable VPF access (V* instructions)
-  mcr p15, 0, r0, c1, c0, 2
-  mov r0, #0x4000   // Set EN bit in FPEXC
-  mcr p10,#0x7,r0,c8,c0,#0  // msr FPEXC,r0 in ARM assembly
-
-
-  // Set CPU vectors to start of DRAM
-  LoadConstantToReg (FixedPcdGet32(PcdCpuVectorBaseAddress) ,r0) // Get vector 
base
-  mcr p15, 0, r0, c12, c0, 0
-  isb   // Sync changes to control registers
-
-  // Fill vector table with branchs to current pc (jmp $)
-  ldr r1, ShouldNeverGetHere
-  movsr2, #0
-FillVectors:
-  str r1, [r0, r2]
-  addsr2, r2, #4
-  cmp r2, #32
-  bne FillVectors
-
-  /* before we call C code, lets setup the stack pointer in internal RAM */
-stack_pointer_setup:
-
-  //
-  // Set stack based on PCD values. Need to do it this way to make C code work
-  // when it runs from FLASH.
-  //
-  LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r2)/* stack base 
arg2  */
-  LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3)/* stack size 
arg3  */
-  add r4, r2, r3
-
-  //Enter SVC mode and set up SVC stack pointer
-  mov r0,#0x13|0x80|0x40
-  msr CPSR_c,r0
-  mov r13,r4
-
-  // Call C entry point
-  LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1)/* memory size arg1  
*/
-  LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0)/* memory size arg0  
   */
-  blx  ASM_PFX(CEntryPoint) /* Assume C code is thumb*/
-
-ShouldNeverGetHere:
-  /* _CEntryPoint should never return */
-  b   ShouldNeverGetHere
-
diff --git a/BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.asm 
b/BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.asm
deleted file mode 100644
index 63174d4b8437..
--- a/BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.asm
+++ /dev/null
@@ -1,89 +0,0 @@
-//--
-//
-// 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
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
-//
-//--
-
-#include 
-#include 
-#include 
-  INCL

[edk2] [PATCH 12/26] ArmPkg/ArmLib: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimerSupport.S |  67 ---
 ArmPkg/Library/ArmLib/AArch64/AArch64Support.S  | 121 
+++-
 ArmPkg/Library/ArmLib/AArch64/ArmLibSupportV8.S |  43 +++
 ArmPkg/Library/ArmLib/ArmV7/ArmLibSupportV7.S   |  47 +++-
 ArmPkg/Library/ArmLib/ArmV7/ArmV7ArchTimerSupport.S |  67 ---
 ArmPkg/Library/ArmLib/ArmV7/ArmV7Support.S  | 113 
++
 ArmPkg/Library/ArmLib/Common/AArch64/ArmLibSupport.S|  78 -
 ArmPkg/Library/ArmLib/Common/Arm/ArmLibSupport.S|  89 +-
 ArmPkg/Library/ArmLib/Common/Arm/ArmLibSupport.asm  |   4 +-
 9 files changed, 205 insertions(+), 424 deletions(-)

diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimerSupport.S 
b/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimerSupport.S
index 3944d8bcb4f1..59e0bc9a0794 100644
--- a/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimerSupport.S
+++ b/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimerSupport.S
@@ -1,6 +1,7 @@
 #--
 #
 # Copyright (c) 2011 - 2013, ARM Limited. All rights reserved.
+# Copyright (c) 2016, Linaro Limited. All rights reserved.
 #
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD 
License
@@ -12,127 +13,105 @@
 #
 #--
 
-.text
-.align 2
-
-GCC_ASM_EXPORT(ArmReadCntFrq)
-GCC_ASM_EXPORT(ArmWriteCntFrq)
-GCC_ASM_EXPORT(ArmReadCntPct)
-GCC_ASM_EXPORT(ArmReadCntkCtl)
-GCC_ASM_EXPORT(ArmWriteCntkCtl)
-GCC_ASM_EXPORT(ArmReadCntpTval)
-GCC_ASM_EXPORT(ArmWriteCntpTval)
-GCC_ASM_EXPORT(ArmReadCntpCtl)
-GCC_ASM_EXPORT(ArmWriteCntpCtl)
-GCC_ASM_EXPORT(ArmReadCntvTval)
-GCC_ASM_EXPORT(ArmWriteCntvTval)
-GCC_ASM_EXPORT(ArmReadCntvCtl)
-GCC_ASM_EXPORT(ArmWriteCntvCtl)
-GCC_ASM_EXPORT(ArmReadCntvCt)
-GCC_ASM_EXPORT(ArmReadCntpCval)
-GCC_ASM_EXPORT(ArmWriteCntpCval)
-GCC_ASM_EXPORT(ArmReadCntvCval)
-GCC_ASM_EXPORT(ArmWriteCntvCval)
-GCC_ASM_EXPORT(ArmReadCntvOff)
-GCC_ASM_EXPORT(ArmWriteCntvOff)
-
-ASM_PFX(ArmReadCntFrq):
+#include 
+
+ASM_FUNC(ArmReadCntFrq)
   mrs   x0, cntfrq_el0   // Read CNTFRQ
   ret
 
 
 # NOTE - Can only write while at highest implemented EL level (EL3 on model). 
Else ReadOnly (EL2, EL1, EL0)
-ASM_PFX(ArmWriteCntFrq):
+ASM_FUNC(ArmWriteCntFrq)
   msr   cntfrq_el0, x0   // Write to CNTFRQ
   ret
 
 
-ASM_PFX(ArmReadCntPct):
+ASM_FUNC(ArmReadCntPct)
   mrs   x0, cntpct_el0   // Read CNTPCT (Physical counter register)
   ret
 
 
-ASM_PFX(ArmReadCntkCtl):
+ASM_FUNC(ArmReadCntkCtl)
   mrs   x0, cntkctl_el1  // Read CNTK_CTL (Timer PL1 Control Register)
   ret
 
 
-ASM_PFX(ArmWriteCntkCtl):
+ASM_FUNC(ArmWriteCntkCtl)
   msr   cntkctl_el1, x0  // Write to CNTK_CTL (Timer PL1 Control 
Register)
   ret
 
 
-ASM_PFX(ArmReadCntpTval):
+ASM_FUNC(ArmReadCntpTval)
   mrs   x0, cntp_tval_el0// Read CNTP_TVAL (PL1 physical timer value 
register)
   ret
 
 
-ASM_PFX(ArmWriteCntpTval):
+ASM_FUNC(ArmWriteCntpTval)
   msr   cntp_tval_el0, x0// Write to CNTP_TVAL (PL1 physical timer 
value register)
   ret
 
 
-ASM_PFX(ArmReadCntpCtl):
+ASM_FUNC(ArmReadCntpCtl)
   mrs   x0, cntp_ctl_el0 // Read CNTP_CTL (PL1 Physical Timer Control 
Register)
   ret
 
 
-ASM_PFX(ArmWriteCntpCtl):
+ASM_FUNC(ArmWriteCntpCtl)
   msr   cntp_ctl_el0, x0 // Write to  CNTP_CTL (PL1 Physical Timer 
Control Register)
   ret
 
 
-ASM_PFX(ArmReadCntvTval):
+ASM_FUNC(ArmReadCntvTval)
   mrs   x0, cntv_tval_el0// Read CNTV_TVAL (Virtual Timer Value 
register)
   ret
 
 
-ASM_PFX(ArmWriteCntvTval):
+ASM_FUNC(ArmWriteCntvTval)
   msr   cntv_tval_el0, x0// Write to CNTV_TVAL (Virtual Timer Value 
register)
   ret
 
 
-ASM_PFX(ArmReadCntvCtl):
+ASM_FUNC(ArmReadCntvCtl)
   mrs   x0, cntv_ctl_el0 // Read CNTV_CTL (Virtual Timer Control 
Register)
   ret
 
 
-ASM_PFX(ArmWriteCntvCtl):
+ASM_FUNC(ArmWriteCntvCtl)
   msr   cntv_ctl_el0, x0 // Write to CNTV_CTL (Virtual Timer Control 
Register)
   ret
 
 
-ASM_PFX(ArmReadCntvCt):
+ASM_FUNC(ArmReadCntvCt)
   mrs  x0, cntvct_el0// Read CNTVCT  (Virtual Count Register)
   ret
 
 
-ASM_PFX(ArmReadCntpCval):
+ASM_FUNC(ArmReadCntpCval)
   mrs   x0, cntp_cval_el0// Read CNTP_CTVAL (Physical Timer Compare 
Value Register)
   ret
 
 
-ASM_PFX(ArmWriteCntpCval):
+ASM_FUNC(ArmWriteCntpCval)
   msr   cntp_cval_el0, x0// Write to CNTP_CTVAL (Physical Timer 
Compare Value Register)
   ret
 
 
-ASM_PFX(ArmReadCntvCval):
+ASM_FUNC(ArmReadCntvCval)
   mrs   x0, cntv_cval_el0// Read CNTV_CTVAL (Virtual Timer Compare 
Value Register)
   ret
 
 
-ASM_PFX(ArmWriteCntv

[edk2] [PATCH 11/26] ArmPkg/ArmHvcLib: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Library/ArmHvcLib/AArch64/ArmHvc.S |  9 +++--
 ArmPkg/Library/ArmHvcLib/Arm/ArmHvc.S | 10 --
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/ArmPkg/Library/ArmHvcLib/AArch64/ArmHvc.S 
b/ArmPkg/Library/ArmHvcLib/AArch64/ArmHvc.S
index 99a1d21ce7f1..e9140a0a9bba 100644
--- a/ArmPkg/Library/ArmHvcLib/AArch64/ArmHvc.S
+++ b/ArmPkg/Library/ArmHvcLib/AArch64/ArmHvc.S
@@ -1,6 +1,6 @@
 //
 //  Copyright (c) 2012-2014, ARM Limited. All rights reserved.
-//  Copyright (c) 2014, Linaro Limited. All rights reserved.
+//  Copyright (c) 2014-2016, Linaro Limited. All rights reserved.
 //
 //  This program and the accompanying materials
 //  are licensed and made available under the terms and conditions of the BSD 
License
@@ -12,12 +12,9 @@
 //
 //
 
-.text
-.align 3
+#include 
 
-GCC_ASM_EXPORT(ArmCallHvc)
-
-ASM_PFX(ArmCallHvc):
+ASM_FUNC(ArmCallHvc)
   // Push x0 on the stack - The stack must always be quad-word aligned
   str   x0, [sp, #-16]!
 
diff --git a/ArmPkg/Library/ArmHvcLib/Arm/ArmHvc.S 
b/ArmPkg/Library/ArmHvcLib/Arm/ArmHvc.S
index 25ceb6a7d8db..be4693796f32 100644
--- a/ArmPkg/Library/ArmHvcLib/Arm/ArmHvc.S
+++ b/ArmPkg/Library/ArmHvcLib/Arm/ArmHvc.S
@@ -1,6 +1,6 @@
 //
 //  Copyright (c) 2012-2014, ARM Limited. All rights reserved.
-//  Copyright (c) 2014, Linaro Limited. All rights reserved.
+//  Copyright (c) 2014-2016, Linaro Limited. All rights reserved.
 //
 //  This program and the accompanying materials
 //  are licensed and made available under the terms and conditions of the BSD 
License
@@ -12,13 +12,11 @@
 //
 //
 
-.text
-.align 3
-.arch_extension virt
+#include 
 
-GCC_ASM_EXPORT(ArmCallHvc)
+.arch_extension virt
 
-ASM_PFX(ArmCallHvc):
+ASM_FUNC(ArmCallHvc)
 push{r4-r8}
 // r0 will be popped just after the HVC call
 push{r0}
-- 
2.7.4

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


[edk2] [PATCH 24/26] ArmPlatformPkg/ArmVExpressPkg: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.S 
| 22 ---
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.S 
| 28 -
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/AArch64/RTSMHelper.S 
| 38 +-
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S 
| 41 ++--
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Boot.S
| 23 ---
 5 files changed, 41 insertions(+), 111 deletions(-)

diff --git 
a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.S 
b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.S
index 20bfe52610e3..3719a5ace604 100644
--- 
a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.S
+++ 
b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.S
@@ -16,22 +16,14 @@
 
 #include 
 
-.text
-.align 2
-
-GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
-GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
-GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
-GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
-
-ASM_PFX(ArmPlatformPeiBootAction):
+ASM_FUNC(ArmPlatformPeiBootAction)
   bxlr
 
 //UINTN
 //ArmPlatformGetCorePosition (
 //  IN UINTN MpId
 //  );
-ASM_PFX(ArmPlatformGetCorePosition):
+ASM_FUNC(ArmPlatformGetCorePosition)
   and   r1, r0, #ARM_CORE_MASK
   and   r0, r0, #ARM_CLUSTER_MASK
   add   r0, r1, r0, LSR #7
@@ -41,10 +33,10 @@ ASM_PFX(ArmPlatformGetCorePosition):
 //ArmPlatformIsPrimaryCore (
 //  IN UINTN MpId
 //  );
-ASM_PFX(ArmPlatformIsPrimaryCore):
+ASM_FUNC(ArmPlatformIsPrimaryCore)
   // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
   // with cpu_id[0:3] and cluster_id[4:7]
-  LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r1)
+  MOV32 (r1, ARM_CTA15A7_SCC_CFGREG48)
   ldr   r1, [r1]
   lsr   r1, #24
 
@@ -58,7 +50,7 @@ ASM_PFX(ArmPlatformIsPrimaryCore):
   orr   r1, r1, r2
 
   // Keep the Cluster ID and Core ID from the MPID
-  LoadConstantToReg (ARM_CLUSTER_MASK | ARM_CORE_MASK, r2)
+  MOV32 (r2, ARM_CLUSTER_MASK | ARM_CORE_MASK)
   and   r0, r0, r2
 
   // Compare mpid and boot cpu from ARM_SCC_CFGREG48
@@ -71,10 +63,10 @@ ASM_PFX(ArmPlatformIsPrimaryCore):
 //ArmPlatformGetPrimaryCoreMpId (
 //  VOID
 //  );
-ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
+ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
   // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
   // with cpu_id[0:3] and cluster_id[4:7]
-  LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r0)
+  MOV32 (r0, ARM_CTA15A7_SCC_CFGREG48)
   ldr   r0, [r0]
   lsr   r0, #24
 
diff --git 
a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.S 
b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.S
index c4aee741a602..f95d2f43d665 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.S
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.S
@@ -14,36 +14,22 @@
 #include 
 #include 
 
-.text
-.align 2
-
-GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
-GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
-GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
-GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
-
-GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
-GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
-
 //UINTN
 //ArmPlatformGetPrimaryCoreMpId (
 //  VOID
 //  );
-ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0)
-  ldr   r0, [r0]
+ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
+  MOV32  (r0, FixedPcdGet32 (PcdArmPrimaryCore))
   bxlr
 
 //UINTN
 //ArmPlatformIsPrimaryCore (
 //  IN UINTN MpId
 //  );
-ASM_PFX(ArmPlatformIsPrimaryCore):
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
-  ldr   r1, [r1]
+ASM_FUNC(ArmPlatformIsPrimaryCore)
+  MOV32  (r1, FixedPcdGet32 (PcdArmPrimaryCoreMask))
   and   r0, r0, r1
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
-  ldr   r1, [r1]
+  MOV32  (r1, FixedPcdGet32 (PcdArmPrimaryCore))
   cmp   r0, r1
   moveq r0, #1
   movne r0, #0
@@ -53,11 +39,11 @@ ASM_PFX(ArmPlatformIsPrimaryCore):
 //ArmPlatformGetCorePosition (
 //  IN UINTN MpId
 //  );
-ASM_PFX(ArmPlatformGetCorePosition):
+ASM_FUNC(ArmPlatformGetCorePosition)
   and   r0, r0, #ARM_CORE_MASK
   bxlr
 
-ASM_PFX(ArmPlatformPeiBootAction):
+ASM_FUNC(ArmPlatformPeiBootAction)
   bxlr
 
 ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git 
a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/AArch64/RTSMHelper.S 
b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/AArch64/RTSMHelper.S
index 50ff71391700..db6d83c3cce9 100644
--- 
a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/AArch64/RTSMHelper.S
+++ 
b/ArmPlatformPkg/ArmVExpressPkg

[edk2] [PATCH 21/26] ArmPlatformPkg/ArmJunoLib: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/AArch64/ArmJunoHelper.S | 37 
++--
 ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/Arm/ArmJunoHelper.S | 36 
++-
 2 files changed, 21 insertions(+), 52 deletions(-)

diff --git 
a/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/AArch64/ArmJunoHelper.S 
b/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/AArch64/ArmJunoHelper.S
index 73b249ca5ffd..4bdf08d1a98a 100644
--- a/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/AArch64/ArmJunoHelper.S
+++ b/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/AArch64/ArmJunoHelper.S
@@ -15,25 +15,12 @@
 #include 
 #include 
 
-.text
-.align 3
-
-GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
-GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
-GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
-GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
-
-GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
-
-
-PrimaryCoreMpid:  .word0x0
-
 //UINTN
 //ArmPlatformGetCorePosition (
 //  IN UINTN MpId
 //  );
 // With this function: CorePos = (ClusterId * 2) + CoreId
-ASM_PFX(ArmPlatformGetCorePosition):
+ASM_FUNC(ArmPlatformGetCorePosition)
   and   x1, x0, #ARM_CORE_MASK
   and   x0, x0, #ARM_CLUSTER_MASK
   add   x0, x1, x0, LSR #7
@@ -43,33 +30,29 @@ ASM_PFX(ArmPlatformGetCorePosition):
 //ArmPlatformGetPrimaryCoreMpId (
 //  VOID
 //  );
-ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
-  ldr   x0, =PrimaryCoreMpid
-  ldrh  w0, [x0]
+ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
+  ldr   w0, PrimaryCoreMpid
   ret
 
 //UINTN
 //ArmPlatformIsPrimaryCore (
 //  IN UINTN MpId
 //  );
-ASM_PFX(ArmPlatformIsPrimaryCore):
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, x1)
-  ldrh  w1, [x1]
+ASM_FUNC(ArmPlatformIsPrimaryCore)
+  MOV32 (w1, FixedPcdGet32 (PcdArmPrimaryCoreMask))
   and   x0, x0, x1
 
-  ldr   x1, =PrimaryCoreMpid
-  ldrh  w1, [x1]
+  ldr   w1, PrimaryCoreMpid
 
   cmp   w0, w1
-  mov   x0, #1
-  mov   x1, #0
-  csel  x0, x0, x1, eq
+  cset  x0, eq
   ret
 
-ASM_PFX(ArmPlatformPeiBootAction):
+ASM_FUNC(ArmPlatformPeiBootAction)
   // The trusted firmware passes the primary CPU MPID through x0 register.
   // Save it in a variable.
-  ldr  x1, =PrimaryCoreMpid
+  adr  x1, PrimaryCoreMpid
   str  w0, [x1]
   ret
 
+PrimaryCoreMpid:  .word0x0
diff --git a/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/Arm/ArmJunoHelper.S 
b/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/Arm/ArmJunoHelper.S
index 2efb5451b88b..a7e904eac697 100644
--- a/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/Arm/ArmJunoHelper.S
+++ b/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/Arm/ArmJunoHelper.S
@@ -12,22 +12,9 @@
 *
 **/
 
-#include 
+#include 
 #include 
 
-.text
-.align 3
-
-GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
-GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
-GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
-GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
-
-GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
-
-
-PrimaryCoreMpid:  .word0x0
-
 //
 // Return the core position from the value of its MpId register
 //
@@ -41,7 +28,7 @@ PrimaryCoreMpid:  .word0x0
 //  IN UINTN MpId
 //  );
 // With this function: CorePos = (ClusterId * 2) + CoreId
-ASM_PFX(ArmPlatformGetCorePosition):
+ASM_FUNC(ArmPlatformGetCorePosition)
   and   r1, r0, #ARM_CORE_MASK
   and   r0, r0, #ARM_CLUSTER_MASK
   add   r0, r1, r0, LSR #7
@@ -59,9 +46,8 @@ ASM_PFX(ArmPlatformGetCorePosition):
 //ArmPlatformGetPrimaryCoreMpId (
 //  VOID
 //  );
-ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
-  ldr   r0, =PrimaryCoreMpid
-  ldr   r0, [r0]
+ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
+  LDRL  (r0, PrimaryCoreMpid)
   bxlr
 
 //
@@ -77,13 +63,11 @@ ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
 //ArmPlatformIsPrimaryCore (
 //  IN UINTN MpId
 //  );
-ASM_PFX(ArmPlatformIsPrimaryCore):
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
-  ldr   r1, [r1]
+ASM_FUNC(ArmPlatformIsPrimaryCore)
+  MOV32 (r1, FixedPcdGet32 (PcdArmPrimaryCoreMask))
   and   r0, r0, r1
 
-  ldr   r1, =PrimaryCoreMpid
-  ldr   r1, [r1]
+  LDRL  (r1, PrimaryCoreMpid)
 
   cmp   r0, r1
   moveq r0, #1
@@ -97,9 +81,11 @@ ASM_PFX(ArmPlatformIsPrimaryCore):
 // or PrePeiCore modules. It allows to retrieve arguments passed to
 // the UEFI firmware through the CPU registers.
 //
-ASM_PFX(ArmPlatformPeiBootAction):
+ASM_FUNC(ArmPlatformPeiBootAction)
   // The trusted firmware passes the primary CPU MPID through r0 register.
   // Save it in a variable.
-  ldr  r1, =PrimaryCoreMpid
+  adr  r1, PrimaryCoreMpid
   str  r0, [r1]
   bx   lr
+
+PrimaryCoreMpid:  .word0x0
-- 
2.7.4

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


[edk2] [PATCH 20/26] BeagleBoardPkg: add missing ArmMmuLib resolution

2016-08-10 Thread Ard Biesheuvel
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 BeagleBoardPkg/BeagleBoardPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc 
b/BeagleBoardPkg/BeagleBoardPkg.dsc
index aedaf4e042ec..b4a645ba9149 100644
--- a/BeagleBoardPkg/BeagleBoardPkg.dsc
+++ b/BeagleBoardPkg/BeagleBoardPkg.dsc
@@ -33,6 +33,7 @@ [Defines]
 
 [LibraryClasses.common]
   ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf
+  ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
   ArmPlatformLib|BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardLib.inf
   ArmCpuLib|ArmPkg/Drivers/ArmCpuLib/ArmCortexA8Lib/ArmCortexA8Lib.inf
   
ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
-- 
2.7.4

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


[edk2] [PATCH 25/26] ArmPlatformPkg/ArmPlatformLibNull: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/Library/ArmPlatformLibNull/AArch64/ArmPlatformHelper.S | 28 
+---
 ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.S | 28 
+---
 2 files changed, 14 insertions(+), 42 deletions(-)

diff --git 
a/ArmPlatformPkg/Library/ArmPlatformLibNull/AArch64/ArmPlatformHelper.S 
b/ArmPlatformPkg/Library/ArmPlatformLibNull/AArch64/ArmPlatformHelper.S
index 8c099b469e0e..2f4cf95cbf13 100644
--- a/ArmPlatformPkg/Library/ArmPlatformLibNull/AArch64/ArmPlatformHelper.S
+++ b/ArmPlatformPkg/Library/ArmPlatformLibNull/AArch64/ArmPlatformHelper.S
@@ -14,18 +14,7 @@
 #include 
 #include 
 
-.text
-.align 2
-
-GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
-GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
-GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
-GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
-
-GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
-GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
-
-ASM_PFX(ArmPlatformPeiBootAction):
+ASM_FUNC(ArmPlatformPeiBootAction)
   ret
 
 //UINTN
@@ -33,7 +22,7 @@ ASM_PFX(ArmPlatformPeiBootAction):
 //  IN UINTN MpId
 //  );
 // With this function: CorePos = (ClusterId * 4) + CoreId
-ASM_PFX(ArmPlatformGetCorePosition):
+ASM_FUNC(ArmPlatformGetCorePosition)
   and   x1, x0, #ARM_CORE_MASK
   and   x0, x0, #ARM_CLUSTER_MASK
   add   x0, x1, x0, LSR #6
@@ -43,21 +32,18 @@ ASM_PFX(ArmPlatformGetCorePosition):
 //ArmPlatformGetPrimaryCoreMpId (
 //  VOID
 //  );
-ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, x0)
-  ldrh  w0, [x0]
+ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
+  MOV32  (w0, FixedPcdGet32 (PcdArmPrimaryCore))
   ret
 
 //UINTN
 //ArmPlatformIsPrimaryCore (
 //  IN UINTN MpId
 //  );
-ASM_PFX(ArmPlatformIsPrimaryCore):
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, x1)
-  ldrh  w1, [x1]
+ASM_FUNC(ArmPlatformIsPrimaryCore)
+  MOV32  (w1, FixedPcdGet32 (PcdArmPrimaryCoreMask))
   and   x0, x0, x1
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, x1)
-  ldrh  w1, [x1]
+  MOV32  (w1, FixedPcdGet32 (PcdArmPrimaryCore))
   cmp   w0, w1
   mov   x0, #1
   mov   x1, #0
diff --git a/ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.S 
b/ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.S
index e52ea5afa2cb..bd517e6e16c1 100644
--- a/ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.S
+++ b/ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.S
@@ -14,25 +14,14 @@
 #include 
 #include 
 
-.text
-.align 2
-
-GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
-GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
-GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
-GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
-
-GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
-GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
-
-ASM_PFX(ArmPlatformPeiBootAction):
+ASM_FUNC(ArmPlatformPeiBootAction)
   bxlr
 
 //UINTN
 //ArmPlatformGetCorePosition (
 //  IN UINTN MpId
 //  );
-ASM_PFX(ArmPlatformGetCorePosition):
+ASM_FUNC(ArmPlatformGetCorePosition)
   and   r1, r0, #ARM_CORE_MASK
   and   r0, r0, #ARM_CLUSTER_MASK
   add   r0, r1, r0, LSR #7
@@ -42,21 +31,18 @@ ASM_PFX(ArmPlatformGetCorePosition):
 //ArmPlatformGetPrimaryCoreMpId (
 //  VOID
 //  );
-ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0)
-  ldr   r0, [r0]
+ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
+  MOV32  (r0, FixedPcdGet32 (PcdArmPrimaryCore))
   bxlr
 
 //UINTN
 //ArmPlatformIsPrimaryCore (
 //  IN UINTN MpId
 //  );
-ASM_PFX(ArmPlatformIsPrimaryCore):
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
-  ldr   r1, [r1]
+ASM_FUNC(ArmPlatformIsPrimaryCore)
+  MOV32  (r1, FixedPcdGet32 (PcdArmPrimaryCoreMask))
   and   r0, r0, r1
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
-  ldr   r1, [r1]
+  MOV32  (r1, FixedPcdGet32 (PcdArmPrimaryCore))
   cmp   r0, r1
   moveq r0, #1
   movne r0, #0
-- 
2.7.4

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


[edk2] [PATCH 18/26] ArmPkg/SemihostLib: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Library/SemihostLib/AArch64/GccSemihost.S | 7 ++-
 ArmPkg/Library/SemihostLib/Arm/GccSemihost.S | 8 ++--
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/ArmPkg/Library/SemihostLib/AArch64/GccSemihost.S 
b/ArmPkg/Library/SemihostLib/AArch64/GccSemihost.S
index 42211cf4ff8f..43a780c9ed3e 100644
--- a/ArmPkg/Library/SemihostLib/AArch64/GccSemihost.S
+++ b/ArmPkg/Library/SemihostLib/AArch64/GccSemihost.S
@@ -13,11 +13,8 @@
 #
 #--
 
-.text
-.align 2
+#include 
 
-.globl ASM_PFX(GccSemihostCall)
-
-ASM_PFX(GccSemihostCall):
+ASM_FUNC(GccSemihostCall)
   hlt #0xf000
   ret
diff --git a/ArmPkg/Library/SemihostLib/Arm/GccSemihost.S 
b/ArmPkg/Library/SemihostLib/Arm/GccSemihost.S
index c9d13183f61e..770e512cfbca 100644
--- a/ArmPkg/Library/SemihostLib/Arm/GccSemihost.S
+++ b/ArmPkg/Library/SemihostLib/Arm/GccSemihost.S
@@ -12,11 +12,7 @@
 #
 #--
 
-.text
-.align 2
-
-.globl ASM_PFX(GccSemihostCall)
-INTERWORK_FUNC(GccSemihostCall)
+#include 
 
 /*
   Semihosting operation request mechanism
@@ -32,7 +28,7 @@ INTERWORK_FUNC(GccSemihostCall)
the svc lr register. That happens to be the one we are using, so we must
save it or we will not be able to return.
  */
-ASM_PFX(GccSemihostCall):
+ASM_FUNC(GccSemihostCall)
   stmfd   sp!, {lr}
   svc #0x123456
   ldmfd   sp!, {lr}
-- 
2.7.4

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


[edk2] [PATCH 17/26] ArmPkg/CompilerIntrinsicsLib: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections. Note that in some cases, various entry points
refer to different parts of the same routine, so in those cases,
the files have been left untouched.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Library/CompilerIntrinsicsLib/AArch64/memcpy.S | 10 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S|  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S|  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S |  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S |  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.S| 13 -
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S |  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S |  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S|  7 ++-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.S   |  7 ++-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.S   |  8 ++--
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S|  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.S|  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S |  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S |  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S |  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch16.S   |  8 +++-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch32.S   |  8 +++-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch8.S|  8 +++-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S   |  9 +++--
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S|  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S|  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S |  7 +++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S|  7 +++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S|  6 ++
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S|  6 ++
 26 files changed, 60 insertions(+), 122 deletions(-)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/AArch64/memcpy.S 
b/ArmPkg/Library/CompilerIntrinsicsLib/AArch64/memcpy.S
index 66102da14b6a..4dd6cf207754 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/AArch64/memcpy.S
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/AArch64/memcpy.S
@@ -26,16 +26,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-
-.text
-.align 2
-
-
-GCC_ASM_EXPORT(memcpy)
-
+#include 
 
 // Taken from Newlib BSD implementation.
-ASM_PFX(memcpy):
+ASM_FUNC(memcpy)
 // Copy dst to x6, so we can preserve return value.
 mov x6, x0
 
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S
index 74960b1df185..a68b60cf0c96 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S
@@ -12,11 +12,9 @@
 #
 #--
 
-  .text
-  .align 2
-  GCC_ASM_EXPORT(__ashldi3)
+#include 
 
-ASM_PFX(__ashldi3):
+ASM_FUNC(__ashldi3)
   cmp  r2, #31
   bls  L2
   cmp  r2, #63
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S
index 3cee2c1085d8..6d004a553fa6 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S
@@ -12,11 +12,9 @@
 #
 #--
 
-  .text
-  .align 2
-  GCC_ASM_EXPORT(__ashrdi3)
+#include 
 
-ASM_PFX(__ashrdi3):
+ASM_FUNC(__ashrdi3)
   cmp  r2, #31
   bls  L2
   cmp  r2, #63
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S
index 4cef26575712..8ebf65bc8c6a 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S
@@ -12,11 +12,9 @@
 #
 #--
 
-  .text
-  .align 2
-  GCC_ASM_EXPORT(__clzsi2)
+#include 
 
-ASM_PFX(__clzsi2):
+ASM_FUNC(__clzsi2)
   @ frame_needed = 1, uses_anonymous_args = 0
   stmfd  sp!, {r7, lr}
   add  r7, sp, #0
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S
index 108072eef720..ea957fb198eb 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S
@@ -12,11 +12,9 @@
 #
 #--
 
-  .text
-  .align 2
-  GCC_ASM_EXPORT(__ctzsi2)
+#include 
 
-ASM_PFX(__ctzsi2):
+ASM_FUNC(__ctzsi2)
   uxth  r3, r0
   cmp  r3, #0
   moveq  ip, #16
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.S 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.S
i

[edk2] [PATCH 10/26] ArmPkg/ArmGicV3: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Drivers/ArmGic/GicV3/AArch64/ArmGicV3.S | 28 ++--
 ArmPkg/Drivers/ArmGic/GicV3/Arm/ArmGicV3.S | 28 ++--
 2 files changed, 16 insertions(+), 40 deletions(-)

diff --git a/ArmPkg/Drivers/ArmGic/GicV3/AArch64/ArmGicV3.S 
b/ArmPkg/Drivers/ArmGic/GicV3/AArch64/ArmGicV3.S
index f1c227f2c421..a4e0a4170a03 100644
--- a/ArmPkg/Drivers/ArmGic/GicV3/AArch64/ArmGicV3.S
+++ b/ArmPkg/Drivers/ArmGic/GicV3/AArch64/ArmGicV3.S
@@ -32,24 +32,12 @@
 
 #endif
 
-.text
-.align 2
-
-GCC_ASM_EXPORT(ArmGicV3GetControlSystemRegisterEnable)
-GCC_ASM_EXPORT(ArmGicV3SetControlSystemRegisterEnable)
-GCC_ASM_EXPORT(ArmGicV3EnableInterruptInterface)
-GCC_ASM_EXPORT(ArmGicV3DisableInterruptInterface)
-GCC_ASM_EXPORT(ArmGicV3EndOfInterrupt)
-GCC_ASM_EXPORT(ArmGicV3AcknowledgeInterrupt)
-GCC_ASM_EXPORT(ArmGicV3SetPriorityMask)
-GCC_ASM_EXPORT(ArmGicV3SetBinaryPointer)
-
 //UINT32
 //EFIAPI
 //ArmGicV3GetControlSystemRegisterEnable (
 //  VOID
 //  );
-ASM_PFX(ArmGicV3GetControlSystemRegisterEnable):
+ASM_FUNC(ArmGicV3GetControlSystemRegisterEnable)
 EL1_OR_EL2_OR_EL3(x1)
 1:  mrs x0, ICC_SRE_EL1
 b   4f
@@ -63,7 +51,7 @@ ASM_PFX(ArmGicV3GetControlSystemRegisterEnable):
 //ArmGicV3SetControlSystemRegisterEnable (
 //  IN UINT32 ControlSystemRegisterEnable
 //  );
-ASM_PFX(ArmGicV3SetControlSystemRegisterEnable):
+ASM_FUNC(ArmGicV3SetControlSystemRegisterEnable)
 EL1_OR_EL2_OR_EL3(x1)
 1:  msr ICC_SRE_EL1, x0
 b   4f
@@ -77,7 +65,7 @@ ASM_PFX(ArmGicV3SetControlSystemRegisterEnable):
 //ArmGicV3EnableInterruptInterface (
 //  VOID
 //  );
-ASM_PFX(ArmGicV3EnableInterruptInterface):
+ASM_FUNC(ArmGicV3EnableInterruptInterface)
 mov x0, #1
 msr ICC_IGRPEN1_EL1, x0
 ret
@@ -86,7 +74,7 @@ ASM_PFX(ArmGicV3EnableInterruptInterface):
 //ArmGicV3DisableInterruptInterface (
 //  VOID
 //  );
-ASM_PFX(ArmGicV3DisableInterruptInterface):
+ASM_FUNC(ArmGicV3DisableInterruptInterface)
 mov x0, #0
 msr ICC_IGRPEN1_EL1, x0
 ret
@@ -95,7 +83,7 @@ ASM_PFX(ArmGicV3DisableInterruptInterface):
 //ArmGicV3EndOfInterrupt (
 //  IN UINTN  InterruptId
 //  );
-ASM_PFX(ArmGicV3EndOfInterrupt):
+ASM_FUNC(ArmGicV3EndOfInterrupt)
 msr ICC_EOIR1_EL1, x0
 ret
 
@@ -103,7 +91,7 @@ ASM_PFX(ArmGicV3EndOfInterrupt):
 //ArmGicV3AcknowledgeInterrupt (
 //  VOID
 //  );
-ASM_PFX(ArmGicV3AcknowledgeInterrupt):
+ASM_FUNC(ArmGicV3AcknowledgeInterrupt)
 mrs x0, ICC_IAR1_EL1
 ret
 
@@ -111,7 +99,7 @@ ASM_PFX(ArmGicV3AcknowledgeInterrupt):
 //ArmGicV3SetPriorityMask (
 //  IN UINTN  Priority
 //  );
-ASM_PFX(ArmGicV3SetPriorityMask):
+ASM_FUNC(ArmGicV3SetPriorityMask)
 msr ICC_PMR_EL1, x0
 ret
 
@@ -119,6 +107,6 @@ ASM_PFX(ArmGicV3SetPriorityMask):
 //ArmGicV3SetBinaryPointer (
 //  IN UINTN  BinaryPoint
 //  );
-ASM_PFX(ArmGicV3SetBinaryPointer):
+ASM_FUNC(ArmGicV3SetBinaryPointer)
 msr ICC_BPR1_EL1, x0
 ret
diff --git a/ArmPkg/Drivers/ArmGic/GicV3/Arm/ArmGicV3.S 
b/ArmPkg/Drivers/ArmGic/GicV3/Arm/ArmGicV3.S
index af14b91b9cfb..a72f3c865163 100644
--- a/ArmPkg/Drivers/ArmGic/GicV3/Arm/ArmGicV3.S
+++ b/ArmPkg/Drivers/ArmGic/GicV3/Arm/ArmGicV3.S
@@ -16,24 +16,12 @@
 
 // For the moment we assume this will run in SVC mode on ARMv7
 
-.text
-.align 2
-
-GCC_ASM_EXPORT(ArmGicV3GetControlSystemRegisterEnable)
-GCC_ASM_EXPORT(ArmGicV3SetControlSystemRegisterEnable)
-GCC_ASM_EXPORT(ArmGicV3EnableInterruptInterface)
-GCC_ASM_EXPORT(ArmGicV3DisableInterruptInterface)
-GCC_ASM_EXPORT(ArmGicV3EndOfInterrupt)
-GCC_ASM_EXPORT(ArmGicV3AcknowledgeInterrupt)
-GCC_ASM_EXPORT(ArmGicV3SetPriorityMask)
-GCC_ASM_EXPORT(ArmGicV3SetBinaryPointer)
-
 //UINT32
 //EFIAPI
 //ArmGicGetControlSystemRegisterEnable (
 //  VOID
 //  );
-ASM_PFX(ArmGicV3GetControlSystemRegisterEnable):
+ASM_FUNC(ArmGicV3GetControlSystemRegisterEnable)
 mrc p15, 0, r0, c12, c12, 5 // ICC_SRE
 bx  lr
 
@@ -42,7 +30,7 @@ ASM_PFX(ArmGicV3GetControlSystemRegisterEnable):
 //ArmGicSetControlSystemRegisterEnable (
 //  IN UINT32 ControlSystemRegisterEnable
 //  );
-ASM_PFX(ArmGicV3SetControlSystemRegisterEnable):
+ASM_FUNC(ArmGicV3SetControlSystemRegisterEnable)
 mcr p15, 0, r0, c12, c12, 5 // ICC_SRE
 isb
 bx  lr
@@ -51,7 +39,7 @@ ASM_PFX(ArmGicV3SetControlSystemRegisterEnable):
 //ArmGicV3EnableInterruptInterface (
 //  VOID
 //  );
-ASM_PFX(ArmGicV3EnableInterruptInterface):
+ASM_FUNC(ArmGicV3EnableInterruptInterface)
 mov r0, #1
 mcr p15, 0, r0, c12, c12, 7 // ICC_IGRPEN1
 bx  lr
@@ -60,7 +48,7 @@ ASM_PFX(ArmGicV3EnableInterruptInterface):
 //ArmGicV3DisableInterruptInterface (
 //  VOID
 //  );
-ASM_PFX(ArmGicV3D

[edk2] [PATCH 08/26] ArmPkg/ArmSmcLibNull: move to generic C implementation

2016-08-10 Thread Ard Biesheuvel
The C language is powerful enough to implement a function that does
absolutely nothing, so there is no need to resort to implementations
in assembler for various toolchains/architectures.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Library/ArmSmcLibNull/Arm/ArmSmcNull.S  | 20 
--
 ArmPkg/Library/ArmSmcLibNull/Arm/ArmSmcNull.asm| 20 
--
 ArmPkg/Library/ArmSmcLibNull/{AArch64/ArmSmcNull.S => ArmSmcLibNull.c} | 42 
++--
 ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.inf |  8 
+---
 4 files changed, 24 insertions(+), 66 deletions(-)

diff --git a/ArmPkg/Library/ArmSmcLibNull/Arm/ArmSmcNull.S 
b/ArmPkg/Library/ArmSmcLibNull/Arm/ArmSmcNull.S
deleted file mode 100644
index 9eaefd30cff4..
--- a/ArmPkg/Library/ArmSmcLibNull/Arm/ArmSmcNull.S
+++ /dev/null
@@ -1,20 +0,0 @@
-//
-//  Copyright (c) 2012-2014, ARM Limited. All rights reserved.
-//
-//  This program and the accompanying materials
-//  are licensed and made available under the terms and conditions of the BSD 
License
-//  which accompanies this distribution.  The full text of the license may be 
found at
-//  http://opensource.org/licenses/bsd-license.php
-//
-//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
-//
-//
-
-.text
-.align 3
-
-GCC_ASM_EXPORT(ArmCallSmc)
-
-ASM_PFX(ArmCallSmc):
-  bx lr
diff --git a/ArmPkg/Library/ArmSmcLibNull/Arm/ArmSmcNull.asm 
b/ArmPkg/Library/ArmSmcLibNull/Arm/ArmSmcNull.asm
deleted file mode 100644
index 3dcb25fa22f6..
--- a/ArmPkg/Library/ArmSmcLibNull/Arm/ArmSmcNull.asm
+++ /dev/null
@@ -1,20 +0,0 @@
-//
-//  Copyright (c) 2012-2014, ARM Limited. All rights reserved.
-//
-//  This program and the accompanying materials
-//  are licensed and made available under the terms and conditions of the BSD 
License
-//  which accompanies this distribution.  The full text of the license may be 
found at
-//  http://opensource.org/licenses/bsd-license.php
-//
-//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
-//
-//
-
-
-INCLUDE AsmMacroExport.inc
-
- RVCT_ASM_EXPORT ArmCallSmc
-  bx lr
-
-  END
diff --git a/ArmPkg/Library/ArmSmcLibNull/AArch64/ArmSmcNull.S 
b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
similarity index 73%
rename from ArmPkg/Library/ArmSmcLibNull/AArch64/ArmSmcNull.S
rename to ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
index a6ef0e04da82..e5d4e511330c 100644
--- a/ArmPkg/Library/ArmSmcLibNull/AArch64/ArmSmcNull.S
+++ b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
@@ -1,20 +1,22 @@
-//
-//  Copyright (c) 2012-2014, ARM Limited. All rights reserved.
-//
-//  This program and the accompanying materials
-//  are licensed and made available under the terms and conditions of the BSD 
License
-//  which accompanies this distribution.  The full text of the license may be 
found at
-//  http://opensource.org/licenses/bsd-license.php
-//
-//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
-//
-//
-
-.text
-.align 3
-
-GCC_ASM_EXPORT(ArmCallSmc)
-
-ASM_PFX(ArmCallSmc):
-  ret
+//
+//  Copyright (c) 2016, Linaro Limited. All rights reserved.
+//
+//  This program and the accompanying materials
+//  are licensed and made available under the terms and conditions of the BSD 
License
+//  which accompanies this distribution.  The full text of the license may be 
found at
+//  http://opensource.org/licenses/bsd-license.php
+//
+//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+//
+//
+
+#include 
+#include 
+
+VOID
+ArmCallSmc (
+  IN OUT ARM_SMC_ARGS *Args
+  )
+{
+}
diff --git a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.inf 
b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.inf
index 6d75c28afbdd..db15a5f8bbb3 100644
--- a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.inf
+++ b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.inf
@@ -22,12 +22,8 @@ [Defines]
   VERSION_STRING = 1.0
   LIBRARY_CLASS  = ArmSmcLib
 
-[Sources.ARM]
-  Arm/ArmSmcNull.asm| RVCT
-  Arm/ArmSmcNull.S  | GCC
-
-[Sources.AARCH64]
-  AArch64/ArmSmcNull.S
+[Sources]
+  ArmSmcLibNull.c
 
 [Packages]
   MdePkg/MdePkg.dec
-- 
2.7.4

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


[edk2] [PATCH 03/26] ArmPkg/AsmMacroIoLib: remove unused obsolete MMIO and other asm macros

2016-08-10 Thread Ard Biesheuvel
This removes the various Mmio ASM macros that are not used anywhere in
the code, and removes some variants of LoadConstant... () that are not
used anywhere either.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Include/AsmMacroIoLib.h   | 213 
 ArmPkg/Include/AsmMacroIoLib.inc |  54 -
 2 files changed, 267 deletions(-)

diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h
index f94dcc619f7a..551b87803d19 100644
--- a/ArmPkg/Include/AsmMacroIoLib.h
+++ b/ArmPkg/Include/AsmMacroIoLib.h
@@ -24,88 +24,6 @@
 //  ldr reg, =expr does not work with current Apple tool chain. So do the work 
our selves
 //
 
-// returns _Data in R0 and _Address in R1
-#define MmioWrite32(_Address, _Data) \
-  ldr  r1, [pc, #8] ;\
-  ldr  r0, [pc, #8] ;\
-  str  r0, [r1] ;\
-  b1f   ;\
-  .long (_Address)  ;\
-  .long (_Data) ;\
-1:
-
-// returns _Data in R0 and _Address in R1, and _OrData in r2
-#define MmioOr32(_Address, _OrData) \
-  ldr  r1, [pc, #16];   \
-  ldr  r2, [pc, #16];   \
-  ldr  r0, [r1] ;   \
-  orr  r0, r0, r2   ;   \
-  str  r0, [r1] ;   \
-  b1f   ;   \
-  .long (_Address)  ;   \
-  .long (_OrData)   ;   \
-1:
-
-// returns _Data in R0 and _Address in R1, and _OrData in r2
-#define MmioAnd32(_Address, _AndData) \
-  ldr  r1, [pc, #16]; \
-  ldr  r2, [pc, #16]; \
-  ldr  r0, [r1] ; \
-  and  r0, r0, r2   ; \
-  str  r0, [r1] ; \
-  b1f   ; \
-  .long (_Address)  ; \
-  .long (_AndData)   ; \
-1:
-
-// returns result in R0, _Address in R1, and _OrData in r2
-#define MmioAndThenOr32(_Address, _AndData, _OrData)  \
-  ldr  r1, [pc, #24]; \
-  ldr  r0, [r1] ; \
-  ldr  r2, [pc, #20]; \
-  and  r0, r0, r2   ; \
-  ldr  r2, [pc, #16]; \
-  orr  r0, r0, r2   ; \
-  str  r0, [r1] ; \
-  b1f   ; \
-  .long (_Address)  ; \
-  .long (_AndData)  ; \
-  .long (_OrData)   ; \
-1:
-
-// returns _Data in _Reg and _Address in R1
-#define MmioWriteFromReg32(_Address, _Reg) \
-  ldr  r1, [pc, #4] ;  \
-  str  _Reg, [r1]   ;  \
-  b1f   ;  \
-  .long (_Address)  ;  \
-1:
-
-
-// returns _Data in R0 and _Address in R1
-#define MmioRead32(_Address)   \
-  ldr  r1, [pc, #4] ;  \
-  ldr  r0, [r1] ;  \
-  b1f   ;  \
-  .long (_Address)  ;  \
-1:
-
-// returns _Data in Reg and _Address in R1
-#define MmioReadToReg32(_Address, _Reg) \
-  ldr  r1, [pc, #4] ;   \
-  ldr  _Reg, [r1]   ;   \
-  b1f   ;   \
-  .long (_Address)  ;   \
-1:
-
-
-// load R0 with _Data
-#define LoadConstant(_Data)  \
-  ldr  r0, [pc, #0] ;\
-  b1f   ;\
-  .long (_Data) ;\
-1:
-
 // load _Reg with _Data
 #define LoadConstantToReg(_Data, _Reg)  \
   ldr  _Reg, [pc, #0]   ;   \
@@ -113,91 +31,8 @@
   .long (_Data) ;   \
 1:
 
-// load _Reg with _Data if eq
-#define LoadConstantToRegIfEq(_Data, _Reg)  \
-  ldreq  _Reg, [pc, #0]   ; \
-  b1f ; \
-  .long (_Data)   ; \
-1:
-
-// Reserve a region at the top of the Primary Core stack
-// for Global variables for the XIP phase
-#define SetPrimaryStack(StackTop, GlobalSize, Tmp)  \
-  and Tmp, GlobalSize, #7 ; \
-  rsbne   Tmp, Tmp, #8; \
-  add GlobalSize, GlobalSize, Tmp ; \
-  sub sp, StackTop, GlobalSize; \
-  ; \
-  mov Tmp, sp ; \
-  mov GlobalSize, #0x0; \
-_SetPrimaryStackInitGlobals:  ; \
-  cmp Tmp, StackTop   ; \
-  beq _SetPrimaryStackEnd ; \
-  str GlobalSize, [Tmp], #4   ; \
-  b   _SetPrimaryStackInitGlobals ; \
-_SetPrimaryStackEnd:
-
-// Initialize the Global Variable with '0'
-#define InitializePrimaryStack(GlobalSize, Tmp1)\
-  and Tmp1, GlobalSize, #7; \
-  rsbne   Tmp1, Tmp1, #8  

[edk2] [PATCH 06/26] ArmVirt/PrePi: make jump to CEntryPoint relative

2016-08-10 Thread Ard Biesheuvel
The ArmVirtPkg platforms that use PrePi have no notion of boot remapped
aliases, so we can simply jump to CEntryPoint() directly rather than
via an absolute reference.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S | 7 +--
 ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S | 7 +--
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S 
b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
index d6be34541834..1fed84ed0ac3 100644
--- a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
+++ b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
@@ -27,7 +27,6 @@ GCC_ASM_IMPORT(ArmPlatformStackSet)
 GCC_ASM_EXPORT(_ModuleEntryPoint)
 ASM_GLOBAL ASM_PFX(mSystemMemoryEnd)
 
-StartupAddr:  .8byte ASM_PFX(CEntryPoint)
 ASM_PFX(mSystemMemoryEnd):.8byte 0
 
 ASM_PFX(_ModuleEntryPoint):
@@ -163,15 +162,11 @@ _PrepareArguments:
   mov   x1, x21
   mov   x2, x22
 
-  // Move sec startup address into a data register
-  // Ensure we're jumping to FV version of the code (not boot remapped alias)
-  ldr   x4, StartupAddr
-
   // Jump to PrePiCore C code
   //x0 = MpId
   //x1 = UefiMemoryBase
   //x2 = StacksBase
-  blr   x4
+  blASM_PFX(CEntryPoint)
 
 _NeverReturn:
   b _NeverReturn
diff --git a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S 
b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
index 3215c7d55876..a0176af91c8f 100644
--- a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
+++ b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
@@ -27,7 +27,6 @@ GCC_ASM_IMPORT(ArmPlatformStackSet)
 GCC_ASM_EXPORT(_ModuleEntryPoint)
 ASM_GLOBAL ASM_PFX(mSystemMemoryEnd)
 
-StartupAddr:  .long ASM_PFX(CEntryPoint)
 ASM_PFX(mSystemMemoryEnd):.quad 0
 
 __relocs:
@@ -182,15 +181,11 @@ _PrepareArguments:
   mov   r1, r11
   mov   r2, r9
 
-  // Move sec startup address into a data register
-  // Ensure we're jumping to FV version of the code (not boot remapped alias)
-  ldr   r4, StartupAddr
-
   // Jump to PrePiCore C code
   //r0 = MpId
   //r1 = UefiMemoryBase
   //r2 = StacksBase
-  blx   r4
+  blASM_PFX(CEntryPoint)
 
 _NeverReturn:
   b _NeverReturn
-- 
2.7.4

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


[edk2] [PATCH 04/26] ArmPlatformPkg RVCT: drop dependency on GCC macro library

2016-08-10 Thread Ard Biesheuvel
The RVCT .asm files include AsmMacroIoLib.h only for the definition of
LoadConstantToReg (), which makes it tedious to make change to that file
without the risk of making the RVCT assembler unhappy. So simply replace
LoadConstantToReg() with mov32, which does the right thing in all cases.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm 
|  7 +++--
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.asm
 |  8 +++---
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm
 | 12 +++--
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Boot.asm   
 |  5 ++--
 ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.asm
 | 10 +++-
 ArmPlatformPkg/Library/ArmPlatformStackLib/Arm/ArmPlatformStackLib.asm 
 |  4 +--
 ArmPlatformPkg/PrePeiCore/Arm/Exception.asm
 |  2 --
 ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm 
 | 14 +++---
 ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm  
 | 27 
 9 files changed, 29 insertions(+), 60 deletions(-)

diff --git 
a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm
 
b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm
index f377cf2e72c6..c035843da078 100644
--- 
a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm
+++ 
b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm
@@ -11,7 +11,6 @@
 //
 //
 
-#include 
 #include 
 
 #include 
@@ -48,7 +47,7 @@ ArmPlatformGetCorePosition FUNCTION
 ArmPlatformIsPrimaryCore FUNCTION
   // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
   // with cpu_id[0:3] and cluster_id[4:7]
-  LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r1)
+  mov32 r1, ARM_CTA15A7_SCC_CFGREG48
   ldr   r1, [r1]
   lsr   r1, #24
 
@@ -62,7 +61,7 @@ ArmPlatformIsPrimaryCore FUNCTION
   orr   r1, r1, r2
 
   // Keep the Cluster ID and Core ID from the MPID
-  LoadConstantToReg (ARM_CLUSTER_MASK :OR: ARM_CORE_MASK, r2)
+  mov32 r2, ARM_CLUSTER_MASK :OR: ARM_CORE_MASK
   and   r0, r0, r2
 
   // Compare mpid and boot cpu from ARM_SCC_CFGREG48
@@ -79,7 +78,7 @@ ArmPlatformIsPrimaryCore FUNCTION
 ArmPlatformGetPrimaryCoreMpId FUNCTION
   // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
   // with cpu_id[0:3] and cluster_id[4:7]
-  LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r0)
+  mov32 r0, ARM_CTA15A7_SCC_CFGREG48
   ldr   r0, [r0]
   lsr   r0, #24
 
diff --git 
a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.asm 
b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.asm
index aa48ed730e16..d5afd9211357 100644
--- 
a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.asm
+++ 
b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.asm
@@ -11,7 +11,6 @@
 //
 //
 
-#include 
 #include 
 
 #include 
@@ -33,7 +32,7 @@
 //  VOID
 //  );
 ArmPlatformGetPrimaryCoreMpId FUNCTION
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0)
+  mov32 r0, FixedPcdGet32(PcdArmPrimaryCore)
   ldr r0, [r0]
   bx  lr
   ENDFUNC
@@ -43,10 +42,9 @@ ArmPlatformGetPrimaryCoreMpId FUNCTION
 //  IN UINTN MpId
 //  );
 ArmPlatformIsPrimaryCore FUNCTION
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
-  ldr   r1, [r1]
+  mov32 r1, FixedPcdGet32(PcdArmPrimaryCoreMask)
   and   r0, r0, r1
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+  mov32 r1, FixedPcdGet32(PcdArmPrimaryCore)
   ldr   r1, [r1]
   cmp   r0, r1
   moveq r0, #1
diff --git 
a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm 
b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm
index f4ad51d36e06..66068e6595db 100644
--- 
a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm
+++ 
b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm
@@ -11,7 +11,6 @@
 //
 //
 
-#include 
 #include 
 #include 
 #include 
@@ -28,9 +27,6 @@
   EXPORTArmPlatformGetPrimaryCoreMpId
   EXPORTArmPlatformGetCorePosition
 
-  IMPORT_gPcd_FixedAtBuild_PcdArmPrimaryCore
-  IMPORT_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask
-
   AREA RTSMHelper, CODE, READONLY
 
 ArmPlatformPeiBootAction FUNCTION
@@ -52,8 +48,7 @@ ArmGetScuBaseAddress FUNCTION
 //  VOID
 //  );
 ArmPlatformGetPrimaryCoreMpId FUNCTION
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0)
-  ldr   r0, [r0]
+  mov32 r0, FixedPcdGet32(PcdArmPrimaryCore)
   bxlr
   ENDFUNC
 
@@ -99,10 +94,9 @@ _Return
 //  IN UINTN MpId
 //  );
 ArmPlatformIsPrimaryCore FUNCTION
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
-  ldr   r1, [r1]
+  mov32 r1, FixedPcdGet32(PcdA

[edk2] [PATCH 09/26] ArmPkg/ArmCpuLib: switch to ASM_FUNC() asm macro

2016-08-10 Thread Ard Biesheuvel
Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/AArch64/ArmCortexA5xHelper.S | 9 
++---
 ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Helper.S   | 9 
+
 2 files changed, 3 insertions(+), 15 deletions(-)

diff --git 
a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/AArch64/ArmCortexA5xHelper.S 
b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/AArch64/ArmCortexA5xHelper.S
index e5fbc86bc1c4..ba3d48f11f6d 100644
--- a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/AArch64/ArmCortexA5xHelper.S
+++ b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/AArch64/ArmCortexA5xHelper.S
@@ -14,16 +14,11 @@
 
 #include 
 
-.text
-.align 3
-GCC_ASM_EXPORT (ArmReadCpuExCr)
-GCC_ASM_EXPORT (ArmWriteCpuExCr)
-
-ASM_PFX(ArmReadCpuExCr):
+ASM_FUNC(ArmReadCpuExCr)
   mrs   x0, S3_1_c15_c2_1
   ret
 
-ASM_PFX(ArmWriteCpuExCr):
+ASM_FUNC(ArmWriteCpuExCr)
   msr   S3_1_c15_c2_1, x0
   dsb   sy
   isb
diff --git a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Helper.S 
b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Helper.S
index 5db586192206..365d57d7e8bd 100644
--- a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Helper.S
+++ b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Helper.S
@@ -12,17 +12,10 @@
 //
 
 #include 
-#include 
-#include 
-
-.text
-.align 3
-
-GCC_ASM_EXPORT(ArmGetScuBaseAddress)
 
 // IN None
 // OUT r0 = SCU Base Address
-ASM_PFX(ArmGetScuBaseAddress):
+ASM_FUNC(ArmGetScuBaseAddress)
   // Read Configuration Base Address Register. ArmCBar cannot be called to get
   // the Configuration BAR as a stack is not necessary setup. The SCU is at the
   // offset 0x from the Private Memory Region.
-- 
2.7.4

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


[edk2] [PATCH 00/26] ARM assembler cleanup series

2016-08-10 Thread Ard Biesheuvel
As requested by Eugene, this series introduces a new ASM_FUNC preprocessor
macro that emits functions into separate sections, allowing the linker to
get rid of the code that ends up unused in the module.

Note that using a native GNU as macro turned out to be problematic, due
to our use of Trim, and the fact that not all versions of GNU as honour
the -I option, making both #include (preprocessor) and .include (GNU as)
unusable to include files with shared macro definitions.

Since we're making a clean spot, let's introduce some other utility macros
as well, and clean up the various assembler files to use it. In particular,
clean up various patterns involving LoadConstantToReg(), including the gem

  LoadConstantToReg (_gPcd_FixedAtBuild_, rN)
  ldr  rN, [rN]

which performs two memory reads, including one that is subject to runtime
relocation, to load a compile time constant into a register. Note that this
is the definition of LoadConstantReg() we use for Clang, even on AARCH64:

  // load _Reg with _Data
  #define LoadConstantToReg(_Data, _Reg)\
ldr  _Reg, 1f ; \
b2f   ; \
  .align(8)   ; \
  1:\
.8byte (_Data); \
  2:

Other changes involve constant folding, i.e.,

 // Stack for the secondary core = Number of Cores - 1
  -  LoadConstantToReg (FixedPcdGet32(PcdCoreCount), x0)
  -  sub   x0, x0, #1
  -  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x1)
  -  mul   x1, x1, x0
  +  MOV32 (x1, (FixedPcdGet32(PcdCoreCount) - 1) * 
FixedPcdGet32(PcdCPUCoreSecondaryStackSize))

and

  -  LoadConstantToReg (FixedPcdGet64(PcdCPUCoresStackBase), r1)
  -  LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
  -  add   r1, r1, r2
  +  MOV32 (r1, FixedPcdGet64(PcdCPUCoresStackBase) + 
FixedPcdGet32(PcdCPUCorePrimaryStackSize))

(where r2 is dead after the add)

Code can be found here
https://git.linaro.org/people/ard.biesheuvel/uefi-next.git/shortlog/refs/heads/arm-asm-cleanup2

Ard Biesheuvel (26):
  ArmLib: remove ArmReplaceLiveTranslationEntry() implementation
  ArmPkg: add missing ArmMmuLib resolution to ArmPkg.dsc
  ArmPkg/AsmMacroIoLib: remove unused obsolete MMIO and other asm macros
  ArmPlatformPkg RVCT: drop dependency on GCC macro library
  ArmPkg: introduce ASM_FUNC, MOV32/MOV64 and ADRL/LDRL macros
  ArmVirt/PrePi: make jump to CEntryPoint relative
  ArmVirtPkg: clean up assembly source files
  ArmPkg/ArmSmcLibNull: move to generic C implementation
  ArmPkg/ArmCpuLib: switch to ASM_FUNC() asm macro
  ArmPkg/ArmGicV3: switch to ASM_FUNC() asm macro
  ArmPkg/ArmHvcLib: switch to ASM_FUNC() asm macro
  ArmPkg/ArmLib: switch to ASM_FUNC() asm macro
  ArmPkg/ArmMmuLib: switch to ASM_FUNC() asm macro
  ArmPkg/ArmSmcLib: switch to ASM_FUNC() asm macro
  ArmPkg/BaseMemoryLibSm: switch to ASM_FUNC() asm macro
  ArmPkg/BaseMemoryLibVstm: switch to ASM_FUNC() asm macro
  ArmPkg/CompilerIntrinsicsLib: switch to ASM_FUNC() asm macro
  ArmPkg/SemihostLib: switch to ASM_FUNC() asm macro
  BeagleBoardPkg: remove unused Sec.inf module
  BeagleBoardPkg: add missing ArmMmuLib resolution
  ArmPlatformPkg/ArmJunoLib: switch to ASM_FUNC() asm macro
  ArmPlatformPkg/PrePi: switch to ASM_FUNC() asm macro
  ArmPlatformPkg/PrePeiCore: switch to ASM_FUNC() asm macro
  ArmPlatformPkg/ArmVExpressPkg: switch to ASM_FUNC() asm macro
  ArmPlatformPkg/ArmPlatformLibNull: switch to ASM_FUNC() asm macro
  ArmPlatformPkg/ArmPlatformStackLib: switch to ASM_FUNC() asm macro

 ArmPkg/ArmPkg.dsc  
  |   4 +
 ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/AArch64/ArmCortexA5xHelper.S  
  |   9 +-
 ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Helper.S
  |   9 +-
 ArmPkg/Drivers/ArmGic/GicV3/AArch64/ArmGicV3.S 
  |  28 +-
 ArmPkg/Drivers/ArmGic/GicV3/Arm/ArmGicV3.S 
  |  28 +-
 ArmPkg/Include/AsmMacroIoLib.h 
  | 232 ++--
 ArmPkg/Include/AsmMacroIoLib.inc   
  |  54 
 ArmPkg/Include/AsmMacroIoLibV8.h   
  |  20 +-
 ArmPkg/Library/ArmHvcLib/AArch64/ArmHvc.S  
  |   9 +-
 ArmPkg/Library/ArmHvcLib/Arm/ArmHvc.S  
  |  10 +-
 ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimerSupport.S
  |  67 ++---
 ArmPkg/Library/ArmLib/AArch64/AArch64Support.S 
  | 181 +++--
 ArmPkg/Library/ArmLib/AArch64/ArmLibSupportV8.S
  |  43 +--
 ArmPkg/Library/ArmLib/ArmV7/ArmLibSupportV7.S  
  |  47 +---
 ArmPkg/Library/ArmLib/ArmV7/ArmV7ArchTimerSupport.S

[edk2] [PATCH 02/26] ArmPkg: add missing ArmMmuLib resolution to ArmPkg.dsc

2016-08-10 Thread Ard Biesheuvel
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/ArmPkg.dsc | 4 
 1 file changed, 4 insertions(+)

diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
index df5be6e21f33..7b278cdd4124 100644
--- a/ArmPkg/ArmPkg.dsc
+++ b/ArmPkg/ArmPkg.dsc
@@ -86,6 +86,8 @@ [LibraryClasses.common]
 
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
 
+  ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
+
 [LibraryClasses.ARM]
   ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf
 
@@ -145,6 +147,8 @@ [Components.common]
 
   ArmPkg/Application/LinuxLoader/LinuxLoader.inf
 
+  ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
+
 [Components.ARM]
   ArmPkg/Library/BaseMemoryLibVstm/BaseMemoryLibVstm.inf
 
-- 
2.7.4

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


[edk2] [PATCH 01/26] ArmLib: remove ArmReplaceLiveTranslationEntry() implementation

2016-08-10 Thread Ard Biesheuvel
The function ArmReplaceLiveTranslationEntry() has been moved to
ArmMmuLib, so remove the old implementation from ArmLib.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Library/ArmLib/AArch64/AArch64Support.S   | 60 

 ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S |  4 ++
 2 files changed, 4 insertions(+), 60 deletions(-)

diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S 
b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
index 9441f47e30ba..5cef98fd42a0 100644
--- a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
+++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
@@ -488,64 +488,4 @@ ASM_PFX(ArmReadCurrentEL):
   mrs   x0, CurrentEL
   ret
 
-
-  .macro __replace_entry, el
-
-  // disable the MMU
-  mrs   x8, sctlr_el\el
-  bic   x9, x8, #CTRL_M_BIT
-  msr   sctlr_el\el, x9
-  isb
-
-  // write updated entry
-  str   x1, [x0]
-
-  // invalidate again to get rid of stale clean cachelines that may
-  // have been filled speculatively since the last invalidate
-  dmb   sy
-  dcivac, x0
-
-  // flush the TLBs
-  .if   \el == 1
-  tlbi  vmalle1
-  .else
-  tlbi  alle\el
-  .endif
-  dsb   sy
-
-  // re-enable the MMU
-  msr   sctlr_el\el, x8
-  isb
-  .endm
-
-//VOID
-//ArmReplaceLiveTranslationEntry (
-//  IN  UINT64  *Entry,
-//  IN  UINT64  Value
-//  )
-ASM_PFX(ArmReplaceLiveTranslationEntry):
-
-  // disable interrupts
-  mrs   x2, daif
-  msr   daifset, #0xf
-  isb
-
-  // clean and invalidate first so that we don't clobber
-  // adjacent entries that are dirty in the caches
-  dccivac, x0
-  dsb   ish
-
-  EL1_OR_EL2_OR_EL3(x3)
-1:__replace_entry 1
-  b 4f
-2:__replace_entry 2
-  b 4f
-3:__replace_entry 3
-
-4:msr   daif, x2
-  ret
-
-ASM_PFX(ArmReplaceLiveTranslationEntrySize):
-  .long   . - ArmReplaceLiveTranslationEntry
-
 ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S 
b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
index 7c5d205d940b..3834da7bfedd 100644
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
@@ -14,6 +14,8 @@
 
 #include 
 
+GCC_ASM_EXPORT(ArmReplaceLiveTranslationEntry)
+
   .set CTRL_M_BIT,  (1 << 0)
 
   .macro __replace_entry, el
@@ -72,5 +74,7 @@ ASM_PFX(ArmReplaceLiveTranslationEntry):
 4:msr   daif, x2
   ret
 
+ASM_GLOBAL ASM_PFX(ArmReplaceLiveTranslationEntrySize)
+
 ASM_PFX(ArmReplaceLiveTranslationEntrySize):
   .long   . - ArmReplaceLiveTranslationEntry
-- 
2.7.4

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


Re: [edk2] [Patch] CryptoPkg IntrinsicLib: Add the missing nasm source file

2016-08-10 Thread Long, Qin
Reviewed-by: Qin Long 

Best Regards & Thanks,
LONG, Qin

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Liming 
> Gao
> Sent: Wednesday, August 10, 2016 8:24 PM
> To: edk2-devel@lists.01.org
> Cc: Long, Qin 
> Subject: [edk2] [Patch] CryptoPkg IntrinsicLib: Add the missing nasm source 
> file
> 
> Add two name files IntrinsicLib Ia32 MathLShiftS64.nasm and MathRShiftU64.nasm
> 
> Cc: Qin Long 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Liming Gao 
> ---
>  .../Library/IntrinsicLib/Ia32/MathLShiftS64.nasm   | 48 +
>  .../Library/IntrinsicLib/Ia32/MathRShiftU64.nasm   | 49 
> ++
>  CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf|  2 +
>  3 files changed, 99 insertions(+)
>  create mode 100644 CryptoPkg/Library/IntrinsicLib/Ia32/MathLShiftS64.nasm
>  create mode 100644 CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.nasm
> 
> diff --git a/CryptoPkg/Library/IntrinsicLib/Ia32/MathLShiftS64.nasm 
> b/CryptoPkg/Library/IntrinsicLib/Ia32/MathLShiftS64.nasm
> new file mode 100644
> index 000..a30edbf
> --- /dev/null
> +++ b/CryptoPkg/Library/IntrinsicLib/Ia32/MathLShiftS64.nasm
> @@ -0,0 +1,48 @@
> +;--
> +;
> +; Copyright (c) 2016, 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.
> +;
> +; Module Name:
> +;
> +;   MathLShiftS64.nasm
> +;
> +; Abstract:
> +;
> +;   64-bit Math Worker Function.
> +;   Shifts a 64-bit signed value left by a certain number of bits.
> +;
> +;--
> +
> +SECTION .text
> +
> +global ASM_PFX(__ashldi3)
> +;--
> +;
> +; void __cdecl __ashldi3 (void)
> +;
> +;--
> +ASM_PFX(__ashldi3):
> +cmp cl,0x40
> +jnc ReturnZero
> +cmp cl,0x20
> +jnc More32
> +shld edx,eax,cl
> +shl eax,cl
> +ret
> +More32:
> +mov edx,eax
> +xor eax,eax
> +and cl,0x1f
> +shl edx,cl
> +ret
> +ReturnZero:
> +xor eax,eax
> +xor edx,edx
> +ret
> diff --git a/CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.nasm 
> b/CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.nasm
> new file mode 100644
> index 000..9bf1711
> --- /dev/null
> +++ b/CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.nasm
> @@ -0,0 +1,49 @@
> +;--
> +;
> +; Copyright (c) 2016, 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.
> +;
> +; Module Name:
> +;
> +;   MathRShiftU64.nasm
> +;
> +; Abstract:
> +;
> +;   64-bit Math Worker Function.
> +;   Shifts a 64-bit unsigned value right by a certain number of bits.
> +;
> +;--
> +
> +SECTION .text
> +
> +;--
> +;
> +; void __cdecl __ashrdi3 (void)
> +;
> +;--
> +global ASM_PFX(__ashrdi3)
> +ASM_PFX(__ashrdi3):
> +cmp cl,0x40
> +jnc _Exit
> +cmp cl,0x20
> +jnc More32
> +shrd eax,edx,cl
> +shr edx,cl
> +ret
> +More32:
> +mov eax,edx
> +xor edx,edx
> +and cl,0x1f
> +shr eax,cl
> +ret
> +_Exit:
> +xor eax,eax
> +xor edx,edx
> +ret
> +
> diff --git a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf 
> b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
> index de61dc4..9495750 100644
> --- a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
> +++ b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
> @@ -41,6 +41,8 @@
> 
>Ia32/MathLShiftS64.S  | GCC
>Ia32/MathRShiftU64.S  | GCC
> +  Ia32/MathLShiftS64.nasm   | GCC
> +  Ia32/MathRShiftU64.nasm   | GCC
> 
>  [Sources.X64]
>CopyMem.c
> --
> 2.8.0.windows.1
> 
> ___
> edk2-devel mailing list

[edk2] [Add UDK2017 branch in edk2 for new UDK release]

2016-08-10 Thread Gao, Liming
Hi, all
  New UDK release UDK2017 is on plan. Its target will be at early Q1 of 2017. 
Main features in this release are listed below. This patch requests to create 
UDK2017 branch based on edk2 master.

1.   UEFI2.6 Features: EMMC/SD Stack, RamDisk, MemoryAttributesTable, IPv6 
Http Boot, URI Configuration

2.   PI1.4 Errata A

3.   FSP2.0

4.   OpenSsl 1.0.2h

5.   NASM transition

6.   VS2015/GCC5/CLANG38 tool chain

7.   Misc:

1)  CPU MP Initialize Library, PiSmmCpuDxeSmm driver

2)  Generic SataController, PciHostBridgeDxe driver

3)  LoadFileOnFv2 driver

4)  PciSioSerialDxe/SerialDxe driver

5)  Opal password support

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


Re: [edk2] [PATCH v2 2/2] MdeModulePkg/Browser: Share default if some default value are not specified

2016-08-10 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Bi, Dandan
> Sent: Tuesday, August 09, 2016 9:25 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming ; Dong, Eric 
> Subject: [PATCH v2 2/2] MdeModulePkg/Browser: Share default if some
> default value are not specified
> 
> Add a new implementation policy of getting default value in SetupBrowser.
> The new policy is only for the situation that a question has default
> value but doesn't have default value for all supported default type.
> In this case, we will choose the smallest default id from the existing
> defaults, and share its value to other default id which has no
> default value.
> 
> Notes:
> v1->V2:
> Generate DefaultStoreList as ascending order directly instead
> of using function GetDefaultIdArray().
> 
> Cc: Liming Gao 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi 
> ---
>  MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 25
> +++
>  MdeModulePkg/Universal/SetupBrowserDxe/Setup.c| 23
> -
>  2 files changed, 43 insertions(+), 5 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
> b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
> index 11a8fdc..61ba0b5 100644
> --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
> +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
> @@ -1,9 +1,9 @@
>  /** @file
>  Parser for IFR binary encoding.
> 
> -Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
> +Copyright (c) 2007 - 2016, 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
> 
> @@ -1309,10 +1309,13 @@ ParseOpCodes (
>EFI_VARSTORE_ID TempVarstoreId;
>BOOLEAN InScopeDisable;
>INTNConditionalExprCount;
>BOOLEAN InUnknownScope;
>UINT8   UnknownDepth;
> +  FORMSET_DEFAULTSTORE*PreDefaultStore;
> +  LIST_ENTRY  *DefaultLink;
> +  BOOLEAN HaveInserted;
> 
>SuppressForQuestion  = FALSE;
>SuppressForOption= FALSE;
>InScopeDisable   = FALSE;
>DepthOfDisable   = 0;
> @@ -1873,21 +1876,35 @@ ParseOpCodes (
> 
>  //
>  // DefaultStore
>  //
>  case EFI_IFR_DEFAULTSTORE_OP:
> +  HaveInserted = FALSE;
>DefaultStore = AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE));
>ASSERT (DefaultStore != NULL);
>DefaultStore->Signature = FORMSET_DEFAULTSTORE_SIGNATURE;
> 
>CopyMem (&DefaultStore->DefaultId,   &((EFI_IFR_DEFAULTSTORE *)
> OpCodeData)->DefaultId,   sizeof (UINT16));
>CopyMem (&DefaultStore->DefaultName, &((EFI_IFR_DEFAULTSTORE *)
> OpCodeData)->DefaultName, sizeof (EFI_STRING_ID));
> -
>//
> -  // Insert to DefaultStore list of this Formset
> +  // Insert it to the DefaultStore list of this Formset with ascending 
> order.
>//
> -  InsertTailList (&FormSet->DefaultStoreListHead, &DefaultStore->Link);
> +  if (!IsListEmpty (&FormSet->DefaultStoreListHead)) {
> +DefaultLink = GetFirstNode (&FormSet->DefaultStoreListHead);
> +while (!IsNull (&FormSet->DefaultStoreListHead, DefaultLink)) {
> +  PreDefaultStore =
> FORMSET_DEFAULTSTORE_FROM_LINK(DefaultLink);
> +  DefaultLink = GetNextNode (&FormSet->DefaultStoreListHead,
> DefaultLink);
> +  if (DefaultStore->DefaultId < PreDefaultStore->DefaultId) {
> +InsertTailList (&PreDefaultStore->Link, &DefaultStore->Link);
> +HaveInserted = TRUE;
> +break;
> +  }
> +}
> +  }
> +  if (!HaveInserted) {
> +InsertTailList (&FormSet->DefaultStoreListHead, &DefaultStore->Link);
> +  }
>break;
> 
>  //
>  // Statements
>  //
> diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
> b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
> index 6b38547..66c4313 100644
> --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
> +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
> @@ -4048,13 +4048,18 @@ GetQuestionDefault (
>EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess;
>EFI_BROWSER_ACTION_REQUEST  ActionRequest;
>INTNAction;
>CHAR16  *NewString;
>EFI_IFR_TYPE_VALUE  *TypeValue;
> +  UINT16  OriginalDefaultId;
> +  FORMSET_DEFAULTSTORE*DefaultStore;
> +  LIST_ENTRY  *DefaultLink;
> 
>Status   = EFI_NOT_FOUND;
>StrValue = NULL;
> +  OriginalDefaultId  = DefaultId;
> +  DefaultLink= GetFirstNode (&FormSet->DefaultStoreListHead);
> 
>//
>// Statement don't have s

[edk2] [Patch] CryptoPkg IntrinsicLib: Add the missing nasm source file

2016-08-10 Thread Liming Gao
Add two name files IntrinsicLib Ia32 MathLShiftS64.nasm and MathRShiftU64.nasm

Cc: Qin Long 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao 
---
 .../Library/IntrinsicLib/Ia32/MathLShiftS64.nasm   | 48 +
 .../Library/IntrinsicLib/Ia32/MathRShiftU64.nasm   | 49 ++
 CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf|  2 +
 3 files changed, 99 insertions(+)
 create mode 100644 CryptoPkg/Library/IntrinsicLib/Ia32/MathLShiftS64.nasm
 create mode 100644 CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.nasm

diff --git a/CryptoPkg/Library/IntrinsicLib/Ia32/MathLShiftS64.nasm 
b/CryptoPkg/Library/IntrinsicLib/Ia32/MathLShiftS64.nasm
new file mode 100644
index 000..a30edbf
--- /dev/null
+++ b/CryptoPkg/Library/IntrinsicLib/Ia32/MathLShiftS64.nasm
@@ -0,0 +1,48 @@
+;--
+;
+; Copyright (c) 2016, 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.
+;
+; Module Name:
+;
+;   MathLShiftS64.nasm
+;
+; Abstract:
+;
+;   64-bit Math Worker Function.
+;   Shifts a 64-bit signed value left by a certain number of bits.
+;
+;--
+
+SECTION .text
+
+global ASM_PFX(__ashldi3)
+;--
+;
+; void __cdecl __ashldi3 (void)
+;
+;--
+ASM_PFX(__ashldi3):
+cmp cl,0x40
+jnc ReturnZero
+cmp cl,0x20
+jnc More32
+shld edx,eax,cl
+shl eax,cl
+ret
+More32:
+mov edx,eax
+xor eax,eax
+and cl,0x1f
+shl edx,cl
+ret
+ReturnZero:
+xor eax,eax
+xor edx,edx
+ret
diff --git a/CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.nasm 
b/CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.nasm
new file mode 100644
index 000..9bf1711
--- /dev/null
+++ b/CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.nasm
@@ -0,0 +1,49 @@
+;--
+;
+; Copyright (c) 2016, 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.
+;
+; Module Name:
+;
+;   MathRShiftU64.nasm
+;
+; Abstract:
+;
+;   64-bit Math Worker Function.
+;   Shifts a 64-bit unsigned value right by a certain number of bits.
+;
+;--
+
+SECTION .text
+
+;--
+;
+; void __cdecl __ashrdi3 (void)
+;
+;--
+global ASM_PFX(__ashrdi3)
+ASM_PFX(__ashrdi3):
+cmp cl,0x40
+jnc _Exit
+cmp cl,0x20
+jnc More32
+shrd eax,edx,cl
+shr edx,cl
+ret
+More32:
+mov eax,edx
+xor edx,edx
+and cl,0x1f
+shr eax,cl
+ret
+_Exit:
+xor eax,eax
+xor edx,edx
+ret
+
diff --git a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf 
b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
index de61dc4..9495750 100644
--- a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+++ b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
@@ -41,6 +41,8 @@
 
   Ia32/MathLShiftS64.S  | GCC
   Ia32/MathRShiftU64.S  | GCC
+  Ia32/MathLShiftS64.nasm   | GCC
+  Ia32/MathRShiftU64.nasm   | GCC
 
 [Sources.X64]
   CopyMem.c
-- 
2.8.0.windows.1

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


Re: [edk2] SATA AHCI issue

2016-08-10 Thread Shaveta Leekha
Hi Feng,

PRD table entries are 16Byte aligned, as specified by AHCI spec also, it has 4 
DWs.

I have tried two HDD, but issue is same, TIMEOUT issue.
I have also tried copying one file on SATA HDD to another file on same SATA 
HDD(filesize > 4MB),
No issue occur in this scenario.

USB support is not yet there on our platform, so couldn't try that scenario.

Still not sure, where could be the issue?

Thanks and Regards,
Shaveta



-Original Message-
From: Tian, Feng [mailto:feng.t...@intel.com] 
Sent: Wednesday, August 10, 2016 10:49 AM
To: Shaveta Leekha ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Cc: Tian, Feng 
Subject: RE: SATA AHCI issue

PRD entries are organized like AHCI spec Figure 13 said.

Thanks
Feng

-Original Message-
From: Shaveta Leekha [mailto:shaveta.lee...@nxp.com] 
Sent: Tuesday, August 9, 2016 7:40 PM
To: Tian, Feng ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Subject: RE: SATA AHCI issue

Hi Feng,

Yes, I am using Tftp to get the file on HDD.

Have tried only one HardDisk, will try SATA disk from other vendors also, to 
get to the root cause.
Will also try copying data from SATA to SATA.

Are PRD entries aligned in EDK2 code base? (I mean they are aligned on which 
boundary? 16 Byte? 4KB?)

Best Regards,
Shaveta

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Tian, 
Feng
Sent: Tuesday, August 09, 2016 1:38 PM
To: Shaveta Leekha ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Cc: Tian, Feng 
Subject: Re: [edk2] SATA AHCI issue

Hi, Shaveta

I saw you are using TFTP cmd to do the test? Did you ever test copying file 
from  usb stick to the SATA HDD?

I just copied a 70M file from usb to SATA and from SATA to SATA. It works well.

Does this issue happen at all of your HDDs or only one specific brand model? Do 
you have other helpful info for us to narrow down?

Thanks
Feng

-Original Message-
From: Shaveta Leekha [mailto:shaveta.lee...@nxp.com] 
Sent: Tuesday, August 9, 2016 4:03 PM
To: Tian, Feng ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Subject: RE: SATA AHCI issue

Hi Feng,

Complete stack is:

  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
  FatPkg/FatPei/FatPei.inf
  FatPkg/EnhancedFatDxe/Fat.inf


Best Regards,
Shaveta

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Shaveta 
Leekha
Sent: Tuesday, August 09, 2016 1:07 PM
To: Tian, Feng ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Subject: Re: [edk2] SATA AHCI issue

Hi Feng,

Yes for 30MB file, multiple PRD entries would have been created.
But I able to write file only upto 4MB size.

The protocol stack I am using is:

Generic AtaBusDxe driver use EfiAtaPassThruProtocol Generic AtaAtapiPassThru 
driver consumes "EfiIdeControllerInitProtocol" and produces 
"EfiAtaPassThruProtocol" which is consumed by generic AtaBusDxe driver 
Platform-specific SATA driver that produces "EfiIdeControllerInitProtocol

I am writing SATA HDD at File level.
HDD is formatted with FAT32 which is identified as FileSytem by FATPKG.

Snippet of writing onto SATA HDD Filesystem is pasted below.

Thanks and Regards,
Shaveta


UEFI Interactive Shell v2.1
EDK II
UEFI v2.50 (LS2080a RDB board EFI Jul 25 2016 00:00:33, 0x) Mapping 
table
  FS0: Alias(s):F6a0a:;BLK0:
  PciRoot(0x0)/Pci(0x0,0x0)/Sata(0x0,0x0,0x0)
Shell>FS0:
FS0:\> tftp 192.168.3.161 test2 test
Downloading the file 'test2'
[===>]   0 Kb

-Original Message-
From: Tian, Feng [mailto:feng.t...@intel.com]
Sent: Tuesday, August 09, 2016 8:30 AM
To: Shaveta Leekha ; Linaro UEFI Mailman List 
; edk2-devel@lists.01.org
Cc: Tian, Feng 
Subject: RE: SATA AHCI issue

Hi, Shaveta

No, we will create multiple PRDs if the transfer length is larger than 4M. each 
PRD could represent a 4M transfer request and the maximum number of PRD for 
each command is 65535.

How do you access the HDD? At block level or file level? It happens at all HDDs 
or only one specific brand model?

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Shaveta 
Leekha
Sent: Monday, August 8, 2016 8:07 PM
To: Linaro UEFI Mailman List ; 
edk2-devel@lists.01.org
Subject: Re: [edk2] SATA AHCI issue

Hi,

As per the spec and the code in "AhciMode.c"

  // According to AHCI 1.3 spec, a PRDT entry can point to a maximum 4MB data 
block.

Does it mean, only one PRD entry is getting transferred successfully?
But as the data I am writing onto SATA HDD is 30MB big, what about the rest of 
PRDs?
What could be went here?

Thanks and Regards,
Shaveta

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Shaveta 
Leekha
Sent: Monday, August 08, 2

Re: [edk2] [PATCH v2 1/2] MdeModulePkg/HiiDB: Share default if some default value are not specified

2016-08-10 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Bi, Dandan
> Sent: Tuesday, August 09, 2016 9:25 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming ; Dong, Eric 
> Subject: [PATCH v2 1/2] MdeModulePkg/HiiDB: Share default if some default
> value are not specified
> 
> Add a new implementation policy of getting default value in HiiDatabase.
> The new policy is only for the situation that a question has default
> value but doesn't have default value for all supported default type.
> In this case, we will choose the smallest default id from the existing
> defaults, and share its value to other default id which has no
> default value.
> 
> Notes:
> v1->V2:
> Clarify that when the type of DefaultValueData is
> DefaultValueFromOtherDefault,it can be overrode by itself.
> 
> Cc: Liming Gao 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi 
> ---
>  .../Universal/HiiDatabaseDxe/ConfigRouting.c   | 116
> ++---
>  .../Universal/HiiDatabaseDxe/HiiDatabase.h |   2 +
>  2 files changed, 102 insertions(+), 16 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> index 0578352..546e60c 100644
> --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> @@ -1149,12 +1149,13 @@ InsertDefaultValue (
>for (Link = DefaultLink->ForwardLink; Link != DefaultLink; Link = Link-
> >ForwardLink) {
>  DefaultValueArray = BASE_CR (Link, IFR_DEFAULT_DATA, Entry);
>  if (DefaultValueArray->DefaultId == DefaultValueData->DefaultId) {
>//
>// DEFAULT_VALUE_FROM_OPCODE has high priority,
> DEFAULT_VALUE_FROM_DEFAULT has low priority.
> +  // When the two default types are
> DEFAULT_VALUE_FROM_OTHER_DEFAULT, the default value can be
> overrode.
>//
> -  if (DefaultValueData->Type > DefaultValueArray->Type) {
> +  if ((DefaultValueData->Type > DefaultValueArray->Type) ||
> (DefaultValueData->Type == DefaultValueArray->Type &&
> DefaultValueData->Type == DefaultValueFromOtherDefault)) {
>  //
>  // Update the default value array in BlockData.
>  //
>  CopyMem (&DefaultValueArray->Value, &DefaultValueData->Value,
> sizeof (EFI_IFR_TYPE_VALUE));
>  DefaultValueArray->Type  = DefaultValueData->Type;
> @@ -2099,19 +2100,22 @@ ParseIfrData (
>LIST_ENTRY   *LinkData;
>LIST_ENTRY   *LinkDefault;
>EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore;
>EFI_HII_PACKAGE_HEADER   *PackageHeader;
>EFI_VARSTORE_ID  VarStoreId;
> +  UINT16   SmallestDefaultId;
> +  UINT16   SmallestIdFromFlag;
> 
>Status   = EFI_SUCCESS;
>BlockData= NULL;
>DefaultDataPtr   = NULL;
>FirstOneOfOption = FALSE;
>VarStoreId   = 0;
>FirstOrderedList = FALSE;
>VarStoreName = NULL;
>ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA));
> +  SmallestDefaultId = 0x;
> 
>//
>// Go through the form package to parse OpCode one by one.
>//
>PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);
> @@ -2473,10 +2477,12 @@ ParseIfrData (
>//
>//when go to there,BlockData can't be NULLL.
>//
>ASSERT (BlockData != NULL);
> 
> +  SmallestIdFromFlag = FALSE;
> +
>//
>// Add default value for standard ID by CheckBox Flag
>//
>VarDefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
>//
> @@ -2487,21 +2493,20 @@ ParseIfrData (
>  //
>  // When flag is set, defautl value is TRUE.
>  //
>  DefaultData.Type= DefaultValueFromFlag;
>  DefaultData.Value.b = TRUE;
> -  } else {
> -//
> -// When flag is not set, defautl value is FASLE.
> -//
> -DefaultData.Type= DefaultValueFromDefault;
> -DefaultData.Value.b = FALSE;
> +InsertDefaultValue (BlockData, &DefaultData);
> +
> +if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_STANDARD) {
> +  //
> +  // Record the SmallestDefaultId and update the SmallestIdFromFlag.
> +  //
> +  SmallestDefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
> +  SmallestIdFromFlag = TRUE;
> +}
>}
> -  //
> -  // Add DefaultValue into current BlockData
> -  //
> -  InsertDefaultValue (BlockData, &DefaultData);
> 
>//
>// Add default value for Manufacture ID by CheckBox Flag
>//
>VarDefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING;
> @@ -2513,21 +2518,49 @@ ParseIfrData (
>  //
>  // When flag is set, defautl value is TRUE.
>  //
>  DefaultData.Type= DefaultValueFromFlag;
>  DefaultData.Value.b = TRUE;
> +InsertDefaultValue (BlockData, &DefaultData);
> +
> +if (SmallestDefaultId > E

Re: [edk2] [patch] MdeModulePkg/DriverSample: Skip the character "&" before "OFFSET="

2016-08-10 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Bi, Dandan
> Sent: Wednesday, August 10, 2016 11:11 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming ; Dong, Eric 
> Subject: [patch] MdeModulePkg/DriverSample: Skip the character "&"
> before "OFFSET="
> 
> When comparing the L"OFFSET=" with the ConfigResp string to find
> all the "OFFSET=" in ConfigResp, should skip the character "&"
> before "OFFSET=" in ConfigResp string.
> 
> Cc: Liming Gao 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi 
> Reviewed-by: Eric Dong 
> ---
>  MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
> b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
> index 9c5d4bb..ea6b124 100644
> --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
> +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
> @@ -776,10 +776,15 @@ AppendAltCfgString (
>return;
>  }
>  StringPtr += Length;
> 
>  //
> +// Skip the character "&" before "OFFSET".
> +//
> +StringPtr ++;
> +
> +//
>  // Calculate Value and convert it to hex string.
>  //
>  if (Offset + Width > BlockSize) {
>return;
>  }
> --
> 1.9.5.msysgit.1

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


[edk2] [PATCH] BaseTools/GccBase.lds: don't copy RELA section to PE/COFF

2016-08-10 Thread Ard Biesheuvel
The CLANG38 toolchain creates a PIE binary at link time. This is
necessary since the LTO code generation may otherwise result in
code that cannot execute correctly when loaded above 2 GB.

PIE executables contain a RELA section consisting of dynamic
relocation entries that are intended for consumption by the loader
at runtime. For this reason, it has the SHF_ALLOC attribute set by
default, and will be identified by GenFw as a section that needs to
be copied into the PE/COFF binary, resulting in waste of space since
the PE/COFF loader does not use this data at all.

So mark the RELA section as informational: this will prevent the
linker from setting the SHF_ALLOC attribute, causing GenFw to
ignore it.

DxeCore.efi before:

Detected 'X64' type PE/COFF image consisting of 3 sections
Section alignment:  0x40
File alignment: 0x40
Section '.text' @ 0x0240
File offset:0x240
Virtual size:   0x21000
Raw size:   0x21000
Section '.data' @ 0x00021240
File offset:0x21240
Virtual size:   0x3640
Raw size:   0x3640
Section '.reloc' @ 0x00024880
File offset:0x24880
Virtual size:   0x280
Raw size:   0x280

DxeCore.efi after:

Detected 'X64' type PE/COFF image consisting of 3 sections
Section alignment:  0x40
File alignment: 0x40
Section '.text' @ 0x0240
File offset:0x240
Virtual size:   0x1f440
Raw size:   0x1f440
Section '.data' @ 0x0001f680
File offset:0x1f680
Virtual size:   0x3640
Raw size:   0x3640
Section '.reloc' @ 0x00022cc0
File offset:0x22cc0
Virtual size:   0x280
Raw size:   0x280

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 BaseTools/Scripts/GccBase.lds | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Scripts/GccBase.lds b/BaseTools/Scripts/GccBase.lds
index 281af8a9bd33..900848747144 100644
--- a/BaseTools/Scripts/GccBase.lds
+++ b/BaseTools/Scripts/GccBase.lds
@@ -54,7 +54,7 @@ SECTIONS {
 KEEP (*(.eh_frame))
   }
 
-  .rela ALIGN(CONSTANT(COMMONPAGESIZE)) : {
+  .rela (INFO) : {
 *(.rela .rela.*)
   }
 
-- 
2.7.4

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


[edk2] [patch] BaseTool/VfrCompile: Remove reset button opcode in CheckQuestionOpCode

2016-08-10 Thread Dandan Bi
"EFI_IFR_RESET_BUTTON_OP" is a statement, not a question,
so remove it from function CheckQuestionOpCode.

Cc: Liming Gao 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp 
b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index db1e4bd..0b7b8b1 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -1199,11 +1199,10 @@ CIfrRecordInfoDB::CheckQuestionOpCode (
   case EFI_IFR_STRING_OP:
   case EFI_IFR_DATE_OP:
   case EFI_IFR_TIME_OP:
   case EFI_IFR_ORDERED_LIST_OP:
   case EFI_IFR_REF_OP:
-  case EFI_IFR_RESET_BUTTON_OP:
 return TRUE;
   default:
 return FALSE;
   }
 }
-- 
1.9.5.msysgit.1

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