PatchworkOS
Loading...
Searching...
No Matches
Exceptions

Exception handling. More...

Macros

#define AML_EXCEPTION_RAISE(state, code)   aml_exception_raise(state, code, __func__)
 Macro to raise an AML exception with the current function name.
 

Typedefs

typedef void(* aml_exception_handler_t) (aml_state_t *state, aml_exception_t code)
 AML exception handler function type.
 

Enumerations

enum  aml_exception_t {
  AML_ERROR = 0x3001 ,
  AML_PARSE = 0x3002 ,
  AML_BAD_OPCODE = 0x3003 ,
  AML_NO_OPERAND = 0x3004 ,
  AML_OPERAND_TYPE = 0x3005 ,
  AML_OPERAND_VALUE = 0x3006 ,
  AML_UNINITIALIZED_LOCAL = 0x3007 ,
  AML_UNINITIALIZED_ARG = 0x3008 ,
  AML_UNINITIALIZED_ELEMENT = 0x3009 ,
  AML_NUMERIC_OVERFLOW = 0x300A ,
  AML_REGION_LIMIT = 0x300B ,
  AML_BUFFER_LIMIT = 0x300C ,
  AML_PACKAGE_LIMIT = 0x300D ,
  AML_DIVIDE_BY_ZERO = 0x300E ,
  AML_BAD_NAME = 0x300F ,
  AML_NAME_NOT_FOUND = 0x3010 ,
  AML_INTERNAL = 0x3011 ,
  AML_INVALID_SPACE_ID = 0x3012 ,
  AML_STRING_LIMIT = 0x3013 ,
  AML_NO_RETURN_VALUE = 0x3014 ,
  AML_METHOD_LIMIT = 0x3015 ,
  AML_NOT_OWNER = 0x3016 ,
  AML_MUTEX_ORDER = 0x3017 ,
  AML_MUTEX_NOT_ACQUIRED = 0x3018 ,
  AML_INVALID_RESOURCE_TYPE = 0x3019 ,
  AML_INVALID_INDEX = 0x301A ,
  AML_REGISTER_LIMIT = 0x301B ,
  AML_NO_WHILE = 0x301C ,
  AML_ALIGNMENT = 0x301D ,
  AML_NO_RESOURCE_END_TAG = 0x301E ,
  AML_BAD_RESOURCE_VALUE = 0x301F ,
  AML_CIRCULAR_REFERENCE = 0x3020
}
 AML exception codes. More...
 

Functions

const char * aml_exception_to_string (aml_exception_t code)
 Converts an AML exception code to a string.
 
uint64_t aml_exception_register (aml_exception_handler_t handler)
 Registers an AML exception handler.
 
void aml_exception_unregister (aml_exception_handler_t handler)
 Unregisters an AML exception handler.
 
void aml_exception_raise (aml_state_t *state, aml_exception_t code, const char *function)
 Raises an AML exception.
 

Detailed Description

Exception handling.

When a non-fatal error occurs during AML execution an exception is raised, this module implements the exception handling mechanism.

Macro Definition Documentation

◆ AML_EXCEPTION_RAISE

#define AML_EXCEPTION_RAISE (   state,
  code 
)    aml_exception_raise(state, code, __func__)

Macro to raise an AML exception with the current function name.

Parameters
stateThe AML state in which the exception occurred.
codeThe exception code to raise.

Definition at line 113 of file exception.h.

Typedef Documentation

◆ aml_exception_handler_t

aml_exception_handler_t

AML exception handler function type.

Definition at line 68 of file exception.h.

Enumeration Type Documentation

◆ aml_exception_t

AML exception codes.

These values are taken from ACPICA (lib/acpica/tests/aslts/src/runtime/cntl/ehandle.asl) for compatibility with their runtime test suite. Otherwise they could be any values.

TODO: Implement handling and checking for all of these.

Enumerator
AML_ERROR 
AML_PARSE 
AML_BAD_OPCODE 
AML_NO_OPERAND 
AML_OPERAND_TYPE 
AML_OPERAND_VALUE 
AML_UNINITIALIZED_LOCAL 
AML_UNINITIALIZED_ARG 
AML_UNINITIALIZED_ELEMENT 
AML_NUMERIC_OVERFLOW 
AML_REGION_LIMIT 
AML_BUFFER_LIMIT 
AML_PACKAGE_LIMIT 
AML_DIVIDE_BY_ZERO 
AML_BAD_NAME 
AML_NAME_NOT_FOUND 
AML_INTERNAL 
AML_INVALID_SPACE_ID 
AML_STRING_LIMIT 
AML_NO_RETURN_VALUE 
AML_METHOD_LIMIT 
AML_NOT_OWNER 
AML_MUTEX_ORDER 
AML_MUTEX_NOT_ACQUIRED 
AML_INVALID_RESOURCE_TYPE 
AML_INVALID_INDEX 
AML_REGISTER_LIMIT 
AML_NO_WHILE 
AML_ALIGNMENT 
AML_NO_RESOURCE_END_TAG 
AML_BAD_RESOURCE_VALUE 
AML_CIRCULAR_REFERENCE 

Definition at line 28 of file exception.h.

Function Documentation

◆ aml_exception_raise()

void aml_exception_raise ( aml_state_t state,
aml_exception_t  code,
const char *  function 
)

Raises an AML exception.

Parameters
stateThe AML state in which the exception occurred.
codeThe exception code to raise.
functionThe name of the function raising the exception, used for logging.

Definition at line 133 of file exception.c.

References aml_exception_to_string(), handlerCount, handlers, and LOG_WARN.

◆ aml_exception_register()

uint64_t aml_exception_register ( aml_exception_handler_t  handler)

Registers an AML exception handler.

The handler will be called whenever an AML exception is raised.

Does not allow duplicates.

Parameters
handlerThe handler to register.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 66 of file exception.c.

References EEXIST, ERR, errno, free(), handlerCount, handlers, malloc(), and NULL.

◆ aml_exception_to_string()

const char * aml_exception_to_string ( aml_exception_t  code)

Converts an AML exception code to a string.

Parameters
codeThe exception code to convert.
Returns
The string representation of the exception code, or "AE_AML_UNKNOWN_EXCEPTION" if the code is not recognized.

Definition at line 54 of file exception.c.

References exceptionTable, and aml_exception_info_t::name.

Referenced by aml_exception_raise().

◆ aml_exception_unregister()

void aml_exception_unregister ( aml_exception_handler_t  handler)

Unregisters an AML exception handler.

Parameters
handlerThe handler to unregister.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 99 of file exception.c.

References free(), handlerCount, handlers, memmove(), and NULL.