TianoCore EDK2 master
Loading...
Searching...
No Matches
DefaultExceptionHandler.c File Reference

Go to the source code of this file.

Data Structures

struct  CPSR_CHAR
 

Macros

#define MAX_PRINT_CHARS   100
 
#define CPSR_STRING_SIZE   32
 

Functions

CHAR8 * GetImageName (IN UINTN FaultAddress, OUT UINTN *ImageBase, OUT UINTN *PeCoffSizeOfHeaders)
 
VOID CpsrString (IN UINT32 Cpsr, OUT CHAR8 *ReturnStr)
 
CHAR8 * FaultStatusToString (IN UINT32 Status)
 
VOID DefaultExceptionHandler (IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
 

Variables

STATIC CONST CPSR_CHAR mCpsrChar []
 
STATIC CHAR8 * gExceptionTypeString []
 

Detailed Description

Default exception handler

Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
Copyright (c) 2012 - 2021, Arm Ltd. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file DefaultExceptionHandler.c.

Macro Definition Documentation

◆ CPSR_STRING_SIZE

#define CPSR_STRING_SIZE   32

Definition at line 36 of file DefaultExceptionHandler.c.

◆ MAX_PRINT_CHARS

#define MAX_PRINT_CHARS   100

Definition at line 30 of file DefaultExceptionHandler.c.

Function Documentation

◆ CpsrString()

VOID CpsrString ( IN UINT32  Cpsr,
OUT CHAR8 *  ReturnStr 
)

Convert the Current Program Status Register (CPSR) to a string. The string is a defacto standard in the ARM world.

It is possible to add extra bits by adding them to mCpsrChar array.

Parameters
CpsrARM CPSR register value
ReturnStrCPSR_STRING_SIZE byte string that contains string version of CPSR

Definition at line 76 of file DefaultExceptionHandler.c.

◆ DefaultExceptionHandler()

VOID DefaultExceptionHandler ( IN EFI_EXCEPTION_TYPE  ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT  SystemContext 
)

This is the default action to take on an unexpected exception

Since this is exception context don't do anything crazy like try to allocate memory.

Parameters
ExceptionTypeType of the exception
SystemContextRegister state at the time of the Exception

Definition at line 202 of file DefaultExceptionHandler.c.

◆ FaultStatusToString()

CHAR8 * FaultStatusToString ( IN UINT32  Status)

Definition at line 136 of file DefaultExceptionHandler.c.

◆ GetImageName()

CHAR8 * GetImageName ( IN UINTN  FaultAddress,
OUT UINTN ImageBase,
OUT UINTN PeCoffSizeOfHeaders 
)

Use the EFI Debug Image Table to lookup the FaultAddress and find which PE/COFF image it came from. As long as the PE/COFF image contains a debug directory entry a string can be returned. For ELF and Mach-O images the string points to the Mach-O or ELF image. Microsoft tools contain a pointer to the PDB file that contains the debug information.

Parameters
FaultAddressAddress to find PE/COFF image for.
ImageBaseReturn load address of found image
PeCoffSizeOfHeadersReturn the size of the PE/COFF header for the image that was found
Return values
NULLFaultAddress not in a loaded PE/COFF image.
Pathand file name of PE/COFF image.

Definition at line 30 of file DefaultExceptionHandlerUefi.c.

Variable Documentation

◆ gExceptionTypeString

STATIC CHAR8* gExceptionTypeString[]
Initial value:
= {
"Reset",
"Undefined OpCode",
"SVC",
"Prefetch Abort",
"Data Abort",
"Undefined",
"IRQ",
"FIQ"
}

Definition at line 180 of file DefaultExceptionHandler.c.

◆ mCpsrChar

STATIC CONST CPSR_CHAR mCpsrChar[]
Initial value:
= {
{ 31, 'n' },
{ 30, 'z' },
{ 29, 'c' },
{ 28, 'v' },
{ 9, 'e' },
{ 8, 'a' },
{ 7, 'i' },
{ 6, 'f' },
{ 5, 't' },
{ 0, '?' }
}

Definition at line 43 of file DefaultExceptionHandler.c.