From: "Michael Kubacki" <mikuback@linux.microsoft.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Sami Mujawar <sami.mujawar@arm.com>
Subject: [edk2-devel] [PATCH v1 1/1] ArmPkg/ArmMmuLib: Use function pointer type
Date: Mon, 27 Nov 2023 18:57:43 -0500 [thread overview]
Message-ID: <20231127235743.1055-1-mikuback@linux.microsoft.com> (raw)
From: Michael Kubacki <michael.kubacki@microsoft.com>
mReplaceLiveEntryFunc is a function pointer but assigned as a VOID*
pointer:
mReplaceLiveEntryFunc = *(VOID **)GET_GUID_HOB_DATA (Hob);
This leads to the Visual Studio warning:
nonstandard extension, function/data pointer conversion in
expression
This change updates the assignment to avoid using a data pointer and
defines a type for the function pointer to succinctly and accurately
refer to the type when it is used in the library code.
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 13 +++--------
ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c | 7 +++---
ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf | 2 ++
ArmPkg/Library/ArmMmuLib/ArmMmuLibInternal.h | 23 ++++++++++++++++++++
ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf | 1 +
5 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
index 1e57e589977e..9d9c623581fe 100644
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
@@ -20,16 +20,9 @@
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
+#include "ArmMmuLibInternal.h"
-STATIC
-VOID (
- EFIAPI *mReplaceLiveEntryFunc
- )(
- IN UINT64 *Entry,
- IN UINT64 Value,
- IN UINT64 RegionStart,
- IN BOOLEAN DisableMmu
- ) = ArmReplaceLiveTranslationEntry;
+STATIC ARM_REPLACE_LIVE_TRANSLATION_ENTRY mReplaceLiveEntryFunc = ArmReplaceLiveTranslationEntry;
STATIC
UINT64
@@ -742,7 +735,7 @@ ArmMmuBaseLibConstructor (
Hob = GetFirstGuidHob (&gArmMmuReplaceLiveTranslationEntryFuncGuid);
if (Hob != NULL) {
- mReplaceLiveEntryFunc = *(VOID **)GET_GUID_HOB_DATA (Hob);
+ mReplaceLiveEntryFunc = *(ARM_REPLACE_LIVE_TRANSLATION_ENTRY *)GET_GUID_HOB_DATA (Hob);
} else {
//
// The ArmReplaceLiveTranslationEntry () helper function may be invoked
diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
index 5f50a605a338..a0c9facdea64 100644
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
@@ -13,6 +13,7 @@
#include <Library/CacheMaintenanceLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
+#include "ArmMmuLibInternal.h"
EFI_STATUS
EFIAPI
@@ -21,9 +22,9 @@ ArmMmuPeiLibConstructor (
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- extern UINT32 ArmReplaceLiveTranslationEntrySize;
- VOID *ArmReplaceLiveTranslationEntryFunc;
- VOID *Hob;
+ extern UINT32 ArmReplaceLiveTranslationEntrySize;
+ ARM_REPLACE_LIVE_TRANSLATION_ENTRY ArmReplaceLiveTranslationEntryFunc;
+ VOID *Hob;
EFI_FV_FILE_INFO FileInfo;
EFI_STATUS Status;
diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
index 57cb71f90ee3..510511bd414f 100644
--- a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
+++ b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
@@ -19,10 +19,12 @@ [Defines.AARCH64]
CONSTRUCTOR = ArmMmuBaseLibConstructor
[Sources.AARCH64]
+ ArmMmuLibInternal.h
AArch64/ArmMmuLibCore.c
AArch64/ArmMmuLibReplaceEntry.S
[Sources.ARM]
+ ArmMmuLibInternal.h
Arm/ArmMmuLibConvert.c
Arm/ArmMmuLibCore.c
Arm/ArmMmuLibUpdate.c
diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuLibInternal.h b/ArmPkg/Library/ArmMmuLib/ArmMmuLibInternal.h
new file mode 100644
index 000000000000..8d3bec525d8e
--- /dev/null
+++ b/ArmPkg/Library/ArmMmuLib/ArmMmuLibInternal.h
@@ -0,0 +1,23 @@
+/** @file
+ Arm MMU library instance internal header file.
+
+ Copyright (C) Microsoft Corporation. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef ARM_MMU_LIB_INTERNAL_H_
+#define ARM_MMU_LIB_INTERNAL_H_
+
+typedef
+VOID(
+ EFIAPI *ARM_REPLACE_LIVE_TRANSLATION_ENTRY
+ )(
+ IN UINT64 *Entry,
+ IN UINT64 Value,
+ IN UINT64 RegionStart,
+ IN BOOLEAN DisableMmu
+ );
+
+#endif
diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
index 02f874a1a994..37424628aa07 100644
--- a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
+++ b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
@@ -17,6 +17,7 @@ [Defines]
CONSTRUCTOR = ArmMmuPeiLibConstructor
[Sources.AARCH64]
+ ArmMmuLibInternal.h
AArch64/ArmMmuLibCore.c
AArch64/ArmMmuPeiLibConstructor.c
AArch64/ArmMmuLibReplaceEntry.S
--
2.42.0.windows.2
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111765): https://edk2.groups.io/g/devel/message/111765
Mute This Topic: https://groups.io/mt/102841630/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next reply other threads:[~2023-11-27 23:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-27 23:57 Michael Kubacki [this message]
2023-11-28 11:03 ` [edk2-devel] [PATCH v1 1/1] ArmPkg/ArmMmuLib: Use function pointer type Ard Biesheuvel
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=20231127235743.1055-1-mikuback@linux.microsoft.com \
--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