Merge branch 'master' of git://git.denx.de/u-boot-sunxi
[oweals/u-boot.git] / lib / efi_loader / efi_hii.c
index 89e1a6c2369c4cdf41e415944b8519c5c28bcede..61b71dec621b0be2bb474da55a5a6e456e6f0b25 100644 (file)
@@ -132,13 +132,13 @@ add_strings_package(struct efi_hii_packagelist *hii,
        struct efi_string_table *stbl = NULL;
        efi_status_t ret;
 
-       debug("header_size: %08x\n",
-             get_unaligned_le32(&strings_package->header_size));
-       debug("string_info_offset: %08x\n",
-             get_unaligned_le32(&strings_package->string_info_offset));
-       debug("language_name: %u\n",
-             get_unaligned_le16(&strings_package->language_name));
-       debug("language: %s\n", strings_package->language);
+       EFI_PRINT("header_size: %08x\n",
+                 get_unaligned_le32(&strings_package->header_size));
+       EFI_PRINT("string_info_offset: %08x\n",
+                 get_unaligned_le32(&strings_package->string_info_offset));
+       EFI_PRINT("language_name: %u\n",
+                 get_unaligned_le16(&strings_package->language_name));
+       EFI_PRINT("language: %s\n", strings_package->language);
 
        /* count # of string entries: */
        end = ((void *)strings_package)
@@ -160,8 +160,8 @@ add_strings_package(struct efi_hii_packagelist *hii,
                        block = end;
                        break;
                default:
-                       debug("unknown HII string block type: %02x\n",
-                             block->block_type);
+                       EFI_PRINT("unknown HII string block type: %02x\n",
+                                 block->block_type);
                        return EFI_INVALID_PARAMETER;
                }
        }
@@ -195,7 +195,7 @@ add_strings_package(struct efi_hii_packagelist *hii,
                        struct efi_hii_sibt_string_ucs2_block *ucs2;
 
                        ucs2 = (void *)block;
-                       debug("%4u: \"%ls\"\n", idx + 1, ucs2->string_text);
+                       EFI_PRINT("%4u: \"%ls\"\n", idx + 1, ucs2->string_text);
                        stbl->strings[idx].string =
                                u16_strdup(ucs2->string_text);
                        if (!stbl->strings[idx].string) {
@@ -210,8 +210,8 @@ add_strings_package(struct efi_hii_packagelist *hii,
                case EFI_HII_SIBT_END:
                        goto out;
                default:
-                       debug("unknown HII string block type: %02x\n",
-                             block->block_type);
+                       EFI_PRINT("unknown HII string block type: %02x\n",
+                                 block->block_type);
                        ret = EFI_INVALID_PARAMETER;
                        goto error;
                }
@@ -227,9 +227,8 @@ out:
 error:
        if (stbl) {
                free(stbl->language);
-               if (idx > 0)
-                       while (--idx >= 0)
-                               free(stbl->strings[idx].string);
+               while (idx > 0)
+                       free(stbl->strings[--idx].string);
                free(stbl->strings);
        }
        free(stbl);
@@ -343,6 +342,7 @@ static struct efi_hii_packagelist *new_packagelist(void)
        struct efi_hii_packagelist *hii;
 
        hii = malloc(sizeof(*hii));
+       list_add_tail(&hii->link, &efi_package_lists);
        hii->max_string_id = 0;
        INIT_LIST_HEAD(&hii->string_tables);
        INIT_LIST_HEAD(&hii->guid_list);
@@ -372,14 +372,14 @@ add_packages(struct efi_hii_packagelist *hii,
        end = ((void *)package_list)
                + get_unaligned_le32(&package_list->package_length);
 
-       debug("package_list: %pUl (%u)\n", &package_list->package_list_guid,
-             get_unaligned_le32(&package_list->package_length));
+       EFI_PRINT("package_list: %pUl (%u)\n", &package_list->package_list_guid,
+                 get_unaligned_le32(&package_list->package_length));
 
        package = ((void *)package_list) + sizeof(*package_list);
        while ((void *)package < end) {
-               debug("package=%p, package type=%x, length=%u\n", package,
-                     efi_hii_package_type(package),
-                     efi_hii_package_len(package));
+               EFI_PRINT("package=%p, package type=%x, length=%u\n", package,
+                         efi_hii_package_type(package),
+                         efi_hii_package_len(package));
 
                switch (efi_hii_package_type(package)) {
                case EFI_HII_PACKAGE_TYPE_GUID:
@@ -387,7 +387,7 @@ add_packages(struct efi_hii_packagelist *hii,
                                (struct efi_hii_guid_package *)package);
                        break;
                case EFI_HII_PACKAGE_FORMS:
-                       printf("\tForm package not supported\n");
+                       EFI_PRINT("Form package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        break;
                case EFI_HII_PACKAGE_STRINGS:
@@ -395,19 +395,19 @@ add_packages(struct efi_hii_packagelist *hii,
                                (struct efi_hii_strings_package *)package);
                        break;
                case EFI_HII_PACKAGE_FONTS:
-                       printf("\tFont package not supported\n");
+                       EFI_PRINT("Font package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        break;
                case EFI_HII_PACKAGE_IMAGES:
-                       printf("\tImage package not supported\n");
+                       EFI_PRINT("Image package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        break;
                case EFI_HII_PACKAGE_SIMPLE_FONTS:
-                       printf("\tSimple font package not supported\n");
+                       EFI_PRINT("Simple font package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        break;
                case EFI_HII_PACKAGE_DEVICE_PATH:
-                       printf("\tDevice path package not supported\n");
+                       EFI_PRINT("Device path package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        break;
                case EFI_HII_PACKAGE_KEYBOARD_LAYOUT:
@@ -415,7 +415,7 @@ add_packages(struct efi_hii_packagelist *hii,
                                (struct efi_hii_keyboard_package *)package);
                        break;
                case EFI_HII_PACKAGE_ANIMATIONS:
-                       printf("\tAnimation package not supported\n");
+                       EFI_PRINT("Animation package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        break;
                case EFI_HII_PACKAGE_END:
@@ -465,7 +465,6 @@ new_package_list(const struct efi_hii_database_protocol *this,
        }
 
        hii->driver_handle = driver_handle;
-       list_add_tail(&hii->link, &efi_package_lists);
        *handle = hii;
 
        return EFI_EXIT(EFI_SUCCESS);
@@ -505,50 +504,50 @@ update_package_list(const struct efi_hii_database_protocol *this,
        if (!package_list)
                return EFI_EXIT(EFI_INVALID_PARAMETER);
 
-       debug("package_list: %pUl (%u)\n", &package_list->package_list_guid,
-             get_unaligned_le32(&package_list->package_length));
+       EFI_PRINT("package_list: %pUl (%u)\n", &package_list->package_list_guid,
+                 get_unaligned_le32(&package_list->package_length));
 
        package = ((void *)package_list) + sizeof(*package_list);
        end = ((void *)package_list)
                + get_unaligned_le32(&package_list->package_length);
 
        while ((void *)package < end) {
-               debug("package=%p, package type=%x, length=%u\n", package,
-                     efi_hii_package_type(package),
-                     efi_hii_package_len(package));
+               EFI_PRINT("package=%p, package type=%x, length=%u\n", package,
+                         efi_hii_package_type(package),
+                         efi_hii_package_len(package));
 
                switch (efi_hii_package_type(package)) {
                case EFI_HII_PACKAGE_TYPE_GUID:
                        remove_guid_package(hii);
                        break;
                case EFI_HII_PACKAGE_FORMS:
-                       printf("\tForm package not supported\n");
+                       EFI_PRINT("Form package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        break;
                case EFI_HII_PACKAGE_STRINGS:
                        remove_strings_package(hii);
                        break;
                case EFI_HII_PACKAGE_FONTS:
-                       printf("\tFont package not supported\n");
+                       EFI_PRINT("Font package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        break;
                case EFI_HII_PACKAGE_IMAGES:
-                       printf("\tImage package not supported\n");
+                       EFI_PRINT("Image package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        break;
                case EFI_HII_PACKAGE_SIMPLE_FONTS:
-                       printf("\tSimple font package not supported\n");
+                       EFI_PRINT("Simple font package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        break;
                case EFI_HII_PACKAGE_DEVICE_PATH:
-                       printf("\tDevice path package not supported\n");
+                       EFI_PRINT("Device path package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        break;
                case EFI_HII_PACKAGE_KEYBOARD_LAYOUT:
                        remove_keyboard_package(hii);
                        break;
                case EFI_HII_PACKAGE_ANIMATIONS:
-                       printf("\tAnimation package not supported\n");
+                       EFI_PRINT("Animation package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        break;
                case EFI_HII_PACKAGE_END:
@@ -595,8 +594,8 @@ list_package_lists(const struct efi_hii_database_protocol *this,
            (package_type == EFI_HII_PACKAGE_TYPE_GUID && !package_guid))
                return EFI_EXIT(EFI_INVALID_PARAMETER);
 
-       debug("package type=%x, guid=%pUl, length=%lu\n", (int)package_type,
-             package_guid, *handle_buffer_length);
+       EFI_PRINT("package type=%x, guid=%pUl, length=%zu\n", (int)package_type,
+                 package_guid, *handle_buffer_length);
 
        package_cnt = 0;
        package_max = *handle_buffer_length / sizeof(*handle);
@@ -609,7 +608,7 @@ list_package_lists(const struct efi_hii_database_protocol *this,
                                break;
                        continue;
                case EFI_HII_PACKAGE_FORMS:
-                       printf("\tForm package not supported\n");
+                       EFI_PRINT("Form package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        continue;
                case EFI_HII_PACKAGE_STRINGS:
@@ -617,19 +616,19 @@ list_package_lists(const struct efi_hii_database_protocol *this,
                                break;
                        continue;
                case EFI_HII_PACKAGE_FONTS:
-                       printf("\tFont package not supported\n");
+                       EFI_PRINT("Font package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        continue;
                case EFI_HII_PACKAGE_IMAGES:
-                       printf("\tImage package not supported\n");
+                       EFI_PRINT("Image package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        continue;
                case EFI_HII_PACKAGE_SIMPLE_FONTS:
-                       printf("\tSimple font package not supported\n");
+                       EFI_PRINT("Simple font package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        continue;
                case EFI_HII_PACKAGE_DEVICE_PATH:
-                       printf("\tDevice path package not supported\n");
+                       EFI_PRINT("Device path package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        continue;
                case EFI_HII_PACKAGE_KEYBOARD_LAYOUT:
@@ -637,7 +636,7 @@ list_package_lists(const struct efi_hii_database_protocol *this,
                                break;
                        continue;
                case EFI_HII_PACKAGE_ANIMATIONS:
-                       printf("\tAnimation package not supported\n");
+                       EFI_PRINT("Animation package not supported\n");
                        ret = EFI_INVALID_PARAMETER;
                        continue;
                case EFI_HII_PACKAGE_END:
@@ -1041,7 +1040,7 @@ get_languages(const struct efi_hii_string_protocol *this,
        }
        *p = '\0';
 
-       debug("languages: %s\n", languages);
+       EFI_PRINT("languages: %s\n", languages);
 
        return EFI_EXIT(EFI_SUCCESS);
 }