Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/812141/?format=api
{ "id": 812141, "url": "http://patchwork.ozlabs.org/api/patches/812141/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20170910132236.14318-5-robdclark@gmail.com/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170910132236.14318-5-robdclark@gmail.com>", "list_archive_url": null, "date": "2017-09-10T13:22:25", "name": "[U-Boot,v1,04/12] efi_loader: start fleshing out HII", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "22b84def21cd1c18ac2a3b00c9c7ce479a4fa378", "submitter": { "id": 18760, "url": "http://patchwork.ozlabs.org/api/people/18760/?format=api", "name": "Rob Clark", "email": "robdclark@gmail.com" }, "delegate": { "id": 3400, "url": "http://patchwork.ozlabs.org/api/users/3400/?format=api", "username": "agraf", "first_name": "Alexander", "last_name": "Graf", "email": "agraf@suse.de" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20170910132236.14318-5-robdclark@gmail.com/mbox/", "series": [ { "id": 2401, "url": "http://patchwork.ozlabs.org/api/series/2401/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=2401", "date": "2017-09-10T13:22:21", "name": "efi_loader+video: support for Shell.efi", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/2401/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/812141/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/812141/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"uGgEkTCZ\"; dkim-atps=neutral" ], "Received": [ "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xqsKD5jp4z9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 10 Sep 2017 23:26:40 +1000 (AEST)", "by lists.denx.de (Postfix, from userid 105)\n\tid 82567C21E54; Sun, 10 Sep 2017 13:24:49 +0000 (UTC)", "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id ECAE2C21E9D;\n\tSun, 10 Sep 2017 13:23:32 +0000 (UTC)", "by lists.denx.de (Postfix, from userid 105)\n\tid AEC1DC21F70; Sun, 10 Sep 2017 13:22:58 +0000 (UTC)", "from mail-qt0-f193.google.com (mail-qt0-f193.google.com\n\t[209.85.216.193])\n\tby lists.denx.de (Postfix) with ESMTPS id 3C9FDC21F21\n\tfor <u-boot@lists.denx.de>; Sun, 10 Sep 2017 13:22:56 +0000 (UTC)", "by mail-qt0-f193.google.com with SMTP id u48so1297306qtc.4\n\tfor <u-boot@lists.denx.de>; Sun, 10 Sep 2017 06:22:56 -0700 (PDT)", "from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a])\n\tby smtp.gmail.com with ESMTPSA id\n\ti39sm4644411qte.11.2017.09.10.06.22.53\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSun, 10 Sep 2017 06:22:53 -0700 (PDT)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-0.0 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=5IFF6U5h3HI/ExkQAAxHlPYlx3w+z48LBx/kneAdp10=;\n\tb=uGgEkTCZixKi96CSFNy1kZt8h5+blbmkz5V2jSKgkwlJdrbVOnkDpGgGcGv1A7U1ml\n\tU732JkL7GqjCh+sdFC6+dYk5NCxIOODvE8fyCrXtZR+64bkPdeV4JdVLssGRi8PhFn0X\n\t09SBU3aR/tPkoQkRA6tW2zf1LMz+lGiyoP4lzzVtIwg2iPl0MnW0EQSUuQfHdyh6F8Gn\n\td39AdsvAxAwSTugWGhp2CcibVBEr0IvAJebW2MIRGoWIROyRUwcxBSW/v3HTeeMl4t/R\n\tKQ9EIjMK6pBYVy4QtNriHvsJTRwaC7c1KJJVV5qrHsyMjKZFbCY1Ax8eQX5THp3FACYf\n\tR27w==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=5IFF6U5h3HI/ExkQAAxHlPYlx3w+z48LBx/kneAdp10=;\n\tb=QpLB13BZg1X343MXBAqH3o3dIQ26+bQYxp+QTtu3A7p0+THYG0LQQCrxLZOem0Ekqj\n\t26mkic0o2lTToLmTUXoMP/rMplFyLH51rpjg+PM3eiZuARtyeTTiFxTAPJB1J/GFfqLY\n\ttfV+7CNSIvDR7RbYLsP29dMkIEiB/Gq+18Lat5Q/6uC8wDIKWI8pcgPo/n5DE32UXj83\n\t/t+zpW+sgF3oGyTXcqW0zlkg5hcRAPWYHac7fv9jSCn0/OaCNesMPM+G50gBky0AnkXp\n\tUI2HYlyUsD0N3ngX6+TMn4D0rZhI1Lss2Nicvv1zVi57Kz7A7dZ5uFI9iNLHSeQh45gh\n\twrfw==", "X-Gm-Message-State": "AHPjjUiZ3plQeDWc2noLtg/FyS5IQ/XuUs9DYmxDuoOcL1X8QDhxU0XZ\n\t188W9SAiYih6P2fp/70=", "X-Google-Smtp-Source": "AOwi7QAfxCJENDMs9Pq6X8XOCFjZFTimn+vn+mg4N0GfWV0R1T4opOw/+1PMrXgzXt4XWut6nmvGjQ==", "X-Received": "by 10.200.34.168 with SMTP id f37mr11797783qta.91.1505049774829; \n\tSun, 10 Sep 2017 06:22:54 -0700 (PDT)", "From": "Rob Clark <robdclark@gmail.com>", "To": "U-Boot Mailing List <u-boot@lists.denx.de>", "Date": "Sun, 10 Sep 2017 09:22:25 -0400", "Message-Id": "<20170910132236.14318-5-robdclark@gmail.com>", "X-Mailer": "git-send-email 2.13.5", "In-Reply-To": "<20170910132236.14318-1-robdclark@gmail.com>", "References": "<20170910132236.14318-1-robdclark@gmail.com>", "Cc": "Heinrich Schuchardt <xypron.glpk@gmx.de>, Peter Jones <pjones@redhat.com>,\n\tLeif Lindholm <leif.lindholm@linaro.org>", "Subject": "[U-Boot] [PATCH v1 04/12] efi_loader: start fleshing out HII", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.18", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<http://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>" }, "content": "Not complete but enough for Shell.efi and SCT.efi.\n\nSigned-off-by: Rob Clark <robdclark@gmail.com>\n---\n include/efi_api.h | 68 +++++++++++-\n lib/efi_loader/efi_hii.c | 274 ++++++++++++++++++++++++++++++++++++++++-------\n 2 files changed, 304 insertions(+), 38 deletions(-)", "diff": "diff --git a/include/efi_api.h b/include/efi_api.h\nindex 25f774f253..4853b71497 100644\n--- a/include/efi_api.h\n+++ b/include/efi_api.h\n@@ -16,6 +16,7 @@\n #define _EFI_API_H\n \n #include <efi.h>\n+#include <charset.h>\n \n #ifdef CONFIG_EFI_LOADER\n #include <asm/setjmp.h>\n@@ -540,6 +541,8 @@ struct efi_device_path_utilities_protocol\n \tEFI_GUID(0x587e72d7, 0xcc50, 0x4f79, \\\n \t\t 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f)\n \n+typedef uint16_t efi_string_id_t;\n+\n struct efi_hii_config_routing_protocol\n {\n \tefi_status_t(EFIAPI *extract_config)(\n@@ -630,7 +633,69 @@ struct efi_hii_package_list_header\n {\n \tefi_guid_t package_list_guid;\n \tuint32_t package_length;\n-};\n+} __packed;\n+\n+struct efi_hii_package_header {\n+\tuint32_t length : 24;\n+\tuint32_t type : 8;\n+} __packed;\n+\n+#define EFI_HII_PACKAGE_TYPE_ALL 0x00\n+#define EFI_HII_PACKAGE_TYPE_GUID 0x01\n+#define EFI_HII_PACKAGE_FORMS 0x02\n+#define EFI_HII_PACKAGE_STRINGS 0x04\n+#define EFI_HII_PACKAGE_FONTS 0x05\n+#define EFI_HII_PACKAGE_IMAGES 0x06\n+#define EFI_HII_PACKAGE_SIMPLE_FONTS 0x07\n+#define EFI_HII_PACKAGE_DEVICE_PATH 0x08\n+#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT 0x09\n+#define EFI_HII_PACKAGE_ANIMATIONS 0x0A\n+#define EFI_HII_PACKAGE_END 0xDF\n+#define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN 0xE0\n+#define EFI_HII_PACKAGE_TYPE_SYSTEM_END 0xFF\n+\n+struct efi_hii_strings_package {\n+\tstruct efi_hii_package_header header;\n+\tuint32_t header_size;\n+\tuint32_t string_info_offset;\n+\tuint16_t language_window[16];\n+\tefi_string_id_t language_name;\n+\tuint8_t language[];\n+} __packed;\n+\n+struct efi_hii_string_block {\n+\tuint8_t block_type;\n+\t/*uint8_t block_body[];*/\n+} __packed;\n+\n+#define EFI_HII_SIBT_END 0x00 // The end of the string information.\n+#define EFI_HII_SIBT_STRING_SCSU 0x10 // Single string using default font information.\n+#define EFI_HII_SIBT_STRING_SCSU_FONT 0x11 // Single string with font information.\n+#define EFI_HII_SIBT_STRINGS_SCSU 0x12 // Multiple strings using default font information.\n+#define EFI_HII_SIBT_STRINGS_SCSU_FONT 0x13 // Multiple strings with font information.\n+#define EFI_HII_SIBT_STRING_UCS2 0x14 // Single UCS-2 string using default font information.\n+#define EFI_HII_SIBT_STRING_UCS2_FONT 0x15 // Single UCS-2 string with font information\n+#define EFI_HII_SIBT_STRINGS_UCS2 0x16 // Multiple UCS-2 strings using default font information.\n+#define EFI_HII_SIBT_STRINGS_UCS2_FONT 0x17 // Multiple UCS-2 strings with font information.\n+#define EFI_HII_SIBT_DUPLICATE 0x20 // Create a duplicate of an existing string.\n+#define EFI_HII_SIBT_SKIP2 0x21 // Skip a certain number of string identifiers.\n+#define EFI_HII_SIBT_SKIP1 0x22 // Skip a certain number of string identifiers.\n+#define EFI_HII_SIBT_EXT1 0x30 // For future expansion (one byte length field)\n+#define EFI_HII_SIBT_EXT2 0x31 // For future expansion (two byte length field)\n+#define EFI_HII_SIBT_EXT4 0x32 // For future expansion (four byte length field)\n+#define EFI_HII_SIBT_FONT 0x40 // Font information.\n+\n+struct efi_hii_sibt_string_ucs2_block {\n+\tstruct efi_hii_string_block header;\n+\tuint16_t string_text[];\n+} __packed;\n+\n+static inline struct efi_hii_string_block *efi_hii_sibt_string_ucs2_block_next(\n+\tstruct efi_hii_sibt_string_ucs2_block *blk)\n+{\n+\treturn ((void *)blk) + sizeof(*blk) +\n+\t\t(utf16_strlen(blk->string_text) + 1) * 2;\n+}\n \n typedef void *efi_hii_handle_t;\n \n@@ -693,7 +758,6 @@ struct efi_hii_database_protocol\n \t\t 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a)\n \n typedef uint32_t efi_hii_font_style_t;\n-typedef uint16_t efi_string_id_t;\n \n struct efi_font_info\n {\ndiff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c\nindex cc68a28d2b..d818f409dc 100644\n--- a/lib/efi_loader/efi_hii.c\n+++ b/lib/efi_loader/efi_hii.c\n@@ -7,6 +7,7 @@\n */\n \n #include <common.h>\n+#include <malloc.h>\n #include <efi_loader.h>\n \n const efi_guid_t efi_guid_hii_config_routing_protocol =\n@@ -14,12 +15,128 @@ const efi_guid_t efi_guid_hii_config_routing_protocol =\n const efi_guid_t efi_guid_hii_database_protocol = EFI_HII_DATABASE_PROTOCOL_GUID;\n const efi_guid_t efi_guid_hii_string_protocol = EFI_HII_STRING_PROTOCOL_GUID;\n \n+struct hii_package {\n+\t// TODO should there be an associated efi_object?\n+\tstruct list_head string_tables; /* list of string_table */\n+\t/* we could also track fonts, images, etc */\n+};\n+\n+struct string_table {\n+\tstruct list_head link;\n+\tefi_string_id_t language_name;\n+\tchar *language;\n+\tuint32_t nstrings;\n+\t/* NOTE: string id starts at 1 so value is stbl->strings[id-1] */\n+\tstruct {\n+\t\tefi_string_t string;\n+\t\t/* we could also track font info, etc */\n+\t} strings[];\n+};\n+\n+static void free_strings_table(struct string_table *stbl)\n+{\n+\tfor (int i = 0; i < stbl->nstrings; i++)\n+\t\tfree(stbl->strings[i].string);\n+\tfree(stbl->language);\n+\tfree(stbl);\n+}\n+\n+static struct hii_package *new_package(void)\n+{\n+\tstruct hii_package *hii = malloc(sizeof(*hii));\n+\tINIT_LIST_HEAD(&hii->string_tables);\n+\treturn hii;\n+}\n+\n+static void free_package(struct hii_package *hii)\n+{\n+\n+\twhile (!list_empty(&hii->string_tables)) {\n+\t\tstruct string_table *stbl;\n+\n+\t\tstbl = list_first_entry(&hii->string_tables,\n+\t\t\t\t\tstruct string_table, link);\n+\t\tlist_del(&stbl->link);\n+\t\tfree_strings_table(stbl);\n+\t}\n+\n+\tfree(hii);\n+}\n+\n+static efi_status_t add_strings_package(struct hii_package *hii,\n+\tstruct efi_hii_strings_package *strings_package)\n+{\n+\tstruct efi_hii_string_block *block;\n+\tvoid *end = ((void *)strings_package) + strings_package->header.length;\n+\tuint32_t nstrings = 0;\n+\tunsigned id = 0;\n+\n+\tdebug(\"header_size: %08x\\n\", strings_package->header_size);\n+\tdebug(\"string_info_offset: %08x\\n\", strings_package->string_info_offset);\n+\tdebug(\"language_name: %u\\n\", strings_package->language_name);\n+\tdebug(\"language: %s\\n\", strings_package->language);\n+\n+\t/* count # of string entries: */\n+\tblock = ((void *)strings_package) + strings_package->string_info_offset;\n+\twhile ((void *)block < end) {\n+\t\tswitch (block->block_type) {\n+\t\tcase EFI_HII_SIBT_STRING_UCS2: {\n+\t\t\tstruct efi_hii_sibt_string_ucs2_block *ucs2 =\n+\t\t\t\t(void *)block;\n+\t\t\tnstrings++;\n+\t\t\tblock = efi_hii_sibt_string_ucs2_block_next(ucs2);\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase EFI_HII_SIBT_END:\n+\t\t\tblock = end;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tdebug(\"unknown HII string block type: %02x\\n\",\n+\t\t\t block->block_type);\n+\t\t\treturn EFI_INVALID_PARAMETER;\n+\t\t}\n+\t}\n+\n+\tstruct string_table *stbl = malloc(sizeof(*stbl) +\n+\t\t\t(nstrings * sizeof(stbl->strings[0])));\n+\tstbl->language_name = strings_package->language_name;\n+\tstbl->language = strdup((char *)strings_package->language);\n+\tstbl->nstrings = nstrings;\n+\n+\tlist_add(&stbl->link, &hii->string_tables);\n+\n+\t/* and now parse string entries and populate string_table */\n+\tblock = ((void *)strings_package) + strings_package->string_info_offset;\n+\n+\twhile ((void *)block < end) {\n+\t\tswitch (block->block_type) {\n+\t\tcase EFI_HII_SIBT_STRING_UCS2: {\n+\t\t\tstruct efi_hii_sibt_string_ucs2_block *ucs2 =\n+\t\t\t\t(void *)block;\n+\t\t\tid++;\n+\t\t\tdebug(\"%4u: \\\"%ls\\\"\\n\", id, ucs2->string_text);\n+\t\t\tstbl->strings[id-1].string =\n+\t\t\t\tutf16_strdup(ucs2->string_text);\n+\t\t\tblock = efi_hii_sibt_string_ucs2_block_next(ucs2);\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase EFI_HII_SIBT_END:\n+\t\t\treturn EFI_SUCCESS;\n+\t\tdefault:\n+\t\t\tdebug(\"unknown HII string block type: %02x\\n\",\n+\t\t\t block->block_type);\n+\t\t\treturn EFI_INVALID_PARAMETER;\n+\t\t}\n+\t}\n+\n+\treturn EFI_SUCCESS;\n+}\n \n /*\n * EFI_HII_CONFIG_ROUTING_PROTOCOL\n */\n \n-static efi_status_t extract_config(\n+static efi_status_t EFIAPI extract_config(\n \tconst struct efi_hii_config_routing_protocol *this,\n \tconst efi_string_t request,\n \tefi_string_t *progress,\n@@ -29,7 +146,7 @@ static efi_status_t extract_config(\n \treturn EFI_EXIT(EFI_OUT_OF_RESOURCES);\n }\n \n-static efi_status_t export_config(\n+static efi_status_t EFIAPI export_config(\n \tconst struct efi_hii_config_routing_protocol *this,\n \tefi_string_t *results)\n {\n@@ -37,7 +154,7 @@ static efi_status_t export_config(\n \treturn EFI_EXIT(EFI_OUT_OF_RESOURCES);\n }\n \n-static efi_status_t route_config(\n+static efi_status_t EFIAPI route_config(\n \tconst struct efi_hii_config_routing_protocol *this,\n \tconst efi_string_t configuration,\n \tefi_string_t *progress)\n@@ -46,7 +163,7 @@ static efi_status_t route_config(\n \treturn EFI_EXIT(EFI_OUT_OF_RESOURCES);\n }\n \n-static efi_status_t block_to_config(\n+static efi_status_t EFIAPI block_to_config(\n \tconst struct efi_hii_config_routing_protocol *this,\n \tconst efi_string_t config_request,\n \tconst uint8_t *block,\n@@ -54,12 +171,12 @@ static efi_status_t block_to_config(\n \tefi_string_t *config,\n \tefi_string_t *progress)\n {\n-\tEFI_ENTRY(\"%p, \\\"%ls\\\", %p, %lu, %p, %p\", this, config_request, block,\n+\tEFI_ENTRY(\"%p, \\\"%ls\\\", %p, %zu, %p, %p\", this, config_request, block,\n \t\t block_size, config, progress);\n \treturn EFI_EXIT(EFI_OUT_OF_RESOURCES);\n }\n \n-static efi_status_t config_to_block(\n+static efi_status_t EFIAPI config_to_block(\n \tconst struct efi_hii_config_routing_protocol *this,\n \tconst efi_string_t config_resp,\n \tconst uint8_t *block,\n@@ -71,7 +188,7 @@ static efi_status_t config_to_block(\n \treturn EFI_EXIT(EFI_OUT_OF_RESOURCES);\n }\n \n-static efi_status_t get_alt_config(\n+static efi_status_t EFIAPI get_alt_config(\n \tconst struct efi_hii_config_routing_protocol *this,\n \tconst efi_string_t config_resp,\n \tconst efi_guid_t *guid,\n@@ -91,28 +208,67 @@ static efi_status_t get_alt_config(\n * EFI_HII_DATABASE_PROTOCOL\n */\n \n-static efi_status_t new_package_list(\n+static efi_status_t EFIAPI new_package_list(\n \tconst struct efi_hii_database_protocol *this,\n \tconst struct efi_hii_package_list_header *package_list,\n \tconst efi_handle_t driver_handle,\n \tefi_hii_handle_t *handle)\n {\n-\t/* Current shell start failure. */\n-\t/* Invoked from MdeModulePkg/Library/UefiHiiLib/HiiLib.c : HiiAddPackages */\n-\t/* (Via autogenerated .c file.) */\n+\tefi_status_t ret = EFI_SUCCESS;\n+\n \tEFI_ENTRY(\"%p, %p, %p, %p\", this, package_list, driver_handle, handle);\n-\treturn EFI_EXIT(EFI_OUT_OF_RESOURCES);\n+\n+\tif (!package_list || !driver_handle)\n+\t\treturn EFI_EXIT(EFI_INVALID_PARAMETER);\n+\n+\tstruct hii_package *hii = new_package();\n+\tstruct efi_hii_package_header *package;\n+\tvoid *end = ((void *)package_list) + package_list->package_length;\n+\n+\tdebug(\"package_list: %pUl (%u)\\n\", &package_list->package_list_guid,\n+\t package_list->package_length);\n+\n+\tpackage = ((void *)package_list) + sizeof(*package_list);\n+\twhile ((void *)package < end) {\n+\t\tdebug(\"package=%p, package type=%x, length=%u\\n\", package,\n+\t\t package->type, package->length);\n+\t\tswitch (package->type) {\n+\t\tcase EFI_HII_PACKAGE_STRINGS:\n+\t\t\tret = add_strings_package(hii,\n+\t\t\t\t(struct efi_hii_strings_package *)package);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (ret != EFI_SUCCESS)\n+\t\t\tgoto error;\n+\n+\t\tpackage = ((void *)package) + package->length;\n+\t}\n+\n+\t// TODO in theory there is some notifications that should be sent..\n+\n+\t*handle = hii;\n+\n+\treturn EFI_EXIT(EFI_SUCCESS);\n+\n+error:\n+\tfree_package(hii);\n+\treturn EFI_EXIT(ret);\n }\n \n-static efi_status_t remove_package_list(\n+static efi_status_t EFIAPI remove_package_list(\n \tconst struct efi_hii_database_protocol *this,\n \tefi_hii_handle_t handle)\n {\n+\tstruct hii_package *hii = handle;\n \tEFI_ENTRY(\"%p, %p\", this, handle);\n-\treturn EFI_EXIT(EFI_NOT_FOUND);\n+\tfree_package(hii);\n+\treturn EFI_EXIT(EFI_SUCCESS);\n }\n \n-static efi_status_t update_package_list(\n+static efi_status_t EFIAPI update_package_list(\n \tconst struct efi_hii_database_protocol *this,\n \tefi_hii_handle_t handle,\n \tconst struct efi_hii_package_list_header *package_list)\n@@ -121,7 +277,7 @@ static efi_status_t update_package_list(\n \treturn EFI_EXIT(EFI_NOT_FOUND);\n }\n \n-static efi_status_t list_package_lists(\n+static efi_status_t EFIAPI list_package_lists(\n \tconst struct efi_hii_database_protocol *this,\n \tuint8_t package_type,\n \tconst efi_guid_t *package_guid,\n@@ -133,7 +289,7 @@ static efi_status_t list_package_lists(\n \treturn EFI_EXIT(EFI_NOT_FOUND);\n }\n \n-static efi_status_t export_package_lists(\n+static efi_status_t EFIAPI export_package_lists(\n \tconst struct efi_hii_database_protocol *this,\n \tefi_hii_handle_t handle,\n \tUINTN *buffer_size,\n@@ -143,7 +299,7 @@ static efi_status_t export_package_lists(\n \treturn EFI_EXIT(EFI_NOT_FOUND);\n }\n \n-static efi_status_t register_package_notify(\n+static efi_status_t EFIAPI register_package_notify(\n \tconst struct efi_hii_database_protocol *this,\n \tuint8_t package_type,\n \tconst efi_guid_t *package_guid,\n@@ -151,13 +307,13 @@ static efi_status_t register_package_notify(\n \tUINTN notify_type,\n \tefi_handle_t *notify_handle)\n {\n-\tEFI_ENTRY(\"%p, %u, %pUl, %p, %lu, %p\", this, package_type,\n+\tEFI_ENTRY(\"%p, %u, %pUl, %p, %zu, %p\", this, package_type,\n \t\t package_guid, package_notify_fn, notify_type,\n \t\t notify_handle);\n \treturn EFI_EXIT(EFI_OUT_OF_RESOURCES);\n }\n \n-static efi_status_t unregister_package_notify(\n+static efi_status_t EFIAPI unregister_package_notify(\n \tconst struct efi_hii_database_protocol *this,\n \tefi_handle_t notification_handle)\n {\n@@ -165,7 +321,7 @@ static efi_status_t unregister_package_notify(\n \treturn EFI_EXIT(EFI_NOT_FOUND);\n }\n \n-static efi_status_t find_keyboard_layouts(\n+static efi_status_t EFIAPI find_keyboard_layouts(\n \tconst struct efi_hii_database_protocol *this,\n \tuint16_t *key_guid_buffer_length,\n \tefi_guid_t *key_guid_buffer)\n@@ -174,7 +330,7 @@ static efi_status_t find_keyboard_layouts(\n \treturn EFI_EXIT(EFI_NOT_FOUND); /* Invalid */\n }\n \n-static efi_status_t get_keyboard_layout(\n+static efi_status_t EFIAPI get_keyboard_layout(\n \tconst struct efi_hii_database_protocol *this,\n \tefi_guid_t *key_guid,\n \tuint16_t *keyboard_layout_length,\n@@ -185,7 +341,7 @@ static efi_status_t get_keyboard_layout(\n \treturn EFI_EXIT(EFI_NOT_FOUND);\n }\n \n-static efi_status_t set_keyboard_layout(\n+static efi_status_t EFIAPI set_keyboard_layout(\n \tconst struct efi_hii_database_protocol *this,\n \tefi_guid_t *key_guid)\n {\n@@ -193,7 +349,7 @@ static efi_status_t set_keyboard_layout(\n \treturn EFI_EXIT(EFI_NOT_FOUND);\n }\n \n-static efi_status_t get_package_list_handle(\n+static efi_status_t EFIAPI get_package_list_handle(\n \tconst struct efi_hii_database_protocol *this,\n \tefi_hii_handle_t package_list_handle,\n \tefi_handle_t *driver_handle)\n@@ -207,7 +363,7 @@ static efi_status_t get_package_list_handle(\n * EFI_HII_STRING_PROTOCOL\n */\n \n-static efi_status_t new_string(\n+static efi_status_t EFIAPI new_string(\n \tconst struct efi_hii_string_protocol *this,\n \tefi_hii_handle_t package_list,\n \tefi_string_id_t *string_id,\n@@ -216,13 +372,13 @@ static efi_status_t new_string(\n \tconst efi_string_t string,\n \tconst struct efi_font_info *string_font_info)\n {\n-\tEFI_ENTRY(\"%p, %p, %p, %p, %p, \\\"%ls\\\", %p\", this, package_list,\n+\tEFI_ENTRY(\"%p, %p, %p, \\\"%s\\\", %p, \\\"%ls\\\", %p\", this, package_list,\n \t\t string_id, language, language_name, string,\n \t\t string_font_info);\n \treturn EFI_EXIT(EFI_NOT_FOUND);\n }\n \n-static efi_status_t get_string(\n+static efi_status_t EFIAPI get_string(\n \tconst struct efi_hii_string_protocol *this,\n \tconst uint8_t *language,\n \tefi_hii_handle_t package_list,\n@@ -231,13 +387,34 @@ static efi_status_t get_string(\n \tUINTN *string_size,\n \tstruct efi_font_info **string_font_info)\n {\n-\tEFI_ENTRY(\"%p, %p, %p, %u, \\\"%ls\\\", %p, %p\", this, language,\n+\tstruct hii_package *hii = package_list;\n+\tstruct string_table *stbl;\n+\n+\tEFI_ENTRY(\"%p, \\\"%s\\\", %p, %u, %p, %p, %p\", this, language,\n \t\t package_list, string_id, string, string_size,\n \t\t string_font_info);\n+\n+\tlist_for_each_entry(stbl, &hii->string_tables, link) {\n+\t\tif (!strcmp((char *)language, (char *)stbl->language)) {\n+\t\t\tunsigned idx = string_id - 1;\n+\t\t\tif (idx > stbl->nstrings)\n+\t\t\t\treturn EFI_EXIT(EFI_NOT_FOUND);\n+\t\t\tefi_string_t str = stbl->strings[idx].string;\n+\t\t\tsize_t len = utf16_strlen(str) + 1;\n+\t\t\tif (*string_size < len * 2) {\n+\t\t\t\t*string_size = len * 2;\n+\t\t\t\treturn EFI_EXIT(EFI_BUFFER_TOO_SMALL);\n+\t\t\t}\n+\t\t\tmemcpy(string, str, len * 2);\n+\t\t\t*string_size = len * 2;\n+\t\t\treturn EFI_EXIT(EFI_SUCCESS);\n+\t\t}\n+\t}\n+\n \treturn EFI_EXIT(EFI_NOT_FOUND);\n }\n \n-static efi_status_t set_string(\n+static efi_status_t EFIAPI set_string(\n \tconst struct efi_hii_string_protocol *this,\n \tefi_hii_handle_t package_list,\n \tefi_string_id_t string_id,\n@@ -245,31 +422,56 @@ static efi_status_t set_string(\n \tconst efi_string_t string,\n \tconst struct efi_font_info *string_font_info)\n {\n-\tEFI_ENTRY(\"%p, %p, %u, %p, \\\"%ls\\\", %p\", this, package_list, string_id,\n-\t\t language, string, string_font_info);\n+\tEFI_ENTRY(\"%p, %p, %u, \\\"%s\\\", \\\"%ls\\\", %p\", this, package_list,\n+\t\t string_id, language, string, string_font_info);\n \treturn EFI_EXIT(EFI_NOT_FOUND);\n }\n \n-static efi_status_t get_languages(\n+static efi_status_t EFIAPI get_languages(\n \tconst struct efi_hii_string_protocol *this,\n \tefi_hii_handle_t package_list,\n \tuint8_t *languages,\n \tUINTN *languages_size)\n {\n+\tstruct hii_package *hii = package_list;\n+\tstruct string_table *stbl;\n+\tsize_t len = 0;\n+\n \tEFI_ENTRY(\"%p, %p, %p, %p\", this, package_list, languages,\n \t\t languages_size);\n-\treturn EFI_EXIT(EFI_NOT_FOUND);\n+\n+\t/* figure out required size: */\n+\tlist_for_each_entry(stbl, &hii->string_tables, link) {\n+\t\tlen += strlen((char *)stbl->language) + 1;\n+\t}\n+\n+\tif (*languages_size < len) {\n+\t\t*languages_size = len;\n+\t\treturn EFI_EXIT(EFI_BUFFER_TOO_SMALL);\n+\t}\n+\n+\tchar *p = (char *)languages;\n+\tlist_for_each_entry(stbl, &hii->string_tables, link) {\n+\t\tif (p != (char *)languages)\n+\t\t\tp += sprintf(p, \";\");\n+\t\tp += sprintf(p, \"%s\", stbl->language);\n+\t}\n+\n+\tdebug(\"languages: %s\\n\", languages);\n+\n+\treturn EFI_EXIT(EFI_SUCCESS);\n }\n \n-static efi_status_t get_secondary_languages(\n+static efi_status_t EFIAPI get_secondary_languages(\n \tconst struct efi_hii_string_protocol *this,\n \tefi_hii_handle_t package_list,\n \tconst uint8_t *primary_language,\n \tuint8_t *secondary_languages,\n \tUINTN *secondary_languages_size)\n {\n-\tEFI_ENTRY(\"%p, %p, %p, %p, %p\", this, package_list, primary_language,\n-\t\t secondary_languages, secondary_languages_size);\n+\tEFI_ENTRY(\"%p, %p, \\\"%s\\\", %p, %p\", this, package_list,\n+\t\t primary_language, secondary_languages,\n+\t\t secondary_languages_size);\n \treturn EFI_EXIT(EFI_NOT_FOUND);\n }\n \n", "prefixes": [ "U-Boot", "v1", "04/12" ] }