]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Also try original ComponentName protocol for retrieving driver names
authorMichael Brown <mcb30@ipxe.org>
Fri, 1 Aug 2014 09:36:25 +0000 (10:36 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 1 Aug 2014 09:36:25 +0000 (10:36 +0100)
The ComponentName and ComponentName2 protocols differ only in the
standard which is used for language name codes.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/interface/efi/efi_debug.c

index a3d2438fef040331a44f6b105f61e1b3f1a2dd05..da8efb1ec7e504ba4e49ef9697289d1131f7c244 100644 (file)
@@ -348,7 +348,37 @@ const char * efi_devpath_text ( EFI_DEVICE_PATH_PROTOCOL *path ) {
  * @v wtf              Component name protocol
  * @ret name           Driver name, or NULL
  */
-static const char * efi_driver_name ( EFI_COMPONENT_NAME2_PROTOCOL *wtf ) {
+static const char * efi_driver_name ( EFI_COMPONENT_NAME_PROTOCOL *wtf ) {
+       static char name[64];
+       CHAR16 *driver_name;
+       EFI_STATUS efirc;
+
+       /* Sanity check */
+       if ( ! wtf ) {
+               DBG ( "[NULL ComponentName]" );
+               return NULL;
+       }
+
+       /* Try "eng" first; if that fails then try the first language */
+       if ( ( ( efirc = wtf->GetDriverName ( wtf, "eng",
+                                             &driver_name ) ) != 0 ) &&
+            ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
+                                             &driver_name ) ) != 0 ) ) {
+               return NULL;
+       }
+
+       /* Convert name from CHAR16 to char */
+       snprintf ( name, sizeof ( name ), "%ls", driver_name );
+       return name;
+}
+
+/**
+ * Get driver name
+ *
+ * @v wtf              Component name protocol
+ * @ret name           Driver name, or NULL
+ */
+static const char * efi_driver_name2 ( EFI_COMPONENT_NAME2_PROTOCOL *wtf ) {
        static char name[64];
        CHAR16 *driver_name;
        EFI_STATUS efirc;
@@ -559,6 +589,9 @@ static struct efi_handle_name_type efi_handle_name_types[] = {
                               efi_devpath_text ),
        /* Driver name (for driver image handles) */
        EFI_HANDLE_NAME_TYPE ( &efi_component_name2_protocol_guid,
+                              efi_driver_name2 ),
+       /* Driver name (via obsolete original ComponentName protocol) */
+       EFI_HANDLE_NAME_TYPE ( &efi_component_name_protocol_guid,
                               efi_driver_name ),
        /* PE/COFF debug filename (for image handles) */
        EFI_HANDLE_NAME_TYPE ( &efi_loaded_image_protocol_guid,