* [PATCH edk2-platforms v2 0/2] SbsaQemu: get GIC data from QEMU
@ 2023-06-06 9:21 Marcin Juszkiewicz
2023-06-06 9:21 ` [PATCH edk2-platforms v2 1/2] Platform/SbsaQemu: read platform version Marcin Juszkiewicz
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Marcin Juszkiewicz @ 2023-06-06 9:21 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Graeme Gregory, Marcin Juszkiewicz
Those changes make use of recently added SMC calls to get GIC data from
QEMU instead of having them hardcoded. This is a beginning of changing
this platform to be more flexible.
My blog post about our plans to QEMU SBSA Reference Platform:
https://marcin.juszkiewicz.com.pl/2023/05/23/versioning-of-sbsa-ref-machine/
Marcin Juszkiewicz (2):
Platform/SbsaQemu: read platform version
Platform/SbsaQemu: read GIC base from TF-A
Silicon/Qemu/SbsaQemu/SbsaQemu.dec | 3 ++
Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 3 ++
.../SbsaQemuPlatformDxe.inf | 9 +++++
.../Include/IndustryStandard/SbsaQemuSmc.h | 12 ++++++
.../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 37 +++++++++++++++++++
5 files changed, 64 insertions(+)
create mode 100644 Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
--
2.40.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH edk2-platforms v2 1/2] Platform/SbsaQemu: read platform version
2023-06-06 9:21 [PATCH edk2-platforms v2 0/2] SbsaQemu: get GIC data from QEMU Marcin Juszkiewicz
@ 2023-06-06 9:21 ` Marcin Juszkiewicz
2023-06-06 9:21 ` [PATCH edk2-platforms v2 2/2] Platform/SbsaQemu: read GIC base from TF-A Marcin Juszkiewicz
2023-06-26 17:24 ` [PATCH edk2-platforms v2 0/2] SbsaQemu: get GIC data from QEMU Leif Lindholm
2 siblings, 0 replies; 4+ messages in thread
From: Marcin Juszkiewicz @ 2023-06-06 9:21 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Graeme Gregory, Marcin Juszkiewicz
Qemu has versioning for sbsa-ref platform. TF-A reads it from provided
DeviceTree and provides as SMC.
This change adds reading platform version into EDK2.
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
Silicon/Qemu/SbsaQemu/SbsaQemu.dec | 3 +++
Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 3 +++
.../SbsaQemuPlatformDxe.inf | 4 ++++
.../Include/IndustryStandard/SbsaQemuSmc.h | 11 +++++++++++
.../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 19 +++++++++++++++++++
5 files changed, 40 insertions(+)
create mode 100644 Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
index 9448852967b6..5182978cf56d 100644
--- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
+++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
@@ -67,3 +67,6 @@ [PcdsDynamic.common]
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisManufacturer|L""|VOID*|0x0000011B
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L""|VOID*|0x0000011C
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L""|VOID*|0x0000011D
+
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0|UINT32|0x0000011E
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0|UINT32|0x0000011F
diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
index 0bd0df4f0239..b88729ad8ad6 100644
--- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
+++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
@@ -558,6 +558,9 @@ [PcdsDynamicDefault.common]
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L"AT0000"
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L"SK0000"
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0
+
################################################################################
#
# Components Section - list of all EDK II Modules needed by this Platform
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index 21d2135f6d17..cb1826979bd6 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -20,6 +20,7 @@ [Sources]
SbsaQemuPlatformDxe.c
[Packages]
+ ArmPkg/ArmPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
EmbeddedPkg/EmbeddedPkg.dec
MdeModulePkg/MdeModulePkg.dec
@@ -27,6 +28,7 @@ [Packages]
Silicon/Qemu/SbsaQemu/SbsaQemu.dec
[LibraryClasses]
+ ArmSmcLib
PcdLib
DebugLib
NonDiscoverableDeviceRegistrationLib
@@ -36,6 +38,8 @@ [Pcd]
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
[Depex]
TRUE
diff --git a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
new file mode 100644
index 000000000000..5a179f69b629
--- /dev/null
+++ b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
@@ -0,0 +1,11 @@
+/** @file
+*
+* Copyright (c) 2023, Linaro Ltd. All rights reserved.
+*
+* SPDX-License-Identifier: BSD-2-Clause-Patent
+*
+**/
+
+#include <IndustryStandard/ArmStdSmc.h>
+
+#define SIP_SVC_VERSION SMC_SIP_FUNCTION_ID(1)
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index b7270a07abbd..515d18564bd0 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -7,12 +7,14 @@
*
**/
+#include <Library/ArmSmcLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/NonDiscoverableDeviceRegistrationLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
+#include <IndustryStandard/SbsaQemuSmc.h>
#include <Protocol/FdtClient.h>
@@ -26,6 +28,10 @@ InitializeSbsaQemuPlatformDxe (
EFI_STATUS Status;
UINTN Size;
VOID* Base;
+ UINTN Arg0;
+ UINTN Arg1;
+ UINTN SmcResult;
+ RETURN_STATUS Result;
DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", __FUNCTION__));
@@ -51,5 +57,18 @@ InitializeSbsaQemuPlatformDxe (
return Status;
}
+ SmcResult = ArmCallSmc0 (SIP_SVC_VERSION, &Arg0, &Arg1, NULL);
+ if (SmcResult == SMC_ARCH_CALL_SUCCESS)
+ {
+ Result = PcdSet32S (PcdPlatformVersionMajor, Arg0);
+ ASSERT_RETURN_ERROR (Result);
+ Result = PcdSet32S (PcdPlatformVersionMinor, Arg1);
+ ASSERT_RETURN_ERROR (Result);
+ }
+
+ Arg0 = PcdGet32 (PcdPlatformVersionMajor);
+ Arg1 = PcdGet32 (PcdPlatformVersionMinor);
+
+ DEBUG ((DEBUG_INFO, "Platform version: %d.%d\n", Arg0, Arg1));
return EFI_SUCCESS;
}
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH edk2-platforms v2 2/2] Platform/SbsaQemu: read GIC base from TF-A
2023-06-06 9:21 [PATCH edk2-platforms v2 0/2] SbsaQemu: get GIC data from QEMU Marcin Juszkiewicz
2023-06-06 9:21 ` [PATCH edk2-platforms v2 1/2] Platform/SbsaQemu: read platform version Marcin Juszkiewicz
@ 2023-06-06 9:21 ` Marcin Juszkiewicz
2023-06-26 17:24 ` [PATCH edk2-platforms v2 0/2] SbsaQemu: get GIC data from QEMU Leif Lindholm
2 siblings, 0 replies; 4+ messages in thread
From: Marcin Juszkiewicz @ 2023-06-06 9:21 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Graeme Gregory, Marcin Juszkiewicz
Qemu has versioning for sbsa-ref platform. TF-A reads data from provided
DeviceTree and provides as SMC.
This change adds reading GIC base addresses into EDK2.
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
.../SbsaQemuPlatformDxe.inf | 5 +++++
.../Include/IndustryStandard/SbsaQemuSmc.h | 1 +
.../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 18 ++++++++++++++++++
3 files changed, 24 insertions(+)
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index cb1826979bd6..545794a8c7ff 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -40,6 +40,11 @@ [Pcd]
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
+
+ gArmTokenSpaceGuid.PcdGicDistributorBase
+ gArmTokenSpaceGuid.PcdGicRedistributorsBase
+
+
[Depex]
TRUE
diff --git a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
index 5a179f69b629..24ae6e390abd 100644
--- a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
+++ b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
@@ -9,3 +9,4 @@
#include <IndustryStandard/ArmStdSmc.h>
#define SIP_SVC_VERSION SMC_SIP_FUNCTION_ID(1)
+#define SIP_SVC_GET_GIC SMC_SIP_FUNCTION_ID(100)
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index 515d18564bd0..2c4ee54c3e6b 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -70,5 +70,23 @@ InitializeSbsaQemuPlatformDxe (
Arg1 = PcdGet32 (PcdPlatformVersionMinor);
DEBUG ((DEBUG_INFO, "Platform version: %d.%d\n", Arg0, Arg1));
+
+ SmcResult = ArmCallSmc0 (SIP_SVC_GET_GIC, &Arg0, &Arg1, NULL);
+ if (SmcResult == SMC_ARCH_CALL_SUCCESS)
+ {
+ Result = PcdSet64S (PcdGicDistributorBase, Arg0);
+ ASSERT_RETURN_ERROR (Result);
+ Result = PcdSet64S (PcdGicRedistributorsBase, Arg1);
+ ASSERT_RETURN_ERROR (Result);
+ }
+
+ Arg0 = PcdGet64 (PcdGicDistributorBase);
+
+ DEBUG ((DEBUG_INFO, "GICD base: 0x%x\n", Arg0));
+
+ Arg0 = PcdGet64 (PcdGicRedistributorsBase);
+
+ DEBUG ((DEBUG_INFO, "GICR base: 0x%x\n", Arg0));
+
return EFI_SUCCESS;
}
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH edk2-platforms v2 0/2] SbsaQemu: get GIC data from QEMU
2023-06-06 9:21 [PATCH edk2-platforms v2 0/2] SbsaQemu: get GIC data from QEMU Marcin Juszkiewicz
2023-06-06 9:21 ` [PATCH edk2-platforms v2 1/2] Platform/SbsaQemu: read platform version Marcin Juszkiewicz
2023-06-06 9:21 ` [PATCH edk2-platforms v2 2/2] Platform/SbsaQemu: read GIC base from TF-A Marcin Juszkiewicz
@ 2023-06-26 17:24 ` Leif Lindholm
2 siblings, 0 replies; 4+ messages in thread
From: Leif Lindholm @ 2023-06-26 17:24 UTC (permalink / raw)
To: Marcin Juszkiewicz; +Cc: devel, Ard Biesheuvel, Graeme Gregory
On Tue, Jun 06, 2023 at 11:21:23 +0200, Marcin Juszkiewicz wrote:
> Those changes make use of recently added SMC calls to get GIC data from
> QEMU instead of having them hardcoded. This is a beginning of changing
> this platform to be more flexible.
>
> My blog post about our plans to QEMU SBSA Reference Platform:
>
> https://marcin.juszkiewicz.com.pl/2023/05/23/versioning-of-sbsa-ref-machine/
>
> Marcin Juszkiewicz (2):
> Platform/SbsaQemu: read platform version
> Platform/SbsaQemu: read GIC base from TF-A
There are a few style issues in the set:
- { for if statements placed on separate line
- Copyright stanza missing <BR>
- New header file missing include guard.
Since I've been tardy with review, I've addressed these, added
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
and pushed as be2af02a3fb2..1befeabcc86a.
Thanks!
/
Leif
> Silicon/Qemu/SbsaQemu/SbsaQemu.dec | 3 ++
> Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 3 ++
> .../SbsaQemuPlatformDxe.inf | 9 +++++
> .../Include/IndustryStandard/SbsaQemuSmc.h | 12 ++++++
> .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 37 +++++++++++++++++++
> 5 files changed, 64 insertions(+)
> create mode 100644 Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
>
> --
> 2.40.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-26 17:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-06 9:21 [PATCH edk2-platforms v2 0/2] SbsaQemu: get GIC data from QEMU Marcin Juszkiewicz
2023-06-06 9:21 ` [PATCH edk2-platforms v2 1/2] Platform/SbsaQemu: read platform version Marcin Juszkiewicz
2023-06-06 9:21 ` [PATCH edk2-platforms v2 2/2] Platform/SbsaQemu: read GIC base from TF-A Marcin Juszkiewicz
2023-06-26 17:24 ` [PATCH edk2-platforms v2 0/2] SbsaQemu: get GIC data from QEMU Leif Lindholm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox