[efi] Provide efi_tpl_name() for transcribing TPLs in debug messages

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-07-14 12:15:08 +01:00
parent 434462a93e
commit c01c3215dc
3 changed files with 30 additions and 28 deletions

View File

@@ -273,6 +273,8 @@ extern int efi_shutdown_in_progress;
extern const __attribute__ (( pure )) char *
efi_guid_ntoa ( CONST EFI_GUID *guid );
extern const __attribute__ (( pure )) char *
efi_tpl_name ( EFI_TPL tpl );
extern const __attribute__ (( pure )) char *
efi_locate_search_type_name ( EFI_LOCATE_SEARCH_TYPE search_type );
extern const __attribute__ (( pure )) char *
efi_open_attributes_name ( unsigned int attributes );

View File

@@ -46,6 +46,27 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *efidpt;
EFI_REQUEST_PROTOCOL ( EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, &efidpt );
/**
* Name EFI TPL
*
* @v tpl Task priority level
* @ret text Task priority level as text
*/
const __attribute__ (( pure )) char * efi_tpl_name ( EFI_TPL tpl ) {
static char buf[ 19 /* "0xXXXXXXXXXXXXXXXX" + NUL */ ];
switch ( tpl ) {
case TPL_APPLICATION: return "Application";
case TPL_CALLBACK: return "Callback";
case TPL_NOTIFY: return "Notify";
case TPL_HIGH_LEVEL: return "HighLevel";
default:
snprintf ( buf, sizeof ( buf ), "%#lx",
( unsigned long ) tpl );
return buf;
}
}
/**
* Name locate search type
*

View File

@@ -120,27 +120,6 @@ static const char * efi_boolean ( BOOLEAN boolean ) {
return ( boolean ? "TRUE" : "FALSE" );
}
/**
* Convert EFI TPL to text
*
* @v tpl Task priority level
* @ret text Task priority level as text
*/
static const char * efi_tpl ( EFI_TPL tpl ) {
static char buf[ 19 /* "0xXXXXXXXXXXXXXXXX" + NUL */ ];
switch ( tpl ) {
case TPL_APPLICATION: return "Application";
case TPL_CALLBACK: return "Callback";
case TPL_NOTIFY: return "Notify";
case TPL_HIGH_LEVEL: return "HighLevel";
default:
snprintf ( buf, sizeof ( buf ), "%#lx",
( unsigned long ) tpl );
return buf;
}
}
/**
* Convert EFI allocation type to text
*
@@ -281,9 +260,9 @@ efi_raise_tpl_wrapper ( EFI_TPL new_tpl ) {
void *retaddr = __builtin_return_address ( 0 );
EFI_TPL old_tpl;
DBGCP ( colour, "RaiseTPL ( %s ) ", efi_tpl ( new_tpl ) );
DBGCP ( colour, "RaiseTPL ( %s ) ", efi_tpl_name ( new_tpl ) );
old_tpl = bs->RaiseTPL ( new_tpl );
DBGCP ( colour, "= %s -> %p\n", efi_tpl ( old_tpl ), retaddr );
DBGCP ( colour, "= %s -> %p\n", efi_tpl_name ( old_tpl ), retaddr );
return old_tpl;
}
@@ -296,7 +275,7 @@ efi_restore_tpl_wrapper ( EFI_TPL old_tpl ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
void *retaddr = __builtin_return_address ( 0 );
DBGCP ( colour, "RestoreTPL ( %s ) ", efi_tpl ( old_tpl ) );
DBGCP ( colour, "RestoreTPL ( %s ) ", efi_tpl_name ( old_tpl ) );
bs->RestoreTPL ( old_tpl );
DBGCP ( colour, "-> %p\n", retaddr );
}
@@ -433,8 +412,8 @@ efi_create_event_wrapper ( UINT32 type, EFI_TPL notify_tpl,
void *retaddr = __builtin_return_address ( 0 );
EFI_STATUS efirc;
DBGC ( colour, "CreateEvent ( %#x, %s, %p, %p ) ",
type, efi_tpl ( notify_tpl ), notify_function, notify_context );
DBGC ( colour, "CreateEvent ( %#x, %s, %p, %p ) ", type,
efi_tpl_name ( notify_tpl ), notify_function, notify_context );
efirc = bs->CreateEvent ( type, notify_tpl, notify_function,
notify_context, event );
DBGC ( colour, "= %s ( %p ) -> %p\n",
@@ -1207,8 +1186,8 @@ efi_create_event_ex_wrapper ( UINT32 type, EFI_TPL notify_tpl,
EFI_STATUS efirc;
DBGC ( colour, "CreateEventEx ( %#x, %s, %p, %p, %s ) ",
type, efi_tpl ( notify_tpl ), notify_function, notify_context,
efi_guid_ntoa ( event_group ) );
type, efi_tpl_name ( notify_tpl ), notify_function,
notify_context, efi_guid_ntoa ( event_group ) );
efirc = bs->CreateEventEx ( type, notify_tpl, notify_function,
notify_context, event_group, event );
DBGC ( colour, "= %s ( %p ) -> %p\n",