TianoCore EDK2 master
Loading...
Searching...
No Matches
ArmVirtQemuMonitorLib.c
Go to the documentation of this file.
1
12#include <PiDxe.h>
13
14#include <Library/BaseLib.h>
15#include <Library/DebugLib.h>
16#include <Library/ArmHvcLib.h>
18#include <Library/ArmSmcLib.h>
20
21#include <Protocol/FdtClient.h>
22
23STATIC UINT32 mArmSmcccMethod;
24
30RETURN_STATUS
31EFIAPI
33 VOID
34 )
35{
36 EFI_STATUS Status;
37 FDT_CLIENT_PROTOCOL *FdtClient;
38 CONST VOID *Prop;
39
40 Status = gBS->LocateProtocol (
41 &gFdtClientProtocolGuid,
42 NULL,
43 (VOID **)&FdtClient
44 );
45 ASSERT_EFI_ERROR (Status);
46
47 Status = FdtClient->FindCompatibleNodeProperty (
48 FdtClient,
49 "arm,psci-0.2",
50 "method",
51 &Prop,
52 NULL
53 );
54 if (EFI_ERROR (Status)) {
55 return Status;
56 }
57
58 if (AsciiStrnCmp (Prop, "hvc", 3) == 0) {
59 mArmSmcccMethod = 1;
60 } else if (AsciiStrnCmp (Prop, "smc", 3) == 0) {
61 mArmSmcccMethod = 2;
62 } else {
63 DEBUG ((
64 DEBUG_ERROR,
65 "%a: Unknown SMCCC method \"%a\"\n",
66 __func__,
67 Prop
68 ));
69 return EFI_NOT_FOUND;
70 }
71
72 return EFI_SUCCESS;
73}
74
82VOID
83EFIAPI
86 )
87{
88 if (mArmSmcccMethod == 1) {
89 ArmCallHvc ((ARM_HVC_ARGS *)Args);
90 } else if (mArmSmcccMethod == 2) {
91 ArmCallSmc ((ARM_SMC_ARGS *)Args);
92 } else {
93 ASSERT ((mArmSmcccMethod == 1) || (mArmSmcccMethod == 2));
94 }
95}
VOID ArmCallHvc(IN OUT ARM_HVC_ARGS *Args)
Definition: ArmHvcLibNull.c:23
VOID ArmCallSmc(IN OUT ARM_SMC_ARGS *Args)
Definition: ArmSmcLibNull.c:14
VOID EFIAPI ArmMonitorCall(IN OUT ARM_MONITOR_ARGS *Args)
RETURN_STATUS EFIAPI ArmVirtQemuMonitorLibConstructor(VOID)
INTN EFIAPI AsciiStrnCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString, IN UINTN Length)
Definition: String.c:872
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS