From: "Marcin Juszkiewicz" <marcin.juszkiewicz@linaro.org>
To: devel@edk2.groups.io
Cc: Leif Lindholm <quic_llindhol@quicinc.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Graeme Gregory <graeme@xora.org.uk>,
Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Subject: [edk2-devel] [PATCH edk2-platforms 2/3] SbsaQemu: move from ArmSmcLib to ArmMonitorLib
Date: Thu, 08 Aug 2024 16:20:58 +0200 [thread overview]
Message-ID: <20240808-move-from-armsmclib-to-armmonitorlib-v1-2-de5f744a272c@linaro.org> (raw)
In-Reply-To: <20240808-move-from-armsmclib-to-armmonitorlib-v1-0-de5f744a272c@linaro.org>
ArmMonitorLib allows to use 18 registers are both arguments and results.
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
.../SbsaQemuHardwareInfoLib.inf | 2 +-
.../SbsaQemuHardwareInfoLib.c | 75 ++++++++++----------
2 files changed, 37 insertions(+), 40 deletions(-)
diff --git a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.inf b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.inf
index 58a9c03f18b8..dd920546b11a 100644
--- a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.inf
+++ b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.inf
@@ -25,7 +25,7 @@ [Packages]
Silicon/Qemu/SbsaQemu/SbsaQemu.dec
[LibraryClasses]
- ArmSmcLib
+ ArmMonitorLib
ResetSystemLib
[Pcd]
diff --git a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.c b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.c
index 1d5291cf5b28..cd9db02ba9fe 100644
--- a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.c
+++ b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.c
@@ -7,7 +7,6 @@
*
**/
-#include <Library/ArmSmcLib.h>
#include <Library/ArmMonitorLib.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
@@ -24,18 +23,19 @@ GetCpuCount (
VOID
)
{
- UINTN Arg0;
- UINTN SmcResult;
+ ARM_MONITOR_ARGS SmcArgs;
- SmcResult = ArmCallSmc0 (SIP_SVC_GET_CPU_COUNT, &Arg0, NULL, NULL);
- if (SmcResult != SMC_SIP_CALL_SUCCESS) {
+ SmcArgs.Arg0 = SIP_SVC_GET_CPU_COUNT;
+ ArmMonitorCall (&SmcArgs);
+
+ if (SmcArgs.Arg0 != SMC_SIP_CALL_SUCCESS) {
DEBUG ((DEBUG_ERROR, "%a: SIP_SVC_GET_CPU_COUNT call failed. We have no cpu information.\n", __FUNCTION__));
ResetShutdown ();
}
- DEBUG ((DEBUG_INFO, "%a: We have %d cpus.\n", __FUNCTION__, Arg0));
+ DEBUG ((DEBUG_INFO, "%a: We have %d cpus.\n", __FUNCTION__, SmcArgs.Arg1));
- return Arg0;
+ return SmcArgs.Arg1;
}
/**
@@ -50,21 +50,20 @@ GetMpidr (
IN UINTN CpuId
)
{
- UINTN SmcResult;
- UINTN Arg0;
- UINTN Arg1;
+ ARM_MONITOR_ARGS SmcArgs;
- Arg0 = CpuId;
+ SmcArgs.Arg0 = SIP_SVC_GET_CPU_NODE;
+ SmcArgs.Arg1 = CpuId;
+ ArmMonitorCall (&SmcArgs);
- SmcResult = ArmCallSmc0 (SIP_SVC_GET_CPU_NODE, &Arg0, &Arg1, NULL);
- if (SmcResult != SMC_SIP_CALL_SUCCESS) {
+ if (SmcArgs.Arg0 != SMC_SIP_CALL_SUCCESS) {
DEBUG ((DEBUG_ERROR, "%a: SIP_SVC_GET_CPU_NODE call failed. We have no MPIDR for CPU%d.\n", __FUNCTION__, CpuId));
ResetShutdown ();
}
- DEBUG ((DEBUG_INFO, "%a: MPIDR for CPU%d: = %d\n", __FUNCTION__, CpuId, Arg1));
+ DEBUG ((DEBUG_INFO, "%a: MPIDR for CPU%d: = %d\n", __FUNCTION__, CpuId, SmcArgs.Arg2));
- return Arg1;
+ return SmcArgs.Arg2;
}
/**
@@ -79,21 +78,20 @@ GetCpuNumaNode (
IN UINTN CpuId
)
{
- UINTN SmcResult;
- UINTN Arg0;
- UINTN Arg1;
+ ARM_MONITOR_ARGS SmcArgs;
- Arg0 = CpuId;
+ SmcArgs.Arg0 = SIP_SVC_GET_CPU_NODE;
+ SmcArgs.Arg1 = CpuId;
+ ArmMonitorCall (&SmcArgs);
- SmcResult = ArmCallSmc0 (SIP_SVC_GET_CPU_NODE, &Arg0, &Arg1, NULL);
- if (SmcResult != SMC_SIP_CALL_SUCCESS) {
+ if (SmcArgs.Arg0 != SMC_SIP_CALL_SUCCESS) {
DEBUG ((DEBUG_ERROR, "%a: SIP_SVC_GET_CPU_NODE call failed. Could not find information for CPU%d.\n", __FUNCTION__, CpuId));
return 0;
}
- DEBUG ((DEBUG_INFO, "%a: NUMA node for CPU%d: = %d\n", __FUNCTION__, CpuId, Arg0));
+ DEBUG ((DEBUG_INFO, "%a: NUMA node for CPU%d: = %d\n", __FUNCTION__, CpuId, SmcArgs.Arg1));
- return Arg0;
+ return SmcArgs.Arg1;
}
UINT32
@@ -101,17 +99,18 @@ GetMemNodeCount (
VOID
)
{
- UINTN SmcResult;
- UINTN Arg0;
+ ARM_MONITOR_ARGS SmcArgs;
- SmcResult = ArmCallSmc0 (SIP_SVC_GET_MEMORY_NODE_COUNT, &Arg0, NULL, NULL);
- if (SmcResult != SMC_SIP_CALL_SUCCESS) {
+ SmcArgs.Arg0 = SIP_SVC_GET_MEMORY_NODE_COUNT;
+ ArmMonitorCall (&SmcArgs);
+
+ if (SmcArgs.Arg0 != SMC_SIP_CALL_SUCCESS) {
DEBUG ((DEBUG_ERROR, "%a: SIP_SVC_GET_MEMORY_NODE_COUNT call failed. We have no memory information.\n", __FUNCTION__));
ResetShutdown ();
}
- DEBUG ((DEBUG_INFO, "%a: The number of the memory nodes is %ld\n", __FUNCTION__, Arg0));
- return (UINT32)Arg0;
+ DEBUG ((DEBUG_INFO, "%a: The number of the memory nodes is %ld\n", __FUNCTION__, SmcArgs.Arg1));
+ return (UINT32)SmcArgs.Arg1;
}
VOID
@@ -120,21 +119,19 @@ GetMemInfo (
OUT MemoryInfo *MemInfo
)
{
- UINTN SmcResult;
- UINTN Arg0;
- UINTN Arg1;
- UINTN Arg2;
+ ARM_MONITOR_ARGS SmcArgs;
- Arg0 = MemoryId;
+ SmcArgs.Arg0 = SIP_SVC_GET_MEMORY_NODE;
+ SmcArgs.Arg1 = MemoryId;
+ ArmMonitorCall (&SmcArgs);
- SmcResult = ArmCallSmc1 (SIP_SVC_GET_MEMORY_NODE, &Arg0, &Arg1, &Arg2);
- if (SmcResult != SMC_SIP_CALL_SUCCESS) {
+ if (SmcArgs.Arg0 != SMC_SIP_CALL_SUCCESS) {
DEBUG ((DEBUG_ERROR, "%a: SIP_SVC_GET_MEMORY_NODE call failed. We have no memory information.\n", __FUNCTION__));
ResetShutdown ();
} else {
- MemInfo->NodeId = Arg0;
- MemInfo->AddressBase = Arg1;
- MemInfo->AddressSize = Arg2;
+ MemInfo->NodeId = SmcArgs.Arg1;
+ MemInfo->AddressBase = SmcArgs.Arg2;
+ MemInfo->AddressSize = SmcArgs.Arg3;
}
DEBUG ((
--
2.45.2
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120297): https://edk2.groups.io/g/devel/message/120297
Mute This Topic: https://groups.io/mt/107790447/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-08-08 14:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-08 14:20 [edk2-devel] [PATCH edk2-platforms 0/3] SbsaQemu: Move from ArmSmcLib to ArmMonitorLib Marcin Juszkiewicz
2024-08-08 14:20 ` [edk2-devel] [PATCH edk2-platforms 1/3] SbsaQemu: move SMC calls to HardwareInfoLib Marcin Juszkiewicz
2024-08-08 14:20 ` Marcin Juszkiewicz [this message]
2024-08-08 14:20 ` [edk2-devel] [PATCH edk2-platforms 3/3] SbsaQemu: drop not needed packages Marcin Juszkiewicz
2024-08-08 16:51 ` [edk2-devel] [PATCH edk2-platforms 0/3] SbsaQemu: Move from ArmSmcLib to ArmMonitorLib Leif Lindholm
2024-08-08 17:53 ` Marcin Juszkiewicz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240808-move-from-armsmclib-to-armmonitorlib-v1-2-de5f744a272c@linaro.org \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox