* [PATCH 01/15] ArmPlatformPkg/ArmPlatformLibNull: remove bogus PCD dependencies
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
@ 2017-11-17 16:08 ` Ard Biesheuvel
2017-11-17 16:20 ` Leif Lindholm
2017-11-17 16:09 ` [PATCH 02/15] ArmVirtPkg/PrePi: run all library constructors by hand Ard Biesheuvel
` (13 subsequent siblings)
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:08 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
Remove dependencies on gArmTokenSpaceGuid.PcdSystemMemoryBase and
gArmTokenSpaceGuid.PcdSystemMemorySize, the presence of which in
a [FixedPcd] section makes this module unusable for ArmVirtQemu.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf | 3 ---
1 file changed, 3 deletions(-)
diff --git a/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf b/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf
index 97b2a4b6e495..e59aef611a3c 100644
--- a/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf
+++ b/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf
@@ -41,9 +41,6 @@ [Sources.AArch64]
AArch64/ArmPlatformHelper.S
[FixedPcd]
- gArmTokenSpaceGuid.PcdSystemMemoryBase
- gArmTokenSpaceGuid.PcdSystemMemorySize
-
gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
gArmTokenSpaceGuid.PcdArmPrimaryCore
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 01/15] ArmPlatformPkg/ArmPlatformLibNull: remove bogus PCD dependencies
2017-11-17 16:08 ` [PATCH 01/15] ArmPlatformPkg/ArmPlatformLibNull: remove bogus PCD dependencies Ard Biesheuvel
@ 2017-11-17 16:20 ` Leif Lindholm
2017-11-17 16:23 ` Ard Biesheuvel
0 siblings, 1 reply; 43+ messages in thread
From: Leif Lindholm @ 2017-11-17 16:20 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel, lersek
On Fri, Nov 17, 2017 at 04:08:59PM +0000, Ard Biesheuvel wrote:
> Remove dependencies on gArmTokenSpaceGuid.PcdSystemMemoryBase and
> gArmTokenSpaceGuid.PcdSystemMemorySize, the presence of which in
> a [FixedPcd] section makes this module unusable for ArmVirtQemu.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Question: shouldn't specifically ArmVirtQemu work fine with these,
since it defines them as PcdsFixedAtBuild?
Whereas both ArmVirtQemuKernel and ArmVirtXen define them as
patchable.
/
Leif
> ---
> ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf b/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf
> index 97b2a4b6e495..e59aef611a3c 100644
> --- a/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf
> +++ b/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf
> @@ -41,9 +41,6 @@ [Sources.AArch64]
> AArch64/ArmPlatformHelper.S
>
> [FixedPcd]
> - gArmTokenSpaceGuid.PcdSystemMemoryBase
> - gArmTokenSpaceGuid.PcdSystemMemorySize
> -
> gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
> gArmTokenSpaceGuid.PcdArmPrimaryCore
>
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 01/15] ArmPlatformPkg/ArmPlatformLibNull: remove bogus PCD dependencies
2017-11-17 16:20 ` Leif Lindholm
@ 2017-11-17 16:23 ` Ard Biesheuvel
2017-11-17 16:28 ` Leif Lindholm
0 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:23 UTC (permalink / raw)
To: Leif Lindholm; +Cc: edk2-devel@lists.01.org, Laszlo Ersek
On 17 November 2017 at 16:20, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Fri, Nov 17, 2017 at 04:08:59PM +0000, Ard Biesheuvel wrote:
>> Remove dependencies on gArmTokenSpaceGuid.PcdSystemMemoryBase and
>> gArmTokenSpaceGuid.PcdSystemMemorySize, the presence of which in
>> a [FixedPcd] section makes this module unusable for ArmVirtQemu.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
> Question: shouldn't specifically ArmVirtQemu work fine with these,
> since it defines them as PcdsFixedAtBuild?
> Whereas both ArmVirtQemuKernel and ArmVirtXen define them as
> patchable.
>
PcdSystemMemorySize is dynamic in ArmVirtQemu, and is the only
platform that will include this library after this series. The others
have their own PrePi implementation, allowing me to drop any
dependencies on ArmPlatformLib altogether.
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 01/15] ArmPlatformPkg/ArmPlatformLibNull: remove bogus PCD dependencies
2017-11-17 16:23 ` Ard Biesheuvel
@ 2017-11-17 16:28 ` Leif Lindholm
2017-11-17 19:10 ` Ard Biesheuvel
0 siblings, 1 reply; 43+ messages in thread
From: Leif Lindholm @ 2017-11-17 16:28 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel@lists.01.org, Laszlo Ersek
On Fri, Nov 17, 2017 at 04:23:04PM +0000, Ard Biesheuvel wrote:
> On 17 November 2017 at 16:20, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> > On Fri, Nov 17, 2017 at 04:08:59PM +0000, Ard Biesheuvel wrote:
> >> Remove dependencies on gArmTokenSpaceGuid.PcdSystemMemoryBase and
> >> gArmTokenSpaceGuid.PcdSystemMemorySize, the presence of which in
> >> a [FixedPcd] section makes this module unusable for ArmVirtQemu.
> >>
> >> Contributed-under: TianoCore Contribution Agreement 1.1
> >> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> >
> > Question: shouldn't specifically ArmVirtQemu work fine with these,
> > since it defines them as PcdsFixedAtBuild?
> > Whereas both ArmVirtQemuKernel and ArmVirtXen define them as
> > patchable.
>
> PcdSystemMemorySize is dynamic in ArmVirtQemu, and is the only
> platform that will include this library after this series. The others
> have their own PrePi implementation, allowing me to drop any
> dependencies on ArmPlatformLib altogether.
Right.
Of course I only looked at *Base for ArmVirtQemu.
Never mind.
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
/
Leif
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 01/15] ArmPlatformPkg/ArmPlatformLibNull: remove bogus PCD dependencies
2017-11-17 16:28 ` Leif Lindholm
@ 2017-11-17 19:10 ` Ard Biesheuvel
0 siblings, 0 replies; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 19:10 UTC (permalink / raw)
To: Leif Lindholm; +Cc: edk2-devel@lists.01.org, Laszlo Ersek
On 17 November 2017 at 16:28, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Fri, Nov 17, 2017 at 04:23:04PM +0000, Ard Biesheuvel wrote:
>> On 17 November 2017 at 16:20, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>> > On Fri, Nov 17, 2017 at 04:08:59PM +0000, Ard Biesheuvel wrote:
>> >> Remove dependencies on gArmTokenSpaceGuid.PcdSystemMemoryBase and
>> >> gArmTokenSpaceGuid.PcdSystemMemorySize, the presence of which in
>> >> a [FixedPcd] section makes this module unusable for ArmVirtQemu.
>> >>
>> >> Contributed-under: TianoCore Contribution Agreement 1.1
>> >> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> >
>> > Question: shouldn't specifically ArmVirtQemu work fine with these,
>> > since it defines them as PcdsFixedAtBuild?
>> > Whereas both ArmVirtQemuKernel and ArmVirtXen define them as
>> > patchable.
>>
>> PcdSystemMemorySize is dynamic in ArmVirtQemu, and is the only
>> platform that will include this library after this series. The others
>> have their own PrePi implementation, allowing me to drop any
>> dependencies on ArmPlatformLib altogether.
>
> Right.
>
> Of course I only looked at *Base for ArmVirtQemu.
> Never mind.
>
> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
>
Pushed as b2662641d56a
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 02/15] ArmVirtPkg/PrePi: run all library constructors by hand
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
2017-11-17 16:08 ` [PATCH 01/15] ArmPlatformPkg/ArmPlatformLibNull: remove bogus PCD dependencies Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 15:32 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 03/15] ArmVirtPkg/PrePi: remove unused GetPlatformPpi() function Ard Biesheuvel
` (12 subsequent siblings)
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
Instead of invoking the library constructors of some libraries by
hand, invoke the generated function ProcessLibraryConstructorList
in AutoGen.c so all constructors are executed.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/PrePi/PrePi.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
index c69cff249e80..3679087aec4d 100755
--- a/ArmVirtPkg/PrePi/PrePi.c
+++ b/ArmVirtPkg/PrePi/PrePi.c
@@ -29,15 +29,9 @@
#include "PrePi.h"
#include "LzmaDecompress.h"
-EFI_STATUS
-EFIAPI
-ExtractGuidedSectionLibConstructor (
- VOID
- );
-
-EFI_STATUS
+VOID
EFIAPI
-LzmaDecompressLibConstructor (
+ProcessLibraryConstructorList (
VOID
);
@@ -125,8 +119,7 @@ PrePiMain (
PERF_START (NULL, "PEI", NULL, StartTimeStamp);
// SEC phase needs to run library constructors by hand.
- ExtractGuidedSectionLibConstructor ();
- LzmaDecompressLibConstructor ();
+ ProcessLibraryConstructorList ();
// Build HOBs to pass up our version of stuff the DXE Core needs to save space
BuildPeCoffLoaderHob ();
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 02/15] ArmVirtPkg/PrePi: run all library constructors by hand
2017-11-17 16:09 ` [PATCH 02/15] ArmVirtPkg/PrePi: run all library constructors by hand Ard Biesheuvel
@ 2017-11-21 15:32 ` Laszlo Ersek
0 siblings, 0 replies; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 15:32 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> Instead of invoking the library constructors of some libraries by
> hand, invoke the generated function ProcessLibraryConstructorList
> in AutoGen.c so all constructors are executed.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/PrePi/PrePi.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
> index c69cff249e80..3679087aec4d 100755
> --- a/ArmVirtPkg/PrePi/PrePi.c
> +++ b/ArmVirtPkg/PrePi/PrePi.c
> @@ -29,15 +29,9 @@
> #include "PrePi.h"
> #include "LzmaDecompress.h"
>
> -EFI_STATUS
> -EFIAPI
> -ExtractGuidedSectionLibConstructor (
> - VOID
> - );
> -
> -EFI_STATUS
> +VOID
> EFIAPI
> -LzmaDecompressLibConstructor (
> +ProcessLibraryConstructorList (
> VOID
> );
>
> @@ -125,8 +119,7 @@ PrePiMain (
> PERF_START (NULL, "PEI", NULL, StartTimeStamp);
>
> // SEC phase needs to run library constructors by hand.
> - ExtractGuidedSectionLibConstructor ();
> - LzmaDecompressLibConstructor ();
> + ProcessLibraryConstructorList ();
>
> // Build HOBs to pass up our version of stuff the DXE Core needs to save space
> BuildPeCoffLoaderHob ();
>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 03/15] ArmVirtPkg/PrePi: remove unused GetPlatformPpi() function
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
2017-11-17 16:08 ` [PATCH 01/15] ArmPlatformPkg/ArmPlatformLibNull: remove bogus PCD dependencies Ard Biesheuvel
2017-11-17 16:09 ` [PATCH 02/15] ArmVirtPkg/PrePi: run all library constructors by hand Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 15:36 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 04/15] ArmVirtPkg/PrePi: remove bogus primary core check Ard Biesheuvel
` (11 subsequent siblings)
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
Remove GetPlatformPpi() from PrePi: it is not used anywhere.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/PrePi/PrePi.c | 24 --------------------
1 file changed, 24 deletions(-)
diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
index 3679087aec4d..c4fa979c43ef 100755
--- a/ArmVirtPkg/PrePi/PrePi.c
+++ b/ArmVirtPkg/PrePi/PrePi.c
@@ -35,30 +35,6 @@ ProcessLibraryConstructorList (
VOID
);
-EFI_STATUS
-GetPlatformPpi (
- IN EFI_GUID *PpiGuid,
- OUT VOID **Ppi
- )
-{
- UINTN PpiListSize;
- UINTN PpiListCount;
- EFI_PEI_PPI_DESCRIPTOR *PpiList;
- UINTN Index;
-
- PpiListSize = 0;
- ArmPlatformGetPlatformPpiList (&PpiListSize, &PpiList);
- PpiListCount = PpiListSize / sizeof(EFI_PEI_PPI_DESCRIPTOR);
- for (Index = 0; Index < PpiListCount; Index++, PpiList++) {
- if (CompareGuid (PpiList->Guid, PpiGuid) == TRUE) {
- *Ppi = PpiList->Ppi;
- return EFI_SUCCESS;
- }
- }
-
- return EFI_NOT_FOUND;
-}
-
VOID
PrePiMain (
IN UINTN UefiMemoryBase,
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 03/15] ArmVirtPkg/PrePi: remove unused GetPlatformPpi() function
2017-11-17 16:09 ` [PATCH 03/15] ArmVirtPkg/PrePi: remove unused GetPlatformPpi() function Ard Biesheuvel
@ 2017-11-21 15:36 ` Laszlo Ersek
0 siblings, 0 replies; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 15:36 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> Remove GetPlatformPpi() from PrePi: it is not used anywhere.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/PrePi/PrePi.c | 24 --------------------
> 1 file changed, 24 deletions(-)
>
> diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
> index 3679087aec4d..c4fa979c43ef 100755
> --- a/ArmVirtPkg/PrePi/PrePi.c
> +++ b/ArmVirtPkg/PrePi/PrePi.c
> @@ -35,30 +35,6 @@ ProcessLibraryConstructorList (
> VOID
> );
>
> -EFI_STATUS
> -GetPlatformPpi (
> - IN EFI_GUID *PpiGuid,
> - OUT VOID **Ppi
> - )
> -{
> - UINTN PpiListSize;
> - UINTN PpiListCount;
> - EFI_PEI_PPI_DESCRIPTOR *PpiList;
> - UINTN Index;
> -
> - PpiListSize = 0;
> - ArmPlatformGetPlatformPpiList (&PpiListSize, &PpiList);
> - PpiListCount = PpiListSize / sizeof(EFI_PEI_PPI_DESCRIPTOR);
> - for (Index = 0; Index < PpiListCount; Index++, PpiList++) {
> - if (CompareGuid (PpiList->Guid, PpiGuid) == TRUE) {
> - *Ppi = PpiList->Ppi;
> - return EFI_SUCCESS;
> - }
> - }
> -
> - return EFI_NOT_FOUND;
> -}
> -
> VOID
> PrePiMain (
> IN UINTN UefiMemoryBase,
>
I suggest removing the function declaration as well, from "PrePi.h"
(assuming that's possible). With that:
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 04/15] ArmVirtPkg/PrePi: remove bogus primary core check
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
` (2 preceding siblings ...)
2017-11-17 16:09 ` [PATCH 03/15] ArmVirtPkg/PrePi: remove unused GetPlatformPpi() function Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 15:40 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 05/15] ArmVirtPkg/PrePi: remove dependency on ArmPlatformLib Ard Biesheuvel
` (10 subsequent siblings)
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
QEMU and KVM based ARM/AARCH64 virtual machines only enter UEFI on
a single core, so ArmPlatformIsPrimaryCore() always returns true.
And even if it didn't, our code does absolutely nothing meaningful
based on its return value, so don't bother calling it, and remove
another frivolous dependency on ArmPlatformLib.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S | 7 -------
ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S | 7 -------
2 files changed, 14 deletions(-)
diff --git a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
index cc8b47e69026..7a9c0c3787cc 100644
--- a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
+++ b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
@@ -128,13 +128,6 @@ _GetStackBase:
MOV32 (x3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
bl ASM_PFX(ArmPlatformStackSet)
- // Is it the Primary Core ?
- mov x0, x10
- bl ASM_PFX(ArmPlatformIsPrimaryCore)
- cmp x0, #1
- bne _PrepareArguments
-
-_PrepareArguments:
mov x0, x20
mov x1, x21
mov x2, x22
diff --git a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
index 59028d0a553e..eebf660acdb2 100644
--- a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
+++ b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
@@ -136,13 +136,6 @@ _GetStackBase:
MOV32 (r3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
bl ASM_PFX(ArmPlatformStackSet)
- // Is it the Primary Core ?
- mov r0, r10
- bl ASM_PFX(ArmPlatformIsPrimaryCore)
- cmp r0, #1
- bne _PrepareArguments
-
-_PrepareArguments:
mov r0, r10
mov r1, r11
mov r2, r9
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 04/15] ArmVirtPkg/PrePi: remove bogus primary core check
2017-11-17 16:09 ` [PATCH 04/15] ArmVirtPkg/PrePi: remove bogus primary core check Ard Biesheuvel
@ 2017-11-21 15:40 ` Laszlo Ersek
0 siblings, 0 replies; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 15:40 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> QEMU and KVM based ARM/AARCH64 virtual machines only enter UEFI on
> a single core, so ArmPlatformIsPrimaryCore() always returns true.
> And even if it didn't, our code does absolutely nothing meaningful
> based on its return value, so don't bother calling it, and remove
> another frivolous dependency on ArmPlatformLib.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S | 7 -------
> ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S | 7 -------
> 2 files changed, 14 deletions(-)
>
> diff --git a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
> index cc8b47e69026..7a9c0c3787cc 100644
> --- a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
> +++ b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
> @@ -128,13 +128,6 @@ _GetStackBase:
> MOV32 (x3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
> bl ASM_PFX(ArmPlatformStackSet)
>
> - // Is it the Primary Core ?
> - mov x0, x10
> - bl ASM_PFX(ArmPlatformIsPrimaryCore)
> - cmp x0, #1
> - bne _PrepareArguments
> -
> -_PrepareArguments:
> mov x0, x20
> mov x1, x21
> mov x2, x22
> diff --git a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
> index 59028d0a553e..eebf660acdb2 100644
> --- a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
> +++ b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
> @@ -136,13 +136,6 @@ _GetStackBase:
> MOV32 (r3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
> bl ASM_PFX(ArmPlatformStackSet)
>
> - // Is it the Primary Core ?
> - mov r0, r10
> - bl ASM_PFX(ArmPlatformIsPrimaryCore)
> - cmp r0, #1
> - bne _PrepareArguments
> -
> -_PrepareArguments:
> mov r0, r10
> mov r1, r11
> mov r2, r9
>
I'll assume ArmPlatformIsPrimaryCore has no side effects. Beyond that,
even I can see that
conditional-jump LABEL
LABEL: ...
is a no-op :)
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 05/15] ArmVirtPkg/PrePi: remove dependency on ArmPlatformLib
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
` (3 preceding siblings ...)
2017-11-17 16:09 ` [PATCH 04/15] ArmVirtPkg/PrePi: remove bogus primary core check Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 15:46 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 06/15] ArmVirtPkg/PrePi: move DRAM discovery code into PrePi Ard Biesheuvel
` (9 subsequent siblings)
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
Remove the pointless dependency on ArmPlatformLib: none of the code we
call from it actually does anything useful.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 -
ArmVirtPkg/PrePi/PrePi.c | 6 ++----
ArmVirtPkg/PrePi/PrePi.h | 1 -
3 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
index 5e706934f69f..1d79b1360c22 100755
--- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
+++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
@@ -52,7 +52,6 @@ [LibraryClasses]
LzmaDecompressLib
PeCoffGetEntryPointLib
PrePiLib
- ArmPlatformLib
ArmPlatformStackLib
MemoryAllocationLib
HobLib
diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
index c4fa979c43ef..fce4ab9428a5 100755
--- a/ArmVirtPkg/PrePi/PrePi.c
+++ b/ArmVirtPkg/PrePi/PrePi.c
@@ -13,6 +13,7 @@
**/
#include <PiPei.h>
+#include <Pi/PiBootMode.h>
#include <Library/PrePiLib.h>
#include <Library/PrintLib.h>
@@ -85,7 +86,7 @@ PrePiMain (
BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
// Set the Boot Mode
- SetBootMode (ArmPlatformGetBootMode ());
+ SetBootMode (BOOT_WITH_FULL_CONFIGURATION);
// Initialize Platform HOBs (CpuHob and FvHob)
Status = PlatformPeim ();
@@ -123,9 +124,6 @@ CEntryPoint (
{
UINT64 StartTimeStamp;
- // Initialize the platform specific controllers
- ArmPlatformInitialize (MpId);
-
if (PerformanceMeasurementEnabled ()) {
// Initialize the Timer Library to setup the Timer HW controller
TimerConstructor ();
diff --git a/ArmVirtPkg/PrePi/PrePi.h b/ArmVirtPkg/PrePi/PrePi.h
index d3189c0b8a6f..1ba88e0506cb 100644
--- a/ArmVirtPkg/PrePi/PrePi.h
+++ b/ArmVirtPkg/PrePi/PrePi.h
@@ -25,7 +25,6 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/HobLib.h>
#include <Library/SerialPortLib.h>
-#include <Library/ArmPlatformLib.h>
#define SerialPrint(txt) SerialPortWrite (txt, AsciiStrLen(txt)+1);
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 05/15] ArmVirtPkg/PrePi: remove dependency on ArmPlatformLib
2017-11-17 16:09 ` [PATCH 05/15] ArmVirtPkg/PrePi: remove dependency on ArmPlatformLib Ard Biesheuvel
@ 2017-11-21 15:46 ` Laszlo Ersek
2017-11-21 15:47 ` Laszlo Ersek
0 siblings, 1 reply; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 15:46 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> Remove the pointless dependency on ArmPlatformLib: none of the code we
> call from it actually does anything useful.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 -
> ArmVirtPkg/PrePi/PrePi.c | 6 ++----
> ArmVirtPkg/PrePi/PrePi.h | 1 -
> 3 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> index 5e706934f69f..1d79b1360c22 100755
> --- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> +++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> @@ -52,7 +52,6 @@ [LibraryClasses]
> LzmaDecompressLib
> PeCoffGetEntryPointLib
> PrePiLib
> - ArmPlatformLib
> ArmPlatformStackLib
> MemoryAllocationLib
> HobLib
> diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
> index c4fa979c43ef..fce4ab9428a5 100755
> --- a/ArmVirtPkg/PrePi/PrePi.c
> +++ b/ArmVirtPkg/PrePi/PrePi.c
> @@ -13,6 +13,7 @@
> **/
>
> #include <PiPei.h>
> +#include <Pi/PiBootMode.h>
>
> #include <Library/PrePiLib.h>
> #include <Library/PrintLib.h>
> @@ -85,7 +86,7 @@ PrePiMain (
> BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
>
> // Set the Boot Mode
> - SetBootMode (ArmPlatformGetBootMode ());
> + SetBootMode (BOOT_WITH_FULL_CONFIGURATION);
>
> // Initialize Platform HOBs (CpuHob and FvHob)
> Status = PlatformPeim ();
> @@ -123,9 +124,6 @@ CEntryPoint (
> {
> UINT64 StartTimeStamp;
>
> - // Initialize the platform specific controllers
> - ArmPlatformInitialize (MpId);
> -
> if (PerformanceMeasurementEnabled ()) {
> // Initialize the Timer Library to setup the Timer HW controller
> TimerConstructor ();
> diff --git a/ArmVirtPkg/PrePi/PrePi.h b/ArmVirtPkg/PrePi/PrePi.h
> index d3189c0b8a6f..1ba88e0506cb 100644
> --- a/ArmVirtPkg/PrePi/PrePi.h
> +++ b/ArmVirtPkg/PrePi/PrePi.h
> @@ -25,7 +25,6 @@
> #include <Library/MemoryAllocationLib.h>
> #include <Library/HobLib.h>
> #include <Library/SerialPortLib.h>
> -#include <Library/ArmPlatformLib.h>
>
> #define SerialPrint(txt) SerialPortWrite (txt, AsciiStrLen(txt)+1);
>
>
ArmPlatformGetBootMode() and ArmPlatformInitialize() have identical
implementations between the ArmQemuRelocatablePlatformLib and the
ArmXenRelocatablePlatformLib instances, so I agree common handling is
justified here.
The ArmPlatformInitialize() call is not replaced by the function's contents:
ASSERT (!FeaturePcdGet (PcdSystemMemoryInitializeInSec));
but I guess this assertion is satisfied simply by the PrePi nature of
the platform -- once we stop sharing the code like before, the assert
becomes useless (there's no possible mis-build to catch). I think,
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 05/15] ArmVirtPkg/PrePi: remove dependency on ArmPlatformLib
2017-11-21 15:46 ` Laszlo Ersek
@ 2017-11-21 15:47 ` Laszlo Ersek
0 siblings, 0 replies; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 15:47 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel
On 11/21/17 16:46, Laszlo Ersek wrote:
> On 11/17/17 17:09, Ard Biesheuvel wrote:
>> Remove the pointless dependency on ArmPlatformLib: none of the code we
>> call from it actually does anything useful.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>> ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 -
>> ArmVirtPkg/PrePi/PrePi.c | 6 ++----
>> ArmVirtPkg/PrePi/PrePi.h | 1 -
>> 3 files changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
>> index 5e706934f69f..1d79b1360c22 100755
>> --- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
>> +++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
>> @@ -52,7 +52,6 @@ [LibraryClasses]
>> LzmaDecompressLib
>> PeCoffGetEntryPointLib
>> PrePiLib
>> - ArmPlatformLib
>> ArmPlatformStackLib
>> MemoryAllocationLib
>> HobLib
>> diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
>> index c4fa979c43ef..fce4ab9428a5 100755
>> --- a/ArmVirtPkg/PrePi/PrePi.c
>> +++ b/ArmVirtPkg/PrePi/PrePi.c
>> @@ -13,6 +13,7 @@
>> **/
>>
>> #include <PiPei.h>
>> +#include <Pi/PiBootMode.h>
>>
>> #include <Library/PrePiLib.h>
>> #include <Library/PrintLib.h>
>> @@ -85,7 +86,7 @@ PrePiMain (
>> BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
>>
>> // Set the Boot Mode
>> - SetBootMode (ArmPlatformGetBootMode ());
>> + SetBootMode (BOOT_WITH_FULL_CONFIGURATION);
>>
>> // Initialize Platform HOBs (CpuHob and FvHob)
>> Status = PlatformPeim ();
>> @@ -123,9 +124,6 @@ CEntryPoint (
>> {
>> UINT64 StartTimeStamp;
>>
>> - // Initialize the platform specific controllers
>> - ArmPlatformInitialize (MpId);
>> -
>> if (PerformanceMeasurementEnabled ()) {
>> // Initialize the Timer Library to setup the Timer HW controller
>> TimerConstructor ();
>> diff --git a/ArmVirtPkg/PrePi/PrePi.h b/ArmVirtPkg/PrePi/PrePi.h
>> index d3189c0b8a6f..1ba88e0506cb 100644
>> --- a/ArmVirtPkg/PrePi/PrePi.h
>> +++ b/ArmVirtPkg/PrePi/PrePi.h
>> @@ -25,7 +25,6 @@
>> #include <Library/MemoryAllocationLib.h>
>> #include <Library/HobLib.h>
>> #include <Library/SerialPortLib.h>
>> -#include <Library/ArmPlatformLib.h>
>>
>> #define SerialPrint(txt) SerialPortWrite (txt, AsciiStrLen(txt)+1);
>>
>>
>
> ArmPlatformGetBootMode() and ArmPlatformInitialize() have identical
> implementations between the ArmQemuRelocatablePlatformLib and the
> ArmXenRelocatablePlatformLib instances, so I agree common handling is
> justified here.
>
> The ArmPlatformInitialize() call is not replaced by the function's contents:
>
> ASSERT (!FeaturePcdGet (PcdSystemMemoryInitializeInSec));
>
> but I guess this assertion is satisfied simply by the PrePi nature of
> the platform -- once we stop sharing the code like before, the assert
> becomes useless (there's no possible mis-build to catch). I think,
>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
>
heh, that was supposed to be: "I think.". Nothing else to add :)
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 06/15] ArmVirtPkg/PrePi: move DRAM discovery code into PrePi
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
` (4 preceding siblings ...)
2017-11-17 16:09 ` [PATCH 05/15] ArmVirtPkg/PrePi: remove dependency on ArmPlatformLib Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 15:48 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 07/15] ArmVirtPkg/PrePi: remove ArmPlatformStackLib dependency Ard Biesheuvel
` (8 subsequent siblings)
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
ArmVirtQemuKernel and ArmVirtXen use essentially the same code to
retrieve DRAM information from the DT /memory node at early boot,
and invoke it via the ArmPlatformPeiBootAction () hook exposed by
ArmPlatformLib. Let's move this code into the PrePi implementation
these platforms share between them (and not with any other platforms)
so we can eliminate another dependency on the messy ArmPlatformLib.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S | 77 ++++++++++++++++-
ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S | 71 +++++++++++++++
ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 2 +
ArmVirtPkg/PrePi/FdtParser.c | 90 ++++++++++++++++++++
4 files changed, 238 insertions(+), 2 deletions(-)
diff --git a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
index 7a9c0c3787cc..3296aedfe9aa 100644
--- a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
+++ b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
@@ -49,8 +49,7 @@ ASM_FUNC(_ModuleEntryPoint)
b .Lreloc_loop
.Lreloc_done:
- // Do early platform specific actions
- bl ASM_PFX(ArmPlatformPeiBootAction)
+ bl ASM_PFX(DiscoverDramFromDt)
// Get ID of this CPU in Multicore system
bl ASM_PFX(ArmReadMpidr)
@@ -140,3 +139,77 @@ _GetStackBase:
_NeverReturn:
b _NeverReturn
+
+// VOID
+// DiscoverDramFromDt (
+// VOID *DeviceTreeBaseAddress, // passed by loader in x0
+// VOID *ImageBase // passed by FDF trampoline in x1
+// );
+ASM_PFX(DiscoverDramFromDt):
+ //
+ // If we are booting from RAM using the Linux kernel boot protocol, x0 will
+ // point to the DTB image in memory. Otherwise, use the default value defined
+ // by the platform.
+ //
+ cbnz x0, 0f
+ ldr x0, PcdGet64 (PcdDeviceTreeInitialBaseAddress)
+
+0:mov x29, x30 // preserve LR
+ mov x28, x0 // preserve DTB pointer
+ mov x27, x1 // preserve base of image pointer
+
+ //
+ // The base of the runtime image has been preserved in x1. Check whether
+ // the expected magic number can be found in the header.
+ //
+ ldr w8, .LArm64LinuxMagic
+ ldr w9, [x1, #0x38]
+ cmp w8, w9
+ bne .Lout
+
+ //
+ //
+ // OK, so far so good. We have confirmed that we likely have a DTB and are
+ // booting via the arm64 Linux boot protocol. Update the base-of-image PCD
+ // to the actual relocated value, and add the shift of PcdFdBaseAddress to
+ // PcdFvBaseAddress as well
+ //
+ adr x8, PcdGet64 (PcdFdBaseAddress)
+ adr x9, PcdGet64 (PcdFvBaseAddress)
+ ldr x6, [x8]
+ ldr x7, [x9]
+ sub x7, x7, x6
+ add x7, x7, x1
+ str x1, [x8]
+ str x7, [x9]
+
+ //
+ // Discover the memory size and offset from the DTB, and record in the
+ // respective PCDs. This will also return false if a corrupt DTB is
+ // encountered. Since we are calling a C function, use the window at the
+ // beginning of the FD image as a temp stack.
+ //
+ adr x1, PcdGet64 (PcdSystemMemoryBase)
+ adr x2, PcdGet64 (PcdSystemMemorySize)
+ mov sp, x7
+ bl FindMemnode
+ cbz x0, .Lout
+
+ //
+ // Copy the DTB to the slack space right after the 64 byte arm64/Linux style
+ // image header at the base of this image (defined in the FDF), and record the
+ // pointer in PcdDeviceTreeInitialBaseAddress.
+ //
+ adr x8, PcdGet64 (PcdDeviceTreeInitialBaseAddress)
+ add x27, x27, #0x40
+ str x27, [x8]
+
+ mov x0, x27
+ mov x1, x28
+ bl CopyFdt
+
+.Lout:
+ ret x29
+
+.LArm64LinuxMagic:
+ .byte 0x41, 0x52, 0x4d, 0x64
diff --git a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
index eebf660acdb2..a918c191432e 100644
--- a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
+++ b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
@@ -148,3 +148,74 @@ _GetStackBase:
_NeverReturn:
b _NeverReturn
+
+ASM_PFX(ArmPlatformPeiBootAction):
+ //
+ // If we are booting from RAM using the Linux kernel boot protocol, r0 will
+ // point to the DTB image in memory. Otherwise, use the default value defined
+ // by the platform.
+ //
+ teq r0, #0
+ bne 0f
+ LDRL (r0, PcdGet64 (PcdDeviceTreeInitialBaseAddress))
+
+0:mov r11, r14 // preserve LR
+ mov r10, r0 // preserve DTB pointer
+ mov r9, r1 // preserve base of image pointer
+
+ //
+ // The base of the runtime image has been preserved in r1. Check whether
+ // the expected magic number can be found in the header.
+ //
+ ldr r8, .LArm32LinuxMagic
+ ldr r7, [r1, #0x24]
+ cmp r7, r8
+ bne .Lout
+
+ //
+ //
+ // OK, so far so good. We have confirmed that we likely have a DTB and are
+ // booting via the ARM Linux boot protocol. Update the base-of-image PCD
+ // to the actual relocated value, and add the shift of PcdFdBaseAddress to
+ // PcdFvBaseAddress as well
+ //
+ ADRL (r8, PcdGet64 (PcdFdBaseAddress))
+ ADRL (r7, PcdGet64 (PcdFvBaseAddress))
+ ldr r6, [r8]
+ ldr r5, [r7]
+ sub r5, r5, r6
+ add r5, r5, r1
+ str r1, [r8]
+ str r5, [r7]
+
+ //
+ // Discover the memory size and offset from the DTB, and record in the
+ // respective PCDs. This will also return false if a corrupt DTB is
+ // encountered. Since we are calling a C function, use the window at the
+ // beginning of the FD image as a temp stack.
+ //
+ ADRL (r1, PcdGet64 (PcdSystemMemoryBase))
+ ADRL (r2, PcdGet64 (PcdSystemMemorySize))
+ mov sp, r5
+ bl FindMemnode
+ teq r0, #0
+ beq .Lout
+
+ //
+ // Copy the DTB to the slack space right after the 64 byte arm64/Linux style
+ // image header at the base of this image (defined in the FDF), and record the
+ // pointer in PcdDeviceTreeInitialBaseAddress.
+ //
+ ADRL (r8, PcdGet64 (PcdDeviceTreeInitialBaseAddress))
+ add r9, r9, #0x40
+ str r9, [r8]
+
+ mov r0, r9
+ mov r1, r10
+ bl CopyFdt
+
+.Lout:
+ bx r11
+
+.LArm32LinuxMagic:
+ .byte 0x18, 0x28, 0x6f, 0x01
diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
index 1d79b1360c22..e816e9583da8 100755
--- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
+++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
@@ -23,6 +23,7 @@ [Defines]
[Sources]
PrePi.c
+ FdtParser.c
[Sources.AArch64]
AArch64/ArchPrePi.c
@@ -44,6 +45,7 @@ [Packages]
[LibraryClasses]
BaseLib
DebugLib
+ FdtLib
ArmLib
IoLib
TimerLib
diff --git a/ArmVirtPkg/PrePi/FdtParser.c b/ArmVirtPkg/PrePi/FdtParser.c
new file mode 100644
index 000000000000..afdc81a8839d
--- /dev/null
+++ b/ArmVirtPkg/PrePi/FdtParser.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2015, 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 <Uefi.h>
+#include <Include/libfdt.h>
+
+BOOLEAN
+FindMemnode (
+ IN VOID *DeviceTreeBlob,
+ OUT UINT64 *SystemMemoryBase,
+ OUT UINT64 *SystemMemorySize
+ )
+{
+ INT32 MemoryNode;
+ INT32 AddressCells;
+ INT32 SizeCells;
+ INT32 Length;
+ CONST INT32 *Prop;
+
+ if (fdt_check_header (DeviceTreeBlob) != 0) {
+ return FALSE;
+ }
+
+ //
+ // Look for a node called "memory" at the lowest level of the tree
+ //
+ MemoryNode = fdt_path_offset (DeviceTreeBlob, "/memory");
+ if (MemoryNode <= 0) {
+ return FALSE;
+ }
+
+ //
+ // Retrieve the #address-cells and #size-cells properties
+ // from the root node, or use the default if not provided.
+ //
+ AddressCells = 1;
+ SizeCells = 1;
+
+ Prop = fdt_getprop (DeviceTreeBlob, 0, "#address-cells", &Length);
+ if (Length == 4) {
+ AddressCells = fdt32_to_cpu (*Prop);
+ }
+
+ Prop = fdt_getprop (DeviceTreeBlob, 0, "#size-cells", &Length);
+ if (Length == 4) {
+ SizeCells = fdt32_to_cpu (*Prop);
+ }
+
+ //
+ // Now find the 'reg' property of the /memory node, and read the first
+ // range listed.
+ //
+ Prop = fdt_getprop (DeviceTreeBlob, MemoryNode, "reg", &Length);
+
+ if (Length < (AddressCells + SizeCells) * sizeof (INT32)) {
+ return FALSE;
+ }
+
+ *SystemMemoryBase = fdt32_to_cpu (Prop[0]);
+ if (AddressCells > 1) {
+ *SystemMemoryBase = (*SystemMemoryBase << 32) | fdt32_to_cpu (Prop[1]);
+ }
+ Prop += AddressCells;
+
+ *SystemMemorySize = fdt32_to_cpu (Prop[0]);
+ if (SizeCells > 1) {
+ *SystemMemorySize = (*SystemMemorySize << 32) | fdt32_to_cpu (Prop[1]);
+ }
+
+ return TRUE;
+}
+
+VOID
+CopyFdt (
+ IN VOID *FdtDest,
+ IN VOID *FdtSource
+ )
+{
+ fdt_pack(FdtSource);
+ CopyMem (FdtDest, FdtSource, fdt_totalsize (FdtSource));
+}
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 06/15] ArmVirtPkg/PrePi: move DRAM discovery code into PrePi
2017-11-17 16:09 ` [PATCH 06/15] ArmVirtPkg/PrePi: move DRAM discovery code into PrePi Ard Biesheuvel
@ 2017-11-21 15:48 ` Laszlo Ersek
0 siblings, 0 replies; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 15:48 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> ArmVirtQemuKernel and ArmVirtXen use essentially the same code to
> retrieve DRAM information from the DT /memory node at early boot,
> and invoke it via the ArmPlatformPeiBootAction () hook exposed by
> ArmPlatformLib. Let's move this code into the PrePi implementation
> these platforms share between them (and not with any other platforms)
> so we can eliminate another dependency on the messy ArmPlatformLib.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S | 77 ++++++++++++++++-
> ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S | 71 +++++++++++++++
> ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 2 +
> ArmVirtPkg/PrePi/FdtParser.c | 90 ++++++++++++++++++++
> 4 files changed, 238 insertions(+), 2 deletions(-)
>
> diff --git a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
> index 7a9c0c3787cc..3296aedfe9aa 100644
> --- a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
> +++ b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
> @@ -49,8 +49,7 @@ ASM_FUNC(_ModuleEntryPoint)
> b .Lreloc_loop
> .Lreloc_done:
>
> - // Do early platform specific actions
> - bl ASM_PFX(ArmPlatformPeiBootAction)
> + bl ASM_PFX(DiscoverDramFromDt)
>
> // Get ID of this CPU in Multicore system
> bl ASM_PFX(ArmReadMpidr)
> @@ -140,3 +139,77 @@ _GetStackBase:
>
> _NeverReturn:
> b _NeverReturn
> +
> +// VOID
> +// DiscoverDramFromDt (
> +// VOID *DeviceTreeBaseAddress, // passed by loader in x0
> +// VOID *ImageBase // passed by FDF trampoline in x1
> +// );
> +ASM_PFX(DiscoverDramFromDt):
> + //
> + // If we are booting from RAM using the Linux kernel boot protocol, x0 will
> + // point to the DTB image in memory. Otherwise, use the default value defined
> + // by the platform.
> + //
> + cbnz x0, 0f
> + ldr x0, PcdGet64 (PcdDeviceTreeInitialBaseAddress)
> +
> +0:mov x29, x30 // preserve LR
> + mov x28, x0 // preserve DTB pointer
> + mov x27, x1 // preserve base of image pointer
> +
> + //
> + // The base of the runtime image has been preserved in x1. Check whether
> + // the expected magic number can be found in the header.
> + //
> + ldr w8, .LArm64LinuxMagic
> + ldr w9, [x1, #0x38]
> + cmp w8, w9
> + bne .Lout
> +
> + //
> + //
> + // OK, so far so good. We have confirmed that we likely have a DTB and are
> + // booting via the arm64 Linux boot protocol. Update the base-of-image PCD
> + // to the actual relocated value, and add the shift of PcdFdBaseAddress to
> + // PcdFvBaseAddress as well
> + //
> + adr x8, PcdGet64 (PcdFdBaseAddress)
> + adr x9, PcdGet64 (PcdFvBaseAddress)
> + ldr x6, [x8]
> + ldr x7, [x9]
> + sub x7, x7, x6
> + add x7, x7, x1
> + str x1, [x8]
> + str x7, [x9]
> +
> + //
> + // Discover the memory size and offset from the DTB, and record in the
> + // respective PCDs. This will also return false if a corrupt DTB is
> + // encountered. Since we are calling a C function, use the window at the
> + // beginning of the FD image as a temp stack.
> + //
> + adr x1, PcdGet64 (PcdSystemMemoryBase)
> + adr x2, PcdGet64 (PcdSystemMemorySize)
> + mov sp, x7
> + bl FindMemnode
> + cbz x0, .Lout
> +
> + //
> + // Copy the DTB to the slack space right after the 64 byte arm64/Linux style
> + // image header at the base of this image (defined in the FDF), and record the
> + // pointer in PcdDeviceTreeInitialBaseAddress.
> + //
> + adr x8, PcdGet64 (PcdDeviceTreeInitialBaseAddress)
> + add x27, x27, #0x40
> + str x27, [x8]
> +
> + mov x0, x27
> + mov x1, x28
> + bl CopyFdt
> +
> +.Lout:
> + ret x29
> +
> +.LArm64LinuxMagic:
> + .byte 0x41, 0x52, 0x4d, 0x64
> diff --git a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
> index eebf660acdb2..a918c191432e 100644
> --- a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
> +++ b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
> @@ -148,3 +148,74 @@ _GetStackBase:
>
> _NeverReturn:
> b _NeverReturn
> +
> +ASM_PFX(ArmPlatformPeiBootAction):
> + //
> + // If we are booting from RAM using the Linux kernel boot protocol, r0 will
> + // point to the DTB image in memory. Otherwise, use the default value defined
> + // by the platform.
> + //
> + teq r0, #0
> + bne 0f
> + LDRL (r0, PcdGet64 (PcdDeviceTreeInitialBaseAddress))
> +
> +0:mov r11, r14 // preserve LR
> + mov r10, r0 // preserve DTB pointer
> + mov r9, r1 // preserve base of image pointer
> +
> + //
> + // The base of the runtime image has been preserved in r1. Check whether
> + // the expected magic number can be found in the header.
> + //
> + ldr r8, .LArm32LinuxMagic
> + ldr r7, [r1, #0x24]
> + cmp r7, r8
> + bne .Lout
> +
> + //
> + //
> + // OK, so far so good. We have confirmed that we likely have a DTB and are
> + // booting via the ARM Linux boot protocol. Update the base-of-image PCD
> + // to the actual relocated value, and add the shift of PcdFdBaseAddress to
> + // PcdFvBaseAddress as well
> + //
> + ADRL (r8, PcdGet64 (PcdFdBaseAddress))
> + ADRL (r7, PcdGet64 (PcdFvBaseAddress))
> + ldr r6, [r8]
> + ldr r5, [r7]
> + sub r5, r5, r6
> + add r5, r5, r1
> + str r1, [r8]
> + str r5, [r7]
> +
> + //
> + // Discover the memory size and offset from the DTB, and record in the
> + // respective PCDs. This will also return false if a corrupt DTB is
> + // encountered. Since we are calling a C function, use the window at the
> + // beginning of the FD image as a temp stack.
> + //
> + ADRL (r1, PcdGet64 (PcdSystemMemoryBase))
> + ADRL (r2, PcdGet64 (PcdSystemMemorySize))
> + mov sp, r5
> + bl FindMemnode
> + teq r0, #0
> + beq .Lout
> +
> + //
> + // Copy the DTB to the slack space right after the 64 byte arm64/Linux style
> + // image header at the base of this image (defined in the FDF), and record the
> + // pointer in PcdDeviceTreeInitialBaseAddress.
> + //
> + ADRL (r8, PcdGet64 (PcdDeviceTreeInitialBaseAddress))
> + add r9, r9, #0x40
> + str r9, [r8]
> +
> + mov r0, r9
> + mov r1, r10
> + bl CopyFdt
> +
> +.Lout:
> + bx r11
> +
> +.LArm32LinuxMagic:
> + .byte 0x18, 0x28, 0x6f, 0x01
> diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> index 1d79b1360c22..e816e9583da8 100755
> --- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> +++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> @@ -23,6 +23,7 @@ [Defines]
>
> [Sources]
> PrePi.c
> + FdtParser.c
>
> [Sources.AArch64]
> AArch64/ArchPrePi.c
> @@ -44,6 +45,7 @@ [Packages]
> [LibraryClasses]
> BaseLib
> DebugLib
> + FdtLib
> ArmLib
> IoLib
> TimerLib
> diff --git a/ArmVirtPkg/PrePi/FdtParser.c b/ArmVirtPkg/PrePi/FdtParser.c
> new file mode 100644
> index 000000000000..afdc81a8839d
> --- /dev/null
> +++ b/ArmVirtPkg/PrePi/FdtParser.c
> @@ -0,0 +1,90 @@
> +/*
> + * Copyright (c) 2015, 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 <Uefi.h>
> +#include <Include/libfdt.h>
> +
> +BOOLEAN
> +FindMemnode (
> + IN VOID *DeviceTreeBlob,
> + OUT UINT64 *SystemMemoryBase,
> + OUT UINT64 *SystemMemorySize
> + )
> +{
> + INT32 MemoryNode;
> + INT32 AddressCells;
> + INT32 SizeCells;
> + INT32 Length;
> + CONST INT32 *Prop;
> +
> + if (fdt_check_header (DeviceTreeBlob) != 0) {
> + return FALSE;
> + }
> +
> + //
> + // Look for a node called "memory" at the lowest level of the tree
> + //
> + MemoryNode = fdt_path_offset (DeviceTreeBlob, "/memory");
> + if (MemoryNode <= 0) {
> + return FALSE;
> + }
> +
> + //
> + // Retrieve the #address-cells and #size-cells properties
> + // from the root node, or use the default if not provided.
> + //
> + AddressCells = 1;
> + SizeCells = 1;
> +
> + Prop = fdt_getprop (DeviceTreeBlob, 0, "#address-cells", &Length);
> + if (Length == 4) {
> + AddressCells = fdt32_to_cpu (*Prop);
> + }
> +
> + Prop = fdt_getprop (DeviceTreeBlob, 0, "#size-cells", &Length);
> + if (Length == 4) {
> + SizeCells = fdt32_to_cpu (*Prop);
> + }
> +
> + //
> + // Now find the 'reg' property of the /memory node, and read the first
> + // range listed.
> + //
> + Prop = fdt_getprop (DeviceTreeBlob, MemoryNode, "reg", &Length);
> +
> + if (Length < (AddressCells + SizeCells) * sizeof (INT32)) {
> + return FALSE;
> + }
> +
> + *SystemMemoryBase = fdt32_to_cpu (Prop[0]);
> + if (AddressCells > 1) {
> + *SystemMemoryBase = (*SystemMemoryBase << 32) | fdt32_to_cpu (Prop[1]);
> + }
> + Prop += AddressCells;
> +
> + *SystemMemorySize = fdt32_to_cpu (Prop[0]);
> + if (SizeCells > 1) {
> + *SystemMemorySize = (*SystemMemorySize << 32) | fdt32_to_cpu (Prop[1]);
> + }
> +
> + return TRUE;
> +}
> +
> +VOID
> +CopyFdt (
> + IN VOID *FdtDest,
> + IN VOID *FdtSource
> + )
> +{
> + fdt_pack(FdtSource);
> + CopyMem (FdtDest, FdtSource, fdt_totalsize (FdtSource));
> +}
>
OK, this is where my curiosity about PrePi starts to wane :) /me checks
the diffstat.
Acked-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 07/15] ArmVirtPkg/PrePi: remove ArmPlatformStackLib dependency
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
` (5 preceding siblings ...)
2017-11-17 16:09 ` [PATCH 06/15] ArmVirtPkg/PrePi: move DRAM discovery code into PrePi Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 15:51 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 08/15] ArmVirtPkg/PrePi: remove bogus IntelFrameworkModulePkg.dec dependency Ard Biesheuvel
` (7 subsequent siblings)
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
ArmPlatformStackLib has hooks into primary/secondary core PCDs and
other ArmPlatformLib related junk, so let's simply set the stack
pointer directly. This is trivial given that our PrePi is unicore
only.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/ArmVirt.dsc.inc | 1 -
ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S | 14 ++------------
ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S | 14 ++------------
ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 -
4 files changed, 4 insertions(+), 26 deletions(-)
diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 50eb8675d1c0..5d7edff104b5 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -93,7 +93,6 @@ [LibraryClasses.common]
ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
ArmGicArchLib|ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf
- ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.inf
diff --git a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
index 3296aedfe9aa..891cf1fcab40 100644
--- a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
+++ b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
@@ -111,22 +111,12 @@ _GetBaseUefiMemory:
_GetStackBase:
// r1 = The top of the Mpcore Stacks
+ mov sp, x1
+
// Stack for the primary core = PrimaryCoreStack
MOV32 (x2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
sub x22, x1, x2
- // Stack for the secondary core = Number of Cores - 1
- MOV32 (x1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
- sub x22, x22, x1
-
- // x22 = The base of the MpCore Stacks (primary stack & secondary stacks)
- mov x0, x22
- mov x1, x20
- //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)
- MOV32 (x2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
- MOV32 (x3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
- bl ASM_PFX(ArmPlatformStackSet)
-
mov x0, x20
mov x1, x21
mov x2, x22
diff --git a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
index a918c191432e..ced08593e9de 100644
--- a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
+++ b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
@@ -120,22 +120,12 @@ _GetBaseUefiMemory:
_GetStackBase:
// r1 = The top of the Mpcore Stacks
+ mov sp, r1
+
// Stack for the primary core = PrimaryCoreStack
MOV32 (r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
sub r9, r1, r2
- // Stack for the secondary core = Number of Cores - 1
- MOV32 (r1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
- sub r9, r9, r1
-
- // r9 = The base of the MpCore Stacks (primary stack & secondary stacks)
- mov r0, r9
- mov r1, r10
- //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)
- MOV32 (r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
- MOV32 (r3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
- bl ASM_PFX(ArmPlatformStackSet)
-
mov r0, r10
mov r1, r11
mov r2, r9
diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
index e816e9583da8..ae9a088c7256 100755
--- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
+++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
@@ -54,7 +54,6 @@ [LibraryClasses]
LzmaDecompressLib
PeCoffGetEntryPointLib
PrePiLib
- ArmPlatformStackLib
MemoryAllocationLib
HobLib
PrePiHobListPointerLib
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 07/15] ArmVirtPkg/PrePi: remove ArmPlatformStackLib dependency
2017-11-17 16:09 ` [PATCH 07/15] ArmVirtPkg/PrePi: remove ArmPlatformStackLib dependency Ard Biesheuvel
@ 2017-11-21 15:51 ` Laszlo Ersek
0 siblings, 0 replies; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 15:51 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> ArmPlatformStackLib has hooks into primary/secondary core PCDs and
> other ArmPlatformLib related junk, so let's simply set the stack
> pointer directly. This is trivial given that our PrePi is unicore
> only.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/ArmVirt.dsc.inc | 1 -
> ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S | 14 ++------------
> ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S | 14 ++------------
> ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 -
> 4 files changed, 4 insertions(+), 26 deletions(-)
>
> diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
> index 50eb8675d1c0..5d7edff104b5 100644
> --- a/ArmVirtPkg/ArmVirt.dsc.inc
> +++ b/ArmVirtPkg/ArmVirt.dsc.inc
> @@ -93,7 +93,6 @@ [LibraryClasses.common]
> ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
> ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
> ArmGicArchLib|ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf
> - ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
> ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf
> ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.inf
> diff --git a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
> index 3296aedfe9aa..891cf1fcab40 100644
> --- a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
> +++ b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
> @@ -111,22 +111,12 @@ _GetBaseUefiMemory:
>
> _GetStackBase:
> // r1 = The top of the Mpcore Stacks
Before pushing the patch, please consider updating the "r1" comment
here, in the aarch64 version.
Acked-by: Laszlo Ersek <lersek@redhat.com>
Thanks
Laszlo
> + mov sp, x1
> +
> // Stack for the primary core = PrimaryCoreStack
> MOV32 (x2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
> sub x22, x1, x2
>
> - // Stack for the secondary core = Number of Cores - 1
> - MOV32 (x1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
> - sub x22, x22, x1
> -
> - // x22 = The base of the MpCore Stacks (primary stack & secondary stacks)
> - mov x0, x22
> - mov x1, x20
> - //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)
> - MOV32 (x2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
> - MOV32 (x3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
> - bl ASM_PFX(ArmPlatformStackSet)
> -
> mov x0, x20
> mov x1, x21
> mov x2, x22
> diff --git a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
> index a918c191432e..ced08593e9de 100644
> --- a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
> +++ b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S
> @@ -120,22 +120,12 @@ _GetBaseUefiMemory:
>
> _GetStackBase:
> // r1 = The top of the Mpcore Stacks
> + mov sp, r1
> +
> // Stack for the primary core = PrimaryCoreStack
> MOV32 (r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
> sub r9, r1, r2
>
> - // Stack for the secondary core = Number of Cores - 1
> - MOV32 (r1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
> - sub r9, r9, r1
> -
> - // r9 = The base of the MpCore Stacks (primary stack & secondary stacks)
> - mov r0, r9
> - mov r1, r10
> - //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)
> - MOV32 (r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
> - MOV32 (r3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
> - bl ASM_PFX(ArmPlatformStackSet)
> -
> mov r0, r10
> mov r1, r11
> mov r2, r9
> diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> index e816e9583da8..ae9a088c7256 100755
> --- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> +++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> @@ -54,7 +54,6 @@ [LibraryClasses]
> LzmaDecompressLib
> PeCoffGetEntryPointLib
> PrePiLib
> - ArmPlatformStackLib
> MemoryAllocationLib
> HobLib
> PrePiHobListPointerLib
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 08/15] ArmVirtPkg/PrePi: remove bogus IntelFrameworkModulePkg.dec dependency
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
` (6 preceding siblings ...)
2017-11-17 16:09 ` [PATCH 07/15] ArmVirtPkg/PrePi: remove ArmPlatformStackLib dependency Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 15:52 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 09/15] ArmVirtPkg/ArmVirtPlatformLib: remove support for uncached mappings Ard Biesheuvel
` (6 subsequent siblings)
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
PrePi doesn't use anything defined by this package so drop the bogus
dependency.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 -
1 file changed, 1 deletion(-)
diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
index ae9a088c7256..58290d2d1b76 100755
--- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
+++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
@@ -40,7 +40,6 @@ [Packages]
ArmPkg/ArmPkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
[LibraryClasses]
BaseLib
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 08/15] ArmVirtPkg/PrePi: remove bogus IntelFrameworkModulePkg.dec dependency
2017-11-17 16:09 ` [PATCH 08/15] ArmVirtPkg/PrePi: remove bogus IntelFrameworkModulePkg.dec dependency Ard Biesheuvel
@ 2017-11-21 15:52 ` Laszlo Ersek
0 siblings, 0 replies; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 15:52 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> PrePi doesn't use anything defined by this package so drop the bogus
> dependency.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> index ae9a088c7256..58290d2d1b76 100755
> --- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> +++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> @@ -40,7 +40,6 @@ [Packages]
> ArmPkg/ArmPkg.dec
> ArmPlatformPkg/ArmPlatformPkg.dec
> ArmVirtPkg/ArmVirtPkg.dec
> - IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
>
> [LibraryClasses]
> BaseLib
>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 09/15] ArmVirtPkg/ArmVirtPlatformLib: remove support for uncached mappings
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
` (7 preceding siblings ...)
2017-11-17 16:09 ` [PATCH 08/15] ArmVirtPkg/PrePi: remove bogus IntelFrameworkModulePkg.dec dependency Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 16:15 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 10/15] ArmVirtPkg: introduce ArmVirtMemInfoLib library class Ard Biesheuvel
` (5 subsequent siblings)
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
QEMU/KVM has very little tolerance for using anything except writeback
cacheable mappings of DRAM, so let's remove the 'feature' that allows
us to select uncached mappings at build time.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c b/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
index d10548f86dfc..4368d05f76ef 100644
--- a/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
+++ b/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
@@ -22,10 +22,6 @@
// Number of Virtual Memory Map Descriptors
#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
-// DDR attributes
-#define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
-#define DDR_ATTRIBUTES_UNCACHED ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED
-
EFI_PHYSICAL_ADDRESS
ArmGetPhysAddrTop (
VOID
@@ -48,7 +44,6 @@ ArmPlatformGetVirtualMemoryMap (
IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap
)
{
- ARM_MEMORY_REGION_ATTRIBUTES CacheAttributes;
ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
ASSERT (VirtualMemoryMap != NULL);
@@ -65,17 +60,11 @@ ArmPlatformGetVirtualMemoryMap (
return;
}
- if (FeaturePcdGet (PcdCacheEnable) == TRUE) {
- CacheAttributes = DDR_ATTRIBUTES_CACHED;
- } else {
- CacheAttributes = DDR_ATTRIBUTES_UNCACHED;
- }
-
// System DRAM
VirtualMemoryTable[0].PhysicalBase = PcdGet64 (PcdSystemMemoryBase);
VirtualMemoryTable[0].VirtualBase = VirtualMemoryTable[0].PhysicalBase;
VirtualMemoryTable[0].Length = PcdGet64 (PcdSystemMemorySize);
- VirtualMemoryTable[0].Attributes = CacheAttributes;
+ VirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
DEBUG ((EFI_D_INFO, "%a: Dumping System DRAM Memory Map:\n"
"\tPhysicalBase: 0x%lX\n"
@@ -104,7 +93,7 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[3].PhysicalBase = FixedPcdGet64 (PcdFdBaseAddress);
VirtualMemoryTable[3].VirtualBase = VirtualMemoryTable[3].PhysicalBase;
VirtualMemoryTable[3].Length = FixedPcdGet32 (PcdFdSize);
- VirtualMemoryTable[3].Attributes = CacheAttributes;
+ VirtualMemoryTable[3].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
// End of Table
ZeroMem (&VirtualMemoryTable[4], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 09/15] ArmVirtPkg/ArmVirtPlatformLib: remove support for uncached mappings
2017-11-17 16:09 ` [PATCH 09/15] ArmVirtPkg/ArmVirtPlatformLib: remove support for uncached mappings Ard Biesheuvel
@ 2017-11-21 16:15 ` Laszlo Ersek
0 siblings, 0 replies; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 16:15 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> QEMU/KVM has very little tolerance for using anything except writeback
> cacheable mappings of DRAM, so let's remove the 'feature' that allows
> us to select uncached mappings at build time.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c | 15 ++-------------
> 1 file changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c b/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
> index d10548f86dfc..4368d05f76ef 100644
> --- a/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
> +++ b/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
> @@ -22,10 +22,6 @@
> // Number of Virtual Memory Map Descriptors
> #define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
>
> -// DDR attributes
> -#define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
> -#define DDR_ATTRIBUTES_UNCACHED ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED
> -
> EFI_PHYSICAL_ADDRESS
> ArmGetPhysAddrTop (
> VOID
> @@ -48,7 +44,6 @@ ArmPlatformGetVirtualMemoryMap (
> IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap
> )
> {
> - ARM_MEMORY_REGION_ATTRIBUTES CacheAttributes;
> ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
>
> ASSERT (VirtualMemoryMap != NULL);
> @@ -65,17 +60,11 @@ ArmPlatformGetVirtualMemoryMap (
> return;
> }
>
> - if (FeaturePcdGet (PcdCacheEnable) == TRUE) {
> - CacheAttributes = DDR_ATTRIBUTES_CACHED;
> - } else {
> - CacheAttributes = DDR_ATTRIBUTES_UNCACHED;
> - }
> -
> // System DRAM
> VirtualMemoryTable[0].PhysicalBase = PcdGet64 (PcdSystemMemoryBase);
> VirtualMemoryTable[0].VirtualBase = VirtualMemoryTable[0].PhysicalBase;
> VirtualMemoryTable[0].Length = PcdGet64 (PcdSystemMemorySize);
> - VirtualMemoryTable[0].Attributes = CacheAttributes;
> + VirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
>
> DEBUG ((EFI_D_INFO, "%a: Dumping System DRAM Memory Map:\n"
> "\tPhysicalBase: 0x%lX\n"
> @@ -104,7 +93,7 @@ ArmPlatformGetVirtualMemoryMap (
> VirtualMemoryTable[3].PhysicalBase = FixedPcdGet64 (PcdFdBaseAddress);
> VirtualMemoryTable[3].VirtualBase = VirtualMemoryTable[3].PhysicalBase;
> VirtualMemoryTable[3].Length = FixedPcdGet32 (PcdFdSize);
> - VirtualMemoryTable[3].Attributes = CacheAttributes;
> + VirtualMemoryTable[3].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
>
> // End of Table
> ZeroMem (&VirtualMemoryTable[4], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));
>
Looks OK.
I see that PcdCacheEnable is removed from -- or, well, "with" -- all the
affected INF files in the last patch. I also see that the EmbeddedPkg
default for the PCD is FALSE. So it likely makes sense to keep our TRUE
default in "ArmVirt.dsc.inc", for any other (external) modules that
depend on the PCD.
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 10/15] ArmVirtPkg: introduce ArmVirtMemInfoLib library class
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
` (8 preceding siblings ...)
2017-11-17 16:09 ` [PATCH 09/15] ArmVirtPkg/ArmVirtPlatformLib: remove support for uncached mappings Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 16:23 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 11/15] ArmVirtPkg/ArmVirtXen: add ArmVirtMemInfoLib implementation Ard Biesheuvel
` (4 subsequent siblings)
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
As part of the effort to get rid of ArmPlatformLib (which incorporates
far too many duties in a single library), introduce ArmVirtMemInfoLib
which will be invoked by our ArmVirtMemoryInitPeiLib implementation to
get a description of the virtual address space. This will allow us to
remove this functionality from ArmPlatformLib later, or, in the case of
ArmVirtXen and ArmVirtQemuKernel, drop ArmPlatformLib altogether.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/ArmVirtPkg.dec | 3 ++
ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h | 39 ++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
index a8603e1b80e5..8f656fd2739d 100644
--- a/ArmVirtPkg/ArmVirtPkg.dec
+++ b/ArmVirtPkg/ArmVirtPkg.dec
@@ -30,6 +30,9 @@ [Defines]
[Includes.common]
Include # Root include for the package
+[LibraryClasses]
+ ArmVirtMemInfoLib|Include/Library/ArmVirtMemInfoLib.h
+
[Guids.common]
gArmVirtTokenSpaceGuid = { 0x0B6F5CA7, 0x4F53, 0x445A, { 0xB7, 0x6E, 0x2E, 0x36, 0x5B, 0x80, 0x63, 0x66 } }
gEarlyPL011BaseAddressGuid = { 0xB199DEA9, 0xFD5C, 0x4A84, { 0x80, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } }
diff --git a/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
new file mode 100644
index 000000000000..65be2cbd8082
--- /dev/null
+++ b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
@@ -0,0 +1,39 @@
+/** @file
+
+ Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. All rights reserved.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _ARM_VIRT_MEMINFO_LIB_H_
+#define _ARM_VIRT_MEMINFO_LIB_H_
+
+#include <Base.h>
+#include <Library/ArmLib.h>
+
+/**
+ Return the Virtual Memory Map of your platform
+
+ This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
+ on your platform.
+
+ @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
+ describing a Physical-to-Virtual Memory
+ mapping. This array must be ended by a
+ zero-filled entry
+
+**/
+VOID
+ArmVirtGetMemoryMap (
+ OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
+ );
+
+#endif
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 10/15] ArmVirtPkg: introduce ArmVirtMemInfoLib library class
2017-11-17 16:09 ` [PATCH 10/15] ArmVirtPkg: introduce ArmVirtMemInfoLib library class Ard Biesheuvel
@ 2017-11-21 16:23 ` Laszlo Ersek
2017-11-21 16:27 ` Laszlo Ersek
0 siblings, 1 reply; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 16:23 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> As part of the effort to get rid of ArmPlatformLib (which incorporates
> far too many duties in a single library), introduce ArmVirtMemInfoLib
> which will be invoked by our ArmVirtMemoryInitPeiLib implementation to
> get a description of the virtual address space. This will allow us to
> remove this functionality from ArmPlatformLib later, or, in the case of
> ArmVirtXen and ArmVirtQemuKernel, drop ArmPlatformLib altogether.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/ArmVirtPkg.dec | 3 ++
> ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h | 39 ++++++++++++++++++++
> 2 files changed, 42 insertions(+)
>
> diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
> index a8603e1b80e5..8f656fd2739d 100644
> --- a/ArmVirtPkg/ArmVirtPkg.dec
> +++ b/ArmVirtPkg/ArmVirtPkg.dec
> @@ -30,6 +30,9 @@ [Defines]
> [Includes.common]
> Include # Root include for the package
>
> +[LibraryClasses]
> + ArmVirtMemInfoLib|Include/Library/ArmVirtMemInfoLib.h
> +
> [Guids.common]
> gArmVirtTokenSpaceGuid = { 0x0B6F5CA7, 0x4F53, 0x445A, { 0xB7, 0x6E, 0x2E, 0x36, 0x5B, 0x80, 0x63, 0x66 } }
> gEarlyPL011BaseAddressGuid = { 0xB199DEA9, 0xFD5C, 0x4A84, { 0x80, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } }
> diff --git a/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
> new file mode 100644
> index 000000000000..65be2cbd8082
> --- /dev/null
> +++ b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
> @@ -0,0 +1,39 @@
> +/** @file
> +
> + Copyright (c) 2011-2013, ARM Limited. All rights reserved.
> + Copyright (c) 2017, Linaro, Ltd. All rights reserved.
> +
> + This program and the accompanying materials are licensed and made available
> + under the terms and conditions of the BSD License which accompanies this
> + distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef _ARM_VIRT_MEMINFO_LIB_H_
> +#define _ARM_VIRT_MEMINFO_LIB_H_
> +
> +#include <Base.h>
> +#include <Library/ArmLib.h>
> +
> +/**
> + Return the Virtual Memory Map of your platform
> +
> + This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
> + on your platform.
> +
> + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
> + describing a Physical-to-Virtual Memory
> + mapping. This array must be ended by a
> + zero-filled entry
> +
> +**/
> +VOID
> +ArmVirtGetMemoryMap (
> + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
> + );
> +
> +#endif
>
(1) Since this is a library API, please add EFIAPI to the declaration.
(This will affect the instance(s) too.)
(2) If it's not overly restrictive, then please mention in the
"VirtualMemoryMap" param comment that the map is supposed to be
allocated dynamically within the function, using the phase-matching
MemoryAllocationLib instance.
(Judged from the AllocatePages() call in
"ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/QemuVirtMem.c".)
With those addressed,
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Thanks
Laszlo
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 10/15] ArmVirtPkg: introduce ArmVirtMemInfoLib library class
2017-11-21 16:23 ` Laszlo Ersek
@ 2017-11-21 16:27 ` Laszlo Ersek
2017-11-21 16:32 ` Ard Biesheuvel
0 siblings, 1 reply; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 16:27 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/21/17 17:23, Laszlo Ersek wrote:
> On 11/17/17 17:09, Ard Biesheuvel wrote:
>> As part of the effort to get rid of ArmPlatformLib (which incorporates
>> far too many duties in a single library), introduce ArmVirtMemInfoLib
>> which will be invoked by our ArmVirtMemoryInitPeiLib implementation to
>> get a description of the virtual address space. This will allow us to
>> remove this functionality from ArmPlatformLib later, or, in the case of
>> ArmVirtXen and ArmVirtQemuKernel, drop ArmPlatformLib altogether.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>> ArmVirtPkg/ArmVirtPkg.dec | 3 ++
>> ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h | 39 ++++++++++++++++++++
>> 2 files changed, 42 insertions(+)
>>
>> diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
>> index a8603e1b80e5..8f656fd2739d 100644
>> --- a/ArmVirtPkg/ArmVirtPkg.dec
>> +++ b/ArmVirtPkg/ArmVirtPkg.dec
>> @@ -30,6 +30,9 @@ [Defines]
>> [Includes.common]
>> Include # Root include for the package
>>
>> +[LibraryClasses]
>> + ArmVirtMemInfoLib|Include/Library/ArmVirtMemInfoLib.h
>> +
>> [Guids.common]
>> gArmVirtTokenSpaceGuid = { 0x0B6F5CA7, 0x4F53, 0x445A, { 0xB7, 0x6E, 0x2E, 0x36, 0x5B, 0x80, 0x63, 0x66 } }
>> gEarlyPL011BaseAddressGuid = { 0xB199DEA9, 0xFD5C, 0x4A84, { 0x80, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } }
>> diff --git a/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
>> new file mode 100644
>> index 000000000000..65be2cbd8082
>> --- /dev/null
>> +++ b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
>> @@ -0,0 +1,39 @@
>> +/** @file
>> +
>> + Copyright (c) 2011-2013, ARM Limited. All rights reserved.
>> + Copyright (c) 2017, Linaro, Ltd. All rights reserved.
>> +
>> + This program and the accompanying materials are licensed and made available
>> + under the terms and conditions of the BSD License which accompanies this
>> + distribution. The full text of the license may be found at
>> + http://opensource.org/licenses/bsd-license.php
>> +
>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>> +
>> +**/
>> +
>> +#ifndef _ARM_VIRT_MEMINFO_LIB_H_
>> +#define _ARM_VIRT_MEMINFO_LIB_H_
>> +
>> +#include <Base.h>
>> +#include <Library/ArmLib.h>
>> +
>> +/**
>> + Return the Virtual Memory Map of your platform
>> +
>> + This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
>> + on your platform.
>> +
>> + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
>> + describing a Physical-to-Virtual Memory
>> + mapping. This array must be ended by a
>> + zero-filled entry
>> +
>> +**/
>> +VOID
>> +ArmVirtGetMemoryMap (
>> + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
>> + );
>> +
>> +#endif
>>
>
> (1) Since this is a library API, please add EFIAPI to the declaration.
>
> (This will affect the instance(s) too.)
>
>
> (2) If it's not overly restrictive, then please mention in the
> "VirtualMemoryMap" param comment that the map is supposed to be
> allocated dynamically within the function, using the phase-matching
> MemoryAllocationLib instance.
>
> (Judged from the AllocatePages() call in
> "ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/QemuVirtMem.c".)
Looking at the patch right after this one, dynamic memory allocation
appears wrong to spell out in the library interface.
Then I guess the right thing to say would be, "the returned array is
never supposed to be freed; it is released at the latest when the OS
takes control".
> With those addressed,
>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
My R-b stands, just please clarify the expected lifetime of the array
returned, one way or another.
Thanks
Laszlo
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 10/15] ArmVirtPkg: introduce ArmVirtMemInfoLib library class
2017-11-21 16:27 ` Laszlo Ersek
@ 2017-11-21 16:32 ` Ard Biesheuvel
0 siblings, 0 replies; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-21 16:32 UTC (permalink / raw)
To: Laszlo Ersek; +Cc: edk2-devel@lists.01.org, Leif Lindholm
On 21 November 2017 at 16:27, Laszlo Ersek <lersek@redhat.com> wrote:
> On 11/21/17 17:23, Laszlo Ersek wrote:
>> On 11/17/17 17:09, Ard Biesheuvel wrote:
>>> As part of the effort to get rid of ArmPlatformLib (which incorporates
>>> far too many duties in a single library), introduce ArmVirtMemInfoLib
>>> which will be invoked by our ArmVirtMemoryInitPeiLib implementation to
>>> get a description of the virtual address space. This will allow us to
>>> remove this functionality from ArmPlatformLib later, or, in the case of
>>> ArmVirtXen and ArmVirtQemuKernel, drop ArmPlatformLib altogether.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>>> ---
>>> ArmVirtPkg/ArmVirtPkg.dec | 3 ++
>>> ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h | 39 ++++++++++++++++++++
>>> 2 files changed, 42 insertions(+)
>>>
>>> diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
>>> index a8603e1b80e5..8f656fd2739d 100644
>>> --- a/ArmVirtPkg/ArmVirtPkg.dec
>>> +++ b/ArmVirtPkg/ArmVirtPkg.dec
>>> @@ -30,6 +30,9 @@ [Defines]
>>> [Includes.common]
>>> Include # Root include for the package
>>>
>>> +[LibraryClasses]
>>> + ArmVirtMemInfoLib|Include/Library/ArmVirtMemInfoLib.h
>>> +
>>> [Guids.common]
>>> gArmVirtTokenSpaceGuid = { 0x0B6F5CA7, 0x4F53, 0x445A, { 0xB7, 0x6E, 0x2E, 0x36, 0x5B, 0x80, 0x63, 0x66 } }
>>> gEarlyPL011BaseAddressGuid = { 0xB199DEA9, 0xFD5C, 0x4A84, { 0x80, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } }
>>> diff --git a/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
>>> new file mode 100644
>>> index 000000000000..65be2cbd8082
>>> --- /dev/null
>>> +++ b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
>>> @@ -0,0 +1,39 @@
>>> +/** @file
>>> +
>>> + Copyright (c) 2011-2013, ARM Limited. All rights reserved.
>>> + Copyright (c) 2017, Linaro, Ltd. All rights reserved.
>>> +
>>> + This program and the accompanying materials are licensed and made available
>>> + under the terms and conditions of the BSD License which accompanies this
>>> + distribution. The full text of the license may be found at
>>> + http://opensource.org/licenses/bsd-license.php
>>> +
>>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>>> +
>>> +**/
>>> +
>>> +#ifndef _ARM_VIRT_MEMINFO_LIB_H_
>>> +#define _ARM_VIRT_MEMINFO_LIB_H_
>>> +
>>> +#include <Base.h>
>>> +#include <Library/ArmLib.h>
>>> +
>>> +/**
>>> + Return the Virtual Memory Map of your platform
>>> +
>>> + This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
>>> + on your platform.
>>> +
>>> + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
>>> + describing a Physical-to-Virtual Memory
>>> + mapping. This array must be ended by a
>>> + zero-filled entry
>>> +
>>> +**/
>>> +VOID
>>> +ArmVirtGetMemoryMap (
>>> + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
>>> + );
>>> +
>>> +#endif
>>>
>>
>> (1) Since this is a library API, please add EFIAPI to the declaration.
>>
>> (This will affect the instance(s) too.)
>>
>>
>> (2) If it's not overly restrictive, then please mention in the
>> "VirtualMemoryMap" param comment that the map is supposed to be
>> allocated dynamically within the function, using the phase-matching
>> MemoryAllocationLib instance.
>>
>> (Judged from the AllocatePages() call in
>> "ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/QemuVirtMem.c".)
>
> Looking at the patch right after this one, dynamic memory allocation
> appears wrong to spell out in the library interface.
>
> Then I guess the right thing to say would be, "the returned array is
> never supposed to be freed; it is released at the latest when the OS
> takes control".
>
>> With those addressed,
>>
>> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
>
> My R-b stands, just please clarify the expected lifetime of the array
> returned, one way or another.
>
Thanks. Simply not freeing it is the current practice everywhere,
given that PrePi and PEI MemoryAllocationLib implementations don't do
FreePages() in the first place. But I agree it should be mentioned
explicitly.
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 11/15] ArmVirtPkg/ArmVirtXen: add ArmVirtMemInfoLib implementation
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
` (9 preceding siblings ...)
2017-11-17 16:09 ` [PATCH 10/15] ArmVirtPkg: introduce ArmVirtMemInfoLib library class Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 16:30 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 12/15] ArmVirtPkg/ArmVirtQemu: " Ard Biesheuvel
` (3 subsequent siblings)
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
Clone the existing ArmPlatformGetVirtualMemoryMap () for this platform,
clean it up slightly (by using a static buffer rather than a heap
allocation, and removing the support for uncached DRAM mappings), and
turn it into a new ArmVirtMemInfoLib implementation.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/ArmVirtXen.dsc | 1 +
ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S | 39 +++++++++++++
ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S | 24 ++++++++
ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c | 61 ++++++++++++++++++++
ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf | 41 +++++++++++++
5 files changed, 166 insertions(+)
diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
index 7a443483d1ac..3df684d13cb0 100644
--- a/ArmVirtPkg/ArmVirtXen.dsc
+++ b/ArmVirtPkg/ArmVirtXen.dsc
@@ -44,6 +44,7 @@ [LibraryClasses]
VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
ArmPlatformLib|ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ArmXenRelocatablePlatformLib.inf
+ ArmVirtMemInfoLib|ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S b/ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S
new file mode 100644
index 000000000000..a1f6a194d59b
--- /dev/null
+++ b/ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+# Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+
+#include <AsmMacroIoLibV8.h>
+
+//EFI_PHYSICAL_ADDRESS
+//GetPhysAddrTop (
+// VOID
+// );
+ASM_FUNC(ArmGetPhysAddrTop)
+ mrs x0, id_aa64mmfr0_el1
+ adr x1, .LPARanges
+ and x0, x0, #7
+ ldrb w1, [x1, x0]
+ mov x0, #1
+ lsl x0, x0, x1
+ ret
+
+//
+// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
+// physical address space support on this CPU:
+// 0 == 32 bits, 1 == 36 bits, etc etc
+// 6 and 7 are reserved
+//
+.LPARanges:
+ .byte 32, 36, 40, 42, 44, 48, -1, -1
+
+ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S b/ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S
new file mode 100644
index 000000000000..9cd81529fb3d
--- /dev/null
+++ b/ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+
+#include <AsmMacroIoLib.h>
+
+//EFI_PHYSICAL_ADDRESS
+//GetPhysAddrTop (
+// VOID
+// );
+ASM_FUNC(ArmGetPhysAddrTop)
+ mov r0, #0x00000000
+ mov r1, #0x10000
+ bx lr
diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c
new file mode 100644
index 000000000000..cc806b474560
--- /dev/null
+++ b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c
@@ -0,0 +1,61 @@
+/** @file
+
+ Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Base.h>
+#include <Library/ArmLib.h>
+#include <Library/DebugLib.h>
+
+STATIC ARM_MEMORY_REGION_DESCRIPTOR mVirtualMemoryTable[2];
+
+EFI_PHYSICAL_ADDRESS
+ArmGetPhysAddrTop (
+ VOID
+ );
+
+/**
+ Return the Virtual Memory Map of your platform
+
+ This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
+ on your platform.
+
+ @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
+ describing a Physical-to-Virtual Memory
+ mapping. This array must be ended by a
+ zero-filled entry
+
+**/
+VOID
+ArmVirtGetMemoryMap (
+ OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
+ )
+{
+ ASSERT (VirtualMemoryMap != NULL);
+
+ //
+ // Map the entire physical memory space as cached. The only device
+ // we care about is the GIC, which will be stage 2 mapped as a device
+ // by the hypervisor, overriding the cached mapping we install here.
+ //
+ mVirtualMemoryTable[0].PhysicalBase = 0x0;
+ mVirtualMemoryTable[0].VirtualBase = 0x0;
+ mVirtualMemoryTable[0].Length = ArmGetPhysAddrTop ();
+ mVirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
+
+ mVirtualMemoryTable[1].PhysicalBase = 0x0;
+ mVirtualMemoryTable[1].VirtualBase = 0x0;
+ mVirtualMemoryTable[1].Length = 0x0;
+ mVirtualMemoryTable[1].Attributes = 0x0;
+
+ *VirtualMemoryMap = mVirtualMemoryTable;
+}
diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf
new file mode 100644
index 000000000000..cd4c805a4db9
--- /dev/null
+++ b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf
@@ -0,0 +1,41 @@
+#/* @file
+#
+# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
+# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
+#
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License which accompanies this
+# distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#*/
+
+[Defines]
+ INF_VERSION = 0x0001001A
+ BASE_NAME = XenVirtMemInfoLib
+ FILE_GUID = 40d1f8f5-4dfe-4e0f-9a15-b1de9dc9f4ed
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ArmVirtMemInfoLib
+
+[Sources]
+ XenVirtMemInfoLib.c
+
+[Sources.ARM]
+ Arm/PhysAddrTop.S
+
+[Sources.AARCH64]
+ AArch64/PhysAddrTop.S
+
+[Packages]
+ ArmPkg/ArmPkg.dec
+ ArmVirtPkg/ArmVirtPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ ArmLib
+ DebugLib
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 11/15] ArmVirtPkg/ArmVirtXen: add ArmVirtMemInfoLib implementation
2017-11-17 16:09 ` [PATCH 11/15] ArmVirtPkg/ArmVirtXen: add ArmVirtMemInfoLib implementation Ard Biesheuvel
@ 2017-11-21 16:30 ` Laszlo Ersek
0 siblings, 0 replies; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 16:30 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel, leif.lindholm, Julien Grall
On 11/17/17 17:09, Ard Biesheuvel wrote:
> Clone the existing ArmPlatformGetVirtualMemoryMap () for this platform,
> clean it up slightly (by using a static buffer rather than a heap
> allocation, and removing the support for uncached DRAM mappings), and
> turn it into a new ArmVirtMemInfoLib implementation.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/ArmVirtXen.dsc | 1 +
> ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S | 39 +++++++++++++
> ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S | 24 ++++++++
> ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c | 61 ++++++++++++++++++++
> ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf | 41 +++++++++++++
> 5 files changed, 166 insertions(+)
Based on the diffstat, I'm happy to ACK this quickly:
Acked-by: Laszlo Ersek <lersek@redhat.com>
I'm adding Julien to the CC list (see commit f724f9d9c72a,
"Maintainers.txt: add Xen reviewer for ArmVirtPkg", 2017-09-22), in case
he wants to comment.
Thanks
Laszlo
>
> diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
> index 7a443483d1ac..3df684d13cb0 100644
> --- a/ArmVirtPkg/ArmVirtXen.dsc
> +++ b/ArmVirtPkg/ArmVirtXen.dsc
> @@ -44,6 +44,7 @@ [LibraryClasses]
> VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
>
> ArmPlatformLib|ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ArmXenRelocatablePlatformLib.inf
> + ArmVirtMemInfoLib|ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf
>
> TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
>
> diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S b/ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S
> new file mode 100644
> index 000000000000..a1f6a194d59b
> --- /dev/null
> +++ b/ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S
> @@ -0,0 +1,39 @@
> +#
> +# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
> +# Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#
> +
> +#include <AsmMacroIoLibV8.h>
> +
> +//EFI_PHYSICAL_ADDRESS
> +//GetPhysAddrTop (
> +// VOID
> +// );
> +ASM_FUNC(ArmGetPhysAddrTop)
> + mrs x0, id_aa64mmfr0_el1
> + adr x1, .LPARanges
> + and x0, x0, #7
> + ldrb w1, [x1, x0]
> + mov x0, #1
> + lsl x0, x0, x1
> + ret
> +
> +//
> +// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
> +// physical address space support on this CPU:
> +// 0 == 32 bits, 1 == 36 bits, etc etc
> +// 6 and 7 are reserved
> +//
> +.LPARanges:
> + .byte 32, 36, 40, 42, 44, 48, -1, -1
> +
> +ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S b/ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S
> new file mode 100644
> index 000000000000..9cd81529fb3d
> --- /dev/null
> +++ b/ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S
> @@ -0,0 +1,24 @@
> +#
> +# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
> +# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#
> +
> +#include <AsmMacroIoLib.h>
> +
> +//EFI_PHYSICAL_ADDRESS
> +//GetPhysAddrTop (
> +// VOID
> +// );
> +ASM_FUNC(ArmGetPhysAddrTop)
> + mov r0, #0x00000000
> + mov r1, #0x10000
> + bx lr
> diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c
> new file mode 100644
> index 000000000000..cc806b474560
> --- /dev/null
> +++ b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c
> @@ -0,0 +1,61 @@
> +/** @file
> +
> + Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
> +
> + This program and the accompanying materials are licensed and made available
> + under the terms and conditions of the BSD License which accompanies this
> + distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <Base.h>
> +#include <Library/ArmLib.h>
> +#include <Library/DebugLib.h>
> +
> +STATIC ARM_MEMORY_REGION_DESCRIPTOR mVirtualMemoryTable[2];
> +
> +EFI_PHYSICAL_ADDRESS
> +ArmGetPhysAddrTop (
> + VOID
> + );
> +
> +/**
> + Return the Virtual Memory Map of your platform
> +
> + This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
> + on your platform.
> +
> + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
> + describing a Physical-to-Virtual Memory
> + mapping. This array must be ended by a
> + zero-filled entry
> +
> +**/
> +VOID
> +ArmVirtGetMemoryMap (
> + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
> + )
> +{
> + ASSERT (VirtualMemoryMap != NULL);
> +
> + //
> + // Map the entire physical memory space as cached. The only device
> + // we care about is the GIC, which will be stage 2 mapped as a device
> + // by the hypervisor, overriding the cached mapping we install here.
> + //
> + mVirtualMemoryTable[0].PhysicalBase = 0x0;
> + mVirtualMemoryTable[0].VirtualBase = 0x0;
> + mVirtualMemoryTable[0].Length = ArmGetPhysAddrTop ();
> + mVirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
> +
> + mVirtualMemoryTable[1].PhysicalBase = 0x0;
> + mVirtualMemoryTable[1].VirtualBase = 0x0;
> + mVirtualMemoryTable[1].Length = 0x0;
> + mVirtualMemoryTable[1].Attributes = 0x0;
> +
> + *VirtualMemoryMap = mVirtualMemoryTable;
> +}
> diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf
> new file mode 100644
> index 000000000000..cd4c805a4db9
> --- /dev/null
> +++ b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf
> @@ -0,0 +1,41 @@
> +#/* @file
> +#
> +# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
> +# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
> +#
> +# This program and the accompanying materials are licensed and made available
> +# under the terms and conditions of the BSD License which accompanies this
> +# distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#*/
> +
> +[Defines]
> + INF_VERSION = 0x0001001A
> + BASE_NAME = XenVirtMemInfoLib
> + FILE_GUID = 40d1f8f5-4dfe-4e0f-9a15-b1de9dc9f4ed
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = ArmVirtMemInfoLib
> +
> +[Sources]
> + XenVirtMemInfoLib.c
> +
> +[Sources.ARM]
> + Arm/PhysAddrTop.S
> +
> +[Sources.AARCH64]
> + AArch64/PhysAddrTop.S
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + ArmVirtPkg/ArmVirtPkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> + ArmLib
> + DebugLib
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 12/15] ArmVirtPkg/ArmVirtQemu: add ArmVirtMemInfoLib implementation
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
` (10 preceding siblings ...)
2017-11-17 16:09 ` [PATCH 11/15] ArmVirtPkg/ArmVirtXen: add ArmVirtMemInfoLib implementation Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 16:47 ` Ard Biesheuvel
2017-11-21 16:56 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 13/15] ArmVirtPkg: implement ArmVirtMemInfo PPI, PEIM and library Ard Biesheuvel
` (2 subsequent siblings)
14 siblings, 2 replies; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
Clone the existing ArmPlatformGetVirtualMemoryMap () for this platform,
clean it up slightly (by removing the support for uncached DRAM mappings),
and turn it into a new ArmVirtMemInfoLib implementation.
In a future patch, we will add this library to the ordinary ArmVirtQemu
platform as well.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 +
ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S | 39 ++++++++
ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S | 24 +++++
ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c | 101 ++++++++++++++++++++
ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf | 53 ++++++++++
5 files changed, 218 insertions(+)
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index 7e5d584344b4..f50d30388cf2 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -49,6 +49,7 @@ [LibraryClasses.common]
QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf
ArmPlatformLib|ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ArmQemuRelocatablePlatformLib.inf
+ ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S b/ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S
new file mode 100644
index 000000000000..a1f6a194d59b
--- /dev/null
+++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+# Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+
+#include <AsmMacroIoLibV8.h>
+
+//EFI_PHYSICAL_ADDRESS
+//GetPhysAddrTop (
+// VOID
+// );
+ASM_FUNC(ArmGetPhysAddrTop)
+ mrs x0, id_aa64mmfr0_el1
+ adr x1, .LPARanges
+ and x0, x0, #7
+ ldrb w1, [x1, x0]
+ mov x0, #1
+ lsl x0, x0, x1
+ ret
+
+//
+// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
+// physical address space support on this CPU:
+// 0 == 32 bits, 1 == 36 bits, etc etc
+// 6 and 7 are reserved
+//
+.LPARanges:
+ .byte 32, 36, 40, 42, 44, 48, -1, -1
+
+ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S b/ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S
new file mode 100644
index 000000000000..9cd81529fb3d
--- /dev/null
+++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+
+#include <AsmMacroIoLib.h>
+
+//EFI_PHYSICAL_ADDRESS
+//GetPhysAddrTop (
+// VOID
+// );
+ASM_FUNC(ArmGetPhysAddrTop)
+ mov r0, #0x00000000
+ mov r1, #0x10000
+ bx lr
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
new file mode 100644
index 000000000000..b08305fe4a4f
--- /dev/null
+++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
@@ -0,0 +1,101 @@
+/** @file
+
+ Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Base.h>
+#include <Library/ArmLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+// Number of Virtual Memory Map Descriptors
+#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
+
+EFI_PHYSICAL_ADDRESS
+ArmGetPhysAddrTop (
+ VOID
+ );
+
+/**
+ Return the Virtual Memory Map of your platform
+
+ This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
+ on your platform.
+
+ @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
+ describing a Physical-to-Virtual Memory
+ mapping. This array must be ended by a
+ zero-filled entry
+
+**/
+VOID
+ArmVirtGetMemoryMap (
+ OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
+ )
+{
+ ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
+ UINT64 TopOfMemory;
+ UINTN TableSize;
+
+ ASSERT (VirtualMemoryMap != NULL);
+
+ TableSize = sizeof (ARM_MEMORY_REGION_DESCRIPTOR) *
+ MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS;
+ VirtualMemoryTable = AllocatePages (EFI_SIZE_TO_PAGES (TableSize));
+
+ if (VirtualMemoryTable == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: Error: Failed AllocatePages()\n", __FUNCTION__));
+ return;
+ }
+
+ // System DRAM
+ VirtualMemoryTable[0].PhysicalBase = PcdGet64 (PcdSystemMemoryBase);
+ VirtualMemoryTable[0].VirtualBase = VirtualMemoryTable[0].PhysicalBase;
+ VirtualMemoryTable[0].Length = PcdGet64 (PcdSystemMemorySize);
+ VirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
+
+ DEBUG ((DEBUG_INFO, "%a: Dumping System DRAM Memory Map:\n"
+ "\tPhysicalBase: 0x%lX\n"
+ "\tVirtualBase: 0x%lX\n"
+ "\tLength: 0x%lX\n",
+ __FUNCTION__,
+ VirtualMemoryTable[0].PhysicalBase,
+ VirtualMemoryTable[0].VirtualBase,
+ VirtualMemoryTable[0].Length));
+
+ // Peripheral space before DRAM
+ VirtualMemoryTable[1].PhysicalBase = 0x0;
+ VirtualMemoryTable[1].VirtualBase = 0x0;
+ VirtualMemoryTable[1].Length = VirtualMemoryTable[0].PhysicalBase;
+ VirtualMemoryTable[1].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
+
+ // Peripheral space after DRAM
+ TopOfMemory = MIN (1ULL << FixedPcdGet8 (PcdPrePiCpuMemorySize),
+ ArmGetPhysAddrTop ());
+ VirtualMemoryTable[2].PhysicalBase = VirtualMemoryTable[0].Length + VirtualMemoryTable[1].Length;
+ VirtualMemoryTable[2].VirtualBase = VirtualMemoryTable[2].PhysicalBase;
+ VirtualMemoryTable[2].Length = TopOfMemory -
+ VirtualMemoryTable[2].PhysicalBase;
+ VirtualMemoryTable[2].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
+
+ // Remap the FD region as normal executable memory
+ VirtualMemoryTable[3].PhysicalBase = PcdGet64 (PcdFdBaseAddress);
+ VirtualMemoryTable[3].VirtualBase = VirtualMemoryTable[3].PhysicalBase;
+ VirtualMemoryTable[3].Length = FixedPcdGet32 (PcdFdSize);
+ VirtualMemoryTable[3].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
+
+ // End of Table
+ ZeroMem (&VirtualMemoryTable[4], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));
+
+ *VirtualMemoryMap = VirtualMemoryTable;
+}
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
new file mode 100644
index 000000000000..8f6ba006fdfd
--- /dev/null
+++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
@@ -0,0 +1,53 @@
+#/* @file
+#
+# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
+# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
+#
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License which accompanies this
+# distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#*/
+
+[Defines]
+ INF_VERSION = 0x0001001A
+ BASE_NAME = QemuVirtMemInfoLib
+ FILE_GUID = 9b30ca82-6746-4a82-a3e6-11ea79df3b46
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ArmVirtMemInfoLib
+
+[Sources]
+ QemuVirtMemInfoLib.c
+
+[Sources.ARM]
+ Arm/PhysAddrTop.S
+
+[Sources.AARCH64]
+ AArch64/PhysAddrTop.S
+
+[Packages]
+ ArmPkg/ArmPkg.dec
+ ArmVirtPkg/ArmVirtPkg.dec
+ EmbeddedPkg/EmbeddedPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ ArmLib
+ BaseMemoryLib
+ DebugLib
+ MemoryAllocationLib
+
+[Pcd]
+ gArmTokenSpaceGuid.PcdFdBaseAddress
+ gArmTokenSpaceGuid.PcdSystemMemoryBase
+ gArmTokenSpaceGuid.PcdSystemMemorySize
+
+[FixedPcd]
+ gArmTokenSpaceGuid.PcdFdSize
+ gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 12/15] ArmVirtPkg/ArmVirtQemu: add ArmVirtMemInfoLib implementation
2017-11-17 16:09 ` [PATCH 12/15] ArmVirtPkg/ArmVirtQemu: " Ard Biesheuvel
@ 2017-11-21 16:47 ` Ard Biesheuvel
2017-11-21 16:56 ` Laszlo Ersek
1 sibling, 0 replies; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-21 16:47 UTC (permalink / raw)
To: edk2-devel@lists.01.org, Laszlo Ersek; +Cc: Leif Lindholm, Ard Biesheuvel
On 17 November 2017 at 16:09, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> Clone the existing ArmPlatformGetVirtualMemoryMap () for this platform,
> clean it up slightly (by removing the support for uncached DRAM mappings),
> and turn it into a new ArmVirtMemInfoLib implementation.
>
> In a future patch, we will add this library to the ordinary ArmVirtQemu
> platform as well.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 +
> ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S | 39 ++++++++
> ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S | 24 +++++
> ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c | 101 ++++++++++++++++++++
> ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf | 53 ++++++++++
> 5 files changed, 218 insertions(+)
>
> diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
> index 7e5d584344b4..f50d30388cf2 100644
> --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
> +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
> @@ -49,6 +49,7 @@ [LibraryClasses.common]
> QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf
>
> ArmPlatformLib|ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ArmQemuRelocatablePlatformLib.inf
> + ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
>
> TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
> NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
> diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S b/ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S
> new file mode 100644
> index 000000000000..a1f6a194d59b
> --- /dev/null
> +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S
> @@ -0,0 +1,39 @@
> +#
> +# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
> +# Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#
> +
> +#include <AsmMacroIoLibV8.h>
> +
> +//EFI_PHYSICAL_ADDRESS
> +//GetPhysAddrTop (
> +// VOID
> +// );
> +ASM_FUNC(ArmGetPhysAddrTop)
> + mrs x0, id_aa64mmfr0_el1
> + adr x1, .LPARanges
> + and x0, x0, #7
> + ldrb w1, [x1, x0]
> + mov x0, #1
> + lsl x0, x0, x1
> + ret
> +
> +//
> +// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
> +// physical address space support on this CPU:
> +// 0 == 32 bits, 1 == 36 bits, etc etc
> +// 6 and 7 are reserved
> +//
> +.LPARanges:
> + .byte 32, 36, 40, 42, 44, 48, -1, -1
> +
> +ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S b/ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S
> new file mode 100644
> index 000000000000..9cd81529fb3d
> --- /dev/null
> +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S
> @@ -0,0 +1,24 @@
> +#
> +# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
> +# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#
> +
> +#include <AsmMacroIoLib.h>
> +
> +//EFI_PHYSICAL_ADDRESS
> +//GetPhysAddrTop (
> +// VOID
> +// );
> +ASM_FUNC(ArmGetPhysAddrTop)
> + mov r0, #0x00000000
> + mov r1, #0x10000
> + bx lr
> diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
> new file mode 100644
> index 000000000000..b08305fe4a4f
> --- /dev/null
> +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
> @@ -0,0 +1,101 @@
> +/** @file
> +
> + Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
> +
> + This program and the accompanying materials are licensed and made available
> + under the terms and conditions of the BSD License which accompanies this
> + distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <Base.h>
> +#include <Library/ArmLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +
> +// Number of Virtual Memory Map Descriptors
> +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
> +
> +EFI_PHYSICAL_ADDRESS
> +ArmGetPhysAddrTop (
> + VOID
> + );
> +
> +/**
> + Return the Virtual Memory Map of your platform
> +
> + This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
> + on your platform.
> +
> + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
> + describing a Physical-to-Virtual Memory
> + mapping. This array must be ended by a
> + zero-filled entry
> +
> +**/
> +VOID
> +ArmVirtGetMemoryMap (
> + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
> + )
> +{
> + ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
> + UINT64 TopOfMemory;
> + UINTN TableSize;
> +
> + ASSERT (VirtualMemoryMap != NULL);
> +
> + TableSize = sizeof (ARM_MEMORY_REGION_DESCRIPTOR) *
> + MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS;
> + VirtualMemoryTable = AllocatePages (EFI_SIZE_TO_PAGES (TableSize));
I should probably use AllocatePool here: given that it's only 160
bytes, and never freed.
> +
> + if (VirtualMemoryTable == NULL) {
> + DEBUG ((DEBUG_ERROR, "%a: Error: Failed AllocatePages()\n", __FUNCTION__));
> + return;
> + }
> +
> + // System DRAM
> + VirtualMemoryTable[0].PhysicalBase = PcdGet64 (PcdSystemMemoryBase);
> + VirtualMemoryTable[0].VirtualBase = VirtualMemoryTable[0].PhysicalBase;
> + VirtualMemoryTable[0].Length = PcdGet64 (PcdSystemMemorySize);
> + VirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
> +
> + DEBUG ((DEBUG_INFO, "%a: Dumping System DRAM Memory Map:\n"
> + "\tPhysicalBase: 0x%lX\n"
> + "\tVirtualBase: 0x%lX\n"
> + "\tLength: 0x%lX\n",
> + __FUNCTION__,
> + VirtualMemoryTable[0].PhysicalBase,
> + VirtualMemoryTable[0].VirtualBase,
> + VirtualMemoryTable[0].Length));
> +
> + // Peripheral space before DRAM
> + VirtualMemoryTable[1].PhysicalBase = 0x0;
> + VirtualMemoryTable[1].VirtualBase = 0x0;
> + VirtualMemoryTable[1].Length = VirtualMemoryTable[0].PhysicalBase;
> + VirtualMemoryTable[1].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> +
> + // Peripheral space after DRAM
> + TopOfMemory = MIN (1ULL << FixedPcdGet8 (PcdPrePiCpuMemorySize),
> + ArmGetPhysAddrTop ());
> + VirtualMemoryTable[2].PhysicalBase = VirtualMemoryTable[0].Length + VirtualMemoryTable[1].Length;
> + VirtualMemoryTable[2].VirtualBase = VirtualMemoryTable[2].PhysicalBase;
> + VirtualMemoryTable[2].Length = TopOfMemory -
> + VirtualMemoryTable[2].PhysicalBase;
> + VirtualMemoryTable[2].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> +
> + // Remap the FD region as normal executable memory
> + VirtualMemoryTable[3].PhysicalBase = PcdGet64 (PcdFdBaseAddress);
> + VirtualMemoryTable[3].VirtualBase = VirtualMemoryTable[3].PhysicalBase;
> + VirtualMemoryTable[3].Length = FixedPcdGet32 (PcdFdSize);
> + VirtualMemoryTable[3].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
> +
> + // End of Table
> + ZeroMem (&VirtualMemoryTable[4], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));
> +
> + *VirtualMemoryMap = VirtualMemoryTable;
> +}
> diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
> new file mode 100644
> index 000000000000..8f6ba006fdfd
> --- /dev/null
> +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
> @@ -0,0 +1,53 @@
> +#/* @file
> +#
> +# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
> +# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
> +#
> +# This program and the accompanying materials are licensed and made available
> +# under the terms and conditions of the BSD License which accompanies this
> +# distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#*/
> +
> +[Defines]
> + INF_VERSION = 0x0001001A
> + BASE_NAME = QemuVirtMemInfoLib
> + FILE_GUID = 9b30ca82-6746-4a82-a3e6-11ea79df3b46
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = ArmVirtMemInfoLib
> +
> +[Sources]
> + QemuVirtMemInfoLib.c
> +
> +[Sources.ARM]
> + Arm/PhysAddrTop.S
> +
> +[Sources.AARCH64]
> + AArch64/PhysAddrTop.S
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + ArmVirtPkg/ArmVirtPkg.dec
> + EmbeddedPkg/EmbeddedPkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> + ArmLib
> + BaseMemoryLib
> + DebugLib
> + MemoryAllocationLib
> +
> +[Pcd]
> + gArmTokenSpaceGuid.PcdFdBaseAddress
> + gArmTokenSpaceGuid.PcdSystemMemoryBase
> + gArmTokenSpaceGuid.PcdSystemMemorySize
> +
> +[FixedPcd]
> + gArmTokenSpaceGuid.PcdFdSize
> + gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 12/15] ArmVirtPkg/ArmVirtQemu: add ArmVirtMemInfoLib implementation
2017-11-17 16:09 ` [PATCH 12/15] ArmVirtPkg/ArmVirtQemu: " Ard Biesheuvel
2017-11-21 16:47 ` Ard Biesheuvel
@ 2017-11-21 16:56 ` Laszlo Ersek
2017-11-21 17:11 ` Ard Biesheuvel
1 sibling, 1 reply; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 16:56 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> Clone the existing ArmPlatformGetVirtualMemoryMap () for this platform,
> clean it up slightly (by removing the support for uncached DRAM mappings),
> and turn it into a new ArmVirtMemInfoLib implementation.
I've looked at this patch with "git show --find-copies-harder". It looks
OK, but the commit message could be improved:
(1) the support for uncached DRAM mappings is removed in the copy-origin
lib instance, in patch 09/15 ("ArmVirtPkg/ArmVirtPlatformLib: remove
support for uncached mappings"). I think this sentence should be dropped
from the commit message.
(2) There are other cleanups however:
- factor out TableSize and TopOfMemory
- replace EFI_D_* with DEBUG_*
- fetch PcdFdBaseAddress with PcdGet64(), not FixedPcdGet64(). (This is
matched by the [Pcd] / [FixedPcd] sections in the new INF file.)
Can you elaborate on the last item? I wonder if that change qualifies as
cleanup. (I'm fine if the change is justified by some other flexibility,
but it should be documented please.)
With the commit message updated:
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Thanks
Laszlo
>
> In a future patch, we will add this library to the ordinary ArmVirtQemu
> platform as well.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 +
> ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S | 39 ++++++++
> ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S | 24 +++++
> ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c | 101 ++++++++++++++++++++
> ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf | 53 ++++++++++
> 5 files changed, 218 insertions(+)
>
> diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
> index 7e5d584344b4..f50d30388cf2 100644
> --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
> +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
> @@ -49,6 +49,7 @@ [LibraryClasses.common]
> QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf
>
> ArmPlatformLib|ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ArmQemuRelocatablePlatformLib.inf
> + ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
>
> TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
> NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
> diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S b/ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S
> new file mode 100644
> index 000000000000..a1f6a194d59b
> --- /dev/null
> +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S
> @@ -0,0 +1,39 @@
> +#
> +# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
> +# Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#
> +
> +#include <AsmMacroIoLibV8.h>
> +
> +//EFI_PHYSICAL_ADDRESS
> +//GetPhysAddrTop (
> +// VOID
> +// );
> +ASM_FUNC(ArmGetPhysAddrTop)
> + mrs x0, id_aa64mmfr0_el1
> + adr x1, .LPARanges
> + and x0, x0, #7
> + ldrb w1, [x1, x0]
> + mov x0, #1
> + lsl x0, x0, x1
> + ret
> +
> +//
> +// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
> +// physical address space support on this CPU:
> +// 0 == 32 bits, 1 == 36 bits, etc etc
> +// 6 and 7 are reserved
> +//
> +.LPARanges:
> + .byte 32, 36, 40, 42, 44, 48, -1, -1
> +
> +ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S b/ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S
> new file mode 100644
> index 000000000000..9cd81529fb3d
> --- /dev/null
> +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S
> @@ -0,0 +1,24 @@
> +#
> +# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
> +# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#
> +
> +#include <AsmMacroIoLib.h>
> +
> +//EFI_PHYSICAL_ADDRESS
> +//GetPhysAddrTop (
> +// VOID
> +// );
> +ASM_FUNC(ArmGetPhysAddrTop)
> + mov r0, #0x00000000
> + mov r1, #0x10000
> + bx lr
> diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
> new file mode 100644
> index 000000000000..b08305fe4a4f
> --- /dev/null
> +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
> @@ -0,0 +1,101 @@
> +/** @file
> +
> + Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
> +
> + This program and the accompanying materials are licensed and made available
> + under the terms and conditions of the BSD License which accompanies this
> + distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <Base.h>
> +#include <Library/ArmLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +
> +// Number of Virtual Memory Map Descriptors
> +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
> +
> +EFI_PHYSICAL_ADDRESS
> +ArmGetPhysAddrTop (
> + VOID
> + );
> +
> +/**
> + Return the Virtual Memory Map of your platform
> +
> + This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
> + on your platform.
> +
> + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
> + describing a Physical-to-Virtual Memory
> + mapping. This array must be ended by a
> + zero-filled entry
> +
> +**/
> +VOID
> +ArmVirtGetMemoryMap (
> + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
> + )
> +{
> + ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
> + UINT64 TopOfMemory;
> + UINTN TableSize;
> +
> + ASSERT (VirtualMemoryMap != NULL);
> +
> + TableSize = sizeof (ARM_MEMORY_REGION_DESCRIPTOR) *
> + MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS;
> + VirtualMemoryTable = AllocatePages (EFI_SIZE_TO_PAGES (TableSize));
> +
> + if (VirtualMemoryTable == NULL) {
> + DEBUG ((DEBUG_ERROR, "%a: Error: Failed AllocatePages()\n", __FUNCTION__));
> + return;
> + }
> +
> + // System DRAM
> + VirtualMemoryTable[0].PhysicalBase = PcdGet64 (PcdSystemMemoryBase);
> + VirtualMemoryTable[0].VirtualBase = VirtualMemoryTable[0].PhysicalBase;
> + VirtualMemoryTable[0].Length = PcdGet64 (PcdSystemMemorySize);
> + VirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
> +
> + DEBUG ((DEBUG_INFO, "%a: Dumping System DRAM Memory Map:\n"
> + "\tPhysicalBase: 0x%lX\n"
> + "\tVirtualBase: 0x%lX\n"
> + "\tLength: 0x%lX\n",
> + __FUNCTION__,
> + VirtualMemoryTable[0].PhysicalBase,
> + VirtualMemoryTable[0].VirtualBase,
> + VirtualMemoryTable[0].Length));
> +
> + // Peripheral space before DRAM
> + VirtualMemoryTable[1].PhysicalBase = 0x0;
> + VirtualMemoryTable[1].VirtualBase = 0x0;
> + VirtualMemoryTable[1].Length = VirtualMemoryTable[0].PhysicalBase;
> + VirtualMemoryTable[1].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> +
> + // Peripheral space after DRAM
> + TopOfMemory = MIN (1ULL << FixedPcdGet8 (PcdPrePiCpuMemorySize),
> + ArmGetPhysAddrTop ());
> + VirtualMemoryTable[2].PhysicalBase = VirtualMemoryTable[0].Length + VirtualMemoryTable[1].Length;
> + VirtualMemoryTable[2].VirtualBase = VirtualMemoryTable[2].PhysicalBase;
> + VirtualMemoryTable[2].Length = TopOfMemory -
> + VirtualMemoryTable[2].PhysicalBase;
> + VirtualMemoryTable[2].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> +
> + // Remap the FD region as normal executable memory
> + VirtualMemoryTable[3].PhysicalBase = PcdGet64 (PcdFdBaseAddress);
> + VirtualMemoryTable[3].VirtualBase = VirtualMemoryTable[3].PhysicalBase;
> + VirtualMemoryTable[3].Length = FixedPcdGet32 (PcdFdSize);
> + VirtualMemoryTable[3].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
> +
> + // End of Table
> + ZeroMem (&VirtualMemoryTable[4], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));
> +
> + *VirtualMemoryMap = VirtualMemoryTable;
> +}
> diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
> new file mode 100644
> index 000000000000..8f6ba006fdfd
> --- /dev/null
> +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
> @@ -0,0 +1,53 @@
> +#/* @file
> +#
> +# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
> +# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
> +#
> +# This program and the accompanying materials are licensed and made available
> +# under the terms and conditions of the BSD License which accompanies this
> +# distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#*/
> +
> +[Defines]
> + INF_VERSION = 0x0001001A
> + BASE_NAME = QemuVirtMemInfoLib
> + FILE_GUID = 9b30ca82-6746-4a82-a3e6-11ea79df3b46
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = ArmVirtMemInfoLib
> +
> +[Sources]
> + QemuVirtMemInfoLib.c
> +
> +[Sources.ARM]
> + Arm/PhysAddrTop.S
> +
> +[Sources.AARCH64]
> + AArch64/PhysAddrTop.S
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + ArmVirtPkg/ArmVirtPkg.dec
> + EmbeddedPkg/EmbeddedPkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> + ArmLib
> + BaseMemoryLib
> + DebugLib
> + MemoryAllocationLib
> +
> +[Pcd]
> + gArmTokenSpaceGuid.PcdFdBaseAddress
> + gArmTokenSpaceGuid.PcdSystemMemoryBase
> + gArmTokenSpaceGuid.PcdSystemMemorySize
> +
> +[FixedPcd]
> + gArmTokenSpaceGuid.PcdFdSize
> + gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 12/15] ArmVirtPkg/ArmVirtQemu: add ArmVirtMemInfoLib implementation
2017-11-21 16:56 ` Laszlo Ersek
@ 2017-11-21 17:11 ` Ard Biesheuvel
0 siblings, 0 replies; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-21 17:11 UTC (permalink / raw)
To: Laszlo Ersek; +Cc: edk2-devel@lists.01.org, Leif Lindholm
On 21 November 2017 at 16:56, Laszlo Ersek <lersek@redhat.com> wrote:
> On 11/17/17 17:09, Ard Biesheuvel wrote:
>> Clone the existing ArmPlatformGetVirtualMemoryMap () for this platform,
>> clean it up slightly (by removing the support for uncached DRAM mappings),
>> and turn it into a new ArmVirtMemInfoLib implementation.
>
> I've looked at this patch with "git show --find-copies-harder". It looks
> OK, but the commit message could be improved:
>
> (1) the support for uncached DRAM mappings is removed in the copy-origin
> lib instance, in patch 09/15 ("ArmVirtPkg/ArmVirtPlatformLib: remove
> support for uncached mappings"). I think this sentence should be dropped
> from the commit message.
>
> (2) There are other cleanups however:
>
> - factor out TableSize and TopOfMemory
>
> - replace EFI_D_* with DEBUG_*
>
> - fetch PcdFdBaseAddress with PcdGet64(), not FixedPcdGet64(). (This is
> matched by the [Pcd] / [FixedPcd] sections in the new INF file.)
>
> Can you elaborate on the last item? I wonder if that change qualifies as
> cleanup. (I'm fine if the change is justified by some other flexibility,
> but it should be documented please.)
>
> With the commit message updated:
>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
>
Thanks. But is actually based on
ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib, which explains the
latter point.
However, given that we will be sharing it between ArmVirtQemu and
ArmVirtQemuKernel later on (which is apparently justified, since git
can't even tell them apart), it makes sense to elaborate a bit on the
differences and changes wrt the originals.
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 13/15] ArmVirtPkg: implement ArmVirtMemInfo PPI, PEIM and library
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
` (11 preceding siblings ...)
2017-11-17 16:09 ` [PATCH 12/15] ArmVirtPkg/ArmVirtQemu: " Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 17:49 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 14/15] ArmVirtPkg/ArmVirtMemoryInitPeiLib: move to ArmVirtMemInfoLib Ard Biesheuvel
2017-11-17 16:09 ` [PATCH 15/15] ArmVirtPkg: remove ArmPlatformLib implementations Ard Biesheuvel
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
Equivalent to the PrePi based platforms, this patch implements the
newly introduced ArmVirtMemInfo library class via a separate PEIM
and PPI.
The reason is that ArmVirtPlatformLib has populated the ArmPlatformLib
API function ArmPlatformInitializeSystemMemory () to retrieve memory
information from the DT, ensuring that it will be present when
MemoryPeim() is executed. This is a bit of a hack, and someting we
will need to get rid of if we want to reduce our dependency on
ArmPlatformLib altogether.
Putting this code in a ArmVirtMemInfo library constructor is problematic
as well, given that the implementation uses other libraries, among which
PcdLib, and so we need to find another way to run it before MemoryPeim()
So instead, create a separate PEIM that encapsulates the ArmVirtMemInfo
code and exposes it via a PPI. Another ArmVirtMemInfo library class
implementation is also provided that depexes on the PPI, which ensures
that the code is called in the correct order.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/ArmVirtPkg.dec | 3 +
ArmVirtPkg/Include/Ppi/ArmVirtMemInfo.h | 48 ++++++++
ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.c | 46 ++++++++
ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf | 42 +++++++
ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.c | 121 ++++++++++++++++++++
ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf | 60 ++++++++++
6 files changed, 320 insertions(+)
diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
index 8f656fd2739d..260849dc845c 100644
--- a/ArmVirtPkg/ArmVirtPkg.dec
+++ b/ArmVirtPkg/ArmVirtPkg.dec
@@ -39,6 +39,9 @@ [Guids.common]
gArmVirtVariableGuid = { 0x50bea1e5, 0xa2c5, 0x46e9, { 0x9b, 0x3a, 0x59, 0x59, 0x65, 0x16, 0xb0, 0x0a } }
+[Ppis]
+ gArmVirtMemInfoPpiGuid = { 0x3b060b72, 0x8696, 0x4393, { 0xa8, 0x93, 0x34, 0x25, 0x1e, 0x3f, 0x8a, 0x6b } }
+
[Protocols]
gFdtClientProtocolGuid = { 0xE11FACA0, 0x4710, 0x4C8E, { 0xA7, 0xA2, 0x01, 0xBA, 0xA2, 0x59, 0x1B, 0x4C } }
diff --git a/ArmVirtPkg/Include/Ppi/ArmVirtMemInfo.h b/ArmVirtPkg/Include/Ppi/ArmVirtMemInfo.h
new file mode 100644
index 000000000000..46885d02c384
--- /dev/null
+++ b/ArmVirtPkg/Include/Ppi/ArmVirtMemInfo.h
@@ -0,0 +1,48 @@
+/** @file
+
+ Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. All rights reserved.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _ARM_VIRT_MEMINFO_PPI_H_
+#define _ARM_VIRT_MEMINFO_PPI_H_
+
+#include <Library/ArmLib.h>
+
+#define ARM_VIRT_MEMINFO_PPI_GUID \
+ { 0x3b060b72, 0x8696, 0x4393, { 0xa8, 0x93, 0x34, 0x25, 0x1e, 0x3f, 0x8a, 0x6b } }
+
+/**
+ Return the Virtual Memory Map of your platform
+
+ This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
+ on your platform.
+
+ @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
+ describing a Physical-to-Virtual Memory
+ mapping. This array must be ended by a
+ zero-filled entry
+
+**/
+typedef
+VOID
+(EFIAPI * GET_MEMORY_MAP) (
+ OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
+ );
+
+typedef struct {
+ GET_MEMORY_MAP GetMemoryMap;
+} ARM_VIRT_MEMINFO_PPI;
+
+extern EFI_GUID gArmVirtMemInfoPpiGuid;
+
+#endif
diff --git a/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.c b/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.c
new file mode 100644
index 000000000000..ad27b246f980
--- /dev/null
+++ b/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.c
@@ -0,0 +1,46 @@
+/** @file
+
+ Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiPei.h>
+#include <Library/ArmLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Ppi/ArmVirtMemInfo.h>
+
+/**
+ Return the Virtual Memory Map of your platform
+
+ This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
+ on your platform.
+
+ @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
+ describing a Physical-to-Virtual Memory
+ mapping. This array must be ended by a
+ zero-filled entry
+
+**/
+VOID
+ArmVirtGetMemoryMap (
+ OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
+ )
+{
+ ARM_VIRT_MEMINFO_PPI *MemInfo;
+ EFI_STATUS Status;
+
+ Status = PeiServicesLocatePpi (&gArmVirtMemInfoPpiGuid, 0, NULL,
+ (VOID **)&MemInfo);
+ ASSERT_EFI_ERROR (Status);
+
+ MemInfo->GetMemoryMap (VirtualMemoryMap);
+}
diff --git a/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf b/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf
new file mode 100644
index 000000000000..b661c2f43faf
--- /dev/null
+++ b/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf
@@ -0,0 +1,42 @@
+#/* @file
+#
+# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
+# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
+#
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License which accompanies this
+# distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#*/
+
+[Defines]
+ INF_VERSION = 0x0001001A
+ BASE_NAME = PeiVirtMemInfoLib
+ FILE_GUID = 1d7bae0f-9674-4a4b-8d85-9804968cb12b
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ArmVirtMemInfoLib|PEIM
+
+[Sources]
+ PeiVirtMemInfoLib.c
+
+[Packages]
+ ArmPkg/ArmPkg.dec
+ ArmVirtPkg/ArmVirtPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ ArmLib
+ DebugLib
+ PeiServicesLib
+
+[Ppis]
+ gArmVirtMemInfoPpiGuid
+
+[Depex]
+ gArmVirtMemInfoPpiGuid
diff --git a/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.c b/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.c
new file mode 100644
index 000000000000..90ee552bdba0
--- /dev/null
+++ b/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.c
@@ -0,0 +1,121 @@
+/**@file
+
+ Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
+
+ 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 <PiPei.h>
+#include <Library/ArmLib.h>
+#include <Library/ArmVirtMemInfoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+#include <Library/PeiServicesLib.h>
+#include <libfdt.h>
+#include <Ppi/ArmVirtMemInfo.h>
+
+STATIC ARM_VIRT_MEMINFO_PPI mArmVirtMeminfoPpi = {
+ ArmVirtGetMemoryMap
+};
+
+STATIC CONST EFI_PEI_PPI_DESCRIPTOR mArmVirtMeminfoPpiTable = {
+ EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+ &gArmVirtMemInfoPpiGuid,
+ &mArmVirtMeminfoPpi
+};
+
+EFI_STATUS
+EFIAPI
+QemuVirtMemInfoPeimEntryPoint (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ VOID *DeviceTreeBase;
+ INT32 Node, Prev;
+ UINT64 NewBase, CurBase;
+ UINT64 NewSize, CurSize;
+ CONST CHAR8 *Type;
+ INT32 Len;
+ CONST UINT64 *RegProp;
+ RETURN_STATUS PcdStatus;
+
+ NewBase = 0;
+ NewSize = 0;
+
+ DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
+ ASSERT (DeviceTreeBase != NULL);
+
+ //
+ // Make sure we have a valid device tree blob
+ //
+ ASSERT (fdt_check_header (DeviceTreeBase) == 0);
+
+ //
+ // Look for the lowest memory node
+ //
+ for (Prev = 0;; Prev = Node) {
+ Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
+ if (Node < 0) {
+ break;
+ }
+
+ //
+ // Check for memory node
+ //
+ Type = fdt_getprop (DeviceTreeBase, Node, "device_type", &Len);
+ if (Type && AsciiStrnCmp (Type, "memory", Len) == 0) {
+ //
+ // Get the 'reg' property of this node. For now, we will assume
+ // two 8 byte quantities for base and size, respectively.
+ //
+ RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
+ if (RegProp != 0 && Len == (2 * sizeof (UINT64))) {
+
+ CurBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
+ CurSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
+
+ DEBUG ((DEBUG_INFO, "%a: System RAM @ 0x%lx - 0x%lx\n",
+ __FUNCTION__, CurBase, CurBase + CurSize - 1));
+
+ if (NewBase > CurBase || NewBase == 0) {
+ NewBase = CurBase;
+ NewSize = CurSize;
+ }
+ } else {
+ DEBUG ((DEBUG_ERROR, "%a: Failed to parse FDT memory node\n",
+ __FUNCTION__));
+ }
+ }
+ }
+
+ //
+ // Make sure the start of DRAM matches our expectation
+ //
+ ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) == NewBase);
+ PcdStatus = PcdSet64S (PcdSystemMemorySize, NewSize);
+ ASSERT_RETURN_ERROR (PcdStatus);
+
+ //
+ // We need to make sure that the machine we are running on has at least
+ // 128 MB of memory configured, and is currently executing this binary from
+ // NOR flash. This prevents a device tree image in DRAM from getting
+ // clobbered when our caller installs permanent PEI RAM, before we have a
+ // chance of marking its location as reserved or copy it to a freshly
+ // allocated block in the permanent PEI RAM in the platform PEIM.
+ //
+ ASSERT (NewSize >= SIZE_128MB);
+ ASSERT (
+ (((UINT64)PcdGet64 (PcdFdBaseAddress) +
+ (UINT64)PcdGet32 (PcdFdSize)) <= NewBase) ||
+ ((UINT64)PcdGet64 (PcdFdBaseAddress) >= (NewBase + NewSize)));
+
+ return PeiServicesInstallPpi (&mArmVirtMeminfoPpiTable);
+}
diff --git a/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf b/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf
new file mode 100644
index 000000000000..ac91e065be57
--- /dev/null
+++ b/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf
@@ -0,0 +1,60 @@
+## @file
+#
+# Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
+#
+# 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 = QemuVirtMemInfoPeim
+ FILE_GUID = 91da13af-d0ff-4810-b9b9-b095a9ee6b09
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ ENTRY_POINT = QemuVirtMemInfoPeimEntryPoint
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = ARM AARCH64
+#
+
+[Sources]
+ QemuVirtMemInfoPeim.c
+
+[Packages]
+ ArmPkg/ArmPkg.dec
+ ArmVirtPkg/ArmVirtPkg.dec
+ EmbeddedPkg/EmbeddedPkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ ArmLib
+ ArmVirtMemInfoLib
+ DebugLib
+ FdtLib
+ PeimEntryPoint
+ PeiServicesLib
+
+[Pcd]
+ gArmTokenSpaceGuid.PcdSystemMemorySize
+
+[Ppis]
+ gArmVirtMemInfoPpiGuid
+
+[FixedPcd]
+ gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress
+ gArmTokenSpaceGuid.PcdSystemMemoryBase
+ gArmTokenSpaceGuid.PcdFdBaseAddress
+ gArmTokenSpaceGuid.PcdFdSize
+ gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
+
+[Depex]
+ TRUE
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 13/15] ArmVirtPkg: implement ArmVirtMemInfo PPI, PEIM and library
2017-11-17 16:09 ` [PATCH 13/15] ArmVirtPkg: implement ArmVirtMemInfo PPI, PEIM and library Ard Biesheuvel
@ 2017-11-21 17:49 ` Laszlo Ersek
2017-11-21 17:57 ` Ard Biesheuvel
0 siblings, 1 reply; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 17:49 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> Equivalent to the PrePi based platforms, this patch implements the
> newly introduced ArmVirtMemInfo library class via a separate PEIM
> and PPI.
>
> The reason is that ArmVirtPlatformLib has populated the ArmPlatformLib
> API function ArmPlatformInitializeSystemMemory () to retrieve memory
> information from the DT, ensuring that it will be present when
> MemoryPeim() is executed. This is a bit of a hack, and someting we
> will need to get rid of if we want to reduce our dependency on
> ArmPlatformLib altogether.
OK, so whenever I try to look at this code, my brain crashes. This
occasion is no exception. All the more reason to clean it all up; thanks
for doing that.
So, I guess we are talking about the following call stack. If you agree,
please add it to the commit message (IMO it's OK to exceed the preferred
74 chars width for such sections):
ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf [ArmVirtPkg/ArmVirtQemu.dsc]
InitializeMemory() [ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c]
ArmPlatformInitializeSystemMemory() [ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c]
//
// set PcdSystemMemorySize from the DT
//
MemoryPeim() [ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c]
InitMmu() [ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c]
ArmPlatformGetVirtualMemoryMap() [ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c]
//
// consume PcdSystemMemorySize
//
Here we have two ArmVirtPlatformLib actions:
- The "PCD consumption" half of that has been moved -- well, copied, for
now -- to QemuVirtMemInfoLib, in patch 12/15.
- And we are now looking for a new home for the "PCD production" half.
> Putting this code in a ArmVirtMemInfo library constructor is
> problematic as well, given that the implementation uses other
> libraries, among which PcdLib, and so we need to find another way to
> run it before MemoryPeim()
Hm, this claim could be true :) , but I'm not totally convinced by the
way you put it.
First off, I notice that
"ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf" does not
spell out PcdLib as a dependency. This is quite bad, because it uses
PCDs.
However, ultimately, "gEfiPeiPcdPpiGuid" does end up in the final DEPEX
of "MemoryInitPeim.inf", according to the ArmVirtQemu build report file.
This must be due to some of the library instances already pulling in
PeiPcdLib.
Therefore, if we modify the constructor of QemuVirtMemInfoLib to parse
the DT and to set the PCD, *plus* we spell out PcdLib in the
QemuVirtMemInfoLib INF file, then the ultimate DEPEX for the
MemoryInitPeim module should remain the same. And, the PeiPcdLib
constructor should run before the QemuVirtMemInfoLib constructor
(parsing the DT and setting the PCD).
What's wrong with this argument?
> So instead, create a separate PEIM that encapsulates the
> ArmVirtMemInfo code and exposes it via a PPI. Another ArmVirtMemInfo
> library class implementation is also provided that depexes on the PPI,
> which ensures that the code is called in the correct order.
I understand what this does, but I find it very complex.
Sometimes, whenever we want to make sure that a PCD is set dynamically
"no later than" it's consumed by a "common" module outside of
ArmVirtPkg, we create a dedicated library instance (with all the right
library dependencies spelled out in its INF file), set the PCD in its
constructor, and hook it into the consumer module via NULL class
resolution.
In this case, we have a lib instance that is used through an actual lib
class already, so I would suggest to add a constructor function, and to
spell out the PcdLib dependency in the INF file.
... In fact, this is something that I missed in patch 12 --
QemuVirtMemInfoLib already uses PCDs, but doesn't include "PcdLib" under
[LibraryClasses]. That is a bug inherited from ArmVirtPlatformLib (see
above), and should be fixed. And then we should only need the
constructor.
What do you think?
Thanks,
Laszlo
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/ArmVirtPkg.dec | 3 +
> ArmVirtPkg/Include/Ppi/ArmVirtMemInfo.h | 48 ++++++++
> ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.c | 46 ++++++++
> ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf | 42 +++++++
> ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.c | 121 ++++++++++++++++++++
> ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf | 60 ++++++++++
> 6 files changed, 320 insertions(+)
>
> diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
> index 8f656fd2739d..260849dc845c 100644
> --- a/ArmVirtPkg/ArmVirtPkg.dec
> +++ b/ArmVirtPkg/ArmVirtPkg.dec
> @@ -39,6 +39,9 @@ [Guids.common]
>
> gArmVirtVariableGuid = { 0x50bea1e5, 0xa2c5, 0x46e9, { 0x9b, 0x3a, 0x59, 0x59, 0x65, 0x16, 0xb0, 0x0a } }
>
> +[Ppis]
> + gArmVirtMemInfoPpiGuid = { 0x3b060b72, 0x8696, 0x4393, { 0xa8, 0x93, 0x34, 0x25, 0x1e, 0x3f, 0x8a, 0x6b } }
> +
> [Protocols]
> gFdtClientProtocolGuid = { 0xE11FACA0, 0x4710, 0x4C8E, { 0xA7, 0xA2, 0x01, 0xBA, 0xA2, 0x59, 0x1B, 0x4C } }
>
> diff --git a/ArmVirtPkg/Include/Ppi/ArmVirtMemInfo.h b/ArmVirtPkg/Include/Ppi/ArmVirtMemInfo.h
> new file mode 100644
> index 000000000000..46885d02c384
> --- /dev/null
> +++ b/ArmVirtPkg/Include/Ppi/ArmVirtMemInfo.h
> @@ -0,0 +1,48 @@
> +/** @file
> +
> + Copyright (c) 2011-2013, ARM Limited. All rights reserved.
> + Copyright (c) 2017, Linaro, Ltd. All rights reserved.
> +
> + This program and the accompanying materials are licensed and made available
> + under the terms and conditions of the BSD License which accompanies this
> + distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef _ARM_VIRT_MEMINFO_PPI_H_
> +#define _ARM_VIRT_MEMINFO_PPI_H_
> +
> +#include <Library/ArmLib.h>
> +
> +#define ARM_VIRT_MEMINFO_PPI_GUID \
> + { 0x3b060b72, 0x8696, 0x4393, { 0xa8, 0x93, 0x34, 0x25, 0x1e, 0x3f, 0x8a, 0x6b } }
> +
> +/**
> + Return the Virtual Memory Map of your platform
> +
> + This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
> + on your platform.
> +
> + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
> + describing a Physical-to-Virtual Memory
> + mapping. This array must be ended by a
> + zero-filled entry
> +
> +**/
> +typedef
> +VOID
> +(EFIAPI * GET_MEMORY_MAP) (
> + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
> + );
> +
> +typedef struct {
> + GET_MEMORY_MAP GetMemoryMap;
> +} ARM_VIRT_MEMINFO_PPI;
> +
> +extern EFI_GUID gArmVirtMemInfoPpiGuid;
> +
> +#endif
> diff --git a/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.c b/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.c
> new file mode 100644
> index 000000000000..ad27b246f980
> --- /dev/null
> +++ b/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.c
> @@ -0,0 +1,46 @@
> +/** @file
> +
> + Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
> +
> + This program and the accompanying materials are licensed and made available
> + under the terms and conditions of the BSD License which accompanies this
> + distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <PiPei.h>
> +#include <Library/ArmLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/PeiServicesLib.h>
> +#include <Ppi/ArmVirtMemInfo.h>
> +
> +/**
> + Return the Virtual Memory Map of your platform
> +
> + This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
> + on your platform.
> +
> + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
> + describing a Physical-to-Virtual Memory
> + mapping. This array must be ended by a
> + zero-filled entry
> +
> +**/
> +VOID
> +ArmVirtGetMemoryMap (
> + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
> + )
> +{
> + ARM_VIRT_MEMINFO_PPI *MemInfo;
> + EFI_STATUS Status;
> +
> + Status = PeiServicesLocatePpi (&gArmVirtMemInfoPpiGuid, 0, NULL,
> + (VOID **)&MemInfo);
> + ASSERT_EFI_ERROR (Status);
> +
> + MemInfo->GetMemoryMap (VirtualMemoryMap);
> +}
> diff --git a/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf b/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf
> new file mode 100644
> index 000000000000..b661c2f43faf
> --- /dev/null
> +++ b/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf
> @@ -0,0 +1,42 @@
> +#/* @file
> +#
> +# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
> +# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
> +#
> +# This program and the accompanying materials are licensed and made available
> +# under the terms and conditions of the BSD License which accompanies this
> +# distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#*/
> +
> +[Defines]
> + INF_VERSION = 0x0001001A
> + BASE_NAME = PeiVirtMemInfoLib
> + FILE_GUID = 1d7bae0f-9674-4a4b-8d85-9804968cb12b
> + MODULE_TYPE = PEIM
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = ArmVirtMemInfoLib|PEIM
> +
> +[Sources]
> + PeiVirtMemInfoLib.c
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + ArmVirtPkg/ArmVirtPkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> + ArmLib
> + DebugLib
> + PeiServicesLib
> +
> +[Ppis]
> + gArmVirtMemInfoPpiGuid
> +
> +[Depex]
> + gArmVirtMemInfoPpiGuid
> diff --git a/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.c b/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.c
> new file mode 100644
> index 000000000000..90ee552bdba0
> --- /dev/null
> +++ b/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.c
> @@ -0,0 +1,121 @@
> +/**@file
> +
> + Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
> +
> + 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 <PiPei.h>
> +#include <Library/ArmLib.h>
> +#include <Library/ArmVirtMemInfoLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/PeiServicesLib.h>
> +#include <libfdt.h>
> +#include <Ppi/ArmVirtMemInfo.h>
> +
> +STATIC ARM_VIRT_MEMINFO_PPI mArmVirtMeminfoPpi = {
> + ArmVirtGetMemoryMap
> +};
> +
> +STATIC CONST EFI_PEI_PPI_DESCRIPTOR mArmVirtMeminfoPpiTable = {
> + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
> + &gArmVirtMemInfoPpiGuid,
> + &mArmVirtMeminfoPpi
> +};
> +
> +EFI_STATUS
> +EFIAPI
> +QemuVirtMemInfoPeimEntryPoint (
> + IN EFI_PEI_FILE_HANDLE FileHandle,
> + IN CONST EFI_PEI_SERVICES **PeiServices
> + )
> +{
> + VOID *DeviceTreeBase;
> + INT32 Node, Prev;
> + UINT64 NewBase, CurBase;
> + UINT64 NewSize, CurSize;
> + CONST CHAR8 *Type;
> + INT32 Len;
> + CONST UINT64 *RegProp;
> + RETURN_STATUS PcdStatus;
> +
> + NewBase = 0;
> + NewSize = 0;
> +
> + DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
> + ASSERT (DeviceTreeBase != NULL);
> +
> + //
> + // Make sure we have a valid device tree blob
> + //
> + ASSERT (fdt_check_header (DeviceTreeBase) == 0);
> +
> + //
> + // Look for the lowest memory node
> + //
> + for (Prev = 0;; Prev = Node) {
> + Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
> + if (Node < 0) {
> + break;
> + }
> +
> + //
> + // Check for memory node
> + //
> + Type = fdt_getprop (DeviceTreeBase, Node, "device_type", &Len);
> + if (Type && AsciiStrnCmp (Type, "memory", Len) == 0) {
> + //
> + // Get the 'reg' property of this node. For now, we will assume
> + // two 8 byte quantities for base and size, respectively.
> + //
> + RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
> + if (RegProp != 0 && Len == (2 * sizeof (UINT64))) {
> +
> + CurBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
> + CurSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
> +
> + DEBUG ((DEBUG_INFO, "%a: System RAM @ 0x%lx - 0x%lx\n",
> + __FUNCTION__, CurBase, CurBase + CurSize - 1));
> +
> + if (NewBase > CurBase || NewBase == 0) {
> + NewBase = CurBase;
> + NewSize = CurSize;
> + }
> + } else {
> + DEBUG ((DEBUG_ERROR, "%a: Failed to parse FDT memory node\n",
> + __FUNCTION__));
> + }
> + }
> + }
> +
> + //
> + // Make sure the start of DRAM matches our expectation
> + //
> + ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) == NewBase);
> + PcdStatus = PcdSet64S (PcdSystemMemorySize, NewSize);
> + ASSERT_RETURN_ERROR (PcdStatus);
> +
> + //
> + // We need to make sure that the machine we are running on has at least
> + // 128 MB of memory configured, and is currently executing this binary from
> + // NOR flash. This prevents a device tree image in DRAM from getting
> + // clobbered when our caller installs permanent PEI RAM, before we have a
> + // chance of marking its location as reserved or copy it to a freshly
> + // allocated block in the permanent PEI RAM in the platform PEIM.
> + //
> + ASSERT (NewSize >= SIZE_128MB);
> + ASSERT (
> + (((UINT64)PcdGet64 (PcdFdBaseAddress) +
> + (UINT64)PcdGet32 (PcdFdSize)) <= NewBase) ||
> + ((UINT64)PcdGet64 (PcdFdBaseAddress) >= (NewBase + NewSize)));
> +
> + return PeiServicesInstallPpi (&mArmVirtMeminfoPpiTable);
> +}
> diff --git a/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf b/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf
> new file mode 100644
> index 000000000000..ac91e065be57
> --- /dev/null
> +++ b/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf
> @@ -0,0 +1,60 @@
> +## @file
> +#
> +# Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
> +#
> +# 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 = QemuVirtMemInfoPeim
> + FILE_GUID = 91da13af-d0ff-4810-b9b9-b095a9ee6b09
> + MODULE_TYPE = PEIM
> + VERSION_STRING = 1.0
> + ENTRY_POINT = QemuVirtMemInfoPeimEntryPoint
> +
> +#
> +# The following information is for reference only and not required by the build tools.
> +#
> +# VALID_ARCHITECTURES = ARM AARCH64
> +#
> +
> +[Sources]
> + QemuVirtMemInfoPeim.c
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + ArmVirtPkg/ArmVirtPkg.dec
> + EmbeddedPkg/EmbeddedPkg.dec
> + MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> + ArmLib
> + ArmVirtMemInfoLib
> + DebugLib
> + FdtLib
> + PeimEntryPoint
> + PeiServicesLib
> +
> +[Pcd]
> + gArmTokenSpaceGuid.PcdSystemMemorySize
> +
> +[Ppis]
> + gArmVirtMemInfoPpiGuid
> +
> +[FixedPcd]
> + gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress
> + gArmTokenSpaceGuid.PcdSystemMemoryBase
> + gArmTokenSpaceGuid.PcdFdBaseAddress
> + gArmTokenSpaceGuid.PcdFdSize
> + gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
> +
> +[Depex]
> + TRUE
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 13/15] ArmVirtPkg: implement ArmVirtMemInfo PPI, PEIM and library
2017-11-21 17:49 ` Laszlo Ersek
@ 2017-11-21 17:57 ` Ard Biesheuvel
2017-11-21 20:17 ` Laszlo Ersek
0 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-21 17:57 UTC (permalink / raw)
To: Laszlo Ersek; +Cc: edk2-devel, leif.lindholm
> On 21 Nov 2017, at 17:49, Laszlo Ersek <lersek@redhat.com> wrote:
>
>> On 11/17/17 17:09, Ard Biesheuvel wrote:
>> Equivalent to the PrePi based platforms, this patch implements the
>> newly introduced ArmVirtMemInfo library class via a separate PEIM
>> and PPI.
>>
>> The reason is that ArmVirtPlatformLib has populated the ArmPlatformLib
>> API function ArmPlatformInitializeSystemMemory () to retrieve memory
>> information from the DT, ensuring that it will be present when
>> MemoryPeim() is executed. This is a bit of a hack, and someting we
>> will need to get rid of if we want to reduce our dependency on
>> ArmPlatformLib altogether.
>
> OK, so whenever I try to look at this code, my brain crashes. This
> occasion is no exception. All the more reason to clean it all up; thanks
> for doing that.
>
> So, I guess we are talking about the following call stack. If you agree,
> please add it to the commit message (IMO it's OK to exceed the preferred
> 74 chars width for such sections):
>
> ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf [ArmVirtPkg/ArmVirtQemu.dsc]
> InitializeMemory() [ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c]
> ArmPlatformInitializeSystemMemory() [ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c]
> //
> // set PcdSystemMemorySize from the DT
> //
> MemoryPeim() [ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c]
> InitMmu() [ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c]
> ArmPlatformGetVirtualMemoryMap() [ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c]
> //
> // consume PcdSystemMemorySize
> //
>
> Here we have two ArmVirtPlatformLib actions:
>
> - The "PCD consumption" half of that has been moved -- well, copied, for
> now -- to QemuVirtMemInfoLib, in patch 12/15.
>
> - And we are now looking for a new home for the "PCD production" half.
>
Yes
>> Putting this code in a ArmVirtMemInfo library constructor is
>> problematic as well, given that the implementation uses other
>> libraries, among which PcdLib, and so we need to find another way to
>> run it before MemoryPeim()
>
> Hm, this claim could be true :) , but I'm not totally convinced by the
> way you put it.
>
> First off, I notice that
> "ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf" does not
> spell out PcdLib as a dependency. This is quite bad, because it uses
> PCDs.
>
> However, ultimately, "gEfiPeiPcdPpiGuid" does end up in the final DEPEX
> of "MemoryInitPeim.inf", according to the ArmVirtQemu build report file.
> This must be due to some of the library instances already pulling in
> PeiPcdLib.
>
> Therefore, if we modify the constructor of QemuVirtMemInfoLib to parse
> the DT and to set the PCD, *plus* we spell out PcdLib in the
> QemuVirtMemInfoLib INF file, then the ultimate DEPEX for the
> MemoryInitPeim module should remain the same. And, the PeiPcdLib
> constructor should run before the QemuVirtMemInfoLib constructor
> (parsing the DT and setting the PCD).
>
> What's wrong with this argument?
>
I guess you’re right. Direct dependencies between libraries with constructors are handled correctly by the tools, I simply managed to confuse myself due to the issues with transitive dependencies which you surely remember.
>> So instead, create a separate PEIM that encapsulates the
>> ArmVirtMemInfo code and exposes it via a PPI. Another ArmVirtMemInfo
>> library class implementation is also provided that depexes on the PPI,
>> which ensures that the code is called in the correct order.
>
> I understand what this does, but I find it very complex.
>
> Sometimes, whenever we want to make sure that a PCD is set dynamically
> "no later than" it's consumed by a "common" module outside of
> ArmVirtPkg, we create a dedicated library instance (with all the right
> library dependencies spelled out in its INF file), set the PCD in its
> constructor, and hook it into the consumer module via NULL class
> resolution.
>
> In this case, we have a lib instance that is used through an actual lib
> class already, so I would suggest to add a constructor function, and to
> spell out the PcdLib dependency in the INF file.
>
> ... In fact, this is something that I missed in patch 12 --
> QemuVirtMemInfoLib already uses PCDs, but doesn't include "PcdLib" under
> [LibraryClasses]. That is a bug inherited from ArmVirtPlatformLib (see
> above), and should be fixed. And then we should only need the
> constructor.
>
> What do you think?
>
I think you’re right.
So how do you propose i go about creating two versions of QemuVirtMemInfoLib, only one of which has a constructor? Share the .c file between two infs in the same directory?
>
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>> ArmVirtPkg/ArmVirtPkg.dec | 3 +
>> ArmVirtPkg/Include/Ppi/ArmVirtMemInfo.h | 48 ++++++++
>> ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.c | 46 ++++++++
>> ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf | 42 +++++++
>> ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.c | 121 ++++++++++++++++++++
>> ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf | 60 ++++++++++
>> 6 files changed, 320 insertions(+)
>>
>> diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
>> index 8f656fd2739d..260849dc845c 100644
>> --- a/ArmVirtPkg/ArmVirtPkg.dec
>> +++ b/ArmVirtPkg/ArmVirtPkg.dec
>> @@ -39,6 +39,9 @@ [Guids.common]
>>
>> gArmVirtVariableGuid = { 0x50bea1e5, 0xa2c5, 0x46e9, { 0x9b, 0x3a, 0x59, 0x59, 0x65, 0x16, 0xb0, 0x0a } }
>>
>> +[Ppis]
>> + gArmVirtMemInfoPpiGuid = { 0x3b060b72, 0x8696, 0x4393, { 0xa8, 0x93, 0x34, 0x25, 0x1e, 0x3f, 0x8a, 0x6b } }
>> +
>> [Protocols]
>> gFdtClientProtocolGuid = { 0xE11FACA0, 0x4710, 0x4C8E, { 0xA7, 0xA2, 0x01, 0xBA, 0xA2, 0x59, 0x1B, 0x4C } }
>>
>> diff --git a/ArmVirtPkg/Include/Ppi/ArmVirtMemInfo.h b/ArmVirtPkg/Include/Ppi/ArmVirtMemInfo.h
>> new file mode 100644
>> index 000000000000..46885d02c384
>> --- /dev/null
>> +++ b/ArmVirtPkg/Include/Ppi/ArmVirtMemInfo.h
>> @@ -0,0 +1,48 @@
>> +/** @file
>> +
>> + Copyright (c) 2011-2013, ARM Limited. All rights reserved.
>> + Copyright (c) 2017, Linaro, Ltd. All rights reserved.
>> +
>> + This program and the accompanying materials are licensed and made available
>> + under the terms and conditions of the BSD License which accompanies this
>> + distribution. The full text of the license may be found at
>> + http://opensource.org/licenses/bsd-license.php
>> +
>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>> +
>> +**/
>> +
>> +#ifndef _ARM_VIRT_MEMINFO_PPI_H_
>> +#define _ARM_VIRT_MEMINFO_PPI_H_
>> +
>> +#include <Library/ArmLib.h>
>> +
>> +#define ARM_VIRT_MEMINFO_PPI_GUID \
>> + { 0x3b060b72, 0x8696, 0x4393, { 0xa8, 0x93, 0x34, 0x25, 0x1e, 0x3f, 0x8a, 0x6b } }
>> +
>> +/**
>> + Return the Virtual Memory Map of your platform
>> +
>> + This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
>> + on your platform.
>> +
>> + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
>> + describing a Physical-to-Virtual Memory
>> + mapping. This array must be ended by a
>> + zero-filled entry
>> +
>> +**/
>> +typedef
>> +VOID
>> +(EFIAPI * GET_MEMORY_MAP) (
>> + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
>> + );
>> +
>> +typedef struct {
>> + GET_MEMORY_MAP GetMemoryMap;
>> +} ARM_VIRT_MEMINFO_PPI;
>> +
>> +extern EFI_GUID gArmVirtMemInfoPpiGuid;
>> +
>> +#endif
>> diff --git a/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.c b/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.c
>> new file mode 100644
>> index 000000000000..ad27b246f980
>> --- /dev/null
>> +++ b/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.c
>> @@ -0,0 +1,46 @@
>> +/** @file
>> +
>> + Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
>> +
>> + This program and the accompanying materials are licensed and made available
>> + under the terms and conditions of the BSD License which accompanies this
>> + distribution. The full text of the license may be found at
>> + http://opensource.org/licenses/bsd-license.php
>> +
>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>> +
>> +**/
>> +
>> +#include <PiPei.h>
>> +#include <Library/ArmLib.h>
>> +#include <Library/DebugLib.h>
>> +#include <Library/PeiServicesLib.h>
>> +#include <Ppi/ArmVirtMemInfo.h>
>> +
>> +/**
>> + Return the Virtual Memory Map of your platform
>> +
>> + This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
>> + on your platform.
>> +
>> + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
>> + describing a Physical-to-Virtual Memory
>> + mapping. This array must be ended by a
>> + zero-filled entry
>> +
>> +**/
>> +VOID
>> +ArmVirtGetMemoryMap (
>> + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
>> + )
>> +{
>> + ARM_VIRT_MEMINFO_PPI *MemInfo;
>> + EFI_STATUS Status;
>> +
>> + Status = PeiServicesLocatePpi (&gArmVirtMemInfoPpiGuid, 0, NULL,
>> + (VOID **)&MemInfo);
>> + ASSERT_EFI_ERROR (Status);
>> +
>> + MemInfo->GetMemoryMap (VirtualMemoryMap);
>> +}
>> diff --git a/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf b/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf
>> new file mode 100644
>> index 000000000000..b661c2f43faf
>> --- /dev/null
>> +++ b/ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf
>> @@ -0,0 +1,42 @@
>> +#/* @file
>> +#
>> +# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
>> +# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
>> +#
>> +# This program and the accompanying materials are licensed and made available
>> +# under the terms and conditions of the BSD License which accompanies this
>> +# distribution. The full text of the license may be found at
>> +# http://opensource.org/licenses/bsd-license.php
>> +#
>> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>> +#
>> +#*/
>> +
>> +[Defines]
>> + INF_VERSION = 0x0001001A
>> + BASE_NAME = PeiVirtMemInfoLib
>> + FILE_GUID = 1d7bae0f-9674-4a4b-8d85-9804968cb12b
>> + MODULE_TYPE = PEIM
>> + VERSION_STRING = 1.0
>> + LIBRARY_CLASS = ArmVirtMemInfoLib|PEIM
>> +
>> +[Sources]
>> + PeiVirtMemInfoLib.c
>> +
>> +[Packages]
>> + ArmPkg/ArmPkg.dec
>> + ArmVirtPkg/ArmVirtPkg.dec
>> + MdeModulePkg/MdeModulePkg.dec
>> + MdePkg/MdePkg.dec
>> +
>> +[LibraryClasses]
>> + ArmLib
>> + DebugLib
>> + PeiServicesLib
>> +
>> +[Ppis]
>> + gArmVirtMemInfoPpiGuid
>> +
>> +[Depex]
>> + gArmVirtMemInfoPpiGuid
>> diff --git a/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.c b/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.c
>> new file mode 100644
>> index 000000000000..90ee552bdba0
>> --- /dev/null
>> +++ b/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.c
>> @@ -0,0 +1,121 @@
>> +/**@file
>> +
>> + Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
>> +
>> + 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 <PiPei.h>
>> +#include <Library/ArmLib.h>
>> +#include <Library/ArmVirtMemInfoLib.h>
>> +#include <Library/DebugLib.h>
>> +#include <Library/PcdLib.h>
>> +#include <Library/PeiServicesLib.h>
>> +#include <libfdt.h>
>> +#include <Ppi/ArmVirtMemInfo.h>
>> +
>> +STATIC ARM_VIRT_MEMINFO_PPI mArmVirtMeminfoPpi = {
>> + ArmVirtGetMemoryMap
>> +};
>> +
>> +STATIC CONST EFI_PEI_PPI_DESCRIPTOR mArmVirtMeminfoPpiTable = {
>> + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
>> + &gArmVirtMemInfoPpiGuid,
>> + &mArmVirtMeminfoPpi
>> +};
>> +
>> +EFI_STATUS
>> +EFIAPI
>> +QemuVirtMemInfoPeimEntryPoint (
>> + IN EFI_PEI_FILE_HANDLE FileHandle,
>> + IN CONST EFI_PEI_SERVICES **PeiServices
>> + )
>> +{
>> + VOID *DeviceTreeBase;
>> + INT32 Node, Prev;
>> + UINT64 NewBase, CurBase;
>> + UINT64 NewSize, CurSize;
>> + CONST CHAR8 *Type;
>> + INT32 Len;
>> + CONST UINT64 *RegProp;
>> + RETURN_STATUS PcdStatus;
>> +
>> + NewBase = 0;
>> + NewSize = 0;
>> +
>> + DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
>> + ASSERT (DeviceTreeBase != NULL);
>> +
>> + //
>> + // Make sure we have a valid device tree blob
>> + //
>> + ASSERT (fdt_check_header (DeviceTreeBase) == 0);
>> +
>> + //
>> + // Look for the lowest memory node
>> + //
>> + for (Prev = 0;; Prev = Node) {
>> + Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
>> + if (Node < 0) {
>> + break;
>> + }
>> +
>> + //
>> + // Check for memory node
>> + //
>> + Type = fdt_getprop (DeviceTreeBase, Node, "device_type", &Len);
>> + if (Type && AsciiStrnCmp (Type, "memory", Len) == 0) {
>> + //
>> + // Get the 'reg' property of this node. For now, we will assume
>> + // two 8 byte quantities for base and size, respectively.
>> + //
>> + RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
>> + if (RegProp != 0 && Len == (2 * sizeof (UINT64))) {
>> +
>> + CurBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
>> + CurSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
>> +
>> + DEBUG ((DEBUG_INFO, "%a: System RAM @ 0x%lx - 0x%lx\n",
>> + __FUNCTION__, CurBase, CurBase + CurSize - 1));
>> +
>> + if (NewBase > CurBase || NewBase == 0) {
>> + NewBase = CurBase;
>> + NewSize = CurSize;
>> + }
>> + } else {
>> + DEBUG ((DEBUG_ERROR, "%a: Failed to parse FDT memory node\n",
>> + __FUNCTION__));
>> + }
>> + }
>> + }
>> +
>> + //
>> + // Make sure the start of DRAM matches our expectation
>> + //
>> + ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) == NewBase);
>> + PcdStatus = PcdSet64S (PcdSystemMemorySize, NewSize);
>> + ASSERT_RETURN_ERROR (PcdStatus);
>> +
>> + //
>> + // We need to make sure that the machine we are running on has at least
>> + // 128 MB of memory configured, and is currently executing this binary from
>> + // NOR flash. This prevents a device tree image in DRAM from getting
>> + // clobbered when our caller installs permanent PEI RAM, before we have a
>> + // chance of marking its location as reserved or copy it to a freshly
>> + // allocated block in the permanent PEI RAM in the platform PEIM.
>> + //
>> + ASSERT (NewSize >= SIZE_128MB);
>> + ASSERT (
>> + (((UINT64)PcdGet64 (PcdFdBaseAddress) +
>> + (UINT64)PcdGet32 (PcdFdSize)) <= NewBase) ||
>> + ((UINT64)PcdGet64 (PcdFdBaseAddress) >= (NewBase + NewSize)));
>> +
>> + return PeiServicesInstallPpi (&mArmVirtMeminfoPpiTable);
>> +}
>> diff --git a/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf b/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf
>> new file mode 100644
>> index 000000000000..ac91e065be57
>> --- /dev/null
>> +++ b/ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf
>> @@ -0,0 +1,60 @@
>> +## @file
>> +#
>> +# Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
>> +#
>> +# 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 = QemuVirtMemInfoPeim
>> + FILE_GUID = 91da13af-d0ff-4810-b9b9-b095a9ee6b09
>> + MODULE_TYPE = PEIM
>> + VERSION_STRING = 1.0
>> + ENTRY_POINT = QemuVirtMemInfoPeimEntryPoint
>> +
>> +#
>> +# The following information is for reference only and not required by the build tools.
>> +#
>> +# VALID_ARCHITECTURES = ARM AARCH64
>> +#
>> +
>> +[Sources]
>> + QemuVirtMemInfoPeim.c
>> +
>> +[Packages]
>> + ArmPkg/ArmPkg.dec
>> + ArmVirtPkg/ArmVirtPkg.dec
>> + EmbeddedPkg/EmbeddedPkg.dec
>> + MdePkg/MdePkg.dec
>> +
>> +[LibraryClasses]
>> + ArmLib
>> + ArmVirtMemInfoLib
>> + DebugLib
>> + FdtLib
>> + PeimEntryPoint
>> + PeiServicesLib
>> +
>> +[Pcd]
>> + gArmTokenSpaceGuid.PcdSystemMemorySize
>> +
>> +[Ppis]
>> + gArmVirtMemInfoPpiGuid
>> +
>> +[FixedPcd]
>> + gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress
>> + gArmTokenSpaceGuid.PcdSystemMemoryBase
>> + gArmTokenSpaceGuid.PcdFdBaseAddress
>> + gArmTokenSpaceGuid.PcdFdSize
>> + gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
>> +
>> +[Depex]
>> + TRUE
>>
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 13/15] ArmVirtPkg: implement ArmVirtMemInfo PPI, PEIM and library
2017-11-21 17:57 ` Ard Biesheuvel
@ 2017-11-21 20:17 ` Laszlo Ersek
2017-11-21 20:32 ` Ard Biesheuvel
0 siblings, 1 reply; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 20:17 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel, leif.lindholm
On 11/21/17 18:57, Ard Biesheuvel wrote:
>
>
>> On 21 Nov 2017, at 17:49, Laszlo Ersek <lersek@redhat.com> wrote:
>>
>>> On 11/17/17 17:09, Ard Biesheuvel wrote:
>>> Equivalent to the PrePi based platforms, this patch implements the
>>> newly introduced ArmVirtMemInfo library class via a separate PEIM
>>> and PPI.
>>>
>>> The reason is that ArmVirtPlatformLib has populated the ArmPlatformLib
>>> API function ArmPlatformInitializeSystemMemory () to retrieve memory
>>> information from the DT, ensuring that it will be present when
>>> MemoryPeim() is executed. This is a bit of a hack, and someting we
>>> will need to get rid of if we want to reduce our dependency on
>>> ArmPlatformLib altogether.
>>
>> OK, so whenever I try to look at this code, my brain crashes. This
>> occasion is no exception. All the more reason to clean it all up; thanks
>> for doing that.
>>
>> So, I guess we are talking about the following call stack. If you agree,
>> please add it to the commit message (IMO it's OK to exceed the preferred
>> 74 chars width for such sections):
>>
>> ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf [ArmVirtPkg/ArmVirtQemu.dsc]
>> InitializeMemory() [ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c]
>> ArmPlatformInitializeSystemMemory() [ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c]
>> //
>> // set PcdSystemMemorySize from the DT
>> //
>> MemoryPeim() [ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c]
>> InitMmu() [ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c]
>> ArmPlatformGetVirtualMemoryMap() [ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c]
>> //
>> // consume PcdSystemMemorySize
>> //
>>
>> Here we have two ArmVirtPlatformLib actions:
>>
>> - The "PCD consumption" half of that has been moved -- well, copied, for
>> now -- to QemuVirtMemInfoLib, in patch 12/15.
>>
>> - And we are now looking for a new home for the "PCD production" half.
>>
>
> Yes
>
>>> Putting this code in a ArmVirtMemInfo library constructor is
>>> problematic as well, given that the implementation uses other
>>> libraries, among which PcdLib, and so we need to find another way to
>>> run it before MemoryPeim()
>>
>> Hm, this claim could be true :) , but I'm not totally convinced by the
>> way you put it.
>>
>> First off, I notice that
>> "ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf" does not
>> spell out PcdLib as a dependency. This is quite bad, because it uses
>> PCDs.
>>
>> However, ultimately, "gEfiPeiPcdPpiGuid" does end up in the final DEPEX
>> of "MemoryInitPeim.inf", according to the ArmVirtQemu build report file.
>> This must be due to some of the library instances already pulling in
>> PeiPcdLib.
>>
>> Therefore, if we modify the constructor of QemuVirtMemInfoLib to parse
>> the DT and to set the PCD, *plus* we spell out PcdLib in the
>> QemuVirtMemInfoLib INF file, then the ultimate DEPEX for the
>> MemoryInitPeim module should remain the same. And, the PeiPcdLib
>> constructor should run before the QemuVirtMemInfoLib constructor
>> (parsing the DT and setting the PCD).
>>
>> What's wrong with this argument?
>>
>
> I guess you’re right. Direct dependencies between libraries with constructors are handled correctly by the tools, I simply managed to confuse myself due to the issues with transitive dependencies which you surely remember.
Right, I suspected that this experience was in the background. If I
remember correctly, the issue was when some libraries had constructors
while some others had none (and required explicit init function calls
instead). In some cases this mixing was not possible to avoid due to
circular dependencies between constructors, but in turn the explicit
calls didn't get ordered right, or some such. *shudder* :)
>
>>> So instead, create a separate PEIM that encapsulates the
>>> ArmVirtMemInfo code and exposes it via a PPI. Another ArmVirtMemInfo
>>> library class implementation is also provided that depexes on the PPI,
>>> which ensures that the code is called in the correct order.
>>
>> I understand what this does, but I find it very complex.
>>
>> Sometimes, whenever we want to make sure that a PCD is set dynamically
>> "no later than" it's consumed by a "common" module outside of
>> ArmVirtPkg, we create a dedicated library instance (with all the right
>> library dependencies spelled out in its INF file), set the PCD in its
>> constructor, and hook it into the consumer module via NULL class
>> resolution.
>>
>> In this case, we have a lib instance that is used through an actual lib
>> class already, so I would suggest to add a constructor function, and to
>> spell out the PcdLib dependency in the INF file.
>>
>> ... In fact, this is something that I missed in patch 12 --
>> QemuVirtMemInfoLib already uses PCDs, but doesn't include "PcdLib" under
>> [LibraryClasses]. That is a bug inherited from ArmVirtPlatformLib (see
>> above), and should be fixed. And then we should only need the
>> constructor.
>>
>> What do you think?
>>
>
> I think you’re right.
>
> So how do you propose i go about creating two versions of QemuVirtMemInfoLib, only one of which has a constructor? Share the .c file between two infs in the same directory?
Hm, I think I missed the impact on ArmVirtQemuKernel. In the current
set, its DSC file is only modified in patch 12. (I missed that too.) Are
any changes necessary for ArmVirtQemuKernel that are not contained in
this set?
Either way, what you propose above seems to be the standard approach to
me: use two INF files, keep the bulk of the code in one (shared) C file,
and add the constructor to another (non-shared) C file (i.e., referenced
by only one of the INF files). Should the constructor need shared
utility functions from the shared C file, add an internal header for those.
Thanks!
Laszlo
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 13/15] ArmVirtPkg: implement ArmVirtMemInfo PPI, PEIM and library
2017-11-21 20:17 ` Laszlo Ersek
@ 2017-11-21 20:32 ` Ard Biesheuvel
2017-11-22 8:45 ` Laszlo Ersek
0 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-21 20:32 UTC (permalink / raw)
To: Laszlo Ersek; +Cc: edk2-devel@lists.01.org, Leif Lindholm
On 21 November 2017 at 20:17, Laszlo Ersek <lersek@redhat.com> wrote:
> On 11/21/17 18:57, Ard Biesheuvel wrote:
>>
>>
>>> On 21 Nov 2017, at 17:49, Laszlo Ersek <lersek@redhat.com> wrote:
>>>
>>>> On 11/17/17 17:09, Ard Biesheuvel wrote:
>>>> Equivalent to the PrePi based platforms, this patch implements the
>>>> newly introduced ArmVirtMemInfo library class via a separate PEIM
>>>> and PPI.
>>>>
>>>> The reason is that ArmVirtPlatformLib has populated the ArmPlatformLib
>>>> API function ArmPlatformInitializeSystemMemory () to retrieve memory
>>>> information from the DT, ensuring that it will be present when
>>>> MemoryPeim() is executed. This is a bit of a hack, and someting we
>>>> will need to get rid of if we want to reduce our dependency on
>>>> ArmPlatformLib altogether.
>>>
>>> OK, so whenever I try to look at this code, my brain crashes. This
>>> occasion is no exception. All the more reason to clean it all up; thanks
>>> for doing that.
>>>
>>> So, I guess we are talking about the following call stack. If you agree,
>>> please add it to the commit message (IMO it's OK to exceed the preferred
>>> 74 chars width for such sections):
>>>
>>> ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf [ArmVirtPkg/ArmVirtQemu.dsc]
>>> InitializeMemory() [ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c]
>>> ArmPlatformInitializeSystemMemory() [ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c]
>>> //
>>> // set PcdSystemMemorySize from the DT
>>> //
>>> MemoryPeim() [ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c]
>>> InitMmu() [ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c]
>>> ArmPlatformGetVirtualMemoryMap() [ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c]
>>> //
>>> // consume PcdSystemMemorySize
>>> //
>>>
>>> Here we have two ArmVirtPlatformLib actions:
>>>
>>> - The "PCD consumption" half of that has been moved -- well, copied, for
>>> now -- to QemuVirtMemInfoLib, in patch 12/15.
>>>
>>> - And we are now looking for a new home for the "PCD production" half.
>>>
>>
>> Yes
>>
>>>> Putting this code in a ArmVirtMemInfo library constructor is
>>>> problematic as well, given that the implementation uses other
>>>> libraries, among which PcdLib, and so we need to find another way to
>>>> run it before MemoryPeim()
>>>
>>> Hm, this claim could be true :) , but I'm not totally convinced by the
>>> way you put it.
>>>
>>> First off, I notice that
>>> "ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf" does not
>>> spell out PcdLib as a dependency. This is quite bad, because it uses
>>> PCDs.
>>>
>>> However, ultimately, "gEfiPeiPcdPpiGuid" does end up in the final DEPEX
>>> of "MemoryInitPeim.inf", according to the ArmVirtQemu build report file.
>>> This must be due to some of the library instances already pulling in
>>> PeiPcdLib.
>>>
>>> Therefore, if we modify the constructor of QemuVirtMemInfoLib to parse
>>> the DT and to set the PCD, *plus* we spell out PcdLib in the
>>> QemuVirtMemInfoLib INF file, then the ultimate DEPEX for the
>>> MemoryInitPeim module should remain the same. And, the PeiPcdLib
>>> constructor should run before the QemuVirtMemInfoLib constructor
>>> (parsing the DT and setting the PCD).
>>>
>>> What's wrong with this argument?
>>>
>>
>> I guess you’re right. Direct dependencies between libraries with constructors are handled correctly by the tools, I simply managed to confuse myself due to the issues with transitive dependencies which you surely remember.
>
> Right, I suspected that this experience was in the background. If I
> remember correctly, the issue was when some libraries had constructors
> while some others had none (and required explicit init function calls
> instead). In some cases this mixing was not possible to avoid due to
> circular dependencies between constructors, but in turn the explicit
> calls didn't get ordered right, or some such. *shudder* :)
>
The core of the issue is that transitive library dependencies are not
honoured in the ordering of constructor invocations if they pass
through a library that has no constructor itself.
I.e., libA with a constructor
depending on libB with no constructor
depending on libC with a constructor
Currently, libA's constructor may be called before libC's constructor,
which is clearly a bug, and which is the reason why I /think/ we
generally shouldn't be relying on other libraries in constructor
implementations.
>>
>>>> So instead, create a separate PEIM that encapsulates the
>>>> ArmVirtMemInfo code and exposes it via a PPI. Another ArmVirtMemInfo
>>>> library class implementation is also provided that depexes on the PPI,
>>>> which ensures that the code is called in the correct order.
>>>
>>> I understand what this does, but I find it very complex.
>>>
>>> Sometimes, whenever we want to make sure that a PCD is set dynamically
>>> "no later than" it's consumed by a "common" module outside of
>>> ArmVirtPkg, we create a dedicated library instance (with all the right
>>> library dependencies spelled out in its INF file), set the PCD in its
>>> constructor, and hook it into the consumer module via NULL class
>>> resolution.
>>>
>>> In this case, we have a lib instance that is used through an actual lib
>>> class already, so I would suggest to add a constructor function, and to
>>> spell out the PcdLib dependency in the INF file.
>>>
>>> ... In fact, this is something that I missed in patch 12 --
>>> QemuVirtMemInfoLib already uses PCDs, but doesn't include "PcdLib" under
>>> [LibraryClasses]. That is a bug inherited from ArmVirtPlatformLib (see
>>> above), and should be fixed. And then we should only need the
>>> constructor.
>>>
>>> What do you think?
>>>
>>
>> I think you’re right.
>>
>> So how do you propose i go about creating two versions of QemuVirtMemInfoLib, only one of which has a constructor? Share the .c file between two infs in the same directory?
>
> Hm, I think I missed the impact on ArmVirtQemuKernel. In the current
> set, its DSC file is only modified in patch 12. (I missed that too.) Are
> any changes necessary for ArmVirtQemuKernel that are not contained in
> this set?
>
> Either way, what you propose above seems to be the standard approach to
> me: use two INF files, keep the bulk of the code in one (shared) C file,
> and add the constructor to another (non-shared) C file (i.e., referenced
> by only one of the INF files). Should the constructor need shared
> utility functions from the shared C file, add an internal header for those.
>
Would you object to having a single .c file, but only declare the
constructor in one of the two .INFs? The code will be pruned anyway,
due to our use of -ffunction-sections
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 13/15] ArmVirtPkg: implement ArmVirtMemInfo PPI, PEIM and library
2017-11-21 20:32 ` Ard Biesheuvel
@ 2017-11-22 8:45 ` Laszlo Ersek
0 siblings, 0 replies; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-22 8:45 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel@lists.01.org, Leif Lindholm
On 11/21/17 21:32, Ard Biesheuvel wrote:
> On 21 November 2017 at 20:17, Laszlo Ersek <lersek@redhat.com>
> wrote:
>> On 11/21/17 18:57, Ard Biesheuvel wrote:
>>> So how do you propose i go about creating two versions of
>>> QemuVirtMemInfoLib, only one of which has a constructor? Share
>>> the .c file between two infs in the same directory?
>>
>> Hm, I think I missed the impact on ArmVirtQemuKernel. In the
>> current set, its DSC file is only modified in patch 12. (I missed
>> that too.) Are any changes necessary for ArmVirtQemuKernel that are
>> not contained in this set?
>>
>> Either way, what you propose above seems to be the standard
>> approach to me: use two INF files, keep the bulk of the code in one
>> (shared) C file, and add the constructor to another (non-shared) C
>> file (i.e., referenced by only one of the INF files). Should the
>> constructor need shared utility functions from the shared C file,
>> add an internal header for those.
>>
>
> Would you object to having a single .c file, but only declare the
> constructor in one of the two .INFs? The code will be pruned anyway,
> due to our use of -ffunction-sections
>
I would frown, but not object. :)
Please add a comment above the constructor function about the non-shared
use.
Thanks,
Laszlo
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 14/15] ArmVirtPkg/ArmVirtMemoryInitPeiLib: move to ArmVirtMemInfoLib
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
` (12 preceding siblings ...)
2017-11-17 16:09 ` [PATCH 13/15] ArmVirtPkg: implement ArmVirtMemInfo PPI, PEIM and library Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 17:51 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 15/15] ArmVirtPkg: remove ArmPlatformLib implementations Ard Biesheuvel
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
Move to the new ArmVirtMemInfoLib library to retrieve DRAM information
from the platform, so that we can phase out ArmPlatformLib going forward.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/ArmVirtQemu.dsc | 7 ++++++-
ArmVirtPkg/ArmVirtQemu.fdf | 1 +
ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c | 4 ++--
ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf | 3 ++-
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index d14a0dd0d1d9..5c59f05187fa 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -48,7 +48,8 @@ [LibraryClasses.common]
QemuFwCfgLib|ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf
- ArmPlatformLib|ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf
+ ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf
+ ArmVirtMemInfoLib|ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
@@ -233,6 +234,10 @@ [Components.common]
<LibraryClasses>
NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
}
+ ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf {
+ <LibraryClasses>
+ ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
+ }
#
# DXE
diff --git a/ArmVirtPkg/ArmVirtQemu.fdf b/ArmVirtPkg/ArmVirtQemu.fdf
index c6a22dc018f3..696dec264639 100644
--- a/ArmVirtPkg/ArmVirtQemu.fdf
+++ b/ArmVirtPkg/ArmVirtQemu.fdf
@@ -109,6 +109,7 @@ [FV.FVMAIN_COMPACT]
INF ArmPkg/Drivers/CpuPei/CpuPei.inf
INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
+ INF ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf
INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
index 6f3e54b7afcb..05afd1282422 100644
--- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
+++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
@@ -16,7 +16,7 @@
#include <PiPei.h>
#include <Library/ArmMmuLib.h>
-#include <Library/ArmPlatformLib.h>
+#include <Library/ArmVirtMemInfoLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
#include <Library/MemoryAllocationLib.h>
@@ -39,7 +39,7 @@ InitMmu (
RETURN_STATUS Status;
// Get Virtual Memory Map from the Platform Library
- ArmPlatformGetVirtualMemoryMap (&MemoryTable);
+ ArmVirtGetMemoryMap (&MemoryTable);
//Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in
// DRAM (even at the top of DRAM as it is the first permanent memory allocation)
diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf
index 028d6fb5ac28..54879d590a8a 100644
--- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf
+++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf
@@ -29,13 +29,14 @@ [Packages]
EmbeddedPkg/EmbeddedPkg.dec
ArmPkg/ArmPkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
+ ArmVirtPkg/ArmVirtPkg.dec
[LibraryClasses]
DebugLib
HobLib
ArmLib
ArmMmuLib
- ArmPlatformLib
+ ArmVirtMemInfoLib
CacheMaintenanceLib
[Guids]
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 14/15] ArmVirtPkg/ArmVirtMemoryInitPeiLib: move to ArmVirtMemInfoLib
2017-11-17 16:09 ` [PATCH 14/15] ArmVirtPkg/ArmVirtMemoryInitPeiLib: move to ArmVirtMemInfoLib Ard Biesheuvel
@ 2017-11-21 17:51 ` Laszlo Ersek
0 siblings, 0 replies; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 17:51 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> Move to the new ArmVirtMemInfoLib library to retrieve DRAM information
> from the platform, so that we can phase out ArmPlatformLib going forward.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/ArmVirtQemu.dsc | 7 ++++++-
> ArmVirtPkg/ArmVirtQemu.fdf | 1 +
> ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c | 4 ++--
> ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf | 3 ++-
> 4 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
> index d14a0dd0d1d9..5c59f05187fa 100644
> --- a/ArmVirtPkg/ArmVirtQemu.dsc
> +++ b/ArmVirtPkg/ArmVirtQemu.dsc
> @@ -48,7 +48,8 @@ [LibraryClasses.common]
> QemuFwCfgLib|ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
> QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf
>
> - ArmPlatformLib|ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf
> + ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf
> + ArmVirtMemInfoLib|ArmVirtPkg/Library/PeiVirtMemInfoLib/PeiVirtMemInfoLib.inf
>
> TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
> NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
> @@ -233,6 +234,10 @@ [Components.common]
> <LibraryClasses>
> NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
> }
> + ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf {
> + <LibraryClasses>
> + ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
> + }
>
> #
> # DXE
> diff --git a/ArmVirtPkg/ArmVirtQemu.fdf b/ArmVirtPkg/ArmVirtQemu.fdf
> index c6a22dc018f3..696dec264639 100644
> --- a/ArmVirtPkg/ArmVirtQemu.fdf
> +++ b/ArmVirtPkg/ArmVirtQemu.fdf
> @@ -109,6 +109,7 @@ [FV.FVMAIN_COMPACT]
> INF ArmPkg/Drivers/CpuPei/CpuPei.inf
> INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
> INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
> + INF ArmVirtPkg/QemuVirtMemInfoPeim/QemuVirtMemInfoPeim.inf
> INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
>
> FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
> diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
> index 6f3e54b7afcb..05afd1282422 100644
> --- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
> +++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
> @@ -16,7 +16,7 @@
> #include <PiPei.h>
>
> #include <Library/ArmMmuLib.h>
> -#include <Library/ArmPlatformLib.h>
> +#include <Library/ArmVirtMemInfoLib.h>
> #include <Library/DebugLib.h>
> #include <Library/HobLib.h>
> #include <Library/MemoryAllocationLib.h>
> @@ -39,7 +39,7 @@ InitMmu (
> RETURN_STATUS Status;
>
> // Get Virtual Memory Map from the Platform Library
> - ArmPlatformGetVirtualMemoryMap (&MemoryTable);
> + ArmVirtGetMemoryMap (&MemoryTable);
>
> //Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in
> // DRAM (even at the top of DRAM as it is the first permanent memory allocation)
> diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf
> index 028d6fb5ac28..54879d590a8a 100644
> --- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf
> +++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf
> @@ -29,13 +29,14 @@ [Packages]
> EmbeddedPkg/EmbeddedPkg.dec
> ArmPkg/ArmPkg.dec
> ArmPlatformPkg/ArmPlatformPkg.dec
> + ArmVirtPkg/ArmVirtPkg.dec
>
> [LibraryClasses]
> DebugLib
> HobLib
> ArmLib
> ArmMmuLib
> - ArmPlatformLib
> + ArmVirtMemInfoLib
> CacheMaintenanceLib
>
> [Guids]
>
This patch is the logical continuation of patch #13, so my feedback
depends on your answer to my patch #13 feedback :)
Thanks
Laszlo
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 15/15] ArmVirtPkg: remove ArmPlatformLib implementations
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
` (13 preceding siblings ...)
2017-11-17 16:09 ` [PATCH 14/15] ArmVirtPkg/ArmVirtMemoryInitPeiLib: move to ArmVirtMemInfoLib Ard Biesheuvel
@ 2017-11-17 16:09 ` Ard Biesheuvel
2017-11-21 17:52 ` Laszlo Ersek
14 siblings, 1 reply; 43+ messages in thread
From: Ard Biesheuvel @ 2017-11-17 16:09 UTC (permalink / raw)
To: edk2-devel, lersek; +Cc: leif.lindholm, Ard Biesheuvel
These libraries are no longer used, so remove them from the tree.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 -
ArmVirtPkg/ArmVirtXen.dsc | 1 -
ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S | 141 -----------------
ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ARM/RelocatableVirtHelper.S | 123 ---------------
ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ArmQemuRelocatablePlatformLib.inf | 64 --------
ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/FdtParser.c | 90 -----------
ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/QemuVirtMem.c | 106 -------------
ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/RelocatableVirt.c | 70 ---------
ArmVirtPkg/Library/ArmVirtPlatformLib/AARCH64/VirtHelper.S | 70 ---------
ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.S | 57 -------
ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.asm | 71 ---------
ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf | 64 --------
ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c | 160 --------------------
ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c | 102 -------------
ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S | 140 -----------------
ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ARM/RelocatableVirtHelper.S | 123 ---------------
ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ArmXenRelocatablePlatformLib.inf | 63 --------
ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/FdtParser.c | 89 -----------
ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/RelocatableVirt.c | 70 ---------
ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/XenVirtMem.c | 82 ----------
20 files changed, 1687 deletions(-)
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index f50d30388cf2..cc2c5a50c925 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -48,7 +48,6 @@ [LibraryClasses.common]
QemuFwCfgLib|ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf
- ArmPlatformLib|ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ArmQemuRelocatablePlatformLib.inf
ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
index 3df684d13cb0..11e073287a84 100644
--- a/ArmVirtPkg/ArmVirtXen.dsc
+++ b/ArmVirtPkg/ArmVirtXen.dsc
@@ -43,7 +43,6 @@ [LibraryClasses]
VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
- ArmPlatformLib|ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ArmXenRelocatablePlatformLib.inf
ArmVirtMemInfoLib|ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
diff --git a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S b/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S
deleted file mode 100644
index ec6955cf0af8..000000000000
--- a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S
+++ /dev/null
@@ -1,141 +0,0 @@
-#
-# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-# Copyright (c) 2016, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# 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 <AsmMacroIoLibV8.h>
-#include <Library/ArmLib.h>
-
-// VOID
-// ArmPlatformPeiBootAction (
-// VOID *DeviceTreeBaseAddress, // passed by loader in x0
-// VOID *ImageBase // passed by FDF trampoline in x1
-// );
-ASM_FUNC(ArmPlatformPeiBootAction)
- //
- // If we are booting from RAM using the Linux kernel boot protocol, x0 will
- // point to the DTB image in memory. Otherwise, use the default value defined
- // by the platform.
- //
- cbnz x0, 0f
- ldr x0, PcdGet64 (PcdDeviceTreeInitialBaseAddress)
-
-0:mov x29, x30 // preserve LR
- mov x28, x0 // preserve DTB pointer
- mov x27, x1 // preserve base of image pointer
-
- //
- // The base of the runtime image has been preserved in x1. Check whether
- // the expected magic number can be found in the header.
- //
- ldr w8, .LArm64LinuxMagic
- ldr w9, [x1, #0x38]
- cmp w8, w9
- bne .Lout
-
- //
- //
- // OK, so far so good. We have confirmed that we likely have a DTB and are
- // booting via the arm64 Linux boot protocol. Update the base-of-image PCD
- // to the actual relocated value, and add the shift of PcdFdBaseAddress to
- // PcdFvBaseAddress as well
- //
- adr x8, PcdGet64 (PcdFdBaseAddress)
- adr x9, PcdGet64 (PcdFvBaseAddress)
- ldr x6, [x8]
- ldr x7, [x9]
- sub x7, x7, x6
- add x7, x7, x1
- str x1, [x8]
- str x7, [x9]
-
- //
- // Discover the memory size and offset from the DTB, and record in the
- // respective PCDs. This will also return false if a corrupt DTB is
- // encountered. Since we are calling a C function, use the window at the
- // beginning of the FD image as a temp stack.
- //
- adr x1, PcdGet64 (PcdSystemMemoryBase)
- adr x2, PcdGet64 (PcdSystemMemorySize)
- mov sp, x7
- bl FindMemnode
- cbz x0, .Lout
-
- //
- // Copy the DTB to the slack space right after the 64 byte arm64/Linux style
- // image header at the base of this image (defined in the FDF), and record the
- // pointer in PcdDeviceTreeInitialBaseAddress.
- //
- adr x8, PcdGet64 (PcdDeviceTreeInitialBaseAddress)
- add x27, x27, #0x40
- str x27, [x8]
-
- mov x0, x27
- mov x1, x28
- bl CopyFdt
-
-.Lout:
- ret x29
-
-.LArm64LinuxMagic:
- .byte 0x41, 0x52, 0x4d, 0x64
-
-//UINTN
-//ArmPlatformGetPrimaryCoreMpId (
-// VOID
-// );
-ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
- MOV32 (w0, FixedPcdGet32 (PcdArmPrimaryCore))
- ret
-
-//UINTN
-//ArmPlatformIsPrimaryCore (
-// IN UINTN MpId
-// );
-ASM_FUNC(ArmPlatformIsPrimaryCore)
- mov x0, #1
- ret
-
-//UINTN
-//ArmPlatformGetCorePosition (
-// IN UINTN MpId
-// );
-// With this function: CorePos = (ClusterId * 4) + CoreId
-ASM_FUNC(ArmPlatformGetCorePosition)
- and x1, x0, #ARM_CORE_MASK
- and x0, x0, #ARM_CLUSTER_MASK
- add x0, x1, x0, LSR #6
- ret
-
-//EFI_PHYSICAL_ADDRESS
-//GetPhysAddrTop (
-// VOID
-// );
-ASM_FUNC(ArmGetPhysAddrTop)
- mrs x0, id_aa64mmfr0_el1
- adr x1, .LPARanges
- and x0, x0, #7
- ldrb w1, [x1, x0]
- mov x0, #1
- lsl x0, x0, x1
- ret
-
-//
-// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
-// physical address space support on this CPU:
-// 0 == 32 bits, 1 == 36 bits, etc etc
-// 6 and 7 are reserved
-//
-.LPARanges:
- .byte 32, 36, 40, 42, 44, 48, -1, -1
-
-ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ARM/RelocatableVirtHelper.S b/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ARM/RelocatableVirtHelper.S
deleted file mode 100644
index 27af98970c16..000000000000
--- a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ARM/RelocatableVirtHelper.S
+++ /dev/null
@@ -1,123 +0,0 @@
-#
-# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-# Copyright (c) 2014-2016, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# 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 <AsmMacroIoLib.h>
-#include <Library/ArmLib.h>
-
-ASM_FUNC(ArmPlatformPeiBootAction)
- //
- // If we are booting from RAM using the Linux kernel boot protocol, r0 will
- // point to the DTB image in memory. Otherwise, use the default value defined
- // by the platform.
- //
- teq r0, #0
- bne 0f
- LDRL (r0, PcdGet64 (PcdDeviceTreeInitialBaseAddress))
-
-0:mov r11, r14 // preserve LR
- mov r10, r0 // preserve DTB pointer
- mov r9, r1 // preserve base of image pointer
-
- //
- // The base of the runtime image has been preserved in r1. Check whether
- // the expected magic number can be found in the header.
- //
- ldr r8, .LArm32LinuxMagic
- ldr r7, [r1, #0x24]
- cmp r7, r8
- bne .Lout
-
- //
- //
- // OK, so far so good. We have confirmed that we likely have a DTB and are
- // booting via the ARM Linux boot protocol. Update the base-of-image PCD
- // to the actual relocated value, and add the shift of PcdFdBaseAddress to
- // PcdFvBaseAddress as well
- //
- ADRL (r8, PcdGet64 (PcdFdBaseAddress))
- ADRL (r7, PcdGet64 (PcdFvBaseAddress))
- ldr r6, [r8]
- ldr r5, [r7]
- sub r5, r5, r6
- add r5, r5, r1
- str r1, [r8]
- str r5, [r7]
-
- //
- // Discover the memory size and offset from the DTB, and record in the
- // respective PCDs. This will also return false if a corrupt DTB is
- // encountered. Since we are calling a C function, use the window at the
- // beginning of the FD image as a temp stack.
- //
- ADRL (r1, PcdGet64 (PcdSystemMemoryBase))
- ADRL (r2, PcdGet64 (PcdSystemMemorySize))
- mov sp, r5
- bl FindMemnode
- teq r0, #0
- beq .Lout
-
- //
- // Copy the DTB to the slack space right after the 64 byte arm64/Linux style
- // image header at the base of this image (defined in the FDF), and record the
- // pointer in PcdDeviceTreeInitialBaseAddress.
- //
- ADRL (r8, PcdGet64 (PcdDeviceTreeInitialBaseAddress))
- add r9, r9, #0x40
- str r9, [r8]
-
- mov r0, r9
- mov r1, r10
- bl CopyFdt
-
-.Lout:
- bx r11
-
-.LArm32LinuxMagic:
- .byte 0x18, 0x28, 0x6f, 0x01
-
-//UINTN
-//ArmPlatformGetPrimaryCoreMpId (
-// VOID
-// );
-ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
- MOV32 (r0, FixedPcdGet32 (PcdArmPrimaryCore))
- bx lr
-
-//UINTN
-//ArmPlatformIsPrimaryCore (
-// IN UINTN MpId
-// );
-ASM_FUNC(ArmPlatformIsPrimaryCore)
- mov r0, #1
- bx lr
-
-//UINTN
-//ArmPlatformGetCorePosition (
-// IN UINTN MpId
-// );
-// With this function: CorePos = (ClusterId * 4) + CoreId
-ASM_FUNC(ArmPlatformGetCorePosition)
- and r1, r0, #ARM_CORE_MASK
- and r0, r0, #ARM_CLUSTER_MASK
- add r0, r1, r0, LSR #6
- bx lr
-
-//EFI_PHYSICAL_ADDRESS
-//GetPhysAddrTop (
-// VOID
-// );
-ASM_FUNC(ArmGetPhysAddrTop)
- mov r0, #0x00000000
- mov r1, #0x10000
- bx lr
diff --git a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ArmQemuRelocatablePlatformLib.inf b/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ArmQemuRelocatablePlatformLib.inf
deleted file mode 100644
index acd523bbd2ce..000000000000
--- a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ArmQemuRelocatablePlatformLib.inf
+++ /dev/null
@@ -1,64 +0,0 @@
-#/* @file
-# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
-# Copyright (c) 2014, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#*/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = ArmXenRelocatablePlatformLib
- FILE_GUID = c8602718-4faa-4119-90ca-cae72509ac4c
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = ArmPlatformLib|SEC PEIM
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
- ArmVirtPkg/ArmVirtPkg.dec
-
-[LibraryClasses]
- IoLib
- ArmLib
- PrintLib
- FdtLib
-
-[Sources.common]
- RelocatableVirt.c
- QemuVirtMem.c
- FdtParser.c
-
-[Sources.AARCH64]
- AARCH64/RelocatableVirtHelper.S
-
-[Sources.ARM]
- ARM/RelocatableVirtHelper.S
-
-[FeaturePcd]
- gEmbeddedTokenSpaceGuid.PcdCacheEnable
- gArmPlatformTokenSpaceGuid.PcdSystemMemoryInitializeInSec
-
-[PatchPcd]
- gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress
- gArmTokenSpaceGuid.PcdFdBaseAddress
- gArmTokenSpaceGuid.PcdFvBaseAddress
- gArmTokenSpaceGuid.PcdSystemMemoryBase
- gArmTokenSpaceGuid.PcdSystemMemorySize
-
-[FixedPcd]
- gArmPlatformTokenSpaceGuid.PcdCoreCount
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
- gArmTokenSpaceGuid.PcdFdSize
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
diff --git a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/FdtParser.c b/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/FdtParser.c
deleted file mode 100644
index afdc81a8839d..000000000000
--- a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/FdtParser.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2015, 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 <Uefi.h>
-#include <Include/libfdt.h>
-
-BOOLEAN
-FindMemnode (
- IN VOID *DeviceTreeBlob,
- OUT UINT64 *SystemMemoryBase,
- OUT UINT64 *SystemMemorySize
- )
-{
- INT32 MemoryNode;
- INT32 AddressCells;
- INT32 SizeCells;
- INT32 Length;
- CONST INT32 *Prop;
-
- if (fdt_check_header (DeviceTreeBlob) != 0) {
- return FALSE;
- }
-
- //
- // Look for a node called "memory" at the lowest level of the tree
- //
- MemoryNode = fdt_path_offset (DeviceTreeBlob, "/memory");
- if (MemoryNode <= 0) {
- return FALSE;
- }
-
- //
- // Retrieve the #address-cells and #size-cells properties
- // from the root node, or use the default if not provided.
- //
- AddressCells = 1;
- SizeCells = 1;
-
- Prop = fdt_getprop (DeviceTreeBlob, 0, "#address-cells", &Length);
- if (Length == 4) {
- AddressCells = fdt32_to_cpu (*Prop);
- }
-
- Prop = fdt_getprop (DeviceTreeBlob, 0, "#size-cells", &Length);
- if (Length == 4) {
- SizeCells = fdt32_to_cpu (*Prop);
- }
-
- //
- // Now find the 'reg' property of the /memory node, and read the first
- // range listed.
- //
- Prop = fdt_getprop (DeviceTreeBlob, MemoryNode, "reg", &Length);
-
- if (Length < (AddressCells + SizeCells) * sizeof (INT32)) {
- return FALSE;
- }
-
- *SystemMemoryBase = fdt32_to_cpu (Prop[0]);
- if (AddressCells > 1) {
- *SystemMemoryBase = (*SystemMemoryBase << 32) | fdt32_to_cpu (Prop[1]);
- }
- Prop += AddressCells;
-
- *SystemMemorySize = fdt32_to_cpu (Prop[0]);
- if (SizeCells > 1) {
- *SystemMemorySize = (*SystemMemorySize << 32) | fdt32_to_cpu (Prop[1]);
- }
-
- return TRUE;
-}
-
-VOID
-CopyFdt (
- IN VOID *FdtDest,
- IN VOID *FdtSource
- )
-{
- fdt_pack(FdtSource);
- CopyMem (FdtDest, FdtSource, fdt_totalsize (FdtSource));
-}
diff --git a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/QemuVirtMem.c b/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/QemuVirtMem.c
deleted file mode 100644
index 2ce5c48d52cf..000000000000
--- a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/QemuVirtMem.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/** @file
-*
-* Copyright (c) 2014, Linaro Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <Library/ArmPlatformLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/PcdLib.h>
-#include <Library/IoLib.h>
-#include <Library/MemoryAllocationLib.h>
-
-// Number of Virtual Memory Map Descriptors
-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
-
-// DDR attributes
-#define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
-#define DDR_ATTRIBUTES_UNCACHED ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED
-
-EFI_PHYSICAL_ADDRESS
-ArmGetPhysAddrTop (
- VOID
- );
-
-/**
- Return the Virtual Memory Map of your platform
-
- This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
- on your platform.
-
- @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
- describing a Physical-to-Virtual Memory
- mapping. This array must be ended by a
- zero-filled entry
-
-**/
-VOID
-ArmPlatformGetVirtualMemoryMap (
- IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap
- )
-{
- ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
-
- ASSERT (VirtualMemoryMap != NULL);
-
- VirtualMemoryTable = AllocatePages (
- EFI_SIZE_TO_PAGES (
- sizeof (ARM_MEMORY_REGION_DESCRIPTOR)
- * MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS
- )
- );
-
- if (VirtualMemoryTable == NULL) {
- DEBUG ((EFI_D_ERROR, "%a: Error: Failed AllocatePages()\n", __FUNCTION__));
- return;
- }
-
- // System DRAM
- VirtualMemoryTable[0].PhysicalBase = PcdGet64 (PcdSystemMemoryBase);
- VirtualMemoryTable[0].VirtualBase = VirtualMemoryTable[0].PhysicalBase;
- VirtualMemoryTable[0].Length = PcdGet64 (PcdSystemMemorySize);
- VirtualMemoryTable[0].Attributes = DDR_ATTRIBUTES_CACHED;
-
- DEBUG ((EFI_D_INFO, "%a: Dumping System DRAM Memory Map:\n"
- "\tPhysicalBase: 0x%lX\n"
- "\tVirtualBase: 0x%lX\n"
- "\tLength: 0x%lX\n",
- __FUNCTION__,
- VirtualMemoryTable[0].PhysicalBase,
- VirtualMemoryTable[0].VirtualBase,
- VirtualMemoryTable[0].Length));
-
- // Peripheral space before DRAM
- VirtualMemoryTable[1].PhysicalBase = 0x0;
- VirtualMemoryTable[1].VirtualBase = 0x0;
- VirtualMemoryTable[1].Length = VirtualMemoryTable[0].PhysicalBase;
- VirtualMemoryTable[1].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
-
- // Peripheral space after DRAM
- VirtualMemoryTable[2].PhysicalBase = VirtualMemoryTable[0].Length + VirtualMemoryTable[1].Length;
- VirtualMemoryTable[2].VirtualBase = VirtualMemoryTable[2].PhysicalBase;
- VirtualMemoryTable[2].Length = MIN (1ULL << FixedPcdGet8 (PcdPrePiCpuMemorySize),
- ArmGetPhysAddrTop ()) -
- VirtualMemoryTable[2].PhysicalBase;
- VirtualMemoryTable[2].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
-
- // Remap the FD region as normal executable memory
- VirtualMemoryTable[3].PhysicalBase = PcdGet64 (PcdFdBaseAddress);
- VirtualMemoryTable[3].VirtualBase = VirtualMemoryTable[3].PhysicalBase;
- VirtualMemoryTable[3].Length = FixedPcdGet32 (PcdFdSize);
- VirtualMemoryTable[3].Attributes = DDR_ATTRIBUTES_CACHED;
-
- // End of Table
- ZeroMem (&VirtualMemoryTable[4], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));
-
- *VirtualMemoryMap = VirtualMemoryTable;
-}
diff --git a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/RelocatableVirt.c b/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/RelocatableVirt.c
deleted file mode 100644
index 6df207733ab2..000000000000
--- a/ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/RelocatableVirt.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-* Copyright (c) 2014, Linaro Limited. All rights reserved.
-* Copyright (c) 2014, Red Hat, Inc.
-*
-*
-* 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 <Library/IoLib.h>
-#include <Library/ArmPlatformLib.h>
-#include <Library/DebugLib.h>
-#include <Pi/PiBootMode.h>
-
-/**
- Return the current Boot Mode
-
- This function returns the boot reason on the platform
-
- @return Return the current Boot Mode of the platform
-
-**/
-EFI_BOOT_MODE
-ArmPlatformGetBootMode (
- VOID
- )
-{
- return BOOT_WITH_FULL_CONFIGURATION;
-}
-
-/**
- This function is called by PrePeiCore, in the SEC phase.
-**/
-RETURN_STATUS
-ArmPlatformInitialize (
- IN UINTN MpId
- )
-{
- //
- // We are relying on ArmPlatformInitializeSystemMemory () being called from
- // InitializeMemory (), which only occurs if the following feature is disabled
- //
- ASSERT (!FeaturePcdGet (PcdSystemMemoryInitializeInSec));
- return RETURN_SUCCESS;
-}
-
-VOID
-ArmPlatformInitializeSystemMemory (
- VOID
- )
-{
-}
-
-VOID
-ArmPlatformGetPlatformPpiList (
- OUT UINTN *PpiListSize,
- OUT EFI_PEI_PPI_DESCRIPTOR **PpiList
- )
-{
- *PpiListSize = 0;
- *PpiList = NULL;
-}
diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/AARCH64/VirtHelper.S b/ArmVirtPkg/Library/ArmVirtPlatformLib/AARCH64/VirtHelper.S
deleted file mode 100644
index 1d8fe25928d8..000000000000
--- a/ArmVirtPkg/Library/ArmVirtPlatformLib/AARCH64/VirtHelper.S
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-# Copyright (c) 2016, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# 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 <AsmMacroIoLibV8.h>
-#include <Library/ArmLib.h>
-
-ASM_FUNC(ArmPlatformPeiBootAction)
- ret
-
-//UINTN
-//ArmPlatformGetPrimaryCoreMpId (
-// VOID
-// );
-ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
- MOV32 (w0, FixedPcdGet32 (PcdArmPrimaryCore))
- ret
-
-//UINTN
-//ArmPlatformIsPrimaryCore (
-// IN UINTN MpId
-// );
-ASM_FUNC(ArmPlatformIsPrimaryCore)
- mov x0, #1
- ret
-
-//UINTN
-//ArmPlatformGetCorePosition (
-// IN UINTN MpId
-// );
-// With this function: CorePos = (ClusterId * 4) + CoreId
-ASM_FUNC(ArmPlatformGetCorePosition)
- and x1, x0, #ARM_CORE_MASK
- and x0, x0, #ARM_CLUSTER_MASK
- add x0, x1, x0, LSR #6
- ret
-
-//EFI_PHYSICAL_ADDRESS
-//GetPhysAddrTop (
-// VOID
-// );
-ASM_FUNC(ArmGetPhysAddrTop)
- mrs x0, id_aa64mmfr0_el1
- adr x1, .LPARanges
- and x0, x0, #7
- ldrb w1, [x1, x0]
- mov x0, #1
- lsl x0, x0, x1
- ret
-
-//
-// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
-// physical address space support on this CPU:
-// 0 == 32 bits, 1 == 36 bits, etc etc
-// 6 and 7 are reserved
-//
-.LPARanges:
- .byte 32, 36, 40, 42, 44, 48, -1, -1
-
-ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.S b/ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.S
deleted file mode 100644
index 4a4db3721072..000000000000
--- a/ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.S
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-# Copyright (c) 2014-2016, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# 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 <AsmMacroIoLib.h>
-#include <Library/ArmLib.h>
-
-ASM_FUNC(ArmPlatformPeiBootAction)
- bx lr
-
-//UINTN
-//ArmPlatformGetPrimaryCoreMpId (
-// VOID
-// );
-ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
- MOV32 (r0, FixedPcdGet32 (PcdArmPrimaryCore))
- bx lr
-
-//UINTN
-//ArmPlatformIsPrimaryCore (
-// IN UINTN MpId
-// );
-ASM_FUNC(ArmPlatformIsPrimaryCore)
- mov r0, #1
- bx lr
-
-//UINTN
-//ArmPlatformGetCorePosition (
-// IN UINTN MpId
-// );
-// With this function: CorePos = (ClusterId * 4) + CoreId
-ASM_FUNC(ArmPlatformGetCorePosition)
- and r1, r0, #ARM_CORE_MASK
- and r0, r0, #ARM_CLUSTER_MASK
- add r0, r1, r0, LSR #6
- bx lr
-
-//EFI_PHYSICAL_ADDRESS
-//GetPhysAddrTop (
-// VOID
-// );
-ASM_FUNC(ArmGetPhysAddrTop)
- mov r0, #0x00000000
- mov r1, #0x10000
- bx lr
-
-ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.asm b/ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.asm
deleted file mode 100644
index b476516f2115..000000000000
--- a/ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.asm
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// Copyright (c) 2011-2014, ARM Limited. All rights reserved.
-// Copyright (c) 2014, Linaro Limited. All rights reserved.
-//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-//
-
-#include <Library/ArmLib.h>
-#include <AutoGen.h>
-
- INCLUDE AsmMacroIoLib.inc
-
- EXPORT ArmPlatformPeiBootAction
- EXPORT ArmPlatformIsPrimaryCore
- EXPORT ArmPlatformGetPrimaryCoreMpId
- EXPORT ArmPlatformGetCorePosition
- EXPORT ArmGetPhysAddrTop
-
- AREA VirtHelper, CODE, READONLY
-
-ArmPlatformPeiBootAction FUNCTION
- bx lr
- ENDFUNC
-
-//UINTN
-//ArmPlatformGetPrimaryCoreMpId (
-// VOID
-// );
-ArmPlatformGetPrimaryCoreMpId FUNCTION
- MOV32 r0, FixedPcdGet32 (PcdArmPrimaryCore)
- bx lr
- ENDFUNC
-
-//UINTN
-//ArmPlatformIsPrimaryCore (
-// IN UINTN MpId
-// );
-ArmPlatformIsPrimaryCore FUNCTION
- mov r0, #1
- bx lr
- ENDFUNC
-
-//UINTN
-//ArmPlatformGetCorePosition (
-// IN UINTN MpId
-// );
-// With this function: CorePos = (ClusterId * 4) + CoreId
-ArmPlatformGetCorePosition FUNCTION
- and r1, r0, #ARM_CORE_MASK
- and r0, r0, #ARM_CLUSTER_MASK
- add r0, r1, r0, LSR #6
- bx lr
- ENDFUNC
-
-//EFI_PHYSICAL_ADDRESS
-//GetPhysAddrTop (
-// VOID
-// );
-ArmGetPhysAddrTop FUNCTION
- mov r0, #0x00000000
- mov r1, #0x10000
- bx lr
- ENDFUNC
-
- END
diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf b/ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf
deleted file mode 100644
index 3cb3fb1f3aea..000000000000
--- a/ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf
+++ /dev/null
@@ -1,64 +0,0 @@
-#/* @file
-# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
-# Copyright (c) 2014, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#*/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = ArmVirtPlatformLib
- FILE_GUID = 00214cc1-06d1-45fe-9700-dca5726ad7bf
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = ArmPlatformLib|SEC PEIM
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
- ArmVirtPkg/ArmVirtPkg.dec
-
-[LibraryClasses]
- IoLib
- MemoryAllocationLib
- ArmLib
- PrintLib
- FdtLib
-
-[Sources.common]
- Virt.c
- VirtMem.c
-
-[Sources.AARCH64]
- AARCH64/VirtHelper.S
-
-[Sources.ARM]
- ARM/VirtHelper.S | GCC
- ARM/VirtHelper.asm | RVCT
-
-[FeaturePcd]
- gEmbeddedTokenSpaceGuid.PcdCacheEnable
- gArmPlatformTokenSpaceGuid.PcdSystemMemoryInitializeInSec
-
-[Pcd]
- gArmTokenSpaceGuid.PcdSystemMemorySize
-
-[FixedPcd]
- gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress
- gArmPlatformTokenSpaceGuid.PcdCoreCount
- gArmTokenSpaceGuid.PcdSystemMemoryBase
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
- gArmTokenSpaceGuid.PcdFdBaseAddress
- gArmTokenSpaceGuid.PcdFdSize
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c b/ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c
deleted file mode 100644
index 140bdde8b2ac..000000000000
--- a/ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-* Copyright (c) 2014, Linaro Limited. All rights reserved.
-* Copyright (c) 2014, Red Hat, Inc.
-*
-*
-* 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 <Library/IoLib.h>
-#include <Library/ArmPlatformLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-#include <libfdt.h>
-#include <Pi/PiBootMode.h>
-#include <Uefi/UefiBaseType.h>
-#include <Uefi/UefiMultiPhase.h>
-
-/**
- Return the current Boot Mode
-
- This function returns the boot reason on the platform
-
- @return Return the current Boot Mode of the platform
-
-**/
-EFI_BOOT_MODE
-ArmPlatformGetBootMode (
- VOID
- )
-{
- return BOOT_WITH_FULL_CONFIGURATION;
-}
-
-/**
- This function is called by PrePeiCore, in the SEC phase.
-**/
-RETURN_STATUS
-ArmPlatformInitialize (
- IN UINTN MpId
- )
-{
- //
- // We are relying on ArmPlatformInitializeSystemMemory () being called from
- // InitializeMemory (), which only occurs if the following feature is disabled
- //
- ASSERT (!FeaturePcdGet (PcdSystemMemoryInitializeInSec));
- return RETURN_SUCCESS;
-}
-
-/**
- Initialize the system (or sometimes called permanent) memory
-
- This memory is generally represented by the DRAM.
-
- This function is called from InitializeMemory() in MemoryInitPeim, in the PEI
- phase.
-**/
-VOID
-ArmPlatformInitializeSystemMemory (
- VOID
- )
-{
- VOID *DeviceTreeBase;
- INT32 Node, Prev;
- UINT64 NewBase, CurBase;
- UINT64 NewSize, CurSize;
- CONST CHAR8 *Type;
- INT32 Len;
- CONST UINT64 *RegProp;
- RETURN_STATUS PcdStatus;
-
- NewBase = 0;
- NewSize = 0;
-
- DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
- ASSERT (DeviceTreeBase != NULL);
-
- //
- // Make sure we have a valid device tree blob
- //
- ASSERT (fdt_check_header (DeviceTreeBase) == 0);
-
- //
- // Look for the lowest memory node
- //
- for (Prev = 0;; Prev = Node) {
- Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
- if (Node < 0) {
- break;
- }
-
- //
- // Check for memory node
- //
- Type = fdt_getprop (DeviceTreeBase, Node, "device_type", &Len);
- if (Type && AsciiStrnCmp (Type, "memory", Len) == 0) {
- //
- // Get the 'reg' property of this node. For now, we will assume
- // two 8 byte quantities for base and size, respectively.
- //
- RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
- if (RegProp != 0 && Len == (2 * sizeof (UINT64))) {
-
- CurBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
- CurSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
-
- DEBUG ((EFI_D_INFO, "%a: System RAM @ 0x%lx - 0x%lx\n",
- __FUNCTION__, CurBase, CurBase + CurSize - 1));
-
- if (NewBase > CurBase || NewBase == 0) {
- NewBase = CurBase;
- NewSize = CurSize;
- }
- } else {
- DEBUG ((EFI_D_ERROR, "%a: Failed to parse FDT memory node\n",
- __FUNCTION__));
- }
- }
- }
-
- //
- // Make sure the start of DRAM matches our expectation
- //
- ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) == NewBase);
- PcdStatus = PcdSet64S (PcdSystemMemorySize, NewSize);
- ASSERT_RETURN_ERROR (PcdStatus);
-
- //
- // We need to make sure that the machine we are running on has at least
- // 128 MB of memory configured, and is currently executing this binary from
- // NOR flash. This prevents a device tree image in DRAM from getting
- // clobbered when our caller installs permanent PEI RAM, before we have a
- // chance of marking its location as reserved or copy it to a freshly
- // allocated block in the permanent PEI RAM in the platform PEIM.
- //
- ASSERT (NewSize >= SIZE_128MB);
- ASSERT (
- (((UINT64)PcdGet64 (PcdFdBaseAddress) +
- (UINT64)PcdGet32 (PcdFdSize)) <= NewBase) ||
- ((UINT64)PcdGet64 (PcdFdBaseAddress) >= (NewBase + NewSize)));
-}
-
-VOID
-ArmPlatformGetPlatformPpiList (
- OUT UINTN *PpiListSize,
- OUT EFI_PEI_PPI_DESCRIPTOR **PpiList
- )
-{
- *PpiListSize = 0;
- *PpiList = NULL;
-}
diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c b/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
deleted file mode 100644
index 4368d05f76ef..000000000000
--- a/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/** @file
-*
-* Copyright (c) 2014, Linaro Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <Library/ArmPlatformLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/PcdLib.h>
-#include <Library/IoLib.h>
-#include <Library/MemoryAllocationLib.h>
-
-// Number of Virtual Memory Map Descriptors
-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
-
-EFI_PHYSICAL_ADDRESS
-ArmGetPhysAddrTop (
- VOID
- );
-
-/**
- Return the Virtual Memory Map of your platform
-
- This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
- on your platform.
-
- @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
- describing a Physical-to-Virtual Memory
- mapping. This array must be ended by a
- zero-filled entry
-
-**/
-VOID
-ArmPlatformGetVirtualMemoryMap (
- IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap
- )
-{
- ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
-
- ASSERT (VirtualMemoryMap != NULL);
-
- VirtualMemoryTable = AllocatePages (
- EFI_SIZE_TO_PAGES (
- sizeof (ARM_MEMORY_REGION_DESCRIPTOR)
- * MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS
- )
- );
-
- if (VirtualMemoryTable == NULL) {
- DEBUG ((EFI_D_ERROR, "%a: Error: Failed AllocatePages()\n", __FUNCTION__));
- return;
- }
-
- // System DRAM
- VirtualMemoryTable[0].PhysicalBase = PcdGet64 (PcdSystemMemoryBase);
- VirtualMemoryTable[0].VirtualBase = VirtualMemoryTable[0].PhysicalBase;
- VirtualMemoryTable[0].Length = PcdGet64 (PcdSystemMemorySize);
- VirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
-
- DEBUG ((EFI_D_INFO, "%a: Dumping System DRAM Memory Map:\n"
- "\tPhysicalBase: 0x%lX\n"
- "\tVirtualBase: 0x%lX\n"
- "\tLength: 0x%lX\n",
- __FUNCTION__,
- VirtualMemoryTable[0].PhysicalBase,
- VirtualMemoryTable[0].VirtualBase,
- VirtualMemoryTable[0].Length));
-
- // Peripheral space before DRAM
- VirtualMemoryTable[1].PhysicalBase = 0x0;
- VirtualMemoryTable[1].VirtualBase = 0x0;
- VirtualMemoryTable[1].Length = VirtualMemoryTable[0].PhysicalBase;
- VirtualMemoryTable[1].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
-
- // Peripheral space after DRAM
- VirtualMemoryTable[2].PhysicalBase = VirtualMemoryTable[0].Length + VirtualMemoryTable[1].Length;
- VirtualMemoryTable[2].VirtualBase = VirtualMemoryTable[2].PhysicalBase;
- VirtualMemoryTable[2].Length = MIN (1ULL << FixedPcdGet8 (PcdPrePiCpuMemorySize),
- ArmGetPhysAddrTop ()) -
- VirtualMemoryTable[2].PhysicalBase;
- VirtualMemoryTable[2].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
-
- // Remap the FD region as normal executable memory
- VirtualMemoryTable[3].PhysicalBase = FixedPcdGet64 (PcdFdBaseAddress);
- VirtualMemoryTable[3].VirtualBase = VirtualMemoryTable[3].PhysicalBase;
- VirtualMemoryTable[3].Length = FixedPcdGet32 (PcdFdSize);
- VirtualMemoryTable[3].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
-
- // End of Table
- ZeroMem (&VirtualMemoryTable[4], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));
-
- *VirtualMemoryMap = VirtualMemoryTable;
-}
diff --git a/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S b/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S
deleted file mode 100644
index ce886378eae6..000000000000
--- a/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S
+++ /dev/null
@@ -1,140 +0,0 @@
-#
-# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-# Copyright (c) 2016, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# 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 <AsmMacroIoLibV8.h>
-#include <Library/ArmLib.h>
-
-// VOID
-// ArmPlatformPeiBootAction (
-// VOID *DeviceTreeBaseAddress, // passed by loader in x0
-// VOID *ImageBase // passed by FDF trampoline in x1
-// );
-ASM_FUNC(ArmPlatformPeiBootAction)
- mov x29, x30 // preserve LR
- mov x28, x0 // preserve DTB pointer
- mov x27, x1 // preserve base of image pointer
-
- //
- // If we are booting from RAM using the Linux kernel boot protocol, x0 will
- // point to the DTB image in memory. Otherwise, we are just coming out of
- // reset, and x0 will be 0.
- //
- cbz x0, .Lout
-
- //
- // The base of the runtime image has been preserved in x1. Check whether
- // the expected magic number can be found in the header.
- //
- ldr w8, .LArm64LinuxMagic
- ldr w9, [x1, #0x38]
- cmp w8, w9
- bne .Lout
-
- //
- //
- // OK, so far so good. We have confirmed that we likely have a DTB and are
- // booting via the arm64 Linux boot protocol. Update the base-of-image PCD
- // to the actual relocated value, and add the shift of PcdFdBaseAddress to
- // PcdFvBaseAddress as well
- //
- adr x8, PcdGet64 (PcdFdBaseAddress)
- adr x9, PcdGet64 (PcdFvBaseAddress)
- ldr x6, [x8]
- ldr x7, [x9]
- sub x7, x7, x6
- add x7, x7, x1
- str x1, [x8]
- str x7, [x9]
-
- //
- // Discover the memory size and offset from the DTB, and record in the
- // respective PCDs. This will also return false if a corrupt DTB is
- // encountered. Since we are calling a C function, use the window at the
- // beginning of the FD image as a temp stack.
- //
- adr x1, PcdGet64 (PcdSystemMemoryBase)
- adr x2, PcdGet64 (PcdSystemMemorySize)
- mov sp, x7
- bl FindMemnode
- cbz x0, .Lout
-
- //
- // Copy the DTB to the slack space right after the 64 byte arm64/Linux style
- // image header at the base of this image (defined in the FDF), and record the
- // pointer in PcdDeviceTreeInitialBaseAddress.
- //
- adr x8, PcdGet64 (PcdDeviceTreeInitialBaseAddress)
- add x27, x27, #0x40
- str x27, [x8]
-
- mov x0, x27
- mov x1, x28
- bl CopyFdt
-
-.Lout:
- ret x29
-
-.LArm64LinuxMagic:
- .byte 0x41, 0x52, 0x4d, 0x64
-
-//UINTN
-//ArmPlatformGetPrimaryCoreMpId (
-// VOID
-// );
-ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
- MOV32 (w0, FixedPcdGet32 (PcdArmPrimaryCore))
- ret
-
-//UINTN
-//ArmPlatformIsPrimaryCore (
-// IN UINTN MpId
-// );
-ASM_FUNC(ArmPlatformIsPrimaryCore)
- mov x0, #1
- ret
-
-//UINTN
-//ArmPlatformGetCorePosition (
-// IN UINTN MpId
-// );
-// With this function: CorePos = (ClusterId * 4) + CoreId
-ASM_FUNC(ArmPlatformGetCorePosition)
- and x1, x0, #ARM_CORE_MASK
- and x0, x0, #ARM_CLUSTER_MASK
- add x0, x1, x0, LSR #6
- ret
-
-//EFI_PHYSICAL_ADDRESS
-//GetPhysAddrTop (
-// VOID
-// );
-ASM_FUNC(ArmGetPhysAddrTop)
- mrs x0, id_aa64mmfr0_el1
- adr x1, .LPARanges
- and x0, x0, #7
- ldrb w1, [x1, x0]
- mov x0, #1
- lsl x0, x0, x1
- ret
-
-//
-// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
-// physical address space support on this CPU:
-// 0 == 32 bits, 1 == 36 bits, etc etc
-// 6 and 7 are reserved
-//
-.LPARanges:
- .byte 32, 36, 40, 42, 44, 48, -1, -1
-
-ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ARM/RelocatableVirtHelper.S b/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ARM/RelocatableVirtHelper.S
deleted file mode 100644
index f264fa1cf731..000000000000
--- a/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ARM/RelocatableVirtHelper.S
+++ /dev/null
@@ -1,123 +0,0 @@
-#
-# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-# Copyright (c) 2014-2016, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# 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 <AsmMacroIoLib.h>
-#include <Library/ArmLib.h>
-
-ASM_FUNC(ArmPlatformPeiBootAction)
- mov r11, r14 // preserve LR
- mov r10, r0 // preserve DTB pointer
- mov r9, r1 // preserve base of image pointer
-
- //
- // If we are booting from RAM using the Linux kernel boot protocol, r0 will
- // point to the DTB image in memory. Otherwise, we are just coming out of
- // reset, and r0 will be 0.
- //
- teq r0, #0
- beq .Lout
-
- //
- // The base of the runtime image has been preserved in r1. Check whether
- // the expected magic number can be found in the header.
- //
- ldr r8, .LArm32LinuxMagic
- ldr r7, [r1, #0x24]
- cmp r7, r8
- bne .Lout
-
- //
- //
- // OK, so far so good. We have confirmed that we likely have a DTB and are
- // booting via the ARM Linux boot protocol. Update the base-of-image PCD
- // to the actual relocated value, and add the shift of PcdFdBaseAddress to
- // PcdFvBaseAddress as well
- //
- ADRL (r8, PcdGet64 (PcdFdBaseAddress))
- ADRL (r7, PcdGet64 (PcdFvBaseAddress))
- ldr r6, [r8]
- ldr r5, [r7]
- sub r5, r5, r6
- add r5, r5, r1
- str r1, [r8]
- str r5, [r7]
-
- //
- // Discover the memory size and offset from the DTB, and record in the
- // respective PCDs. This will also return false if a corrupt DTB is
- // encountered. Since we are calling a C function, use the window at the
- // beginning of the FD image as a temp stack.
- //
- ADRL (r1, PcdGet64 (PcdSystemMemoryBase))
- ADRL (r2, PcdGet64 (PcdSystemMemorySize))
- mov sp, r5
- bl FindMemnode
- teq r0, #0
- beq .Lout
-
- //
- // Copy the DTB to the slack space right after the 64 byte arm64/Linux style
- // image header at the base of this image (defined in the FDF), and record the
- // pointer in PcdDeviceTreeInitialBaseAddress.
- //
- ADRL (r8, PcdGet64 (PcdDeviceTreeInitialBaseAddress))
- add r9, r9, #0x40
- str r9, [r8]
-
- mov r0, r9
- mov r1, r10
- bl CopyFdt
-
-.Lout:
- bx r11
-
-.LArm32LinuxMagic:
- .byte 0x18, 0x28, 0x6f, 0x01
-
-//UINTN
-//ArmPlatformGetPrimaryCoreMpId (
-// VOID
-// );
-ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
- MOV32 (r0, FixedPcdGet32 (PcdArmPrimaryCore))
- bx lr
-
-//UINTN
-//ArmPlatformIsPrimaryCore (
-// IN UINTN MpId
-// );
-ASM_FUNC(ArmPlatformIsPrimaryCore)
- mov r0, #1
- bx lr
-
-//UINTN
-//ArmPlatformGetCorePosition (
-// IN UINTN MpId
-// );
-// With this function: CorePos = (ClusterId * 4) + CoreId
-ASM_FUNC(ArmPlatformGetCorePosition)
- and r1, r0, #ARM_CORE_MASK
- and r0, r0, #ARM_CLUSTER_MASK
- add r0, r1, r0, LSR #6
- bx lr
-
-//EFI_PHYSICAL_ADDRESS
-//GetPhysAddrTop (
-// VOID
-// );
-ASM_FUNC(ArmGetPhysAddrTop)
- mov r0, #0x00000000
- mov r1, #0x10000
- bx lr
-
diff --git a/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ArmXenRelocatablePlatformLib.inf b/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ArmXenRelocatablePlatformLib.inf
deleted file mode 100644
index b8cb24514d4c..000000000000
--- a/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ArmXenRelocatablePlatformLib.inf
+++ /dev/null
@@ -1,63 +0,0 @@
-#/* @file
-# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
-# Copyright (c) 2014, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#*/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = ArmXenRelocatablePlatformLib
- FILE_GUID = c8602718-4faa-4119-90ca-cae72509ac4c
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = ArmPlatformLib|SEC PEIM
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
- ArmVirtPkg/ArmVirtPkg.dec
-
-[LibraryClasses]
- IoLib
- ArmLib
- PrintLib
- FdtLib
-
-[Sources.common]
- RelocatableVirt.c
- XenVirtMem.c
- FdtParser.c
-
-[Sources.AARCH64]
- AARCH64/RelocatableVirtHelper.S
-
-[Sources.ARM]
- ARM/RelocatableVirtHelper.S
-
-[FeaturePcd]
- gEmbeddedTokenSpaceGuid.PcdCacheEnable
- gArmPlatformTokenSpaceGuid.PcdSystemMemoryInitializeInSec
-
-[PatchPcd]
- gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress
- gArmTokenSpaceGuid.PcdFdBaseAddress
- gArmTokenSpaceGuid.PcdFvBaseAddress
- gArmTokenSpaceGuid.PcdSystemMemoryBase
- gArmTokenSpaceGuid.PcdSystemMemorySize
-
-[FixedPcd]
- gArmPlatformTokenSpaceGuid.PcdCoreCount
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
- gArmTokenSpaceGuid.PcdFdSize
diff --git a/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/FdtParser.c b/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/FdtParser.c
deleted file mode 100644
index 38fd5d3ed00c..000000000000
--- a/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/FdtParser.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2015, 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 <Uefi.h>
-#include <Include/libfdt.h>
-
-BOOLEAN
-FindMemnode (
- IN VOID *DeviceTreeBlob,
- OUT UINT64 *SystemMemoryBase,
- OUT UINT64 *SystemMemorySize
- )
-{
- INT32 MemoryNode;
- INT32 AddressCells;
- INT32 SizeCells;
- INT32 Length;
- CONST INT32 *Prop;
-
- if (fdt_check_header (DeviceTreeBlob) != 0) {
- return FALSE;
- }
-
- //
- // Look for a node called "memory" at the lowest level of the tree
- //
- MemoryNode = fdt_path_offset (DeviceTreeBlob, "/memory");
- if (MemoryNode <= 0) {
- return FALSE;
- }
-
- //
- // Retrieve the #address-cells and #size-cells properties
- // from the root node, or use the default if not provided.
- //
- AddressCells = 1;
- SizeCells = 1;
-
- Prop = fdt_getprop (DeviceTreeBlob, 0, "#address-cells", &Length);
- if (Length == 4) {
- AddressCells = fdt32_to_cpu (*Prop);
- }
-
- Prop = fdt_getprop (DeviceTreeBlob, 0, "#size-cells", &Length);
- if (Length == 4) {
- SizeCells = fdt32_to_cpu (*Prop);
- }
-
- //
- // Now find the 'reg' property of the /memory node, and read the first
- // range listed.
- //
- Prop = fdt_getprop (DeviceTreeBlob, MemoryNode, "reg", &Length);
-
- if (Length < (AddressCells + SizeCells) * sizeof (INT32)) {
- return FALSE;
- }
-
- *SystemMemoryBase = fdt32_to_cpu (Prop[0]);
- if (AddressCells > 1) {
- *SystemMemoryBase = (*SystemMemoryBase << 32) | fdt32_to_cpu (Prop[1]);
- }
- Prop += AddressCells;
-
- *SystemMemorySize = fdt32_to_cpu (Prop[0]);
- if (SizeCells > 1) {
- *SystemMemorySize = (*SystemMemorySize << 32) | fdt32_to_cpu (Prop[1]);
- }
-
- return TRUE;
-}
-
-VOID
-CopyFdt (
- IN VOID *FdtDest,
- IN VOID *FdtSource
- )
-{
- CopyMem (FdtDest, FdtSource, fdt_totalsize (FdtSource));
-}
diff --git a/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/RelocatableVirt.c b/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/RelocatableVirt.c
deleted file mode 100644
index 6df207733ab2..000000000000
--- a/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/RelocatableVirt.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-* Copyright (c) 2014, Linaro Limited. All rights reserved.
-* Copyright (c) 2014, Red Hat, Inc.
-*
-*
-* 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 <Library/IoLib.h>
-#include <Library/ArmPlatformLib.h>
-#include <Library/DebugLib.h>
-#include <Pi/PiBootMode.h>
-
-/**
- Return the current Boot Mode
-
- This function returns the boot reason on the platform
-
- @return Return the current Boot Mode of the platform
-
-**/
-EFI_BOOT_MODE
-ArmPlatformGetBootMode (
- VOID
- )
-{
- return BOOT_WITH_FULL_CONFIGURATION;
-}
-
-/**
- This function is called by PrePeiCore, in the SEC phase.
-**/
-RETURN_STATUS
-ArmPlatformInitialize (
- IN UINTN MpId
- )
-{
- //
- // We are relying on ArmPlatformInitializeSystemMemory () being called from
- // InitializeMemory (), which only occurs if the following feature is disabled
- //
- ASSERT (!FeaturePcdGet (PcdSystemMemoryInitializeInSec));
- return RETURN_SUCCESS;
-}
-
-VOID
-ArmPlatformInitializeSystemMemory (
- VOID
- )
-{
-}
-
-VOID
-ArmPlatformGetPlatformPpiList (
- OUT UINTN *PpiListSize,
- OUT EFI_PEI_PPI_DESCRIPTOR **PpiList
- )
-{
- *PpiListSize = 0;
- *PpiList = NULL;
-}
diff --git a/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/XenVirtMem.c b/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/XenVirtMem.c
deleted file mode 100644
index 63090586cf8b..000000000000
--- a/ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/XenVirtMem.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/** @file
-*
-* Copyright (c) 2014, Linaro Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <Library/ArmPlatformLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/PcdLib.h>
-#include <Library/IoLib.h>
-#include <Library/MemoryAllocationLib.h>
-
-// Number of Virtual Memory Map Descriptors
-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 2
-
-// DDR attributes
-#define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
-#define DDR_ATTRIBUTES_UNCACHED ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED
-
-EFI_PHYSICAL_ADDRESS
-ArmGetPhysAddrTop (
- VOID
- );
-
-/**
- Return the Virtual Memory Map of your platform
-
- This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
- on your platform.
-
- @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
- describing a Physical-to-Virtual Memory
- mapping. This array must be ended by a
- zero-filled entry
-
-**/
-VOID
-ArmPlatformGetVirtualMemoryMap (
- IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap
- )
-{
- ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
-
- ASSERT (VirtualMemoryMap != NULL);
-
- VirtualMemoryTable = AllocatePages (
- EFI_SIZE_TO_PAGES (
- sizeof (ARM_MEMORY_REGION_DESCRIPTOR)
- * MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS
- )
- );
-
- if (VirtualMemoryTable == NULL) {
- DEBUG ((EFI_D_ERROR, "%a: Error: Failed AllocatePages()\n", __FUNCTION__));
- return;
- }
-
- //
- // Map the entire physical memory space as cached. The only device
- // we care about is the GIC, which will be stage 2 mapped as a device
- // by the hypervisor, which will override the cached mapping we install
- // here.
- //
- VirtualMemoryTable[0].PhysicalBase = 0x0;
- VirtualMemoryTable[0].VirtualBase = 0x0;
- VirtualMemoryTable[0].Length = ArmGetPhysAddrTop ();
- VirtualMemoryTable[0].Attributes = DDR_ATTRIBUTES_CACHED;
-
- // End of Table
- ZeroMem (&VirtualMemoryTable[1], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));
-
- *VirtualMemoryMap = VirtualMemoryTable;
-}
--
2.11.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 15/15] ArmVirtPkg: remove ArmPlatformLib implementations
2017-11-17 16:09 ` [PATCH 15/15] ArmVirtPkg: remove ArmPlatformLib implementations Ard Biesheuvel
@ 2017-11-21 17:52 ` Laszlo Ersek
0 siblings, 0 replies; 43+ messages in thread
From: Laszlo Ersek @ 2017-11-21 17:52 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel; +Cc: leif.lindholm
On 11/17/17 17:09, Ard Biesheuvel wrote:
> These libraries are no longer used, so remove them from the tree.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 -
> ArmVirtPkg/ArmVirtXen.dsc | 1 -
> ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S | 141 -----------------
> ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ARM/RelocatableVirtHelper.S | 123 ---------------
> ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ArmQemuRelocatablePlatformLib.inf | 64 --------
> ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/FdtParser.c | 90 -----------
> ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/QemuVirtMem.c | 106 -------------
> ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/RelocatableVirt.c | 70 ---------
> ArmVirtPkg/Library/ArmVirtPlatformLib/AARCH64/VirtHelper.S | 70 ---------
> ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.S | 57 -------
> ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.asm | 71 ---------
> ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf | 64 --------
> ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c | 160 --------------------
> ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c | 102 -------------
> ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S | 140 -----------------
> ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ARM/RelocatableVirtHelper.S | 123 ---------------
> ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ArmXenRelocatablePlatformLib.inf | 63 --------
> ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/FdtParser.c | 89 -----------
> ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/RelocatableVirt.c | 70 ---------
> ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/XenVirtMem.c | 82 ----------
> 20 files changed, 1687 deletions(-)
This feels awesome.
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 43+ messages in thread