Skip to content

Commit 2441860

Browse files
kuqin12makubacki
andauthored
Creating a base instance of FFA library (#1508)
## Description Current usage of Rx/Tx buffer is unnecessarily pulling in UEFI framework related data usage, i.e. PEI, DXE, STMM, etc. This is undesirable for components that only needs to use the basic functionalities. - [x] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? - [x] Backport to release branch? ## How This Was Tested This was tested on QEMU SBSA and passed the online build + run. ## Integration Instructions For components that does not need Rx/Tx functionalities, one can use `MdeModulePkg/Library/ArmFfaLib/ArmFfaLibBase.inf` for `ArmFfaLib`. --------- Signed-off-by: kuqin12 <[email protected]> Co-authored-by: Michael Kubacki <[email protected]>
1 parent 77cb7b8 commit 2441860

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/** @file
2+
MU_CHANGE - This file is originally sourced from ArmFfaStandaloneMmLib, with
3+
Rx/Tx-related APIs removed to focus exclusively on FFA primitives.
4+
5+
Provides FF-A ABI Library used in all environments.
6+
7+
Copyright (c) 2024, Arm Limited. All rights reserved.<BR>
8+
SPDX-License-Identifier: BSD-2-Clause-Patent
9+
10+
@par Glossary:
11+
- FF-A - Firmware Framework for Arm A-profile
12+
13+
@par Reference(s):
14+
- Arm Firmware Framework for Arm A-Profile [https://developer.arm.com/documentation/den0077/latest]
15+
16+
**/
17+
18+
#include <Uefi.h>
19+
#include <Pi/PiBootMode.h>
20+
#include <Pi/PiHob.h>
21+
22+
#include <Library/DebugLib.h>
23+
24+
#include "ArmFfaCommon.h"
25+
26+
/**
27+
ArmFfaLib Constructor.
28+
29+
@retval EFI_SUCCESS Success
30+
@retval Others Error
31+
32+
**/
33+
EFI_STATUS
34+
EFIAPI
35+
ArmFfaLibBaseConstructor (
36+
VOID
37+
)
38+
{
39+
EFI_STATUS Status;
40+
41+
Status = ArmFfaLibCommonInit ();
42+
if (Status == EFI_UNSUPPORTED) {
43+
/*
44+
* EFI_UNSUPPORTED means FF-A interface isn't available.
45+
* However, for Standalone MM modules, FF-A availability is not required.
46+
* i.e. Standalone MM could use SpmMm as a legitimate protocol.
47+
* Thus, returning EFI_SUCCESS here to avoid the entrypoint to assert.
48+
*/
49+
return EFI_SUCCESS;
50+
}
51+
52+
if (EFI_ERROR (Status)) {
53+
DEBUG ((DEBUG_ERROR, "%a failed. Status = %r\n", __func__, Status));
54+
}
55+
56+
return Status;
57+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## @file
2+
# MU_CHANGE - This file is originally sourced from ArmFfaStandaloneMmLib, with
3+
# Rx/Tx-related APIs removed to focus exclusively on FFA primitives.
4+
# Provides FF-A ABI Library used in all environments.
5+
#
6+
# Copyright (c) 2024, Arm Limited. All rights reserved.<BR>
7+
#
8+
# SPDX-License-Identifier: BSD-2-Clause-Patent
9+
##
10+
11+
[Defines]
12+
INF_VERSION = 0x0001001B
13+
BASE_NAME = ArmFfaLibBase
14+
FILE_GUID = D79FF75E-AD0A-4074-A335-2084533744AF
15+
MODULE_TYPE = BASE
16+
VERSION_STRING = 1.0
17+
PI_SPECIFICATION_VERSION = 0x00010032
18+
LIBRARY_CLASS = ArmFfaLib
19+
CONSTRUCTOR = ArmFfaLibBaseConstructor
20+
21+
[Sources]
22+
ArmFfaCommon.h
23+
ArmFfaCommon.c
24+
ArmFfaLibBase.c
25+
26+
[Packages]
27+
MdePkg/MdePkg.dec
28+
MdeModulePkg/MdeModulePkg.dec
29+
30+
[LibraryClasses]
31+
ArmSmcLib
32+
ArmSvcLib
33+
BaseLib
34+
BaseMemoryLib
35+
DebugLib
36+
HobLib
37+
PcdLib
38+
MemoryAllocationLib
39+
TimerLib
40+
41+
[Pcd]
42+
gEfiMdeModulePkgTokenSpaceGuid.PcdFfaLibConduitSmc
43+
gEfiMdeModulePkgTokenSpaceGuid.PcdFfaTxRxPageCount
44+
45+
[Guids]
46+
gArmFfaRxTxBufferInfoGuid

MdeModulePkg/MdeModulePkg.dsc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,5 +599,6 @@
599599
MdeModulePkg/Library/ArmFfaLib/ArmFfaDxeLib.inf
600600
MdeModulePkg/Library/ArmFfaLib/ArmFfaStandaloneMmCoreLib.inf
601601
MdeModulePkg/Library/ArmFfaLib/ArmFfaStandaloneMmLib.inf
602+
MdeModulePkg/Library/ArmFfaLib/ArmFfaLibBase.inf # MU_CHANGE
602603

603604
[BuildOptions]

0 commit comments

Comments
 (0)