]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Provide efi_tpl_name() for transcribing TPLs in debug messages
authorMichael Brown <mcb30@ipxe.org>
Mon, 14 Jul 2025 11:15:08 +0000 (12:15 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 14 Jul 2025 11:15:08 +0000 (12:15 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/efi/efi.h
src/interface/efi/efi_debug.c
src/interface/efi/efi_wrap.c

index 29c292f36523d1ba532c8c43542278736918346b..03081f6f40ce2e4af342b5f94a8349e88d34a988 100644 (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 );
index 026adc25e7a71042f2b5abf1afb8b7889c7857f6..067899a729050495ff3639c0f3838b68aa00c9f7 100644 (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
  *
index a806a7c60c872014f964e246a60956920c54f63f..8c3f41e3b1660653d9caabb8e4ed0fbae208ce57 100644 (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",