From 65e27445877ff101115c79e76928d91bf7625876 Mon Sep 17 00:00:00 2001 From: andrewfish Date: Tue, 16 Feb 2010 23:45:42 +0000 Subject: [PATCH] Fix bug in UncachedMemoryAllocationLib, Assembler, make DefaultExceptionHandler lib inc the PC past the faulting instruction to aid debug. Update LR in Exception hanlder, so return address can get updated properly. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10018 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPkg/Drivers/CpuDxe/ExceptionSupport.ARMv6.asm | 1 + ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c | 7 +++---- .../DefaultExceptionHandlerLib/DefaultExceptionHandler.c | 7 +++++-- .../UncachedMemoryAllocationLib.c | 2 +- .../UncachedMemoryAllocationLib.inf | 4 +++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ArmPkg/Drivers/CpuDxe/ExceptionSupport.ARMv6.asm b/ArmPkg/Drivers/CpuDxe/ExceptionSupport.ARMv6.asm index 7411762c72..6e960133b1 100755 --- a/ArmPkg/Drivers/CpuDxe/ExceptionSupport.ARMv6.asm +++ b/ArmPkg/Drivers/CpuDxe/ExceptionSupport.ARMv6.asm @@ -229,6 +229,7 @@ AsmCommonExceptionEntry tst r1, #0x20 ; if ((CPSR & T)) == T) { // Thumb Mode on entry addne R5, R5, #2 ; PC += 2; + str R5,[SP,#0x58] ; Update LR value pused by srsfd NoAdjustNeeded diff --git a/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c b/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c index 8b3132cc99..d46a4fa2c3 100644 --- a/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c +++ b/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c @@ -339,7 +339,7 @@ THUMB_INSTRUCTIONS gOpThumb2[] = { { "LDR", 0xf8500800, 0xfff00800, LDM_REG_IMM8 }, // LDR , [, {, #]} { "LDRBT", 0xf8100e00, 0xfff00f00, LDM_REG_IMM8 }, // LDRBT , [, {, #]} { "LDRHT", 0xf8300e00, 0xfff00f00, LDM_REG_IMM8 }, // LDRHT , [, {, #]} - { "LDRSB", 0xf9900800, 0xfff00800, LDM_REG_IMM8 }, // LDRHT , [, {, #]} {!} form? + { "LDRSB", 0xf9100800, 0xfff00800, LDM_REG_IMM8 }, // LDRHT , [, {, #]} {!} form? { "LDRSBT",0xf9100e00, 0xfff00f00, LDM_REG_IMM8 }, // LDRHBT , [, {, #]} {!} form? { "LDRSH" ,0xf9300800, 0xfff00800, LDM_REG_IMM8 }, // LDRSH , [, {, #]} { "LDRSHT",0xf9300e00, 0xfff00f00, LDM_REG_IMM8 }, // LDRSHT , [, {, #]} @@ -791,7 +791,6 @@ DisassembleThumbInstruction ( return; case LDM_REG_IMM8: - ASSERT (FALSE); // , [, {, #}]{!} W = (OpCode32 & BIT8) == BIT8; U = (OpCode32 & BIT9) == BIT9; @@ -801,10 +800,10 @@ DisassembleThumbInstruction ( if ((OpCode32 && 0xff) == 0) { AsciiSPrint (&Buf[Offset], Size - Offset, "]%a", W?"!":""); } else { - AsciiSPrint (&Buf[Offset], Size - Offset, ", #%a0x%x]%a", OpCode32 & 0xff, U?"":"-" , W?"!":""); + AsciiSPrint (&Buf[Offset], Size - Offset, ", #%a0x%x]%a", U?"":"-" , OpCode32 & 0xff, W?"!":""); } } else { - AsciiSPrint (&Buf[Offset], Size - Offset, "], #%a0x%x]", OpCode32 & 0xff, U?"":"-"); + AsciiSPrint (&Buf[Offset], Size - Offset, "], #%a0x%x", U?"":"-", OpCode32 & 0xff); } return; diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandler.c index e146ac0c4a..927a66b915 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandler.c @@ -224,6 +224,7 @@ DefaultExceptionHandler ( ) { UINT32 DfsrStatus; + UINT32 IfsrStatus; BOOLEAN DfsrWrite; UINT32 PcAdjust = 0; @@ -289,8 +290,10 @@ DefaultExceptionHandler ( if (DfsrStatus != 0x00) { DEBUG ((EFI_D_ERROR, " %a: %a 0x%08x\n", FaultStatusToString (DfsrStatus), DfsrWrite ? "write to" : "read from", SystemContext.SystemContextArm->DFAR)); } - if ((SystemContext.SystemContextArm->IFSR & 0xf) != 0x00) { - DEBUG ((EFI_D_ERROR, "Instruction %a at 0x%08x, \n", FaultStatusToString (SystemContext.SystemContextArm->IFSR & 0xf), SystemContext.SystemContextArm->IFAR)); + + IfsrStatus = (SystemContext.SystemContextArm->IFSR & 0xf) | ((SystemContext.SystemContextArm->IFSR >> 6) & 0x10); + if (IfsrStatus != 0) { + DEBUG ((EFI_D_ERROR, " Instruction %a at 0x%08x\n", FaultStatusToString (SystemContext.SystemContextArm->IFSR & 0xf), SystemContext.SystemContextArm->IFAR)); } DEBUG ((EFI_D_ERROR, "\n")); diff --git a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c index fa683e19ed..bf1497daf0 100644 --- a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c +++ b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c @@ -609,7 +609,7 @@ UncachedSafeFreePool ( **/ EFI_STATUS EFIAPI -DebugUncachedMemoryAllocationLibConstructor ( +UncachedMemoryAllocationLibConstructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) diff --git a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf index 87ff18ce37..8b596377bd 100644 --- a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf +++ b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf @@ -20,6 +20,7 @@ MODULE_TYPE = DXE_DRIVER VERSION_STRING = 1.0 LIBRARY_CLASS = UncachedMemoryAllocationLib + CONSTRUCTOR = UncachedMemoryAllocationLibConstructor [Sources.common] UncachedMemoryAllocationLib.c @@ -37,4 +38,5 @@ MemoryAllocationLib DxeServicesTableLib - \ No newline at end of file +[Depex] + gEfiCpuArchProtocolGuid \ No newline at end of file