diff mbox series

[U-Boot,6/6] efi_selftest: add HII database protocols test

Message ID 20181101044746.19977-5-takahiro.akashi@linaro.org
State Superseded
Delegated to: Alexander Graf
Headers show
Series efi_loader: add HII database protocol | expand

Commit Message

takahiro.akashi@linaro.org Nov. 1, 2018, 4:47 a.m. UTC
This efi_selftest tests HII database protocol and HII string protocol.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 lib/efi_selftest/Makefile                |   1 +
 lib/efi_selftest/efi_selftest_hii.c      | 882 +++++++++++++++++++++++
 lib/efi_selftest/efi_selftest_hii_data.c | 450 ++++++++++++
 3 files changed, 1333 insertions(+)
 create mode 100644 lib/efi_selftest/efi_selftest_hii.c
 create mode 100644 lib/efi_selftest/efi_selftest_hii_data.c

Comments

Heinrich Schuchardt Nov. 1, 2018, 7:33 a.m. UTC | #1
On 11/01/2018 05:47 AM, AKASHI Takahiro wrote:
> This efi_selftest tests HII database protocol and HII string protocol.
> 
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
>  lib/efi_selftest/Makefile                |   1 +
>  lib/efi_selftest/efi_selftest_hii.c      | 882 +++++++++++++++++++++++
>  lib/efi_selftest/efi_selftest_hii_data.c | 450 ++++++++++++
>  3 files changed, 1333 insertions(+)
>  create mode 100644 lib/efi_selftest/efi_selftest_hii.c
>  create mode 100644 lib/efi_selftest/efi_selftest_hii_data.c
> 
> diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
> index 4b1c0bb84b18..1209b54b07cd 100644
> --- a/lib/efi_selftest/Makefile
> +++ b/lib/efi_selftest/Makefile
> @@ -25,6 +25,7 @@ efi_selftest_exception.o \
>  efi_selftest_exitbootservices.o \
>  efi_selftest_fdt.o \
>  efi_selftest_gop.o \
> +efi_selftest_hii.o \
>  efi_selftest_loaded_image.o \
>  efi_selftest_manageprotocols.o \
>  efi_selftest_rtc.o \
> diff --git a/lib/efi_selftest/efi_selftest_hii.c b/lib/efi_selftest/efi_selftest_hii.c
> new file mode 100644
> index 000000000000..2d5fe095a9b2
> --- /dev/null
> +++ b/lib/efi_selftest/efi_selftest_hii.c
> @@ -0,0 +1,882 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * efi_selftest_hii
> + *
> + * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited
> + *
> + * Test HII database protocols
> + */
> +
> +#include <efi_selftest.h>
> +#include <malloc.h>
> +#include "efi_selftest_hii_data.c"
> +
> +#define PRINT_TESTNAME efi_st_printf("%s:\n", __func__)
> +
> +static struct efi_boot_services *boottime;
> +
> +static const efi_guid_t hii_database_protocol_guid =
> +	EFI_HII_DATABASE_PROTOCOL_GUID;
> +static const efi_guid_t hii_string_protocol_guid =
> +	EFI_HII_STRING_PROTOCOL_GUID;
> +
> +static struct efi_hii_database_protocol *hii_database_protocol;
> +static struct efi_hii_string_protocol *hii_string_protocol;
> +
> +/*
> + * Setup unit test.
> + *
> + * @handle:	handle of the loaded image
> + * @systable:	system table
> + *
> + * @return:	EFI_ST_SUCCESS for success
> + */
> +static int setup(const efi_handle_t handle,
> +		 const struct efi_system_table *systable)
> +{
> +	efi_status_t ret;
> +
> +	boottime = systable->boottime;
> +
> +	/* HII database protocol */
> +	ret = boottime->locate_protocol(&hii_database_protocol_guid, NULL,
> +					(void **)&hii_database_protocol);
> +	if (ret != EFI_SUCCESS) {
> +		hii_database_protocol = NULL;
> +		efi_st_error("HII database protocol is not available.\n");
> +		return EFI_ST_FAILURE;
> +	}
> +
> +	/* HII string protocol */
> +	ret = boottime->locate_protocol(&hii_string_protocol_guid, NULL,
> +					(void **)&hii_string_protocol);
> +	if (ret != EFI_SUCCESS) {
> +		hii_string_protocol = NULL;
> +		efi_st_error("HII string protocol is not available.\n");
> +		return EFI_ST_FAILURE;
> +	}
> +
> +	return EFI_ST_SUCCESS;
> +}
> +
> +/*
> + * HII database protocol Tests

Thanks a lot for providing unit tests for the protocols.

%s/Tests/tests/

> + */
> +

Please, add a comment to each test describing what it is doing, e.g.

/**
 * test_hii_database_new_package_list() - test creation and removal of
package lists
 *
 * This test adds a new package list and then tries to remove it using
the provided handle.
 *
 * @Return:	status code
 */

> +static int test_hii_database_new_package_list(void)
> +{
> +	efi_hii_handle_t handle;
> +	efi_status_t ret;
> +
> +	PRINT_TESTNAME;
> +	ret = hii_database_protocol->new_package_list(hii_database_protocol,
> +			(struct efi_hii_package_list_header *)packagelist1,
> +			NULL, &handle);
> +	if (ret != EFI_SUCCESS || !handle) {
> +		efi_st_error("new_package_list returned %u\n", (int)ret);

%s/int/unsigned int/

> +		return EFI_ST_FAILURE;
> +	}
> +
> +	ret = hii_database_protocol->remove_package_list(hii_database_protocol,
> +			handle);
> +	if (ret != EFI_SUCCESS) {
> +		efi_st_error("remove_package_list returned %u\n", (int)ret);

%s/int/unsigned int/

Same change needed all over the file.

Best regards

Heinrich
takahiro.akashi@linaro.org Nov. 2, 2018, 12:55 a.m. UTC | #2
On Thu, Nov 01, 2018 at 08:33:09AM +0100, Heinrich Schuchardt wrote:
> On 11/01/2018 05:47 AM, AKASHI Takahiro wrote:
> > This efi_selftest tests HII database protocol and HII string protocol.
> > 
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> >  lib/efi_selftest/Makefile                |   1 +
> >  lib/efi_selftest/efi_selftest_hii.c      | 882 +++++++++++++++++++++++
> >  lib/efi_selftest/efi_selftest_hii_data.c | 450 ++++++++++++
> >  3 files changed, 1333 insertions(+)
> >  create mode 100644 lib/efi_selftest/efi_selftest_hii.c
> >  create mode 100644 lib/efi_selftest/efi_selftest_hii_data.c
> > 
> > diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
> > index 4b1c0bb84b18..1209b54b07cd 100644
> > --- a/lib/efi_selftest/Makefile
> > +++ b/lib/efi_selftest/Makefile
> > @@ -25,6 +25,7 @@ efi_selftest_exception.o \
> >  efi_selftest_exitbootservices.o \
> >  efi_selftest_fdt.o \
> >  efi_selftest_gop.o \
> > +efi_selftest_hii.o \
> >  efi_selftest_loaded_image.o \
> >  efi_selftest_manageprotocols.o \
> >  efi_selftest_rtc.o \
> > diff --git a/lib/efi_selftest/efi_selftest_hii.c b/lib/efi_selftest/efi_selftest_hii.c
> > new file mode 100644
> > index 000000000000..2d5fe095a9b2
> > --- /dev/null
> > +++ b/lib/efi_selftest/efi_selftest_hii.c
> > @@ -0,0 +1,882 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * efi_selftest_hii
> > + *
> > + * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited
> > + *
> > + * Test HII database protocols
> > + */
> > +
> > +#include <efi_selftest.h>
> > +#include <malloc.h>
> > +#include "efi_selftest_hii_data.c"
> > +
> > +#define PRINT_TESTNAME efi_st_printf("%s:\n", __func__)
> > +
> > +static struct efi_boot_services *boottime;
> > +
> > +static const efi_guid_t hii_database_protocol_guid =
> > +	EFI_HII_DATABASE_PROTOCOL_GUID;
> > +static const efi_guid_t hii_string_protocol_guid =
> > +	EFI_HII_STRING_PROTOCOL_GUID;
> > +
> > +static struct efi_hii_database_protocol *hii_database_protocol;
> > +static struct efi_hii_string_protocol *hii_string_protocol;
> > +
> > +/*
> > + * Setup unit test.
> > + *
> > + * @handle:	handle of the loaded image
> > + * @systable:	system table
> > + *
> > + * @return:	EFI_ST_SUCCESS for success
> > + */
> > +static int setup(const efi_handle_t handle,
> > +		 const struct efi_system_table *systable)
> > +{
> > +	efi_status_t ret;
> > +
> > +	boottime = systable->boottime;
> > +
> > +	/* HII database protocol */
> > +	ret = boottime->locate_protocol(&hii_database_protocol_guid, NULL,
> > +					(void **)&hii_database_protocol);
> > +	if (ret != EFI_SUCCESS) {
> > +		hii_database_protocol = NULL;
> > +		efi_st_error("HII database protocol is not available.\n");
> > +		return EFI_ST_FAILURE;
> > +	}
> > +
> > +	/* HII string protocol */
> > +	ret = boottime->locate_protocol(&hii_string_protocol_guid, NULL,
> > +					(void **)&hii_string_protocol);
> > +	if (ret != EFI_SUCCESS) {
> > +		hii_string_protocol = NULL;
> > +		efi_st_error("HII string protocol is not available.\n");
> > +		return EFI_ST_FAILURE;
> > +	}
> > +
> > +	return EFI_ST_SUCCESS;
> > +}
> > +
> > +/*
> > + * HII database protocol Tests
> 
> Thanks a lot for providing unit tests for the protocols.
> 
> %s/Tests/tests/

Fixed.

> > + */
> > +
> 
> Please, add a comment to each test describing what it is doing, e.g.

OK, but it's a quite painful task.

> /**
>  * test_hii_database_new_package_list() - test creation and removal of
> package lists
>  *
>  * This test adds a new package list and then tries to remove it using
> the provided handle.
>  *
>  * @Return:	status code
>  */
> 
> > +static int test_hii_database_new_package_list(void)
> > +{
> > +	efi_hii_handle_t handle;
> > +	efi_status_t ret;
> > +
> > +	PRINT_TESTNAME;
> > +	ret = hii_database_protocol->new_package_list(hii_database_protocol,
> > +			(struct efi_hii_package_list_header *)packagelist1,
> > +			NULL, &handle);
> > +	if (ret != EFI_SUCCESS || !handle) {
> > +		efi_st_error("new_package_list returned %u\n", (int)ret);
> 
> %s/int/unsigned int/
> 
> > +		return EFI_ST_FAILURE;
> > +	}
> > +
> > +	ret = hii_database_protocol->remove_package_list(hii_database_protocol,
> > +			handle);
> > +	if (ret != EFI_SUCCESS) {
> > +		efi_st_error("remove_package_list returned %u\n", (int)ret);
> 
> %s/int/unsigned int/
> 
> Same change needed all over the file.

OK, but the root issue is that efi_st_printf/error() doesn't support
'l' specifier in "%lx" format.

-Takahiro Akashi

> Best regards
> 
> Heinrich
Heinrich Schuchardt Nov. 2, 2018, 8:12 a.m. UTC | #3
On 11/02/2018 01:55 AM, AKASHI Takahiro wrote:
> On Thu, Nov 01, 2018 at 08:33:09AM +0100, Heinrich Schuchardt wrote:
>> On 11/01/2018 05:47 AM, AKASHI Takahiro wrote:
>>> This efi_selftest tests HII database protocol and HII string protocol.
>>>

<snip />

> 
> OK, but the root issue is that efi_st_printf/error() doesn't support
> 'l' specifier in "%lx" format.

You could use efi_st_error("remove_package_list returned %p\n",
(void *)ret);

Regards

Heinrich

> 
> -Takahiro Akashi
> 
>> Best regards
>>
>> Heinrich
>
diff mbox series

Patch

diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
index 4b1c0bb84b18..1209b54b07cd 100644
--- a/lib/efi_selftest/Makefile
+++ b/lib/efi_selftest/Makefile
@@ -25,6 +25,7 @@  efi_selftest_exception.o \
 efi_selftest_exitbootservices.o \
 efi_selftest_fdt.o \
 efi_selftest_gop.o \
+efi_selftest_hii.o \
 efi_selftest_loaded_image.o \
 efi_selftest_manageprotocols.o \
 efi_selftest_rtc.o \
diff --git a/lib/efi_selftest/efi_selftest_hii.c b/lib/efi_selftest/efi_selftest_hii.c
new file mode 100644
index 000000000000..2d5fe095a9b2
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_hii.c
@@ -0,0 +1,882 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * efi_selftest_hii
+ *
+ * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited
+ *
+ * Test HII database protocols
+ */
+
+#include <efi_selftest.h>
+#include <malloc.h>
+#include "efi_selftest_hii_data.c"
+
+#define PRINT_TESTNAME efi_st_printf("%s:\n", __func__)
+
+static struct efi_boot_services *boottime;
+
+static const efi_guid_t hii_database_protocol_guid =
+	EFI_HII_DATABASE_PROTOCOL_GUID;
+static const efi_guid_t hii_string_protocol_guid =
+	EFI_HII_STRING_PROTOCOL_GUID;
+
+static struct efi_hii_database_protocol *hii_database_protocol;
+static struct efi_hii_string_protocol *hii_string_protocol;
+
+/*
+ * Setup unit test.
+ *
+ * @handle:	handle of the loaded image
+ * @systable:	system table
+ *
+ * @return:	EFI_ST_SUCCESS for success
+ */
+static int setup(const efi_handle_t handle,
+		 const struct efi_system_table *systable)
+{
+	efi_status_t ret;
+
+	boottime = systable->boottime;
+
+	/* HII database protocol */
+	ret = boottime->locate_protocol(&hii_database_protocol_guid, NULL,
+					(void **)&hii_database_protocol);
+	if (ret != EFI_SUCCESS) {
+		hii_database_protocol = NULL;
+		efi_st_error("HII database protocol is not available.\n");
+		return EFI_ST_FAILURE;
+	}
+
+	/* HII string protocol */
+	ret = boottime->locate_protocol(&hii_string_protocol_guid, NULL,
+					(void **)&hii_string_protocol);
+	if (ret != EFI_SUCCESS) {
+		hii_string_protocol = NULL;
+		efi_st_error("HII string protocol is not available.\n");
+		return EFI_ST_FAILURE;
+	}
+
+	return EFI_ST_SUCCESS;
+}
+
+/*
+ * HII database protocol Tests
+ */
+
+static int test_hii_database_new_package_list(void)
+{
+	efi_hii_handle_t handle;
+	efi_status_t ret;
+
+	PRINT_TESTNAME;
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist1,
+			NULL, &handle);
+	if (ret != EFI_SUCCESS || !handle) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		return EFI_ST_FAILURE;
+	}
+
+	ret = hii_database_protocol->remove_package_list(hii_database_protocol,
+			handle);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("remove_package_list returned %u\n", (int)ret);
+		return EFI_ST_FAILURE;
+	}
+
+	return EFI_ST_SUCCESS;
+}
+
+static int test_hii_database_update_package_list(void)
+{
+	efi_hii_handle_t handle = NULL;
+	efi_status_t ret;
+	int result = EFI_ST_FAILURE;
+
+	PRINT_TESTNAME;
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist1,
+			NULL, &handle);
+	if (ret != EFI_SUCCESS || !handle) {
+		efi_st_error("new_package_list returned %u\n", (int)(int)ret);
+		return EFI_ST_FAILURE;
+	}
+
+	ret = hii_database_protocol->update_package_list(hii_database_protocol,
+			handle,
+			(struct efi_hii_package_list_header *)packagelist2);
+	if (ret != EFI_SUCCESS || !handle) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		goto out;
+	}
+
+	result = EFI_ST_SUCCESS;
+
+out:
+	if (handle) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle);
+		if (ret != EFI_SUCCESS) {
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+			return EFI_ST_FAILURE;
+		}
+	}
+
+	return result;
+}
+
+static int test_hii_database_list_package_lists(void)
+{
+	efi_hii_handle_t handle1 = NULL, handle2 = NULL, *handles;
+	efi_uintn_t handles_size;
+	efi_status_t ret;
+	int result = EFI_ST_FAILURE;
+
+	PRINT_TESTNAME;
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist1,
+			NULL, &handle1);
+	if (ret != EFI_SUCCESS || !handle1) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		goto out;
+	}
+
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist2,
+			NULL, &handle2);
+	if (ret != EFI_SUCCESS || !handle2) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		goto out;
+	}
+
+	/* TYPE_ALL */
+	handles = NULL;
+	handles_size = 0;
+	ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+			EFI_HII_PACKAGE_TYPE_ALL, NULL,
+			&handles_size, handles);
+	if (ret != EFI_BUFFER_TOO_SMALL) {
+		efi_st_error("list_package_lists returned %u\n", (int)ret);
+		goto out;
+	}
+	handles = malloc(handles_size);
+	if (!handles) {
+		efi_st_error("malloc failed\n");
+		goto out;
+	}
+	ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+			EFI_HII_PACKAGE_TYPE_ALL, NULL,
+			&handles_size, handles);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("list_package_lists returned %u\n", (int)ret);
+		goto out;
+	}
+	efi_st_printf("list_package_lists returned %ld handles\n",
+		      handles_size / sizeof(*handles));
+	free(handles);
+
+	/* STRINGS */
+	handles = NULL;
+	handles_size = 0;
+	ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+			EFI_HII_PACKAGE_STRINGS, NULL,
+			&handles_size, handles);
+	if (ret != EFI_BUFFER_TOO_SMALL) {
+		efi_st_error("list_package_lists returned %u\n", (int)ret);
+		ret = EFI_ST_FAILURE;
+		goto out;
+	}
+	handles = malloc(handles_size);
+	if (!handles) {
+		efi_st_error("malloc failed\n");
+		ret = EFI_ST_FAILURE;
+		goto out;
+	}
+	ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+			EFI_HII_PACKAGE_STRINGS, NULL,
+			&handles_size, handles);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("list_package_lists returned %u\n", (int)ret);
+		ret = EFI_ST_FAILURE;
+		goto out;
+	}
+	efi_st_printf("list_package_lists returned %ld strings handles\n",
+		      handles_size / sizeof(*handles));
+	free(handles);
+
+	/* GUID */
+	handles = NULL;
+	handles_size = 0;
+	ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+			EFI_HII_PACKAGE_TYPE_GUID, &package_guid,
+			&handles_size, handles);
+	if (ret != EFI_BUFFER_TOO_SMALL) {
+		efi_st_error("list_package_lists returned %u\n", (int)ret);
+		ret = EFI_ST_FAILURE;
+		goto out;
+	}
+	handles = malloc(handles_size);
+	if (!handles) {
+		efi_st_error("malloc failed\n");
+		ret = EFI_ST_FAILURE;
+		goto out;
+	}
+	ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+			EFI_HII_PACKAGE_TYPE_GUID, &package_guid,
+			&handles_size, handles);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("list_package_lists returned %u\n", (int)ret);
+		ret = EFI_ST_FAILURE;
+		goto out;
+	}
+	efi_st_printf("list_package_lists returned %ld guid handles\n",
+		      handles_size / sizeof(*handles));
+	free(handles);
+
+	/* KEYBOARD_LAYOUT */
+	handles = NULL;
+	handles_size = 0;
+	ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+			EFI_HII_PACKAGE_KEYBOARD_LAYOUT, NULL,
+			&handles_size, handles);
+	if (ret != EFI_BUFFER_TOO_SMALL) {
+		efi_st_error("list_package_lists returned %u\n", (int)ret);
+		ret = EFI_ST_FAILURE;
+		goto out;
+	}
+	handles = malloc(handles_size);
+	if (!handles) {
+		efi_st_error("malloc failed\n");
+		ret = EFI_ST_FAILURE;
+		goto out;
+	}
+	ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+			EFI_HII_PACKAGE_KEYBOARD_LAYOUT, NULL,
+			&handles_size, handles);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("list_package_lists returned %u\n", (int)ret);
+		ret = EFI_ST_FAILURE;
+		goto out;
+	}
+	efi_st_printf("list_package_lists returned %ld keyboard layout handles\n",
+		      handles_size / sizeof(*handles));
+	free(handles);
+
+	result = EFI_ST_SUCCESS;
+
+out:
+	if (handle1) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle1);
+		if (ret != EFI_SUCCESS)
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+	}
+	if (handle2) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle2);
+		if (ret != EFI_SUCCESS)
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+	}
+
+	return result;
+}
+
+static int test_hii_database_export_package_lists(void)
+{
+	PRINT_TESTNAME;
+	/* export_package_lists() not implemented yet */
+	return EFI_ST_SUCCESS;
+}
+
+static int test_hii_database_register_package_notify(void)
+{
+	PRINT_TESTNAME;
+	/* register_package_notify() not implemented yet */
+	return EFI_ST_SUCCESS;
+}
+
+static int test_hii_database_unregister_package_notify(void)
+{
+	PRINT_TESTNAME;
+	/* unregsiter_package_notify() not implemented yet */
+	return EFI_ST_SUCCESS;
+}
+
+static int test_hii_database_find_keyboard_layouts(void)
+{
+	efi_hii_handle_t handle1 = NULL, handle2 = NULL;
+	efi_guid_t *guids;
+	u16 guids_size;
+	efi_status_t ret;
+	int result = EFI_ST_FAILURE;
+
+	PRINT_TESTNAME;
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist1,
+			NULL, &handle1);
+	if (ret != EFI_SUCCESS || !handle1) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		goto out;
+	}
+
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist2,
+			NULL, &handle2);
+	if (ret != EFI_SUCCESS || !handle2) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		goto out;
+	}
+
+	guids = NULL;
+	guids_size = 0;
+	ret = hii_database_protocol->find_keyboard_layouts(
+			hii_database_protocol, &guids_size, guids);
+	if (ret != EFI_BUFFER_TOO_SMALL) {
+		efi_st_error("find_keyboard_layouts returned %u\n", (int)ret);
+		goto out;
+	}
+	guids = malloc(guids_size);
+	if (!guids) {
+		efi_st_error("malloc failed\n");
+		goto out;
+	}
+	ret = hii_database_protocol->find_keyboard_layouts(
+			hii_database_protocol, &guids_size, guids);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("find_keyboard_layouts returned %u\n", (int)ret);
+		goto out;
+	}
+	free(guids);
+
+	efi_st_printf("find_keyboard_layouts returned %ld guids\n",
+		      guids_size / sizeof(*guids));
+
+	result = EFI_ST_SUCCESS;
+
+out:
+	if (handle1) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle1);
+		if (ret != EFI_SUCCESS)
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+	}
+	if (handle2) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle2);
+		if (ret != EFI_SUCCESS)
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+	}
+
+	return result;
+}
+
+static int test_hii_database_get_keyboard_layout(void)
+{
+	efi_hii_handle_t handle1 = NULL, handle2 = NULL;
+	struct efi_hii_keyboard_layout *kb_layout;
+	u16 kb_layout_size;
+	efi_status_t ret;
+	int result = EFI_ST_FAILURE;
+
+	PRINT_TESTNAME;
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist1,
+			NULL, &handle1);
+	if (ret != EFI_SUCCESS || !handle1) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		goto out;
+	}
+
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist2,
+			NULL, &handle2);
+	if (ret != EFI_SUCCESS || !handle2) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		goto out;
+	}
+
+	/* specific keyboard_layout(guid11) */
+	kb_layout = NULL;
+	kb_layout_size = 0;
+	ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol,
+			&kb_layout_guid11, &kb_layout_size, kb_layout);
+	if (ret != EFI_BUFFER_TOO_SMALL) {
+		efi_st_error("get_keyboard_layout returned %u\n", (int)ret);
+		goto out;
+	}
+	kb_layout = malloc(kb_layout_size);
+	if (!kb_layout) {
+		efi_st_error("malloc failed\n");
+		goto out;
+	}
+	ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol,
+			&kb_layout_guid11, &kb_layout_size, kb_layout);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("get_keyboard_layout returned %u\n", (int)ret);
+		goto out;
+	}
+	free(kb_layout);
+
+	/* current */
+	kb_layout = NULL;
+	kb_layout_size = 0;
+	ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol,
+			NULL, &kb_layout_size, kb_layout);
+	if (ret != EFI_INVALID_PARAMETER) {
+		efi_st_error("get_keyboard_layout returned %u\n", (int)ret);
+		goto out;
+	}
+
+	result = EFI_ST_SUCCESS;
+
+out:
+	if (handle1) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle1);
+		if (ret != EFI_SUCCESS)
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+	}
+	if (handle2) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle2);
+		if (ret != EFI_SUCCESS)
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+	}
+
+	return result;
+}
+
+static int test_hii_database_set_keyboard_layout(void)
+{
+	PRINT_TESTNAME;
+	/* set_keyboard_layout() not implemented yet */
+	return EFI_ST_SUCCESS;
+}
+
+static int test_hii_database_get_package_list_handle(void)
+{
+	efi_hii_handle_t handle = NULL;
+	efi_handle_t driver_handle;
+	efi_status_t ret;
+	int result = EFI_ST_FAILURE;
+
+	PRINT_TESTNAME;
+	driver_handle = (efi_handle_t)0x12345678; /* dummy */
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist1,
+			driver_handle, &handle);
+	if (ret != EFI_SUCCESS || !handle) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		return EFI_ST_FAILURE;
+	}
+
+	driver_handle = NULL;
+	ret = hii_database_protocol->get_package_list_handle(
+			hii_database_protocol, handle, &driver_handle);
+	if (ret != EFI_SUCCESS || driver_handle != (efi_handle_t)0x12345678) {
+		efi_st_error("get_package_list_handle returned %u, driver:%p\n",
+			     (int)ret, driver_handle);
+		goto out;
+	}
+
+	result = EFI_ST_SUCCESS;
+
+out:
+	if (handle) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle);
+		if (ret != EFI_SUCCESS) {
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+			return EFI_ST_FAILURE;
+		}
+	}
+
+	return result;
+}
+
+static int test_hii_database_protocol(void)
+{
+	int ret;
+
+	ret = test_hii_database_new_package_list();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_database_update_package_list();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_database_list_package_lists();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_database_export_package_lists();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_database_register_package_notify();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_database_unregister_package_notify();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_database_find_keyboard_layouts();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_database_get_keyboard_layout();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_database_set_keyboard_layout();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_database_get_package_list_handle();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	return EFI_ST_SUCCESS;
+}
+
+/*
+ * HII string protocol Tests
+ */
+
+static int test_hii_string_new_string(void)
+{
+	efi_hii_handle_t handle = NULL;
+	efi_string_id_t id;
+	efi_status_t ret;
+	int result = EFI_ST_FAILURE;
+
+	PRINT_TESTNAME;
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist1,
+			NULL, &handle);
+	if (ret != EFI_SUCCESS || !handle) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		return EFI_ST_FAILURE;
+	}
+
+	ret = hii_string_protocol->new_string(hii_string_protocol, handle,
+					      &id, (uint8_t *)"en-US",
+					      L"Japanese", L"Japanese", NULL);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("new_string returned %u\n", (int)ret);
+		goto out;
+	}
+	efi_st_printf("new string id is %u\n", id);
+
+	result = EFI_ST_SUCCESS;
+
+out:
+	if (handle) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle);
+		if (ret != EFI_SUCCESS) {
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+			return EFI_ST_FAILURE;
+		}
+	}
+
+	return result;
+}
+
+static int test_hii_string_get_string(void)
+{
+	efi_hii_handle_t handle = NULL;
+	efi_string_id_t id;
+	efi_string_t string;
+	efi_uintn_t string_len;
+	efi_status_t ret;
+	int result = EFI_ST_FAILURE;
+
+	PRINT_TESTNAME;
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist1,
+			NULL, &handle);
+	if (ret != EFI_SUCCESS || !handle) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		return EFI_ST_FAILURE;
+	}
+
+	ret = hii_string_protocol->new_string(hii_string_protocol, handle,
+					      &id, (uint8_t *)"en-US",
+					      L"Japanese", L"Japanese", NULL);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("new_string returned %u\n", (int)ret);
+		goto out;
+	}
+
+	string = NULL;
+	string_len = 0;
+	ret = hii_string_protocol->get_string(hii_string_protocol,
+			(uint8_t *)"en-US", handle, id, string, &string_len,
+			NULL);
+	if (ret != EFI_BUFFER_TOO_SMALL) {
+		efi_st_error("get_string returned %u\n", (int)ret);
+		goto out;
+	}
+	string_len += sizeof(u16);
+	string = malloc(string_len);
+	if (!string) {
+		efi_st_error("malloc failed\n");
+		goto out;
+	}
+	ret = hii_string_protocol->get_string(hii_string_protocol,
+			(uint8_t *)"en-US", handle, id, string, &string_len,
+			NULL);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("get_string returned %u\n", (int)ret);
+		goto out;
+	}
+
+	/* TODO: %ls */
+	efi_st_printf("got string is %s\n", string);
+
+	result = EFI_ST_SUCCESS;
+
+out:
+	if (handle) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle);
+		if (ret != EFI_SUCCESS) {
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+			return EFI_ST_FAILURE;
+		}
+	}
+
+	return result;
+}
+
+static int test_hii_string_set_string(void)
+{
+	efi_hii_handle_t handle = NULL;
+	efi_string_id_t id;
+	efi_status_t ret;
+	int result = EFI_ST_FAILURE;
+
+	PRINT_TESTNAME;
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist1,
+			NULL, &handle);
+	if (ret != EFI_SUCCESS || !handle) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		return EFI_ST_FAILURE;
+	}
+
+	ret = hii_string_protocol->new_string(hii_string_protocol, handle,
+					      &id, (uint8_t *)"en-US",
+					      L"Japanese", L"Japanese", NULL);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("new_string returned %u\n", (int)ret);
+		goto out;
+	}
+
+	ret = hii_string_protocol->set_string(hii_string_protocol, handle,
+					      id, (uint8_t *)"en-US",
+					      L"Nihongo", NULL);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("set_string returned %u\n", (int)ret);
+		goto out;
+	}
+
+	result = EFI_ST_SUCCESS;
+
+out:
+	if (handle) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle);
+		if (ret != EFI_SUCCESS) {
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+			return EFI_ST_FAILURE;
+		}
+	}
+
+	return result;
+}
+
+static int test_hii_string_get_languages(void)
+{
+	efi_hii_handle_t handle = NULL;
+	u8 *languages;
+	efi_uintn_t languages_len;
+	efi_status_t ret;
+	int result = EFI_ST_FAILURE;
+
+	PRINT_TESTNAME;
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist1,
+			NULL, &handle);
+	if (ret != EFI_SUCCESS || !handle) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		return EFI_ST_FAILURE;
+	}
+
+	languages = NULL;
+	languages_len = 0;
+	ret = hii_string_protocol->get_languages(hii_string_protocol, handle,
+			languages, &languages_len);
+	if (ret != EFI_BUFFER_TOO_SMALL) {
+		efi_st_error("get_languages returned %u\n", (int)ret);
+		goto out;
+	}
+	languages = malloc(languages_len);
+	if (!languages) {
+		efi_st_error("malloc failed\n");
+		goto out;
+	}
+	ret = hii_string_protocol->get_languages(hii_string_protocol, handle,
+			languages, &languages_len);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("get_languages returned %u\n", (int)ret);
+		goto out;
+	}
+
+	efi_st_printf("got languages are %s\n", languages);
+
+	result = EFI_ST_SUCCESS;
+
+out:
+	if (handle) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle);
+		if (ret != EFI_SUCCESS) {
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+			return EFI_ST_FAILURE;
+		}
+	}
+
+	return result;
+}
+
+static int test_hii_string_get_secondary_languages(void)
+{
+	efi_hii_handle_t handle = NULL;
+	u8 *languages;
+	efi_uintn_t languages_len;
+	efi_status_t ret;
+	int result = EFI_ST_FAILURE;
+
+	PRINT_TESTNAME;
+	ret = hii_database_protocol->new_package_list(hii_database_protocol,
+			(struct efi_hii_package_list_header *)packagelist1,
+			NULL, &handle);
+	if (ret != EFI_SUCCESS || !handle) {
+		efi_st_error("new_package_list returned %u\n", (int)ret);
+		return EFI_ST_FAILURE;
+	}
+
+	languages = NULL;
+	languages_len = 0;
+	ret = hii_string_protocol->get_secondary_languages(hii_string_protocol,
+			handle, (uint8_t *)"en-US", languages, &languages_len);
+	if (ret == EFI_NOT_FOUND) {
+		efi_st_printf("no secondary languages\n");
+		result = EFI_ST_SUCCESS;
+		goto out;
+	}
+	if (ret != EFI_BUFFER_TOO_SMALL) {
+		efi_st_error("get_secondary_languages returned %u\n", (int)ret);
+		goto out;
+	}
+	languages = malloc(languages_len);
+	if (!languages) {
+		efi_st_error("malloc failed\n");
+		goto out;
+	}
+	ret = hii_string_protocol->get_secondary_languages(hii_string_protocol,
+			handle, (uint8_t *)"en-US", languages, &languages_len);
+	if (ret != EFI_SUCCESS) {
+		efi_st_error("get_secondary_languages returned %u\n", (int)ret);
+		goto out;
+	}
+
+	efi_st_printf("got secondary languages are %s\n", languages);
+
+	result = EFI_ST_SUCCESS;
+
+out:
+	if (handle) {
+		ret = hii_database_protocol->remove_package_list(
+				hii_database_protocol, handle);
+		if (ret != EFI_SUCCESS) {
+			efi_st_error("remove_package_list returned %u\n",
+				     (int)ret);
+			return EFI_ST_FAILURE;
+		}
+	}
+
+	return result;
+}
+
+static int test_hii_string_protocol(void)
+{
+	int ret;
+
+	ret = test_hii_string_new_string();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_string_get_string();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_string_set_string();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_string_get_languages();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	ret = test_hii_string_get_secondary_languages();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	return EFI_ST_SUCCESS;
+}
+
+/*
+ * Execute unit test.
+ *
+ * @return:	EFI_ST_SUCCESS for success, EFI_ST_FAILURE for failure
+ */
+static int execute(void)
+{
+	int ret;
+
+	/* HII database protocol */
+	ret = test_hii_database_protocol();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	/* HII string protocol */
+	ret = test_hii_string_protocol();
+	if (ret != EFI_ST_SUCCESS)
+		return EFI_ST_FAILURE;
+
+	return EFI_ST_SUCCESS;
+}
+
+EFI_UNIT_TEST(hii) = {
+	.name = "HII database protocols",
+	.phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
+	.setup = setup,
+	.execute = execute,
+};
diff --git a/lib/efi_selftest/efi_selftest_hii_data.c b/lib/efi_selftest/efi_selftest_hii_data.c
new file mode 100644
index 000000000000..2000a9315960
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_hii_data.c
@@ -0,0 +1,450 @@ 
+// SPDX-License-Identifier:     GPL-2.0+
+/*
+ * This file's test data is derived from UEFI SCT.
+ * The original copyright is attached below.
+ */
+
+/** @file
+
+  Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <efi.h>
+
+/* FIXME: define them elsewhere */
+#if 0
+/* HII form */
+#define EFI_IFR_AND_OP			0x15
+#define EFI_IFR_END_OP			0x29
+#define EFI_IFR_BITWISE_AND_OP		0x35
+
+/* HII image */
+#define EFI_HII_IIBT_END		0x00
+#define EFI_HII_IIBT_IMAGE_1BIT		0x10
+#endif
+
+/* HII keyboard layout */
+#define EFI_NULL_MODIFIER		0x0000
+
+u8 packagelist1[] = {
+	// EFI_HII_PACKAGE_LIST_HEADER, length = 20
+	// SimpleFont, Font, GUID, Form, String, Image, DevicePath,
+	// (74)        (110) 20    (8)   78      (67)   (8)
+	// KeyboardLayout, End
+	// 192             4
+
+	0x89, 0xcd, 0xab, 0x03, 0xf4, 0x03, 0x44, 0x70,
+	0x81, 0xde, 0x99, 0xb1, 0x81, 0x20, 0xf7, 0x68,	//16: guid
+	0x3a, 0x01, 0x00, 0x00,				// 4: total 314(0x13a)
+#if 0
+	//
+	// Simple Font Package 1, length = 74
+	//
+	0x4A, 0x00, 0x00,
+	EFI_HII_PACKAGE_SIMPLE_FONTS,
+	1, 0,
+	1, 0,
+	0x55, 0x0, 0x1,
+	1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+	0x77, 0x0, 0x2,
+	2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
+	3, 4, 5,
+	6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 0, 0, 0,
+	//
+	// Font Package 1, length = 110
+	//
+	0x6e, 0x00, 0x00,				// 3
+	EFI_HII_PACKAGE_FONTS,				// 1
+	0x5c, 0x00, 0x00, 0x00,				// 4: size of header
+	0x5c, 0x00, 0x00, 0x00,				// 4: offset
+	0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00,
+	0xf5, 0x00, 0xec, 0xec,				//10+2(pads)
+	0xff, 0x33, 0xff, 0x44,				// 4: font style
+	0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66,	//64
+	//
+	// Glyph block  1, length = 18
+	//
+	EFI_HII_GIBT_GLYPH_DEFAULT,			// 1
+	0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x99,
+	0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,	//16: BitMapData
+	EFI_HII_GIBT_END,				// 1
+#endif
+	//
+	// Guid Package 1, length = 20
+	//
+	0x14, 0x00, 0x00,				// 3
+	EFI_HII_PACKAGE_TYPE_GUID,			// 1
+	0x5a, 0xc9, 0x87, 0x03, 0x3, 0xd7, 0x46, 0x23,
+	0xb2, 0xab, 0xd0, 0xc7, 0xdd, 0x90, 0x44, 0xf8,	//16: guid
+#if 0
+	//
+	// EFI_HII_PACKAGE_FORMS, length = 8
+	//
+	0x08, 0x00, 0x00,				// 3
+	EFI_HII_PACKAGE_FORMS,				// 1
+	//
+	// Opcode 1, length = 4
+	//
+	EFI_IFR_AND_OP,
+	0x82,
+	EFI_IFR_END_OP,
+	0x02,
+	//
+#endif
+	// EFI_HII_PACKAGE_STRINGS, length = 78
+	//
+	0x4e, 0x00, 0x00,				// 3: length(header)
+	EFI_HII_PACKAGE_STRINGS,			// 1: type(header)
+	0x3c, 0x00, 0x00, 0x00,				// 4: header_size
+	0x3c, 0x00, 0x00, 0x00,				// 4: string_offset
+	0x00, 0x00, 0x11, 0x22, 0x44, 0x55, 0x77, 0x89,	//32: language_window
+	0x11, 0x00, 0x11, 0x22, 0x44, 0x55, 0x87, 0x89,
+	0x22, 0x00, 0x11, 0x22, 0x44, 0x55, 0x77, 0x89,
+	0x33, 0x00, 0x11, 0x22, 0x44, 0x55, 0x77, 0x89,
+	0x01, 0x00,					// 2: language name
+	0x65, 0x6e, 0x2d, 0x55, 0x53, 0x3b, 0x7a, 0x68, //14: language
+	0x2d, 0x48, 0x61, 0x6e, 0x74, 0x00,		//    "en-US;zh-Hant"
+	EFI_HII_SIBT_STRING_UCS2,			// 1
+	0x45,  0x00,  0x6E,  0x00,  0x67,  0x00,  0x6C, 0x00,
+	0x69,  0x00,  0x73,  0x00,  0x68,  0x00,  0x00, 0x00,	//16: "English"
+	EFI_HII_SIBT_END,				// 1
+#if 0
+	//
+	// EFI_HII_PACKAGE_IMAGES, length = 67
+	//
+	0x43, 0x00, 0x00,			// 3
+	EFI_HII_PACKAGE_IMAGES,			// 1
+	0x0c, 0x00, 0x00, 0x00,			// 4: image info offset
+	0x39, 0x00, 0x00, 0x00,			// 4: palette info offset
+	EFI_HII_IIBT_IMAGE_1BIT,		// 1
+	0x01,
+	0x0b, 0x00,
+	0x13, 0x00,
+	0x80, 0x00,
+	0xc0, 0x00,
+	0xe0, 0x00,
+	0xf0, 0x00,
+	0xf8, 0x00,
+	0xfc, 0x00,
+	0xfe, 0x00,
+	0xff, 0x00,
+	0xff, 0x80,
+	0xff, 0xc0,
+	0xff, 0xe0,
+	0xfe, 0x00,
+	0xef, 0x00,
+	0xcf, 0x00,
+	0x87, 0x80,
+	0x07, 0x80,
+	0x03, 0xc0,
+	0x03, 0xc0,
+	0x01, 0x80,				//43
+	EFI_HII_IIBT_END,			// 1
+	0x01, 0x00,
+	0x06, 0x00,
+	0x00, 0x00, 0x00,
+	0xFF, 0xFF, 0xFF,			//10
+	//
+	// EFI_HII_PACKAGE_DEVICE_PATH, length = 8
+	//
+	0x08, 0x00, 0x00,			// 3
+	EFI_HII_PACKAGE_DEVICE_PATH,		// 1
+	0x01, 0x23, 0x45, 0x66,			// 4: dummy device path protocol
+						//    instance address
+#endif
+	//
+	// Keyboard layout package 1, length = 192
+	0xc0, 0x00, 0x00,			// 3: length(header)
+	EFI_HII_PACKAGE_KEYBOARD_LAYOUT,	// 1: type(header)
+	0x02, 0x00,				// 2: LayoutCount
+	//
+	// Layout 1, length = 93
+	//
+	0x5d, 0x00,				// 2: layout_length
+	0x95, 0xe4, 0x40, 0x8d, 0xaa, 0xe2, 0x6f, 0x4c,
+	0x89, 0x70, 0x68, 0x85, 0x09, 0xee, 0xc7, 0xd2, //16: guid
+	0x37, 0x00, 0x00, 0x00,			// 4: layout_descriptor_
+						//        string_offset
+	0x02,					// 1: descriptor_count
+	//
+	// Descriptor 1, length = 16
+	//
+	49 /*EfiKeyD1*/, 0x00, 0x00, 0x00,	// 4: key
+	'q', 0x00,				// 2: unicode
+	'Q', 0x00,				// 2: shifted_unicode
+	0x00, 0x00,				// 2: alt_gr_unicode
+	0x00, 0x00,				// 2: shifted_alt_gr_unicode
+	EFI_NULL_MODIFIER, 0x00,		// 2: modifier
+	0x03, 0x00,				// 2: affected_attribute
+	//
+	// Descriptor 2,  length = 16
+	//
+	50 /*EfiKeyD2*/, 0x00, 0x00, 0x00,	// 4: key
+	'w', 0x00,				// 2: unicode
+	'W', 0x00,				// 2: shifted_unicode
+	0x00, 0x00,				// 2: alt_gr_unicode
+	0x00, 0x00,				// 2: shifted_alt_gr_unicode
+	EFI_NULL_MODIFIER, 0x00,		// 2: modifier
+	0x3, 0x0,				// 2: affected_attribute
+	//
+	// EFI_DESCRIPTOR_STRING_BUNDLE, length = 38
+	//
+	0x01, 0x00,				// 2: DescriptionCount
+	'e', 0x0, 'n', 0x0, '-', 0x0, 'U', 0x0, 'S', 0x0,
+						//10: RFC3066 language code
+	' ', 0x0,				// 2: Space
+	'S', 0x0, 'i', 0x0, 'm', 0x0, 'p', 0x0, 'l', 0x0, 'e', 0x0,
+	'1', 0x0, 'o', 0x0, 'n', 0x0, 'l', 0x0, 'y', 0x0, '\0', 0x0,
+						//24: DescriptionString
+	//
+	// Layout 2, length = 93
+	//
+	0x5d, 0x00,				// 2: layout_length
+	0x3e, 0x0b, 0xe6, 0x2a, 0xd6, 0xb9, 0xd8, 0x49,
+	0x9a, 0x16, 0xc2, 0x48, 0xf1, 0xeb, 0xa8, 0xdb,	//16: guid
+	0x37, 0x00, 0x00, 0x00,			// 4: layout_descriptor_
+						//    string_offset
+	0x02,					// 1 Descriptor count
+	//
+	// Descriptor 1, length = 16
+	//
+	51 /*EfiKeyD3*/, 0x0, 0x0, 0x0,		// 4: key
+	'e', 0x00,				// 2: unicode
+	'E', 0x00,				// 2: shifted_unicode
+	0x00, 0x00,				// 2: alt_gr_unicode
+	0x00, 0x00,				// 2: shifted_alt_gr_unicode
+	EFI_NULL_MODIFIER, 0x0,			// 2: modifier
+	0x3, 0x0,				// 2: affected_attribute
+	//
+	// Descriptor 2,  length = 16
+	//
+	52 /*EfiKeyD4*/, 0x0, 0x0, 0x0,		// 4: key
+	'r', 0x00,				// 2: unicode
+	'R', 0x00,				// 2: shifted_unicode
+	0x00, 0x00,				// 2: alt_gr_unicode
+	0x00, 0x00,				// 2: shifted_alt_gr_unicode
+	EFI_NULL_MODIFIER, 0x0,			// 2: modifier
+	0x3, 0x0,				// 2: affected_attribute
+	//
+	// EFI_DESCRIPTOR_STRING_BUNDLE, length = 38
+	//
+	0x01, 0x00,				// 2: DescriptionCount
+	'e', 0x0, 'n', 0x0, '-', 0x0, 'U', 0x0, 'S', 0x0,
+						//10: RFC3066 language code
+	' ', 0x0,				// 2: Space
+	'S', 0x0, 'i', 0x0, 'm', 0x0, 'p', 0x0, 'l', 0x0, 'e', 0x0,
+	'2', 0x0, 'o', 0x0, 'n', 0x0, 'l', 0x0, 'y', 0x0, '\0', 0x0,
+						//24: DescriptionString
+	//
+	// End of package list, length = 4
+	//
+	0x4, 0x00, 0x00,
+	EFI_HII_PACKAGE_END
+};
+
+u8 packagelist2[] = {
+	// EFI_HII_PACKAGE_LIST_HEADER, length = 20
+	// SimpleFont, Font, GUID, KeyboardLayout, Form, End
+	// (74)        (122) 20    192             (8)   4
+	0xd3, 0xde, 0x85, 0x86, 0xce, 0x1b, 0xf3, 0x43,
+	0xa2, 0x0c, 0xa3, 0x06, 0xec, 0x69, 0x72, 0xdd,	//16
+	0xec, 0x00, 0x00, 0x00,				// 4: total 236(0xec)
+
+#if 0
+	//
+	// Simple Font Package 2, length = 74
+	//
+	0x4A, 0x00, 0x00,				// 3
+	EFI_HII_PACKAGE_SIMPLE_FONTS,			// 1
+	1, 0,						// 2
+	1, 0,						// 2
+	0x33, 0x0, 0, 1, 2, 3, 4, 5, 0, 7, 8, 9,
+	10, 11, 12, 13, 14, 15, 16, 17, 18, 19,		//22
+	0x44, 0x0, 0x2, 2, 3, 4, 5, 6, 0, 8, 9,
+	10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,	//22
+	3, 4, 5, 6, 7, 8, 9, 10, 11, 9, 13,
+	14, 15, 16, 17, 18, 19, 20, 21, 0, 0, 0,	//22
+	//
+	// Font Package 2, length = 122
+	//
+	0x7A, 0x00, 0x00,				// 3
+	EFI_HII_PACKAGE_FONTS,				// 1
+	0x5C, 0x00, 0x00, 0x00,				// 4: size of header
+	0x5C, 0x00, 0x00, 0x00,				// 4: dummy offset
+	0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00,
+	0xf5, 0x00, 0xec, 0xec,				//10+2(pads)
+	0xff, 0x11, 0xff, 0x22,				// 4: font style
+	0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88,	//64
+	//
+	// Glyph block  1, length = 30
+	//
+	EFI_HII_GIBT_GLYPH,				// 1
+	0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00,
+	0xf5, 0x00,					//10
+	0xff, 0x01,					// 2
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,	//16: BitMapData
+	EFI_HII_GIBT_END,				// 1
+#endif
+	//
+	// Guid Package 1, length = 20
+	//
+	0x14, 0x00, 0x00,				// 3
+	EFI_HII_PACKAGE_TYPE_GUID,			// 1
+	0x5a, 0xc9, 0x87, 0x03, 0x3, 0xd7, 0x46, 0x23,
+	0xb2, 0xab, 0xd0, 0xc7, 0xdd, 0x90, 0x44, 0xf8,	//16: guid
+	//
+	// Keyboard layout package 2, length = 192
+	0xc0, 0x00, 0x00,			// 3
+	EFI_HII_PACKAGE_KEYBOARD_LAYOUT,	// 1
+	0x02, 0x00, //0xec, 0xec,		// 2: LayoutCount
+	//
+	// Layout 1, length = 93
+	//
+	0x5d, 0x00,					// 2: layout_length
+	0x1f, 0x6a, 0xf5, 0xe0, 0x6b, 0xdf, 0x7e, 0x4a,
+	 0xa3, 0x9a, 0xe7, 0xa5, 0x19, 0x15, 0x45, 0xd6,//16: guid
+	0x37, 0x00, 0x00, 0x00,				// 4: layout_descriptor
+							//    string offset
+	0x02,						// 1: descriptor_count
+	//
+	// Descriptor 1, length = 16
+	//
+	32 /*EfiKeyC1*/, 0x00, 0x00, 0x00,	// 4: key
+	'a', 0x00,				// 2: unicode
+	'A', 0x00,				// 2: shifted_unicode
+	0x00, 0x00,				// 2: alt_gr_unicode
+	0x00, 0x00,				// 2: shifted_alt_gr_unic
+	EFI_NULL_MODIFIER, 0x00,		// 2: modifier
+	0x03, 0x00,				// 2: affected_attribute
+	//
+	// Descriptor 2,  length = 16
+	//
+	33 /*EfiKeyC2*/, 0x00, 0x00, 0x00,
+	's', 0x00,
+	'S', 0x00,
+	0x00, 0x00,
+	0x00, 0x00,
+	EFI_NULL_MODIFIER, 0x00,
+	0x3, 0x0,
+	//
+	// EFI_DESCRIPTOR_STRING_BUNDLE, length = 38
+	//
+	0x01, 0x00,				// 2: DescriptionCount
+	'e', 0x0, 'n', 0x0, '-', 0x0, 'U', 0x0, 'S', 0x0,
+						//10: RFC3066 language code
+	' ', 0x0,				// 2: Space
+	'S', 0x0, 'i', 0x0, 'm', 0x0, 'p', 0x0, 'l', 0x0, 'e', 0x0,
+	'3', 0x0, 'o', 0x0, 'n', 0x0, 'l', 0x0, 'y', 0x0, '\0', 0x0,
+						//24: DescriptionString
+	//
+	// Layout 2, length = 93
+	//
+	0x5d, 0x00,					// 2: layout_length
+	0xc9, 0x6a, 0xbe, 0x47, 0xcc, 0x54, 0xf9, 0x46,
+	0xa2, 0x62, 0xd5, 0x3b, 0x25, 0x6a, 0xc, 0x34,	//16: guid
+	0x37, 0x00, 0x00, 0x00,				// 4: layout_descriptor
+							//    string_offset
+	0x02,						// 1: descriptor_count
+	//
+	// Descriptor 1, length = 16
+	//
+	34 /*EfiKeyC3*/, 0x0, 0x0, 0x0,
+	'd', 0x00,
+	'D', 0x00,
+	0x00, 0x00,
+	0x00, 0x00,
+	EFI_NULL_MODIFIER, 0x0,
+	0x3, 0x0,
+	//
+	// Descriptor 2,  length = 16
+	//
+	35 /*EfiKeyC4*/, 0x0, 0x0, 0x0,
+	'e', 0x00,
+	'E', 0x00,
+	0x00, 0x00,
+	0x00, 0x00,
+	EFI_NULL_MODIFIER,  0x0,
+	0x3, 0x0,
+	//
+	// EFI_DESCRIPTOR_STRING_BUNDLE, length = 38
+	//
+	0x01, 0x00,				// 2: DescriptionCount
+	'e', 0x0, 'n', 0x0, '-', 0x0, 'U', 0x0, 'S', 0x0,
+						//10: RFC3066 language code
+	' ', 0x0,				// 2: Space
+	'S', 0x0, 'i', 0x0, 'm', 0x0, 'p', 0x0, 'l', 0x0, 'e', 0x0,
+	'4', 0x0, 'o', 0x0, 'n', 0x0, 'l', 0x0, 'y', 0x0, '\0', 0x0,
+						//24: DescriptionString
+#if 0
+	//
+	// EFI_HII_PACKAGE_FORMS, length = 8
+	//
+	0x08, 0x00, 0x00,			// 3
+	EFI_HII_PACKAGE_FORMS,			// 1
+	//
+	// Opcode 1
+	//
+	EFI_IFR_BITWISE_AND_OP,			// 1
+	0x02,					// 1
+	EFI_IFR_END_OP,				// 1
+	0x02,					// 1
+#endif
+	//
+	// End of package list, length = 4
+	//
+	0x4, 0x00, 0x00,			// 3
+	EFI_HII_PACKAGE_END			// 1
+};
+
+efi_guid_t packagelist_guid1 =
+	EFI_GUID(0x03abcd89, 0x03f4, 0x7044,
+		 0x81, 0xde, 0x99, 0xb1, 0x81, 0x20, 0xf7, 0x68);
+
+efi_guid_t packagelist_guid2 =
+	EFI_GUID(0x8685ded3, 0x1bce, 0x43f3,
+		 0xa2, 0x0c, 0xa3, 0x06, 0xec, 0x69, 0x72, 0xdd);
+
+efi_guid_t kb_layout_guid11 =
+	EFI_GUID(0x8d40e495, 0xe2aa, 0x4c6f,
+		 0x89, 0x70, 0x68, 0x85, 0x09, 0xee, 0xc7, 0xd2);
+
+efi_guid_t kb_layout_guid12 =
+	EFI_GUID(0x2ae60b3e, 0xb9d6, 0x49d8,
+		 0x9a, 0x16, 0xc2, 0x48, 0xf1, 0xeb, 0xa8, 0xdb);
+
+efi_guid_t kb_layout_guid21 =
+	EFI_GUID(0xe0f56a1f, 0xdf6b, 0x4a7e,
+		 0xa3, 0x9a, 0xe7, 0xa5, 0x19, 0x15, 0x45, 0xd6);
+
+efi_guid_t kb_layout_guid22 =
+	EFI_GUID(0x47be6ac9, 0x54cc, 0x46f9,
+		 0xa2, 0x62, 0xd5, 0x3b, 0x25, 0x6a, 0x0c, 0x34);
+
+efi_guid_t package_guid =
+	EFI_GUID(0x0387c95a, 0xd703, 0x2346,
+		 0xb2, 0xab, 0xd0, 0xc7, 0xdd, 0x90, 0x44, 0xf8);