ArmPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the ArmPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Andrew Fish <afish@apple.com>
This commit is contained in:
committed by
mergify[bot]
parent
7c2a6033c1
commit
429309e0c6
@@ -7,7 +7,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <Base.h>
|
||||
#include <Library/ArmLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
@@ -16,16 +15,15 @@
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/ArmGenericTimerCounterLib.h>
|
||||
|
||||
#define TICKS_PER_MICRO_SEC (PcdGet32 (PcdArmArchTimerFreqInHz)/1000000U)
|
||||
#define TICKS_PER_MICRO_SEC (PcdGet32 (PcdArmArchTimerFreqInHz)/1000000U)
|
||||
|
||||
// Select appropriate multiply function for platform architecture.
|
||||
#ifdef MDE_CPU_ARM
|
||||
#define MULT_U64_X_N MultU64x32
|
||||
#define MULT_U64_X_N MultU64x32
|
||||
#else
|
||||
#define MULT_U64_X_N MultU64x64
|
||||
#define MULT_U64_X_N MultU64x64
|
||||
#endif
|
||||
|
||||
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
TimerConstructor (
|
||||
@@ -36,7 +34,6 @@ TimerConstructor (
|
||||
// Check if the ARM Generic Timer Extension is implemented.
|
||||
//
|
||||
if (ArmIsArchTimerImplemented ()) {
|
||||
|
||||
//
|
||||
// Check if Architectural Timer frequency is pre-determined by the platform
|
||||
// (ie. nonzero).
|
||||
@@ -49,7 +46,7 @@ TimerConstructor (
|
||||
//
|
||||
ASSERT (TICKS_PER_MICRO_SEC);
|
||||
|
||||
#ifdef MDE_CPU_ARM
|
||||
#ifdef MDE_CPU_ARM
|
||||
//
|
||||
// Only set the frequency for ARMv7. We expect the secure firmware to
|
||||
// have already done it.
|
||||
@@ -59,7 +56,8 @@ TimerConstructor (
|
||||
if (ArmHasSecurityExtensions ()) {
|
||||
ArmGenericTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
@@ -68,7 +66,6 @@ TimerConstructor (
|
||||
// If the reset value (0) is returned, just ASSERT.
|
||||
//
|
||||
ASSERT (ArmGenericTimerGetTimerFreq () != 0);
|
||||
|
||||
} else {
|
||||
DEBUG ((DEBUG_ERROR, "ARM Architectural Timer is not available in the CPU, hence this library cannot be used.\n"));
|
||||
ASSERT (0);
|
||||
@@ -90,16 +87,16 @@ EFIAPI
|
||||
GetPlatformTimerFreq (
|
||||
)
|
||||
{
|
||||
UINTN TimerFreq;
|
||||
UINTN TimerFreq;
|
||||
|
||||
TimerFreq = PcdGet32 (PcdArmArchTimerFreqInHz);
|
||||
if (TimerFreq == 0) {
|
||||
TimerFreq = ArmGenericTimerGetTimerFreq ();
|
||||
}
|
||||
|
||||
return TimerFreq;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stalls the CPU for the number of microseconds specified by MicroSeconds.
|
||||
|
||||
@@ -111,11 +108,11 @@ GetPlatformTimerFreq (
|
||||
UINTN
|
||||
EFIAPI
|
||||
MicroSecondDelay (
|
||||
IN UINTN MicroSeconds
|
||||
IN UINTN MicroSeconds
|
||||
)
|
||||
{
|
||||
UINT64 TimerTicks64;
|
||||
UINT64 SystemCounterVal;
|
||||
UINT64 TimerTicks64;
|
||||
UINT64 SystemCounterVal;
|
||||
|
||||
// Calculate counter ticks that represent requested delay:
|
||||
// = MicroSeconds x TICKS_PER_MICRO_SEC
|
||||
@@ -141,7 +138,6 @@ MicroSecondDelay (
|
||||
return MicroSeconds;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stalls the CPU for at least the given number of nanoseconds.
|
||||
|
||||
@@ -158,13 +154,13 @@ MicroSecondDelay (
|
||||
UINTN
|
||||
EFIAPI
|
||||
NanoSecondDelay (
|
||||
IN UINTN NanoSeconds
|
||||
IN UINTN NanoSeconds
|
||||
)
|
||||
{
|
||||
UINTN MicroSeconds;
|
||||
|
||||
// Round up to 1us Tick Number
|
||||
MicroSeconds = NanoSeconds / 1000;
|
||||
MicroSeconds = NanoSeconds / 1000;
|
||||
MicroSeconds += ((NanoSeconds % 1000) == 0) ? 0 : 1;
|
||||
|
||||
MicroSecondDelay (MicroSeconds);
|
||||
@@ -219,13 +215,13 @@ GetPerformanceCounter (
|
||||
UINT64
|
||||
EFIAPI
|
||||
GetPerformanceCounterProperties (
|
||||
OUT UINT64 *StartValue OPTIONAL,
|
||||
OUT UINT64 *EndValue OPTIONAL
|
||||
OUT UINT64 *StartValue OPTIONAL,
|
||||
OUT UINT64 *EndValue OPTIONAL
|
||||
)
|
||||
{
|
||||
if (StartValue != NULL) {
|
||||
// Timer starts at 0
|
||||
*StartValue = (UINT64)0ULL ;
|
||||
*StartValue = (UINT64)0ULL;
|
||||
}
|
||||
|
||||
if (EndValue != NULL) {
|
||||
@@ -250,7 +246,7 @@ GetPerformanceCounterProperties (
|
||||
UINT64
|
||||
EFIAPI
|
||||
GetTimeInNanoSecond (
|
||||
IN UINT64 Ticks
|
||||
IN UINT64 Ticks
|
||||
)
|
||||
{
|
||||
UINT64 NanoSeconds;
|
||||
@@ -267,7 +263,8 @@ GetTimeInNanoSecond (
|
||||
DivU64x32Remainder (
|
||||
Ticks,
|
||||
TimerFreq,
|
||||
&Remainder),
|
||||
&Remainder
|
||||
),
|
||||
1000000000U
|
||||
);
|
||||
|
||||
@@ -277,8 +274,9 @@ GetTimeInNanoSecond (
|
||||
//
|
||||
NanoSeconds += DivU64x32 (
|
||||
MULT_U64_X_N (
|
||||
(UINT64) Remainder,
|
||||
1000000000U),
|
||||
(UINT64)Remainder,
|
||||
1000000000U
|
||||
),
|
||||
TimerFreq
|
||||
);
|
||||
|
||||
|
@@ -20,20 +20,21 @@ CacheRangeOperation (
|
||||
IN UINTN LineLength
|
||||
)
|
||||
{
|
||||
UINTN ArmCacheLineAlignmentMask;
|
||||
UINTN ArmCacheLineAlignmentMask;
|
||||
// Align address (rounding down)
|
||||
UINTN AlignedAddress;
|
||||
UINTN EndAddress;
|
||||
UINTN AlignedAddress;
|
||||
UINTN EndAddress;
|
||||
|
||||
ArmCacheLineAlignmentMask = LineLength - 1;
|
||||
AlignedAddress = (UINTN)Start - ((UINTN)Start & ArmCacheLineAlignmentMask);
|
||||
EndAddress = (UINTN)Start + Length;
|
||||
AlignedAddress = (UINTN)Start - ((UINTN)Start & ArmCacheLineAlignmentMask);
|
||||
EndAddress = (UINTN)Start + Length;
|
||||
|
||||
// Perform the line operation on an address in each cache line
|
||||
while (AlignedAddress < EndAddress) {
|
||||
LineOperation(AlignedAddress);
|
||||
LineOperation (AlignedAddress);
|
||||
AlignedAddress += LineLength;
|
||||
}
|
||||
|
||||
ArmDataSynchronizationBarrier ();
|
||||
}
|
||||
|
||||
@@ -58,15 +59,22 @@ InvalidateDataCache (
|
||||
VOID *
|
||||
EFIAPI
|
||||
InvalidateInstructionCacheRange (
|
||||
IN VOID *Address,
|
||||
IN UINTN Length
|
||||
IN VOID *Address,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
CacheRangeOperation (Address, Length, ArmCleanDataCacheEntryToPoUByMVA,
|
||||
ArmDataCacheLineLength ());
|
||||
CacheRangeOperation (Address, Length,
|
||||
CacheRangeOperation (
|
||||
Address,
|
||||
Length,
|
||||
ArmCleanDataCacheEntryToPoUByMVA,
|
||||
ArmDataCacheLineLength ()
|
||||
);
|
||||
CacheRangeOperation (
|
||||
Address,
|
||||
Length,
|
||||
ArmInvalidateInstructionCacheEntryToPoUByMVA,
|
||||
ArmInstructionCacheLineLength ());
|
||||
ArmInstructionCacheLineLength ()
|
||||
);
|
||||
|
||||
ArmInstructionSynchronizationBarrier ();
|
||||
|
||||
@@ -85,12 +93,16 @@ WriteBackInvalidateDataCache (
|
||||
VOID *
|
||||
EFIAPI
|
||||
WriteBackInvalidateDataCacheRange (
|
||||
IN VOID *Address,
|
||||
IN UINTN Length
|
||||
IN VOID *Address,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
CacheRangeOperation(Address, Length, ArmCleanInvalidateDataCacheEntryByMVA,
|
||||
ArmDataCacheLineLength ());
|
||||
CacheRangeOperation (
|
||||
Address,
|
||||
Length,
|
||||
ArmCleanInvalidateDataCacheEntryByMVA,
|
||||
ArmDataCacheLineLength ()
|
||||
);
|
||||
return Address;
|
||||
}
|
||||
|
||||
@@ -106,23 +118,31 @@ WriteBackDataCache (
|
||||
VOID *
|
||||
EFIAPI
|
||||
WriteBackDataCacheRange (
|
||||
IN VOID *Address,
|
||||
IN UINTN Length
|
||||
IN VOID *Address,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
CacheRangeOperation(Address, Length, ArmCleanDataCacheEntryByMVA,
|
||||
ArmDataCacheLineLength ());
|
||||
CacheRangeOperation (
|
||||
Address,
|
||||
Length,
|
||||
ArmCleanDataCacheEntryByMVA,
|
||||
ArmDataCacheLineLength ()
|
||||
);
|
||||
return Address;
|
||||
}
|
||||
|
||||
VOID *
|
||||
EFIAPI
|
||||
InvalidateDataCacheRange (
|
||||
IN VOID *Address,
|
||||
IN UINTN Length
|
||||
IN VOID *Address,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
CacheRangeOperation(Address, Length, ArmInvalidateDataCacheEntryByMVA,
|
||||
ArmDataCacheLineLength ());
|
||||
CacheRangeOperation (
|
||||
Address,
|
||||
Length,
|
||||
ArmInvalidateDataCacheEntryByMVA,
|
||||
ArmDataCacheLineLength ()
|
||||
);
|
||||
return Address;
|
||||
}
|
||||
|
@@ -26,12 +26,12 @@
|
||||
**/
|
||||
VOID
|
||||
DisassembleInstruction (
|
||||
IN UINT8 **OpCodePtr,
|
||||
IN BOOLEAN Thumb,
|
||||
IN BOOLEAN Extended,
|
||||
IN OUT UINT32 *ItBlock,
|
||||
OUT CHAR8 *Buf,
|
||||
OUT UINTN Size
|
||||
IN UINT8 **OpCodePtr,
|
||||
IN BOOLEAN Thumb,
|
||||
IN BOOLEAN Extended,
|
||||
IN OUT UINT32 *ItBlock,
|
||||
OUT CHAR8 *Buf,
|
||||
OUT UINTN Size
|
||||
)
|
||||
{
|
||||
// Not yet supported for AArch64.
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/ArmDisassemblerLib.h>
|
||||
|
||||
CHAR8 *gCondition[] = {
|
||||
CHAR8 *gCondition[] = {
|
||||
"EQ",
|
||||
"NE",
|
||||
"CS",
|
||||
@@ -34,7 +34,7 @@ CHAR8 *gCondition[] = {
|
||||
|
||||
#define COND(_a) gCondition[((_a) >> 28)]
|
||||
|
||||
CHAR8 *gReg[] = {
|
||||
CHAR8 *gReg[] = {
|
||||
"r0",
|
||||
"r1",
|
||||
"r2",
|
||||
@@ -53,37 +53,36 @@ CHAR8 *gReg[] = {
|
||||
"pc"
|
||||
};
|
||||
|
||||
CHAR8 *gLdmAdr[] = {
|
||||
CHAR8 *gLdmAdr[] = {
|
||||
"DA",
|
||||
"IA",
|
||||
"DB",
|
||||
"IB"
|
||||
};
|
||||
|
||||
CHAR8 *gLdmStack[] = {
|
||||
CHAR8 *gLdmStack[] = {
|
||||
"FA",
|
||||
"FD",
|
||||
"EA",
|
||||
"ED"
|
||||
};
|
||||
|
||||
#define LDM_EXT(_reg, _off) ((_reg == 13) ? gLdmStack[(_off)] : gLdmAdr[(_off)])
|
||||
#define LDM_EXT(_reg, _off) ((_reg == 13) ? gLdmStack[(_off)] : gLdmAdr[(_off)])
|
||||
|
||||
#define SIGN(_U) ((_U) ? "" : "-")
|
||||
#define WRITE(_Write) ((_Write) ? "!" : "")
|
||||
#define BYTE(_B) ((_B) ? "B":"")
|
||||
#define USER(_B) ((_B) ? "^" : "")
|
||||
|
||||
#define SIGN(_U) ((_U) ? "" : "-")
|
||||
#define WRITE(_Write) ((_Write) ? "!" : "")
|
||||
#define BYTE(_B) ((_B) ? "B":"")
|
||||
#define USER(_B) ((_B) ? "^" : "")
|
||||
|
||||
CHAR8 mMregListStr[4*15 + 1];
|
||||
CHAR8 mMregListStr[4*15 + 1];
|
||||
|
||||
CHAR8 *
|
||||
MRegList (
|
||||
UINT32 OpCode
|
||||
)
|
||||
{
|
||||
UINTN Index, Start, End;
|
||||
BOOLEAN First;
|
||||
UINTN Index, Start, End;
|
||||
BOOLEAN First;
|
||||
|
||||
mMregListStr[0] = '\0';
|
||||
AsciiStrCatS (mMregListStr, sizeof mMregListStr, "{");
|
||||
@@ -110,9 +109,11 @@ MRegList (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (First) {
|
||||
AsciiStrCatS (mMregListStr, sizeof mMregListStr, "ERROR");
|
||||
}
|
||||
|
||||
AsciiStrCatS (mMregListStr, sizeof mMregListStr, "}");
|
||||
|
||||
// BugBug: Make caller pass in buffer it is cleaner
|
||||
@@ -129,14 +130,13 @@ FieldMask (
|
||||
|
||||
UINT32
|
||||
RotateRight (
|
||||
IN UINT32 Op,
|
||||
IN UINT32 Shift
|
||||
IN UINT32 Op,
|
||||
IN UINT32 Shift
|
||||
)
|
||||
{
|
||||
return (Op >> Shift) | (Op << (32 - Shift));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Place a disassembly of **OpCodePtr into buffer, and update OpCodePtr to
|
||||
point to next instruction.
|
||||
@@ -152,39 +152,38 @@ RotateRight (
|
||||
**/
|
||||
VOID
|
||||
DisassembleArmInstruction (
|
||||
IN UINT32 **OpCodePtr,
|
||||
OUT CHAR8 *Buf,
|
||||
OUT UINTN Size,
|
||||
IN BOOLEAN Extended
|
||||
IN UINT32 **OpCodePtr,
|
||||
OUT CHAR8 *Buf,
|
||||
OUT UINTN Size,
|
||||
IN BOOLEAN Extended
|
||||
)
|
||||
{
|
||||
UINT32 OpCode;
|
||||
CHAR8 *Type;
|
||||
CHAR8 *Root;
|
||||
BOOLEAN Imm, Pre, Up, WriteBack, Write, Load, Sign, Half;
|
||||
UINT32 Rn, Rd, Rm;
|
||||
UINT32 IMod, Offset8, Offset12;
|
||||
UINT32 Index;
|
||||
UINT32 ShiftImm, Shift;
|
||||
UINT32 OpCode;
|
||||
CHAR8 *Type;
|
||||
CHAR8 *Root;
|
||||
BOOLEAN Imm, Pre, Up, WriteBack, Write, Load, Sign, Half;
|
||||
UINT32 Rn, Rd, Rm;
|
||||
UINT32 IMod, Offset8, Offset12;
|
||||
UINT32 Index;
|
||||
UINT32 ShiftImm, Shift;
|
||||
|
||||
OpCode = **OpCodePtr;
|
||||
|
||||
Imm = (OpCode & BIT25) == BIT25; // I
|
||||
Pre = (OpCode & BIT24) == BIT24; // P
|
||||
Up = (OpCode & BIT23) == BIT23; // U
|
||||
Imm = (OpCode & BIT25) == BIT25; // I
|
||||
Pre = (OpCode & BIT24) == BIT24; // P
|
||||
Up = (OpCode & BIT23) == BIT23; // U
|
||||
WriteBack = (OpCode & BIT22) == BIT22; // B, also called S
|
||||
Write = (OpCode & BIT21) == BIT21; // W
|
||||
Load = (OpCode & BIT20) == BIT20; // L
|
||||
Sign = (OpCode & BIT6) == BIT6; // S
|
||||
Half = (OpCode & BIT5) == BIT5; // H
|
||||
Rn = (OpCode >> 16) & 0xf;
|
||||
Rd = (OpCode >> 12) & 0xf;
|
||||
Rm = (OpCode & 0xf);
|
||||
|
||||
Write = (OpCode & BIT21) == BIT21; // W
|
||||
Load = (OpCode & BIT20) == BIT20; // L
|
||||
Sign = (OpCode & BIT6) == BIT6; // S
|
||||
Half = (OpCode & BIT5) == BIT5; // H
|
||||
Rn = (OpCode >> 16) & 0xf;
|
||||
Rd = (OpCode >> 12) & 0xf;
|
||||
Rm = (OpCode & 0xf);
|
||||
|
||||
if (Extended) {
|
||||
Index = AsciiSPrint (Buf, Size, "0x%08x ", OpCode);
|
||||
Buf += Index;
|
||||
Buf += Index;
|
||||
Size -= Index;
|
||||
}
|
||||
|
||||
@@ -194,9 +193,10 @@ DisassembleArmInstruction (
|
||||
// A4.1.27 LDREX{<cond>} <Rd>, [<Rn>]
|
||||
AsciiSPrint (Buf, Size, "LDREX%a %a, [%a]", COND (OpCode), gReg[Rd], gReg[Rn]);
|
||||
} else {
|
||||
// A4.1.103 STREX{<cond>} <Rd>, <Rm>, [<Rn>]
|
||||
// A4.1.103 STREX{<cond>} <Rd>, <Rm>, [<Rn>]
|
||||
AsciiSPrint (Buf, Size, "STREX%a %a, %a, [%a]", COND (OpCode), gReg[Rd], gReg[Rn], gReg[Rn]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -206,23 +206,25 @@ DisassembleArmInstruction (
|
||||
// A4.1.20 LDM{<cond>}<addressing_mode> <Rn>{!}, <registers>
|
||||
// A4.1.21 LDM{<cond>}<addressing_mode> <Rn>, <registers_without_pc>^
|
||||
// A4.1.22 LDM{<cond>}<addressing_mode> <Rn>{!}, <registers_and_pc>^
|
||||
AsciiSPrint (Buf, Size, "LDM%a%a, %a%a, %a", COND (OpCode), LDM_EXT (Rn ,(OpCode >> 23) & 3), gReg[Rn], WRITE (Write), MRegList (OpCode), USER (WriteBack));
|
||||
AsciiSPrint (Buf, Size, "LDM%a%a, %a%a, %a", COND (OpCode), LDM_EXT (Rn, (OpCode >> 23) & 3), gReg[Rn], WRITE (Write), MRegList (OpCode), USER (WriteBack));
|
||||
} else {
|
||||
// A4.1.97 STM{<cond>}<addressing_mode> <Rn>{!}, <registers>
|
||||
// A4.1.98 STM{<cond>}<addressing_mode> <Rn>, <registers>^
|
||||
AsciiSPrint (Buf, Size, "STM%a%a, %a%a, %a", COND (OpCode), LDM_EXT (Rn ,(OpCode >> 23) & 3), gReg[Rn], WRITE (Write), MRegList (OpCode), USER (WriteBack));
|
||||
AsciiSPrint (Buf, Size, "STM%a%a, %a%a, %a", COND (OpCode), LDM_EXT (Rn, (OpCode >> 23) & 3), gReg[Rn], WRITE (Write), MRegList (OpCode), USER (WriteBack));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// LDR/STR Address Mode 2
|
||||
if ( ((OpCode & 0x0c000000) == 0x04000000) || ((OpCode & 0xfd70f000 ) == 0xf550f000) ) {
|
||||
if (((OpCode & 0x0c000000) == 0x04000000) || ((OpCode & 0xfd70f000) == 0xf550f000)) {
|
||||
Offset12 = OpCode & 0xfff;
|
||||
if ((OpCode & 0xfd70f000 ) == 0xf550f000) {
|
||||
if ((OpCode & 0xfd70f000) == 0xf550f000) {
|
||||
Index = AsciiSPrint (Buf, Size, "PLD");
|
||||
} else {
|
||||
Index = AsciiSPrint (Buf, Size, "%a%a%a%a %a, ", Load ? "LDR" : "STR", COND (OpCode), BYTE (WriteBack), (!(Pre) && Write) ? "T":"", gReg[Rd]);
|
||||
Index = AsciiSPrint (Buf, Size, "%a%a%a%a %a, ", Load ? "LDR" : "STR", COND (OpCode), BYTE (WriteBack), (!(Pre) && Write) ? "T" : "", gReg[Rd]);
|
||||
}
|
||||
|
||||
if (Pre) {
|
||||
if (!Imm) {
|
||||
// A5.2.2 [<Rn>, #+/-<offset_12>]
|
||||
@@ -236,7 +238,7 @@ DisassembleArmInstruction (
|
||||
// A5.2.4 [<Rn>, +/-<Rm>, LSL #<shift_imm>]
|
||||
// A5.2.7 [<Rn>, +/-<Rm>, LSL #<shift_imm>]!
|
||||
ShiftImm = (OpCode >> 7) & 0x1f;
|
||||
Shift = (OpCode >> 5) & 0x3;
|
||||
Shift = (OpCode >> 5) & 0x3;
|
||||
if (Shift == 0x0) {
|
||||
Type = "LSL";
|
||||
} else if (Shift == 0x1) {
|
||||
@@ -255,7 +257,8 @@ DisassembleArmInstruction (
|
||||
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a, #%a%a, %a, #%d]%a", gReg[Rn], SIGN (Up), gReg[Rm], Type, ShiftImm, WRITE (Write));
|
||||
}
|
||||
} else { // !Pre
|
||||
} else {
|
||||
// !Pre
|
||||
if (!Imm) {
|
||||
// A5.2.8 [<Rn>], #+/-<offset_12>
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a0x%x", gReg[Rn], SIGN (Up), Offset12);
|
||||
@@ -265,7 +268,7 @@ DisassembleArmInstruction (
|
||||
} else {
|
||||
// A5.2.10 [<Rn>], +/-<Rm>, LSL #<shift_imm>
|
||||
ShiftImm = (OpCode >> 7) & 0x1f;
|
||||
Shift = (OpCode >> 5) & 0x3;
|
||||
Shift = (OpCode >> 5) & 0x3;
|
||||
|
||||
if (Shift == 0x0) {
|
||||
Type = "LSL";
|
||||
@@ -287,6 +290,7 @@ DisassembleArmInstruction (
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a%a, %a, #%d", gReg[Rn], SIGN (Up), gReg[Rm], Type, ShiftImm);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -313,30 +317,31 @@ DisassembleArmInstruction (
|
||||
|
||||
Index = AsciiSPrint (Buf, Size, Root, COND (OpCode), gReg[Rd]);
|
||||
|
||||
Sign = (OpCode & BIT6) == BIT6;
|
||||
Half = (OpCode & BIT5) == BIT5;
|
||||
Sign = (OpCode & BIT6) == BIT6;
|
||||
Half = (OpCode & BIT5) == BIT5;
|
||||
Offset8 = ((OpCode >> 4) | (OpCode * 0xf)) & 0xff;
|
||||
if (Pre & !Write) {
|
||||
// Immediate offset/index
|
||||
if (WriteBack) {
|
||||
// A5.3.2 [<Rn>, #+/-<offset_8>]
|
||||
// A5.3.4 [<Rn>, #+/-<offset_8>]!
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a, #%a%d]%a", gReg[Rn], SIGN (Up), Offset8, WRITE (Write));
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a, #%a%d]%a", gReg[Rn], SIGN (Up), Offset8, WRITE (Write));
|
||||
} else {
|
||||
// A5.3.3 [<Rn>, +/-<Rm>]
|
||||
// A5.3.5 [<Rn>, +/-<Rm>]!
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a, #%a%]a", gReg[Rn], SIGN (Up), gReg[Rm], WRITE (Write));
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a, #%a%]a", gReg[Rn], SIGN (Up), gReg[Rm], WRITE (Write));
|
||||
}
|
||||
} else {
|
||||
// Register offset/index
|
||||
if (WriteBack) {
|
||||
// A5.3.6 [<Rn>], #+/-<offset_8>
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a%d", gReg[Rn], SIGN (Up), Offset8);
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a%d", gReg[Rn], SIGN (Up), Offset8);
|
||||
} else {
|
||||
// A5.3.7 [<Rn>], +/-<Rm>
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a%a", gReg[Rn], SIGN (Up), gReg[Rm]);
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a%a", gReg[Rn], SIGN (Up), gReg[Rm]);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -370,16 +375,21 @@ DisassembleArmInstruction (
|
||||
if (((OpCode >> 6) & 0x7) == 0) {
|
||||
AsciiSPrint (Buf, Size, "CPS #0x%x", (OpCode & 0x2f));
|
||||
} else {
|
||||
IMod = (OpCode >> 18) & 0x3;
|
||||
Index = AsciiSPrint (Buf, Size, "CPS%a %a%a%a",
|
||||
(IMod == 3) ? "ID":"IE",
|
||||
((OpCode & BIT8) != 0) ? "A":"",
|
||||
((OpCode & BIT7) != 0) ? "I":"",
|
||||
((OpCode & BIT6) != 0) ? "F":"");
|
||||
IMod = (OpCode >> 18) & 0x3;
|
||||
Index = AsciiSPrint (
|
||||
Buf,
|
||||
Size,
|
||||
"CPS%a %a%a%a",
|
||||
(IMod == 3) ? "ID" : "IE",
|
||||
((OpCode & BIT8) != 0) ? "A" : "",
|
||||
((OpCode & BIT7) != 0) ? "I" : "",
|
||||
((OpCode & BIT6) != 0) ? "F" : ""
|
||||
);
|
||||
if ((OpCode & BIT17) != 0) {
|
||||
AsciiSPrint (&Buf[Index], Size - Index, ", #0x%x", OpCode & 0x1f);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -395,16 +405,16 @@ DisassembleArmInstruction (
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ((OpCode & 0x0db00000) == 0x01200000) {
|
||||
// A4.1.38 MSR{<cond>} CPSR_<fields>, #<immediate> MSR{<cond>} CPSR_<fields>, <Rm>
|
||||
if (Imm) {
|
||||
// MSR{<cond>} CPSR_<fields>, #<immediate>
|
||||
AsciiSPrint (Buf, Size, "MRS%a %a_%a, #0x%x", COND (OpCode), WriteBack ? "SPSR" : "CPSR", FieldMask ((OpCode >> 16) & 0xf), RotateRight (OpCode & 0xf, ((OpCode >> 8) & 0xf) *2));
|
||||
AsciiSPrint (Buf, Size, "MRS%a %a_%a, #0x%x", COND (OpCode), WriteBack ? "SPSR" : "CPSR", FieldMask ((OpCode >> 16) & 0xf), RotateRight (OpCode & 0xf, ((OpCode >> 8) & 0xf) *2));
|
||||
} else {
|
||||
// MSR{<cond>} CPSR_<fields>, <Rm>
|
||||
AsciiSPrint (Buf, Size, "MRS%a %a_%a, %a", COND (OpCode), WriteBack ? "SPSR" : "CPSR", gReg[Rd]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -417,35 +427,34 @@ DisassembleArmInstruction (
|
||||
if ((OpCode & 0x0e000000) == 0x0c000000) {
|
||||
// A4.1.19 LDC and A4.1.96 SDC
|
||||
if ((OpCode & 0xf0000000) == 0xf0000000) {
|
||||
Index = AsciiSPrint (Buf, Size, "%a2 0x%x, CR%d, ", Load ? "LDC":"SDC", (OpCode >> 8) & 0xf, Rd);
|
||||
Index = AsciiSPrint (Buf, Size, "%a2 0x%x, CR%d, ", Load ? "LDC" : "SDC", (OpCode >> 8) & 0xf, Rd);
|
||||
} else {
|
||||
Index = AsciiSPrint (Buf, Size, "%a%a 0x%x, CR%d, ", Load ? "LDC":"SDC", COND (OpCode), (OpCode >> 8) & 0xf, Rd);
|
||||
Index = AsciiSPrint (Buf, Size, "%a%a 0x%x, CR%d, ", Load ? "LDC" : "SDC", COND (OpCode), (OpCode >> 8) & 0xf, Rd);
|
||||
}
|
||||
|
||||
if (!Pre) {
|
||||
if (!Write) {
|
||||
// A5.5.5.5 [<Rn>], <option>
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], {0x%x}", gReg[Rn], OpCode & 0xff);
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], {0x%x}", gReg[Rn], OpCode & 0xff);
|
||||
} else {
|
||||
// A.5.5.4 [<Rn>], #+/-<offset_8>*4
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a0x%x*4", gReg[Rn], SIGN (Up), OpCode & 0xff);
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a0x%x*4", gReg[Rn], SIGN (Up), OpCode & 0xff);
|
||||
}
|
||||
} else {
|
||||
// A5.5.5.2 [<Rn>, #+/-<offset_8>*4 ]!
|
||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a, #%a0x%x*4]%a", gReg[Rn], SIGN (Up), OpCode & 0xff, WRITE (Write));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ((OpCode & 0x0f000010) == 0x0e000010) {
|
||||
// A4.1.32 MRC2, MCR2
|
||||
AsciiSPrint (Buf, Size, "%a%a 0x%x, 0x%x, %a, CR%d, CR%d, 0x%x", Load ? "MRC":"MCR", COND (OpCode), (OpCode >> 8) & 0xf, (OpCode >> 20) & 0xf, gReg[Rd], Rn, Rm, (OpCode >> 5) &0x7);
|
||||
AsciiSPrint (Buf, Size, "%a%a 0x%x, 0x%x, %a, CR%d, CR%d, 0x%x", Load ? "MRC" : "MCR", COND (OpCode), (OpCode >> 8) & 0xf, (OpCode >> 20) & 0xf, gReg[Rd], Rn, Rm, (OpCode >> 5) &0x7);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((OpCode & 0x0ff00000) == 0x0c400000) {
|
||||
// A4.1.33 MRRC2, MCRR2
|
||||
AsciiSPrint (Buf, Size, "%a%a 0x%x, 0x%x, %a, %a, CR%d", Load ? "MRRC":"MCRR", COND (OpCode), (OpCode >> 4) & 0xf, (OpCode >> 20) & 0xf, gReg[Rd], gReg[Rn], Rm);
|
||||
AsciiSPrint (Buf, Size, "%a%a 0x%x, 0x%x, %a, %a, CR%d", Load ? "MRRC" : "MCRR", COND (OpCode), (OpCode >> 4) & 0xf, (OpCode >> 20) & 0xf, gReg[Rd], gReg[Rn], Rm);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -454,4 +463,3 @@ DisassembleArmInstruction (
|
||||
*OpCodePtr += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -14,39 +14,39 @@
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Protocol/DebugSupport.h> // for MAX_AARCH64_EXCEPTION
|
||||
|
||||
UINTN gMaxExceptionNumber = MAX_AARCH64_EXCEPTION;
|
||||
EFI_EXCEPTION_CALLBACK gExceptionHandlers[MAX_AARCH64_EXCEPTION + 1] = { 0 };
|
||||
UINTN gMaxExceptionNumber = MAX_AARCH64_EXCEPTION;
|
||||
EFI_EXCEPTION_CALLBACK gExceptionHandlers[MAX_AARCH64_EXCEPTION + 1] = { 0 };
|
||||
EFI_EXCEPTION_CALLBACK gDebuggerExceptionHandlers[MAX_AARCH64_EXCEPTION + 1] = { 0 };
|
||||
PHYSICAL_ADDRESS gExceptionVectorAlignmentMask = ARM_VECTOR_TABLE_ALIGNMENT;
|
||||
UINTN gDebuggerNoHandlerValue = 0; // todo: define for AArch64
|
||||
PHYSICAL_ADDRESS gExceptionVectorAlignmentMask = ARM_VECTOR_TABLE_ALIGNMENT;
|
||||
UINTN gDebuggerNoHandlerValue = 0; // todo: define for AArch64
|
||||
|
||||
#define EL0_STACK_SIZE EFI_PAGES_TO_SIZE(2)
|
||||
STATIC UINTN mNewStackBase[EL0_STACK_SIZE / sizeof (UINTN)];
|
||||
STATIC UINTN mNewStackBase[EL0_STACK_SIZE / sizeof (UINTN)];
|
||||
|
||||
VOID
|
||||
RegisterEl0Stack (
|
||||
IN VOID *Stack
|
||||
IN VOID *Stack
|
||||
);
|
||||
|
||||
RETURN_STATUS
|
||||
ArchVectorConfig (
|
||||
IN UINTN VectorBaseAddress
|
||||
IN UINTN VectorBaseAddress
|
||||
)
|
||||
{
|
||||
UINTN HcrReg;
|
||||
UINTN HcrReg;
|
||||
|
||||
// Round down sp by 16 bytes alignment
|
||||
RegisterEl0Stack (
|
||||
(VOID *)(((UINTN)mNewStackBase + EL0_STACK_SIZE) & ~0xFUL)
|
||||
);
|
||||
|
||||
if (ArmReadCurrentEL() == AARCH64_EL2) {
|
||||
HcrReg = ArmReadHcr();
|
||||
if (ArmReadCurrentEL () == AARCH64_EL2) {
|
||||
HcrReg = ArmReadHcr ();
|
||||
|
||||
// Trap General Exceptions. All exceptions that would be routed to EL1 are routed to EL2
|
||||
HcrReg |= ARM_HCR_TGE;
|
||||
|
||||
ArmWriteHcr(HcrReg);
|
||||
ArmWriteHcr (HcrReg);
|
||||
}
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
|
@@ -17,28 +17,27 @@
|
||||
|
||||
#include <Protocol/DebugSupport.h> // for MAX_ARM_EXCEPTION
|
||||
|
||||
UINTN gMaxExceptionNumber = MAX_ARM_EXCEPTION;
|
||||
EFI_EXCEPTION_CALLBACK gExceptionHandlers[MAX_ARM_EXCEPTION + 1] = { 0 };
|
||||
UINTN gMaxExceptionNumber = MAX_ARM_EXCEPTION;
|
||||
EFI_EXCEPTION_CALLBACK gExceptionHandlers[MAX_ARM_EXCEPTION + 1] = { 0 };
|
||||
EFI_EXCEPTION_CALLBACK gDebuggerExceptionHandlers[MAX_ARM_EXCEPTION + 1] = { 0 };
|
||||
PHYSICAL_ADDRESS gExceptionVectorAlignmentMask = ARM_VECTOR_TABLE_ALIGNMENT;
|
||||
PHYSICAL_ADDRESS gExceptionVectorAlignmentMask = ARM_VECTOR_TABLE_ALIGNMENT;
|
||||
|
||||
// Exception handler contains branch to vector location (jmp $) so no handler
|
||||
// NOTE: This code assumes vectors are ARM and not Thumb code
|
||||
UINTN gDebuggerNoHandlerValue = 0xEAFFFFFE;
|
||||
UINTN gDebuggerNoHandlerValue = 0xEAFFFFFE;
|
||||
|
||||
RETURN_STATUS
|
||||
ArchVectorConfig (
|
||||
IN UINTN VectorBaseAddress
|
||||
IN UINTN VectorBaseAddress
|
||||
)
|
||||
{
|
||||
// if the vector address corresponds to high vectors
|
||||
if (VectorBaseAddress == 0xFFFF0000) {
|
||||
// set SCTLR.V to enable high vectors
|
||||
ArmSetHighVectors();
|
||||
}
|
||||
else {
|
||||
ArmSetHighVectors ();
|
||||
} else {
|
||||
// Set SCTLR.V to 0 to enable VBAR to be used
|
||||
ArmSetLowVectors();
|
||||
ArmSetLowVectors ();
|
||||
}
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
|
@@ -22,37 +22,38 @@
|
||||
|
||||
STATIC
|
||||
RETURN_STATUS
|
||||
CopyExceptionHandlers(
|
||||
IN PHYSICAL_ADDRESS BaseAddress
|
||||
CopyExceptionHandlers (
|
||||
IN PHYSICAL_ADDRESS BaseAddress
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
RegisterExceptionHandler(
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
|
||||
RegisterExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
|
||||
);
|
||||
|
||||
VOID
|
||||
ExceptionHandlersStart(
|
||||
ExceptionHandlersStart (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
ExceptionHandlersEnd(
|
||||
ExceptionHandlersEnd (
|
||||
VOID
|
||||
);
|
||||
|
||||
RETURN_STATUS ArchVectorConfig(
|
||||
IN UINTN VectorBaseAddress
|
||||
RETURN_STATUS
|
||||
ArchVectorConfig (
|
||||
IN UINTN VectorBaseAddress
|
||||
);
|
||||
|
||||
// these globals are provided by the architecture specific source (Arm or AArch64)
|
||||
extern UINTN gMaxExceptionNumber;
|
||||
extern EFI_EXCEPTION_CALLBACK gExceptionHandlers[];
|
||||
extern EFI_EXCEPTION_CALLBACK gDebuggerExceptionHandlers[];
|
||||
extern PHYSICAL_ADDRESS gExceptionVectorAlignmentMask;
|
||||
extern UINTN gDebuggerNoHandlerValue;
|
||||
extern UINTN gMaxExceptionNumber;
|
||||
extern EFI_EXCEPTION_CALLBACK gExceptionHandlers[];
|
||||
extern EFI_EXCEPTION_CALLBACK gDebuggerExceptionHandlers[];
|
||||
extern PHYSICAL_ADDRESS gExceptionVectorAlignmentMask;
|
||||
extern UINTN gDebuggerNoHandlerValue;
|
||||
|
||||
// A compiler flag adjusts the compilation of this library to a variant where
|
||||
// the vectors are relocated (copied) to another location versus using the
|
||||
@@ -60,13 +61,12 @@ extern UINTN gDebuggerNoHandlerValue;
|
||||
// address this at library build time. Since this affects the build of the
|
||||
// library we cannot represent this in a PCD since PCDs are evaluated on
|
||||
// a per-module basis.
|
||||
#if defined(ARM_RELOCATE_VECTORS)
|
||||
STATIC CONST BOOLEAN gArmRelocateVectorTable = TRUE;
|
||||
#if defined (ARM_RELOCATE_VECTORS)
|
||||
STATIC CONST BOOLEAN gArmRelocateVectorTable = TRUE;
|
||||
#else
|
||||
STATIC CONST BOOLEAN gArmRelocateVectorTable = FALSE;
|
||||
STATIC CONST BOOLEAN gArmRelocateVectorTable = FALSE;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
Initializes all CPU exceptions entries and provides the default exception handlers.
|
||||
|
||||
@@ -85,23 +85,21 @@ with default exception handlers.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeCpuExceptionHandlers(
|
||||
IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL
|
||||
InitializeCpuExceptionHandlers (
|
||||
IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL
|
||||
)
|
||||
{
|
||||
RETURN_STATUS Status;
|
||||
UINTN VectorBase;
|
||||
RETURN_STATUS Status;
|
||||
UINTN VectorBase;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
// if we are requested to copy exception handlers to another location
|
||||
if (gArmRelocateVectorTable) {
|
||||
|
||||
VectorBase = PcdGet64(PcdCpuVectorBaseAddress);
|
||||
Status = CopyExceptionHandlers(VectorBase);
|
||||
|
||||
}
|
||||
else { // use VBAR to point to where our exception handlers are
|
||||
VectorBase = PcdGet64 (PcdCpuVectorBaseAddress);
|
||||
Status = CopyExceptionHandlers (VectorBase);
|
||||
} else {
|
||||
// use VBAR to point to where our exception handlers are
|
||||
|
||||
// The vector table must be aligned for the architecture. If this
|
||||
// assertion fails ensure the appropriate FFS alignment is in effect,
|
||||
@@ -110,7 +108,7 @@ InitializeCpuExceptionHandlers(
|
||||
// for AArch64 Align=4K is required. Align=Auto can be used but this
|
||||
// is known to cause an issue with populating the reset vector area
|
||||
// for encapsulated FVs.
|
||||
ASSERT(((UINTN)ExceptionHandlersStart & gExceptionVectorAlignmentMask) == 0);
|
||||
ASSERT (((UINTN)ExceptionHandlersStart & gExceptionVectorAlignmentMask) == 0);
|
||||
|
||||
// We do not copy the Exception Table at PcdGet64(PcdCpuVectorBaseAddress). We just set Vector
|
||||
// Base Address to point into CpuDxe code.
|
||||
@@ -119,12 +117,12 @@ InitializeCpuExceptionHandlers(
|
||||
Status = RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
if (!RETURN_ERROR(Status)) {
|
||||
if (!RETURN_ERROR (Status)) {
|
||||
// call the architecture-specific routine to prepare for the new vector
|
||||
// configuration to take effect
|
||||
ArchVectorConfig(VectorBase);
|
||||
ArchVectorConfig (VectorBase);
|
||||
|
||||
ArmWriteVBar(VectorBase);
|
||||
ArmWriteVBar (VectorBase);
|
||||
}
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
@@ -148,14 +146,14 @@ with default exception handlers.
|
||||
**/
|
||||
STATIC
|
||||
RETURN_STATUS
|
||||
CopyExceptionHandlers(
|
||||
IN PHYSICAL_ADDRESS BaseAddress
|
||||
CopyExceptionHandlers (
|
||||
IN PHYSICAL_ADDRESS BaseAddress
|
||||
)
|
||||
{
|
||||
RETURN_STATUS Status;
|
||||
UINTN Length;
|
||||
UINTN Index;
|
||||
UINT32 *VectorBase;
|
||||
RETURN_STATUS Status;
|
||||
UINTN Length;
|
||||
UINTN Index;
|
||||
UINT32 *VectorBase;
|
||||
|
||||
// ensure that the destination value specifies an address meeting the vector alignment requirements
|
||||
ASSERT ((BaseAddress & gExceptionVectorAlignmentMask) == 0);
|
||||
@@ -167,37 +165,35 @@ CopyExceptionHandlers(
|
||||
|
||||
VectorBase = (UINT32 *)(UINTN)BaseAddress;
|
||||
|
||||
if (FeaturePcdGet(PcdDebuggerExceptionSupport) == TRUE) {
|
||||
if (FeaturePcdGet (PcdDebuggerExceptionSupport) == TRUE) {
|
||||
// Save existing vector table, in case debugger is already hooked in
|
||||
CopyMem((VOID *)gDebuggerExceptionHandlers, (VOID *)VectorBase, sizeof (EFI_EXCEPTION_CALLBACK)* (gMaxExceptionNumber+1));
|
||||
CopyMem ((VOID *)gDebuggerExceptionHandlers, (VOID *)VectorBase, sizeof (EFI_EXCEPTION_CALLBACK)* (gMaxExceptionNumber+1));
|
||||
}
|
||||
|
||||
// Copy our assembly code into the page that contains the exception vectors.
|
||||
CopyMem((VOID *)VectorBase, (VOID *)ExceptionHandlersStart, Length);
|
||||
CopyMem ((VOID *)VectorBase, (VOID *)ExceptionHandlersStart, Length);
|
||||
|
||||
//
|
||||
// Initialize the C entry points for interrupts
|
||||
//
|
||||
for (Index = 0; Index <= gMaxExceptionNumber; Index++) {
|
||||
if (!FeaturePcdGet(PcdDebuggerExceptionSupport) ||
|
||||
(gDebuggerExceptionHandlers[Index] == 0) || (gDebuggerExceptionHandlers[Index] == (VOID *)gDebuggerNoHandlerValue)) {
|
||||
|
||||
Status = RegisterExceptionHandler(Index, NULL);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
}
|
||||
else {
|
||||
if (!FeaturePcdGet (PcdDebuggerExceptionSupport) ||
|
||||
(gDebuggerExceptionHandlers[Index] == 0) || (gDebuggerExceptionHandlers[Index] == (VOID *)gDebuggerNoHandlerValue))
|
||||
{
|
||||
Status = RegisterExceptionHandler (Index, NULL);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
} else {
|
||||
// If the debugger has already hooked put its vector back
|
||||
VectorBase[Index] = (UINT32)(UINTN)gDebuggerExceptionHandlers[Index];
|
||||
}
|
||||
}
|
||||
|
||||
// Flush Caches since we updated executable stuff
|
||||
InvalidateInstructionCacheRange((VOID *)(UINTN)BaseAddress, Length);
|
||||
InvalidateInstructionCacheRange ((VOID *)(UINTN)BaseAddress, Length);
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.
|
||||
|
||||
@@ -216,9 +212,9 @@ with default interrupt/exception handlers.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeCpuInterruptHandlers(
|
||||
IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL
|
||||
)
|
||||
InitializeCpuInterruptHandlers (
|
||||
IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL
|
||||
)
|
||||
{
|
||||
// not needed, this is what the CPU driver is for
|
||||
return EFI_UNSUPPORTED;
|
||||
@@ -250,9 +246,9 @@ previously installed.
|
||||
or this function is not supported.
|
||||
**/
|
||||
RETURN_STATUS
|
||||
RegisterCpuInterruptHandler(
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN EFI_CPU_INTERRUPT_HANDLER ExceptionHandler
|
||||
RegisterCpuInterruptHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN EFI_CPU_INTERRUPT_HANDLER ExceptionHandler
|
||||
)
|
||||
{
|
||||
if (ExceptionType > gMaxExceptionNumber) {
|
||||
@@ -287,19 +283,19 @@ If this parameter is NULL, then the handler will be uninstalled.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
RegisterExceptionHandler(
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
|
||||
RegisterExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
|
||||
)
|
||||
{
|
||||
return RegisterCpuInterruptHandler(ExceptionType, InterruptHandler);
|
||||
return RegisterCpuInterruptHandler (ExceptionType, InterruptHandler);
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
CommonCExceptionHandler(
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
CommonCExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
if (ExceptionType <= gMaxExceptionNumber) {
|
||||
@@ -307,13 +303,12 @@ CommonCExceptionHandler(
|
||||
gExceptionHandlers[ExceptionType](ExceptionType, SystemContext);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
DEBUG((DEBUG_ERROR, "Unknown exception type %d\n", ExceptionType));
|
||||
ASSERT(FALSE);
|
||||
} else {
|
||||
DEBUG ((DEBUG_ERROR, "Unknown exception type %d\n", ExceptionType));
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
DefaultExceptionHandler(ExceptionType, SystemContext);
|
||||
DefaultExceptionHandler (ExceptionType, SystemContext);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,8 +336,8 @@ CommonCExceptionHandler(
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeCpuExceptionHandlersEx (
|
||||
IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL,
|
||||
IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL
|
||||
IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL,
|
||||
IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL
|
||||
)
|
||||
{
|
||||
return InitializeCpuExceptionHandlers (VectorInfo);
|
||||
|
@@ -16,9 +16,9 @@ ArmGenericTimerEnableTimer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN TimerCtrlReg;
|
||||
UINTN TimerCtrlReg;
|
||||
|
||||
TimerCtrlReg = ArmReadCntpCtl ();
|
||||
TimerCtrlReg = ArmReadCntpCtl ();
|
||||
TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
|
||||
ArmWriteCntpCtl (TimerCtrlReg);
|
||||
}
|
||||
@@ -37,9 +37,9 @@ ArmGenericTimerDisableTimer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN TimerCtrlReg;
|
||||
UINTN TimerCtrlReg;
|
||||
|
||||
TimerCtrlReg = ArmReadCntpCtl ();
|
||||
TimerCtrlReg = ArmReadCntpCtl ();
|
||||
TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;
|
||||
ArmWriteCntpCtl (TimerCtrlReg);
|
||||
}
|
||||
@@ -71,11 +71,10 @@ ArmGenericTimerGetTimerVal (
|
||||
return ArmReadCntpTval ();
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmGenericTimerSetTimerVal (
|
||||
IN UINTN Value
|
||||
IN UINTN Value
|
||||
)
|
||||
{
|
||||
ArmWriteCntpTval (Value);
|
||||
@@ -102,7 +101,7 @@ ArmGenericTimerGetTimerCtrlReg (
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmGenericTimerSetTimerCtrlReg (
|
||||
UINTN Value
|
||||
UINTN Value
|
||||
)
|
||||
{
|
||||
ArmWriteCntpCtl (Value);
|
||||
@@ -120,7 +119,7 @@ ArmGenericTimerGetCompareVal (
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmGenericTimerSetCompareVal (
|
||||
IN UINT64 Value
|
||||
IN UINT64 Value
|
||||
)
|
||||
{
|
||||
ArmWriteCntpCval (Value);
|
||||
|
@@ -16,9 +16,9 @@ ArmGenericTimerEnableTimer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN TimerCtrlReg;
|
||||
UINTN TimerCtrlReg;
|
||||
|
||||
TimerCtrlReg = ArmReadCntvCtl ();
|
||||
TimerCtrlReg = ArmReadCntvCtl ();
|
||||
TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
|
||||
ArmWriteCntvCtl (TimerCtrlReg);
|
||||
}
|
||||
@@ -37,9 +37,9 @@ ArmGenericTimerDisableTimer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN TimerCtrlReg;
|
||||
UINTN TimerCtrlReg;
|
||||
|
||||
TimerCtrlReg = ArmReadCntvCtl ();
|
||||
TimerCtrlReg = ArmReadCntvCtl ();
|
||||
TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;
|
||||
ArmWriteCntvCtl (TimerCtrlReg);
|
||||
}
|
||||
@@ -71,11 +71,10 @@ ArmGenericTimerGetTimerVal (
|
||||
return ArmReadCntvTval ();
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmGenericTimerSetTimerVal (
|
||||
IN UINTN Value
|
||||
IN UINTN Value
|
||||
)
|
||||
{
|
||||
ArmWriteCntvTval (Value);
|
||||
@@ -102,7 +101,7 @@ ArmGenericTimerGetTimerCtrlReg (
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmGenericTimerSetTimerCtrlReg (
|
||||
UINTN Value
|
||||
UINTN Value
|
||||
)
|
||||
{
|
||||
ArmWriteCntvCtl (Value);
|
||||
@@ -120,7 +119,7 @@ ArmGenericTimerGetCompareVal (
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmGenericTimerSetCompareVal (
|
||||
IN UINT64 Value
|
||||
IN UINT64 Value
|
||||
)
|
||||
{
|
||||
ArmWriteCntvCval (Value);
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include <Library/ArmLib.h>
|
||||
#include <Library/ArmGicLib.h>
|
||||
|
||||
STATIC ARM_GIC_ARCH_REVISION mGicArchRevision;
|
||||
STATIC ARM_GIC_ARCH_REVISION mGicArchRevision;
|
||||
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
@@ -17,7 +17,7 @@ ArmGicArchLibInitialize (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINT32 IccSre;
|
||||
UINT32 IccSre;
|
||||
|
||||
// Ideally we would like to use the GICC IIDR Architecture version here, but
|
||||
// this does not seem to be very reliable as the implementation could easily
|
||||
@@ -38,6 +38,7 @@ ArmGicArchLibInitialize (
|
||||
ArmGicV3SetControlSystemRegisterEnable (IccSre | ICC_SRE_EL2_SRE);
|
||||
IccSre = ArmGicV3GetControlSystemRegisterEnable ();
|
||||
}
|
||||
|
||||
if (IccSre & ICC_SRE_EL2_SRE) {
|
||||
mGicArchRevision = ARM_GIC_ARCH_REVISION_3;
|
||||
goto Done;
|
||||
|
@@ -15,7 +15,7 @@ ArmGicGetSupportedArchRevision (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINT32 IccSre;
|
||||
UINT32 IccSre;
|
||||
|
||||
// Ideally we would like to use the GICC IIDR Architecture version here, but
|
||||
// this does not seem to be very reliable as the implementation could easily
|
||||
@@ -36,6 +36,7 @@ ArmGicGetSupportedArchRevision (
|
||||
ArmGicV3SetControlSystemRegisterEnable (IccSre | ICC_SRE_EL2_SRE);
|
||||
IccSre = ArmGicV3GetControlSystemRegisterEnable ();
|
||||
}
|
||||
|
||||
if (IccSre & ICC_SRE_EL2_SRE) {
|
||||
return ARM_GIC_ARCH_REVISION_3;
|
||||
}
|
||||
|
@@ -23,10 +23,10 @@ AArch64DataCacheOperation (
|
||||
IN AARCH64_CACHE_OPERATION DataCacheOperation
|
||||
)
|
||||
{
|
||||
UINTN SavedInterruptState;
|
||||
UINTN SavedInterruptState;
|
||||
|
||||
SavedInterruptState = ArmGetInterruptState ();
|
||||
ArmDisableInterrupts();
|
||||
ArmDisableInterrupts ();
|
||||
|
||||
AArch64AllDataCachesOperation (DataCacheOperation);
|
||||
|
||||
@@ -99,7 +99,7 @@ ArmHasCcidx (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN Mmfr2;
|
||||
UINTN Mmfr2;
|
||||
|
||||
Mmfr2 = ArmReadIdAA64Mmfr2 ();
|
||||
return (((Mmfr2 >> 20) & 0xF) == 1) ? TRUE : FALSE;
|
||||
|
@@ -11,7 +11,9 @@
|
||||
#ifndef AARCH64_LIB_H_
|
||||
#define AARCH64_LIB_H_
|
||||
|
||||
typedef VOID (*AARCH64_CACHE_OPERATION)(UINTN);
|
||||
typedef VOID (*AARCH64_CACHE_OPERATION)(
|
||||
UINTN
|
||||
);
|
||||
|
||||
VOID
|
||||
AArch64AllDataCachesOperation (
|
||||
@@ -33,7 +35,7 @@ ArmCleanDataCacheEntryBySetWay (
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmCleanInvalidateDataCacheEntryBySetWay (
|
||||
IN UINTN SetWayFormat
|
||||
IN UINTN SetWayFormat
|
||||
);
|
||||
|
||||
UINTN
|
||||
@@ -53,4 +55,3 @@ ArmReadIdAA64Mmfr2 (
|
||||
);
|
||||
|
||||
#endif // AARCH64_LIB_H_
|
||||
|
||||
|
@@ -23,7 +23,7 @@ ArmV7DataCacheOperation (
|
||||
IN ARM_V7_CACHE_OPERATION DataCacheOperation
|
||||
)
|
||||
{
|
||||
UINTN SavedInterruptState;
|
||||
UINTN SavedInterruptState;
|
||||
|
||||
SavedInterruptState = ArmGetInterruptState ();
|
||||
ArmDisableInterrupts ();
|
||||
@@ -114,7 +114,7 @@ ArmHasCcidx (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN Mmfr4;
|
||||
UINTN Mmfr4;
|
||||
|
||||
Mmfr4 = ArmReadIdMmfr4 ();
|
||||
return (((Mmfr4 >> 24) & 0xF) == 1) ? TRUE : FALSE;
|
||||
|
@@ -9,21 +9,23 @@
|
||||
#ifndef ARM_V7_LIB_H_
|
||||
#define ARM_V7_LIB_H_
|
||||
|
||||
#define ID_MMFR0_SHARELVL_SHIFT 12
|
||||
#define ID_MMFR0_SHARELVL_MASK 0xf
|
||||
#define ID_MMFR0_SHARELVL_ONE 0
|
||||
#define ID_MMFR0_SHARELVL_TWO 1
|
||||
#define ID_MMFR0_SHARELVL_SHIFT 12
|
||||
#define ID_MMFR0_SHARELVL_MASK 0xf
|
||||
#define ID_MMFR0_SHARELVL_ONE 0
|
||||
#define ID_MMFR0_SHARELVL_TWO 1
|
||||
|
||||
#define ID_MMFR0_INNERSHR_SHIFT 28
|
||||
#define ID_MMFR0_INNERSHR_MASK 0xf
|
||||
#define ID_MMFR0_OUTERSHR_SHIFT 8
|
||||
#define ID_MMFR0_OUTERSHR_MASK 0xf
|
||||
#define ID_MMFR0_INNERSHR_SHIFT 28
|
||||
#define ID_MMFR0_INNERSHR_MASK 0xf
|
||||
#define ID_MMFR0_OUTERSHR_SHIFT 8
|
||||
#define ID_MMFR0_OUTERSHR_MASK 0xf
|
||||
|
||||
#define ID_MMFR0_SHR_IMP_UNCACHED 0
|
||||
#define ID_MMFR0_SHR_IMP_HW_COHERENT 1
|
||||
#define ID_MMFR0_SHR_IGNORED 0xf
|
||||
#define ID_MMFR0_SHR_IMP_UNCACHED 0
|
||||
#define ID_MMFR0_SHR_IMP_HW_COHERENT 1
|
||||
#define ID_MMFR0_SHR_IGNORED 0xf
|
||||
|
||||
typedef VOID (*ARM_V7_CACHE_OPERATION)(UINT32);
|
||||
typedef VOID (*ARM_V7_CACHE_OPERATION)(
|
||||
UINT32
|
||||
);
|
||||
|
||||
VOID
|
||||
ArmV7AllDataCachesOperation (
|
||||
@@ -45,7 +47,7 @@ ArmCleanDataCacheEntryBySetWay (
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmCleanInvalidateDataCacheEntryBySetWay (
|
||||
IN UINTN SetWayFormat
|
||||
IN UINTN SetWayFormat
|
||||
);
|
||||
|
||||
/** Reads the ID_MMFR4 register.
|
||||
@@ -65,4 +67,3 @@ ArmReadIdPfr1 (
|
||||
);
|
||||
|
||||
#endif // ARM_V7_LIB_H_
|
||||
|
||||
|
@@ -16,19 +16,19 @@
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmSetAuxCrBit (
|
||||
IN UINT32 Bits
|
||||
IN UINT32 Bits
|
||||
)
|
||||
{
|
||||
ArmWriteAuxCr(ArmReadAuxCr() | Bits);
|
||||
ArmWriteAuxCr (ArmReadAuxCr () | Bits);
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmUnsetAuxCrBit (
|
||||
IN UINT32 Bits
|
||||
IN UINT32 Bits
|
||||
)
|
||||
{
|
||||
ArmWriteAuxCr(ArmReadAuxCr() & ~Bits);
|
||||
ArmWriteAuxCr (ArmReadAuxCr () & ~Bits);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -38,7 +38,7 @@ ArmUnsetAuxCrBit (
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmSetCpuActlrBit (
|
||||
IN UINTN Bits
|
||||
IN UINTN Bits
|
||||
)
|
||||
{
|
||||
ArmWriteCpuActlr (ArmReadCpuActlr () | Bits);
|
||||
@@ -47,7 +47,7 @@ ArmSetCpuActlrBit (
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmUnsetCpuActlrBit (
|
||||
IN UINTN Bits
|
||||
IN UINTN Bits
|
||||
)
|
||||
{
|
||||
ArmWriteCpuActlr (ArmReadCpuActlr () & ~Bits);
|
||||
@@ -77,7 +77,7 @@ ArmCacheWritebackGranule (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN CWG;
|
||||
UINTN CWG;
|
||||
|
||||
CWG = (ArmCacheInfo () >> 24) & 0xf; // CTR_EL0.CWG
|
||||
|
||||
|
@@ -11,19 +11,19 @@
|
||||
#ifndef ARM_LIB_PRIVATE_H_
|
||||
#define ARM_LIB_PRIVATE_H_
|
||||
|
||||
#define CACHE_SIZE_4_KB (3UL)
|
||||
#define CACHE_SIZE_8_KB (4UL)
|
||||
#define CACHE_SIZE_16_KB (5UL)
|
||||
#define CACHE_SIZE_32_KB (6UL)
|
||||
#define CACHE_SIZE_64_KB (7UL)
|
||||
#define CACHE_SIZE_128_KB (8UL)
|
||||
#define CACHE_SIZE_4_KB (3UL)
|
||||
#define CACHE_SIZE_8_KB (4UL)
|
||||
#define CACHE_SIZE_16_KB (5UL)
|
||||
#define CACHE_SIZE_32_KB (6UL)
|
||||
#define CACHE_SIZE_64_KB (7UL)
|
||||
#define CACHE_SIZE_128_KB (8UL)
|
||||
|
||||
#define CACHE_ASSOCIATIVITY_DIRECT (0UL)
|
||||
#define CACHE_ASSOCIATIVITY_4_WAY (2UL)
|
||||
#define CACHE_ASSOCIATIVITY_8_WAY (3UL)
|
||||
|
||||
#define CACHE_PRESENT (0UL)
|
||||
#define CACHE_NOT_PRESENT (1UL)
|
||||
#define CACHE_PRESENT (0UL)
|
||||
#define CACHE_NOT_PRESENT (1UL)
|
||||
|
||||
#define CACHE_LINE_LENGTH_32_BYTES (2UL)
|
||||
|
||||
@@ -32,25 +32,25 @@
|
||||
#define SIZE_FIELD_TO_CACHE_PRESENCE(x) (((x) >> 2) & 0x01)
|
||||
#define SIZE_FIELD_TO_CACHE_LINE_LENGTH(x) (((x) >> 0) & 0x03)
|
||||
|
||||
#define DATA_CACHE_SIZE_FIELD(x) (((x) >> 12) & 0x0FFF)
|
||||
#define INSTRUCTION_CACHE_SIZE_FIELD(x) (((x) >> 0) & 0x0FFF)
|
||||
#define DATA_CACHE_SIZE_FIELD(x) (((x) >> 12) & 0x0FFF)
|
||||
#define INSTRUCTION_CACHE_SIZE_FIELD(x) (((x) >> 0) & 0x0FFF)
|
||||
|
||||
#define DATA_CACHE_SIZE(x) (SIZE_FIELD_TO_CACHE_SIZE(DATA_CACHE_SIZE_FIELD(x)))
|
||||
#define DATA_CACHE_ASSOCIATIVITY(x) (SIZE_FIELD_TO_CACHE_ASSOCIATIVITY(DATA_CACHE_SIZE_FIELD(x)))
|
||||
#define DATA_CACHE_PRESENT(x) (SIZE_FIELD_TO_CACHE_PRESENCE(DATA_CACHE_SIZE_FIELD(x)))
|
||||
#define DATA_CACHE_LINE_LENGTH(x) (SIZE_FIELD_TO_CACHE_LINE_LENGTH(DATA_CACHE_SIZE_FIELD(x)))
|
||||
#define DATA_CACHE_SIZE(x) (SIZE_FIELD_TO_CACHE_SIZE(DATA_CACHE_SIZE_FIELD(x)))
|
||||
#define DATA_CACHE_ASSOCIATIVITY(x) (SIZE_FIELD_TO_CACHE_ASSOCIATIVITY(DATA_CACHE_SIZE_FIELD(x)))
|
||||
#define DATA_CACHE_PRESENT(x) (SIZE_FIELD_TO_CACHE_PRESENCE(DATA_CACHE_SIZE_FIELD(x)))
|
||||
#define DATA_CACHE_LINE_LENGTH(x) (SIZE_FIELD_TO_CACHE_LINE_LENGTH(DATA_CACHE_SIZE_FIELD(x)))
|
||||
|
||||
#define INSTRUCTION_CACHE_SIZE(x) (SIZE_FIELD_TO_CACHE_SIZE(INSTRUCTION_CACHE_SIZE_FIELD(x)))
|
||||
#define INSTRUCTION_CACHE_ASSOCIATIVITY(x) (SIZE_FIELD_TO_CACHE_ASSOCIATIVITY(INSTRUCTION_CACHE_SIZE_FIELD(x)))
|
||||
#define INSTRUCTION_CACHE_PRESENT(x) (SIZE_FIELD_TO_CACHE_PRESENCE(INSTRUCTION_CACHE_SIZE_FIELD(x)))
|
||||
#define INSTRUCTION_CACHE_LINE_LENGTH(x) (SIZE_FIELD_TO_CACHE_LINE_LENGTH(INSTRUCTION_CACHE_SIZE_FIELD(x)))
|
||||
#define INSTRUCTION_CACHE_SIZE(x) (SIZE_FIELD_TO_CACHE_SIZE(INSTRUCTION_CACHE_SIZE_FIELD(x)))
|
||||
#define INSTRUCTION_CACHE_ASSOCIATIVITY(x) (SIZE_FIELD_TO_CACHE_ASSOCIATIVITY(INSTRUCTION_CACHE_SIZE_FIELD(x)))
|
||||
#define INSTRUCTION_CACHE_PRESENT(x) (SIZE_FIELD_TO_CACHE_PRESENCE(INSTRUCTION_CACHE_SIZE_FIELD(x)))
|
||||
#define INSTRUCTION_CACHE_LINE_LENGTH(x) (SIZE_FIELD_TO_CACHE_LINE_LENGTH(INSTRUCTION_CACHE_SIZE_FIELD(x)))
|
||||
|
||||
#define CACHE_TYPE(x) (((x) >> 25) & 0x0F)
|
||||
#define CACHE_TYPE_WRITE_BACK (0x0EUL)
|
||||
#define CACHE_TYPE(x) (((x) >> 25) & 0x0F)
|
||||
#define CACHE_TYPE_WRITE_BACK (0x0EUL)
|
||||
|
||||
#define CACHE_ARCHITECTURE(x) (((x) >> 24) & 0x01)
|
||||
#define CACHE_ARCHITECTURE_UNIFIED (0UL)
|
||||
#define CACHE_ARCHITECTURE_SEPARATE (1UL)
|
||||
#define CACHE_ARCHITECTURE(x) (((x) >> 24) & 0x01)
|
||||
#define CACHE_ARCHITECTURE_UNIFIED (0UL)
|
||||
#define CACHE_ARCHITECTURE_SEPARATE (1UL)
|
||||
|
||||
VOID
|
||||
CPSRMaskInsert (
|
||||
|
@@ -26,31 +26,32 @@ ArmMemoryAttributeToPageAttribute (
|
||||
)
|
||||
{
|
||||
switch (Attributes) {
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE:
|
||||
return TT_ATTR_INDX_MEMORY_WRITE_BACK;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE:
|
||||
return TT_ATTR_INDX_MEMORY_WRITE_BACK;
|
||||
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK:
|
||||
return TT_ATTR_INDX_MEMORY_WRITE_BACK | TT_SH_INNER_SHAREABLE;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK:
|
||||
return TT_ATTR_INDX_MEMORY_WRITE_BACK | TT_SH_INNER_SHAREABLE;
|
||||
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH:
|
||||
return TT_ATTR_INDX_MEMORY_WRITE_THROUGH | TT_SH_INNER_SHAREABLE;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH:
|
||||
return TT_ATTR_INDX_MEMORY_WRITE_THROUGH | TT_SH_INNER_SHAREABLE;
|
||||
|
||||
// Uncached and device mappings are treated as outer shareable by default,
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED:
|
||||
return TT_ATTR_INDX_MEMORY_NON_CACHEABLE;
|
||||
// Uncached and device mappings are treated as outer shareable by default,
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED:
|
||||
return TT_ATTR_INDX_MEMORY_NON_CACHEABLE;
|
||||
|
||||
default:
|
||||
ASSERT (0);
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:
|
||||
if (ArmReadCurrentEL () == AARCH64_EL2)
|
||||
return TT_ATTR_INDX_DEVICE_MEMORY | TT_XN_MASK;
|
||||
else
|
||||
return TT_ATTR_INDX_DEVICE_MEMORY | TT_UXN_MASK | TT_PXN_MASK;
|
||||
default:
|
||||
ASSERT (0);
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:
|
||||
if (ArmReadCurrentEL () == AARCH64_EL2) {
|
||||
return TT_ATTR_INDX_DEVICE_MEMORY | TT_XN_MASK;
|
||||
} else {
|
||||
return TT_ATTR_INDX_DEVICE_MEMORY | TT_UXN_MASK | TT_PXN_MASK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ ArmMemoryAttributeToPageAttribute (
|
||||
STATIC
|
||||
UINTN
|
||||
GetRootTableEntryCount (
|
||||
IN UINTN T0SZ
|
||||
IN UINTN T0SZ
|
||||
)
|
||||
{
|
||||
return TT_ENTRY_COUNT >> (T0SZ - MIN_T0SZ) % BITS_PER_LEVEL;
|
||||
@@ -70,7 +71,7 @@ GetRootTableEntryCount (
|
||||
STATIC
|
||||
UINTN
|
||||
GetRootTableLevel (
|
||||
IN UINTN T0SZ
|
||||
IN UINTN T0SZ
|
||||
)
|
||||
{
|
||||
return (T0SZ - MIN_T0SZ) / BITS_PER_LEVEL;
|
||||
@@ -79,10 +80,10 @@ GetRootTableLevel (
|
||||
STATIC
|
||||
VOID
|
||||
ReplaceTableEntry (
|
||||
IN UINT64 *Entry,
|
||||
IN UINT64 Value,
|
||||
IN UINT64 RegionStart,
|
||||
IN BOOLEAN IsLiveBlockMapping
|
||||
IN UINT64 *Entry,
|
||||
IN UINT64 Value,
|
||||
IN UINT64 RegionStart,
|
||||
IN BOOLEAN IsLiveBlockMapping
|
||||
)
|
||||
{
|
||||
if (!ArmMmuEnabled () || !IsLiveBlockMapping) {
|
||||
@@ -100,19 +101,22 @@ FreePageTablesRecursive (
|
||||
IN UINTN Level
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
ASSERT (Level <= 3);
|
||||
|
||||
if (Level < 3) {
|
||||
for (Index = 0; Index < TT_ENTRY_COUNT; Index++) {
|
||||
if ((TranslationTable[Index] & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY) {
|
||||
FreePageTablesRecursive ((VOID *)(UINTN)(TranslationTable[Index] &
|
||||
TT_ADDRESS_MASK_BLOCK_ENTRY),
|
||||
Level + 1);
|
||||
FreePageTablesRecursive (
|
||||
(VOID *)(UINTN)(TranslationTable[Index] &
|
||||
TT_ADDRESS_MASK_BLOCK_ENTRY),
|
||||
Level + 1
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FreePages (TranslationTable, 1);
|
||||
}
|
||||
|
||||
@@ -126,6 +130,7 @@ IsBlockEntry (
|
||||
if (Level == 3) {
|
||||
return (Entry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY_LEVEL3;
|
||||
}
|
||||
|
||||
return (Entry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY;
|
||||
}
|
||||
|
||||
@@ -143,39 +148,48 @@ IsTableEntry (
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return (Entry & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY;
|
||||
}
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
UpdateRegionMappingRecursive (
|
||||
IN UINT64 RegionStart,
|
||||
IN UINT64 RegionEnd,
|
||||
IN UINT64 AttributeSetMask,
|
||||
IN UINT64 AttributeClearMask,
|
||||
IN UINT64 *PageTable,
|
||||
IN UINTN Level
|
||||
IN UINT64 RegionStart,
|
||||
IN UINT64 RegionEnd,
|
||||
IN UINT64 AttributeSetMask,
|
||||
IN UINT64 AttributeClearMask,
|
||||
IN UINT64 *PageTable,
|
||||
IN UINTN Level
|
||||
)
|
||||
{
|
||||
UINTN BlockShift;
|
||||
UINT64 BlockMask;
|
||||
UINT64 BlockEnd;
|
||||
UINT64 *Entry;
|
||||
UINT64 EntryValue;
|
||||
VOID *TranslationTable;
|
||||
EFI_STATUS Status;
|
||||
UINTN BlockShift;
|
||||
UINT64 BlockMask;
|
||||
UINT64 BlockEnd;
|
||||
UINT64 *Entry;
|
||||
UINT64 EntryValue;
|
||||
VOID *TranslationTable;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (((RegionStart | RegionEnd) & EFI_PAGE_MASK) == 0);
|
||||
|
||||
BlockShift = (Level + 1) * BITS_PER_LEVEL + MIN_T0SZ;
|
||||
BlockMask = MAX_UINT64 >> BlockShift;
|
||||
BlockMask = MAX_UINT64 >> BlockShift;
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "%a(%d): %llx - %llx set %lx clr %lx\n", __FUNCTION__,
|
||||
Level, RegionStart, RegionEnd, AttributeSetMask, AttributeClearMask));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a(%d): %llx - %llx set %lx clr %lx\n",
|
||||
__FUNCTION__,
|
||||
Level,
|
||||
RegionStart,
|
||||
RegionEnd,
|
||||
AttributeSetMask,
|
||||
AttributeClearMask
|
||||
));
|
||||
|
||||
for (; RegionStart < RegionEnd; RegionStart = BlockEnd) {
|
||||
for ( ; RegionStart < RegionEnd; RegionStart = BlockEnd) {
|
||||
BlockEnd = MIN (RegionEnd, (RegionStart | BlockMask) + 1);
|
||||
Entry = &PageTable[(RegionStart >> (64 - BlockShift)) & (TT_ENTRY_COUNT - 1)];
|
||||
Entry = &PageTable[(RegionStart >> (64 - BlockShift)) & (TT_ENTRY_COUNT - 1)];
|
||||
|
||||
//
|
||||
// If RegionStart or BlockEnd is not aligned to the block size at this
|
||||
@@ -187,8 +201,9 @@ UpdateRegionMappingRecursive (
|
||||
// we cannot replace it with a block entry without potentially losing
|
||||
// attribute information, so keep the table entry in that case.
|
||||
//
|
||||
if (Level == 0 || ((RegionStart | BlockEnd) & BlockMask) != 0 ||
|
||||
(IsTableEntry (*Entry, Level) && AttributeClearMask != 0)) {
|
||||
if ((Level == 0) || (((RegionStart | BlockEnd) & BlockMask) != 0) ||
|
||||
(IsTableEntry (*Entry, Level) && (AttributeClearMask != 0)))
|
||||
{
|
||||
ASSERT (Level < 3);
|
||||
|
||||
if (!IsTableEntry (*Entry, Level)) {
|
||||
@@ -216,9 +231,14 @@ UpdateRegionMappingRecursive (
|
||||
// We are splitting an existing block entry, so we have to populate
|
||||
// the new table with the attributes of the block entry it replaces.
|
||||
//
|
||||
Status = UpdateRegionMappingRecursive (RegionStart & ~BlockMask,
|
||||
(RegionStart | BlockMask) + 1, *Entry & TT_ATTRIBUTES_MASK,
|
||||
0, TranslationTable, Level + 1);
|
||||
Status = UpdateRegionMappingRecursive (
|
||||
RegionStart & ~BlockMask,
|
||||
(RegionStart | BlockMask) + 1,
|
||||
*Entry & TT_ATTRIBUTES_MASK,
|
||||
0,
|
||||
TranslationTable,
|
||||
Level + 1
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// The range we passed to UpdateRegionMappingRecursive () is block
|
||||
@@ -236,9 +256,14 @@ UpdateRegionMappingRecursive (
|
||||
//
|
||||
// Recurse to the next level
|
||||
//
|
||||
Status = UpdateRegionMappingRecursive (RegionStart, BlockEnd,
|
||||
AttributeSetMask, AttributeClearMask, TranslationTable,
|
||||
Level + 1);
|
||||
Status = UpdateRegionMappingRecursive (
|
||||
RegionStart,
|
||||
BlockEnd,
|
||||
AttributeSetMask,
|
||||
AttributeClearMask,
|
||||
TranslationTable,
|
||||
Level + 1
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (!IsTableEntry (*Entry, Level)) {
|
||||
//
|
||||
@@ -250,16 +275,21 @@ UpdateRegionMappingRecursive (
|
||||
//
|
||||
FreePageTablesRecursive (TranslationTable, Level + 1);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (!IsTableEntry (*Entry, Level)) {
|
||||
EntryValue = (UINTN)TranslationTable | TT_TYPE_TABLE_ENTRY;
|
||||
ReplaceTableEntry (Entry, EntryValue, RegionStart,
|
||||
IsBlockEntry (*Entry, Level));
|
||||
ReplaceTableEntry (
|
||||
Entry,
|
||||
EntryValue,
|
||||
RegionStart,
|
||||
IsBlockEntry (*Entry, Level)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
EntryValue = (*Entry & AttributeClearMask) | AttributeSetMask;
|
||||
EntryValue = (*Entry & AttributeClearMask) | AttributeSetMask;
|
||||
EntryValue |= RegionStart;
|
||||
EntryValue |= (Level == 3) ? TT_TYPE_BLOCK_ENTRY_LEVEL3
|
||||
: TT_TYPE_BLOCK_ENTRY;
|
||||
@@ -280,6 +310,7 @@ UpdateRegionMappingRecursive (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -292,7 +323,7 @@ UpdateRegionMapping (
|
||||
IN UINT64 AttributeClearMask
|
||||
)
|
||||
{
|
||||
UINTN T0SZ;
|
||||
UINTN T0SZ;
|
||||
|
||||
if (((RegionStart | RegionLength) & EFI_PAGE_MASK) != 0) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -300,9 +331,14 @@ UpdateRegionMapping (
|
||||
|
||||
T0SZ = ArmGetTCR () & TCR_T0SZ_MASK;
|
||||
|
||||
return UpdateRegionMappingRecursive (RegionStart, RegionStart + RegionLength,
|
||||
AttributeSetMask, AttributeClearMask, ArmGetTTBR0BaseAddress (),
|
||||
GetRootTableLevel (T0SZ));
|
||||
return UpdateRegionMappingRecursive (
|
||||
RegionStart,
|
||||
RegionStart + RegionLength,
|
||||
AttributeSetMask,
|
||||
AttributeClearMask,
|
||||
ArmGetTTBR0BaseAddress (),
|
||||
GetRootTableLevel (T0SZ)
|
||||
);
|
||||
}
|
||||
|
||||
STATIC
|
||||
@@ -323,31 +359,32 @@ FillTranslationTable (
|
||||
STATIC
|
||||
UINT64
|
||||
GcdAttributeToPageAttribute (
|
||||
IN UINT64 GcdAttributes
|
||||
IN UINT64 GcdAttributes
|
||||
)
|
||||
{
|
||||
UINT64 PageAttributes;
|
||||
UINT64 PageAttributes;
|
||||
|
||||
switch (GcdAttributes & EFI_MEMORY_CACHETYPE_MASK) {
|
||||
case EFI_MEMORY_UC:
|
||||
PageAttributes = TT_ATTR_INDX_DEVICE_MEMORY;
|
||||
break;
|
||||
case EFI_MEMORY_WC:
|
||||
PageAttributes = TT_ATTR_INDX_MEMORY_NON_CACHEABLE;
|
||||
break;
|
||||
case EFI_MEMORY_WT:
|
||||
PageAttributes = TT_ATTR_INDX_MEMORY_WRITE_THROUGH | TT_SH_INNER_SHAREABLE;
|
||||
break;
|
||||
case EFI_MEMORY_WB:
|
||||
PageAttributes = TT_ATTR_INDX_MEMORY_WRITE_BACK | TT_SH_INNER_SHAREABLE;
|
||||
break;
|
||||
default:
|
||||
PageAttributes = TT_ATTR_INDX_MASK;
|
||||
break;
|
||||
case EFI_MEMORY_UC:
|
||||
PageAttributes = TT_ATTR_INDX_DEVICE_MEMORY;
|
||||
break;
|
||||
case EFI_MEMORY_WC:
|
||||
PageAttributes = TT_ATTR_INDX_MEMORY_NON_CACHEABLE;
|
||||
break;
|
||||
case EFI_MEMORY_WT:
|
||||
PageAttributes = TT_ATTR_INDX_MEMORY_WRITE_THROUGH | TT_SH_INNER_SHAREABLE;
|
||||
break;
|
||||
case EFI_MEMORY_WB:
|
||||
PageAttributes = TT_ATTR_INDX_MEMORY_WRITE_BACK | TT_SH_INNER_SHAREABLE;
|
||||
break;
|
||||
default:
|
||||
PageAttributes = TT_ATTR_INDX_MASK;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((GcdAttributes & EFI_MEMORY_XP) != 0 ||
|
||||
(GcdAttributes & EFI_MEMORY_CACHETYPE_MASK) == EFI_MEMORY_UC) {
|
||||
if (((GcdAttributes & EFI_MEMORY_XP) != 0) ||
|
||||
((GcdAttributes & EFI_MEMORY_CACHETYPE_MASK) == EFI_MEMORY_UC))
|
||||
{
|
||||
if (ArmReadCurrentEL () == AARCH64_EL2) {
|
||||
PageAttributes |= TT_XN_MASK;
|
||||
} else {
|
||||
@@ -364,15 +401,15 @@ GcdAttributeToPageAttribute (
|
||||
|
||||
EFI_STATUS
|
||||
ArmSetMemoryAttributes (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
)
|
||||
{
|
||||
UINT64 PageAttributes;
|
||||
UINT64 PageAttributeMask;
|
||||
UINT64 PageAttributes;
|
||||
UINT64 PageAttributeMask;
|
||||
|
||||
PageAttributes = GcdAttributeToPageAttribute (Attributes);
|
||||
PageAttributes = GcdAttributeToPageAttribute (Attributes);
|
||||
PageAttributeMask = 0;
|
||||
|
||||
if ((Attributes & EFI_MEMORY_CACHETYPE_MASK) == 0) {
|
||||
@@ -380,22 +417,26 @@ ArmSetMemoryAttributes (
|
||||
// No memory type was set in Attributes, so we are going to update the
|
||||
// permissions only.
|
||||
//
|
||||
PageAttributes &= TT_AP_MASK | TT_UXN_MASK | TT_PXN_MASK;
|
||||
PageAttributes &= TT_AP_MASK | TT_UXN_MASK | TT_PXN_MASK;
|
||||
PageAttributeMask = ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK |
|
||||
TT_PXN_MASK | TT_XN_MASK);
|
||||
}
|
||||
|
||||
return UpdateRegionMapping (BaseAddress, Length, PageAttributes,
|
||||
PageAttributeMask);
|
||||
return UpdateRegionMapping (
|
||||
BaseAddress,
|
||||
Length,
|
||||
PageAttributes,
|
||||
PageAttributeMask
|
||||
);
|
||||
}
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
SetMemoryRegionAttribute (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes,
|
||||
IN UINT64 BlockEntryMask
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes,
|
||||
IN UINT64 BlockEntryMask
|
||||
)
|
||||
{
|
||||
return UpdateRegionMapping (BaseAddress, Length, Attributes, BlockEntryMask);
|
||||
@@ -403,11 +444,11 @@ SetMemoryRegionAttribute (
|
||||
|
||||
EFI_STATUS
|
||||
ArmSetMemoryRegionNoExec (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
UINT64 Val;
|
||||
UINT64 Val;
|
||||
|
||||
if (ArmReadCurrentEL () == AARCH64_EL1) {
|
||||
Val = TT_PXN_MASK | TT_UXN_MASK;
|
||||
@@ -419,16 +460,17 @@ ArmSetMemoryRegionNoExec (
|
||||
BaseAddress,
|
||||
Length,
|
||||
Val,
|
||||
~TT_ADDRESS_MASK_BLOCK_ENTRY);
|
||||
~TT_ADDRESS_MASK_BLOCK_ENTRY
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmClearMemoryRegionNoExec (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
UINT64 Mask;
|
||||
UINT64 Mask;
|
||||
|
||||
// XN maps to UXN in the EL1&0 translation regime
|
||||
Mask = ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_PXN_MASK | TT_XN_MASK);
|
||||
@@ -437,50 +479,53 @@ ArmClearMemoryRegionNoExec (
|
||||
BaseAddress,
|
||||
Length,
|
||||
0,
|
||||
Mask);
|
||||
Mask
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmSetMemoryRegionReadOnly (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return SetMemoryRegionAttribute (
|
||||
BaseAddress,
|
||||
Length,
|
||||
TT_AP_RO_RO,
|
||||
~TT_ADDRESS_MASK_BLOCK_ENTRY);
|
||||
~TT_ADDRESS_MASK_BLOCK_ENTRY
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmClearMemoryRegionReadOnly (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return SetMemoryRegionAttribute (
|
||||
BaseAddress,
|
||||
Length,
|
||||
TT_AP_RW_RW,
|
||||
~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK));
|
||||
~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK)
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ArmConfigureMmu (
|
||||
IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable,
|
||||
OUT VOID **TranslationTableBase OPTIONAL,
|
||||
OUT VOID **TranslationTableBase OPTIONAL,
|
||||
OUT UINTN *TranslationTableSize OPTIONAL
|
||||
)
|
||||
{
|
||||
VOID* TranslationTable;
|
||||
UINTN MaxAddressBits;
|
||||
UINT64 MaxAddress;
|
||||
UINTN T0SZ;
|
||||
UINTN RootTableEntryCount;
|
||||
UINT64 TCR;
|
||||
EFI_STATUS Status;
|
||||
VOID *TranslationTable;
|
||||
UINTN MaxAddressBits;
|
||||
UINT64 MaxAddress;
|
||||
UINTN T0SZ;
|
||||
UINTN RootTableEntryCount;
|
||||
UINT64 TCR;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (MemoryTable == NULL) {
|
||||
ASSERT (MemoryTable != NULL);
|
||||
@@ -495,9 +540,9 @@ ArmConfigureMmu (
|
||||
// use of 4 KB pages.
|
||||
//
|
||||
MaxAddressBits = MIN (ArmGetPhysicalAddressBits (), MAX_VA_BITS);
|
||||
MaxAddress = LShiftU64 (1ULL, MaxAddressBits) - 1;
|
||||
MaxAddress = LShiftU64 (1ULL, MaxAddressBits) - 1;
|
||||
|
||||
T0SZ = 64 - MaxAddressBits;
|
||||
T0SZ = 64 - MaxAddressBits;
|
||||
RootTableEntryCount = GetRootTableEntryCount (T0SZ);
|
||||
|
||||
//
|
||||
@@ -506,7 +551,7 @@ ArmConfigureMmu (
|
||||
// Ideally we will be running at EL2, but should support EL1 as well.
|
||||
// UEFI should not run at EL3.
|
||||
if (ArmReadCurrentEL () == AARCH64_EL2) {
|
||||
//Note: Bits 23 and 31 are reserved(RES1) bits in TCR_EL2
|
||||
// Note: Bits 23 and 31 are reserved(RES1) bits in TCR_EL2
|
||||
TCR = T0SZ | (1UL << 31) | (1UL << 23) | TCR_TG0_4KB;
|
||||
|
||||
// Set the Physical Address Size using MaxAddress
|
||||
@@ -523,9 +568,11 @@ ArmConfigureMmu (
|
||||
} else if (MaxAddress < SIZE_256TB) {
|
||||
TCR |= TCR_PS_256TB;
|
||||
} else {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"ArmConfigureMmu: The MaxAddress 0x%lX is not supported by this MMU configuration.\n",
|
||||
MaxAddress));
|
||||
MaxAddress
|
||||
));
|
||||
ASSERT (0); // Bigger than 48-bit memory space are not supported
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@@ -547,9 +594,11 @@ ArmConfigureMmu (
|
||||
} else if (MaxAddress < SIZE_256TB) {
|
||||
TCR |= TCR_IPS_256TB;
|
||||
} else {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"ArmConfigureMmu: The MaxAddress 0x%lX is not supported by this MMU configuration.\n",
|
||||
MaxAddress));
|
||||
MaxAddress
|
||||
));
|
||||
ASSERT (0); // Bigger than 48-bit memory space are not supported
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@@ -579,6 +628,7 @@ ArmConfigureMmu (
|
||||
if (TranslationTable == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// We set TTBR0 just after allocating the table to retrieve its location from
|
||||
// the subsequent functions without needing to pass this value across the
|
||||
@@ -599,8 +649,10 @@ ArmConfigureMmu (
|
||||
// Make sure we are not inadvertently hitting in the caches
|
||||
// when populating the page tables.
|
||||
//
|
||||
InvalidateDataCacheRange (TranslationTable,
|
||||
RootTableEntryCount * sizeof (UINT64));
|
||||
InvalidateDataCacheRange (
|
||||
TranslationTable,
|
||||
RootTableEntryCount * sizeof (UINT64)
|
||||
);
|
||||
ZeroMem (TranslationTable, RootTableEntryCount * sizeof (UINT64));
|
||||
|
||||
while (MemoryTable->Length != 0) {
|
||||
@@ -608,6 +660,7 @@ ArmConfigureMmu (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreeTranslationTable;
|
||||
}
|
||||
|
||||
MemoryTable++;
|
||||
}
|
||||
|
||||
@@ -618,10 +671,10 @@ ArmConfigureMmu (
|
||||
// EFI_MEMORY_WB ==> MAIR_ATTR_NORMAL_MEMORY_WRITE_BACK
|
||||
//
|
||||
ArmSetMAIR (
|
||||
MAIR_ATTR (TT_ATTR_INDX_DEVICE_MEMORY, MAIR_ATTR_DEVICE_MEMORY) |
|
||||
MAIR_ATTR (TT_ATTR_INDX_DEVICE_MEMORY, MAIR_ATTR_DEVICE_MEMORY) |
|
||||
MAIR_ATTR (TT_ATTR_INDX_MEMORY_NON_CACHEABLE, MAIR_ATTR_NORMAL_MEMORY_NON_CACHEABLE) |
|
||||
MAIR_ATTR (TT_ATTR_INDX_MEMORY_WRITE_THROUGH, MAIR_ATTR_NORMAL_MEMORY_WRITE_THROUGH) |
|
||||
MAIR_ATTR (TT_ATTR_INDX_MEMORY_WRITE_BACK, MAIR_ATTR_NORMAL_MEMORY_WRITE_BACK)
|
||||
MAIR_ATTR (TT_ATTR_INDX_MEMORY_WRITE_BACK, MAIR_ATTR_NORMAL_MEMORY_WRITE_BACK)
|
||||
);
|
||||
|
||||
ArmDisableAlignmentCheck ();
|
||||
@@ -643,14 +696,16 @@ ArmMmuBaseLibConstructor (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
extern UINT32 ArmReplaceLiveTranslationEntrySize;
|
||||
extern UINT32 ArmReplaceLiveTranslationEntrySize;
|
||||
|
||||
//
|
||||
// The ArmReplaceLiveTranslationEntry () helper function may be invoked
|
||||
// with the MMU off so we have to ensure that it gets cleaned to the PoC
|
||||
//
|
||||
WriteBackDataCacheRange ((VOID *)(UINTN)ArmReplaceLiveTranslationEntry,
|
||||
ArmReplaceLiveTranslationEntrySize);
|
||||
WriteBackDataCacheRange (
|
||||
(VOID *)(UINTN)ArmReplaceLiveTranslationEntry,
|
||||
ArmReplaceLiveTranslationEntrySize
|
||||
);
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
@@ -16,14 +16,14 @@
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ArmMmuPeiLibConstructor (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices
|
||||
)
|
||||
{
|
||||
extern UINT32 ArmReplaceLiveTranslationEntrySize;
|
||||
extern UINT32 ArmReplaceLiveTranslationEntrySize;
|
||||
|
||||
EFI_FV_FILE_INFO FileInfo;
|
||||
EFI_STATUS Status;
|
||||
EFI_FV_FILE_INFO FileInfo;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (FileHandle != NULL);
|
||||
|
||||
@@ -37,9 +37,10 @@ ArmMmuPeiLibConstructor (
|
||||
// is executing from DRAM, we only need to perform the cache maintenance
|
||||
// when not executing in place.
|
||||
//
|
||||
if ((UINTN)FileInfo.Buffer <= (UINTN)ArmReplaceLiveTranslationEntry &&
|
||||
if (((UINTN)FileInfo.Buffer <= (UINTN)ArmReplaceLiveTranslationEntry) &&
|
||||
((UINTN)FileInfo.Buffer + FileInfo.BufferSize >=
|
||||
(UINTN)ArmReplaceLiveTranslationEntry + ArmReplaceLiveTranslationEntrySize)) {
|
||||
(UINTN)ArmReplaceLiveTranslationEntry + ArmReplaceLiveTranslationEntrySize))
|
||||
{
|
||||
DEBUG ((DEBUG_INFO, "ArmMmuLib: skipping cache maintenance on XIP PEIM\n"));
|
||||
} else {
|
||||
DEBUG ((DEBUG_INFO, "ArmMmuLib: performing cache maintenance on shadowed PEIM\n"));
|
||||
@@ -47,8 +48,10 @@ ArmMmuPeiLibConstructor (
|
||||
// The ArmReplaceLiveTranslationEntry () helper function may be invoked
|
||||
// with the MMU off so we have to ensure that it gets cleaned to the PoC
|
||||
//
|
||||
WriteBackDataCacheRange ((VOID *)(UINTN)ArmReplaceLiveTranslationEntry,
|
||||
ArmReplaceLiveTranslationEntrySize);
|
||||
WriteBackDataCacheRange (
|
||||
(VOID *)(UINTN)ArmReplaceLiveTranslationEntry,
|
||||
ArmReplaceLiveTranslationEntrySize
|
||||
);
|
||||
}
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
|
@@ -19,9 +19,9 @@ ConvertSectionAttributesToPageAttributes (
|
||||
IN BOOLEAN IsLargePage
|
||||
)
|
||||
{
|
||||
UINT32 PageAttributes;
|
||||
UINT32 PageAttributes;
|
||||
|
||||
PageAttributes = 0;
|
||||
PageAttributes = 0;
|
||||
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY (SectionAttributes, IsLargePage);
|
||||
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_AP (SectionAttributes);
|
||||
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_XN (SectionAttributes, IsLargePage);
|
||||
|
@@ -17,19 +17,19 @@
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
|
||||
#define ID_MMFR0_SHARELVL_SHIFT 12
|
||||
#define ID_MMFR0_SHARELVL_MASK 0xf
|
||||
#define ID_MMFR0_SHARELVL_ONE 0
|
||||
#define ID_MMFR0_SHARELVL_TWO 1
|
||||
#define ID_MMFR0_SHARELVL_SHIFT 12
|
||||
#define ID_MMFR0_SHARELVL_MASK 0xf
|
||||
#define ID_MMFR0_SHARELVL_ONE 0
|
||||
#define ID_MMFR0_SHARELVL_TWO 1
|
||||
|
||||
#define ID_MMFR0_INNERSHR_SHIFT 28
|
||||
#define ID_MMFR0_INNERSHR_MASK 0xf
|
||||
#define ID_MMFR0_OUTERSHR_SHIFT 8
|
||||
#define ID_MMFR0_OUTERSHR_MASK 0xf
|
||||
#define ID_MMFR0_INNERSHR_SHIFT 28
|
||||
#define ID_MMFR0_INNERSHR_MASK 0xf
|
||||
#define ID_MMFR0_OUTERSHR_SHIFT 8
|
||||
#define ID_MMFR0_OUTERSHR_MASK 0xf
|
||||
|
||||
#define ID_MMFR0_SHR_IMP_UNCACHED 0
|
||||
#define ID_MMFR0_SHR_IMP_HW_COHERENT 1
|
||||
#define ID_MMFR0_SHR_IGNORED 0xf
|
||||
#define ID_MMFR0_SHR_IMP_UNCACHED 0
|
||||
#define ID_MMFR0_SHR_IMP_HW_COHERENT 1
|
||||
#define ID_MMFR0_SHR_IGNORED 0xf
|
||||
|
||||
UINTN
|
||||
EFIAPI
|
||||
@@ -49,8 +49,8 @@ PreferNonshareableMemory (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN Mmfr;
|
||||
UINTN Val;
|
||||
UINTN Mmfr;
|
||||
UINTN Val;
|
||||
|
||||
if (FeaturePcdGet (PcdNormalMemoryNonshareableOverride)) {
|
||||
return TRUE;
|
||||
@@ -63,32 +63,33 @@ PreferNonshareableMemory (
|
||||
//
|
||||
Mmfr = ArmReadIdMmfr0 ();
|
||||
switch ((Mmfr >> ID_MMFR0_SHARELVL_SHIFT) & ID_MMFR0_SHARELVL_MASK) {
|
||||
case ID_MMFR0_SHARELVL_ONE:
|
||||
// one level of shareability
|
||||
Val = (Mmfr >> ID_MMFR0_OUTERSHR_SHIFT) & ID_MMFR0_OUTERSHR_MASK;
|
||||
break;
|
||||
case ID_MMFR0_SHARELVL_TWO:
|
||||
// two levels of shareability
|
||||
Val = (Mmfr >> ID_MMFR0_INNERSHR_SHIFT) & ID_MMFR0_INNERSHR_MASK;
|
||||
break;
|
||||
default:
|
||||
// unexpected value -> shareable is the safe option
|
||||
ASSERT (FALSE);
|
||||
return FALSE;
|
||||
case ID_MMFR0_SHARELVL_ONE:
|
||||
// one level of shareability
|
||||
Val = (Mmfr >> ID_MMFR0_OUTERSHR_SHIFT) & ID_MMFR0_OUTERSHR_MASK;
|
||||
break;
|
||||
case ID_MMFR0_SHARELVL_TWO:
|
||||
// two levels of shareability
|
||||
Val = (Mmfr >> ID_MMFR0_INNERSHR_SHIFT) & ID_MMFR0_INNERSHR_MASK;
|
||||
break;
|
||||
default:
|
||||
// unexpected value -> shareable is the safe option
|
||||
ASSERT (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return Val != ID_MMFR0_SHR_IMP_HW_COHERENT;
|
||||
}
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
PopulateLevel2PageTable (
|
||||
IN UINT32 *SectionEntry,
|
||||
IN UINT32 PhysicalBase,
|
||||
IN UINT32 RemainLength,
|
||||
IN ARM_MEMORY_REGION_ATTRIBUTES Attributes
|
||||
IN UINT32 *SectionEntry,
|
||||
IN UINT32 PhysicalBase,
|
||||
IN UINT32 RemainLength,
|
||||
IN ARM_MEMORY_REGION_ATTRIBUTES Attributes
|
||||
)
|
||||
{
|
||||
UINT32* PageEntry;
|
||||
UINT32 *PageEntry;
|
||||
UINT32 Pages;
|
||||
UINT32 Index;
|
||||
UINT32 PageAttributes;
|
||||
@@ -104,7 +105,7 @@ PopulateLevel2PageTable (
|
||||
break;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE:
|
||||
PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK;
|
||||
PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK;
|
||||
PageAttributes &= ~TT_DESCRIPTOR_PAGE_S_SHARED;
|
||||
break;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:
|
||||
@@ -132,7 +133,7 @@ PopulateLevel2PageTable (
|
||||
// Level 2 Translation Table to it
|
||||
if (*SectionEntry != 0) {
|
||||
// The entry must be a page table. Otherwise it exists an overlapping in the memory map
|
||||
if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE(*SectionEntry)) {
|
||||
if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE (*SectionEntry)) {
|
||||
TranslationTable = *SectionEntry & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK;
|
||||
} else if ((*SectionEntry & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) {
|
||||
// Case where a virtual memory map descriptor overlapped a section entry
|
||||
@@ -140,60 +141,66 @@ PopulateLevel2PageTable (
|
||||
// Allocate a Level2 Page Table for this Section
|
||||
TranslationTable = (UINTN)AllocateAlignedPages (
|
||||
EFI_SIZE_TO_PAGES (TRANSLATION_TABLE_PAGE_SIZE),
|
||||
TRANSLATION_TABLE_PAGE_ALIGNMENT);
|
||||
TRANSLATION_TABLE_PAGE_ALIGNMENT
|
||||
);
|
||||
|
||||
// Translate the Section Descriptor into Page Descriptor
|
||||
SectionDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE | ConvertSectionAttributesToPageAttributes (*SectionEntry, FALSE);
|
||||
|
||||
BaseSectionAddress = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(*SectionEntry);
|
||||
BaseSectionAddress = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (*SectionEntry);
|
||||
|
||||
//
|
||||
// Make sure we are not inadvertently hitting in the caches
|
||||
// when populating the page tables
|
||||
//
|
||||
InvalidateDataCacheRange ((VOID *)TranslationTable,
|
||||
TRANSLATION_TABLE_PAGE_SIZE);
|
||||
InvalidateDataCacheRange (
|
||||
(VOID *)TranslationTable,
|
||||
TRANSLATION_TABLE_PAGE_SIZE
|
||||
);
|
||||
|
||||
// Populate the new Level2 Page Table for the section
|
||||
PageEntry = (UINT32*)TranslationTable;
|
||||
PageEntry = (UINT32 *)TranslationTable;
|
||||
for (Index = 0; Index < TRANSLATION_TABLE_PAGE_COUNT; Index++) {
|
||||
PageEntry[Index] = TT_DESCRIPTOR_PAGE_BASE_ADDRESS(BaseSectionAddress + (Index << 12)) | SectionDescriptor;
|
||||
PageEntry[Index] = TT_DESCRIPTOR_PAGE_BASE_ADDRESS (BaseSectionAddress + (Index << 12)) | SectionDescriptor;
|
||||
}
|
||||
|
||||
// Overwrite the section entry to point to the new Level2 Translation Table
|
||||
*SectionEntry = (TranslationTable & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK) |
|
||||
(IS_ARM_MEMORY_REGION_ATTRIBUTES_SECURE(Attributes) ? (1 << 3) : 0) |
|
||||
TT_DESCRIPTOR_SECTION_TYPE_PAGE_TABLE;
|
||||
(IS_ARM_MEMORY_REGION_ATTRIBUTES_SECURE (Attributes) ? (1 << 3) : 0) |
|
||||
TT_DESCRIPTOR_SECTION_TYPE_PAGE_TABLE;
|
||||
} else {
|
||||
// We do not support the other section type (16MB Section)
|
||||
ASSERT(0);
|
||||
ASSERT (0);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
TranslationTable = (UINTN)AllocateAlignedPages (
|
||||
EFI_SIZE_TO_PAGES (TRANSLATION_TABLE_PAGE_SIZE),
|
||||
TRANSLATION_TABLE_PAGE_ALIGNMENT);
|
||||
TRANSLATION_TABLE_PAGE_ALIGNMENT
|
||||
);
|
||||
//
|
||||
// Make sure we are not inadvertently hitting in the caches
|
||||
// when populating the page tables
|
||||
//
|
||||
InvalidateDataCacheRange ((VOID *)TranslationTable,
|
||||
TRANSLATION_TABLE_PAGE_SIZE);
|
||||
InvalidateDataCacheRange (
|
||||
(VOID *)TranslationTable,
|
||||
TRANSLATION_TABLE_PAGE_SIZE
|
||||
);
|
||||
ZeroMem ((VOID *)TranslationTable, TRANSLATION_TABLE_PAGE_SIZE);
|
||||
|
||||
*SectionEntry = (TranslationTable & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK) |
|
||||
(IS_ARM_MEMORY_REGION_ATTRIBUTES_SECURE(Attributes) ? (1 << 3) : 0) |
|
||||
TT_DESCRIPTOR_SECTION_TYPE_PAGE_TABLE;
|
||||
(IS_ARM_MEMORY_REGION_ATTRIBUTES_SECURE (Attributes) ? (1 << 3) : 0) |
|
||||
TT_DESCRIPTOR_SECTION_TYPE_PAGE_TABLE;
|
||||
}
|
||||
|
||||
FirstPageOffset = (PhysicalBase & TT_DESCRIPTOR_PAGE_INDEX_MASK) >> TT_DESCRIPTOR_PAGE_BASE_SHIFT;
|
||||
PageEntry = (UINT32 *)TranslationTable + FirstPageOffset;
|
||||
Pages = RemainLength / TT_DESCRIPTOR_PAGE_SIZE;
|
||||
PageEntry = (UINT32 *)TranslationTable + FirstPageOffset;
|
||||
Pages = RemainLength / TT_DESCRIPTOR_PAGE_SIZE;
|
||||
|
||||
ASSERT (FirstPageOffset + Pages <= TRANSLATION_TABLE_PAGE_COUNT);
|
||||
|
||||
for (Index = 0; Index < Pages; Index++) {
|
||||
*PageEntry++ = TT_DESCRIPTOR_PAGE_BASE_ADDRESS(PhysicalBase) | PageAttributes;
|
||||
*PageEntry++ = TT_DESCRIPTOR_PAGE_BASE_ADDRESS (PhysicalBase) | PageAttributes;
|
||||
PhysicalBase += TT_DESCRIPTOR_PAGE_SIZE;
|
||||
}
|
||||
|
||||
@@ -202,8 +209,10 @@ PopulateLevel2PageTable (
|
||||
// [speculatively] since the previous invalidate are evicted again.
|
||||
//
|
||||
ArmDataMemoryBarrier ();
|
||||
InvalidateDataCacheRange ((UINT32 *)TranslationTable + FirstPageOffset,
|
||||
RemainLength / TT_DESCRIPTOR_PAGE_SIZE * sizeof (*PageEntry));
|
||||
InvalidateDataCacheRange (
|
||||
(UINT32 *)TranslationTable + FirstPageOffset,
|
||||
RemainLength / TT_DESCRIPTOR_PAGE_SIZE * sizeof (*PageEntry)
|
||||
);
|
||||
}
|
||||
|
||||
STATIC
|
||||
@@ -219,50 +228,50 @@ FillTranslationTable (
|
||||
UINT64 RemainLength;
|
||||
UINT32 PageMapLength;
|
||||
|
||||
ASSERT(MemoryRegion->Length > 0);
|
||||
ASSERT (MemoryRegion->Length > 0);
|
||||
|
||||
if (MemoryRegion->PhysicalBase >= SIZE_4GB) {
|
||||
return;
|
||||
}
|
||||
|
||||
PhysicalBase = (UINT32)MemoryRegion->PhysicalBase;
|
||||
RemainLength = MIN(MemoryRegion->Length, SIZE_4GB - PhysicalBase);
|
||||
RemainLength = MIN (MemoryRegion->Length, SIZE_4GB - PhysicalBase);
|
||||
|
||||
switch (MemoryRegion->Attributes) {
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:
|
||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(0);
|
||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK (0);
|
||||
break;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:
|
||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(0);
|
||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK (0);
|
||||
Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;
|
||||
break;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:
|
||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH(0);
|
||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH (0);
|
||||
break;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:
|
||||
Attributes = TT_DESCRIPTOR_SECTION_DEVICE(0);
|
||||
Attributes = TT_DESCRIPTOR_SECTION_DEVICE (0);
|
||||
break;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:
|
||||
Attributes = TT_DESCRIPTOR_SECTION_UNCACHED(0);
|
||||
Attributes = TT_DESCRIPTOR_SECTION_UNCACHED (0);
|
||||
break;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK:
|
||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(1);
|
||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK (1);
|
||||
break;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE:
|
||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(1);
|
||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK (1);
|
||||
Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;
|
||||
break;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH:
|
||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH(1);
|
||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH (1);
|
||||
break;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:
|
||||
Attributes = TT_DESCRIPTOR_SECTION_DEVICE(1);
|
||||
Attributes = TT_DESCRIPTOR_SECTION_DEVICE (1);
|
||||
break;
|
||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED:
|
||||
Attributes = TT_DESCRIPTOR_SECTION_UNCACHED(1);
|
||||
Attributes = TT_DESCRIPTOR_SECTION_UNCACHED (1);
|
||||
break;
|
||||
default:
|
||||
Attributes = TT_DESCRIPTOR_SECTION_UNCACHED(0);
|
||||
Attributes = TT_DESCRIPTOR_SECTION_UNCACHED (0);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -271,14 +280,15 @@ FillTranslationTable (
|
||||
}
|
||||
|
||||
// Get the first section entry for this mapping
|
||||
SectionEntry = TRANSLATION_TABLE_ENTRY_FOR_VIRTUAL_ADDRESS(TranslationTable, MemoryRegion->VirtualBase);
|
||||
SectionEntry = TRANSLATION_TABLE_ENTRY_FOR_VIRTUAL_ADDRESS (TranslationTable, MemoryRegion->VirtualBase);
|
||||
|
||||
while (RemainLength != 0) {
|
||||
if (PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE == 0 &&
|
||||
RemainLength >= TT_DESCRIPTOR_SECTION_SIZE) {
|
||||
if ((PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE == 0) &&
|
||||
(RemainLength >= TT_DESCRIPTOR_SECTION_SIZE))
|
||||
{
|
||||
// Case: Physical address aligned on the Section Size (1MB) && the length
|
||||
// is greater than the Section Size
|
||||
*SectionEntry = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(PhysicalBase) | Attributes;
|
||||
*SectionEntry = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (PhysicalBase) | Attributes;
|
||||
|
||||
//
|
||||
// Issue a DMB to ensure that the page table entry update made it to
|
||||
@@ -291,14 +301,21 @@ FillTranslationTable (
|
||||
PhysicalBase += TT_DESCRIPTOR_SECTION_SIZE;
|
||||
RemainLength -= TT_DESCRIPTOR_SECTION_SIZE;
|
||||
} else {
|
||||
PageMapLength = MIN ((UINT32)RemainLength, TT_DESCRIPTOR_SECTION_SIZE -
|
||||
(PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE));
|
||||
PageMapLength = MIN (
|
||||
(UINT32)RemainLength,
|
||||
TT_DESCRIPTOR_SECTION_SIZE -
|
||||
(PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE)
|
||||
);
|
||||
|
||||
// Case: Physical address aligned on the Section Size (1MB) && the length
|
||||
// does not fill a section
|
||||
// Case: Physical address NOT aligned on the Section Size (1MB)
|
||||
PopulateLevel2PageTable (SectionEntry, PhysicalBase, PageMapLength,
|
||||
MemoryRegion->Attributes);
|
||||
PopulateLevel2PageTable (
|
||||
SectionEntry,
|
||||
PhysicalBase,
|
||||
PageMapLength,
|
||||
MemoryRegion->Attributes
|
||||
);
|
||||
|
||||
//
|
||||
// Issue a DMB to ensure that the page table entry update made it to
|
||||
@@ -323,16 +340,17 @@ RETURN_STATUS
|
||||
EFIAPI
|
||||
ArmConfigureMmu (
|
||||
IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable,
|
||||
OUT VOID **TranslationTableBase OPTIONAL,
|
||||
OUT VOID **TranslationTableBase OPTIONAL,
|
||||
OUT UINTN *TranslationTableSize OPTIONAL
|
||||
)
|
||||
{
|
||||
VOID *TranslationTable;
|
||||
UINT32 TTBRAttributes;
|
||||
VOID *TranslationTable;
|
||||
UINT32 TTBRAttributes;
|
||||
|
||||
TranslationTable = AllocateAlignedPages (
|
||||
EFI_SIZE_TO_PAGES (TRANSLATION_TABLE_SECTION_SIZE),
|
||||
TRANSLATION_TABLE_SECTION_ALIGNMENT);
|
||||
TRANSLATION_TABLE_SECTION_ALIGNMENT
|
||||
);
|
||||
if (TranslationTable == NULL) {
|
||||
return RETURN_OUT_OF_RESOURCES;
|
||||
}
|
||||
@@ -389,25 +407,27 @@ ArmConfigureMmu (
|
||||
//
|
||||
ArmSetTTBCR (0);
|
||||
|
||||
ArmSetDomainAccessControl (DOMAIN_ACCESS_CONTROL_NONE(15) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE(14) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE(13) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE(12) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE(11) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE(10) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE( 9) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE( 8) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE( 7) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE( 6) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE( 5) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE( 4) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE( 3) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE( 2) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE( 1) |
|
||||
DOMAIN_ACCESS_CONTROL_CLIENT(0));
|
||||
ArmSetDomainAccessControl (
|
||||
DOMAIN_ACCESS_CONTROL_NONE (15) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (14) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (13) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (12) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (11) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (10) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (9) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (8) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (7) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (6) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (5) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (4) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (3) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (2) |
|
||||
DOMAIN_ACCESS_CONTROL_NONE (1) |
|
||||
DOMAIN_ACCESS_CONTROL_CLIENT (0)
|
||||
);
|
||||
|
||||
ArmEnableInstructionCache();
|
||||
ArmEnableDataCache();
|
||||
ArmEnableMmu();
|
||||
ArmEnableInstructionCache ();
|
||||
ArmEnableDataCache ();
|
||||
ArmEnableMmu ();
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
@@ -18,9 +18,9 @@
|
||||
|
||||
#include <Chipset/ArmV7.h>
|
||||
|
||||
#define __EFI_MEMORY_RWX 0 // no restrictions
|
||||
#define __EFI_MEMORY_RWX 0 // no restrictions
|
||||
|
||||
#define CACHE_ATTRIBUTE_MASK (EFI_MEMORY_UC | \
|
||||
#define CACHE_ATTRIBUTE_MASK (EFI_MEMORY_UC | \
|
||||
EFI_MEMORY_WC | \
|
||||
EFI_MEMORY_WT | \
|
||||
EFI_MEMORY_WB | \
|
||||
@@ -33,14 +33,14 @@ ConvertSectionToPages (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress
|
||||
)
|
||||
{
|
||||
UINT32 FirstLevelIdx;
|
||||
UINT32 SectionDescriptor;
|
||||
UINT32 PageTableDescriptor;
|
||||
UINT32 PageDescriptor;
|
||||
UINT32 Index;
|
||||
UINT32 FirstLevelIdx;
|
||||
UINT32 SectionDescriptor;
|
||||
UINT32 PageTableDescriptor;
|
||||
UINT32 PageDescriptor;
|
||||
UINT32 Index;
|
||||
|
||||
volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;
|
||||
volatile ARM_PAGE_TABLE_ENTRY *PageTable;
|
||||
volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;
|
||||
volatile ARM_PAGE_TABLE_ENTRY *PageTable;
|
||||
|
||||
DEBUG ((DEBUG_PAGE, "Converting section at 0x%x to pages\n", (UINTN)BaseAddress));
|
||||
|
||||
@@ -48,12 +48,12 @@ ConvertSectionToPages (
|
||||
FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress ();
|
||||
|
||||
// Calculate index into first level translation table for start of modification
|
||||
FirstLevelIdx = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(BaseAddress) >> TT_DESCRIPTOR_SECTION_BASE_SHIFT;
|
||||
FirstLevelIdx = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (BaseAddress) >> TT_DESCRIPTOR_SECTION_BASE_SHIFT;
|
||||
ASSERT (FirstLevelIdx < TRANSLATION_TABLE_SECTION_COUNT);
|
||||
|
||||
// Get section attributes and convert to page attributes
|
||||
SectionDescriptor = FirstLevelTable[FirstLevelIdx];
|
||||
PageDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE | ConvertSectionAttributesToPageAttributes (SectionDescriptor, FALSE);
|
||||
PageDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE | ConvertSectionAttributesToPageAttributes (SectionDescriptor, FALSE);
|
||||
|
||||
// Allocate a page table for the 4KB entries (we use up a full page even though we only need 1KB)
|
||||
PageTable = (volatile ARM_PAGE_TABLE_ENTRY *)AllocatePages (1);
|
||||
@@ -63,7 +63,7 @@ ConvertSectionToPages (
|
||||
|
||||
// Write the page table entries out
|
||||
for (Index = 0; Index < TRANSLATION_TABLE_PAGE_COUNT; Index++) {
|
||||
PageTable[Index] = TT_DESCRIPTOR_PAGE_BASE_ADDRESS(BaseAddress + (Index << 12)) | PageDescriptor;
|
||||
PageTable[Index] = TT_DESCRIPTOR_PAGE_BASE_ADDRESS (BaseAddress + (Index << 12)) | PageDescriptor;
|
||||
}
|
||||
|
||||
// Formulate page table entry, Domain=0, NS=0
|
||||
@@ -78,27 +78,27 @@ ConvertSectionToPages (
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
UpdatePageEntries (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes,
|
||||
OUT BOOLEAN *FlushTlbs OPTIONAL
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes,
|
||||
OUT BOOLEAN *FlushTlbs OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 EntryValue;
|
||||
UINT32 EntryMask;
|
||||
UINT32 FirstLevelIdx;
|
||||
UINT32 Offset;
|
||||
UINT32 NumPageEntries;
|
||||
UINT32 Descriptor;
|
||||
UINT32 p;
|
||||
UINT32 PageTableIndex;
|
||||
UINT32 PageTableEntry;
|
||||
UINT32 CurrentPageTableEntry;
|
||||
VOID *Mva;
|
||||
EFI_STATUS Status;
|
||||
UINT32 EntryValue;
|
||||
UINT32 EntryMask;
|
||||
UINT32 FirstLevelIdx;
|
||||
UINT32 Offset;
|
||||
UINT32 NumPageEntries;
|
||||
UINT32 Descriptor;
|
||||
UINT32 p;
|
||||
UINT32 PageTableIndex;
|
||||
UINT32 PageTableEntry;
|
||||
UINT32 CurrentPageTableEntry;
|
||||
VOID *Mva;
|
||||
|
||||
volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;
|
||||
volatile ARM_PAGE_TABLE_ENTRY *PageTable;
|
||||
volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;
|
||||
volatile ARM_PAGE_TABLE_ENTRY *PageTable;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
@@ -156,19 +156,19 @@ UpdatePageEntries (
|
||||
|
||||
// Iterate for the number of 4KB pages to change
|
||||
Offset = 0;
|
||||
for(p = 0; p < NumPageEntries; p++) {
|
||||
for (p = 0; p < NumPageEntries; p++) {
|
||||
// Calculate index into first level translation table for page table value
|
||||
|
||||
FirstLevelIdx = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(BaseAddress + Offset) >> TT_DESCRIPTOR_SECTION_BASE_SHIFT;
|
||||
FirstLevelIdx = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (BaseAddress + Offset) >> TT_DESCRIPTOR_SECTION_BASE_SHIFT;
|
||||
ASSERT (FirstLevelIdx < TRANSLATION_TABLE_SECTION_COUNT);
|
||||
|
||||
// Read the descriptor from the first level page table
|
||||
Descriptor = FirstLevelTable[FirstLevelIdx];
|
||||
|
||||
// Does this descriptor need to be converted from section entry to 4K pages?
|
||||
if (!TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE(Descriptor)) {
|
||||
if (!TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE (Descriptor)) {
|
||||
Status = ConvertSectionToPages (FirstLevelIdx << TT_DESCRIPTOR_SECTION_BASE_SHIFT);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
// Exit for loop
|
||||
break;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ UpdatePageEntries (
|
||||
}
|
||||
|
||||
// Obtain page table base address
|
||||
PageTable = (ARM_PAGE_TABLE_ENTRY *)TT_DESCRIPTOR_PAGE_BASE_ADDRESS(Descriptor);
|
||||
PageTable = (ARM_PAGE_TABLE_ENTRY *)TT_DESCRIPTOR_PAGE_BASE_ADDRESS (Descriptor);
|
||||
|
||||
// Calculate index into the page table
|
||||
PageTableIndex = ((BaseAddress + Offset) & TT_DESCRIPTOR_PAGE_INDEX_MASK) >> TT_DESCRIPTOR_PAGE_BASE_SHIFT;
|
||||
@@ -204,9 +204,8 @@ UpdatePageEntries (
|
||||
ArmUpdateTranslationTableEntry ((VOID *)&PageTable[PageTableIndex], Mva);
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Status = EFI_SUCCESS;
|
||||
Offset += TT_DESCRIPTOR_PAGE_SIZE;
|
||||
|
||||
} // End first level translation table loop
|
||||
|
||||
return Status;
|
||||
@@ -215,21 +214,21 @@ UpdatePageEntries (
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
UpdateSectionEntries (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 EntryMask;
|
||||
UINT32 EntryValue;
|
||||
UINT32 FirstLevelIdx;
|
||||
UINT32 NumSections;
|
||||
UINT32 i;
|
||||
UINT32 CurrentDescriptor;
|
||||
UINT32 Descriptor;
|
||||
VOID *Mva;
|
||||
volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;
|
||||
EFI_STATUS Status;
|
||||
UINT32 EntryMask;
|
||||
UINT32 EntryValue;
|
||||
UINT32 FirstLevelIdx;
|
||||
UINT32 NumSections;
|
||||
UINT32 i;
|
||||
UINT32 CurrentDescriptor;
|
||||
UINT32 Descriptor;
|
||||
VOID *Mva;
|
||||
volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
@@ -286,24 +285,25 @@ UpdateSectionEntries (
|
||||
FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress ();
|
||||
|
||||
// calculate index into first level translation table for start of modification
|
||||
FirstLevelIdx = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(BaseAddress) >> TT_DESCRIPTOR_SECTION_BASE_SHIFT;
|
||||
FirstLevelIdx = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (BaseAddress) >> TT_DESCRIPTOR_SECTION_BASE_SHIFT;
|
||||
ASSERT (FirstLevelIdx < TRANSLATION_TABLE_SECTION_COUNT);
|
||||
|
||||
// calculate number of 1MB first level entries this applies to
|
||||
NumSections = (UINT32)(Length / TT_DESCRIPTOR_SECTION_SIZE);
|
||||
|
||||
// iterate through each descriptor
|
||||
for(i=0; i<NumSections; i++) {
|
||||
for (i = 0; i < NumSections; i++) {
|
||||
CurrentDescriptor = FirstLevelTable[FirstLevelIdx + i];
|
||||
|
||||
// has this descriptor already been converted to pages?
|
||||
if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE(CurrentDescriptor)) {
|
||||
if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE (CurrentDescriptor)) {
|
||||
// forward this 1MB range to page table function instead
|
||||
Status = UpdatePageEntries (
|
||||
(FirstLevelIdx + i) << TT_DESCRIPTOR_SECTION_BASE_SHIFT,
|
||||
TT_DESCRIPTOR_SECTION_SIZE,
|
||||
Attributes,
|
||||
NULL);
|
||||
NULL
|
||||
);
|
||||
} else {
|
||||
// still a section entry
|
||||
|
||||
@@ -334,14 +334,14 @@ UpdateSectionEntries (
|
||||
|
||||
EFI_STATUS
|
||||
ArmSetMemoryAttributes (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT64 ChunkLength;
|
||||
BOOLEAN FlushTlbs;
|
||||
EFI_STATUS Status;
|
||||
UINT64 ChunkLength;
|
||||
BOOLEAN FlushTlbs;
|
||||
|
||||
if (BaseAddress > (UINT64)MAX_ADDRESS) {
|
||||
return EFI_UNSUPPORTED;
|
||||
@@ -355,19 +355,22 @@ ArmSetMemoryAttributes (
|
||||
FlushTlbs = FALSE;
|
||||
while (Length > 0) {
|
||||
if ((BaseAddress % TT_DESCRIPTOR_SECTION_SIZE == 0) &&
|
||||
Length >= TT_DESCRIPTOR_SECTION_SIZE) {
|
||||
|
||||
(Length >= TT_DESCRIPTOR_SECTION_SIZE))
|
||||
{
|
||||
ChunkLength = Length - Length % TT_DESCRIPTOR_SECTION_SIZE;
|
||||
|
||||
DEBUG ((DEBUG_PAGE,
|
||||
DEBUG ((
|
||||
DEBUG_PAGE,
|
||||
"SetMemoryAttributes(): MMU section 0x%lx length 0x%lx to %lx\n",
|
||||
BaseAddress, ChunkLength, Attributes));
|
||||
BaseAddress,
|
||||
ChunkLength,
|
||||
Attributes
|
||||
));
|
||||
|
||||
Status = UpdateSectionEntries (BaseAddress, ChunkLength, Attributes);
|
||||
|
||||
FlushTlbs = TRUE;
|
||||
} else {
|
||||
|
||||
//
|
||||
// Process page by page until the next section boundary, but only if
|
||||
// we have more than a section's worth of area to deal with after that.
|
||||
@@ -378,12 +381,20 @@ ArmSetMemoryAttributes (
|
||||
ChunkLength = Length;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_PAGE,
|
||||
DEBUG ((
|
||||
DEBUG_PAGE,
|
||||
"SetMemoryAttributes(): MMU page 0x%lx length 0x%lx to %lx\n",
|
||||
BaseAddress, ChunkLength, Attributes));
|
||||
BaseAddress,
|
||||
ChunkLength,
|
||||
Attributes
|
||||
));
|
||||
|
||||
Status = UpdatePageEntries (BaseAddress, ChunkLength, Attributes,
|
||||
&FlushTlbs);
|
||||
Status = UpdatePageEntries (
|
||||
BaseAddress,
|
||||
ChunkLength,
|
||||
Attributes,
|
||||
&FlushTlbs
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -391,19 +402,20 @@ ArmSetMemoryAttributes (
|
||||
}
|
||||
|
||||
BaseAddress += ChunkLength;
|
||||
Length -= ChunkLength;
|
||||
Length -= ChunkLength;
|
||||
}
|
||||
|
||||
if (FlushTlbs) {
|
||||
ArmInvalidateTlb ();
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmSetMemoryRegionNoExec (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return ArmSetMemoryAttributes (BaseAddress, Length, EFI_MEMORY_XP);
|
||||
@@ -411,8 +423,8 @@ ArmSetMemoryRegionNoExec (
|
||||
|
||||
EFI_STATUS
|
||||
ArmClearMemoryRegionNoExec (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return ArmSetMemoryAttributes (BaseAddress, Length, __EFI_MEMORY_RWX);
|
||||
@@ -420,8 +432,8 @@ ArmClearMemoryRegionNoExec (
|
||||
|
||||
EFI_STATUS
|
||||
ArmSetMemoryRegionReadOnly (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return ArmSetMemoryAttributes (BaseAddress, Length, EFI_MEMORY_RO);
|
||||
@@ -429,8 +441,8 @@ ArmSetMemoryRegionReadOnly (
|
||||
|
||||
EFI_STATUS
|
||||
ArmClearMemoryRegionReadOnly (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return ArmSetMemoryAttributes (BaseAddress, Length, __EFI_MEMORY_RWX);
|
||||
|
@@ -34,7 +34,7 @@ MtlWaitUntilChannelFree (
|
||||
|
||||
@retval UINT32* Pointer to the payload.
|
||||
**/
|
||||
UINT32*
|
||||
UINT32 *
|
||||
MtlGetChannelPayload (
|
||||
IN MTL_CHANNEL *Channel
|
||||
)
|
||||
|
@@ -36,30 +36,30 @@
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LibResetSystem (
|
||||
IN EFI_RESET_TYPE ResetType,
|
||||
IN EFI_STATUS ResetStatus,
|
||||
IN UINTN DataSize,
|
||||
IN CHAR16 *ResetData OPTIONAL
|
||||
IN EFI_RESET_TYPE ResetType,
|
||||
IN EFI_STATUS ResetStatus,
|
||||
IN UINTN DataSize,
|
||||
IN CHAR16 *ResetData OPTIONAL
|
||||
)
|
||||
{
|
||||
ARM_SMC_ARGS ArmSmcArgs;
|
||||
ARM_SMC_ARGS ArmSmcArgs;
|
||||
|
||||
switch (ResetType) {
|
||||
case EfiResetPlatformSpecific:
|
||||
case EfiResetPlatformSpecific:
|
||||
// Map the platform specific reset as reboot
|
||||
case EfiResetWarm:
|
||||
case EfiResetWarm:
|
||||
// Map a warm reset into a cold reset
|
||||
case EfiResetCold:
|
||||
// Send a PSCI 0.2 SYSTEM_RESET command
|
||||
ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
|
||||
break;
|
||||
case EfiResetShutdown:
|
||||
// Send a PSCI 0.2 SYSTEM_OFF command
|
||||
ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
|
||||
break;
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
return EFI_UNSUPPORTED;
|
||||
case EfiResetCold:
|
||||
// Send a PSCI 0.2 SYSTEM_RESET command
|
||||
ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
|
||||
break;
|
||||
case EfiResetShutdown:
|
||||
// Send a PSCI 0.2 SYSTEM_OFF command
|
||||
ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
|
||||
break;
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
ArmCallSmc (&ArmSmcArgs);
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
VOID
|
||||
ArmCallSmc (
|
||||
IN OUT ARM_SMC_ARGS *Args
|
||||
IN OUT ARM_SMC_ARGS *Args
|
||||
)
|
||||
{
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ ResetCold (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ARM_SMC_ARGS ArmSmcArgs;
|
||||
ARM_SMC_ARGS ArmSmcArgs;
|
||||
|
||||
// Send a PSCI 0.2 SYSTEM_RESET command
|
||||
ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
|
||||
@@ -66,7 +66,7 @@ ResetShutdown (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ARM_SMC_ARGS ArmSmcArgs;
|
||||
ARM_SMC_ARGS ArmSmcArgs;
|
||||
|
||||
// Send a PSCI 0.2 SYSTEM_OFF command
|
||||
ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
|
||||
@@ -87,8 +87,8 @@ ResetShutdown (
|
||||
VOID
|
||||
EFIAPI
|
||||
ResetPlatformSpecific (
|
||||
IN UINTN DataSize,
|
||||
IN VOID *ResetData
|
||||
IN UINTN DataSize,
|
||||
IN VOID *ResetData
|
||||
)
|
||||
{
|
||||
// Map the platform specific reset as reboot
|
||||
@@ -110,30 +110,30 @@ ResetPlatformSpecific (
|
||||
VOID
|
||||
EFIAPI
|
||||
ResetSystem (
|
||||
IN EFI_RESET_TYPE ResetType,
|
||||
IN EFI_STATUS ResetStatus,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *ResetData OPTIONAL
|
||||
IN EFI_RESET_TYPE ResetType,
|
||||
IN EFI_STATUS ResetStatus,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *ResetData OPTIONAL
|
||||
)
|
||||
{
|
||||
switch (ResetType) {
|
||||
case EfiResetWarm:
|
||||
ResetWarm ();
|
||||
break;
|
||||
case EfiResetWarm:
|
||||
ResetWarm ();
|
||||
break;
|
||||
|
||||
case EfiResetCold:
|
||||
ResetCold ();
|
||||
break;
|
||||
case EfiResetCold:
|
||||
ResetCold ();
|
||||
break;
|
||||
|
||||
case EfiResetShutdown:
|
||||
ResetShutdown ();
|
||||
return;
|
||||
case EfiResetShutdown:
|
||||
ResetShutdown ();
|
||||
return;
|
||||
|
||||
case EfiResetPlatformSpecific:
|
||||
ResetPlatformSpecific (DataSize, ResetData);
|
||||
return;
|
||||
case EfiResetPlatformSpecific:
|
||||
ResetPlatformSpecific (DataSize, ResetData);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -18,35 +18,47 @@
|
||||
* have been expected we use aeabi_float_t and aeabi_double_t respectively
|
||||
* instead.
|
||||
*/
|
||||
typedef uint32_t aeabi_float_t;
|
||||
typedef uint64_t aeabi_double_t;
|
||||
typedef uint32_t aeabi_float_t;
|
||||
typedef uint64_t aeabi_double_t;
|
||||
|
||||
/*
|
||||
* Helpers to convert between float32 and aeabi_float_t, and float64 and
|
||||
* aeabi_double_t used by the AEABI functions below.
|
||||
*/
|
||||
static aeabi_float_t f32_to_f(float32_t val)
|
||||
static aeabi_float_t
|
||||
f32_to_f (
|
||||
float32_t val
|
||||
)
|
||||
{
|
||||
return val.v;
|
||||
}
|
||||
|
||||
static float32_t f32_from_f(aeabi_float_t val)
|
||||
static float32_t
|
||||
f32_from_f (
|
||||
aeabi_float_t val
|
||||
)
|
||||
{
|
||||
float32_t res;
|
||||
float32_t res;
|
||||
|
||||
res.v = val;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static aeabi_double_t f64_to_d(float64_t val)
|
||||
static aeabi_double_t
|
||||
f64_to_d (
|
||||
float64_t val
|
||||
)
|
||||
{
|
||||
return val.v;
|
||||
}
|
||||
|
||||
static float64_t f64_from_d(aeabi_double_t val)
|
||||
static float64_t
|
||||
f64_from_d (
|
||||
aeabi_double_t val
|
||||
)
|
||||
{
|
||||
float64_t res;
|
||||
float64_t res;
|
||||
|
||||
res.v = val;
|
||||
|
||||
@@ -64,220 +76,346 @@ static float64_t f64_from_d(aeabi_double_t val)
|
||||
* Table 2, Standard aeabi_double_t precision floating-point arithmetic helper
|
||||
* functions
|
||||
*/
|
||||
|
||||
aeabi_double_t __aeabi_dadd(aeabi_double_t a, aeabi_double_t b)
|
||||
aeabi_double_t
|
||||
__aeabi_dadd (
|
||||
aeabi_double_t a,
|
||||
aeabi_double_t b
|
||||
)
|
||||
{
|
||||
return f64_to_d(f64_add(f64_from_d(a), f64_from_d(b)));
|
||||
return f64_to_d (f64_add (f64_from_d (a), f64_from_d (b)));
|
||||
}
|
||||
|
||||
aeabi_double_t __aeabi_ddiv(aeabi_double_t a, aeabi_double_t b)
|
||||
aeabi_double_t
|
||||
__aeabi_ddiv (
|
||||
aeabi_double_t a,
|
||||
aeabi_double_t b
|
||||
)
|
||||
{
|
||||
return f64_to_d(f64_div(f64_from_d(a), f64_from_d(b)));
|
||||
return f64_to_d (f64_div (f64_from_d (a), f64_from_d (b)));
|
||||
}
|
||||
|
||||
aeabi_double_t __aeabi_dmul(aeabi_double_t a, aeabi_double_t b)
|
||||
aeabi_double_t
|
||||
__aeabi_dmul (
|
||||
aeabi_double_t a,
|
||||
aeabi_double_t b
|
||||
)
|
||||
{
|
||||
return f64_to_d(f64_mul(f64_from_d(a), f64_from_d(b)));
|
||||
return f64_to_d (f64_mul (f64_from_d (a), f64_from_d (b)));
|
||||
}
|
||||
|
||||
|
||||
aeabi_double_t __aeabi_drsub(aeabi_double_t a, aeabi_double_t b)
|
||||
aeabi_double_t
|
||||
__aeabi_drsub (
|
||||
aeabi_double_t a,
|
||||
aeabi_double_t b
|
||||
)
|
||||
{
|
||||
return f64_to_d(f64_sub(f64_from_d(b), f64_from_d(a)));
|
||||
return f64_to_d (f64_sub (f64_from_d (b), f64_from_d (a)));
|
||||
}
|
||||
|
||||
aeabi_double_t __aeabi_dsub(aeabi_double_t a, aeabi_double_t b)
|
||||
aeabi_double_t
|
||||
__aeabi_dsub (
|
||||
aeabi_double_t a,
|
||||
aeabi_double_t b
|
||||
)
|
||||
{
|
||||
return f64_to_d(f64_sub(f64_from_d(a), f64_from_d(b)));
|
||||
return f64_to_d (f64_sub (f64_from_d (a), f64_from_d (b)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Table 3, double precision floating-point comparison helper functions
|
||||
*/
|
||||
|
||||
int __aeabi_dcmpeq(aeabi_double_t a, aeabi_double_t b)
|
||||
int
|
||||
__aeabi_dcmpeq (
|
||||
aeabi_double_t a,
|
||||
aeabi_double_t b
|
||||
)
|
||||
{
|
||||
return f64_eq(f64_from_d(a), f64_from_d(b));
|
||||
return f64_eq (f64_from_d (a), f64_from_d (b));
|
||||
}
|
||||
|
||||
int __aeabi_dcmplt(aeabi_double_t a, aeabi_double_t b)
|
||||
int
|
||||
__aeabi_dcmplt (
|
||||
aeabi_double_t a,
|
||||
aeabi_double_t b
|
||||
)
|
||||
{
|
||||
return f64_lt(f64_from_d(a), f64_from_d(b));
|
||||
return f64_lt (f64_from_d (a), f64_from_d (b));
|
||||
}
|
||||
|
||||
int __aeabi_dcmple(aeabi_double_t a, aeabi_double_t b)
|
||||
int
|
||||
__aeabi_dcmple (
|
||||
aeabi_double_t a,
|
||||
aeabi_double_t b
|
||||
)
|
||||
{
|
||||
return f64_le(f64_from_d(a), f64_from_d(b));
|
||||
return f64_le (f64_from_d (a), f64_from_d (b));
|
||||
}
|
||||
|
||||
int __aeabi_dcmpge(aeabi_double_t a, aeabi_double_t b)
|
||||
int
|
||||
__aeabi_dcmpge (
|
||||
aeabi_double_t a,
|
||||
aeabi_double_t b
|
||||
)
|
||||
{
|
||||
return f64_le(f64_from_d(b), f64_from_d(a));
|
||||
return f64_le (f64_from_d (b), f64_from_d (a));
|
||||
}
|
||||
|
||||
int __aeabi_dcmpgt(aeabi_double_t a, aeabi_double_t b)
|
||||
int
|
||||
__aeabi_dcmpgt (
|
||||
aeabi_double_t a,
|
||||
aeabi_double_t b
|
||||
)
|
||||
{
|
||||
return f64_lt(f64_from_d(b), f64_from_d(a));
|
||||
return f64_lt (f64_from_d (b), f64_from_d (a));
|
||||
}
|
||||
|
||||
/*
|
||||
* Table 4, Standard single precision floating-point arithmetic helper
|
||||
* functions
|
||||
*/
|
||||
|
||||
aeabi_float_t __aeabi_fadd(aeabi_float_t a, aeabi_float_t b)
|
||||
aeabi_float_t
|
||||
__aeabi_fadd (
|
||||
aeabi_float_t a,
|
||||
aeabi_float_t b
|
||||
)
|
||||
{
|
||||
return f32_to_f(f32_add(f32_from_f(a), f32_from_f(b)));
|
||||
return f32_to_f (f32_add (f32_from_f (a), f32_from_f (b)));
|
||||
}
|
||||
|
||||
aeabi_float_t __aeabi_fdiv(aeabi_float_t a, aeabi_float_t b)
|
||||
aeabi_float_t
|
||||
__aeabi_fdiv (
|
||||
aeabi_float_t a,
|
||||
aeabi_float_t b
|
||||
)
|
||||
{
|
||||
return f32_to_f(f32_div(f32_from_f(a), f32_from_f(b)));
|
||||
return f32_to_f (f32_div (f32_from_f (a), f32_from_f (b)));
|
||||
}
|
||||
|
||||
aeabi_float_t __aeabi_fmul(aeabi_float_t a, aeabi_float_t b)
|
||||
aeabi_float_t
|
||||
__aeabi_fmul (
|
||||
aeabi_float_t a,
|
||||
aeabi_float_t b
|
||||
)
|
||||
{
|
||||
return f32_to_f(f32_mul(f32_from_f(a), f32_from_f(b)));
|
||||
return f32_to_f (f32_mul (f32_from_f (a), f32_from_f (b)));
|
||||
}
|
||||
|
||||
aeabi_float_t __aeabi_frsub(aeabi_float_t a, aeabi_float_t b)
|
||||
aeabi_float_t
|
||||
__aeabi_frsub (
|
||||
aeabi_float_t a,
|
||||
aeabi_float_t b
|
||||
)
|
||||
{
|
||||
return f32_to_f(f32_sub(f32_from_f(b), f32_from_f(a)));
|
||||
return f32_to_f (f32_sub (f32_from_f (b), f32_from_f (a)));
|
||||
}
|
||||
|
||||
aeabi_float_t __aeabi_fsub(aeabi_float_t a, aeabi_float_t b)
|
||||
aeabi_float_t
|
||||
__aeabi_fsub (
|
||||
aeabi_float_t a,
|
||||
aeabi_float_t b
|
||||
)
|
||||
{
|
||||
return f32_to_f(f32_sub(f32_from_f(a), f32_from_f(b)));
|
||||
return f32_to_f (f32_sub (f32_from_f (a), f32_from_f (b)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Table 5, Standard single precision floating-point comparison helper
|
||||
* functions
|
||||
*/
|
||||
|
||||
int __aeabi_fcmpeq(aeabi_float_t a, aeabi_float_t b)
|
||||
int
|
||||
__aeabi_fcmpeq (
|
||||
aeabi_float_t a,
|
||||
aeabi_float_t b
|
||||
)
|
||||
{
|
||||
return f32_eq(f32_from_f(a), f32_from_f(b));
|
||||
return f32_eq (f32_from_f (a), f32_from_f (b));
|
||||
}
|
||||
|
||||
int __aeabi_fcmplt(aeabi_float_t a, aeabi_float_t b)
|
||||
int
|
||||
__aeabi_fcmplt (
|
||||
aeabi_float_t a,
|
||||
aeabi_float_t b
|
||||
)
|
||||
{
|
||||
return f32_lt(f32_from_f(a), f32_from_f(b));
|
||||
return f32_lt (f32_from_f (a), f32_from_f (b));
|
||||
}
|
||||
|
||||
int __aeabi_fcmple(aeabi_float_t a, aeabi_float_t b)
|
||||
int
|
||||
__aeabi_fcmple (
|
||||
aeabi_float_t a,
|
||||
aeabi_float_t b
|
||||
)
|
||||
{
|
||||
return f32_le(f32_from_f(a), f32_from_f(b));
|
||||
return f32_le (f32_from_f (a), f32_from_f (b));
|
||||
}
|
||||
|
||||
int __aeabi_fcmpge(aeabi_float_t a, aeabi_float_t b)
|
||||
int
|
||||
__aeabi_fcmpge (
|
||||
aeabi_float_t a,
|
||||
aeabi_float_t b
|
||||
)
|
||||
{
|
||||
return f32_le(f32_from_f(b), f32_from_f(a));
|
||||
return f32_le (f32_from_f (b), f32_from_f (a));
|
||||
}
|
||||
|
||||
int __aeabi_fcmpgt(aeabi_float_t a, aeabi_float_t b)
|
||||
int
|
||||
__aeabi_fcmpgt (
|
||||
aeabi_float_t a,
|
||||
aeabi_float_t b
|
||||
)
|
||||
{
|
||||
return f32_lt(f32_from_f(b), f32_from_f(a));
|
||||
return f32_lt (f32_from_f (b), f32_from_f (a));
|
||||
}
|
||||
|
||||
/*
|
||||
* Table 6, Standard floating-point to integer conversions
|
||||
*/
|
||||
|
||||
int __aeabi_d2iz(aeabi_double_t a)
|
||||
int
|
||||
__aeabi_d2iz (
|
||||
aeabi_double_t a
|
||||
)
|
||||
{
|
||||
return f64_to_i32_r_minMag(f64_from_d(a), false);
|
||||
return f64_to_i32_r_minMag (f64_from_d (a), false);
|
||||
}
|
||||
|
||||
unsigned __aeabi_d2uiz(aeabi_double_t a)
|
||||
unsigned
|
||||
__aeabi_d2uiz (
|
||||
aeabi_double_t a
|
||||
)
|
||||
{
|
||||
return f64_to_ui32_r_minMag(f64_from_d(a), false);
|
||||
return f64_to_ui32_r_minMag (f64_from_d (a), false);
|
||||
}
|
||||
|
||||
long long __aeabi_d2lz(aeabi_double_t a)
|
||||
long long
|
||||
__aeabi_d2lz (
|
||||
aeabi_double_t a
|
||||
)
|
||||
{
|
||||
return f64_to_i64_r_minMag(f64_from_d(a), false);
|
||||
return f64_to_i64_r_minMag (f64_from_d (a), false);
|
||||
}
|
||||
|
||||
unsigned long long __aeabi_d2ulz(aeabi_double_t a)
|
||||
unsigned long long
|
||||
__aeabi_d2ulz (
|
||||
aeabi_double_t a
|
||||
)
|
||||
{
|
||||
return f64_to_ui64_r_minMag(f64_from_d(a), false);
|
||||
return f64_to_ui64_r_minMag (f64_from_d (a), false);
|
||||
}
|
||||
|
||||
int __aeabi_f2iz(aeabi_float_t a)
|
||||
int
|
||||
__aeabi_f2iz (
|
||||
aeabi_float_t a
|
||||
)
|
||||
{
|
||||
return f32_to_i32_r_minMag(f32_from_f(a), false);
|
||||
return f32_to_i32_r_minMag (f32_from_f (a), false);
|
||||
}
|
||||
|
||||
unsigned __aeabi_f2uiz(aeabi_float_t a)
|
||||
unsigned
|
||||
__aeabi_f2uiz (
|
||||
aeabi_float_t a
|
||||
)
|
||||
{
|
||||
return f32_to_ui32_r_minMag(f32_from_f(a), false);
|
||||
return f32_to_ui32_r_minMag (f32_from_f (a), false);
|
||||
}
|
||||
|
||||
long long __aeabi_f2lz(aeabi_float_t a)
|
||||
long long
|
||||
__aeabi_f2lz (
|
||||
aeabi_float_t a
|
||||
)
|
||||
{
|
||||
return f32_to_i64_r_minMag(f32_from_f(a), false);
|
||||
return f32_to_i64_r_minMag (f32_from_f (a), false);
|
||||
}
|
||||
|
||||
unsigned long long __aeabi_f2ulz(aeabi_float_t a)
|
||||
unsigned long long
|
||||
__aeabi_f2ulz (
|
||||
aeabi_float_t a
|
||||
)
|
||||
{
|
||||
return f32_to_ui64_r_minMag(f32_from_f(a), false);
|
||||
return f32_to_ui64_r_minMag (f32_from_f (a), false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Table 7, Standard conversions between floating types
|
||||
*/
|
||||
|
||||
aeabi_float_t __aeabi_d2f(aeabi_double_t a)
|
||||
aeabi_float_t
|
||||
__aeabi_d2f (
|
||||
aeabi_double_t a
|
||||
)
|
||||
{
|
||||
return f32_to_f(f64_to_f32(f64_from_d(a)));
|
||||
return f32_to_f (f64_to_f32 (f64_from_d (a)));
|
||||
}
|
||||
|
||||
aeabi_double_t __aeabi_f2d(aeabi_float_t a)
|
||||
aeabi_double_t
|
||||
__aeabi_f2d (
|
||||
aeabi_float_t a
|
||||
)
|
||||
{
|
||||
return f64_to_d(f32_to_f64(f32_from_f(a)));
|
||||
return f64_to_d (f32_to_f64 (f32_from_f (a)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Table 8, Standard integer to floating-point conversions
|
||||
*/
|
||||
|
||||
aeabi_double_t __aeabi_i2d(int a)
|
||||
aeabi_double_t
|
||||
__aeabi_i2d (
|
||||
int a
|
||||
)
|
||||
{
|
||||
return f64_to_d(i32_to_f64(a));
|
||||
return f64_to_d (i32_to_f64 (a));
|
||||
}
|
||||
|
||||
aeabi_double_t __aeabi_ui2d(unsigned a)
|
||||
aeabi_double_t
|
||||
__aeabi_ui2d (
|
||||
unsigned a
|
||||
)
|
||||
{
|
||||
return f64_to_d(ui32_to_f64(a));
|
||||
return f64_to_d (ui32_to_f64 (a));
|
||||
}
|
||||
|
||||
aeabi_double_t __aeabi_l2d(long long a)
|
||||
aeabi_double_t
|
||||
__aeabi_l2d (
|
||||
long long a
|
||||
)
|
||||
{
|
||||
return f64_to_d(i64_to_f64(a));
|
||||
return f64_to_d (i64_to_f64 (a));
|
||||
}
|
||||
|
||||
aeabi_double_t __aeabi_ul2d(unsigned long long a)
|
||||
aeabi_double_t
|
||||
__aeabi_ul2d (
|
||||
unsigned long long a
|
||||
)
|
||||
{
|
||||
return f64_to_d(ui64_to_f64(a));
|
||||
return f64_to_d (ui64_to_f64 (a));
|
||||
}
|
||||
|
||||
aeabi_float_t __aeabi_i2f(int a)
|
||||
aeabi_float_t
|
||||
__aeabi_i2f (
|
||||
int a
|
||||
)
|
||||
{
|
||||
return f32_to_f(i32_to_f32(a));
|
||||
return f32_to_f (i32_to_f32 (a));
|
||||
}
|
||||
|
||||
aeabi_float_t __aeabi_ui2f(unsigned a)
|
||||
aeabi_float_t
|
||||
__aeabi_ui2f (
|
||||
unsigned a
|
||||
)
|
||||
{
|
||||
return f32_to_f(ui32_to_f32(a));
|
||||
return f32_to_f (ui32_to_f32 (a));
|
||||
}
|
||||
|
||||
aeabi_float_t __aeabi_l2f(long long a)
|
||||
aeabi_float_t
|
||||
__aeabi_l2f (
|
||||
long long a
|
||||
)
|
||||
{
|
||||
return f32_to_f(i64_to_f32(a));
|
||||
return f32_to_f (i64_to_f32 (a));
|
||||
}
|
||||
|
||||
aeabi_float_t __aeabi_ul2f(unsigned long long a)
|
||||
aeabi_float_t
|
||||
__aeabi_ul2f (
|
||||
unsigned long long a
|
||||
)
|
||||
{
|
||||
return f32_to_f(ui64_to_f32(a));
|
||||
return f32_to_f (ui64_to_f32 (a));
|
||||
}
|
||||
|
@@ -8,9 +8,9 @@
|
||||
#ifndef ARM_SOFT_FLOAT_LIB_H_
|
||||
#define ARM_SOFT_FLOAT_LIB_H_
|
||||
|
||||
#define LITTLEENDIAN 1
|
||||
#define INLINE static inline
|
||||
#define SOFTFLOAT_BUILTIN_CLZ 1
|
||||
#define LITTLEENDIAN 1
|
||||
#define INLINE static inline
|
||||
#define SOFTFLOAT_BUILTIN_CLZ 1
|
||||
#define SOFTFLOAT_FAST_INT64
|
||||
#include "opts-GCC.h"
|
||||
|
||||
|
@@ -1,32 +1,45 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2019, Pete Batard. All rights reserved.
|
||||
// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
#if defined(_M_ARM64)
|
||||
typedef unsigned __int64 size_t;
|
||||
#if defined (_M_ARM64)
|
||||
typedef unsigned __int64 size_t;
|
||||
#else
|
||||
typedef unsigned __int32 size_t;
|
||||
typedef unsigned __int32 size_t;
|
||||
#endif
|
||||
|
||||
int memcmp(void *, void *, size_t);
|
||||
int
|
||||
memcmp (
|
||||
void *,
|
||||
void *,
|
||||
size_t
|
||||
);
|
||||
|
||||
#pragma intrinsic(memcmp)
|
||||
#pragma function(memcmp)
|
||||
int memcmp(const void *s1, const void *s2, size_t n)
|
||||
int
|
||||
memcmp (
|
||||
const void *s1,
|
||||
const void *s2,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
unsigned char const *t1;
|
||||
unsigned char const *t2;
|
||||
unsigned char const *t1;
|
||||
unsigned char const *t2;
|
||||
|
||||
t1 = s1;
|
||||
t2 = s2;
|
||||
|
||||
while (n-- != 0) {
|
||||
if (*t1 != *t2)
|
||||
if (*t1 != *t2) {
|
||||
return (int)*t1 - (int)*t2;
|
||||
}
|
||||
|
||||
t1++;
|
||||
t2++;
|
||||
}
|
||||
|
@@ -1,18 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
|
||||
// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
|
||||
static void __memcpy(void *dest, const void *src, size_t n)
|
||||
static void
|
||||
__memcpy (
|
||||
void *dest,
|
||||
const void *src,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
unsigned char *d;
|
||||
unsigned char const *s;
|
||||
unsigned char *d;
|
||||
unsigned char const *s;
|
||||
|
||||
d = dest;
|
||||
s = src;
|
||||
@@ -22,21 +27,41 @@ static void __memcpy(void *dest, const void *src, size_t n)
|
||||
}
|
||||
}
|
||||
|
||||
void *memcpy(void *dest, const void *src, size_t n)
|
||||
void *
|
||||
memcpy (
|
||||
void *dest,
|
||||
const void *src,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
__memcpy(dest, src, n);
|
||||
__memcpy (dest, src, n);
|
||||
return dest;
|
||||
}
|
||||
|
||||
#ifdef __arm__
|
||||
|
||||
__attribute__((__alias__("__memcpy")))
|
||||
void __aeabi_memcpy(void *dest, const void *src, size_t n);
|
||||
__attribute__ ((__alias__ ("__memcpy")))
|
||||
void
|
||||
__aeabi_memcpy (
|
||||
void *dest,
|
||||
const void *src,
|
||||
size_t n
|
||||
);
|
||||
|
||||
__attribute__((__alias__("__memcpy")))
|
||||
void __aeabi_memcpy4(void *dest, const void *src, size_t n);
|
||||
__attribute__ ((__alias__ ("__memcpy")))
|
||||
void
|
||||
__aeabi_memcpy4 (
|
||||
void *dest,
|
||||
const void *src,
|
||||
size_t n
|
||||
);
|
||||
|
||||
__attribute__((__alias__("__memcpy")))
|
||||
void __aeabi_memcpy8(void *dest, const void *src, size_t n);
|
||||
__attribute__ ((__alias__ ("__memcpy")))
|
||||
void
|
||||
__aeabi_memcpy8 (
|
||||
void *dest,
|
||||
const void *src,
|
||||
size_t n
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -1,25 +1,36 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2017, Pete Batard. All rights reserved.<BR>
|
||||
// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
#if defined(_M_ARM64)
|
||||
typedef unsigned __int64 size_t;
|
||||
#if defined (_M_ARM64)
|
||||
typedef unsigned __int64 size_t;
|
||||
#else
|
||||
typedef unsigned __int32 size_t;
|
||||
typedef unsigned __int32 size_t;
|
||||
#endif
|
||||
|
||||
void* memcpy(void *, const void *, size_t);
|
||||
void *
|
||||
memcpy (
|
||||
void *,
|
||||
const void *,
|
||||
size_t
|
||||
);
|
||||
|
||||
#pragma intrinsic(memcpy)
|
||||
#pragma function(memcpy)
|
||||
void* memcpy(void *dest, const void *src, size_t n)
|
||||
void *
|
||||
memcpy (
|
||||
void *dest,
|
||||
const void *src,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
unsigned char *d;
|
||||
unsigned char const *s;
|
||||
unsigned char *d;
|
||||
unsigned char const *s;
|
||||
|
||||
d = dest;
|
||||
s = src;
|
||||
|
@@ -1,25 +1,36 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2019, Pete Batard. All rights reserved.
|
||||
// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
#if defined(_M_ARM64)
|
||||
typedef unsigned __int64 size_t;
|
||||
#if defined (_M_ARM64)
|
||||
typedef unsigned __int64 size_t;
|
||||
#else
|
||||
typedef unsigned __int32 size_t;
|
||||
typedef unsigned __int32 size_t;
|
||||
#endif
|
||||
|
||||
void* memmove(void *, const void *, size_t);
|
||||
void *
|
||||
memmove (
|
||||
void *,
|
||||
const void *,
|
||||
size_t
|
||||
);
|
||||
|
||||
#pragma intrinsic(memmove)
|
||||
#pragma function(memmove)
|
||||
void* memmove(void *dest, const void *src, size_t n)
|
||||
void *
|
||||
memmove (
|
||||
void *dest,
|
||||
const void *src,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
unsigned char *d;
|
||||
unsigned char const *s;
|
||||
unsigned char *d;
|
||||
unsigned char const *s;
|
||||
|
||||
d = dest;
|
||||
s = src;
|
||||
|
@@ -1,18 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
|
||||
// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
|
||||
static __attribute__((__used__))
|
||||
void *__memset(void *s, int c, size_t n)
|
||||
static __attribute__ ((__used__))
|
||||
void *
|
||||
__memset (
|
||||
void *s,
|
||||
int c,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
unsigned char *d;
|
||||
unsigned char *d;
|
||||
|
||||
d = s;
|
||||
|
||||
@@ -29,31 +34,63 @@ void *__memset(void *s, int c, size_t n)
|
||||
// object was pulled into the link due to the definitions below. So make
|
||||
// our memset() 'weak' to let the other implementation take precedence.
|
||||
//
|
||||
__attribute__((__weak__, __alias__("__memset")))
|
||||
void *memset(void *dest, int c, size_t n);
|
||||
__attribute__ ((__weak__, __alias__ ("__memset")))
|
||||
void *
|
||||
memset (
|
||||
void *dest,
|
||||
int c,
|
||||
size_t n
|
||||
);
|
||||
|
||||
#ifdef __arm__
|
||||
|
||||
void __aeabi_memset(void *dest, size_t n, int c)
|
||||
void
|
||||
__aeabi_memset (
|
||||
void *dest,
|
||||
size_t n,
|
||||
int c
|
||||
)
|
||||
{
|
||||
__memset(dest, c, n);
|
||||
__memset (dest, c, n);
|
||||
}
|
||||
|
||||
__attribute__((__alias__("__aeabi_memset")))
|
||||
void __aeabi_memset4(void *dest, size_t n, int c);
|
||||
__attribute__ ((__alias__ ("__aeabi_memset")))
|
||||
void
|
||||
__aeabi_memset4 (
|
||||
void *dest,
|
||||
size_t n,
|
||||
int c
|
||||
);
|
||||
|
||||
__attribute__((__alias__("__aeabi_memset")))
|
||||
void __aeabi_memset8(void *dest, size_t n, int c);
|
||||
__attribute__ ((__alias__ ("__aeabi_memset")))
|
||||
void
|
||||
__aeabi_memset8 (
|
||||
void *dest,
|
||||
size_t n,
|
||||
int c
|
||||
);
|
||||
|
||||
void __aeabi_memclr(void *dest, size_t n)
|
||||
void
|
||||
__aeabi_memclr (
|
||||
void *dest,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
__memset(dest, 0, n);
|
||||
__memset (dest, 0, n);
|
||||
}
|
||||
|
||||
__attribute__((__alias__("__aeabi_memclr")))
|
||||
void __aeabi_memclr4(void *dest, size_t n);
|
||||
__attribute__ ((__alias__ ("__aeabi_memclr")))
|
||||
void
|
||||
__aeabi_memclr4 (
|
||||
void *dest,
|
||||
size_t n
|
||||
);
|
||||
|
||||
__attribute__((__alias__("__aeabi_memclr")))
|
||||
void __aeabi_memclr8(void *dest, size_t n);
|
||||
__attribute__ ((__alias__ ("__aeabi_memclr")))
|
||||
void
|
||||
__aeabi_memclr8 (
|
||||
void *dest,
|
||||
size_t n
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -1,24 +1,35 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2017, Pete Batard. All rights reserved.<BR>
|
||||
// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
#if defined(_M_ARM64)
|
||||
typedef unsigned __int64 size_t;
|
||||
#if defined (_M_ARM64)
|
||||
typedef unsigned __int64 size_t;
|
||||
#else
|
||||
typedef unsigned __int32 size_t;
|
||||
typedef unsigned __int32 size_t;
|
||||
#endif
|
||||
|
||||
void* memset(void *, int, size_t);
|
||||
void *
|
||||
memset (
|
||||
void *,
|
||||
int,
|
||||
size_t
|
||||
);
|
||||
|
||||
#pragma intrinsic(memset)
|
||||
#pragma function(memset)
|
||||
void *memset(void *s, int c, size_t n)
|
||||
void *
|
||||
memset (
|
||||
void *s,
|
||||
int c,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
unsigned char *d;
|
||||
unsigned char *d;
|
||||
|
||||
d = s;
|
||||
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
|
||||
(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
|
||||
|
||||
|
||||
// Vector Table for Sec Phase
|
||||
VOID
|
||||
DebugAgentVectorTable (
|
||||
@@ -53,7 +52,7 @@ GetFileState (
|
||||
FileState = FfsHeader->State;
|
||||
|
||||
if (ErasePolarity != 0) {
|
||||
FileState = (EFI_FFS_FILE_STATE)~FileState;
|
||||
FileState = (EFI_FFS_FILE_STATE) ~FileState;
|
||||
}
|
||||
|
||||
HighestBit = 0x80;
|
||||
@@ -79,10 +78,10 @@ CalculateHeaderChecksum (
|
||||
IN EFI_FFS_FILE_HEADER *FileHeader
|
||||
)
|
||||
{
|
||||
UINT8 Sum;
|
||||
UINT8 Sum;
|
||||
|
||||
// Calculate the sum of the header
|
||||
Sum = CalculateSum8 ((CONST VOID*)FileHeader,sizeof(EFI_FFS_FILE_HEADER));
|
||||
Sum = CalculateSum8 ((CONST VOID *)FileHeader, sizeof (EFI_FFS_FILE_HEADER));
|
||||
|
||||
// State field (since this indicates the different state of file).
|
||||
Sum = (UINT8)(Sum - FileHeader->State);
|
||||
@@ -95,24 +94,24 @@ CalculateHeaderChecksum (
|
||||
|
||||
EFI_STATUS
|
||||
GetFfsFile (
|
||||
IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
|
||||
IN EFI_FV_FILETYPE FileType,
|
||||
OUT EFI_FFS_FILE_HEADER **FileHeader
|
||||
IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
|
||||
IN EFI_FV_FILETYPE FileType,
|
||||
OUT EFI_FFS_FILE_HEADER **FileHeader
|
||||
)
|
||||
{
|
||||
UINT64 FvLength;
|
||||
UINTN FileOffset;
|
||||
EFI_FFS_FILE_HEADER *FfsFileHeader;
|
||||
UINT8 ErasePolarity;
|
||||
UINT8 FileState;
|
||||
UINT32 FileLength;
|
||||
UINT32 FileOccupiedSize;
|
||||
UINT64 FvLength;
|
||||
UINTN FileOffset;
|
||||
EFI_FFS_FILE_HEADER *FfsFileHeader;
|
||||
UINT8 ErasePolarity;
|
||||
UINT8 FileState;
|
||||
UINT32 FileLength;
|
||||
UINT32 FileOccupiedSize;
|
||||
|
||||
ASSERT (FwVolHeader->Signature == EFI_FVH_SIGNATURE);
|
||||
|
||||
FvLength = FwVolHeader->FvLength;
|
||||
FvLength = FwVolHeader->FvLength;
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);
|
||||
FileOffset = FwVolHeader->HeaderLength;
|
||||
FileOffset = FwVolHeader->HeaderLength;
|
||||
|
||||
if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {
|
||||
ErasePolarity = 1;
|
||||
@@ -125,42 +124,42 @@ GetFfsFile (
|
||||
FileState = GetFileState (ErasePolarity, FfsFileHeader);
|
||||
|
||||
switch (FileState) {
|
||||
case EFI_FILE_HEADER_INVALID:
|
||||
FileOffset += sizeof (EFI_FFS_FILE_HEADER);
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
|
||||
break;
|
||||
|
||||
case EFI_FILE_HEADER_INVALID:
|
||||
FileOffset += sizeof(EFI_FFS_FILE_HEADER);
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof(EFI_FFS_FILE_HEADER));
|
||||
break;
|
||||
case EFI_FILE_DATA_VALID:
|
||||
case EFI_FILE_MARKED_FOR_UPDATE:
|
||||
if (CalculateHeaderChecksum (FfsFileHeader) != 0) {
|
||||
ASSERT (FALSE);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
case EFI_FILE_DATA_VALID:
|
||||
case EFI_FILE_MARKED_FOR_UPDATE:
|
||||
if (CalculateHeaderChecksum (FfsFileHeader) != 0) {
|
||||
ASSERT (FALSE);
|
||||
if (FfsFileHeader->Type == FileType) {
|
||||
*FileHeader = FfsFileHeader;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
|
||||
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
|
||||
|
||||
FileOffset += FileOccupiedSize;
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
|
||||
break;
|
||||
|
||||
case EFI_FILE_DELETED:
|
||||
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
|
||||
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
|
||||
FileOffset += FileOccupiedSize;
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
|
||||
break;
|
||||
|
||||
default:
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (FfsFileHeader->Type == FileType) {
|
||||
*FileHeader = FfsFileHeader;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
|
||||
FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);
|
||||
|
||||
FileOffset += FileOccupiedSize;
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
|
||||
break;
|
||||
|
||||
case EFI_FILE_DELETED:
|
||||
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
|
||||
FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);
|
||||
FileOffset += FileOccupiedSize;
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
|
||||
break;
|
||||
|
||||
default:
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -170,25 +169,25 @@ GetImageContext (
|
||||
OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN ParsedLength;
|
||||
UINTN SectionSize;
|
||||
UINTN SectionLength;
|
||||
EFI_COMMON_SECTION_HEADER *Section;
|
||||
VOID *EfiImage;
|
||||
UINTN ImageAddress;
|
||||
EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
|
||||
VOID *CodeViewEntryPointer;
|
||||
EFI_STATUS Status;
|
||||
UINTN ParsedLength;
|
||||
UINTN SectionSize;
|
||||
UINTN SectionLength;
|
||||
EFI_COMMON_SECTION_HEADER *Section;
|
||||
VOID *EfiImage;
|
||||
UINTN ImageAddress;
|
||||
EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
|
||||
VOID *CodeViewEntryPointer;
|
||||
|
||||
Section = (EFI_COMMON_SECTION_HEADER *)(FfsHeader + 1);
|
||||
SectionSize = *(UINT32 *)(FfsHeader->Size) & 0x00FFFFFF;
|
||||
Section = (EFI_COMMON_SECTION_HEADER *)(FfsHeader + 1);
|
||||
SectionSize = *(UINT32 *)(FfsHeader->Size) & 0x00FFFFFF;
|
||||
SectionSize -= sizeof (EFI_FFS_FILE_HEADER);
|
||||
ParsedLength = 0;
|
||||
EfiImage = NULL;
|
||||
EfiImage = NULL;
|
||||
|
||||
while (ParsedLength < SectionSize) {
|
||||
if ((Section->Type == EFI_SECTION_PE32) || (Section->Type == EFI_SECTION_TE)) {
|
||||
EfiImage = (EFI_IMAGE_OPTIONAL_HEADER_UNION*)(Section + 1);
|
||||
EfiImage = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(Section + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -201,7 +200,7 @@ GetImageContext (
|
||||
SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
|
||||
ASSERT (SectionLength != 0);
|
||||
ParsedLength += SectionLength;
|
||||
Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
|
||||
Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
|
||||
}
|
||||
|
||||
if (EfiImage == NULL) {
|
||||
@@ -214,27 +213,27 @@ GetImageContext (
|
||||
ImageContext->ImageRead = PeCoffLoaderImageReadFromMemory;
|
||||
|
||||
Status = PeCoffLoaderGetImageInfo (ImageContext);
|
||||
if (!EFI_ERROR(Status) && ((VOID*)(UINTN)ImageContext->DebugDirectoryEntryRva != NULL)) {
|
||||
if (!EFI_ERROR (Status) && ((VOID *)(UINTN)ImageContext->DebugDirectoryEntryRva != NULL)) {
|
||||
ImageAddress = ImageContext->ImageAddress;
|
||||
if (ImageContext->IsTeImage) {
|
||||
ImageAddress += sizeof (EFI_TE_IMAGE_HEADER) - ((EFI_TE_IMAGE_HEADER*)EfiImage)->StrippedSize;
|
||||
ImageAddress += sizeof (EFI_TE_IMAGE_HEADER) - ((EFI_TE_IMAGE_HEADER *)EfiImage)->StrippedSize;
|
||||
}
|
||||
|
||||
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY*)(ImageAddress + ImageContext->DebugDirectoryEntryRva);
|
||||
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(ImageAddress + ImageContext->DebugDirectoryEntryRva);
|
||||
if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
|
||||
CodeViewEntryPointer = (VOID *) (ImageAddress + (UINTN) DebugEntry->RVA);
|
||||
switch (* (UINT32 *) CodeViewEntryPointer) {
|
||||
case CODEVIEW_SIGNATURE_NB10:
|
||||
ImageContext->PdbPointer = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);
|
||||
break;
|
||||
case CODEVIEW_SIGNATURE_RSDS:
|
||||
ImageContext->PdbPointer = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
|
||||
break;
|
||||
case CODEVIEW_SIGNATURE_MTOC:
|
||||
ImageContext->PdbPointer = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
CodeViewEntryPointer = (VOID *)(ImageAddress + (UINTN)DebugEntry->RVA);
|
||||
switch (*(UINT32 *)CodeViewEntryPointer) {
|
||||
case CODEVIEW_SIGNATURE_NB10:
|
||||
ImageContext->PdbPointer = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);
|
||||
break;
|
||||
case CODEVIEW_SIGNATURE_RSDS:
|
||||
ImageContext->PdbPointer = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
|
||||
break;
|
||||
case CODEVIEW_SIGNATURE_MTOC:
|
||||
ImageContext->PdbPointer = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,8 +271,8 @@ InitializeDebugAgent (
|
||||
IN DEBUG_AGENT_CONTINUE Function OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FFS_FILE_HEADER *FfsHeader;
|
||||
EFI_STATUS Status;
|
||||
EFI_FFS_FILE_HEADER *FfsHeader;
|
||||
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
|
||||
|
||||
// We use InitFlag to know if DebugAgent has been initialized from
|
||||
@@ -283,10 +282,10 @@ InitializeDebugAgent (
|
||||
//
|
||||
// Get the Sec or PrePeiCore module (defined as SEC type module)
|
||||
//
|
||||
Status = GetFfsFile ((EFI_FIRMWARE_VOLUME_HEADER*)(UINTN)PcdGet64 (PcdSecureFvBaseAddress), EFI_FV_FILETYPE_SECURITY_CORE, &FfsHeader);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = GetImageContext (FfsHeader,&ImageContext);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = GetFfsFile ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet64 (PcdSecureFvBaseAddress), EFI_FV_FILETYPE_SECURITY_CORE, &FfsHeader);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = GetImageContext (FfsHeader, &ImageContext);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
PeCoffLoaderRelocateImageExtraAction (&ImageContext);
|
||||
}
|
||||
}
|
||||
@@ -294,10 +293,10 @@ InitializeDebugAgent (
|
||||
//
|
||||
// Get the PrePi or PrePeiCore module (defined as SEC type module)
|
||||
//
|
||||
Status = GetFfsFile ((EFI_FIRMWARE_VOLUME_HEADER*)(UINTN)PcdGet64 (PcdFvBaseAddress), EFI_FV_FILETYPE_SECURITY_CORE, &FfsHeader);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = GetImageContext (FfsHeader,&ImageContext);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = GetFfsFile ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet64 (PcdFvBaseAddress), EFI_FV_FILETYPE_SECURITY_CORE, &FfsHeader);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = GetImageContext (FfsHeader, &ImageContext);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
PeCoffLoaderRelocateImageExtraAction (&ImageContext);
|
||||
}
|
||||
}
|
||||
@@ -305,10 +304,10 @@ InitializeDebugAgent (
|
||||
//
|
||||
// Get the PeiCore module (defined as PEI_CORE type module)
|
||||
//
|
||||
Status = GetFfsFile ((EFI_FIRMWARE_VOLUME_HEADER*)(UINTN)PcdGet64 (PcdFvBaseAddress), EFI_FV_FILETYPE_PEI_CORE, &FfsHeader);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = GetImageContext (FfsHeader,&ImageContext);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = GetFfsFile ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet64 (PcdFvBaseAddress), EFI_FV_FILETYPE_PEI_CORE, &FfsHeader);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = GetImageContext (FfsHeader, &ImageContext);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
PeCoffLoaderRelocateImageExtraAction (&ImageContext);
|
||||
}
|
||||
}
|
||||
@@ -330,7 +329,7 @@ InitializeDebugAgent (
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
SaveAndSetDebugTimerInterrupt (
|
||||
IN BOOLEAN EnableStatus
|
||||
IN BOOLEAN EnableStatus
|
||||
)
|
||||
{
|
||||
return FALSE;
|
||||
|
@@ -17,7 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/PeCoffExtraActionLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
|
||||
|
||||
/**
|
||||
If the build is done on cygwin the paths are cygpaths.
|
||||
/cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert
|
||||
@@ -28,14 +27,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
CHAR8 *
|
||||
DeCygwinPathIfNeeded (
|
||||
IN CHAR8 *Name,
|
||||
IN CHAR8 *Temp,
|
||||
IN UINTN Size
|
||||
IN CHAR8 *Name,
|
||||
IN CHAR8 *Temp,
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
CHAR8 *Ptr;
|
||||
UINTN Index;
|
||||
UINTN Index2;
|
||||
CHAR8 *Ptr;
|
||||
UINTN Index;
|
||||
UINTN Index2;
|
||||
|
||||
Ptr = AsciiStrStr (Name, "/cygdrive/");
|
||||
if (Ptr == NULL) {
|
||||
@@ -45,19 +44,18 @@ DeCygwinPathIfNeeded (
|
||||
for (Index = 9, Index2 = 0; (Index < (Size + 9)) && (Ptr[Index] != '\0'); Index++, Index2++) {
|
||||
Temp[Index2] = Ptr[Index];
|
||||
if (Temp[Index2] == '/') {
|
||||
Temp[Index2] = '\\' ;
|
||||
}
|
||||
Temp[Index2] = '\\';
|
||||
}
|
||||
|
||||
if (Index2 == 1) {
|
||||
Temp[Index2 - 1] = Ptr[Index];
|
||||
Temp[Index2] = ':';
|
||||
Temp[Index2] = ':';
|
||||
}
|
||||
}
|
||||
|
||||
return Temp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Performs additional actions after a PE/COFF image has been loaded and relocated.
|
||||
|
||||
@@ -73,32 +71,30 @@ PeCoffLoaderRelocateImageExtraAction (
|
||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
#if !defined(MDEPKG_NDEBUG)
|
||||
CHAR8 Temp[512];
|
||||
#endif
|
||||
#if !defined (MDEPKG_NDEBUG)
|
||||
CHAR8 Temp[512];
|
||||
#endif
|
||||
|
||||
if (ImageContext->PdbPointer) {
|
||||
#ifdef __CC_ARM
|
||||
#if (__ARMCC_VERSION < 500000)
|
||||
#ifdef __CC_ARM
|
||||
#if (__ARMCC_VERSION < 500000)
|
||||
// Print out the command for the RVD debugger to load symbols for this image
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "load /a /ni /np %a &0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
|
||||
#else
|
||||
#else
|
||||
// Print out the command for the DS-5 to load symbols for this image
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
|
||||
#endif
|
||||
#elif __GNUC__
|
||||
#endif
|
||||
#elif __GNUC__
|
||||
// This may not work correctly if you generate PE/COFF directly as then the Offset would not be required
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
|
||||
#else
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
|
||||
#endif
|
||||
#else
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
|
||||
#endif
|
||||
} else {
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
||||
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
|
||||
@@ -115,21 +111,21 @@ PeCoffLoaderUnloadImageExtraAction (
|
||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
#if !defined(MDEPKG_NDEBUG)
|
||||
CHAR8 Temp[512];
|
||||
#endif
|
||||
#if !defined (MDEPKG_NDEBUG)
|
||||
CHAR8 Temp[512];
|
||||
#endif
|
||||
|
||||
if (ImageContext->PdbPointer) {
|
||||
#ifdef __CC_ARM
|
||||
#ifdef __CC_ARM
|
||||
// Print out the command for the RVD debugger to load symbols for this image
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "unload symbols_only %a\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp))));
|
||||
#elif __GNUC__
|
||||
#elif __GNUC__
|
||||
// This may not work correctly if you generate PE/COFF directly as then the Offset would not be required
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "remove-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
|
||||
#else
|
||||
#else
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Unloading %a\n", ImageContext->PdbPointer));
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Unloading driver at 0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress));
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Unloading driver at 0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress));
|
||||
}
|
||||
}
|
||||
|
@@ -22,14 +22,14 @@
|
||||
#include <Protocol/DebugSupport.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
|
||||
STATIC CHAR8 *gExceptionTypeString[] = {
|
||||
STATIC CHAR8 *gExceptionTypeString[] = {
|
||||
"Synchronous",
|
||||
"IRQ",
|
||||
"FIQ",
|
||||
"SError"
|
||||
};
|
||||
|
||||
STATIC BOOLEAN mRecursiveException;
|
||||
STATIC BOOLEAN mRecursiveException;
|
||||
|
||||
CHAR8 *
|
||||
GetImageName (
|
||||
@@ -41,47 +41,79 @@ GetImageName (
|
||||
STATIC
|
||||
VOID
|
||||
DescribeInstructionOrDataAbort (
|
||||
IN CHAR8 *AbortType,
|
||||
IN UINTN Iss
|
||||
IN CHAR8 *AbortType,
|
||||
IN UINTN Iss
|
||||
)
|
||||
{
|
||||
CHAR8 *AbortCause;
|
||||
CHAR8 *AbortCause;
|
||||
|
||||
switch (Iss & 0x3f) {
|
||||
case 0x0: AbortCause = "Address size fault, zeroth level of translation or translation table base register"; break;
|
||||
case 0x1: AbortCause = "Address size fault, first level"; break;
|
||||
case 0x2: AbortCause = "Address size fault, second level"; break;
|
||||
case 0x3: AbortCause = "Address size fault, third level"; break;
|
||||
case 0x4: AbortCause = "Translation fault, zeroth level"; break;
|
||||
case 0x5: AbortCause = "Translation fault, first level"; break;
|
||||
case 0x6: AbortCause = "Translation fault, second level"; break;
|
||||
case 0x7: AbortCause = "Translation fault, third level"; break;
|
||||
case 0x9: AbortCause = "Access flag fault, first level"; break;
|
||||
case 0xa: AbortCause = "Access flag fault, second level"; break;
|
||||
case 0xb: AbortCause = "Access flag fault, third level"; break;
|
||||
case 0xd: AbortCause = "Permission fault, first level"; break;
|
||||
case 0xe: AbortCause = "Permission fault, second level"; break;
|
||||
case 0xf: AbortCause = "Permission fault, third level"; break;
|
||||
case 0x10: AbortCause = "Synchronous external abort"; break;
|
||||
case 0x18: AbortCause = "Synchronous parity error on memory access"; break;
|
||||
case 0x11: AbortCause = "Asynchronous external abort"; break;
|
||||
case 0x19: AbortCause = "Asynchronous parity error on memory access"; break;
|
||||
case 0x14: AbortCause = "Synchronous external abort on translation table walk, zeroth level"; break;
|
||||
case 0x15: AbortCause = "Synchronous external abort on translation table walk, first level"; break;
|
||||
case 0x16: AbortCause = "Synchronous external abort on translation table walk, second level"; break;
|
||||
case 0x17: AbortCause = "Synchronous external abort on translation table walk, third level"; break;
|
||||
case 0x1c: AbortCause = "Synchronous parity error on memory access on translation table walk, zeroth level"; break;
|
||||
case 0x1d: AbortCause = "Synchronous parity error on memory access on translation table walk, first level"; break;
|
||||
case 0x1e: AbortCause = "Synchronous parity error on memory access on translation table walk, second level"; break;
|
||||
case 0x1f: AbortCause = "Synchronous parity error on memory access on translation table walk, third level"; break;
|
||||
case 0x21: AbortCause = "Alignment fault"; break;
|
||||
case 0x22: AbortCause = "Debug event"; break;
|
||||
case 0x30: AbortCause = "TLB conflict abort"; break;
|
||||
case 0x0: AbortCause = "Address size fault, zeroth level of translation or translation table base register";
|
||||
break;
|
||||
case 0x1: AbortCause = "Address size fault, first level";
|
||||
break;
|
||||
case 0x2: AbortCause = "Address size fault, second level";
|
||||
break;
|
||||
case 0x3: AbortCause = "Address size fault, third level";
|
||||
break;
|
||||
case 0x4: AbortCause = "Translation fault, zeroth level";
|
||||
break;
|
||||
case 0x5: AbortCause = "Translation fault, first level";
|
||||
break;
|
||||
case 0x6: AbortCause = "Translation fault, second level";
|
||||
break;
|
||||
case 0x7: AbortCause = "Translation fault, third level";
|
||||
break;
|
||||
case 0x9: AbortCause = "Access flag fault, first level";
|
||||
break;
|
||||
case 0xa: AbortCause = "Access flag fault, second level";
|
||||
break;
|
||||
case 0xb: AbortCause = "Access flag fault, third level";
|
||||
break;
|
||||
case 0xd: AbortCause = "Permission fault, first level";
|
||||
break;
|
||||
case 0xe: AbortCause = "Permission fault, second level";
|
||||
break;
|
||||
case 0xf: AbortCause = "Permission fault, third level";
|
||||
break;
|
||||
case 0x10: AbortCause = "Synchronous external abort";
|
||||
break;
|
||||
case 0x18: AbortCause = "Synchronous parity error on memory access";
|
||||
break;
|
||||
case 0x11: AbortCause = "Asynchronous external abort";
|
||||
break;
|
||||
case 0x19: AbortCause = "Asynchronous parity error on memory access";
|
||||
break;
|
||||
case 0x14: AbortCause = "Synchronous external abort on translation table walk, zeroth level";
|
||||
break;
|
||||
case 0x15: AbortCause = "Synchronous external abort on translation table walk, first level";
|
||||
break;
|
||||
case 0x16: AbortCause = "Synchronous external abort on translation table walk, second level";
|
||||
break;
|
||||
case 0x17: AbortCause = "Synchronous external abort on translation table walk, third level";
|
||||
break;
|
||||
case 0x1c: AbortCause = "Synchronous parity error on memory access on translation table walk, zeroth level";
|
||||
break;
|
||||
case 0x1d: AbortCause = "Synchronous parity error on memory access on translation table walk, first level";
|
||||
break;
|
||||
case 0x1e: AbortCause = "Synchronous parity error on memory access on translation table walk, second level";
|
||||
break;
|
||||
case 0x1f: AbortCause = "Synchronous parity error on memory access on translation table walk, third level";
|
||||
break;
|
||||
case 0x21: AbortCause = "Alignment fault";
|
||||
break;
|
||||
case 0x22: AbortCause = "Debug event";
|
||||
break;
|
||||
case 0x30: AbortCause = "TLB conflict abort";
|
||||
break;
|
||||
case 0x33:
|
||||
case 0x34: AbortCause = "IMPLEMENTATION DEFINED"; break;
|
||||
case 0x34: AbortCause = "IMPLEMENTATION DEFINED";
|
||||
break;
|
||||
case 0x35:
|
||||
case 0x36: AbortCause = "Domain fault"; break;
|
||||
default: AbortCause = ""; break;
|
||||
case 0x36: AbortCause = "Domain fault";
|
||||
break;
|
||||
default: AbortCause = "";
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "\n%a: %a\n", AbortType, AbortCause));
|
||||
@@ -90,24 +122,29 @@ DescribeInstructionOrDataAbort (
|
||||
STATIC
|
||||
VOID
|
||||
DescribeExceptionSyndrome (
|
||||
IN UINT32 Esr
|
||||
IN UINT32 Esr
|
||||
)
|
||||
{
|
||||
CHAR8 *Message;
|
||||
UINTN Ec;
|
||||
UINTN Iss;
|
||||
CHAR8 *Message;
|
||||
UINTN Ec;
|
||||
UINTN Iss;
|
||||
|
||||
Ec = Esr >> 26;
|
||||
Ec = Esr >> 26;
|
||||
Iss = Esr & 0x00ffffff;
|
||||
|
||||
switch (Ec) {
|
||||
case 0x15: Message = "SVC executed in AArch64"; break;
|
||||
case 0x15: Message = "SVC executed in AArch64";
|
||||
break;
|
||||
case 0x20:
|
||||
case 0x21: DescribeInstructionOrDataAbort ("Instruction abort", Iss); return;
|
||||
case 0x22: Message = "PC alignment fault"; break;
|
||||
case 0x23: Message = "SP alignment fault"; break;
|
||||
case 0x21: DescribeInstructionOrDataAbort ("Instruction abort", Iss);
|
||||
return;
|
||||
case 0x22: Message = "PC alignment fault";
|
||||
break;
|
||||
case 0x23: Message = "SP alignment fault";
|
||||
break;
|
||||
case 0x24:
|
||||
case 0x25: DescribeInstructionOrDataAbort ("Data abort", Iss); return;
|
||||
case 0x25: DescribeInstructionOrDataAbort ("Data abort", Iss);
|
||||
return;
|
||||
default: return;
|
||||
}
|
||||
|
||||
@@ -118,20 +155,22 @@ DescribeExceptionSyndrome (
|
||||
STATIC
|
||||
CONST CHAR8 *
|
||||
BaseName (
|
||||
IN CONST CHAR8 *FullName
|
||||
IN CONST CHAR8 *FullName
|
||||
)
|
||||
{
|
||||
CONST CHAR8 *Str;
|
||||
CONST CHAR8 *Str;
|
||||
|
||||
Str = FullName + AsciiStrLen (FullName);
|
||||
|
||||
while (--Str > FullName) {
|
||||
if (*Str == '/' || *Str == '\\') {
|
||||
if ((*Str == '/') || (*Str == '\\')) {
|
||||
return Str + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return Str;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -145,8 +184,8 @@ BaseName (
|
||||
**/
|
||||
VOID
|
||||
DefaultExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
CHAR8 Buffer[100];
|
||||
@@ -154,75 +193,93 @@ DefaultExceptionHandler (
|
||||
INT32 Offset;
|
||||
|
||||
if (mRecursiveException) {
|
||||
STATIC CHAR8 CONST Message[] = "\nRecursive exception occurred while dumping the CPU state\n";
|
||||
STATIC CHAR8 CONST Message[] = "\nRecursive exception occurred while dumping the CPU state\n";
|
||||
|
||||
SerialPortWrite ((UINT8 *)Message, sizeof Message - 1);
|
||||
if (gST->ConOut != NULL) {
|
||||
AsciiPrint (Message);
|
||||
}
|
||||
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
|
||||
mRecursiveException = TRUE;
|
||||
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n\n%a Exception at 0x%016lx\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextAArch64->ELR);
|
||||
SerialPortWrite ((UINT8 *) Buffer, CharCount);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "\n\n%a Exception at 0x%016lx\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextAArch64->ELR);
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
if (gST->ConOut != NULL) {
|
||||
AsciiPrint (Buffer);
|
||||
}
|
||||
|
||||
DEBUG_CODE_BEGIN ();
|
||||
CHAR8 *Pdb, *PrevPdb;
|
||||
UINTN ImageBase;
|
||||
UINTN PeCoffSizeOfHeader;
|
||||
UINT64 *Fp;
|
||||
UINT64 RootFp[2];
|
||||
UINTN Idx;
|
||||
CHAR8 *Pdb, *PrevPdb;
|
||||
UINTN ImageBase;
|
||||
UINTN PeCoffSizeOfHeader;
|
||||
UINT64 *Fp;
|
||||
UINT64 RootFp[2];
|
||||
UINTN Idx;
|
||||
|
||||
PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
|
||||
if (Pdb != NULL) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"PC 0x%012lx (0x%012lx+0x%08x) [ 0] %a\n",
|
||||
SystemContext.SystemContextAArch64->ELR,
|
||||
ImageBase,
|
||||
SystemContext.SystemContextAArch64->ELR - ImageBase,
|
||||
BaseName (Pdb)
|
||||
));
|
||||
} else {
|
||||
DEBUG ((DEBUG_ERROR, "PC 0x%012lx\n", SystemContext.SystemContextAArch64->ELR));
|
||||
}
|
||||
|
||||
if ((UINT64 *)SystemContext.SystemContextAArch64->FP != 0) {
|
||||
Idx = 0;
|
||||
|
||||
RootFp[0] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[0];
|
||||
RootFp[1] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[1];
|
||||
if (RootFp[1] != SystemContext.SystemContextAArch64->LR) {
|
||||
RootFp[0] = SystemContext.SystemContextAArch64->FP;
|
||||
RootFp[1] = SystemContext.SystemContextAArch64->LR;
|
||||
}
|
||||
|
||||
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
|
||||
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
|
||||
if (Pdb != NULL) {
|
||||
if (Pdb != PrevPdb) {
|
||||
Idx++;
|
||||
PrevPdb = Pdb;
|
||||
}
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"PC 0x%012lx (0x%012lx+0x%08x) [% 2d] %a\n",
|
||||
Fp[1],
|
||||
ImageBase,
|
||||
Fp[1] - ImageBase,
|
||||
Idx,
|
||||
BaseName (Pdb)
|
||||
));
|
||||
} else {
|
||||
DEBUG ((DEBUG_ERROR, "PC 0x%012lx\n", Fp[1]));
|
||||
}
|
||||
}
|
||||
|
||||
PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
|
||||
if (Pdb != NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [ 0] %a\n",
|
||||
SystemContext.SystemContextAArch64->ELR, ImageBase,
|
||||
SystemContext.SystemContextAArch64->ELR - ImageBase, BaseName (Pdb)));
|
||||
} else {
|
||||
DEBUG ((DEBUG_ERROR, "PC 0x%012lx\n", SystemContext.SystemContextAArch64->ELR));
|
||||
DEBUG ((DEBUG_ERROR, "\n[ 0] %a\n", Pdb));
|
||||
}
|
||||
|
||||
if ((UINT64 *)SystemContext.SystemContextAArch64->FP != 0) {
|
||||
Idx = 0;
|
||||
|
||||
RootFp[0] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[0];
|
||||
RootFp[1] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[1];
|
||||
if (RootFp[1] != SystemContext.SystemContextAArch64->LR) {
|
||||
RootFp[0] = SystemContext.SystemContextAArch64->FP;
|
||||
RootFp[1] = SystemContext.SystemContextAArch64->LR;
|
||||
}
|
||||
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
|
||||
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
|
||||
if (Pdb != NULL) {
|
||||
if (Pdb != PrevPdb) {
|
||||
Idx++;
|
||||
PrevPdb = Pdb;
|
||||
}
|
||||
DEBUG ((DEBUG_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [% 2d] %a\n",
|
||||
Fp[1], ImageBase, Fp[1] - ImageBase, Idx, BaseName (Pdb)));
|
||||
} else {
|
||||
DEBUG ((DEBUG_ERROR, "PC 0x%012lx\n", Fp[1]));
|
||||
}
|
||||
}
|
||||
PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
|
||||
if (Pdb != NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "\n[ 0] %a\n", Pdb));
|
||||
}
|
||||
|
||||
Idx = 0;
|
||||
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
|
||||
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
|
||||
if (Pdb != NULL && Pdb != PrevPdb) {
|
||||
DEBUG ((DEBUG_ERROR, "[% 2d] %a\n", ++Idx, Pdb));
|
||||
PrevPdb = Pdb;
|
||||
}
|
||||
Idx = 0;
|
||||
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
|
||||
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
|
||||
if ((Pdb != NULL) && (Pdb != PrevPdb)) {
|
||||
DEBUG ((DEBUG_ERROR, "[% 2d] %a\n", ++Idx, Pdb));
|
||||
PrevPdb = Pdb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_CODE_END ();
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "\n X0 0x%016lx X1 0x%016lx X2 0x%016lx X3 0x%016lx\n", SystemContext.SystemContextAArch64->X0, SystemContext.SystemContextAArch64->X1, SystemContext.SystemContextAArch64->X2, SystemContext.SystemContextAArch64->X3));
|
||||
@@ -255,19 +312,22 @@ DefaultExceptionHandler (
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "\n SP 0x%016lx ELR 0x%016lx SPSR 0x%08lx FPSR 0x%08lx\n ESR 0x%08lx FAR 0x%016lx\n", SystemContext.SystemContextAArch64->SP, SystemContext.SystemContextAArch64->ELR, SystemContext.SystemContextAArch64->SPSR, SystemContext.SystemContextAArch64->FPSR, SystemContext.SystemContextAArch64->ESR, SystemContext.SystemContextAArch64->FAR));
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "\n ESR : EC 0x%02x IL 0x%x ISS 0x%08x\n", (SystemContext.SystemContextAArch64->ESR & 0xFC000000) >> 26, (SystemContext.SystemContextAArch64->ESR >> 25) & 0x1, SystemContext.SystemContextAArch64->ESR & 0x1FFFFFF ));
|
||||
DEBUG ((DEBUG_ERROR, "\n ESR : EC 0x%02x IL 0x%x ISS 0x%08x\n", (SystemContext.SystemContextAArch64->ESR & 0xFC000000) >> 26, (SystemContext.SystemContextAArch64->ESR >> 25) & 0x1, SystemContext.SystemContextAArch64->ESR & 0x1FFFFFF));
|
||||
|
||||
DescribeExceptionSyndrome (SystemContext.SystemContextAArch64->ESR);
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "\nStack dump:\n"));
|
||||
for (Offset = -256; Offset < 256; Offset += 32) {
|
||||
DEBUG ((DEBUG_ERROR, "%c %013lx: %016lx %016lx %016lx %016lx\n",
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%c %013lx: %016lx %016lx %016lx %016lx\n",
|
||||
Offset == 0 ? '>' : ' ',
|
||||
SystemContext.SystemContextAArch64->SP + Offset,
|
||||
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset),
|
||||
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 8),
|
||||
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 16),
|
||||
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 24)));
|
||||
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 24)
|
||||
));
|
||||
}
|
||||
|
||||
ASSERT (FALSE);
|
||||
|
@@ -27,14 +27,14 @@
|
||||
// The number of elements in a CHAR8 array, including the terminating NUL, that
|
||||
// is meant to hold the string rendering of the CPSR.
|
||||
//
|
||||
#define CPSR_STRING_SIZE 32
|
||||
#define CPSR_STRING_SIZE 32
|
||||
|
||||
typedef struct {
|
||||
UINT32 BIT;
|
||||
CHAR8 Char;
|
||||
UINT32 BIT;
|
||||
CHAR8 Char;
|
||||
} CPSR_CHAR;
|
||||
|
||||
STATIC CONST CPSR_CHAR mCpsrChar[] = {
|
||||
STATIC CONST CPSR_CHAR mCpsrChar[] = {
|
||||
{ 31, 'n' },
|
||||
{ 30, 'z' },
|
||||
{ 29, 'c' },
|
||||
@@ -72,9 +72,9 @@ CpsrString (
|
||||
OUT CHAR8 *ReturnStr
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
CHAR8* Str;
|
||||
CHAR8* ModeStr;
|
||||
UINTN Index;
|
||||
CHAR8 *Str;
|
||||
CHAR8 *ModeStr;
|
||||
|
||||
Str = ReturnStr;
|
||||
|
||||
@@ -87,37 +87,37 @@ CpsrString (
|
||||
}
|
||||
|
||||
*Str++ = '_';
|
||||
*Str = '\0';
|
||||
*Str = '\0';
|
||||
|
||||
switch (Cpsr & 0x1f) {
|
||||
case 0x10:
|
||||
ModeStr = "usr";
|
||||
break;
|
||||
case 0x011:
|
||||
ModeStr = "fiq";
|
||||
break;
|
||||
case 0x12:
|
||||
ModeStr = "irq";
|
||||
break;
|
||||
case 0x13:
|
||||
ModeStr = "svc";
|
||||
break;
|
||||
case 0x16:
|
||||
ModeStr = "mon";
|
||||
break;
|
||||
case 0x17:
|
||||
ModeStr = "abt";
|
||||
break;
|
||||
case 0x1b:
|
||||
ModeStr = "und";
|
||||
break;
|
||||
case 0x1f:
|
||||
ModeStr = "sys";
|
||||
break;
|
||||
case 0x10:
|
||||
ModeStr = "usr";
|
||||
break;
|
||||
case 0x011:
|
||||
ModeStr = "fiq";
|
||||
break;
|
||||
case 0x12:
|
||||
ModeStr = "irq";
|
||||
break;
|
||||
case 0x13:
|
||||
ModeStr = "svc";
|
||||
break;
|
||||
case 0x16:
|
||||
ModeStr = "mon";
|
||||
break;
|
||||
case 0x17:
|
||||
ModeStr = "abt";
|
||||
break;
|
||||
case 0x1b:
|
||||
ModeStr = "und";
|
||||
break;
|
||||
case 0x1f:
|
||||
ModeStr = "sys";
|
||||
break;
|
||||
|
||||
default:
|
||||
ModeStr = "???";
|
||||
break;
|
||||
default:
|
||||
ModeStr = "???";
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -131,31 +131,47 @@ FaultStatusToString (
|
||||
IN UINT32 Status
|
||||
)
|
||||
{
|
||||
CHAR8 *FaultSource;
|
||||
CHAR8 *FaultSource;
|
||||
|
||||
switch (Status) {
|
||||
case 0x01: FaultSource = "Alignment fault"; break;
|
||||
case 0x02: FaultSource = "Debug event fault"; break;
|
||||
case 0x03: FaultSource = "Access Flag fault on Section"; break;
|
||||
case 0x04: FaultSource = "Cache maintenance operation fault[2]"; break;
|
||||
case 0x05: FaultSource = "Translation fault on Section"; break;
|
||||
case 0x06: FaultSource = "Access Flag fault on Page"; break;
|
||||
case 0x07: FaultSource = "Translation fault on Page"; break;
|
||||
case 0x08: FaultSource = "Precise External Abort"; break;
|
||||
case 0x09: FaultSource = "Domain fault on Section"; break;
|
||||
case 0x0b: FaultSource = "Domain fault on Page"; break;
|
||||
case 0x0c: FaultSource = "External abort on translation, first level"; break;
|
||||
case 0x0d: FaultSource = "Permission fault on Section"; break;
|
||||
case 0x0e: FaultSource = "External abort on translation, second level"; break;
|
||||
case 0x0f: FaultSource = "Permission fault on Page"; break;
|
||||
case 0x16: FaultSource = "Imprecise External Abort"; break;
|
||||
default: FaultSource = "No function"; break;
|
||||
}
|
||||
case 0x01: FaultSource = "Alignment fault";
|
||||
break;
|
||||
case 0x02: FaultSource = "Debug event fault";
|
||||
break;
|
||||
case 0x03: FaultSource = "Access Flag fault on Section";
|
||||
break;
|
||||
case 0x04: FaultSource = "Cache maintenance operation fault[2]";
|
||||
break;
|
||||
case 0x05: FaultSource = "Translation fault on Section";
|
||||
break;
|
||||
case 0x06: FaultSource = "Access Flag fault on Page";
|
||||
break;
|
||||
case 0x07: FaultSource = "Translation fault on Page";
|
||||
break;
|
||||
case 0x08: FaultSource = "Precise External Abort";
|
||||
break;
|
||||
case 0x09: FaultSource = "Domain fault on Section";
|
||||
break;
|
||||
case 0x0b: FaultSource = "Domain fault on Page";
|
||||
break;
|
||||
case 0x0c: FaultSource = "External abort on translation, first level";
|
||||
break;
|
||||
case 0x0d: FaultSource = "Permission fault on Section";
|
||||
break;
|
||||
case 0x0e: FaultSource = "External abort on translation, second level";
|
||||
break;
|
||||
case 0x0f: FaultSource = "Permission fault on Page";
|
||||
break;
|
||||
case 0x16: FaultSource = "Imprecise External Abort";
|
||||
break;
|
||||
default: FaultSource = "No function";
|
||||
break;
|
||||
}
|
||||
|
||||
return FaultSource;
|
||||
}
|
||||
|
||||
STATIC CHAR8 *gExceptionTypeString[] = {
|
||||
STATIC CHAR8 *gExceptionTypeString[] = {
|
||||
"Reset",
|
||||
"Undefined OpCode",
|
||||
"SVC",
|
||||
@@ -178,62 +194,68 @@ STATIC CHAR8 *gExceptionTypeString[] = {
|
||||
**/
|
||||
VOID
|
||||
DefaultExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
CHAR8 Buffer[100];
|
||||
UINTN CharCount;
|
||||
UINT32 DfsrStatus;
|
||||
UINT32 IfsrStatus;
|
||||
BOOLEAN DfsrWrite;
|
||||
UINT32 PcAdjust;
|
||||
CHAR8 Buffer[100];
|
||||
UINTN CharCount;
|
||||
UINT32 DfsrStatus;
|
||||
UINT32 IfsrStatus;
|
||||
BOOLEAN DfsrWrite;
|
||||
UINT32 PcAdjust;
|
||||
|
||||
PcAdjust = 0;
|
||||
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n%a Exception PC at 0x%08x CPSR 0x%08x ",
|
||||
gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR);
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
sizeof (Buffer),
|
||||
"\n%a Exception PC at 0x%08x CPSR 0x%08x ",
|
||||
gExceptionTypeString[ExceptionType],
|
||||
SystemContext.SystemContextArm->PC,
|
||||
SystemContext.SystemContextArm->CPSR
|
||||
);
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
if (gST->ConOut != NULL) {
|
||||
AsciiPrint (Buffer);
|
||||
}
|
||||
|
||||
DEBUG_CODE_BEGIN ();
|
||||
CHAR8 *Pdb;
|
||||
UINT32 ImageBase;
|
||||
UINT32 PeCoffSizeOfHeader;
|
||||
UINT32 Offset;
|
||||
CHAR8 CpsrStr[CPSR_STRING_SIZE]; // char per bit. Lower 5-bits are mode
|
||||
CHAR8 *Pdb;
|
||||
UINT32 ImageBase;
|
||||
UINT32 PeCoffSizeOfHeader;
|
||||
UINT32 Offset;
|
||||
CHAR8 CpsrStr[CPSR_STRING_SIZE]; // char per bit. Lower 5-bits are mode
|
||||
// that is a 3 char string
|
||||
CHAR8 Buffer[80];
|
||||
UINT8 *DisAsm;
|
||||
UINT32 ItBlock;
|
||||
CHAR8 Buffer[80];
|
||||
UINT8 *DisAsm;
|
||||
UINT32 ItBlock;
|
||||
|
||||
CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);
|
||||
DEBUG ((DEBUG_ERROR, "%a\n", CpsrStr));
|
||||
CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);
|
||||
DEBUG ((DEBUG_ERROR, "%a\n", CpsrStr));
|
||||
|
||||
Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase, &PeCoffSizeOfHeader);
|
||||
Offset = SystemContext.SystemContextArm->PC - ImageBase;
|
||||
if (Pdb != NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "%a\n", Pdb));
|
||||
Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase, &PeCoffSizeOfHeader);
|
||||
Offset = SystemContext.SystemContextArm->PC - ImageBase;
|
||||
if (Pdb != NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "%a\n", Pdb));
|
||||
|
||||
//
|
||||
// A PE/COFF image loads its headers into memory so the headers are
|
||||
// included in the linked addresses. ELF and Mach-O images do not
|
||||
// include the headers so the first byte of the image is usually
|
||||
// text (code). If you look at link maps from ELF or Mach-O images
|
||||
// you need to subtract out the size of the PE/COFF header to get
|
||||
// get the offset that matches the link map.
|
||||
//
|
||||
DEBUG ((DEBUG_ERROR, "loaded at 0x%08x (PE/COFF offset) 0x%x (ELF or Mach-O offset) 0x%x", ImageBase, Offset, Offset - PeCoffSizeOfHeader));
|
||||
//
|
||||
// A PE/COFF image loads its headers into memory so the headers are
|
||||
// included in the linked addresses. ELF and Mach-O images do not
|
||||
// include the headers so the first byte of the image is usually
|
||||
// text (code). If you look at link maps from ELF or Mach-O images
|
||||
// you need to subtract out the size of the PE/COFF header to get
|
||||
// get the offset that matches the link map.
|
||||
//
|
||||
DEBUG ((DEBUG_ERROR, "loaded at 0x%08x (PE/COFF offset) 0x%x (ELF or Mach-O offset) 0x%x", ImageBase, Offset, Offset - PeCoffSizeOfHeader));
|
||||
|
||||
// If we come from an image it is safe to show the instruction. We know it should not fault
|
||||
DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC;
|
||||
ItBlock = 0;
|
||||
DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, TRUE, &ItBlock, Buffer, sizeof (Buffer));
|
||||
DEBUG ((DEBUG_ERROR, "\n%a", Buffer));
|
||||
// If we come from an image it is safe to show the instruction. We know it should not fault
|
||||
DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC;
|
||||
ItBlock = 0;
|
||||
DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, TRUE, &ItBlock, Buffer, sizeof (Buffer));
|
||||
DEBUG ((DEBUG_ERROR, "\n%a", Buffer));
|
||||
|
||||
switch (ExceptionType) {
|
||||
switch (ExceptionType) {
|
||||
case EXCEPT_ARM_UNDEFINED_INSTRUCTION:
|
||||
case EXCEPT_ARM_SOFTWARE_INTERRUPT:
|
||||
case EXCEPT_ARM_PREFETCH_ABORT:
|
||||
@@ -244,9 +266,9 @@ DefaultExceptionHandler (
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_CODE_END ();
|
||||
DEBUG ((DEBUG_ERROR, "\n R0 0x%08x R1 0x%08x R2 0x%08x R3 0x%08x\n", SystemContext.SystemContextArm->R0, SystemContext.SystemContextArm->R1, SystemContext.SystemContextArm->R2, SystemContext.SystemContextArm->R3));
|
||||
DEBUG ((DEBUG_ERROR, " R4 0x%08x R5 0x%08x R6 0x%08x R7 0x%08x\n", SystemContext.SystemContextArm->R4, SystemContext.SystemContextArm->R5, SystemContext.SystemContextArm->R6, SystemContext.SystemContextArm->R7));
|
||||
@@ -256,7 +278,7 @@ DefaultExceptionHandler (
|
||||
|
||||
// Bit10 is Status[4] Bit3:0 is Status[3:0]
|
||||
DfsrStatus = (SystemContext.SystemContextArm->DFSR & 0xf) | ((SystemContext.SystemContextArm->DFSR >> 6) & 0x10);
|
||||
DfsrWrite = (SystemContext.SystemContextArm->DFSR & BIT11) != 0;
|
||||
DfsrWrite = (SystemContext.SystemContextArm->DFSR & BIT11) != 0;
|
||||
if (DfsrStatus != 0x00) {
|
||||
DEBUG ((DEBUG_ERROR, " %a: %a 0x%08x\n", FaultStatusToString (DfsrStatus), DfsrWrite ? "write to" : "read from", SystemContext.SystemContextArm->DFAR));
|
||||
}
|
||||
|
@@ -33,11 +33,11 @@ GetImageName (
|
||||
OUT UINTN *PeCoffSizeOfHeaders
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *DebugTableHeader;
|
||||
EFI_DEBUG_IMAGE_INFO *DebugTable;
|
||||
UINTN Entry;
|
||||
CHAR8 *Address;
|
||||
EFI_STATUS Status;
|
||||
EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *DebugTableHeader;
|
||||
EFI_DEBUG_IMAGE_INFO *DebugTable;
|
||||
UINTN Entry;
|
||||
CHAR8 *Address;
|
||||
|
||||
Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&DebugTableHeader);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -53,10 +53,12 @@ GetImageName (
|
||||
for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) {
|
||||
if (DebugTable->NormalImage != NULL) {
|
||||
if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
|
||||
(DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
|
||||
(DebugTable->NormalImage->LoadedImageProtocolInstance != NULL))
|
||||
{
|
||||
if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&
|
||||
(Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) {
|
||||
*ImageBase = (UINTN)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;
|
||||
(Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize)))
|
||||
{
|
||||
*ImageBase = (UINTN)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;
|
||||
*PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)*ImageBase);
|
||||
return PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase);
|
||||
}
|
||||
@@ -66,4 +68,3 @@ GetImageName (
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -38,19 +38,19 @@
|
||||
STATIC
|
||||
VOID
|
||||
PlatformRegisterFvBootOption (
|
||||
CONST EFI_GUID *FileGuid,
|
||||
CHAR16 *Description,
|
||||
UINT32 Attributes
|
||||
CONST EFI_GUID *FileGuid,
|
||||
CHAR16 *Description,
|
||||
UINT32 Attributes
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
INTN OptionIndex;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||
UINTN BootOptionCount;
|
||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
EFI_STATUS Status;
|
||||
INTN OptionIndex;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||
UINTN BootOptionCount;
|
||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
gImageHandle,
|
||||
@@ -96,6 +96,7 @@ PlatformRegisterFvBootOption (
|
||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
EfiBootManagerFreeLoadOption (&NewOption);
|
||||
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
||||
}
|
||||
@@ -136,7 +137,7 @@ PlatformBootManagerAfterConsole (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_GUID LinuxBootFileGuid;
|
||||
EFI_GUID LinuxBootFileGuid;
|
||||
|
||||
CopyGuid (&LinuxBootFileGuid, PcdGetPtr (PcdLinuxBootFileGuid));
|
||||
|
||||
@@ -163,7 +164,7 @@ PlatformBootManagerAfterConsole (
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerWaitCallback (
|
||||
UINT16 TimeoutRemain
|
||||
UINT16 TimeoutRemain
|
||||
)
|
||||
{
|
||||
return;
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include <OpteeSmc.h>
|
||||
#include <Uefi.h>
|
||||
|
||||
STATIC OPTEE_SHARED_MEMORY_INFORMATION OpteeSharedMemoryInformation = { 0 };
|
||||
STATIC OPTEE_SHARED_MEMORY_INFORMATION OpteeSharedMemoryInformation = { 0 };
|
||||
|
||||
/**
|
||||
Check for OP-TEE presence.
|
||||
@@ -31,7 +31,7 @@ IsOpteePresent (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ARM_SMC_ARGS ArmSmcArgs;
|
||||
ARM_SMC_ARGS ArmSmcArgs;
|
||||
|
||||
ZeroMem (&ArmSmcArgs, sizeof (ARM_SMC_ARGS));
|
||||
// Send a Trusted OS Calls UID command
|
||||
@@ -41,7 +41,8 @@ IsOpteePresent (
|
||||
if ((ArmSmcArgs.Arg0 == OPTEE_OS_UID0) &&
|
||||
(ArmSmcArgs.Arg1 == OPTEE_OS_UID1) &&
|
||||
(ArmSmcArgs.Arg2 == OPTEE_OS_UID2) &&
|
||||
(ArmSmcArgs.Arg3 == OPTEE_OS_UID3)) {
|
||||
(ArmSmcArgs.Arg3 == OPTEE_OS_UID3))
|
||||
{
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
@@ -54,12 +55,12 @@ OpteeSharedMemoryRemap (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ARM_SMC_ARGS ArmSmcArgs;
|
||||
EFI_PHYSICAL_ADDRESS PhysicalAddress;
|
||||
EFI_PHYSICAL_ADDRESS Start;
|
||||
EFI_PHYSICAL_ADDRESS End;
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
ARM_SMC_ARGS ArmSmcArgs;
|
||||
EFI_PHYSICAL_ADDRESS PhysicalAddress;
|
||||
EFI_PHYSICAL_ADDRESS Start;
|
||||
EFI_PHYSICAL_ADDRESS End;
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
|
||||
ZeroMem (&ArmSmcArgs, sizeof (ARM_SMC_ARGS));
|
||||
ArmSmcArgs.Arg0 = OPTEE_SMC_GET_SHARED_MEMORY_CONFIG;
|
||||
@@ -75,10 +76,10 @@ OpteeSharedMemoryRemap (
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Start = (ArmSmcArgs.Arg1 + SIZE_4KB - 1) & ~(SIZE_4KB - 1);
|
||||
End = (ArmSmcArgs.Arg1 + ArmSmcArgs.Arg2) & ~(SIZE_4KB - 1);
|
||||
Start = (ArmSmcArgs.Arg1 + SIZE_4KB - 1) & ~(SIZE_4KB - 1);
|
||||
End = (ArmSmcArgs.Arg1 + ArmSmcArgs.Arg2) & ~(SIZE_4KB - 1);
|
||||
PhysicalAddress = Start;
|
||||
Size = End - Start;
|
||||
Size = End - Start;
|
||||
|
||||
if (Size < SIZE_4KB) {
|
||||
DEBUG ((DEBUG_WARN, "OP-TEE shared memory too small\n"));
|
||||
@@ -102,7 +103,7 @@ OpteeInit (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (!IsOpteePresent ()) {
|
||||
DEBUG ((DEBUG_WARN, "OP-TEE not present\n"));
|
||||
@@ -121,7 +122,7 @@ OpteeInit (
|
||||
STATIC
|
||||
BOOLEAN
|
||||
IsOpteeSmcReturnRpc (
|
||||
UINT32 Return
|
||||
UINT32 Return
|
||||
)
|
||||
{
|
||||
return (Return != OPTEE_SMC_RETURN_UNKNOWN_FUNCTION) &&
|
||||
@@ -140,10 +141,10 @@ IsOpteeSmcReturnRpc (
|
||||
STATIC
|
||||
UINT32
|
||||
OpteeCallWithArg (
|
||||
IN UINT64 PhysicalArg
|
||||
IN UINT64 PhysicalArg
|
||||
)
|
||||
{
|
||||
ARM_SMC_ARGS ArmSmcArgs;
|
||||
ARM_SMC_ARGS ArmSmcArgs;
|
||||
|
||||
ZeroMem (&ArmSmcArgs, sizeof (ARM_SMC_ARGS));
|
||||
ArmSmcArgs.Arg0 = OPTEE_SMC_CALL_WITH_ARG;
|
||||
@@ -155,18 +156,18 @@ OpteeCallWithArg (
|
||||
|
||||
if (IsOpteeSmcReturnRpc (ArmSmcArgs.Arg0)) {
|
||||
switch (ArmSmcArgs.Arg0) {
|
||||
case OPTEE_SMC_RETURN_RPC_FOREIGN_INTERRUPT:
|
||||
//
|
||||
// A foreign interrupt was raised while secure world was
|
||||
// executing, since they are handled in UEFI a dummy RPC is
|
||||
// performed to let UEFI take the interrupt through the normal
|
||||
// vector.
|
||||
//
|
||||
break;
|
||||
case OPTEE_SMC_RETURN_RPC_FOREIGN_INTERRUPT:
|
||||
//
|
||||
// A foreign interrupt was raised while secure world was
|
||||
// executing, since they are handled in UEFI a dummy RPC is
|
||||
// performed to let UEFI take the interrupt through the normal
|
||||
// vector.
|
||||
//
|
||||
break;
|
||||
|
||||
default:
|
||||
// Do nothing in case RPC is not implemented.
|
||||
break;
|
||||
default:
|
||||
// Do nothing in case RPC is not implemented.
|
||||
break;
|
||||
}
|
||||
|
||||
ArmSmcArgs.Arg0 = OPTEE_SMC_RETURN_FROM_RPC;
|
||||
@@ -181,8 +182,8 @@ OpteeCallWithArg (
|
||||
STATIC
|
||||
VOID
|
||||
EfiGuidToRfc4122Uuid (
|
||||
OUT RFC4122_UUID *Rfc4122Uuid,
|
||||
IN EFI_GUID *Guid
|
||||
OUT RFC4122_UUID *Rfc4122Uuid,
|
||||
IN EFI_GUID *Guid
|
||||
)
|
||||
{
|
||||
Rfc4122Uuid->Data1 = SwapBytes32 (Guid->Data1);
|
||||
@@ -194,10 +195,10 @@ EfiGuidToRfc4122Uuid (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
OpteeOpenSession (
|
||||
IN OUT OPTEE_OPEN_SESSION_ARG *OpenSessionArg
|
||||
IN OUT OPTEE_OPEN_SESSION_ARG *OpenSessionArg
|
||||
)
|
||||
{
|
||||
OPTEE_MESSAGE_ARG *MessageArg;
|
||||
OPTEE_MESSAGE_ARG *MessageArg;
|
||||
|
||||
MessageArg = NULL;
|
||||
|
||||
@@ -229,12 +230,12 @@ OpteeOpenSession (
|
||||
MessageArg->NumParams = 2;
|
||||
|
||||
if (OpteeCallWithArg ((UINTN)MessageArg) != 0) {
|
||||
MessageArg->Return = OPTEE_ERROR_COMMUNICATION;
|
||||
MessageArg->Return = OPTEE_ERROR_COMMUNICATION;
|
||||
MessageArg->ReturnOrigin = OPTEE_ORIGIN_COMMUNICATION;
|
||||
}
|
||||
|
||||
OpenSessionArg->Session = MessageArg->Session;
|
||||
OpenSessionArg->Return = MessageArg->Return;
|
||||
OpenSessionArg->Session = MessageArg->Session;
|
||||
OpenSessionArg->Return = MessageArg->Return;
|
||||
OpenSessionArg->ReturnOrigin = MessageArg->ReturnOrigin;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@@ -243,10 +244,10 @@ OpteeOpenSession (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
OpteeCloseSession (
|
||||
IN UINT32 Session
|
||||
IN UINT32 Session
|
||||
)
|
||||
{
|
||||
OPTEE_MESSAGE_ARG *MessageArg;
|
||||
OPTEE_MESSAGE_ARG *MessageArg;
|
||||
|
||||
MessageArg = NULL;
|
||||
|
||||
@@ -269,70 +270,70 @@ OpteeCloseSession (
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
OpteeToMessageParam (
|
||||
OUT OPTEE_MESSAGE_PARAM *MessageParams,
|
||||
IN UINT32 NumParams,
|
||||
IN OPTEE_MESSAGE_PARAM *InParams
|
||||
OUT OPTEE_MESSAGE_PARAM *MessageParams,
|
||||
IN UINT32 NumParams,
|
||||
IN OPTEE_MESSAGE_PARAM *InParams
|
||||
)
|
||||
{
|
||||
UINT32 Idx;
|
||||
UINTN ParamSharedMemoryAddress;
|
||||
UINTN SharedMemorySize;
|
||||
UINTN Size;
|
||||
UINT32 Idx;
|
||||
UINTN ParamSharedMemoryAddress;
|
||||
UINTN SharedMemorySize;
|
||||
UINTN Size;
|
||||
|
||||
Size = (sizeof (OPTEE_MESSAGE_ARG) + sizeof (UINT64) - 1) &
|
||||
~(sizeof (UINT64) - 1);
|
||||
~(sizeof (UINT64) - 1);
|
||||
ParamSharedMemoryAddress = OpteeSharedMemoryInformation.Base + Size;
|
||||
SharedMemorySize = OpteeSharedMemoryInformation.Size - Size;
|
||||
SharedMemorySize = OpteeSharedMemoryInformation.Size - Size;
|
||||
|
||||
for (Idx = 0; Idx < NumParams; Idx++) {
|
||||
CONST OPTEE_MESSAGE_PARAM *InParam;
|
||||
OPTEE_MESSAGE_PARAM *MessageParam;
|
||||
UINT32 Attribute;
|
||||
CONST OPTEE_MESSAGE_PARAM *InParam;
|
||||
OPTEE_MESSAGE_PARAM *MessageParam;
|
||||
UINT32 Attribute;
|
||||
|
||||
InParam = InParams + Idx;
|
||||
InParam = InParams + Idx;
|
||||
MessageParam = MessageParams + Idx;
|
||||
Attribute = InParam->Attribute & OPTEE_MESSAGE_ATTRIBUTE_TYPE_MASK;
|
||||
Attribute = InParam->Attribute & OPTEE_MESSAGE_ATTRIBUTE_TYPE_MASK;
|
||||
|
||||
switch (Attribute) {
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE:
|
||||
MessageParam->Attribute = OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE;
|
||||
ZeroMem (&MessageParam->Union, sizeof (MessageParam->Union));
|
||||
break;
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE:
|
||||
MessageParam->Attribute = OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE;
|
||||
ZeroMem (&MessageParam->Union, sizeof (MessageParam->Union));
|
||||
break;
|
||||
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_OUTPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INOUT:
|
||||
MessageParam->Attribute = Attribute;
|
||||
MessageParam->Union.Value.A = InParam->Union.Value.A;
|
||||
MessageParam->Union.Value.B = InParam->Union.Value.B;
|
||||
MessageParam->Union.Value.C = InParam->Union.Value.C;
|
||||
break;
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_OUTPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INOUT:
|
||||
MessageParam->Attribute = Attribute;
|
||||
MessageParam->Union.Value.A = InParam->Union.Value.A;
|
||||
MessageParam->Union.Value.B = InParam->Union.Value.B;
|
||||
MessageParam->Union.Value.C = InParam->Union.Value.C;
|
||||
break;
|
||||
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_OUTPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INOUT:
|
||||
MessageParam->Attribute = Attribute;
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_OUTPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INOUT:
|
||||
MessageParam->Attribute = Attribute;
|
||||
|
||||
if (InParam->Union.Memory.Size > SharedMemorySize) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
if (InParam->Union.Memory.Size > SharedMemorySize) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
(VOID *)ParamSharedMemoryAddress,
|
||||
(VOID *)(UINTN)InParam->Union.Memory.BufferAddress,
|
||||
InParam->Union.Memory.Size
|
||||
);
|
||||
MessageParam->Union.Memory.BufferAddress = (UINT64)ParamSharedMemoryAddress;
|
||||
MessageParam->Union.Memory.Size = InParam->Union.Memory.Size;
|
||||
CopyMem (
|
||||
(VOID *)ParamSharedMemoryAddress,
|
||||
(VOID *)(UINTN)InParam->Union.Memory.BufferAddress,
|
||||
InParam->Union.Memory.Size
|
||||
);
|
||||
MessageParam->Union.Memory.BufferAddress = (UINT64)ParamSharedMemoryAddress;
|
||||
MessageParam->Union.Memory.Size = InParam->Union.Memory.Size;
|
||||
|
||||
Size = (InParam->Union.Memory.Size + sizeof (UINT64) - 1) &
|
||||
~(sizeof (UINT64) - 1);
|
||||
ParamSharedMemoryAddress += Size;
|
||||
SharedMemorySize -= Size;
|
||||
break;
|
||||
Size = (InParam->Union.Memory.Size + sizeof (UINT64) - 1) &
|
||||
~(sizeof (UINT64) - 1);
|
||||
ParamSharedMemoryAddress += Size;
|
||||
SharedMemorySize -= Size;
|
||||
break;
|
||||
|
||||
default:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
default:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,56 +343,56 @@ OpteeToMessageParam (
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
OpteeFromMessageParam (
|
||||
OUT OPTEE_MESSAGE_PARAM *OutParams,
|
||||
IN UINT32 NumParams,
|
||||
IN OPTEE_MESSAGE_PARAM *MessageParams
|
||||
OUT OPTEE_MESSAGE_PARAM *OutParams,
|
||||
IN UINT32 NumParams,
|
||||
IN OPTEE_MESSAGE_PARAM *MessageParams
|
||||
)
|
||||
{
|
||||
UINT32 Idx;
|
||||
UINT32 Idx;
|
||||
|
||||
for (Idx = 0; Idx < NumParams; Idx++) {
|
||||
OPTEE_MESSAGE_PARAM *OutParam;
|
||||
CONST OPTEE_MESSAGE_PARAM *MessageParam;
|
||||
UINT32 Attribute;
|
||||
OPTEE_MESSAGE_PARAM *OutParam;
|
||||
CONST OPTEE_MESSAGE_PARAM *MessageParam;
|
||||
UINT32 Attribute;
|
||||
|
||||
OutParam = OutParams + Idx;
|
||||
OutParam = OutParams + Idx;
|
||||
MessageParam = MessageParams + Idx;
|
||||
Attribute = MessageParam->Attribute & OPTEE_MESSAGE_ATTRIBUTE_TYPE_MASK;
|
||||
Attribute = MessageParam->Attribute & OPTEE_MESSAGE_ATTRIBUTE_TYPE_MASK;
|
||||
|
||||
switch (Attribute) {
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE:
|
||||
OutParam->Attribute = OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE;
|
||||
ZeroMem (&OutParam->Union, sizeof (OutParam->Union));
|
||||
break;
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE:
|
||||
OutParam->Attribute = OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE;
|
||||
ZeroMem (&OutParam->Union, sizeof (OutParam->Union));
|
||||
break;
|
||||
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_OUTPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INOUT:
|
||||
OutParam->Attribute = Attribute;
|
||||
OutParam->Union.Value.A = MessageParam->Union.Value.A;
|
||||
OutParam->Union.Value.B = MessageParam->Union.Value.B;
|
||||
OutParam->Union.Value.C = MessageParam->Union.Value.C;
|
||||
break;
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_OUTPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INOUT:
|
||||
OutParam->Attribute = Attribute;
|
||||
OutParam->Union.Value.A = MessageParam->Union.Value.A;
|
||||
OutParam->Union.Value.B = MessageParam->Union.Value.B;
|
||||
OutParam->Union.Value.C = MessageParam->Union.Value.C;
|
||||
break;
|
||||
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_OUTPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INOUT:
|
||||
OutParam->Attribute = Attribute;
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_OUTPUT:
|
||||
case OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INOUT:
|
||||
OutParam->Attribute = Attribute;
|
||||
|
||||
if (MessageParam->Union.Memory.Size > OutParam->Union.Memory.Size) {
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
if (MessageParam->Union.Memory.Size > OutParam->Union.Memory.Size) {
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
(VOID *)(UINTN)OutParam->Union.Memory.BufferAddress,
|
||||
(VOID *)(UINTN)MessageParam->Union.Memory.BufferAddress,
|
||||
MessageParam->Union.Memory.Size
|
||||
);
|
||||
OutParam->Union.Memory.Size = MessageParam->Union.Memory.Size;
|
||||
break;
|
||||
CopyMem (
|
||||
(VOID *)(UINTN)OutParam->Union.Memory.BufferAddress,
|
||||
(VOID *)(UINTN)MessageParam->Union.Memory.BufferAddress,
|
||||
MessageParam->Union.Memory.Size
|
||||
);
|
||||
OutParam->Union.Memory.Size = MessageParam->Union.Memory.Size;
|
||||
break;
|
||||
|
||||
default:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
default:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,11 +402,11 @@ OpteeFromMessageParam (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
OpteeInvokeFunction (
|
||||
IN OUT OPTEE_INVOKE_FUNCTION_ARG *InvokeFunctionArg
|
||||
IN OUT OPTEE_INVOKE_FUNCTION_ARG *InvokeFunctionArg
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
OPTEE_MESSAGE_ARG *MessageArg;
|
||||
EFI_STATUS Status;
|
||||
OPTEE_MESSAGE_ARG *MessageArg;
|
||||
|
||||
MessageArg = NULL;
|
||||
|
||||
@@ -417,9 +418,9 @@ OpteeInvokeFunction (
|
||||
MessageArg = (OPTEE_MESSAGE_ARG *)OpteeSharedMemoryInformation.Base;
|
||||
ZeroMem (MessageArg, sizeof (OPTEE_MESSAGE_ARG));
|
||||
|
||||
MessageArg->Command = OPTEE_MESSAGE_COMMAND_INVOKE_FUNCTION;
|
||||
MessageArg->Command = OPTEE_MESSAGE_COMMAND_INVOKE_FUNCTION;
|
||||
MessageArg->Function = InvokeFunctionArg->Function;
|
||||
MessageArg->Session = InvokeFunctionArg->Session;
|
||||
MessageArg->Session = InvokeFunctionArg->Session;
|
||||
|
||||
Status = OpteeToMessageParam (
|
||||
MessageArg->Params,
|
||||
@@ -433,7 +434,7 @@ OpteeInvokeFunction (
|
||||
MessageArg->NumParams = OPTEE_MAX_CALL_PARAMS;
|
||||
|
||||
if (OpteeCallWithArg ((UINTN)MessageArg) != 0) {
|
||||
MessageArg->Return = OPTEE_ERROR_COMMUNICATION;
|
||||
MessageArg->Return = OPTEE_ERROR_COMMUNICATION;
|
||||
MessageArg->ReturnOrigin = OPTEE_ORIGIN_COMMUNICATION;
|
||||
}
|
||||
|
||||
@@ -441,12 +442,13 @@ OpteeInvokeFunction (
|
||||
InvokeFunctionArg->Params,
|
||||
OPTEE_MAX_CALL_PARAMS,
|
||||
MessageArg->Params
|
||||
) != 0) {
|
||||
MessageArg->Return = OPTEE_ERROR_COMMUNICATION;
|
||||
) != 0)
|
||||
{
|
||||
MessageArg->Return = OPTEE_ERROR_COMMUNICATION;
|
||||
MessageArg->ReturnOrigin = OPTEE_ORIGIN_COMMUNICATION;
|
||||
}
|
||||
|
||||
InvokeFunctionArg->Return = MessageArg->Return;
|
||||
InvokeFunctionArg->Return = MessageArg->Return;
|
||||
InvokeFunctionArg->ReturnOrigin = MessageArg->ReturnOrigin;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
@@ -11,26 +11,26 @@
|
||||
#define OPTEE_SMC_H_
|
||||
|
||||
/* Returned in Arg0 only from Trusted OS functions */
|
||||
#define OPTEE_SMC_RETURN_OK 0x0
|
||||
#define OPTEE_SMC_RETURN_OK 0x0
|
||||
|
||||
#define OPTEE_SMC_RETURN_FROM_RPC 0x32000003
|
||||
#define OPTEE_SMC_CALL_WITH_ARG 0x32000004
|
||||
#define OPTEE_SMC_GET_SHARED_MEMORY_CONFIG 0xb2000007
|
||||
#define OPTEE_SMC_RETURN_FROM_RPC 0x32000003
|
||||
#define OPTEE_SMC_CALL_WITH_ARG 0x32000004
|
||||
#define OPTEE_SMC_GET_SHARED_MEMORY_CONFIG 0xb2000007
|
||||
|
||||
#define OPTEE_SMC_SHARED_MEMORY_CACHED 1
|
||||
#define OPTEE_SMC_SHARED_MEMORY_CACHED 1
|
||||
|
||||
#define OPTEE_SMC_RETURN_UNKNOWN_FUNCTION 0xffffffff
|
||||
#define OPTEE_SMC_RETURN_RPC_PREFIX_MASK 0xffff0000
|
||||
#define OPTEE_SMC_RETURN_RPC_PREFIX 0xffff0000
|
||||
#define OPTEE_SMC_RETURN_RPC_FOREIGN_INTERRUPT 0xffff0004
|
||||
|
||||
#define OPTEE_MESSAGE_COMMAND_OPEN_SESSION 0
|
||||
#define OPTEE_MESSAGE_COMMAND_INVOKE_FUNCTION 1
|
||||
#define OPTEE_MESSAGE_COMMAND_CLOSE_SESSION 2
|
||||
#define OPTEE_MESSAGE_COMMAND_OPEN_SESSION 0
|
||||
#define OPTEE_MESSAGE_COMMAND_INVOKE_FUNCTION 1
|
||||
#define OPTEE_MESSAGE_COMMAND_CLOSE_SESSION 2
|
||||
|
||||
#define OPTEE_MESSAGE_ATTRIBUTE_META 0x100
|
||||
#define OPTEE_MESSAGE_ATTRIBUTE_META 0x100
|
||||
|
||||
#define OPTEE_LOGIN_PUBLIC 0x0
|
||||
#define OPTEE_LOGIN_PUBLIC 0x0
|
||||
|
||||
typedef struct {
|
||||
UINTN Base;
|
||||
@@ -41,10 +41,10 @@ typedef struct {
|
||||
// UUID struct compliant with RFC4122 (network byte order).
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Data1;
|
||||
UINT16 Data2;
|
||||
UINT16 Data3;
|
||||
UINT8 Data4[8];
|
||||
UINT32 Data1;
|
||||
UINT16 Data2;
|
||||
UINT16 Data3;
|
||||
UINT8 Data4[8];
|
||||
} RFC4122_UUID;
|
||||
|
||||
#endif // OPTEE_SMC_H_
|
||||
|
@@ -28,10 +28,10 @@
|
||||
VOID
|
||||
EFIAPI
|
||||
SetPeiServicesTablePointer (
|
||||
IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
|
||||
IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
|
||||
)
|
||||
{
|
||||
ArmWriteTpidrurw((UINTN)PeiServicesTablePointer);
|
||||
ArmWriteTpidrurw ((UINTN)PeiServicesTablePointer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ GetPeiServicesTablePointer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return (CONST EFI_PEI_SERVICES **)ArmReadTpidrurw();
|
||||
return (CONST EFI_PEI_SERVICES **)ArmReadTpidrurw ();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,9 +71,9 @@ migration actions are required for Itanium or ARM CPUs.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
MigratePeiServicesTablePointer(
|
||||
VOID
|
||||
)
|
||||
MigratePeiServicesTablePointer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -37,23 +37,23 @@
|
||||
|
||||
#include "PlatformBm.h"
|
||||
|
||||
#define DP_NODE_LEN(Type) { (UINT8)sizeof (Type), (UINT8)(sizeof (Type) >> 8) }
|
||||
#define DP_NODE_LEN(Type) { (UINT8)sizeof (Type), (UINT8)(sizeof (Type) >> 8) }
|
||||
|
||||
#pragma pack (1)
|
||||
typedef struct {
|
||||
VENDOR_DEVICE_PATH SerialDxe;
|
||||
UART_DEVICE_PATH Uart;
|
||||
VENDOR_DEFINED_DEVICE_PATH TermType;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
VENDOR_DEVICE_PATH SerialDxe;
|
||||
UART_DEVICE_PATH Uart;
|
||||
VENDOR_DEFINED_DEVICE_PATH TermType;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} PLATFORM_SERIAL_CONSOLE;
|
||||
#pragma pack ()
|
||||
|
||||
STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
|
||||
STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
|
||||
//
|
||||
// VENDOR_DEVICE_PATH SerialDxe
|
||||
//
|
||||
{
|
||||
{ HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },
|
||||
{ HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },
|
||||
EDKII_SERIAL_PORT_LIB_VENDOR_GUID
|
||||
},
|
||||
|
||||
@@ -61,7 +61,7 @@ STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
|
||||
// UART_DEVICE_PATH Uart
|
||||
//
|
||||
{
|
||||
{ MESSAGING_DEVICE_PATH, MSG_UART_DP, DP_NODE_LEN (UART_DEVICE_PATH) },
|
||||
{ MESSAGING_DEVICE_PATH, MSG_UART_DP, DP_NODE_LEN (UART_DEVICE_PATH) },
|
||||
0, // Reserved
|
||||
FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
|
||||
FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
|
||||
@@ -91,15 +91,14 @@ STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#pragma pack (1)
|
||||
typedef struct {
|
||||
USB_CLASS_DEVICE_PATH Keyboard;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
USB_CLASS_DEVICE_PATH Keyboard;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} PLATFORM_USB_KEYBOARD;
|
||||
#pragma pack ()
|
||||
|
||||
STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
|
||||
STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
|
||||
//
|
||||
// USB_CLASS_DEVICE_PATH Keyboard
|
||||
//
|
||||
@@ -124,7 +123,6 @@ STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Check if the handle satisfies a particular condition.
|
||||
|
||||
@@ -138,12 +136,11 @@ STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
|
||||
**/
|
||||
typedef
|
||||
BOOLEAN
|
||||
(EFIAPI *FILTER_FUNCTION) (
|
||||
(EFIAPI *FILTER_FUNCTION)(
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Process a handle.
|
||||
|
||||
@@ -153,7 +150,7 @@ BOOLEAN
|
||||
**/
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *CALLBACK_FUNCTION) (
|
||||
(EFIAPI *CALLBACK_FUNCTION)(
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
);
|
||||
@@ -174,31 +171,41 @@ VOID
|
||||
STATIC
|
||||
VOID
|
||||
FilterAndProcess (
|
||||
IN EFI_GUID *ProtocolGuid,
|
||||
IN FILTER_FUNCTION Filter OPTIONAL,
|
||||
IN CALLBACK_FUNCTION Process
|
||||
IN EFI_GUID *ProtocolGuid,
|
||||
IN FILTER_FUNCTION Filter OPTIONAL,
|
||||
IN CALLBACK_FUNCTION Process
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE *Handles;
|
||||
UINTN NoHandles;
|
||||
UINTN Idx;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE *Handles;
|
||||
UINTN NoHandles;
|
||||
UINTN Idx;
|
||||
|
||||
Status = gBS->LocateHandleBuffer (ByProtocol, ProtocolGuid,
|
||||
NULL /* SearchKey */, &NoHandles, &Handles);
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
ProtocolGuid,
|
||||
NULL /* SearchKey */,
|
||||
&NoHandles,
|
||||
&Handles
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// This is not an error, just an informative condition.
|
||||
//
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: %g: %r\n", __FUNCTION__, ProtocolGuid,
|
||||
Status));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: %g: %r\n",
|
||||
__FUNCTION__,
|
||||
ProtocolGuid,
|
||||
Status
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT (NoHandles > 0);
|
||||
for (Idx = 0; Idx < NoHandles; ++Idx) {
|
||||
CHAR16 *DevicePathText;
|
||||
STATIC CHAR16 Fallback[] = L"<device path unavailable>";
|
||||
CHAR16 *DevicePathText;
|
||||
STATIC CHAR16 Fallback[] = L"<device path unavailable>";
|
||||
|
||||
//
|
||||
// The ConvertDevicePathToText() function handles NULL input transparently.
|
||||
@@ -212,7 +219,7 @@ FilterAndProcess (
|
||||
DevicePathText = Fallback;
|
||||
}
|
||||
|
||||
if (Filter == NULL || Filter (Handles[Idx], DevicePathText)) {
|
||||
if ((Filter == NULL) || Filter (Handles[Idx], DevicePathText)) {
|
||||
Process (Handles[Idx], DevicePathText);
|
||||
}
|
||||
|
||||
@@ -220,10 +227,10 @@ FilterAndProcess (
|
||||
FreePool (DevicePathText);
|
||||
}
|
||||
}
|
||||
|
||||
gBS->FreePool (Handles);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This FILTER_FUNCTION checks if a handle corresponds to a PCI display device.
|
||||
**/
|
||||
@@ -231,16 +238,19 @@ STATIC
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsPciDisplay (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||
PCI_TYPE00 Pci;
|
||||
EFI_STATUS Status;
|
||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||
PCI_TYPE00 Pci;
|
||||
|
||||
Status = gBS->HandleProtocol (Handle, &gEfiPciIoProtocolGuid,
|
||||
(VOID**)&PciIo);
|
||||
Status = gBS->HandleProtocol (
|
||||
Handle,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **)&PciIo
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// This is not an error worth reporting.
|
||||
@@ -248,8 +258,13 @@ IsPciDisplay (
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0 /* Offset */,
|
||||
sizeof Pci / sizeof (UINT32), &Pci);
|
||||
Status = PciIo->Pci.Read (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint32,
|
||||
0 /* Offset */,
|
||||
sizeof Pci / sizeof (UINT32),
|
||||
&Pci
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: %s: %r\n", __FUNCTION__, ReportText, Status));
|
||||
return FALSE;
|
||||
@@ -258,7 +273,6 @@ IsPciDisplay (
|
||||
return IS_PCI_DISPLAY (&Pci);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This FILTER_FUNCTION checks if a handle corresponds to a non-discoverable
|
||||
USB host controller.
|
||||
@@ -267,29 +281,32 @@ STATIC
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsUsbHost (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
)
|
||||
{
|
||||
NON_DISCOVERABLE_DEVICE *Device;
|
||||
EFI_STATUS Status;
|
||||
NON_DISCOVERABLE_DEVICE *Device;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->HandleProtocol (Handle,
|
||||
Status = gBS->HandleProtocol (
|
||||
Handle,
|
||||
&gEdkiiNonDiscoverableDeviceProtocolGuid,
|
||||
(VOID **)&Device);
|
||||
(VOID **)&Device
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (CompareGuid (Device->Type, &gEdkiiNonDiscoverableUhciDeviceGuid) ||
|
||||
CompareGuid (Device->Type, &gEdkiiNonDiscoverableEhciDeviceGuid) ||
|
||||
CompareGuid (Device->Type, &gEdkiiNonDiscoverableXhciDeviceGuid)) {
|
||||
CompareGuid (Device->Type, &gEdkiiNonDiscoverableXhciDeviceGuid))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This CALLBACK_FUNCTION attempts to connect a handle non-recursively, asking
|
||||
the matching driver to produce all first-level child handles.
|
||||
@@ -298,11 +315,11 @@ STATIC
|
||||
VOID
|
||||
EFIAPI
|
||||
Connect (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->ConnectController (
|
||||
Handle, // ControllerHandle
|
||||
@@ -310,11 +327,15 @@ Connect (
|
||||
NULL, // RemainingDevicePath -- produce all children
|
||||
FALSE // Recursive
|
||||
);
|
||||
DEBUG ((EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE, "%a: %s: %r\n",
|
||||
__FUNCTION__, ReportText, Status));
|
||||
DEBUG ((
|
||||
EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE,
|
||||
"%a: %s: %r\n",
|
||||
__FUNCTION__,
|
||||
ReportText,
|
||||
Status
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This CALLBACK_FUNCTION retrieves the EFI_DEVICE_PATH_PROTOCOL from the
|
||||
handle, and adds it to ConOut and ErrOut.
|
||||
@@ -323,60 +344,79 @@ STATIC
|
||||
VOID
|
||||
EFIAPI
|
||||
AddOutput (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
|
||||
DevicePath = DevicePathFromHandle (Handle);
|
||||
if (DevicePath == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: %s: handle %p: device path not found\n",
|
||||
__FUNCTION__, ReportText, Handle));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: %s: handle %p: device path not found\n",
|
||||
__FUNCTION__,
|
||||
ReportText,
|
||||
Handle
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: %s: adding to ConOut: %r\n", __FUNCTION__,
|
||||
ReportText, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: %s: adding to ConOut: %r\n",
|
||||
__FUNCTION__,
|
||||
ReportText,
|
||||
Status
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: %s: adding to ErrOut: %r\n", __FUNCTION__,
|
||||
ReportText, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: %s: adding to ErrOut: %r\n",
|
||||
__FUNCTION__,
|
||||
ReportText,
|
||||
Status
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: %s: added to ConOut and ErrOut\n", __FUNCTION__,
|
||||
ReportText));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: %s: added to ConOut and ErrOut\n",
|
||||
__FUNCTION__,
|
||||
ReportText
|
||||
));
|
||||
}
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
PlatformRegisterFvBootOption (
|
||||
CONST EFI_GUID *FileGuid,
|
||||
CHAR16 *Description,
|
||||
UINT32 Attributes,
|
||||
EFI_INPUT_KEY *Key
|
||||
CONST EFI_GUID *FileGuid,
|
||||
CHAR16 *Description,
|
||||
UINT32 Attributes,
|
||||
EFI_INPUT_KEY *Key
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
INTN OptionIndex;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||
UINTN BootOptionCount;
|
||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
EFI_STATUS Status;
|
||||
INTN OptionIndex;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||
UINTN BootOptionCount;
|
||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
gImageHandle,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
(VOID **) &LoadedImage
|
||||
(VOID **)&LoadedImage
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
@@ -385,7 +425,7 @@ PlatformRegisterFvBootOption (
|
||||
ASSERT (DevicePath != NULL);
|
||||
DevicePath = AppendDevicePathNode (
|
||||
DevicePath,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&FileNode
|
||||
);
|
||||
ASSERT (DevicePath != NULL);
|
||||
|
||||
@@ -403,25 +443,33 @@ PlatformRegisterFvBootOption (
|
||||
FreePool (DevicePath);
|
||||
|
||||
BootOptions = EfiBootManagerGetLoadOptions (
|
||||
&BootOptionCount, LoadOptionTypeBoot
|
||||
&BootOptionCount,
|
||||
LoadOptionTypeBoot
|
||||
);
|
||||
|
||||
OptionIndex = EfiBootManagerFindLoadOption (
|
||||
&NewOption, BootOptions, BootOptionCount
|
||||
&NewOption,
|
||||
BootOptions,
|
||||
BootOptionCount
|
||||
);
|
||||
|
||||
if (OptionIndex == -1) {
|
||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = EfiBootManagerAddKeyOptionVariable (NULL,
|
||||
(UINT16)NewOption.OptionNumber, 0, Key, NULL);
|
||||
Status = EfiBootManagerAddKeyOptionVariable (
|
||||
NULL,
|
||||
(UINT16)NewOption.OptionNumber,
|
||||
0,
|
||||
Key,
|
||||
NULL
|
||||
);
|
||||
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
||||
}
|
||||
|
||||
EfiBootManagerFreeLoadOption (&NewOption);
|
||||
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
||||
}
|
||||
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
GetPlatformOptions (
|
||||
@@ -437,11 +485,15 @@ GetPlatformOptions (
|
||||
UINTN Index;
|
||||
UINTN BootCount;
|
||||
|
||||
Status = gBS->LocateProtocol (&gPlatformBootManagerProtocolGuid, NULL,
|
||||
(VOID **)&PlatformBootManager);
|
||||
Status = gBS->LocateProtocol (
|
||||
&gPlatformBootManagerProtocolGuid,
|
||||
NULL,
|
||||
(VOID **)&PlatformBootManager
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Status = PlatformBootManager->GetPlatformBootOptionsAndKeys (
|
||||
&BootCount,
|
||||
&BootOptions,
|
||||
@@ -450,6 +502,7 @@ GetPlatformOptions (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Fetch the existent boot options. If there are none, CurrentBootCount
|
||||
// will be zeroed.
|
||||
@@ -462,8 +515,8 @@ GetPlatformOptions (
|
||||
// Process the platform boot options.
|
||||
//
|
||||
for (Index = 0; Index < BootCount; Index++) {
|
||||
INTN Match;
|
||||
UINTN BootOptionNumber;
|
||||
INTN Match;
|
||||
UINTN BootOptionNumber;
|
||||
|
||||
//
|
||||
// If there are any preexistent boot options, and the subject platform boot
|
||||
@@ -491,10 +544,16 @@ GetPlatformOptions (
|
||||
MAX_UINTN
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to register \"%s\": %r\n",
|
||||
__FUNCTION__, BootOptions[Index].Description, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: failed to register \"%s\": %r\n",
|
||||
__FUNCTION__,
|
||||
BootOptions[Index].Description,
|
||||
Status
|
||||
));
|
||||
continue;
|
||||
}
|
||||
|
||||
BootOptionNumber = BootOptions[Index].OptionNumber;
|
||||
}
|
||||
|
||||
@@ -513,10 +572,16 @@ GetPlatformOptions (
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to register hotkey for \"%s\": %r\n",
|
||||
__FUNCTION__, BootOptions[Index].Description, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: failed to register hotkey for \"%s\": %r\n",
|
||||
__FUNCTION__,
|
||||
BootOptions[Index].Description,
|
||||
Status
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
EfiBootManagerFreeLoadOptions (CurrentBootOptions, CurrentBootOptionCount);
|
||||
EfiBootManagerFreeLoadOptions (BootOptions, BootCount);
|
||||
FreePool (BootKeys);
|
||||
@@ -528,11 +593,11 @@ PlatformRegisterOptionsAndKeys (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_INPUT_KEY Enter;
|
||||
EFI_INPUT_KEY F2;
|
||||
EFI_INPUT_KEY Esc;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
|
||||
EFI_STATUS Status;
|
||||
EFI_INPUT_KEY Enter;
|
||||
EFI_INPUT_KEY F2;
|
||||
EFI_INPUT_KEY Esc;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
|
||||
|
||||
GetPlatformOptions ();
|
||||
|
||||
@@ -541,7 +606,7 @@ PlatformRegisterOptionsAndKeys (
|
||||
//
|
||||
Enter.ScanCode = SCAN_NULL;
|
||||
Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
|
||||
Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
|
||||
Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
@@ -551,22 +616,30 @@ PlatformRegisterOptionsAndKeys (
|
||||
F2.UnicodeChar = CHAR_NULL;
|
||||
Esc.ScanCode = SCAN_ESC;
|
||||
Esc.UnicodeChar = CHAR_NULL;
|
||||
Status = EfiBootManagerGetBootManagerMenu (&BootOption);
|
||||
Status = EfiBootManagerGetBootManagerMenu (&BootOption);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = EfiBootManagerAddKeyOptionVariable (
|
||||
NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL
|
||||
NULL,
|
||||
(UINT16)BootOption.OptionNumber,
|
||||
0,
|
||||
&F2,
|
||||
NULL
|
||||
);
|
||||
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
||||
Status = EfiBootManagerAddKeyOptionVariable (
|
||||
NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL
|
||||
NULL,
|
||||
(UINT16)BootOption.OptionNumber,
|
||||
0,
|
||||
&Esc,
|
||||
NULL
|
||||
);
|
||||
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// BDS Platform Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Do the platform init, can be customized by OEM/IBV
|
||||
Possible things that can be done in PlatformBootManagerBeforeConsole:
|
||||
@@ -626,27 +699,45 @@ PlatformBootManagerBeforeConsole (
|
||||
//
|
||||
// Add the hardcoded short-form USB keyboard device path to ConIn.
|
||||
//
|
||||
EfiBootManagerUpdateConsoleVariable (ConIn,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&mUsbKeyboard, NULL);
|
||||
EfiBootManagerUpdateConsoleVariable (
|
||||
ConIn,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&mUsbKeyboard,
|
||||
NULL
|
||||
);
|
||||
|
||||
//
|
||||
// Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
|
||||
//
|
||||
STATIC_ASSERT (FixedPcdGet8 (PcdDefaultTerminalType) == 4,
|
||||
"PcdDefaultTerminalType must be TTYTERM");
|
||||
STATIC_ASSERT (FixedPcdGet8 (PcdUartDefaultParity) != 0,
|
||||
"PcdUartDefaultParity must be set to an actual value, not 'default'");
|
||||
STATIC_ASSERT (FixedPcdGet8 (PcdUartDefaultStopBits) != 0,
|
||||
"PcdUartDefaultStopBits must be set to an actual value, not 'default'");
|
||||
STATIC_ASSERT (
|
||||
FixedPcdGet8 (PcdDefaultTerminalType) == 4,
|
||||
"PcdDefaultTerminalType must be TTYTERM"
|
||||
);
|
||||
STATIC_ASSERT (
|
||||
FixedPcdGet8 (PcdUartDefaultParity) != 0,
|
||||
"PcdUartDefaultParity must be set to an actual value, not 'default'"
|
||||
);
|
||||
STATIC_ASSERT (
|
||||
FixedPcdGet8 (PcdUartDefaultStopBits) != 0,
|
||||
"PcdUartDefaultStopBits must be set to an actual value, not 'default'"
|
||||
);
|
||||
|
||||
CopyGuid (&mSerialConsole.TermType.Guid, &gEfiTtyTermGuid);
|
||||
|
||||
EfiBootManagerUpdateConsoleVariable (ConIn,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
|
||||
EfiBootManagerUpdateConsoleVariable (ConOut,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
|
||||
EfiBootManagerUpdateConsoleVariable (ErrOut,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
|
||||
EfiBootManagerUpdateConsoleVariable (
|
||||
ConIn,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole,
|
||||
NULL
|
||||
);
|
||||
EfiBootManagerUpdateConsoleVariable (
|
||||
ConOut,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole,
|
||||
NULL
|
||||
);
|
||||
EfiBootManagerUpdateConsoleVariable (
|
||||
ErrOut,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole,
|
||||
NULL
|
||||
);
|
||||
|
||||
//
|
||||
// Register platform-specific boot options and keyboard shortcuts.
|
||||
@@ -660,16 +751,19 @@ HandleCapsules (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
|
||||
EFI_PEI_HOB_POINTERS HobPointer;
|
||||
EFI_CAPSULE_HEADER *CapsuleHeader;
|
||||
BOOLEAN NeedReset;
|
||||
EFI_STATUS Status;
|
||||
ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
|
||||
EFI_PEI_HOB_POINTERS HobPointer;
|
||||
EFI_CAPSULE_HEADER *CapsuleHeader;
|
||||
BOOLEAN NeedReset;
|
||||
EFI_STATUS Status;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a: processing capsules ...\n", __FUNCTION__));
|
||||
|
||||
Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL,
|
||||
(VOID **)&EsrtManagement);
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEsrtManagementProtocolGuid,
|
||||
NULL,
|
||||
(VOID **)&EsrtManagement
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
EsrtManagement->SyncEsrtFmp ();
|
||||
}
|
||||
@@ -678,33 +772,43 @@ HandleCapsules (
|
||||
// Find all capsule images from hob
|
||||
//
|
||||
HobPointer.Raw = GetHobList ();
|
||||
NeedReset = FALSE;
|
||||
while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE,
|
||||
HobPointer.Raw)) != NULL) {
|
||||
NeedReset = FALSE;
|
||||
while ((HobPointer.Raw = GetNextHob (
|
||||
EFI_HOB_TYPE_UEFI_CAPSULE,
|
||||
HobPointer.Raw
|
||||
)) != NULL)
|
||||
{
|
||||
CapsuleHeader = (VOID *)(UINTN)HobPointer.Capsule->BaseAddress;
|
||||
|
||||
Status = ProcessCapsuleImage (CapsuleHeader);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to process capsule %p - %r\n",
|
||||
__FUNCTION__, CapsuleHeader, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: failed to process capsule %p - %r\n",
|
||||
__FUNCTION__,
|
||||
CapsuleHeader,
|
||||
Status
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
NeedReset = TRUE;
|
||||
NeedReset = TRUE;
|
||||
HobPointer.Raw = GET_NEXT_HOB (HobPointer);
|
||||
}
|
||||
|
||||
if (NeedReset) {
|
||||
DEBUG ((DEBUG_WARN, "%a: capsule update successful, resetting ...\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: capsule update successful, resetting ...\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
|
||||
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
||||
CpuDeadLoop();
|
||||
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define VERSION_STRING_PREFIX L"Tianocore/EDK2 firmware version "
|
||||
#define VERSION_STRING_PREFIX L"Tianocore/EDK2 firmware version "
|
||||
|
||||
/**
|
||||
This functions checks the value of BootDiscoverPolicy variable and
|
||||
@@ -722,14 +826,14 @@ BootDiscoveryPolicyHandler (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 DiscoveryPolicy;
|
||||
UINT32 DiscoveryPolicyOld;
|
||||
UINTN Size;
|
||||
EFI_BOOT_MANAGER_POLICY_PROTOCOL *BMPolicy;
|
||||
EFI_GUID *Class;
|
||||
EFI_STATUS Status;
|
||||
UINT32 DiscoveryPolicy;
|
||||
UINT32 DiscoveryPolicyOld;
|
||||
UINTN Size;
|
||||
EFI_BOOT_MANAGER_POLICY_PROTOCOL *BMPolicy;
|
||||
EFI_GUID *Class;
|
||||
|
||||
Size = sizeof (DiscoveryPolicy);
|
||||
Size = sizeof (DiscoveryPolicy);
|
||||
Status = gRT->GetVariable (
|
||||
BOOT_DISCOVERY_POLICY_VAR,
|
||||
&gBootDiscoveryPolicyMgrFormsetGuid,
|
||||
@@ -739,7 +843,7 @@ BootDiscoveryPolicyHandler (
|
||||
);
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
DiscoveryPolicy = PcdGet32 (PcdBootDiscoveryPolicy);
|
||||
Status = PcdSet32S (PcdBootDiscoveryPolicy, DiscoveryPolicy);
|
||||
Status = PcdSet32S (PcdBootDiscoveryPolicy, DiscoveryPolicy);
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
return EFI_SUCCESS;
|
||||
} else if (EFI_ERROR (Status)) {
|
||||
@@ -776,13 +880,17 @@ BootDiscoveryPolicyHandler (
|
||||
(VOID **)&BMPolicy
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_INFO, "%a - Failed to locate gEfiBootManagerPolicyProtocolGuid."
|
||||
"Driver connect will be skipped.\n", __FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a - Failed to locate gEfiBootManagerPolicyProtocolGuid."
|
||||
"Driver connect will be skipped.\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = BMPolicy->ConnectDeviceClass (BMPolicy, Class);
|
||||
if (EFI_ERROR (Status)){
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a - ConnectDeviceClass returns - %r\n", __FUNCTION__, Status));
|
||||
return Status;
|
||||
}
|
||||
@@ -790,7 +898,7 @@ BootDiscoveryPolicyHandler (
|
||||
//
|
||||
// Refresh Boot Options if Boot Discovery Policy has been changed
|
||||
//
|
||||
Size = sizeof (DiscoveryPolicyOld);
|
||||
Size = sizeof (DiscoveryPolicyOld);
|
||||
Status = gRT->GetVariable (
|
||||
BOOT_DISCOVERY_POLICY_OLD_VAR,
|
||||
&gBootDiscoveryPolicyMgrFormsetGuid,
|
||||
@@ -845,21 +953,33 @@ PlatformBootManagerAfterConsole (
|
||||
Status = BootLogoEnableLogo ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (FirmwareVerLength > 0) {
|
||||
Print (VERSION_STRING_PREFIX L"%s\n",
|
||||
PcdGetPtr (PcdFirmwareVersionString));
|
||||
Print (
|
||||
VERSION_STRING_PREFIX L"%s\n",
|
||||
PcdGetPtr (PcdFirmwareVersionString)
|
||||
);
|
||||
}
|
||||
|
||||
Print (L"Press ESCAPE for boot options ");
|
||||
} else if (FirmwareVerLength > 0) {
|
||||
Status = gBS->HandleProtocol (gST->ConsoleOutHandle,
|
||||
&gEfiGraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput);
|
||||
Status = gBS->HandleProtocol (
|
||||
gST->ConsoleOutHandle,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
(VOID **)&GraphicsOutput
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
PosX = (GraphicsOutput->Mode->Info->HorizontalResolution -
|
||||
(StrLen (VERSION_STRING_PREFIX) + FirmwareVerLength) *
|
||||
EFI_GLYPH_WIDTH) / 2;
|
||||
PosY = 0;
|
||||
|
||||
PrintXY (PosX, PosY, NULL, NULL, VERSION_STRING_PREFIX L"%s",
|
||||
PcdGetPtr (PcdFirmwareVersionString));
|
||||
PrintXY (
|
||||
PosX,
|
||||
PosY,
|
||||
NULL,
|
||||
NULL,
|
||||
VERSION_STRING_PREFIX L"%s",
|
||||
PcdGetPtr (PcdFirmwareVersionString)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -881,8 +1001,8 @@ PlatformBootManagerAfterConsole (
|
||||
//
|
||||
// Register UEFI Shell
|
||||
//
|
||||
Key.ScanCode = SCAN_NULL;
|
||||
Key.UnicodeChar = L's';
|
||||
Key.ScanCode = SCAN_NULL;
|
||||
Key.UnicodeChar = L's';
|
||||
PlatformRegisterFvBootOption (&gUefiShellFileGuid, L"UEFI Shell", 0, &Key);
|
||||
}
|
||||
|
||||
@@ -895,13 +1015,13 @@ PlatformBootManagerAfterConsole (
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerWaitCallback (
|
||||
UINT16 TimeoutRemain
|
||||
UINT16 TimeoutRemain
|
||||
)
|
||||
{
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
|
||||
UINT16 Timeout;
|
||||
EFI_STATUS Status;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
|
||||
UINT16 Timeout;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Timeout = PcdGet16 (PcdPlatformBootTimeOut);
|
||||
|
||||
@@ -934,17 +1054,19 @@ PlatformBootManagerUnableToBoot (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||
UINTN OldBootOptionCount;
|
||||
UINTN NewBootOptionCount;
|
||||
EFI_STATUS Status;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||
UINTN OldBootOptionCount;
|
||||
UINTN NewBootOptionCount;
|
||||
|
||||
//
|
||||
// Record the total number of boot configured boot options
|
||||
//
|
||||
BootOptions = EfiBootManagerGetLoadOptions (&OldBootOptionCount,
|
||||
LoadOptionTypeBoot);
|
||||
BootOptions = EfiBootManagerGetLoadOptions (
|
||||
&OldBootOptionCount,
|
||||
LoadOptionTypeBoot
|
||||
);
|
||||
EfiBootManagerFreeLoadOptions (BootOptions, OldBootOptionCount);
|
||||
|
||||
//
|
||||
@@ -956,8 +1078,10 @@ PlatformBootManagerUnableToBoot (
|
||||
//
|
||||
// Record the updated number of boot configured boot options
|
||||
//
|
||||
BootOptions = EfiBootManagerGetLoadOptions (&NewBootOptionCount,
|
||||
LoadOptionTypeBoot);
|
||||
BootOptions = EfiBootManagerGetLoadOptions (
|
||||
&NewBootOptionCount,
|
||||
LoadOptionTypeBoot
|
||||
);
|
||||
EfiBootManagerFreeLoadOptions (BootOptions, NewBootOptionCount);
|
||||
|
||||
//
|
||||
@@ -969,8 +1093,11 @@ PlatformBootManagerUnableToBoot (
|
||||
//
|
||||
if (!PcdGetBool (PcdEmuVariableNvModeEnable)) {
|
||||
if (NewBootOptionCount != OldBootOptionCount) {
|
||||
DEBUG ((DEBUG_WARN, "%a: rebooting after refreshing all boot options\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: rebooting after refreshing all boot options\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
||||
}
|
||||
}
|
||||
@@ -980,7 +1107,7 @@ PlatformBootManagerUnableToBoot (
|
||||
return;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
for ( ; ;) {
|
||||
EfiBootManagerBoot (&BootManagerMenu);
|
||||
}
|
||||
}
|
||||
|
@@ -39,19 +39,19 @@ WriteStringToFile (
|
||||
// This gets you all the symbols except for SEC. To get SEC symbols you need to copy the
|
||||
// debug print in the SEC into the debugger manually
|
||||
SemihostWriteString (Buffer);
|
||||
/*
|
||||
I'm currently having issues with this code crashing the debugger. Seems like it should work.
|
||||
|
||||
UINT32 SemihostHandle;
|
||||
UINT32 SemihostMode = SEMIHOST_FILE_MODE_WRITE | SEMIHOST_FILE_MODE_BINARY | SEMIHOST_FILE_MODE_UPDATE;
|
||||
/*
|
||||
I'm currently having issues with this code crashing the debugger. Seems like it should work.
|
||||
|
||||
SemihostFileOpen ("c:\rvi_symbols.inc", SemihostMode, &SemihostHandle);
|
||||
SemihostFileWrite (SemihostHandle, &Length, Buffer);
|
||||
SemihostFileClose (SemihostHandle);
|
||||
*/
|
||||
UINT32 SemihostHandle;
|
||||
UINT32 SemihostMode = SEMIHOST_FILE_MODE_WRITE | SEMIHOST_FILE_MODE_BINARY | SEMIHOST_FILE_MODE_UPDATE;
|
||||
|
||||
SemihostFileOpen ("c:\rvi_symbols.inc", SemihostMode, &SemihostHandle);
|
||||
SemihostFileWrite (SemihostHandle, &Length, Buffer);
|
||||
SemihostFileClose (SemihostHandle);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
If the build is done on cygwin the paths are cygpaths.
|
||||
/cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert
|
||||
@@ -62,12 +62,12 @@ WriteStringToFile (
|
||||
**/
|
||||
CHAR8 *
|
||||
DeCygwinPathIfNeeded (
|
||||
IN CHAR8 *Name
|
||||
IN CHAR8 *Name
|
||||
)
|
||||
{
|
||||
CHAR8 *Ptr;
|
||||
UINTN Index;
|
||||
UINTN Len;
|
||||
CHAR8 *Ptr;
|
||||
UINTN Index;
|
||||
UINTN Len;
|
||||
|
||||
Ptr = AsciiStrStr (Name, "/cygdrive/");
|
||||
if (Ptr == NULL) {
|
||||
@@ -88,14 +88,13 @@ DeCygwinPathIfNeeded (
|
||||
// switch path separators
|
||||
for (Index = 11; Index < Len; Index++) {
|
||||
if (Ptr[Index] == '/') {
|
||||
Ptr[Index] = '\\' ;
|
||||
Ptr[Index] = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
return Name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Performs additional actions after a PE/COFF image has been loaded and relocated.
|
||||
|
||||
@@ -111,20 +110,18 @@ PeCoffLoaderRelocateImageExtraAction (
|
||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
CHAR8 Buffer[256];
|
||||
CHAR8 Buffer[256];
|
||||
|
||||
#if (__ARMCC_VERSION < 500000)
|
||||
AsciiSPrint (Buffer, sizeof(Buffer), "load /a /ni /np \"%a\" &0x%08x\n", ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
|
||||
#else
|
||||
AsciiSPrint (Buffer, sizeof(Buffer), "add-symbol-file %a 0x%08x\n", ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
|
||||
#endif
|
||||
#if (__ARMCC_VERSION < 500000)
|
||||
AsciiSPrint (Buffer, sizeof (Buffer), "load /a /ni /np \"%a\" &0x%08x\n", ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
|
||||
#else
|
||||
AsciiSPrint (Buffer, sizeof (Buffer), "add-symbol-file %a 0x%08x\n", ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
|
||||
#endif
|
||||
DeCygwinPathIfNeeded (&Buffer[16]);
|
||||
|
||||
WriteStringToFile (Buffer, AsciiStrSize (Buffer));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
||||
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
|
||||
@@ -141,9 +138,9 @@ PeCoffLoaderUnloadImageExtraAction (
|
||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
CHAR8 Buffer[256];
|
||||
CHAR8 Buffer[256];
|
||||
|
||||
AsciiSPrint (Buffer, sizeof(Buffer), "unload symbols_only \"%a\"\n", ImageContext->PdbPointer);
|
||||
AsciiSPrint (Buffer, sizeof (Buffer), "unload symbols_only \"%a\"\n", ImageContext->PdbPointer);
|
||||
DeCygwinPathIfNeeded (Buffer);
|
||||
|
||||
WriteStringToFile (Buffer, AsciiStrSize (Buffer));
|
||||
|
@@ -7,7 +7,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
@@ -25,7 +24,7 @@
|
||||
// VA_LIST can not initialize to NULL for all compiler, so we use this to
|
||||
// indicate a null VA_LIST
|
||||
//
|
||||
VA_LIST mVaListNull;
|
||||
VA_LIST mVaListNull;
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,14 +48,13 @@ DebugPrint (
|
||||
...
|
||||
)
|
||||
{
|
||||
VA_LIST Marker;
|
||||
VA_LIST Marker;
|
||||
|
||||
VA_START (Marker, Format);
|
||||
DebugVPrint (ErrorLevel, Format, Marker);
|
||||
VA_END (Marker);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Prints a debug message to the debug output device if the specified
|
||||
error level is enabled base on Null-terminated format string and a
|
||||
@@ -76,13 +74,13 @@ DebugPrint (
|
||||
**/
|
||||
VOID
|
||||
DebugPrintMarker (
|
||||
IN UINTN ErrorLevel,
|
||||
IN CONST CHAR8 *Format,
|
||||
IN VA_LIST VaListMarker,
|
||||
IN BASE_LIST BaseListMarker
|
||||
IN UINTN ErrorLevel,
|
||||
IN CONST CHAR8 *Format,
|
||||
IN VA_LIST VaListMarker,
|
||||
IN BASE_LIST BaseListMarker
|
||||
)
|
||||
{
|
||||
CHAR8 AsciiBuffer[MAX_DEBUG_MESSAGE_LENGTH];
|
||||
CHAR8 AsciiBuffer[MAX_DEBUG_MESSAGE_LENGTH];
|
||||
|
||||
//
|
||||
// If Format is NULL, then ASSERT().
|
||||
@@ -92,7 +90,7 @@ DebugPrintMarker (
|
||||
//
|
||||
// Check driver debug mask value and global mask
|
||||
//
|
||||
if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) {
|
||||
if ((ErrorLevel & PcdGet32 (PcdDebugPrintErrorLevel)) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -108,7 +106,6 @@ DebugPrintMarker (
|
||||
SemihostWriteString (AsciiBuffer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Prints a debug message to the debug output device if the specified
|
||||
error level is enabled.
|
||||
@@ -127,15 +124,14 @@ DebugPrintMarker (
|
||||
VOID
|
||||
EFIAPI
|
||||
DebugVPrint (
|
||||
IN UINTN ErrorLevel,
|
||||
IN CONST CHAR8 *Format,
|
||||
IN VA_LIST VaListMarker
|
||||
IN UINTN ErrorLevel,
|
||||
IN CONST CHAR8 *Format,
|
||||
IN VA_LIST VaListMarker
|
||||
)
|
||||
{
|
||||
DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Prints a debug message to the debug output device if the specified
|
||||
error level is enabled.
|
||||
@@ -156,15 +152,14 @@ DebugVPrint (
|
||||
VOID
|
||||
EFIAPI
|
||||
DebugBPrint (
|
||||
IN UINTN ErrorLevel,
|
||||
IN CONST CHAR8 *Format,
|
||||
IN BASE_LIST BaseListMarker
|
||||
IN UINTN ErrorLevel,
|
||||
IN CONST CHAR8 *Format,
|
||||
IN BASE_LIST BaseListMarker
|
||||
)
|
||||
{
|
||||
DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Prints an assert message containing a filename, line number, and description.
|
||||
@@ -196,7 +191,7 @@ DebugAssert (
|
||||
IN CONST CHAR8 *Description
|
||||
)
|
||||
{
|
||||
CHAR8 AsciiBuffer[MAX_DEBUG_MESSAGE_LENGTH];
|
||||
CHAR8 AsciiBuffer[MAX_DEBUG_MESSAGE_LENGTH];
|
||||
|
||||
//
|
||||
// Generate the ASSERT() message in Unicode format
|
||||
@@ -208,14 +203,13 @@ DebugAssert (
|
||||
//
|
||||
// Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
|
||||
//
|
||||
if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
|
||||
if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
|
||||
CpuBreakpoint ();
|
||||
} else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
|
||||
} else if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
|
||||
@@ -248,10 +242,9 @@ DebugClearMemory (
|
||||
//
|
||||
// SetMem() checks for the ASSERT() condition on Length and returns Buffer
|
||||
//
|
||||
return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue));
|
||||
return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns TRUE if ASSERT() macros are enabled.
|
||||
@@ -269,10 +262,9 @@ DebugAssertEnabled (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
|
||||
return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns TRUE if DEBUG()macros are enabled.
|
||||
@@ -290,10 +282,9 @@ DebugPrintEnabled (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
|
||||
return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns TRUE if DEBUG_CODE()macros are enabled.
|
||||
@@ -311,10 +302,9 @@ DebugCodeEnabled (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
|
||||
return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled.
|
||||
@@ -332,5 +322,5 @@ DebugClearMemoryEnabled (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
|
||||
return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#include <Library/SemihostLib.h>
|
||||
#include <Library/SerialPortLib.h>
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Programmed hardware of Serial port.
|
||||
@@ -51,55 +50,50 @@ SerialPortInitialize (
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortWrite (
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
UINT8 PrintBuffer[PRINT_BUFFER_SIZE];
|
||||
UINTN SourceIndex;
|
||||
UINTN DestinationIndex;
|
||||
UINT8 CurrentCharacter;
|
||||
UINT8 PrintBuffer[PRINT_BUFFER_SIZE];
|
||||
UINTN SourceIndex;
|
||||
UINTN DestinationIndex;
|
||||
UINT8 CurrentCharacter;
|
||||
|
||||
SourceIndex = 0;
|
||||
DestinationIndex = 0;
|
||||
|
||||
while (SourceIndex < NumberOfBytes)
|
||||
{
|
||||
CurrentCharacter = Buffer[SourceIndex++];
|
||||
while (SourceIndex < NumberOfBytes) {
|
||||
CurrentCharacter = Buffer[SourceIndex++];
|
||||
|
||||
switch (CurrentCharacter)
|
||||
{
|
||||
switch (CurrentCharacter) {
|
||||
case '\r':
|
||||
continue;
|
||||
continue;
|
||||
|
||||
case '\n':
|
||||
PrintBuffer[DestinationIndex++] = ' ';
|
||||
// fall through
|
||||
PrintBuffer[DestinationIndex++] = ' ';
|
||||
// fall through
|
||||
|
||||
default:
|
||||
PrintBuffer[DestinationIndex++] = CurrentCharacter;
|
||||
break;
|
||||
}
|
||||
PrintBuffer[DestinationIndex++] = CurrentCharacter;
|
||||
break;
|
||||
}
|
||||
|
||||
if (DestinationIndex > PRINT_BUFFER_THRESHOLD)
|
||||
{
|
||||
PrintBuffer[DestinationIndex] = '\0';
|
||||
SemihostWriteString ((CHAR8 *) PrintBuffer);
|
||||
if (DestinationIndex > PRINT_BUFFER_THRESHOLD) {
|
||||
PrintBuffer[DestinationIndex] = '\0';
|
||||
SemihostWriteString ((CHAR8 *)PrintBuffer);
|
||||
|
||||
DestinationIndex = 0;
|
||||
}
|
||||
DestinationIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (DestinationIndex > 0)
|
||||
{
|
||||
PrintBuffer[DestinationIndex] = '\0';
|
||||
SemihostWriteString ((CHAR8 *) PrintBuffer);
|
||||
if (DestinationIndex > 0) {
|
||||
PrintBuffer[DestinationIndex] = '\0';
|
||||
SemihostWriteString ((CHAR8 *)PrintBuffer);
|
||||
}
|
||||
|
||||
return NumberOfBytes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read data from serial device and save the datas in buffer.
|
||||
|
||||
@@ -113,16 +107,14 @@ SerialPortWrite (
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortRead (
|
||||
OUT UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
OUT UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
*Buffer = SemihostReadCharacter ();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Check to see if any data is available to be read from the debug device.
|
||||
|
||||
@@ -139,4 +131,3 @@ SerialPortPoll (
|
||||
// Since SemiHosting read character is blocking always say we have a char ready?
|
||||
return SemihostConnectionSupported ();
|
||||
}
|
||||
|
||||
|
@@ -23,9 +23,9 @@ SemihostConnectionSupported (
|
||||
|
||||
RETURN_STATUS
|
||||
SemihostFileOpen (
|
||||
IN CHAR8 *FileName,
|
||||
IN UINT32 Mode,
|
||||
OUT UINTN *FileHandle
|
||||
IN CHAR8 *FileName,
|
||||
IN UINT32 Mode,
|
||||
OUT UINTN *FileHandle
|
||||
)
|
||||
{
|
||||
SEMIHOST_FILE_OPEN_BLOCK OpenBlock;
|
||||
@@ -40,9 +40,9 @@ SemihostFileOpen (
|
||||
FileName++;
|
||||
}
|
||||
|
||||
OpenBlock.FileName = FileName;
|
||||
OpenBlock.Mode = Mode;
|
||||
OpenBlock.NameLength = AsciiStrLen(FileName);
|
||||
OpenBlock.FileName = FileName;
|
||||
OpenBlock.Mode = Mode;
|
||||
OpenBlock.NameLength = AsciiStrLen (FileName);
|
||||
|
||||
Result = SEMIHOST_SYS_OPEN (&OpenBlock);
|
||||
|
||||
@@ -124,10 +124,11 @@ SemihostFileWrite (
|
||||
|
||||
*Length = SEMIHOST_SYS_WRITE (&WriteBlock);
|
||||
|
||||
if (*Length != 0)
|
||||
if (*Length != 0) {
|
||||
return RETURN_ABORTED;
|
||||
else
|
||||
} else {
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_STATUS
|
||||
@@ -148,7 +149,7 @@ SemihostFileLength (
|
||||
OUT UINTN *Length
|
||||
)
|
||||
{
|
||||
INT32 Result;
|
||||
INT32 Result;
|
||||
|
||||
if (Length == NULL) {
|
||||
return RETURN_INVALID_PARAMETER;
|
||||
@@ -178,7 +179,7 @@ SemihostFileLength (
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
SemihostFileTmpName(
|
||||
SemihostFileTmpName (
|
||||
OUT VOID *Buffer,
|
||||
IN UINT8 Identifier,
|
||||
IN UINTN Length
|
||||
@@ -198,15 +199,15 @@ SemihostFileTmpName(
|
||||
Result = SEMIHOST_SYS_TMPNAME (&TmpNameBlock);
|
||||
|
||||
if (Result != 0) {
|
||||
return RETURN_ABORTED;
|
||||
return RETURN_ABORTED;
|
||||
} else {
|
||||
return RETURN_SUCCESS;
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_STATUS
|
||||
SemihostFileRemove (
|
||||
IN CHAR8 *FileName
|
||||
IN CHAR8 *FileName
|
||||
)
|
||||
{
|
||||
SEMIHOST_FILE_REMOVE_BLOCK RemoveBlock;
|
||||
@@ -217,8 +218,8 @@ SemihostFileRemove (
|
||||
FileName++;
|
||||
}
|
||||
|
||||
RemoveBlock.FileName = FileName;
|
||||
RemoveBlock.NameLength = AsciiStrLen(FileName);
|
||||
RemoveBlock.FileName = FileName;
|
||||
RemoveBlock.NameLength = AsciiStrLen (FileName);
|
||||
|
||||
Result = SEMIHOST_SYS_REMOVE (&RemoveBlock);
|
||||
|
||||
@@ -241,7 +242,7 @@ SemihostFileRemove (
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
SemihostFileRename(
|
||||
SemihostFileRename (
|
||||
IN CHAR8 *FileName,
|
||||
IN CHAR8 *NewFileName
|
||||
)
|
||||
@@ -261,9 +262,9 @@ SemihostFileRename(
|
||||
Result = SEMIHOST_SYS_RENAME (&RenameBlock);
|
||||
|
||||
if (Result != 0) {
|
||||
return RETURN_ABORTED;
|
||||
return RETURN_ABORTED;
|
||||
} else {
|
||||
return RETURN_SUCCESS;
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +278,7 @@ SemihostReadCharacter (
|
||||
|
||||
VOID
|
||||
SemihostWriteCharacter (
|
||||
IN CHAR8 Character
|
||||
IN CHAR8 Character
|
||||
)
|
||||
{
|
||||
SEMIHOST_SYS_WRITEC (&Character);
|
||||
@@ -285,7 +286,7 @@ SemihostWriteCharacter (
|
||||
|
||||
VOID
|
||||
SemihostWriteString (
|
||||
IN CHAR8 *String
|
||||
IN CHAR8 *String
|
||||
)
|
||||
{
|
||||
SEMIHOST_SYS_WRITE0 (String);
|
||||
@@ -293,13 +294,13 @@ SemihostWriteString (
|
||||
|
||||
UINT32
|
||||
SemihostSystem (
|
||||
IN CHAR8 *CommandLine
|
||||
IN CHAR8 *CommandLine
|
||||
)
|
||||
{
|
||||
SEMIHOST_SYSTEM_BLOCK SystemBlock;
|
||||
SEMIHOST_SYSTEM_BLOCK SystemBlock;
|
||||
|
||||
SystemBlock.CommandLine = CommandLine;
|
||||
SystemBlock.CommandLength = AsciiStrLen(CommandLine);
|
||||
SystemBlock.CommandLength = AsciiStrLen (CommandLine);
|
||||
|
||||
return SEMIHOST_SYS_SYSTEM (&SystemBlock);
|
||||
}
|
||||
|
@@ -11,14 +11,14 @@
|
||||
#define SEMIHOST_PRIVATE_H_
|
||||
|
||||
typedef struct {
|
||||
CHAR8 *FileName;
|
||||
CHAR8 *FileName;
|
||||
UINTN Mode;
|
||||
UINTN NameLength;
|
||||
} SEMIHOST_FILE_OPEN_BLOCK;
|
||||
|
||||
typedef struct {
|
||||
UINTN Handle;
|
||||
VOID *Buffer;
|
||||
VOID *Buffer;
|
||||
UINTN Length;
|
||||
} SEMIHOST_FILE_READ_WRITE_BLOCK;
|
||||
|
||||
@@ -28,127 +28,127 @@ typedef struct {
|
||||
} SEMIHOST_FILE_SEEK_BLOCK;
|
||||
|
||||
typedef struct {
|
||||
VOID *Buffer;
|
||||
VOID *Buffer;
|
||||
UINTN Identifier;
|
||||
UINTN Length;
|
||||
} SEMIHOST_FILE_TMPNAME_BLOCK;
|
||||
|
||||
typedef struct {
|
||||
CHAR8 *FileName;
|
||||
CHAR8 *FileName;
|
||||
UINTN NameLength;
|
||||
} SEMIHOST_FILE_REMOVE_BLOCK;
|
||||
|
||||
typedef struct {
|
||||
CHAR8 *FileName;
|
||||
CHAR8 *FileName;
|
||||
UINTN FileNameLength;
|
||||
CHAR8 *NewFileName;
|
||||
CHAR8 *NewFileName;
|
||||
UINTN NewFileNameLength;
|
||||
} SEMIHOST_FILE_RENAME_BLOCK;
|
||||
|
||||
typedef struct {
|
||||
CHAR8 *CommandLine;
|
||||
CHAR8 *CommandLine;
|
||||
UINTN CommandLength;
|
||||
} SEMIHOST_SYSTEM_BLOCK;
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
#if defined (__CC_ARM)
|
||||
|
||||
#if defined(__thumb__)
|
||||
#define SWI 0xAB
|
||||
#else
|
||||
#define SWI 0x123456
|
||||
#endif
|
||||
#if defined (__thumb__)
|
||||
#define SWI 0xAB
|
||||
#else
|
||||
#define SWI 0x123456
|
||||
#endif
|
||||
|
||||
#define SEMIHOST_SUPPORTED TRUE
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
INT32
|
||||
_Semihost_SYS_OPEN(
|
||||
IN UINTN SWI_0x01,
|
||||
IN SEMIHOST_FILE_OPEN_BLOCK *OpenBlock
|
||||
_Semihost_SYS_OPEN (
|
||||
IN UINTN SWI_0x01,
|
||||
IN SEMIHOST_FILE_OPEN_BLOCK *OpenBlock
|
||||
);
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
INT32
|
||||
_Semihost_SYS_CLOSE(
|
||||
IN UINTN SWI_0x02,
|
||||
IN UINT32 *Handle
|
||||
_Semihost_SYS_CLOSE (
|
||||
IN UINTN SWI_0x02,
|
||||
IN UINT32 *Handle
|
||||
);
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
VOID
|
||||
_Semihost_SYS_WRITEC(
|
||||
IN UINTN SWI_0x03,
|
||||
IN CHAR8 *Character
|
||||
_Semihost_SYS_WRITEC (
|
||||
IN UINTN SWI_0x03,
|
||||
IN CHAR8 *Character
|
||||
);
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
VOID
|
||||
_Semihost_SYS_WRITE0(
|
||||
IN UINTN SWI_0x04,
|
||||
IN CHAR8 *String
|
||||
_Semihost_SYS_WRITE0 (
|
||||
IN UINTN SWI_0x04,
|
||||
IN CHAR8 *String
|
||||
);
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
UINT32
|
||||
_Semihost_SYS_WRITE(
|
||||
IN UINTN SWI_0x05,
|
||||
IN OUT SEMIHOST_FILE_READ_WRITE_BLOCK *WriteBlock
|
||||
_Semihost_SYS_WRITE (
|
||||
IN UINTN SWI_0x05,
|
||||
IN OUT SEMIHOST_FILE_READ_WRITE_BLOCK *WriteBlock
|
||||
);
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
UINT32
|
||||
_Semihost_SYS_READ(
|
||||
IN UINTN SWI_0x06,
|
||||
IN OUT SEMIHOST_FILE_READ_WRITE_BLOCK *ReadBlock
|
||||
_Semihost_SYS_READ (
|
||||
IN UINTN SWI_0x06,
|
||||
IN OUT SEMIHOST_FILE_READ_WRITE_BLOCK *ReadBlock
|
||||
);
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
CHAR8
|
||||
_Semihost_SYS_READC(
|
||||
IN UINTN SWI_0x07,
|
||||
IN UINTN Zero
|
||||
_Semihost_SYS_READC (
|
||||
IN UINTN SWI_0x07,
|
||||
IN UINTN Zero
|
||||
);
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
INT32
|
||||
_Semihost_SYS_SEEK(
|
||||
IN UINTN SWI_0x0A,
|
||||
IN SEMIHOST_FILE_SEEK_BLOCK *SeekBlock
|
||||
_Semihost_SYS_SEEK (
|
||||
IN UINTN SWI_0x0A,
|
||||
IN SEMIHOST_FILE_SEEK_BLOCK *SeekBlock
|
||||
);
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
INT32
|
||||
_Semihost_SYS_FLEN(
|
||||
IN UINTN SWI_0x0C,
|
||||
IN UINT32 *Handle
|
||||
_Semihost_SYS_FLEN (
|
||||
IN UINTN SWI_0x0C,
|
||||
IN UINT32 *Handle
|
||||
);
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
UINT32
|
||||
_Semihost_SYS_TMPNAME(
|
||||
IN UINTN SWI_0x0D,
|
||||
IN SEMIHOST_FILE_TMPNAME_BLOCK *TmpNameBlock
|
||||
_Semihost_SYS_TMPNAME (
|
||||
IN UINTN SWI_0x0D,
|
||||
IN SEMIHOST_FILE_TMPNAME_BLOCK *TmpNameBlock
|
||||
);
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
UINT32
|
||||
_Semihost_SYS_REMOVE(
|
||||
IN UINTN SWI_0x0E,
|
||||
IN SEMIHOST_FILE_REMOVE_BLOCK *RemoveBlock
|
||||
_Semihost_SYS_REMOVE (
|
||||
IN UINTN SWI_0x0E,
|
||||
IN SEMIHOST_FILE_REMOVE_BLOCK *RemoveBlock
|
||||
);
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
UINT32
|
||||
_Semihost_SYS_RENAME(
|
||||
IN UINTN SWI_0x0F,
|
||||
IN SEMIHOST_FILE_RENAME_BLOCK *RenameBlock
|
||||
_Semihost_SYS_RENAME (
|
||||
IN UINTN SWI_0x0F,
|
||||
IN SEMIHOST_FILE_RENAME_BLOCK *RenameBlock
|
||||
);
|
||||
|
||||
__swi(SWI)
|
||||
__swi (SWI)
|
||||
UINT32
|
||||
_Semihost_SYS_SYSTEM(
|
||||
IN UINTN SWI_0x12,
|
||||
IN SEMIHOST_SYSTEM_BLOCK *SystemBlock
|
||||
_Semihost_SYS_SYSTEM (
|
||||
IN UINTN SWI_0x12,
|
||||
IN SEMIHOST_SYSTEM_BLOCK *SystemBlock
|
||||
);
|
||||
|
||||
#define SEMIHOST_SYS_OPEN(OpenBlock) _Semihost_SYS_OPEN(0x01, OpenBlock)
|
||||
@@ -165,14 +165,14 @@ _Semihost_SYS_SYSTEM(
|
||||
#define SEMIHOST_SYS_RENAME(RenameBlock) _Semihost_SYS_RENAME(0x0F, RenameBlock)
|
||||
#define SEMIHOST_SYS_SYSTEM(SystemBlock) _Semihost_SYS_SYSTEM(0x12, SystemBlock)
|
||||
|
||||
#elif defined(__GNUC__) // __CC_ARM
|
||||
#elif defined (__GNUC__) // __CC_ARM
|
||||
|
||||
#define SEMIHOST_SUPPORTED TRUE
|
||||
|
||||
UINT32
|
||||
GccSemihostCall (
|
||||
IN UINT32 Operation,
|
||||
IN UINTN SystemBlockAddress
|
||||
IN UINT32 Operation,
|
||||
IN UINTN SystemBlockAddress
|
||||
); // __attribute__ ((interrupt ("SVC")));
|
||||
|
||||
#define SEMIHOST_SYS_OPEN(OpenBlock) GccSemihostCall(0x01, (UINTN)(OpenBlock))
|
||||
@@ -193,8 +193,8 @@ GccSemihostCall (
|
||||
|
||||
#define SEMIHOST_SUPPORTED FALSE
|
||||
|
||||
#define SEMIHOST_SYS_OPEN(OpenBlock) (-1)
|
||||
#define SEMIHOST_SYS_CLOSE(Handle) (-1)
|
||||
#define SEMIHOST_SYS_OPEN(OpenBlock) (-1)
|
||||
#define SEMIHOST_SYS_CLOSE(Handle) (-1)
|
||||
#define SEMIHOST_SYS_WRITE0(String)
|
||||
#define SEMIHOST_SYS_WRITEC(Character)
|
||||
#define SEMIHOST_SYS_WRITE(WriteBlock) (0)
|
||||
|
@@ -45,8 +45,8 @@
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
SendMemoryPermissionRequest (
|
||||
IN OUT ARM_SVC_ARGS *SvcArgs,
|
||||
OUT INT32 *RetVal
|
||||
IN OUT ARM_SVC_ARGS *SvcArgs,
|
||||
OUT INT32 *RetVal
|
||||
)
|
||||
{
|
||||
if ((SvcArgs == NULL) || (RetVal == NULL)) {
|
||||
@@ -148,8 +148,8 @@ SendMemoryPermissionRequest (
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
GetMemoryPermissions (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
OUT UINT32 *MemoryAttributes
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
OUT UINT32 *MemoryAttributes
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -207,9 +207,9 @@ GetMemoryPermissions (
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
RequestMemoryPermissionChange (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT32 Permissions
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT32 Permissions
|
||||
)
|
||||
{
|
||||
INT32 Ret;
|
||||
@@ -239,13 +239,13 @@ RequestMemoryPermissionChange (
|
||||
|
||||
EFI_STATUS
|
||||
ArmSetMemoryRegionNoExec (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 MemoryAttributes;
|
||||
UINT32 CodePermission;
|
||||
EFI_STATUS Status;
|
||||
UINT32 MemoryAttributes;
|
||||
UINT32 CodePermission;
|
||||
|
||||
Status = GetMemoryPermissions (BaseAddress, &MemoryAttributes);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
@@ -256,18 +256,19 @@ ArmSetMemoryRegionNoExec (
|
||||
MemoryAttributes | CodePermission
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmClearMemoryRegionNoExec (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 MemoryAttributes;
|
||||
UINT32 CodePermission;
|
||||
EFI_STATUS Status;
|
||||
UINT32 MemoryAttributes;
|
||||
UINT32 CodePermission;
|
||||
|
||||
Status = GetMemoryPermissions (BaseAddress, &MemoryAttributes);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
@@ -278,18 +279,19 @@ ArmClearMemoryRegionNoExec (
|
||||
MemoryAttributes & ~CodePermission
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmSetMemoryRegionReadOnly (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 MemoryAttributes;
|
||||
UINT32 DataPermission;
|
||||
EFI_STATUS Status;
|
||||
UINT32 MemoryAttributes;
|
||||
UINT32 DataPermission;
|
||||
|
||||
Status = GetMemoryPermissions (BaseAddress, &MemoryAttributes);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
@@ -300,28 +302,32 @@ ArmSetMemoryRegionReadOnly (
|
||||
MemoryAttributes | DataPermission
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmClearMemoryRegionReadOnly (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 MemoryAttributes;
|
||||
UINT32 PermissionRequest;
|
||||
EFI_STATUS Status;
|
||||
UINT32 MemoryAttributes;
|
||||
UINT32 PermissionRequest;
|
||||
|
||||
Status = GetMemoryPermissions (BaseAddress, &MemoryAttributes);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
PermissionRequest = SET_MEM_ATTR_MAKE_PERM_REQUEST (SET_MEM_ATTR_DATA_PERM_RW,
|
||||
MemoryAttributes);
|
||||
PermissionRequest = SET_MEM_ATTR_MAKE_PERM_REQUEST (
|
||||
SET_MEM_ATTR_DATA_PERM_RW,
|
||||
MemoryAttributes
|
||||
);
|
||||
return RequestMemoryPermissionChange (
|
||||
BaseAddress,
|
||||
Length,
|
||||
PermissionRequest
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
Reference in New Issue
Block a user