Re: [edk2] reasoning beehind prohibiting VFP/NEON on AArch32

2018-05-13 Thread Ard Biesheuvel
On 12 May 2018 at 23:11, Michael Zimmermann  wrote:
> For AArch32 the spec says in 2.3.5.3:
>> Floating point, SIMD, vector operations and other instruction set
> extensions must not
> be used.
>
> For AArch64 the spec says in 2.3.6.4:
>> Floating point and SIMD instructions may be used.
>
> So is there a reason why AArch32 is not allowed to use Floating point
> operations?
> I'd understand if this restriction was limited to runtime services only but
> I don't see how it makes sense for boot services.
>
> I've written a patch which adds NEON support to FrameBufferBltLib to
> increase the rendering performance(by a lot actually) for 24bit displays
> and thought about sending it to the mailing list - that's why the question
> came up.
>

The reason for the difference between AArch64 and the other EFI
architectures is that AArch64 does not have a softfloat ABI, so it is
impossible to compile floating point code [portably] without enabling
VFP/NEON. This is why AArch64 is the exception here.

Currently, the AArch32 CPU context structure [EFI_SYSTEM_CONTEXT_ARM]
does not cover VFP/NEON registers, and so they are not
preserved/restored when an interrupt is taken. This means you cannot
use VFP/NEON registers in an event handler or you will corrupt the
VFP/NEON state of the interrupted context.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] reasoning beehind prohibiting VFP/NEON on AArch32

2018-05-13 Thread Michael Zimmermann
So basically using them should be safe as long as you're in
EfiGetCurrentTpl() < TPL_HIGH_LEVEL, right?
Also, it'd probably be trivial to add  VFP/NEON regs to
EFI_SYSTEM_CONTEXT_ARM though that wouldn't help when writing apps for
existing uefi platforms.
On Sun, May 13, 2018 at 9:32 AM Ard Biesheuvel 
wrote:

> On 12 May 2018 at 23:11, Michael Zimmermann 
wrote:
> > For AArch32 the spec says in 2.3.5.3:
> >> Floating point, SIMD, vector operations and other instruction set
> > extensions must not
> > be used.
> >
> > For AArch64 the spec says in 2.3.6.4:
> >> Floating point and SIMD instructions may be used.
> >
> > So is there a reason why AArch32 is not allowed to use Floating point
> > operations?
> > I'd understand if this restriction was limited to runtime services only
but
> > I don't see how it makes sense for boot services.
> >
> > I've written a patch which adds NEON support to FrameBufferBltLib to
> > increase the rendering performance(by a lot actually) for 24bit displays
> > and thought about sending it to the mailing list - that's why the
question
> > came up.
> >

> The reason for the difference between AArch64 and the other EFI
> architectures is that AArch64 does not have a softfloat ABI, so it is
> impossible to compile floating point code [portably] without enabling
> VFP/NEON. This is why AArch64 is the exception here.

> Currently, the AArch32 CPU context structure [EFI_SYSTEM_CONTEXT_ARM]
> does not cover VFP/NEON registers, and so they are not
> preserved/restored when an interrupt is taken. This means you cannot
> use VFP/NEON registers in an event handler or you will corrupt the
> VFP/NEON state of the interrupted context.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] reasoning beehind prohibiting VFP/NEON on AArch32

2018-05-13 Thread Ard Biesheuvel
On 13 May 2018 at 11:48, Michael Zimmermann  wrote:
> So basically using them should be safe as long as you're in
> EfiGetCurrentTpl() < TPL_HIGH_LEVEL, right?

No, the other way around. You should raise the TPL to TPL_HIGH_LEVEL
to prevent being interrupted by something that may corrupt the NEON
registers.

> Also, it'd probably be trivial to add  VFP/NEON regs to
> EFI_SYSTEM_CONTEXT_ARM though that wouldn't help when writing apps for
> existing uefi platforms.

EFI_SYSTEM_CONTEXT_ARM is covered by the UEFI spec, so that is not
going to change.

> On Sun, May 13, 2018 at 9:32 AM Ard Biesheuvel 
> wrote:
>
>> On 12 May 2018 at 23:11, Michael Zimmermann 
> wrote:
>> > For AArch32 the spec says in 2.3.5.3:
>> >> Floating point, SIMD, vector operations and other instruction set
>> > extensions must not
>> > be used.
>> >
>> > For AArch64 the spec says in 2.3.6.4:
>> >> Floating point and SIMD instructions may be used.
>> >
>> > So is there a reason why AArch32 is not allowed to use Floating point
>> > operations?
>> > I'd understand if this restriction was limited to runtime services only
> but
>> > I don't see how it makes sense for boot services.
>> >
>> > I've written a patch which adds NEON support to FrameBufferBltLib to
>> > increase the rendering performance(by a lot actually) for 24bit displays
>> > and thought about sending it to the mailing list - that's why the
> question
>> > came up.
>> >
>
>> The reason for the difference between AArch64 and the other EFI
>> architectures is that AArch64 does not have a softfloat ABI, so it is
>> impossible to compile floating point code [portably] without enabling
>> VFP/NEON. This is why AArch64 is the exception here.
>
>> Currently, the AArch32 CPU context structure [EFI_SYSTEM_CONTEXT_ARM]
>> does not cover VFP/NEON registers, and so they are not
>> preserved/restored when an interrupt is taken. This means you cannot
>> use VFP/NEON registers in an event handler or you will corrupt the
>> VFP/NEON state of the interrupted context.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] Enable using device address when programming BARs

2018-05-13 Thread Ard Biesheuvel
On 9 May 2018 at 22:17, Roman Bacik  wrote:
> I will upload v2 with the corrected subject - add package name 
> MdeModulePkg/Bus
> .
>

I don't think this is the correct approach. Please use the address
translation support that has been added recently to PciHostBridgeDxe
and PciHostBridgeLib.

>
>
> *From:* Roman Bacik [mailto:roman.ba...@broadcom.com]
> *Sent:* Thursday, May 3, 2018 3:55 PM
> *To:* edk2-devel@lists.01.org
> *Cc:* Ruiyu Ni; Vladimir Olovyannikov
> *Subject:* [edk2] [PATCH] Enable using device address when programming BARs
>
>
>
> Some SoCs require to use device address when BARs are programmed:
> https://bugzilla.tianocore.org/show_bug.cgi?id=948
>
> Cc: Ruiyu Ni 
> Cc: Vladimir Olovyannikov 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Roman Bacik 
> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf| 1 +
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c | 8 +---
>  MdeModulePkg/MdeModulePkg.dec   | 3 +++
>  MdeModulePkg/MdeModulePkg.dsc   | 1 +
>  4 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> index 97608bfcf245..1368e5068574 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> @@ -110,6 +110,7 @@
>gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport  ## CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport## CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration##
> SOMETIMES_CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress## CONSUMES
>
>  [UserExtensions.TianoCore."ExtraFiles"]
>PciBusDxeExtra.uni
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
> index 2f713fcee95e..a23bd1e258ef 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
> @@ -1269,6 +1269,7 @@ ProgramBar (
>EFI_PCI_IO_PROTOCOL *PciIo;
>UINT64  Address;
>UINT32  Address32;
> +  BOOLEAN UseDeviceAddress;
>
>ASSERT (Node->Bar < PCI_MAX_BAR);
>
> @@ -1282,8 +1283,9 @@ ProgramBar (
>
>Address = 0;
>PciIo   = &(Node->PciDev->PciIo);
> +  UseDeviceAddress = FeaturePcdGet (PcdUseDeviceAddress);
>
> -  Address = Base + Node->Offset;
> +  Address = UseDeviceAddress? Node->Offset: Base + Node->Offset;
>
>//
>// Indicate pci bus driver has allocated
> @@ -1308,7 +1310,7 @@ ProgramBar (
>   &Address
>   );
>
> -Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
> +Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base +
> Address: Address;
>
>  break;
>
> @@ -1335,7 +1337,7 @@ ProgramBar (
>   &Address32
>   );
>
> -Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
> +Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base +
> Address: Address;
>
>  break;
>
> diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
> index cc397185f7b9..58425ee0d57f 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -1005,6 +1005,9 @@
># @Prompt Enable UEFI Stack Guard.
>gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055
>
> +  ## Indicates whether the device address should be used for BAR
> programming
> +
>  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE|BOOLEAN|0x30001056
> +
>  [PcdsFixedAtBuild, PcdsPatchableInModule]
>## Dynamic type PCD can be registered callback function for Pcd setting
> action.
>#  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of
> callback function
> diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
> index ec24a50c7d0a..39b397cb13d9 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -200,6 +200,7 @@
>gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x0
>gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x0
>gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries|28
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE
>
>  [PcdsFixedAtBuild.IPF]
>gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0c00
> --
> 1.9.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] reasoning beehind prohibiting VFP/NEON on AArch32

2018-05-13 Thread Michael Zimmermann
> No, the other way around. You should raise the TPL to TPL_HIGH_LEVEL
> to prevent being interrupted by something that may corrupt the NEON
> registers.
But isn't that only necessary if you assume that interrupt-handlers use VFP
registers?
afaik on ARM 
wrote:

> On 13 May 2018 at 11:48, Michael Zimmermann 
wrote:
> > So basically using them should be safe as long as you're in
> > EfiGetCurrentTpl() < TPL_HIGH_LEVEL, right?

> No, the other way around. You should raise the TPL to TPL_HIGH_LEVEL
> to prevent being interrupted by something that may corrupt the NEON
> registers.

> > Also, it'd probably be trivial to add  VFP/NEON regs to
> > EFI_SYSTEM_CONTEXT_ARM though that wouldn't help when writing apps for
> > existing uefi platforms.

> EFI_SYSTEM_CONTEXT_ARM is covered by the UEFI spec, so that is not
> going to change.

> > On Sun, May 13, 2018 at 9:32 AM Ard Biesheuvel <
ard.biesheu...@linaro.org>
> > wrote:
> >
> >> On 12 May 2018 at 23:11, Michael Zimmermann 
> > wrote:
> >> > For AArch32 the spec says in 2.3.5.3:
> >> >> Floating point, SIMD, vector operations and other instruction set
> >> > extensions must not
> >> > be used.
> >> >
> >> > For AArch64 the spec says in 2.3.6.4:
> >> >> Floating point and SIMD instructions may be used.
> >> >
> >> > So is there a reason why AArch32 is not allowed to use Floating point
> >> > operations?
> >> > I'd understand if this restriction was limited to runtime services
only
> > but
> >> > I don't see how it makes sense for boot services.
> >> >
> >> > I've written a patch which adds NEON support to FrameBufferBltLib to
> >> > increase the rendering performance(by a lot actually) for 24bit
displays
> >> > and thought about sending it to the mailing list - that's why the
> > question
> >> > came up.
> >> >
> >
> >> The reason for the difference between AArch64 and the other EFI
> >> architectures is that AArch64 does not have a softfloat ABI, so it is
> >> impossible to compile floating point code [portably] without enabling
> >> VFP/NEON. This is why AArch64 is the exception here.
> >
> >> Currently, the AArch32 CPU context structure [EFI_SYSTEM_CONTEXT_ARM]
> >> does not cover VFP/NEON registers, and so they are not
> >> preserved/restored when an interrupt is taken. This means you cannot
> >> use VFP/NEON registers in an event handler or you will corrupt the
> >> VFP/NEON state of the interrupted context.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] reasoning beehind prohibiting VFP/NEON on AArch32

2018-05-13 Thread Ard Biesheuvel
On 13 May 2018 at 12:58, Michael Zimmermann  wrote:
>> No, the other way around. You should raise the TPL to TPL_HIGH_LEVEL
>> to prevent being interrupted by something that may corrupt the NEON
>> registers.
> But isn't that only necessary if you assume that interrupt-handlers use VFP
> registers?

Event handlers are called from the timer interrupt handler. So unless
you want to restrict use of the NEON to non-event handler context
(which is not generally possible for libraries), you will need to
raise the TPL to avoid any interruptions.

> afaik on ARM  interrupt handler so basically if you're going to be interrupted during VFP
> operations no other 
> Please correct me if I'm misunderstanding something.

I don't follow. Your NEON code running at TPL_APPLICATION may be
interrupted at any time by event handlers running at higher TPL
levels. If such code uses the NEON, it will corrupt your register
file.



> On Sun, May 13, 2018 at 12:16 PM Ard Biesheuvel 
> wrote:
>
>> On 13 May 2018 at 11:48, Michael Zimmermann 
> wrote:
>> > So basically using them should be safe as long as you're in
>> > EfiGetCurrentTpl() < TPL_HIGH_LEVEL, right?
>
>> No, the other way around. You should raise the TPL to TPL_HIGH_LEVEL
>> to prevent being interrupted by something that may corrupt the NEON
>> registers.
>
>> > Also, it'd probably be trivial to add  VFP/NEON regs to
>> > EFI_SYSTEM_CONTEXT_ARM though that wouldn't help when writing apps for
>> > existing uefi platforms.
>
>> EFI_SYSTEM_CONTEXT_ARM is covered by the UEFI spec, so that is not
>> going to change.
>
>> > On Sun, May 13, 2018 at 9:32 AM Ard Biesheuvel <
> ard.biesheu...@linaro.org>
>> > wrote:
>> >
>> >> On 12 May 2018 at 23:11, Michael Zimmermann 
>> > wrote:
>> >> > For AArch32 the spec says in 2.3.5.3:
>> >> >> Floating point, SIMD, vector operations and other instruction set
>> >> > extensions must not
>> >> > be used.
>> >> >
>> >> > For AArch64 the spec says in 2.3.6.4:
>> >> >> Floating point and SIMD instructions may be used.
>> >> >
>> >> > So is there a reason why AArch32 is not allowed to use Floating point
>> >> > operations?
>> >> > I'd understand if this restriction was limited to runtime services
> only
>> > but
>> >> > I don't see how it makes sense for boot services.
>> >> >
>> >> > I've written a patch which adds NEON support to FrameBufferBltLib to
>> >> > increase the rendering performance(by a lot actually) for 24bit
> displays
>> >> > and thought about sending it to the mailing list - that's why the
>> > question
>> >> > came up.
>> >> >
>> >
>> >> The reason for the difference between AArch64 and the other EFI
>> >> architectures is that AArch64 does not have a softfloat ABI, so it is
>> >> impossible to compile floating point code [portably] without enabling
>> >> VFP/NEON. This is why AArch64 is the exception here.
>> >
>> >> Currently, the AArch32 CPU context structure [EFI_SYSTEM_CONTEXT_ARM]
>> >> does not cover VFP/NEON registers, and so they are not
>> >> preserved/restored when an interrupt is taken. This means you cannot
>> >> use VFP/NEON registers in an event handler or you will corrupt the
>> >> VFP/NEON state of the interrupted context.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] reasoning beehind prohibiting VFP/NEON on AArch32

2018-05-13 Thread Michael Zimmermann
I looked at ARMs TimerDxe and saw that mTimerNotifyFunction is called with
TPL_HIGH_LEVEL but didn't realize that RestoreTPL would call all pending
events.

Thank you for your help.
On Sun, May 13, 2018 at 1:39 PM Ard Biesheuvel 
wrote:

> On 13 May 2018 at 12:58, Michael Zimmermann 
wrote:
> >> No, the other way around. You should raise the TPL to TPL_HIGH_LEVEL
> >> to prevent being interrupted by something that may corrupt the NEON
> >> registers.
> > But isn't that only necessary if you assume that interrupt-handlers use
VFP
> > registers?

> Event handlers are called from the timer interrupt handler. So unless
> you want to restrict use of the NEON to non-event handler context
> (which is not generally possible for libraries), you will need to
> raise the TPL to avoid any interruptions.

> > afaik on ARM  > interrupt handler so basically if you're going to be interrupted during
VFP
> > operations no other  >
> > Please correct me if I'm misunderstanding something.

> I don't follow. Your NEON code running at TPL_APPLICATION may be
> interrupted at any time by event handlers running at higher TPL
> levels. If such code uses the NEON, it will corrupt your register
> file.



> > On Sun, May 13, 2018 at 12:16 PM Ard Biesheuvel <
ard.biesheu...@linaro.org>
> > wrote:
> >
> >> On 13 May 2018 at 11:48, Michael Zimmermann 
> > wrote:
> >> > So basically using them should be safe as long as you're in
> >> > EfiGetCurrentTpl() < TPL_HIGH_LEVEL, right?
> >
> >> No, the other way around. You should raise the TPL to TPL_HIGH_LEVEL
> >> to prevent being interrupted by something that may corrupt the NEON
> >> registers.
> >
> >> > Also, it'd probably be trivial to add  VFP/NEON regs to
> >> > EFI_SYSTEM_CONTEXT_ARM though that wouldn't help when writing apps
for
> >> > existing uefi platforms.
> >
> >> EFI_SYSTEM_CONTEXT_ARM is covered by the UEFI spec, so that is not
> >> going to change.
> >
> >> > On Sun, May 13, 2018 at 9:32 AM Ard Biesheuvel <
> > ard.biesheu...@linaro.org>
> >> > wrote:
> >> >
> >> >> On 12 May 2018 at 23:11, Michael Zimmermann <
sigmaepsilo...@gmail.com>
> >> > wrote:
> >> >> > For AArch32 the spec says in 2.3.5.3:
> >> >> >> Floating point, SIMD, vector operations and other instruction set
> >> >> > extensions must not
> >> >> > be used.
> >> >> >
> >> >> > For AArch64 the spec says in 2.3.6.4:
> >> >> >> Floating point and SIMD instructions may be used.
> >> >> >
> >> >> > So is there a reason why AArch32 is not allowed to use Floating
point
> >> >> > operations?
> >> >> > I'd understand if this restriction was limited to runtime services
> > only
> >> > but
> >> >> > I don't see how it makes sense for boot services.
> >> >> >
> >> >> > I've written a patch which adds NEON support to FrameBufferBltLib
to
> >> >> > increase the rendering performance(by a lot actually) for 24bit
> > displays
> >> >> > and thought about sending it to the mailing list - that's why the
> >> > question
> >> >> > came up.
> >> >> >
> >> >
> >> >> The reason for the difference between AArch64 and the other EFI
> >> >> architectures is that AArch64 does not have a softfloat ABI, so it
is
> >> >> impossible to compile floating point code [portably] without
enabling
> >> >> VFP/NEON. This is why AArch64 is the exception here.
> >> >
> >> >> Currently, the AArch32 CPU context structure
[EFI_SYSTEM_CONTEXT_ARM]
> >> >> does not cover VFP/NEON registers, and so they are not
> >> >> preserved/restored when an interrupt is taken. This means you cannot
> >> >> use VFP/NEON registers in an event handler or you will corrupt the
> >> >> VFP/NEON state of the interrupted context.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] Enabling network interface for Realtek8168 chip

2018-05-13 Thread Anatol Pomozov
Hello

I have a HP Chromebox (codename "zako") that is a small-form factor
nice x86 computer useful for experiments. I installed firmware from
Matt Davo - the firmware is Coreboot + UEFI payload. UEFI compiled
from this sourcecode fork https://github.com/MattDevo/edk2

At my cromebox I have an ethernet contoller that is identified by
Linux `lspci` as "01:00.0 Ethernet controller [0200]: Realtek
Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet
Controller [10ec:8168] (rev 0c)"

I want to use ethernet network from an UEFI application. I use
LocateHandle() to find a SimpleNetworkProtocol for me. Network works
fine with QEMU and Intel e1000e controller. But at real hardware at
Chromebox LocateHandle() handle returns error EFI_NOT_FOUND.

It sounds like the realtek driver is not enabled at UEFI firmware level.

Does anyone have pointers how to enable or implement Realtek8168 driver in edk2?
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 4/5] SourceLevelDebugPkg: Remove X86 ASM and S files

2018-05-13 Thread Liming Gao
NASM has replaced ASM and S files.
Rmove ASM from all modules.
Remove S files from the drivers only.
After NASM is updated, S files can be removed from Library.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
---
 .../DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.asm  | 422 -
 .../DebugAgent/DebugAgentCommon/X64/AsmFuncs.asm   | 405 
 .../Library/DebugAgent/DxeDebugAgentLib.inf|   2 -
 .../Library/DebugAgent/SecPeiDebugAgentLib.inf |   2 -
 .../Library/DebugAgent/SmmDebugAgentLib.inf|   2 -
 .../PeCoffExtraActionLibDebug/Ia32/IntHandler.asm  |  33 --
 .../PeCoffExtraActionLibDebug.inf  |   2 -
 .../PeCoffExtraActionLibDebug/X64/IntHandler.asm   |  29 --
 8 files changed, 897 deletions(-)
 delete mode 100644 
SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.asm
 delete mode 100644 
SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/AsmFuncs.asm
 delete mode 100644 
SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/Ia32/IntHandler.asm
 delete mode 100644 
SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/X64/IntHandler.asm

diff --git 
a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.asm 
b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.asm
deleted file mode 100644
index 44ed6f7..000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.asm
+++ /dev/null
@@ -1,422 +0,0 @@
-;--
-;
-; Copyright (c) 2010 - 2015, 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:
-;
-;   AsmFuncs.asm
-;
-; Abstract:
-;
-;   Debug interrupt handle functions.
-;
-;--
-
-#include "DebugException.h"
-
-.686p
-.xmm
-.model  flat,c
-
-;
-; InterruptProcess()
-;
-InterruptProcess PROTO   C
-
-publicException0Handle, TimerInterruptHandle, ExceptionStubHeaderSize
-
-AGENT_HANDLER_SIGNATURE  MACRO
-  db   41h, 47h, 54h, 48h   ; SIGNATURE_32('A','G','T','H')
-ENDM
-
-.data
-
-ExceptionStubHeaderSize   DDException1Handle - Exception0Handle
-CommonEntryAddr   DDCommonEntry
-
-.code
-
-AGENT_HANDLER_SIGNATURE
-Exception0Handle:
-cli
-pusheax
-mov eax, 0
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception1Handle:
-cli
-pusheax
-mov eax, 1
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception2Handle:
-cli
-pusheax
-mov eax, 2
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception3Handle:
-cli
-pusheax
-mov eax, 3
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception4Handle:
-cli
-pusheax
-mov eax, 4
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception5Handle:
-cli
-pusheax
-mov eax, 5
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception6Handle:
-cli
-pusheax
-mov eax, 6
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception7Handle:
-cli
-pusheax
-mov eax, 7
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception8Handle:
-cli
-pusheax
-mov eax, 8
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception9Handle:
-cli
-pusheax
-mov eax, 9
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception10Handle:
-cli
-pusheax
-mov eax, 10
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception11Handle:
-cli
-pusheax
-mov eax, 11
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception12Handle:
-cli
-pusheax
-mov eax, 12
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception13Handle:
-cli
-pusheax
-mov eax, 13
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception14Handle:
-cli
-pusheax
-mov eax, 14
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception15Handle:
-cli
-pusheax
-mov eax, 15
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Exception16Handle:
-cli
-pusheax
-mov eax, 16
-jmp dword ptr [CommonEntryAddr]
-AGENT_HANDLER_SIGNATURE
-Excep

[edk2] [Patch 0/5] Remove X86 ASM and S files

2018-05-13 Thread Liming Gao
For IA32 and X64, NASM has replaced ASM and S files.
Rmove ASM from all modules.
Remove S files from the drivers only.
After NASM is updated, S files can be removed from Library. 

Liming Gao (5):
  IntelFrameworkModulePkg: Remove X86 ASM and S files
  MdeModulePkg: Remove X86 ASM and S files
  MdePkg: Remove X86 ASM and S files
  SourceLevelDebugPkg: Remove X86 ASM and S files
  UefiCpuPkg: Remove X86 ASM and S files

 .../Csm/LegacyBiosDxe/IA32/InterruptTable.S|  67 ---
 .../Csm/LegacyBiosDxe/IA32/InterruptTable.asm  |  73 ---
 .../Csm/LegacyBiosDxe/LegacyBiosDxe.inf|   4 -
 .../Csm/LegacyBiosDxe/X64/InterruptTable.S |  72 ---
 .../Csm/LegacyBiosDxe/X64/InterruptTable.asm   |  71 ---
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf|   2 -
 MdeModulePkg/Core/DxeIplPeim/Ia32/IdtVectorAsm.S   |  80 ---
 MdeModulePkg/Core/DxeIplPeim/Ia32/IdtVectorAsm.asm |  88 ---
 .../BootScriptExecutorDxe.inf  |   4 -
 .../Acpi/BootScriptExecutorDxe/IA32/S3Asm.S|  66 ---
 .../Acpi/BootScriptExecutorDxe/IA32/S3Asm.asm  |  71 ---
 .../Acpi/BootScriptExecutorDxe/X64/S3Asm.S | 130 -
 .../Acpi/BootScriptExecutorDxe/X64/S3Asm.asm   | 135 -
 MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf   |   2 -
 .../Universal/CapsulePei/X64/PageFaultHandler.S|  81 ---
 .../Universal/CapsulePei/X64/PageFaultHandler.asm  |  87 ---
 .../Universal/DebugSupportDxe/DebugSupportDxe.inf  |   4 -
 .../Universal/DebugSupportDxe/Ia32/AsmFuncs.S  | 407 --
 .../Universal/DebugSupportDxe/Ia32/AsmFuncs.asm| 509 --
 .../Universal/DebugSupportDxe/X64/AsmFuncs.S   | 551 ---
 .../Universal/DebugSupportDxe/X64/AsmFuncs.asm | 596 -
 MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf  |   4 -
 MdeModulePkg/Universal/EbcDxe/EbcDxe.inf   |   4 -
 MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.S   |  83 ---
 MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.asm | 207 ---
 MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S| 147 -
 MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm  | 246 -
 MdePkg/Library/BaseCpuLib/BaseCpuLib.inf   |   4 -
 MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.asm |  40 --
 MdePkg/Library/BaseCpuLib/Ia32/CpuSleep.asm|  39 --
 MdePkg/Library/BaseCpuLib/X64/CpuFlushTlb.asm  |  38 --
 MdePkg/Library/BaseCpuLib/X64/CpuSleep.asm |  37 --
 .../BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf  |   2 -
 MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifo.asm  | 141 -
 MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifo.asm   | 127 -
 MdePkg/Library/BaseLib/BaseLib.inf | 246 -
 MdePkg/Library/BaseLib/Ia32/ARShiftU64.asm |  48 --
 MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.asm  |  40 --
 MdePkg/Library/BaseLib/Ia32/CpuId.asm  |  66 ---
 MdePkg/Library/BaseLib/Ia32/CpuIdEx.asm|  68 ---
 MdePkg/Library/BaseLib/Ia32/CpuPause.asm   |  40 --
 MdePkg/Library/BaseLib/Ia32/DisableCache.asm   |  45 --
 MdePkg/Library/BaseLib/Ia32/DisableInterrupts.asm  |  40 --
 MdePkg/Library/BaseLib/Ia32/DisablePaging32.asm|  57 --
 MdePkg/Library/BaseLib/Ia32/DivU64x32.asm  |  46 --
 MdePkg/Library/BaseLib/Ia32/DivU64x32Remainder.asm |  51 --
 MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm |  92 
 MdePkg/Library/BaseLib/Ia32/EnableCache.asm|  45 --
 .../BaseLib/Ia32/EnableDisableInterrupts.asm   |  41 --
 MdePkg/Library/BaseLib/Ia32/EnableInterrupts.asm   |  40 --
 MdePkg/Library/BaseLib/Ia32/EnablePaging32.asm |  57 --
 MdePkg/Library/BaseLib/Ia32/EnablePaging64.asm |  68 ---
 MdePkg/Library/BaseLib/Ia32/FlushCacheLine.asm |  55 --
 MdePkg/Library/BaseLib/Ia32/FxRestore.asm  |  42 --
 MdePkg/Library/BaseLib/Ia32/FxSave.asm |  42 --
 MdePkg/Library/BaseLib/Ia32/Invd.asm   |  40 --
 MdePkg/Library/BaseLib/Ia32/LRotU64.asm|  51 --
 MdePkg/Library/BaseLib/Ia32/LShiftU64.asm  |  48 --
 MdePkg/Library/BaseLib/Ia32/LongJump.asm   |  46 --
 MdePkg/Library/BaseLib/Ia32/ModU64x32.asm  |  45 --
 MdePkg/Library/BaseLib/Ia32/Monitor.asm|  45 --
 MdePkg/Library/BaseLib/Ia32/MultU64x32.asm |  43 --
 MdePkg/Library/BaseLib/Ia32/MultU64x64.asm |  47 --
 MdePkg/Library/BaseLib/Ia32/Mwait.asm  |  43 --
 MdePkg/Library/BaseLib/Ia32/RRotU64.asm|  51 --
 MdePkg/Library/BaseLib/Ia32/RShiftU64.asm  |  48 --
 MdePkg/Library/BaseLib/Ia32/RdRand.asm |  94 
 MdePkg/Library/BaseLib/Ia32/ReadCr0.asm|  40 --
 MdePkg/Library/BaseLib/Ia32/ReadCr2.asm|  40 --
 MdePkg/Library/BaseLib/Ia32/ReadCr3.asm|  40 --
 MdePkg/Library/BaseLib/Ia32/ReadCr4.asm|  40 --
 MdePkg/Library/BaseLib/Ia32/ReadCs.asm |  40 --
 MdePkg/Library/BaseLib/Ia32/ReadDr0.asm|  40 --
 MdePkg/Library/

[edk2] [Patch 2/5] MdeModulePkg: Remove X86 ASM and S files

2018-05-13 Thread Liming Gao
NASM has replaced ASM and S files.
Rmove ASM from all modules.
Remove S files from the drivers only.
After NASM is updated, S files can be removed from Library.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
---
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf|   2 -
 MdeModulePkg/Core/DxeIplPeim/Ia32/IdtVectorAsm.S   |  80 ---
 MdeModulePkg/Core/DxeIplPeim/Ia32/IdtVectorAsm.asm |  88 ---
 .../BootScriptExecutorDxe.inf  |   4 -
 .../Acpi/BootScriptExecutorDxe/IA32/S3Asm.S|  66 ---
 .../Acpi/BootScriptExecutorDxe/IA32/S3Asm.asm  |  71 ---
 .../Acpi/BootScriptExecutorDxe/X64/S3Asm.S | 130 -
 .../Acpi/BootScriptExecutorDxe/X64/S3Asm.asm   | 135 -
 MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf   |   2 -
 .../Universal/CapsulePei/X64/PageFaultHandler.S|  81 ---
 .../Universal/CapsulePei/X64/PageFaultHandler.asm  |  87 ---
 .../Universal/DebugSupportDxe/DebugSupportDxe.inf  |   4 -
 .../Universal/DebugSupportDxe/Ia32/AsmFuncs.S  | 407 --
 .../Universal/DebugSupportDxe/Ia32/AsmFuncs.asm| 509 --
 .../Universal/DebugSupportDxe/X64/AsmFuncs.S   | 551 ---
 .../Universal/DebugSupportDxe/X64/AsmFuncs.asm | 596 -
 MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf  |   4 -
 MdeModulePkg/Universal/EbcDxe/EbcDxe.inf   |   4 -
 MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.S   |  83 ---
 MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.asm | 207 ---
 MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S| 147 -
 MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm  | 246 -
 22 files changed, 3504 deletions(-)
 delete mode 100644 MdeModulePkg/Core/DxeIplPeim/Ia32/IdtVectorAsm.S
 delete mode 100644 MdeModulePkg/Core/DxeIplPeim/Ia32/IdtVectorAsm.asm
 delete mode 100644 
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/S3Asm.S
 delete mode 100644 
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/S3Asm.asm
 delete mode 100644 
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/S3Asm.S
 delete mode 100644 
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/S3Asm.asm
 delete mode 100644 MdeModulePkg/Universal/CapsulePei/X64/PageFaultHandler.S
 delete mode 100644 MdeModulePkg/Universal/CapsulePei/X64/PageFaultHandler.asm
 delete mode 100644 MdeModulePkg/Universal/DebugSupportDxe/Ia32/AsmFuncs.S
 delete mode 100644 MdeModulePkg/Universal/DebugSupportDxe/Ia32/AsmFuncs.asm
 delete mode 100644 MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.S
 delete mode 100644 MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.asm
 delete mode 100644 MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.S
 delete mode 100644 MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.asm
 delete mode 100644 MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S
 delete mode 100644 MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm

diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf 
b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
index ba1d9c6..e07f3e3 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
@@ -43,8 +43,6 @@
   X64/VirtualMemory.c
   Ia32/DxeLoadFunc.c
   Ia32/IdtVectorAsm.nasm
-  Ia32/IdtVectorAsm.asm
-  Ia32/IdtVectorAsm.S
 
 [Sources.X64]
   X64/VirtualMemory.h
diff --git a/MdeModulePkg/Core/DxeIplPeim/Ia32/IdtVectorAsm.S 
b/MdeModulePkg/Core/DxeIplPeim/Ia32/IdtVectorAsm.S
deleted file mode 100644
index 96a3acb..000
--- a/MdeModulePkg/Core/DxeIplPeim/Ia32/IdtVectorAsm.S
+++ /dev/null
@@ -1,80 +0,0 @@
-#/** @file
-#  
-#IDT vector entry.
-#  
-#  Copyright (c) 2007 - 2009, 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.
-#  
-#**/
-
-.text
-.code32
-
-
-.p2align 3
-ASM_GLOBAL  ASM_PFX(AsmGetVectorTemplatInfo)
-ASM_GLOBAL ASM_PFX(AsmVectorFixup)
-/*
-;
-;---
-;  Template of IDT Vector Handlers. 
-;
-;---
-*/
-VectorTemplateBase:
-pushl %eax
-.byte 0x6a#  push #VectorNum
-VectorNum:
-.byte 0
-movl  CommonInterruptEntry, %eax
-jmp   *%eax
-VectorTemplateEnd:
-
-
-ASM_PFX(AsmGetVectorTemplatInfo):
-movl  4(%esp), %ecx
-movl  $VectorTemplateBase, (%ecx)
-movl  $(VectorTemplateEnd - VectorTemplateBase), %eax
-ret
-
-ASM_PFX(AsmVectorFixup):
-movl  8(%esp), %eax
-movl  4(%esp), %ecx
-movb  %al, (VectorNum - VectorTemplateBase

[edk2] [Patch 1/5] IntelFrameworkModulePkg: Remove X86 ASM and S files

2018-05-13 Thread Liming Gao
NASM has replaced ASM and S files.
Rmove ASM from all modules.
Remove S files from the drivers only.
After NASM is updated, S files can be removed from Library.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
---
 .../Csm/LegacyBiosDxe/IA32/InterruptTable.S| 67 
 .../Csm/LegacyBiosDxe/IA32/InterruptTable.asm  | 73 --
 .../Csm/LegacyBiosDxe/LegacyBiosDxe.inf|  4 --
 .../Csm/LegacyBiosDxe/X64/InterruptTable.S | 72 -
 .../Csm/LegacyBiosDxe/X64/InterruptTable.asm   | 71 -
 5 files changed, 287 deletions(-)
 delete mode 100644 
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/IA32/InterruptTable.S
 delete mode 100644 
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/IA32/InterruptTable.asm
 delete mode 100644 
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/X64/InterruptTable.S
 delete mode 100644 
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/X64/InterruptTable.asm

diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/IA32/InterruptTable.S 
b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/IA32/InterruptTable.S
deleted file mode 100644
index a785256..000
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/IA32/InterruptTable.S
+++ /dev/null
@@ -1,67 +0,0 @@
-## @file
-#  Interrupt Redirection Template
-#
-# Copyright (c) 2006, 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.
-#
-##
-
-ASM_GLOBAL ASM_PFX(InterruptRedirectionTemplate)
-
-#
-# Procedure:InterruptRedirectionTemplate: Redirects interrupts 0x68-0x6F 
-#
-# Input:None
-#
-# Output:   None
-#
-# Prototype:VOID
-#   InterruptRedirectionTemplate (  
-#VOID
-#);
-#
-# Saves:None
-#
-# Modified: None
-#
-# Description:  Contains the code that is copied into low memory (below 640K).
-#   This code reflects interrupts 0x68-0x6f to interrupts 
0x08-0x0f.
-#   This template must be copied into low memory, and the IDT 
entries
-#   0x68-0x6F must be point to the low memory copy of this code.  
Each
-#   entry is 4 bytes long, so IDT entries 0x68-0x6F can be easily 
-#   computed.
-#
-#
-ASM_PFX(InterruptRedirectionTemplate):
-  int $0x8
-  .byte   0xcf
-  nop
-  int $0x9
-  .byte   0xcf
-  nop
-  int $0xa
-  .byte   0xcf
-  nop
-  int $0xb
-  .byte   0xcf
-  nop
-  int $0xc
-  .byte   0xcf
-  nop
-  int $0xd
-  .byte   0xcf
-  nop
-  int $0xe
-  .byte   0xcf
-  nop
-  int $0xf
-  .byte   0xcf
-  nop
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/IA32/InterruptTable.asm 
b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/IA32/InterruptTable.asm
deleted file mode 100644
index 410ce5b..000
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/IA32/InterruptTable.asm
+++ /dev/null
@@ -1,73 +0,0 @@
-;; @file
-;  Interrupt Redirection Template
-;
-; Copyright (c) 2006, 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.
-;
-;;
-
-.686P
-.MODEL FLAT, C
-.CODE
-
-;
-; Procedure:InterruptRedirectionTemplate: Redirects interrupts 0x68-0x6F 
-;
-; Input:None
-;
-; Output:   None
-;
-; Prototype:VOID
-;   InterruptRedirectionTemplate (  
-;VOID
-;);
-;
-; Saves:None
-;
-; Modified: None
-;
-; Description:  Contains the code that is copied into low memory (below 640K).
-;   This code reflects interrupts 0x68-0x6f to interrupts 
0x08-0x0f.
-;   This template must be copied into low memory, and the IDT 
entries
-;   0x68-0x6F must be point to the low memory copy of this code.  
Each
-;   entry is 4 bytes long, so IDT entries 0x68-0x6F can be easily 
-;   computed.
-;
-;

[edk2] [Patch 5/5] UefiCpuPkg: Remove X86 ASM and S files

2018-05-13 Thread Liming Gao
NASM has replaced ASM and S files.
Rmove ASM from all modules.
Remove S files from the drivers only.
After NASM is updated, S files can be removed from Library.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
---
 UefiCpuPkg/CpuDxe/CpuDxe.inf   |   4 -
 UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S|  57 ---
 UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm  |  58 ---
 UefiCpuPkg/CpuDxe/X64/CpuAsm.S |  60 ---
 UefiCpuPkg/CpuDxe/X64/CpuAsm.asm   |  54 ---
 .../Library/BaseUefiCpuLib/BaseUefiCpuLib.inf  |   2 -
 .../Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm  |  79 
 .../Library/BaseUefiCpuLib/X64/InitializeFpu.asm   |  62 ---
 .../DxeCpuExceptionHandlerLib.inf  |   2 -
 .../Ia32/ExceptionHandlerAsm.asm   | 467 -
 .../PeiCpuExceptionHandlerLib.inf  |   2 -
 .../SecPeiCpuExceptionHandlerLib.inf   |   2 -
 .../SmmCpuExceptionHandlerLib.inf  |   2 -
 .../X64/ExceptionHandlerAsm.asm| 389 -
 .../Library/SmmCpuFeaturesLib/Ia32/SmiEntry.asm| 285 -
 .../SmmCpuFeaturesLib/Ia32/SmiException.asm| 175 
 .../SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf |   4 -
 .../Library/SmmCpuFeaturesLib/X64/SmiEntry.asm | 281 -
 .../Library/SmmCpuFeaturesLib/X64/SmiException.asm | 178 
 .../Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.S|  38 --
 .../Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.asm  |  45 --
 .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf   |   4 -
 .../Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.S |  37 --
 .../Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.asm   |  41 --
 24 files changed, 2328 deletions(-)
 delete mode 100644 UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S
 delete mode 100644 UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm
 delete mode 100644 UefiCpuPkg/CpuDxe/X64/CpuAsm.S
 delete mode 100644 UefiCpuPkg/CpuDxe/X64/CpuAsm.asm
 delete mode 100644 UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm
 delete mode 100644 UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.asm
 delete mode 100644 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm
 delete mode 100644 
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm
 delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.asm
 delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.asm
 delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.asm
 delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.asm
 delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.S
 delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.asm
 delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.S
 delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.asm

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.inf b/UefiCpuPkg/CpuDxe/CpuDxe.inf
index 02f86b7..13c79d0 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.inf
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.inf
@@ -58,14 +58,10 @@
   CpuPageTable.c
 
 [Sources.IA32]
-  Ia32/CpuAsm.asm
   Ia32/CpuAsm.nasm
-  Ia32/CpuAsm.S
 
 [Sources.X64]
-  X64/CpuAsm.asm
   X64/CpuAsm.nasm
-  X64/CpuAsm.S
 
 [Protocols]
   gEfiCpuArchProtocolGuid   ## PRODUCES
diff --git a/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S b/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S
deleted file mode 100644
index e034bc2..000
--- a/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S
+++ /dev/null
@@ -1,57 +0,0 @@
-#--
-#*
-#*   Copyright (c) 2006 - 2013, 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.
-#*
-#*CpuAsm.S
-#*
-#*   Abstract:
-#*
-#--
-
-
-#.MMX
-#.XMM
-
-#--
-# VOID
-# SetCodeSelector (
-#   UINT16 Selector
-#   );
-#--
-ASM_GLOBAL ASM_PFX(SetCodeSelector)
-ASM_PFX(SetCodeSelector):
-movl4(%esp), %ecx
-subl$0x10, %esp 
-lealsetCodeSelectorLongJump, %eax 
-movl%eax, (%esp)
-movw%cx, 4(%esp)
-.byte   0xFF, 0x2C, 0x24   # jmp *(%esp)  note:(FWORD jmp) 
-setCodeSelectorLongJump:
-addl$0x10, %esp 
-ret
-
-#--
-# VOID

Re: [edk2] [Patch 5/5] UefiCpuPkg: Remove X86 ASM and S files

2018-05-13 Thread Laszlo Ersek
On 05/13/18 16:31, Liming Gao wrote:
> NASM has replaced ASM and S files.
> Rmove ASM from all modules.
> Remove S files from the drivers only.
> After NASM is updated, S files can be removed from Library.

The patch looks good to me. I suggest a few commit message updates:

(1) If I remember correctly, we have a TianoCore BZ for this (also for
the NASM update). Can you please reference those here?

(2) There's a typo in "Rmove".

(3) Technically, a number of *.asm files remain under UefiCpuPkg, namely
under "ResetVector/Vtf0". None of those are built stand-alone -- they
are all included by "Vtf0.nasmb", and "Vtf0.inf" only references
"Vtf0.nasmb". So technically speaking these *.asm files are *.nasm[b]
files. I suggest we add a note about this fact, or else file a TianoCore
BZ about renaming the Vtf0 ASM files.

With the commit message updates:

Reviewed-by: Laszlo Ersek 

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


[edk2] [Patch] BaseTools: Enhance error message when file is not exist for Gensec

2018-05-13 Thread Yonghong Zhu
When the file is not exist in workspace or packages path, current
Gensec tool doesn't report exactly error message.

FILE FV_IMAGE = -4CF1-42D8-A0C3-B3F60779dF4D  {
  SECTION GUIDED A7717414-C616-4977-9420-844712A735BF {
SECTION FV_IMAGE = TestPkg/Test.fd
  }
}

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 BaseTools/Source/Python/GenFds/FvImageSection.py | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py 
b/BaseTools/Source/Python/GenFds/FvImageSection.py
index 57ecea0..3a4d8fb 100644
--- a/BaseTools/Source/Python/GenFds/FvImageSection.py
+++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
@@ -131,10 +131,16 @@ class FvImageSection(FvImageSectionClassObject):
 self.Alignment = str (FvAlignmentValue / 
0x400) + "K"
 else:
 # FvAlignmentValue is less than 1K
 self.Alignment = str (FvAlignmentValue)
 FvFileObj.close()
+else:
+if len (mws.getPkgPath()) == 0:
+EdkLogger.error("GenFds", FILE_NOT_FOUND, "%s is 
not found in WORKSPACE: %s" % self.FvFileName, 
GenFdsGlobalVariable.WorkSpaceDir)
+else:
+EdkLogger.error("GenFds", FILE_NOT_FOUND, "%s is 
not found in packages path:\n\t%s" % (self.FvFileName, 
'\n\t'.join(mws.getPkgPath(
+
 else:
 EdkLogger.error("GenFds", GENFDS_ERROR, "FvImageSection 
Failed! %s NOT found in FDF" % self.FvName)
 
 #
 # Prepare the parameter of GenSection
-- 
2.6.1.windows.1

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


Re: [edk2] [PATCH v2 1/2] MdeModulePkg Variable: Fix a corner case issue about setting a variable

2018-05-13 Thread Zeng, Star
Thanks for the contribution.
Reviewed-by: Star Zeng  to the patch series.
And push the patches to d741d1419350dc4ae868d4a9396f9da33a3416a0 and 
989f7a2cf0e27123fda5ca538b15832e115e0f4e.


Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of cinnamon 
shia
Sent: Friday, May 11, 2018 11:21 PM
To: edk2-devel@lists.01.org
Cc: ler...@redhat.com; Zeng, Star ; Ansen Huang 

Subject: [edk2] [PATCH v2 1/2] MdeModulePkg Variable: Fix a corner case issue 
about setting a variable

Fix the issue that failed to update or add a UEFI variable if the remaining 
size is equal to the data size
of the variable.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: cinnamon shia 
Signed-off-by: Ansen Huang 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 6caf603b3d..7303681aaa 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -17,7 +17,7 @@
   integer overflow. It should also check attribute to avoid authentication 
bypass.
 
 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-(C) Copyright 2015 Hewlett Packard Enterprise Development LP
+(C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -288,7 +288,7 @@ UpdateVariableStore (
   DataPtr += mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase;
 }
 
-if ((DataPtr + DataSize) >= ((EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) 
FwVolHeader + FwVolHeader->FvLength))) {
+if ((DataPtr + DataSize) > ((EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) 
FwVolHeader + FwVolHeader->FvLength))) {
   return EFI_INVALID_PARAMETER;
 }
   } else {
@@ -301,7 +301,7 @@ UpdateVariableStore (
   DataPtr += mVariableModuleGlobal->VariableGlobal.VolatileVariableBase;
 }
 
-if ((DataPtr + DataSize) >= ((UINTN) ((UINT8 *) VolatileBase + 
VolatileBase->Size))) {
+if ((DataPtr + DataSize) > ((UINTN) ((UINT8 *) VolatileBase + 
VolatileBase->Size))) {
   return EFI_INVALID_PARAMETER;
 }
 
-- 
2.16.1.windows.4

___
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] Enabling network interface for Realtek8168 chip

2018-05-13 Thread Richardson, Brian
You can try the UEFI UNDI driver available for download from Realtek's website:

http://www.realtek.com/Downloads/downloadsView.aspx?Langid=1&PNid=13&PFid=5&Level=5&Conn=4&DownTypeID=3&GetDown=fa&SortByDesc=1
 

Thanks ... br
---
Brian Richardson, Senior Technical Marketing Engineer, Intel Software
brian.richard...@intel.com -- @intel_brian (Twitter & WeChat)
https://software.intel.com/en-us/meet-the-developers/evangelists/team/brian-richardson
 

-Original Message-
From: edk2-devel  On Behalf Of Anatol Pomozov
Sent: Sunday, May 13, 2018 10:29 AM
To: edk2-devel@lists.01.org
Subject: [edk2] Enabling network interface for Realtek8168 chip

Hello

I have a HP Chromebox (codename "zako") that is a small-form factor nice x86 
computer useful for experiments. I installed firmware from Matt Davo - the 
firmware is Coreboot + UEFI payload. UEFI compiled from this sourcecode fork 
https://github.com/MattDevo/edk2

At my cromebox I have an ethernet contoller that is identified by Linux `lspci` 
as "01:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. 
RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 0c)"

I want to use ethernet network from an UEFI application. I use
LocateHandle() to find a SimpleNetworkProtocol for me. Network works fine with 
QEMU and Intel e1000e controller. But at real hardware at Chromebox 
LocateHandle() handle returns error EFI_NOT_FOUND.

It sounds like the realtek driver is not enabled at UEFI firmware level.

Does anyone have pointers how to enable or implement Realtek8168 driver in edk2?
___
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] Enabling network interface for Realtek8168 chip

2018-05-13 Thread Anatol Pomozov
Awesome, thank you Brian!

On Sun, May 13, 2018 at 7:42 PM, Richardson, Brian
 wrote:
> You can try the UEFI UNDI driver available for download from Realtek's 
> website:
>
> http://www.realtek.com/Downloads/downloadsView.aspx?Langid=1&PNid=13&PFid=5&Level=5&Conn=4&DownTypeID=3&GetDown=fa&SortByDesc=1

I contacted Zako's device firmware maintainer to add this driver to
the firmware blob.

Meanwhile I am thinking what can I do to try this driver myself (in
case if maintainer is busy and will not make the changes quickly).

Is there a way to load this driver programmatically from my UEFI
application? So I can request and use SimpleNetworkProtocol. Googling
did not give me any clear answer on this topic.

And if it does not work, what are other ways for me to enable the network?
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v4 4/6] Platform/Hisilicon/HiKey: add gpio platform driver

2018-05-13 Thread Haojian Zhuang
Add gpio platform driver to enable GPIO in HiKey platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c| 74 ++
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf  | 36 +++
 2 files changed, 110 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf

diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
new file mode 100644
index ..be535f8f1903
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
@@ -0,0 +1,74 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro. All rights reserved.
+*
+*  This program and the accompanying materials
+*  are licensed and made available under the terms and conditions of the BSD 
License
+*  which accompanies this distribution.  The full text of the license may be 
found at
+*  http://opensource.org/licenses/bsd-license.php
+*
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+*
+**/
+
+#include 
+
+#include 
+
+GPIO_CONTROLLER gGpioDevice[] = {
+  //
+  // { base address, gpio index, gpio count }
+  //
+  { 0xf8011000, 0, 8 },// GPIO0
+  { 0xf8012000, 8, 8 },// GPIO1
+  { 0xf8013000, 16, 8 },   // GPIO2
+  { 0xf8014000, 24, 8 },   // GPIO3
+  { 0xf702, 32, 8 },   // GPIO4
+  { 0xf7021000, 40, 8 },   // GPIO5
+  { 0xf7022000, 48, 8 },   // GPIO6
+  { 0xf7023000, 56, 8 },   // GPIO7
+  { 0xf7024000, 64, 8 },   // GPIO8
+  { 0xf7025000, 72, 8 },   // GPIO9
+  { 0xf7026000, 80, 8 },   // GPIO10
+  { 0xf7027000, 88, 8 },   // GPIO11
+  { 0xf7028000, 96, 8 },   // GPIO12
+  { 0xf7029000, 104, 8 },  // GPIO13
+  { 0xf702a000, 112, 8 },  // GPIO14
+  { 0xf702b000, 120, 8 },  // GPIO15
+  { 0xf702c000, 128, 8 },  // GPIO16
+  { 0xf702d000, 136, 8 },  // GPIO17
+  { 0xf702e000, 144, 8 },  // GPIO18
+  { 0xf702f000, 152, 8 }   // GPIO19
+};
+
+PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
+  //
+  // { global gpio count, gpio controller counter, GPIO_CONTROLLER }
+  //
+  160, 20, gGpioDevice
+};
+
+EFI_STATUS
+EFIAPI
+HiKeyGpioEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  Handle;
+
+  // Install the Embedded Platform GPIO Protocol onto a new handle
+  Handle = NULL;
+  Status = gBS->InstallMultipleProtocolInterfaces(
+  &Handle,
+  &gPlatformGpioProtocolGuid, &gPlatformGpioDevice,
+  NULL
+ );
+  if (EFI_ERROR(Status)) {
+Status = EFI_OUT_OF_RESOURCES;
+  }
+
+  return Status;
+}
diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
new file mode 100644
index ..2791b9f44cad
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
@@ -0,0 +1,36 @@
+#
+#  Copyright (c) 2018, Linaro. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+
+[Defines]
+  INF_VERSION= 0x0001001a
+  BASE_NAME  = HiKeyGpio
+  FILE_GUID  = b51a851c-7bf7-463f-b261-cfb158b7f699
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= HiKeyGpioEntryPoint
+
+[Sources.common]
+  HiKeyGpioDxe.c
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gPlatformGpioProtocolGuid
+
+[Depex]
+  TRUE
-- 
2.7.4

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


[edk2] [PATCH edk2-platforms v4 2/6] Platform/HiKey960: do basic initialization

2018-05-13 Thread Haojian Zhuang
Do some basic initliazation on peripherals, such as pins and
regulators.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |   2 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |   2 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 186 
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  91 ++
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  47 +
 Silicon/Hisilicon/Hi3660/Hi3660.dec|  32 
 Silicon/Hisilicon/Hi3660/Include/Hi3660.h  | 194 +
 Silicon/Hisilicon/Hi3660/Include/Hkadc.h   |  68 
 8 files changed, 622 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 create mode 100644 Silicon/Hisilicon/Hi3660/Hi3660.dec
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hi3660.h
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hkadc.h

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 3da1b8556321..6cc1c1edf453 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -182,6 +182,8 @@ [Components.common]
   Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
+
   #
   # USB Host Support
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index 162dbaaf2646..b7d70b010598 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -123,6 +123,8 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
+
   #
   # USB Host Support
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
new file mode 100644
index ..fae68feca89d
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
@@ -0,0 +1,186 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro Ltd. All rights reserved.
+*
+*  This program and the accompanying materials
+*  are licensed and made available under the terms and conditions of the BSD 
License
+*  which accompanies this distribution.  The full text of the license may be 
found at
+*  http://opensource.org/licenses/bsd-license.php
+*
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+*
+**/
+
+#include "HiKey960Dxe.h"
+
+STATIC
+VOID
+InitSdCard (
+  IN VOID
+  )
+{
+  UINT32Data;
+
+  //
+  // LDO16
+  // 000: 1.75V, 001: 1.8V, 010: 2.4V, 011: 2.6V, 100: 2.7V,
+  // 101: 2.85V, 110: 2.95V, 111: 3.0V.
+  //
+  Data = MmioRead32 (PMIC_LDO16_VSET_REG) & LDO16_VSET_MASK;
+  Data |= 6;
+  MmioWrite32 (PMIC_LDO16_VSET_REG, Data);
+  MmioOr32 (PMIC_LDO16_ONOFF_ECO_REG, LDO16_ONOFF_ECO_LDO16_ENABLE);
+  //
+  // wait regulator stable
+  //
+  MicroSecondDelay (100);
+
+  //
+  // LDO9
+  // 000: 1.75V, 001: 1.8V, 010: 1.825V, 011: 2.8V, 100: 2.85V,
+  // 101: 2.95V, 110: 3.0V, 111: 3.3V.
+  //
+  Data = MmioRead32 (PMIC_LDO9_VSET_REG) & LDO9_VSET_MASK;
+  Data |= 5;
+  MmioWrite32 (PMIC_LDO9_VSET_REG, Data);
+  MmioOr32 (PMU_REG_BASE + (0x6a << 2), 2);
+  //
+  // wait regulator stable
+  //
+  MicroSecondDelay (100);
+
+  //
+  // GPIO203
+  //
+  MmioWrite32 (IOMG_AO_REG_BASE + (24 << 2), 0); // GPIO function
+
+  //
+  // SD pinmux
+  //
+  MmioWrite32 (IOMG_MMC0_000_REG, IOMG_FUNC1); // SD_CLK
+  MmioWrite32 (IOMG_MMC0_001_REG, IOMG_FUNC1); // SD_CMD
+  MmioWrite32 (IOMG_MMC0_002_REG, IOMG_FUNC1); // SD_DATA0
+  MmioWrite32 (IOMG_MMC0_003_REG, IOMG_FUNC1); // SD_DATA1
+  MmioWrite32 (IOMG_MMC0_004_REG, IOMG_FUNC1); // SD_DATA2
+  MmioWrite32 (IOMG_MMC0_005_REG, IOMG_FUNC1); // SD_DATA3
+  MmioWrite32 (IOCG_MMC0_000_REG, IOCG_DRIVE (15)); // SD_CLK float with 32mA
+  MmioWrite32 (IOCG_MMC0_001_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_CMD
+  MmioWrite32 (IOCG_MMC0_002_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_DATA0
+  MmioWrite32 (IOCG_MMC0_003_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_DATA1
+  MmioWrite32 (IOCG_MMC0_004_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_DATA2
+  MmioWrite32 (IOCG_MMC0_005_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_DATA3
+
+  //
+  // SC_SEL_SD:
+  //   0xx: 3.2MHz, 100: PPLL0, 101: PPLL1, 11x: PPLL2.
+  // SC_DIV_SD:
+  //   divider = value + 1
+  //
+  do {
+MmioOr32 (
+  CRG_CLKDIV4, CLKDIV4_SC_SEL_SD (4) | CLKDIV4_SC_SEL_SD_MASK |
+  CLKDIV4_SC_DIV_SD

[edk2] [PATCH edk2-platforms v4 3/6] Platform/HiKey960: enable virtual keyboard

2018-05-13 Thread Haojian Zhuang
Enable virtual keyboard on HiKey960 platform. It checks two
conditions, such as pattern in memory and GPIO pin setting.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |  5 ++
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |  5 ++
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 97 ++
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  3 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  1 +
 5 files changed, 111 insertions(+)

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 6cc1c1edf453..79e68754976d 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -182,6 +182,11 @@ [Components.common]
   Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index b7d70b010598..d65f77878575 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -123,6 +123,11 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
index fae68feca89d..60d0e380e0b1 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
@@ -14,6 +14,8 @@
 
 #include "HiKey960Dxe.h"
 
+STATIC EMBEDDED_GPIO   *mGpio;
+
 STATIC
 VOID
 InitSdCard (
@@ -154,6 +156,94 @@ OnEndOfDxe (
 
 EFI_STATUS
 EFIAPI
+VirtualKeyboardRegister (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  Status = gBS->LocateProtocol (
+  &gEmbeddedGpioProtocolGuid,
+  NULL,
+  (VOID **) &mGpio
+  );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardReset (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  if (mGpio == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  //
+  // Configure GPIO68 as GPIO function
+  //
+  MmioWrite32 (0xe896c108, 0);
+  Status = mGpio->Set (mGpio, DETECT_SW_FASTBOOT, GPIO_MODE_INPUT);
+  return Status;
+}
+
+BOOLEAN
+EFIAPI
+VirtualKeyboardQuery (
+  IN VIRTUAL_KBD_KEY *VirtualKey
+  )
+{
+  EFI_STATUS   Status;
+  UINTNValue = 0;
+
+  if ((VirtualKey == NULL) || (mGpio == NULL)) {
+return FALSE;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+goto Done;
+  } else {
+Status = mGpio->Get (mGpio, DETECT_SW_FASTBOOT, &Value);
+if (EFI_ERROR (Status) || (Value != 0)) {
+  return FALSE;
+}
+  }
+Done:
+  VirtualKey->Signature = VIRTUAL_KEYBOARD_KEY_SIGNATURE;
+  VirtualKey->Key.ScanCode = SCAN_NULL;
+  VirtualKey->Key.UnicodeChar = L'f';
+  return TRUE;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardClear (
+  IN VIRTUAL_KBD_KEY*VirtualKey
+  )
+{
+  if (VirtualKey == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+MmioWrite32 (ADB_REBOOT_ADDRESS, ADB_REBOOT_NONE);
+WriteBackInvalidateDataCacheRange ((VOID *)ADB_REBOOT_ADDRESS, 4);
+  }
+  return EFI_SUCCESS;
+}
+
+PLATFORM_VIRTUAL_KBD_PROTOCOL mVirtualKeyboard = {
+  VirtualKeyboardRegister,
+  VirtualKeyboardReset,
+  VirtualKeyboardQuery,
+  VirtualKeyboardClear
+};
+
+EFI_STATUS
+EFIAPI
 HiKey960EntryPoint (
   IN EFI_HANDLE ImageHandle,
   IN EFI_SYSTEM_TABLE   *SystemTable
@@ -182,5 +272,12 @@ HiKey960EntryPoint (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+
+  Status = gBS->InstallProtocolInterface (
+  &ImageHandle,
+  &gPlatformVirtualKeyboardProtocolGuid,
+  EFI_NATIVE_INTERFACE,
+  &mVirtualKeyboard
+  );
   return Status;
 }
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
index 2e89d10e2723..2d5349888ed5 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
@@ -33,6 +33,9 @@
 #include 
 #include 
 
+#include 
+#include 
+
 #define ADC_ADCIN0   0
 #define ADC_ADCIN1   1
 #define ADC_ADCIN2 

[edk2] [PATCH v4 0/6] enable virtual keyboard

2018-05-13 Thread Haojian Zhuang
Changelog:
v4:
  * Fix hard-coding value.
  * Remove unused functions.
v3:
  * Remove ADC and boardid, since it's not really used yet.
  * Add more comments.
v2:
  * Split HiKeyDxe & HiKey960Dxe into smaller patches.
  * Replace hardcoding register with macro.
v1:
  * Enable GPIO driver.
  * Enable virtual keyboard driver.

Haojian Zhuang (6):
  Platform/Hisilicon/HiKey960: add gpio platform driver
  Platform/HiKey960: do basic initialization
  Platform/HiKey960: enable virtual keyboard
  Platform/Hisilicon/HiKey: add gpio platform driver
  Platform/HiKey: do basic initialization on hikey
  Platform/HiKey: enable virtual keyboard

 Platform/Hisilicon/HiKey/HiKey.dsc |   8 +
 Platform/Hisilicon/HiKey/HiKey.fdf |   8 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 217 
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  45 
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c|  74 ++
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf  |  36 +++
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |   8 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |   8 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 283 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  94 +++
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  48 
 .../HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c |  83 ++
 .../HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf   |  35 +++
 Silicon/Hisilicon/Hi3660/Hi3660.dec|  32 +++
 Silicon/Hisilicon/Hi3660/Include/Hi3660.h  | 194 ++
 Silicon/Hisilicon/Hi3660/Include/Hkadc.h   |  68 +
 Silicon/Hisilicon/Hi6220/Include/Hi6220.h  |   6 +
 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h  |  50 
 18 files changed, 1297 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
 create mode 100644 Silicon/Hisilicon/Hi3660/Hi3660.dec
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hi3660.h
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hkadc.h
 create mode 100644 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
-- 
2.7.4

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


[edk2] [PATCH edk2-platforms v4 1/6] Platform/Hisilicon/HiKey960: add gpio platform driver

2018-05-13 Thread Haojian Zhuang
Add gpio platform driver to enable GPIO in HiKey960 platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |  1 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |  1 +
 .../HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c | 83 ++
 .../HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf   | 35 +
 4 files changed, 120 insertions(+)
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 36f43956ab40..3da1b8556321 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -179,6 +179,7 @@ [Components.common]
   #
   # GPIO
   #
+  Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index 655032a36c53..162dbaaf2646 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -120,6 +120,7 @@ [FV.FvMain]
   #
   # GPIO
   #
+  INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
new file mode 100644
index ..b196455072cc
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
@@ -0,0 +1,83 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro. All rights reserved.
+*
+*  This program and the accompanying materials
+*  are licensed and made available under the terms and conditions of the BSD 
License
+*  which accompanies this distribution.  The full text of the license may be 
found at
+*  http://opensource.org/licenses/bsd-license.php
+*
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+*
+**/
+
+#include 
+
+#include 
+
+GPIO_CONTROLLER gGpioDevice[] = {
+  //
+  // { base address, gpio index, gpio count }
+  //
+  { 0xe8a0b000, 0, 8 },// GPIO0
+  { 0xe8a0c000, 8, 8 },// GPIO1
+  { 0xe8a0d000, 16, 8 },   // GPIO2
+  { 0xe8a0e000, 24, 8 },   // GPIO3
+  { 0xe8a0f000, 32, 8 },   // GPIO4
+  { 0xe8a1, 40, 8 },   // GPIO5
+  { 0xe8a11000, 48, 8 },   // GPIO6
+  { 0xe8a12000, 56, 8 },   // GPIO7
+  { 0xe8a13000, 64, 8 },   // GPIO8
+  { 0xe8a14000, 72, 8 },   // GPIO9
+  { 0xe8a15000, 80, 8 },   // GPIO10
+  { 0xe8a16000, 88, 8 },   // GPIO11
+  { 0xe8a17000, 96, 8 },   // GPIO12
+  { 0xe8a18000, 104, 8 },  // GPIO13
+  { 0xe8a19000, 112, 8 },  // GPIO14
+  { 0xe8a1a000, 120, 8 },  // GPIO15
+  { 0xe8a1b000, 128, 8 },  // GPIO16
+  { 0xe8a1c000, 136, 8 },  // GPIO17
+  { 0xff3b4000, 144, 8 },  // GPIO18
+  { 0xff3b5000, 152, 8 },  // GPIO19
+  { 0xe8a1f000, 160, 8 },  // GPIO20
+  { 0xe8a2, 168, 8 },  // GPIO21
+  { 0xfff0b000, 176, 8 },  // GPIO22
+  { 0xfff0c000, 184, 8 },  // GPIO23
+  { 0xfff0d000, 192, 8 },  // GPIO24
+  { 0xfff0e000, 200, 8 },  // GPIO25
+  { 0xfff0f000, 208, 8 },  // GPIO26
+  { 0xfff1, 216, 8 },  // GPIO27
+  { 0xfff1d000, 224, 8 },  // GPIO28
+};
+
+PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
+  //
+  // { global gpio count, gpio controller count, GPIO_CONTROLLER }
+  //
+  232, 29, gGpioDevice
+};
+
+EFI_STATUS
+EFIAPI
+HiKey960GpioEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  Handle;
+
+  // Install the Embedded Platform GPIO Protocol onto a new handle
+  Handle = NULL;
+  Status = gBS->InstallMultipleProtocolInterfaces(
+  &Handle,
+  &gPlatformGpioProtocolGuid, &gPlatformGpioDevice,
+  NULL
+ );
+  if (EFI_ERROR(Status)) {
+Status = EFI_OUT_OF_RESOURCES;
+  }
+
+  return Status;
+}
diff --git a/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf 
b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
new file mode 100644
index ..5ea3747321d8
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
@@ -0,0 +1,35 @@
+#
+#  Copyright (c) 2018, Linaro. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY

[edk2] [PATCH edk2-platforms v4 6/6] Platform/HiKey: enable virtual keyboard

2018-05-13 Thread Haojian Zhuang
Enable virtual keyboard on HiKey platform. It detects the pattern
in memory and GPIO pin setting, and simulates them into virtual
key.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dsc |  5 ++
 Platform/Hisilicon/HiKey/HiKey.fdf |  5 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 98 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  5 ++
 4 files changed, 113 insertions(+)

diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 5cc4ff27f01b..83dd68a820b1 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -192,6 +192,11 @@ [Components.common]
   Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
b/Platform/Hisilicon/HiKey/HiKey.fdf
index 39020d27dbcd..2bca7232b6e5 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -123,6 +123,11 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
index 19987e0b29c3..8f4f9157835c 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
@@ -12,10 +12,15 @@
 *
 **/
 
+#include 
 #include 
 #include 
+#include 
 #include 
 
+#include 
+#include 
+
 #include 
 #include 
 
@@ -31,6 +36,8 @@
 #define ADB_REBOOT_BOOTLOADER0x77665500
 #define ADB_REBOOT_NONE  0x77665501
 
+STATIC EMBEDDED_GPIO*mGpio;
+
 STATIC
 VOID
 UartInit (
@@ -104,6 +111,90 @@ HiKeyInitPeripherals (
 
 EFI_STATUS
 EFIAPI
+VirtualKeyboardRegister (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  Status = gBS->LocateProtocol (
+  &gEmbeddedGpioProtocolGuid,
+  NULL,
+  (VOID **) &mGpio
+  );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardReset (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  if (mGpio == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  Status = mGpio->Set (mGpio, DETECT_J15_FASTBOOT, GPIO_MODE_INPUT);
+  return Status;
+}
+
+BOOLEAN
+EFIAPI
+VirtualKeyboardQuery (
+  IN VIRTUAL_KBD_KEY *VirtualKey
+  )
+{
+  EFI_STATUS   Status;
+  UINTNValue = 0;
+
+  if ((VirtualKey == NULL) || (mGpio == NULL)) {
+return FALSE;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+goto Done;
+  } else {
+Status = mGpio->Get (mGpio, DETECT_J15_FASTBOOT, &Value);
+if (EFI_ERROR (Status) || (Value != 0)) {
+  return FALSE;
+}
+  }
+Done:
+  VirtualKey->Signature = VIRTUAL_KEYBOARD_KEY_SIGNATURE;
+  VirtualKey->Key.ScanCode = SCAN_NULL;
+  VirtualKey->Key.UnicodeChar = L'f';
+  return TRUE;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardClear (
+  IN VIRTUAL_KBD_KEY*VirtualKey
+  )
+{
+  if (VirtualKey == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+MmioWrite32 (ADB_REBOOT_ADDRESS, ADB_REBOOT_NONE);
+WriteBackInvalidateDataCacheRange ((VOID *)ADB_REBOOT_ADDRESS, 4);
+  }
+  return EFI_SUCCESS;
+}
+
+PLATFORM_VIRTUAL_KBD_PROTOCOL mVirtualKeyboard = {
+  VirtualKeyboardRegister,
+  VirtualKeyboardReset,
+  VirtualKeyboardQuery,
+  VirtualKeyboardClear
+};
+
+EFI_STATUS
+EFIAPI
 HiKeyEntryPoint (
   IN EFI_HANDLE ImageHandle,
   IN EFI_SYSTEM_TABLE   *SystemTable
@@ -115,5 +206,12 @@ HiKeyEntryPoint (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+
+  Status = gBS->InstallProtocolInterface (
+  &ImageHandle,
+  &gPlatformVirtualKeyboardProtocolGuid,
+  EFI_NATIVE_INTERFACE,
+  &mVirtualKeyboard
+  );
   return Status;
 }
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
index 34734391b45a..41aa7f8081ed 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
@@ -28,11 +28,16 @@ [Packages]
   MdePkg/MdePkg.dec
 
 [LibraryClasses]
+  CacheMaintenanceLib
   DebugLib
   IoLib
   UefiLib
   UefiDriverEntryPoint
 
+[Protocols]
+  gEmbeddedGpioProtocolGuid
+  gPlatformVirtualKeyboardProtocolGuid
+
 [Guids]
   gEfiEndOfD

[edk2] [PATCH edk2-platforms v4 5/6] Platform/HiKey: do basic initialization on hikey

2018-05-13 Thread Haojian Zhuang
Do some basic initialization on HiKey platform, such as pin
setting, regulators and making peripherals out of reset mode.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dsc|   3 +
 Platform/Hisilicon/HiKey/HiKey.fdf|   3 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c  | 119 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf|  40 
 Silicon/Hisilicon/Hi6220/Include/Hi6220.h |   6 ++
 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h |  50 +
 6 files changed, 221 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 create mode 100644 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h

diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 5c1604d7f689..5cc4ff27f01b 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -189,8 +189,11 @@ [Components.common]
   #
   # GPIO
   #
+  Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+
   #
   # MMC/SD
   #
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
b/Platform/Hisilicon/HiKey/HiKey.fdf
index 2a5c5a4d6e79..39020d27dbcd 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -120,8 +120,11 @@ [FV.FvMain]
   #
   # GPIO
   #
+  INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+
   #
   # Multimedia Card Interface
   #
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
new file mode 100644
index ..19987e0b29c3
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
@@ -0,0 +1,119 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro Ltd. All rights reserved.
+*
+*  This program and the accompanying materials
+*  are licensed and made available under the terms and conditions of the BSD 
License
+*  which accompanies this distribution.  The full text of the license may be 
found at
+*  http://opensource.org/licenses/bsd-license.php
+*
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+*
+**/
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define SERIAL_NUMBER_SIZE   17
+#define SERIAL_NUMBER_BLOCK_SIZE EFI_PAGE_SIZE
+#define SERIAL_NUMBER_LBA1024
+#define RANDOM_MAX   0x7FFF
+#define RANDOM_MAGIC 0x9A4DBEAF
+
+#define DETECT_J15_FASTBOOT  24   // GPIO3_0
+
+#define ADB_REBOOT_ADDRESS   0x05F01000
+#define ADB_REBOOT_BOOTLOADER0x77665500
+#define ADB_REBOOT_NONE  0x77665501
+
+STATIC
+VOID
+UartInit (
+  IN VOID
+  )
+{
+  UINT32 Val;
+
+  /* make UART1 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART1);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART1);
+  /* make UART2 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART2);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART2);
+  /* make UART3 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART3);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART3);
+  /* make UART4 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART4);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART4);
+
+  /* make DW_MMC2 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS0, PERIPH_RST0_MMC2);
+
+  /* enable clock for BT/WIFI */
+  Val = MmioRead32 (PMUSSI_ONOFF8_REG) | PMUSSI_ONOFF8_EN_32KB;
+  MmioWrite32 (PMUSSI_ONOFF8_REG, Val);
+}
+
+STATIC
+VOID
+MtcmosInit (
+  IN VOID
+  )
+{
+  UINT32 Data;
+
+  /* enable MTCMOS for GPU */
+  MmioWrite32 (AO_CTRL_BASE + SC_PW_MTCMOS_EN0, PW_EN0_G3D);
+  do {
+Data = MmioRead32 (AO_CTRL_BASE + SC_PW_MTCMOS_ACK_STAT0);
+  } while ((Data & PW_EN0_G3D) == 0);
+}
+
+EFI_STATUS
+HiKeyInitPeripherals (
+  IN VOID
+  )
+{
+  UINT32 Data, Bits;
+
+  /* make I2C0/I2C1/I2C2/SPI0 out of reset */
+  Bits = PERIPH_RST3_I2C0 | PERIPH_RST3_I2C1 | PERIPH_RST3_I2C2 | \
+ PERIPH_RST3_SSP;
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, Bits);
+
+  do {
+Data = MmioRead32 (PERI_CTRL_BASE + SC_PERIPH_RSTSTAT3);
+  } while (Data & Bits);
+
+  UartInit ();
+  /* MTCMOS -- Multi-threshold CMOS */
+  MtcmosInit ();
+
+  /* Set DETECT_J15_FASTBOOT (GPIO24) pin as GPIO function */
+  MmioWrite32 (IOCG_084_REG, 0);/*

Re: [edk2] Enabling network interface for Realtek8168 chip

2018-05-13 Thread Richardson, Brian
The driver (.efi file) needs to be included in the EDK II project FDF file to 
be properly integrated into the binary firmware image. There is a good example 
of this in the MinnowBoard Max/Turbot project.

https://github.com/tianocore/edk2-platforms/blob/devel-MinnowBoardMax-UDK2017/Vlv2TbltDevicePkg/PlatformPkg.fdf

Search for "Network Modules" to find the entry where the Realtek & Intel UNDI 
drivers are included in the build.

Thanks ... br
---
Brian Richardson, Senior Technical Marketing Engineer, Intel Software
brian.richard...@intel.com -- @intel_brian (Twitter & WeChat)
https://software.intel.com/en-us/meet-the-developers/evangelists/team/brian-richardson
 

-Original Message-
From: edk2-devel  On Behalf Of Anatol Pomozov
Sent: Monday, May 14, 2018 12:03 AM
To: Richardson, Brian 
Cc: edk2-devel@lists.01.org
Subject: Re: [edk2] Enabling network interface for Realtek8168 chip

Awesome, thank you Brian!

On Sun, May 13, 2018 at 7:42 PM, Richardson, Brian  
wrote:
> You can try the UEFI UNDI driver available for download from Realtek's 
> website:
>
> http://www.realtek.com/Downloads/downloadsView.aspx?Langid=1&PNid=13&P
> Fid=5&Level=5&Conn=4&DownTypeID=3&GetDown=fa&SortByDesc=1

I contacted Zako's device firmware maintainer to add this driver to the 
firmware blob.

Meanwhile I am thinking what can I do to try this driver myself (in case if 
maintainer is busy and will not make the changes quickly).

Is there a way to load this driver programmatically from my UEFI application? 
So I can request and use SimpleNetworkProtocol. Googling did not give me any 
clear answer on this topic.

And if it does not work, what are other ways for me to enable the network?
___
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 2/3] ShellPkg/Dp: Initialize summary date when run DP

2018-05-13 Thread Dandan Bi
Issue:
When run "dp -s" or ("dp -v") command in shell several times,
the summary reuslts are different each time.

The root cause is that the previous global data "SummaryData"
is not cleaned when the dp command is callled next time.
This patch initializes the global data "SummaryData"
when the dp dymanic command is called.

Cc: Liming Gao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c 
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index fe85937f557..d8451dbf59f 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -672,10 +672,28 @@ InitCumulativeData (
 CumData[Index].MaxDur = 0;
 CumData[Index].Duration = 0;
   }
 }
 
+/**
+  Initialize the Summary data.
+
+**/
+VOID
+InitSummaryData (
+  VOID
+  )
+{
+  SummaryData.NumTrace  = 0;
+  SummaryData.NumProfile= 0 ;
+  SummaryData.NumIncomplete = 0;
+  SummaryData.NumSummary= 0;
+  SummaryData.NumHandles= 0;
+  SummaryData.NumPEIMs  = 0;
+  SummaryData.NumGlobal = 0;
+}
+
 /**
   Dump performance data.
   
   @param[in]  ImageHandle The image handle.
   @param[in]  SystemTable The system table.
@@ -817,10 +835,15 @@ RunDp (
   //
   // Initialize the pre-defined cumulative data.
   //
   InitCumulativeData ();
 
+  //
+  // Initialize the Summary data.
+  //
+  InitSummaryData ();
+
   //
   // Init the custom cumulative data.
   //
   CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");
   if (CustomCumulativeToken != NULL) {
-- 
2.14.3.windows.1

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


[edk2] [patch 3/3] ShellPkg/Dp: Make the help info align with code

2018-05-13 Thread Dandan Bi
Remove -T, -P, -h flags in the help info of DP to
align with current code implementation.

Cc: Liming Gao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni 
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
index c7eb0fbd71e..ede59069b79 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
@@ -96,21 +96,19 @@
 #string STR_GET_HELP_DP #language en-US ""
 ".TH dp 0 "Display performance metrics"\r\n"
 ".SH NAME\r\n"
 "Displays performance metrics that are stored in memory.\r\n"
 ".SH SYNOPSIS\r\n"
-"DP [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c 
[token]][-i] [-h | -?]\r\n"
+"DP [-b] [-v] [-x] [-s | -A | -R] [-t value] [-n count] [-c [token]][-i] 
[-?]\r\n"
 ".SH OPTIONS\r\n"
 " \r\n"
 "  -b   - Displays on multiple pages\r\n"
 "  -v   - Displays additional information\r\n"
 "  -x   - Prevents display of individual measurements for cumulative 
items\r\n"
 "  -s   - Displays summary information only\r\n"
 "  -A   - Displays all measurements in a list\r\n"
 "  -R   - Displays all measurements in raw format\r\n"
-"  -T   - Displays trace measurements only\r\n"
-"  -P   - Displays profile measurements only\r\n"
 "  -t VALUE - Sets display threshold to VALUE microseconds\r\n"
 "  -n COUNT - Limits display to COUNT lines in All and Raw modes\r\n"
 "  -i   - Displays identifier\r\n"
 "  -c TOKEN - Display pre-defined and custom cumulative data\r\n" 
 " Pre-defined cumulative token are:\r\n"
-- 
2.14.3.windows.1

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


[edk2] [patch 1/3] ShellPkg/Dp: make sure memory is freed before exit

2018-05-13 Thread Dandan Bi
Run dp command now:
Firstly it will get performance records from FPDT and then
parse the DP command. And if encounter invalid parameters,
it will exit directly. Thus the performance records got before
are invalid. And what's worse is that the memory allocated in
getting performance records phase is not freed.

This patch update the code to parse the command firstly and
then get the performance records. And make sure that all the
clean work has been done before exiting.

Cc: Liming Gao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 70 ++-
 1 file changed, 37 insertions(+), 33 deletions(-)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c 
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index aa9c2cdf7a8..fe85937f557 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -390,11 +390,11 @@ BuildCachedGuidHandleTable (
   }
   if (HandleBuffer != NULL) {
 FreePool (HandleBuffer);
 HandleBuffer = NULL;
   }
-  return Status;
+  return EFI_SUCCESS;
 }
 
 /**
   Get Measurement form Fpdt records.
 
@@ -729,39 +729,10 @@ RunDp (
   // initialize the shell lib (we must be in non-auto-init...)
   //
   Status = ShellInitialize();
   ASSERT_EFI_ERROR(Status);
 
-  //
-  // DP dump performance data by parsing FPDT table in ACPI table.
-  // Folloing 3 steps are to get the measurement form the FPDT table.
-  //
-
-  //
-  //1. Get FPDT from ACPI table.
-  //
-  Status = GetBootPerformanceTable ();
-  if (EFI_ERROR(Status)) {
-return Status;
-  }
-
-  //
-  //2. Cache the ModuleGuid and hanlde mapping table.
-  //
-  Status = BuildCachedGuidHandleTable();
-  if (EFI_ERROR (Status)) {
-return Status;
-  }
-
-  //
-  //3. Build the measurement array form the FPDT records.
-  //
-  Status = BuildMeasurementList ();
-  if (EFI_ERROR(Status)) {
-return Status;
-  }
-
   //
   // Process Command Line arguments
   //
   Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);
   if (EFI_ERROR(Status)) {
@@ -809,10 +780,42 @@ RunDp (
 #if PROFILING_IMPLEMENTED
 ProfileMode = TRUE;
 #endif  // PROFILING_IMPLEMENTED
   }
 
+  //
+  // DP dump performance data by parsing FPDT table in ACPI table.
+  // Folloing 3 steps are to get the measurement form the FPDT table.
+  //
+
+  //
+  //1. Get FPDT from ACPI table.
+  //
+  Status = GetBootPerformanceTable ();
+  if (EFI_ERROR (Status)) {
+ShellStatus = Status;
+goto Done;
+  }
+
+  //
+  //2. Cache the ModuleGuid and hanlde mapping table.
+  //
+  Status = BuildCachedGuidHandleTable();
+  if (EFI_ERROR (Status)) {
+ShellStatus = Status;
+goto Done;
+  }
+
+  //
+  //3. Build the measurement array form the FPDT records.
+  //
+  Status = BuildMeasurementList ();
+  if (EFI_ERROR (Status)) {
+ShellStatus = SHELL_OUT_OF_RESOURCES;
+goto Done;
+  }
+
   //
   // Initialize the pre-defined cumulative data.
   //
   InitCumulativeData ();
 
@@ -821,21 +824,22 @@ RunDp (
   //
   CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");
   if (CustomCumulativeToken != NULL) {
 CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));
 if (CustomCumulativeData == NULL) {
-  return SHELL_OUT_OF_RESOURCES;
+  ShellStatus = SHELL_OUT_OF_RESOURCES;
+  goto Done;
 }
 CustomCumulativeData->MinDur = PERF_MAXDUR;
 CustomCumulativeData->MaxDur = 0;
 CustomCumulativeData->Count  = 0;
 CustomCumulativeData->Duration = 0;
 NameSize = StrLen (CustomCumulativeToken) + 1;
 CustomCumulativeData->Name   = AllocateZeroPool (NameSize);
 if (CustomCumulativeData->Name == NULL) {
-  FreePool (CustomCumulativeData);
-  return SHELL_OUT_OF_RESOURCES;
+  ShellStatus = SHELL_OUT_OF_RESOURCES;
+  goto Done;
 }
 UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, 
NameSize);
   }
 
   //
-- 
2.14.3.windows.1

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