From patchwork Tue Oct 17 22:02:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827325 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGq472JJjz9s7g for ; Wed, 18 Oct 2017 09:04:55 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 1D1F9C21E43; Tue, 17 Oct 2017 22:04:14 +0000 (UTC) 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, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B7334C21E1E; Tue, 17 Oct 2017 22:03:13 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 69FD0C21DA1; Tue, 17 Oct 2017 22:03:10 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id E61D4C21CB6 for ; Tue, 17 Oct 2017 22:03:09 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Lg6op-1dSz150E27-00pfcf; Wed, 18 Oct 2017 00:03:08 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:27 +0200 Message-Id: <20171017220244.8549-2-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:2YbihTQt5U61FV1jqkLad76dV7DHjqIV5z+jkViO30IVJZUV0i9 Fzx1ZkiTNA8vMz0zFWch914JqbZm08BRuiW0yoeMebyrGnMYsVh/60kwotsqBpWIdFAMwom fQugS1e44qpVaroN5P0zBjCuqU/YXH64OkRDLlJuFVA/Q4SvVOvWSTst5bdfQrKHdgA81u7 3D5z0VHXRYwgfCMJmenLQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:fbyiGReJm2g=:fOp8XRxSDrzZl0mdCTypyc DmkwCSiDBChbBBC6uDFJkhKSbdsNJ4ESY9gDaBc7T6CzqXFzqY5kbT8LWICnaGxJasgNCdTi3 L7RHMFg58hhtFHED9dOKGtSNJdLzccw1F1BT0kdNBxD9/OVbDzc0VoUlL5rfnTjkEvWsr9zQT 7CgNGqIjOpE0DRHe8No7r3nyFngiHp+ItuUKL8uBxWiSvtFJs2higf8+r0UtZLpEd7ks9+9+i RH5W1jKh6HQZD8SRSQ03jleRHWGMDWJ1ybep5KVATpN0sMldLFsJu4uSyoLo3ajI1iqghM3H+ WOkaJXHSusBwwauK3IjmVclc1+x5LJq0LOPW1tcRm8sz+Rh2KDsd6NsWePwMhY6CZJ1k5m8US 2XUIHXGq6n0uv19G1odh+/N/zndPxQKHA+7XLaxctMqvyadPN/xZdRkWmmj7nq7Y5SBrmoOHR KesmENGMhH54AqLnDsr5ioIjm7QLCL7UKdzS+E9hG8xYmHMDvPPH/KbtPAxwEplsGvY0avVD8 k+gL4ykUD9lk+zmBQrLtz4S9cIgwBIwyqN1+hcXYZ0qsPrD6QLMUvjdwT9vrxfHXHkYHRpBJ9 FEb3NZoMzQtQDfLL+KM6nQWy1+BQz33cEKAy1soIBRtRVvdDaZ7/SEWPSOJ1XECWwOYpGEWE8 z8nXUYVPW8KzA2kjjy1yPmO+8zfeYf9v2/+3Tv36aSlXjS+HS9NUonb+Q/WyK1OeezpBjypqA fNvpwmLnq/kZBZCzUmTmE4bF5IHhzZ/8qQJGrrsK15oxxMaDHlDqWU/9JRAi0RUj+R6jamEBA reU/pfuxpCcZmQDvggOdbONIDXz2A== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 01/18] efi_loader: move efi_search_obj up in code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" To avoid a forward declaration move efi_search_obj before all protocol services functions. Signed-off-by: Heinrich Schuchardt --- v3 no change v2 no change --- lib/efi_loader/efi_boottime.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index f627340de4..30577f717e 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -690,6 +690,27 @@ static efi_status_t EFIAPI efi_check_event(struct efi_event *event) return EFI_EXIT(EFI_INVALID_PARAMETER); } +/* + * Find the internal EFI object for a handle. + * + * @handle handle to find + * @return EFI object + */ +static struct efi_object *efi_search_obj(void *handle) +{ + struct list_head *lhandle; + + list_for_each(lhandle, &efi_obj_list) { + struct efi_object *efiobj; + + efiobj = list_entry(lhandle, struct efi_object, link); + if (efiobj->handle == handle) + return efiobj; + } + + return NULL; +} + /* * Install protocol interface. * @@ -1355,26 +1376,6 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle, panic("EFI application exited"); } -/* - * Find the internal EFI object for a handle. - * - * @handle handle to find - * @return EFI object - */ -static struct efi_object *efi_search_obj(void *handle) -{ - struct list_head *lhandle; - - list_for_each(lhandle, &efi_obj_list) { - struct efi_object *efiobj; - efiobj = list_entry(lhandle, struct efi_object, link); - if (efiobj->handle == handle) - return efiobj; - } - - return NULL; -} - /* * Unload an EFI image. * From patchwork Tue Oct 17 22:02:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827323 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGq2M1ZT6z9s7g for ; Wed, 18 Oct 2017 09:03:21 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 94ED6C21E85; Tue, 17 Oct 2017 22:03:14 +0000 (UTC) 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, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 6BD08C21DA1; Tue, 17 Oct 2017 22:03:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 406E9C21DA0; Tue, 17 Oct 2017 22:03:10 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id E80D7C21D8D for ; Tue, 17 Oct 2017 22:03:09 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MYcJi-1dhuN41Vb8-00VNoW; Wed, 18 Oct 2017 00:03:08 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:28 +0200 Message-Id: <20171017220244.8549-3-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:fEw2zf4lirBwCThUzXdSOCkrPlu/WZb+35hKl6tEMeKxfyVkVOk uhG+BlHDZxz1UtQQnhZdrDjb8MVBOonXOaAs6HpKS8nrSoYQYmdgW/TDBPPCI8ilumCzt6D WE/DrD5gZRHw/mkPnEUFWjn3Mh3RdF11795hJRjq5vmZ2kFba727ZAxCgLljQFQ0VReLclD o3p39RM8BuOZERuoeKXgw== X-UI-Out-Filterresults: notjunk:1; V01:K0:8O8T+LdA/dQ=:Jjs0f3nqyZoaQQuWd5Kr8J IC+Nbo2JyzYiajxoA9o/W3BRORyIwj6iX4lLII0/zJbq19BR7NbM6ngICRiKFjcjO9osSxkoy rNxTR0Fyuhg6QtIkBQRzty6SGtleGx0PpXDH6guihMpd0LbiFIaVaHE9XtFv47QahVxGnxfuM +Xmc2q2cPNSvA4LRGxprBa5WLE3c4ceO2vWwuJ7TQedfQbwBXZeZB27tlsoC0dcSpaUFXrtoN onGmMM01Ek9LnTdNoDHD/+NMNvG2wdWKV+rGHWpFu5f0j2/XaWPzRRcuyybfieq/oHjvCe4JR PF8f9WkuKkYLWiHuiD5dG4lxcLJiWDE21li+qQDy3Ywv+nXQBTfPWk1RruwgH/EGYrxL6jDlY +YxCq994mgS558/PPZSDqZHU4g4S68ufArizen2Fwyd5ULww7pRY1AY1Um/PTgsW4Cjpk+59f /Z6fr0HAW3CrmpsExDzdObZY4YkCuNL5Stw35lIxtKKFasOuOJvqtzj1hynwku67ehq7OMYKA hl9KWvIrw3N++HmfzFzDE8bCRWkLV63A0r2DzZZdJw3cnwEEjOkMB5ebcwC4ikHiuEWSajxTf gHrbHW0SmsnK4yDp1mRjftO0oD9KbjIIpIw+i6UpjMSOff34cJRbj7K9oxr8KQqkwZ2VSIYiP 9DgyCZSy1F/+h0qZMO7fRf6QJZwSAbl4Sv4oQ8oAVwK9Rna/karDtqNFIWrI8d1Wu5BuwEiNh x4GkWWF8Ftq9CL4PkCGxztesRyCe6OHAN0dxcKTBB4oRtuAn4YvxLYDmEbf4HEDy6fw54lUUS wIZ9Cml1MQEHcdBzyRFFUJqs/9sjQ== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 02/18] efi_loader: implement SetWatchdogTimer X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The watchdog is initialized with a 5 minute timeout period. It can be reset by SetWatchdogTimer. It is stopped by ExitBoottimeServices. Signed-off-by: Heinrich Schuchardt --- v3 add a constant for 1s to 100ns conversion v2 code comments updated --- cmd/bootefi.c | 1 + include/efi_loader.h | 4 ++ lib/efi_loader/Makefile | 2 +- lib/efi_loader/efi_boottime.c | 17 ++------- lib/efi_loader/efi_watchdog.c | 89 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 15 deletions(-) create mode 100644 lib/efi_loader/efi_watchdog.c diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 478bc116e2..18176a1266 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -43,6 +43,7 @@ static void efi_init_obj_list(void) #ifdef CONFIG_GENERATE_SMBIOS_TABLE efi_smbios_register(); #endif + efi_watchdog_register(); /* Initialize EFI runtime services */ efi_reset_system_init(); diff --git a/include/efi_loader.h b/include/efi_loader.h index 1b92edbd77..af64b11cee 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -163,6 +163,8 @@ int efi_disk_register(void); int efi_gop_register(void); /* Called by bootefi to make the network interface available */ int efi_net_register(void); +/* Called by bootefi to make the watchdog available */ +int efi_watchdog_register(void); /* Called by bootefi to make SMBIOS tables available */ void efi_smbios_register(void); @@ -171,6 +173,8 @@ efi_fs_from_path(struct efi_device_path *fp); /* Called by networking code to memorize the dhcp ack package */ void efi_net_set_dhcp_ack(void *pkt, int len); +/* Called by efi_set_watchdog_timer to reset the timer */ +efi_status_t efi_set_watchdog(unsigned long timeout); /* Called from places to check whether a timer expired */ void efi_timer_check(void); diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index ddb978f650..83d879b686 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -17,7 +17,7 @@ endif obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o obj-y += efi_image_loader.o efi_boottime.o efi_runtime.o efi_console.o obj-y += efi_memory.o efi_device_path_to_text.o efi_device_path.o -obj-y += efi_file.o efi_variable.o efi_bootmgr.o +obj-y += efi_file.o efi_variable.o efi_bootmgr.o efi_watchdog.o obj-$(CONFIG_LCD) += efi_gop.o obj-$(CONFIG_DM_VIDEO) += efi_gop.o obj-$(CONFIG_PARTITIONS) += efi_disk.o diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 30577f717e..fd8d15655b 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -155,18 +155,6 @@ void efi_signal_event(struct efi_event *event) event->is_queued = false; } -/* - * Write a debug message for an EPI API service that is not implemented yet. - * - * @funcname function that is not yet implemented - * @return EFI_UNSUPPORTED - */ -static efi_status_t efi_unsupported(const char *funcname) -{ - debug("EFI: App called into unimplemented function %s\n", funcname); - return EFI_EXIT(EFI_UNSUPPORTED); -} - /* * Raise the task priority level. * @@ -1454,6 +1442,7 @@ static efi_status_t EFIAPI efi_exit_boot_services(void *image_handle, bootm_disable_interrupts(); /* Give the payload some time to boot */ + efi_set_watchdog(0); WATCHDOG_RESET(); return EFI_EXIT(EFI_SUCCESS); @@ -1497,7 +1486,7 @@ static efi_status_t EFIAPI efi_stall(unsigned long microseconds) /* * Reset the watchdog timer. * - * This function implements the WatchdogTimer service. + * This function implements the SetWatchdogTimer service. * See the Unified Extensible Firmware Interface (UEFI) specification * for details. * @@ -1514,7 +1503,7 @@ static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout, { EFI_ENTRY("%ld, 0x%"PRIx64", %ld, %p", timeout, watchdog_code, data_size, watchdog_data); - return efi_unsupported(__func__); + return EFI_EXIT(efi_set_watchdog(timeout)); } /* diff --git a/lib/efi_loader/efi_watchdog.c b/lib/efi_loader/efi_watchdog.c new file mode 100644 index 0000000000..35a45dedf8 --- /dev/null +++ b/lib/efi_loader/efi_watchdog.c @@ -0,0 +1,89 @@ +/* + * EFI watchdog + * + * Copyright (c) 2017 Heinrich Schuchardt + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include + +/* Conversion factor from seconds to multiples of 100ns */ +#define EFI_SECONDS_TO_100NS 10000000ULL + +static struct efi_event *watchdog_timer_event; + +/* + * Reset the system when the watchdog event is notified. + * + * @event: the watchdog event + * @context: not used + */ +static void EFIAPI efi_watchdog_timer_notify(struct efi_event *event, + void *context) +{ + EFI_ENTRY("%p, %p", event, context); + + printf("\nEFI: Watchdog timeout\n"); + EFI_CALL_VOID(efi_runtime_services.reset_system(EFI_RESET_COLD, + EFI_SUCCESS, 0, NULL)); + + EFI_EXIT(EFI_UNSUPPORTED); +} + +/* + * Reset the watchdog timer. + * + * This function is used by the SetWatchdogTimer service. + * + * @timeout: seconds before reset by watchdog + * @return: status code + */ +efi_status_t efi_set_watchdog(unsigned long timeout) +{ + efi_status_t r; + + if (timeout) + /* Reset watchdog */ + r = efi_set_timer(watchdog_timer_event, EFI_TIMER_RELATIVE, + EFI_SECONDS_TO_100NS * timeout); + else + /* Deactivate watchdog */ + r = efi_set_timer(watchdog_timer_event, EFI_TIMER_STOP, 0); + return r; +} + +/* + * Initialize the EFI watchdog. + * + * This function is called by efi_init_obj_list() + */ +int efi_watchdog_register(void) +{ + efi_status_t r; + + /* + * Create a timer event. + */ + r = efi_create_event(EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, + efi_watchdog_timer_notify, NULL, + &watchdog_timer_event); + if (r != EFI_SUCCESS) { + printf("ERROR: Failed to register watchdog event\n"); + return r; + } + /* + * The UEFI standard requires that the watchdog timer is set to five + * minutes when invoking an EFI boot option. + * + * Unified Extensible Firmware Interface (UEFI), version 2.7 Errata A + * 7.5. Miscellaneous Boot Services - EFI_BOOT_SERVICES.SetWatchdogTimer + */ + r = efi_set_watchdog(300); + if (r != EFI_SUCCESS) { + printf("ERROR: Failed to set watchdog timer\n"); + return r; + } + return 0; +} From patchwork Tue Oct 17 22:02:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827327 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGq5L0lGKz9s7g for ; Wed, 18 Oct 2017 09:05:58 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id B7927C21E57; Tue, 17 Oct 2017 22:04:30 +0000 (UTC) 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, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D46E3C21E63; Tue, 17 Oct 2017 22:03:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C3F64C21D8D; Tue, 17 Oct 2017 22:03:10 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 801CCC21CB6 for ; Tue, 17 Oct 2017 22:03:10 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MPIvU-1e8xfI2pDk-004TII; Wed, 18 Oct 2017 00:03:08 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:29 +0200 Message-Id: <20171017220244.8549-4-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:10FOGAni9y3r/E1LDUNgVIe0OmWkHsUfV+z1+zBWaAM3AoGSw8M NQOzw9oiKtT7gAi+wvkPJs/rdiXFFZvueY0y/cK9tdE3WHysrQHqmd6tHIaMkHf0YhI9vTM HCfF5I4X43eBUgUM2izIOZWvvLc5AID8SEswhsvQHABEnAMiw3ALQHXsyohctOj+WU7xBNd JKFpOEJcMI1kclL1tBaWg== X-UI-Out-Filterresults: notjunk:1; V01:K0:fMhhAno2Cs4=:dQ8jbQ67YSf6KoLF8wCoGO CM51sKK1FNS0cmC/tnQFkDZGfRBVs0cyiSVpwtAtFV/ofDdK/bjrk5RaGXSMoCq9TD0YeBGAy VpCH0jWqsIY2sjR/CsruOeT7oyyMOU35qj85xWBLrfNJThkcUh8+oH/qbyXm4oskxgRHU3M8/ BwbATyTnYMLqM1PIFd3i9XRT72lbKueJ+HQX1o+dZRuiHkxFKJHlZqnpI5fzzsDRqx3X2et+e iuePyZQed2XL16DoEAeZuNY7WhS7THThi3H7CX81/Rne/3hM4wc8+IoRBfatLak8Vi4XHZMOO mAeYbMrJN/0uXlu6UCSZUgS/CW4BuvG69ermiIss/uvqhvudiQDaPAHQKWn3gg3BelM8B1bRn RJch4vjdaZIvuYY8RoL2qVzB+R/pRAsDqXfPsxpoe9sPEf90knelWox1VIBtYSa9tFGKp7fTV f2mO+kGkQVsxd6UTE6nqOqJS+PWqzd4JkfkByIfcMpYcSqwAggLjuJoWuwyI7Tr8QjrA7xHLp V5IbxKQ5NG8O7bXvSI+OWsDhEozi5YkaurSRCHZ48Vh+JhPCIltl7jToiqdz+Yyt66OdDToPC +eFWJvd3OI66zvhU/AqnOTiqd1zxAEi2YepcDj5nOIrpVLyHSrxvJFR4nz6LxdVbz9u2VyjIT zn9QJ4WiJMoFTDiffyHwgWphslBaToyS4f3oEM3ojvpgirsg+d/8fB+c9bTdCSU0fVtyMsDpU rQvjpXEjCkAqK3yTbFnKXwNR0oMaFuo8LltX+VqtufgZhRgK/y+lyRVGSp456okC93WRF/cnL pXEKmsrVnm4z9XdT00sFFxXZy7ZjQ== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 03/18] efi_selftest: provide test for watchdog timer X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The test verifies that resetting the watchdog timer ensures that it is not called during the timeout period. Testing that the watchdog timer actually executes a reset would require a test outside the efi_selftest framework. Signed-off-by: Heinrich Schuchardt --- v3 no change v2 no change --- lib/efi_selftest/Makefile | 5 +- lib/efi_selftest/efi_selftest_watchdog.c | 185 +++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 lib/efi_selftest/efi_selftest_watchdog.c diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index e446046e02..3e5c9a6d16 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -21,6 +21,8 @@ CFLAGS_efi_selftest_tpl.o := $(CFLAGS_EFI) CFLAGS_REMOVE_efi_selftest_tpl.o := $(CFLAGS_NON_EFI) CFLAGS_efi_selftest_util.o := $(CFLAGS_EFI) CFLAGS_REMOVE_efi_selftest_util.o := $(CFLAGS_NON_EFI) +CFLAGS_efi_selftest_watchdog.o := $(CFLAGS_EFI) +CFLAGS_REMOVE_efi_selftest_watchdog.o := $(CFLAGS_NON_EFI) obj-$(CONFIG_CMD_BOOTEFI_SELFTEST) += \ efi_selftest.o \ @@ -29,4 +31,5 @@ efi_selftest_events.o \ efi_selftest_exitbootservices.o \ efi_selftest_snp.o \ efi_selftest_tpl.o \ -efi_selftest_util.o +efi_selftest_util.o \ +efi_selftest_watchdog.o diff --git a/lib/efi_selftest/efi_selftest_watchdog.c b/lib/efi_selftest/efi_selftest_watchdog.c new file mode 100644 index 0000000000..f8c5404000 --- /dev/null +++ b/lib/efi_selftest/efi_selftest_watchdog.c @@ -0,0 +1,185 @@ +/* + * efi_selftest_watchdog + * + * Copyright (c) 2017 Heinrich Schuchardt + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This unit test checks that the watchdog timer will not cause + * a system restart during the timeout period after a timer reset. + * + * Testing that the watchdog timer actually will reset the system + * after a timeout is not possible within the used framework. + */ + +#include + +/* + * This is the communication structure for the notification function. + */ +struct notify_context { + /* Status code returned when resetting watchdog */ + efi_status_t status; + /* Number of invocations of the notification function */ + unsigned int timer_ticks; +}; + +static struct efi_event *event_notify; +static struct efi_event *event_wait; +static struct efi_boot_services *boottime; +static struct notify_context notification_context; + +/* + * Notification function, increments the notfication count if parameter + * context is provided. + * + * @event notified event + * @context pointer to the timeout + */ +static void EFIAPI notify(struct efi_event *event, void *context) +{ + struct notify_context *notify_context = context; + efi_status_t ret = EFI_SUCCESS; + + if (!notify_context) + return; + + /* Reset watchdog timer to one second */ + ret = boottime->set_watchdog_timer(1, 0, 0, NULL); + if (ret != EFI_SUCCESS) + notify_context->status = ret; + /* Count number of calls */ + notify_context->timer_ticks++; +} + +/* + * Setup unit test. + * + * Create two timer events. + * One with EVT_NOTIFY_SIGNAL, the other with EVT_NOTIFY_WAIT. + * + * @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; + + notification_context.status = EFI_SUCCESS; + notification_context.timer_ticks = 0; + ret = boottime->create_event(EVT_TIMER | EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, notify, + (void *)¬ification_context, + &event_notify); + if (ret != EFI_SUCCESS) { + efi_st_error("could not create event\n"); + return EFI_ST_FAILURE; + } + ret = boottime->create_event(EVT_TIMER | EVT_NOTIFY_WAIT, + TPL_CALLBACK, notify, NULL, &event_wait); + if (ret != EFI_SUCCESS) { + efi_st_error("could not create event\n"); + return EFI_ST_FAILURE; + } + return EFI_ST_SUCCESS; +} + +/* + * Tear down unit test. + * + * Close the events created in setup. + * + * @return: EFI_ST_SUCCESS for success + */ +static int teardown(void) +{ + efi_status_t ret; + + /* Set the watchdog timer to the five minute default value */ + ret = boottime->set_watchdog_timer(300, 0, 0, NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("Setting watchdog timer failed\n"); + return EFI_ST_FAILURE; + } + if (event_notify) { + ret = boottime->close_event(event_notify); + event_notify = NULL; + if (ret != EFI_SUCCESS) { + efi_st_error("Could not close event\n"); + return EFI_ST_FAILURE; + } + } + if (event_wait) { + ret = boottime->close_event(event_wait); + event_wait = NULL; + if (ret != EFI_SUCCESS) { + efi_st_error("Could not close event\n"); + return EFI_ST_FAILURE; + } + } + return EFI_ST_SUCCESS; +} + +/* + * Execute unit test. + * + * Run a 600 ms periodic timer that resets the watchdog to one second + * on every timer tick. + * + * Run a 1350 ms single shot timer and check that the 600ms timer has + * been called 2 times. + * + * @return: EFI_ST_SUCCESS for success + */ +static int execute(void) +{ + size_t index; + efi_status_t ret; + + /* Set the watchdog timeout to one second */ + ret = boottime->set_watchdog_timer(1, 0, 0, NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("Setting watchdog timer failed\n"); + return EFI_ST_FAILURE; + } + /* Set 600 ms timer */ + ret = boottime->set_timer(event_notify, EFI_TIMER_PERIODIC, 6000000); + if (ret != EFI_SUCCESS) { + efi_st_error("Could not set timer\n"); + return EFI_ST_FAILURE; + } + /* Set 1350 ms timer */ + ret = boottime->set_timer(event_wait, EFI_TIMER_RELATIVE, 13500000); + if (ret != EFI_SUCCESS) { + efi_st_error("Could not set timer\n"); + return EFI_ST_FAILURE; + } + + ret = boottime->wait_for_event(1, &event_wait, &index); + if (ret != EFI_SUCCESS) { + efi_st_error("Could not wait for event\n"); + return EFI_ST_FAILURE; + } + if (notification_context.status != EFI_SUCCESS) { + efi_st_error("Setting watchdog timer failed\n"); + return EFI_ST_FAILURE; + } + if (notification_context.timer_ticks != 2) { + efi_st_error("The timer was called %u times, expected 2.\n", + notification_context.timer_ticks); + return EFI_ST_FAILURE; + } + return EFI_ST_SUCCESS; +} + +EFI_UNIT_TEST(watchdog) = { + .name = "watchdog timer", + .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, + .setup = setup, + .execute = execute, + .teardown = teardown, +}; From patchwork Tue Oct 17 22:02:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827328 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGq6C12xjz9s7g for ; Wed, 18 Oct 2017 09:06:43 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id DB4BCC21D8D; Tue, 17 Oct 2017 22:04:49 +0000 (UTC) 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, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D45C7C21E71; Tue, 17 Oct 2017 22:03:15 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DB14DC21DA0; Tue, 17 Oct 2017 22:03:10 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 69EE4C21C2B for ; Tue, 17 Oct 2017 22:03:10 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LkSOt-1dXQzX46ZP-00cSCn; Wed, 18 Oct 2017 00:03:09 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:30 +0200 Message-Id: <20171017220244.8549-5-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:ME4/gqJzJtOMf3Ykj3gUWlrh7QFzT90Z9pTMW8zt2/WF9tT77vQ XoUZRRGOrzjCJmEkfFWOeJerDlo0VE56jPsRxITgOXFatKzGjdzu1YNnpjITNWpYfssnI2Y QwirlohH2iHpY/bjkLjkAB70YLfUGGQqckpZAJ0E4KUMErHODcBLM2hYR/hHzy288RlGPgH iilTXI5cLsL3OE0Q57Hug== X-UI-Out-Filterresults: notjunk:1; V01:K0:sa25hAvRxfM=:uU75ykJRhkmkH1bagK3A5o IKhNAfqcCGnP2xMv8b+0sBx9bh1k1cB4HpzZZi7sEsKxnvOsbWjYAexhfISNCXJY6e4pnQokT TLQJZ6x7nKdtal9VIb7ZpoXDhhMMvI2RCAuxD+eWh0Qm5OG0KrW5JKekPr/L2t2fR4aMjsXLU l0Ea2OuhyEcA6g6NEeyIGVWkjJmZH6OR+k1ThOO/9WcN1kEjjvUhJOnZn5lsBpPWWceP+q3/n 5btqeZNDuxmhJsAUKAHyz97xTz5Xd/tFUjgS1ziY0O1WiDGYBu1e8wnrJ+xpy7jVIUCFwhwx4 0EsGLraKqylI8nUye4i3LX+8ACm7p++jJTgRqSbS3u1pdoTZMgONJU0EDTkE/5hlp1CkPgkxL mtgFy8h19Bl6poKjI5yMwaW308KNqryJQJwLy9Endbm/Bgd6KF53nz2jCaeMCKvJNC+WuV9B2 guYbfN0sJG03pUDgCPrrOhurWdT6JpwWII1jbRX4MA+zVC1uG0pQtVcCJaVbMF6lLjn4aeqes UUJqQuMSEyCWDTtLtyqS36N2zV1OrOJ2qPH0u7Ea232FbrdTl3rDwwsNzHikZhJ8mM7cnpjRF oapWHnp30rYlPKunQrLB+/+Wl0tErRDBQbHe5g4LVoJRV/Vq9gj2nVcN7f025ntjt57arnmDD Q8S5R/X/w9cfGFREJEbd9Wxsfw+Rmswfyy5IP0eVOjkFOSqTusrraBB6dvwvPB4K5704IF0oq y/0iC1NP7auQTqUZJ376nmr2pkVYSinzLH9Tyiv55NlUJ1GbY7RTUOF7zd0Xqsc8gf0hffbcZ wJ5tsM21UkkuMW8iu8WjcHltUwZeQ== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 04/18] efi_loader: new function utf8_to_utf16 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Provide a conversion function from utf8 to utf16. Add missing #include in include/charset.h. Remove superfluous #include in lib/charset.c. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 no change v2 new patch --- include/charset.h | 15 +++++++++++++++ lib/charset.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/include/charset.h b/include/charset.h index 37a3278499..2662c2f7c9 100644 --- a/include/charset.h +++ b/include/charset.h @@ -9,6 +9,8 @@ #ifndef __CHARSET_H_ #define __CHARSET_H_ +#include + #define MAX_UTF8_PER_UTF16 3 /** @@ -62,4 +64,17 @@ uint16_t *utf16_strdup(const uint16_t *s); */ uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size); +/** + * utf8_to_utf16() - Convert an utf8 string to utf16 + * + * Converts up to 'size' characters of the utf16 string 'src' to utf8 + * written to the 'dest' buffer. Stops at 0x00. + * + * @dest the destination buffer to write the utf8 characters + * @src the source utf16 string + * @size maximum number of utf16 characters to convert + * @return the pointer to the first unwritten byte in 'dest' + */ +uint16_t *utf8_to_utf16(uint16_t *dest, const uint8_t *src, size_t size); + #endif /* __CHARSET_H_ */ diff --git a/lib/charset.c b/lib/charset.c index ff76e88c77..8cd17ea1cb 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -6,7 +6,6 @@ * SPDX-License-Identifier: GPL-2.0+ */ -#include #include #include @@ -99,3 +98,59 @@ uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size) return dest; } + +uint16_t *utf8_to_utf16(uint16_t *dest, const uint8_t *src, size_t size) +{ + while (size--) { + int extension_bytes; + uint32_t code; + + extension_bytes = 0; + if (*src <= 0x7f) { + code = *src++; + /* Exit on zero byte */ + if (!code) + size = 0; + } else if (*src <= 0xbf) { + /* Illegal code */ + code = '?'; + } else if (*src <= 0xdf) { + code = *src++ & 0x1f; + extension_bytes = 1; + } else if (*src <= 0xef) { + code = *src++ & 0x0f; + extension_bytes = 2; + } else if (*src <= 0xf7) { + code = *src++ & 0x07; + extension_bytes = 3; + } else { + /* Illegal code */ + code = '?'; + } + + for (; extension_bytes && size; --size, --extension_bytes) { + if ((*src & 0xc0) == 0x80) { + code <<= 6; + code |= *src++ & 0x3f; + } else { + /* Illegal code */ + code = '?'; + ++src; + --size; + break; + } + } + + if (code < 0x10000) { + *dest++ = code; + } else { + /* + * Simplified expression for + * (((code - 0x10000) >> 10) & 0x3ff) | 0xd800 + */ + *dest++ = (code >> 10) + 0xd7c0; + *dest++ = (code & 0x3ff) | 0xdc00; + } + } + return dest; +} From patchwork Tue Oct 17 22:02:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827333 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGqC83cVjz9s7g for ; Wed, 18 Oct 2017 09:11:00 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 27A8BC21E79; Tue, 17 Oct 2017 22:05:19 +0000 (UTC) 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 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B27DEC21E3C; Tue, 17 Oct 2017 22:03:17 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5C35EC21CB6; Tue, 17 Oct 2017 22:03:11 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id E5A6DC21CB6 for ; Tue, 17 Oct 2017 22:03:10 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LZlZ2-1dNlxJ1A2G-00lZQU; Wed, 18 Oct 2017 00:03:09 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:31 +0200 Message-Id: <20171017220244.8549-6-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:BZJU8EGik8ps03+JUOLpMk7RyxvQHXbTy1r/o4ZKSe5KqM/HS3H j6MOgb+2XaemIVP/gyYgyOEQQamkX8u2Wee0qipSjept7MGDOxtPsIkWvKD1jf/cTZ9nAOS 8BcBZoa65Oav6pXgbPe9KNFTgdvRBpDJ3K656m3q1gIl8HRWwKgUZHW0sm+TE32bRg91vDp UIfP0cLBvWl3u88b09dAQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:FPQ+qYHnIz0=:BwgxPzQ2/Y2kJIMyWAiTu2 +KJ/iXooKisDefKTzSHxbCy1v14Uy8iMCRtoOsYaBJNktgGozkQYWljB+X8wUQdiRp/hnCkLK MqQgILt5ukDgZYIIjiBHZoaD2y8ycy7eiitCoXzTPP//ru9J/E6V6ZPHh6/ZgpHg4UzMbNtd4 XsjlX25eE5hGvq/8AvEdwZIjGnTcrr0uhdRca/UB5FutczMXDmbd9BMN14htpP0lh8IY+lCtf yDYO/7C5FUMEX8rPAFE1EK2ZrqrocOIsrUjxbu5UhRQuV3bgqcy/VB1Mz6zwY6+wclRVVap53 0rL3VBIFJF0sUO03fRwcY0RXQs2s8jprOYzjqyT1zCSDJ4LiaZOAv2VdxS1e/uOa4aVgsVahg dMJbNiJIxZm/8Mfmj5udwxvgtSSftAq5etEoQeCRFRkTIwr9oQEwU0VDn1E8GE6FKyRXRbQCx LyQAMok2YsKxXx1OxDHLTyb23WP0svbP/nxLKUuIbMy+RzXVmBe6hB3WfuOkEsou+dFlsjmkI V+6w3E2kkBsGH+aTismG/Fpv7Lwp1eu5udBe/sxYUIcUvoLA64XcNWnCPd5vLVeIaHmWYP2wY uMymoaWlmsnTAWqMoq+9H6UjbXtrFWlUjYZEp6RIgzFsZuwvPsRdaGw8jnetuuHVLmwVKWpRo /Of6Le+QAKW/MEiMimNB3s+aotD+Y2lFFpIOoKrvWLn4oVpcIs1Ast/QiajBPSDZ/OVJiaclA e1f5Uts8QZH/QSj1c0XqLjC8U4FovwCh4hByuHBOUV08PqlKw71dUNjnWH4VnPlMqwl9ERb05 R0q9BO3y6pHSqjVd2FSBW/mxEO/Uw== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 05/18] efi_loader: guard against double inclusion of efi_loader.h X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Use a define to detect double inclusion of efi_loader.h. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 no change v2 new patch --- include/efi_loader.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index af64b11cee..e506eeec61 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -6,6 +6,9 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#ifndef _EFI_LOADER_H +#define _EFI_LOADER_H 1 + #include #include #include @@ -345,4 +348,6 @@ static inline void efi_set_bootdev(const char *dev, const char *devnr, const char *path) { } static inline void efi_net_set_dhcp_ack(void *pkt, int len) { } -#endif +#endif /* CONFIG_EFI_LOADER && !CONFIG_SPL_BUILD */ + +#endif /* _EFI_LOADER_H */ From patchwork Tue Oct 17 22:02:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827326 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGq4x2nZ7z9s7g for ; Wed, 18 Oct 2017 09:05:37 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 13FE6C21DC8; Tue, 17 Oct 2017 22:05:04 +0000 (UTC) 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, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BCF14C21E7F; Tue, 17 Oct 2017 22:03:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4E446C21DA0; Tue, 17 Oct 2017 22:03:11 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id D9E80C21C2B for ; Tue, 17 Oct 2017 22:03:10 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MYcJi-1dhuN52Snq-00VNoW; Wed, 18 Oct 2017 00:03:09 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:32 +0200 Message-Id: <20171017220244.8549-7-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:vgbEiQ3ZvAgYoWTQ/TKruZ6acSZLkXKD49NF3PjJ5u6jv6Nunp3 CD/TqL37vTtqkYBpyinUkUVyb3/jRn5xpke1YWjJF89jIxaRmvzVursmPCB3Pdc1aBdfojq BTxmXDSj+Qj5N4+yPkdLKylwzgysFg6tjS4ZW2JFpcJj+x3WTdw/HhqcBf4fak0+G8SnkFl LN3aA1SiGgYZwXoOXQN1w== X-UI-Out-Filterresults: notjunk:1; V01:K0:KRh9kqN2A0g=:DdjqcSWrE/FqL4MCTjBsr8 zy2XRIv6MAwvjZGf0D1mB46EtEVzWVjMPXou0nTlovb3mE9lGnok8w3HT5yhW8pvJI4zN/1Ye q3ZHiivf1++G1CxT8RLIyU5kN4v755aSVz5fvgDUHe9+llT8YhwZGTHAQnqS+IFm6fjQHRP2C BAyXIG1mFnCTL9unwRcWznNOb5HxMDiih06/1bQlhYwGuubUPzwSsOryc6k3LZRtBkkQdp3Fs mnYmk7CkwJtCZDyQzZxvxx6JsYdxnbmkF05YzCwEHXSYY3PYgigGQ5+w834L48BUM3xX0fsH0 ly+XZwFkeVVs6Usj6bRcPw6CmcENo0a9wwjOyO6/ncsa+Ud1JK//VrDB1p4p8wGLaW/gFF2gA aUulE89RZjU8yU/yJv/trFZVO+Y2V0KruybaJD9z6355zLPM/HnuGMvic9ddSGuhJ/ZSfbjl+ tW/Wy8A8S/hfUhbXy0muAidpu4UwB66FoYVBBvzJQ9UUxBQprJZ+CZUZUurQPhOCW+BjPX+j2 THQkVtkdGcJMFolQtNLCdFNjTiMw0Z0TL2isluKe9TQ8+yvzHXhbCh9BIp2CjAduoALKVeQc4 HIs+jJXwjf6Np4Z/N8hF+iougDA+2E6rrZyDyPpRWIGLgPNoDCFI20zD+cbVs2IKGvmqK5zqf h3hInjb+R8LnGtLIyuWLCF2AKrzYtOSEIyO6U+EhLHZ9/eTeqQBmtbO0kFNV1YXztZMzkJ1/K fHDTzN8+cYGFfAmTk5G768vmnew3di7q55QeIK7UQFZjc2rwGFUJbvu1U4GSp5MZ4A+idlp0F IbmIE/DhzKoEAs86MSfrhuBI8urKA== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 06/18] efi_loader: consistently use efi_status_t in bootefi X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Where ulong or unsigned long are used to hold an EFI status code we should consistenly use efi_status_t. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 new patch --- cmd/bootefi.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 18176a1266..6bdbb89c29 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -93,10 +93,10 @@ static void *copy_fdt(void *fdt) return new_fdt; } -static ulong efi_do_enter(void *image_handle, - struct efi_system_table *st, - asmlinkage ulong (*entry)(void *image_handle, - struct efi_system_table *st)) +static efi_status_t efi_do_enter( + void *image_handle, struct efi_system_table *st, + asmlinkage ulong (*entry)(void *image_handle, + struct efi_system_table *st)) { efi_status_t ret = EFI_LOAD_ERROR; @@ -107,7 +107,7 @@ static ulong efi_do_enter(void *image_handle, } #ifdef CONFIG_ARM64 -static unsigned long efi_run_in_el2(asmlinkage ulong (*entry)( +static efi_status_t efi_run_in_el2(asmlinkage ulong (*entry)( void *image_handle, struct efi_system_table *st), void *image_handle, struct efi_system_table *st) { @@ -122,9 +122,9 @@ static unsigned long efi_run_in_el2(asmlinkage ulong (*entry)( * Load an EFI payload into a newly allocated piece of memory, register all * EFI objects it would want to access and jump to it. */ -static unsigned long do_bootefi_exec(void *efi, void *fdt, - struct efi_device_path *device_path, - struct efi_device_path *image_path) +static efi_status_t do_bootefi_exec(void *efi, void *fdt, + struct efi_device_path *device_path, + struct efi_device_path *image_path) { struct efi_loaded_image loaded_image_info = {}; struct efi_object loaded_image_info_obj = {}; @@ -278,7 +278,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char *saddr, *sfdt; unsigned long addr, fdt_addr = 0; - unsigned long r; + efi_status_t r; if (argc < 2) return CMD_RET_USAGE; From patchwork Tue Oct 17 22:02:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827336 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGqDn5stlz9s7g for ; Wed, 18 Oct 2017 09:12:25 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 7B6CCC21EBD; Tue, 17 Oct 2017 22:05:34 +0000 (UTC) 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 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BEE42C21E3A; Tue, 17 Oct 2017 22:03:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 798ECC21DC1; Tue, 17 Oct 2017 22:03:11 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 1A98AC21D8D for ; Tue, 17 Oct 2017 22:03:11 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MOCSm-1e7rCb3mYm-005Zl0; Wed, 18 Oct 2017 00:03:10 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:33 +0200 Message-Id: <20171017220244.8549-8-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:fQM17bJWz8FhQoBfKU19ozekzp7X0z3KbubckLt2jaWSqr48Kzr WW9ROaputreO5OY7gcXUURjmzisyyalqn3RkwSlrecaRnrUu9gK2L9tqAyi/uYiK6s2XVIF o5aeXy8dqsvGuHLSMGbGzhpkTzgWhajqNZrdSddhGBvmXc7QAlO3Jdoh+SDMyGNKbvwl6lZ yX2Bo4SH3uuf2/86sW4qg== X-UI-Out-Filterresults: notjunk:1; V01:K0:LUqhbZ3CNcE=:ienBGHMN15Uf37Vr28TsxE 2iJCQkJKQk6bTOo/hcbGufsPIKNg1/g7dvNaGRUFMiKUxqQfa8Ti/jiCvYUUvjoazTxCMkcsn JfohL+Vu7jNZxN4C9X2vpGf6KL0W8AGRemHd3vRsHdW6K2SCmyN4/JVJ0EcXmwqvnZYD+2zkQ FnTlHtWXjvN+6FadSHLtkGRkXZJiQHDTe743UrB7ym3L0M+o/qkBqParkFEXOmgbwdi0zMlV5 +vBbQhg8VMEsA8xTgAVe55ddKXFubqeWADTP7xSuFCHXqogg/oa6yjAOcTE+hziLmMF8DIPQ7 57BiZKPvXrDk+ORXKnvX8GXrQB+Sc1HX2sPntAQpGJoWCGZfkHgC2dnVC0GaqJD/80isb1FOC aAxGpHXTJ9qR9ovzcM8edzH3SmKha7dPEtJdjln5Hi9GDdEdemengR4YE9SSSCqKLSCo+cRNy GlYpodH4HtkVgzZuI1xPyU4JjhzgfxeLsmHSLR3pGE1Vr0BnxAAUCWlWHq4ayNe3oXL3VOc7K 75mJzRd3B0L0bL9vYZ8bwH8ZhmUTxqRgP8EoVaIERljpN5Bdww0HQJ1bEmnyS2jQ3Ybh6TA+J M92q2qyEAekd0qu5BoQ8ghHbsBXsnb9XVnvOPA2ryxo+W3ZYiErLaBawm318XkIyRefP0ombh /cv8aSmt3/hIhKhCQIDXka8ukdAw4azRQX5EKJ598OSuCniL4k5AEO7CS+WYPCjuwwLC+7P93 wcWOCo48y5Hrw4S+YoNP0y/IF4DlNqLIxi8pPA7mrY65G4HB0+cYjBsMhRlqk3ggy/KEqBn2z fnJCcJZKP3zzS5nqJ+zNHdApimwzw== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 07/18] efi_selftest: provide a dummy device path X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Currently we pass bootefi_device_path and bootefi_image_path as device and image path without initializing them. They may carry values from previous calls to bootefi. With the patch the variables are initialized valid dummy values. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 new patch split off --- cmd/bootefi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 59696f4601..d497381ac3 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -299,6 +299,12 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) struct efi_loaded_image loaded_image_info = {}; struct efi_object loaded_image_info_obj = {}; + /* Construct a dummy device path. */ + bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, + (uintptr_t)&efi_selftest, + (uintptr_t)&efi_selftest); + bootefi_image_path = efi_dp_from_file(NULL, 0, "\\selftest"); + efi_setup_loaded_image(&loaded_image_info, &loaded_image_info_obj, bootefi_device_path, bootefi_image_path); From patchwork Tue Oct 17 22:02:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827332 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGqBt15tBz9s7g for ; Wed, 18 Oct 2017 09:10:46 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id F3E6CC21E4C; Tue, 17 Oct 2017 22:05:48 +0000 (UTC) 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, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 844C2C21E70; Tue, 17 Oct 2017 22:03:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E207BC21E64; Tue, 17 Oct 2017 22:03:12 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 76451C21DA2 for ; Tue, 17 Oct 2017 22:03:11 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M2FhY-1dCkPa0t3k-00s3eA; Wed, 18 Oct 2017 00:03:10 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:34 +0200 Message-Id: <20171017220244.8549-9-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:zm9UoCd1takA/Mpnd5rDJTGZ7uwevqY4xh6Qp3L2fza7taNVL1M mS52/6obiQoRxVmkUEc3+7dvV+uhfJ4msranHoFhTLVzTJQ7jL47/NgY29phWVdXlEDhK7N fM0i9nORS4IjO5WDA8LKZ+S2cjKD0MS7/fIzDyRdgkDJd44mmiUo0tAN1mFl92Z0NBHE2fe AQJk0HpAiN1RbWrcYhrtA== X-UI-Out-Filterresults: notjunk:1; V01:K0:f7FY607r2is=:+VVwv9Er1pKESP/wrbVAMf KgQ6UBR02pjllIxbaNyXDy3eVBE9tnXj6OjUItBrGVHBzMBD/RCpqoAxM7c41XIKchf6kwD0Z uboluV47EbPIL79s2LLI9xcYO35HOotScZEroAahjUHTuMhLK0ev2JLZkmHJMijh8His075fT /iLBdkk72GxvG5rJyZvHgPLGLAN6rhoGK+2NXzB2hBslpX3WjKE3+MvFxR7gNacWBwTXfwMQx yj6Kc/KpDFJW5Ys0c+lqHK6JL3ZQIm9DZ0o6VrdAzc2o9GiyYy21q69xtVdZB93RXKVNaT0lC Q1PcvkQ9WPYs3Dn8GgMWrrtJ9h5LYwGDjwAUy7eb372lndqHGDjfyJjqtZcpE+hIM4EUDRArX Lw7Y/nMr0nbzTz3yPXXsooublgcCGgCaWHWMRvx3bhdfPEZ7Gy6ELFSEhQWib3XwC76Cpxotr 1JwfG/Jsz0bz9P2uoVZTRbLPdPbMB67nXZ3usR1H/eIBQJq+uJhMbVlJhIkKIA7odnjQ1d0H7 6z7vd9Xb9QXuhMt1DJ5p1RX0OTUw2htRwcOtJXPki1nwXngnm2ABfXqdLp0JcuQ6lncQeURSQ 9oMr/h9CBJDqgNYsNjYJZYFis3F77yGwKb3qG13jy3HrtewkfJ4CW7WEzekZ8dqIWLQd5jsRJ zL9FyveB/7c6FFRX1SfpPRviHBtccImvSdTB4m01unJdWfPlXYBdcm+zdULf3EgEBxcVmsrkg GEwPOG0FmyWlQR8pWyfn+ClFxIexImGeoDpYvnFoT4suow8PPjARUUUEPxZt7Bw40SjB0N0CQ m84ROjuDxbSygqPIYsuXaza0kKZjA== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 08/18] efi_selftest: reformat code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Remove superfluous spaces. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 new patch split off --- lib/efi_selftest/efi_selftest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/efi_selftest/efi_selftest.c b/lib/efi_selftest/efi_selftest.c index 45d8d3d384..c2c339a7be 100644 --- a/lib/efi_selftest/efi_selftest.c +++ b/lib/efi_selftest/efi_selftest.c @@ -25,8 +25,8 @@ static u16 reset_message[] = L"Selftest completed"; */ void efi_st_exit_boot_services(void) { - unsigned long map_size = 0; - unsigned long map_key; + unsigned long map_size = 0; + unsigned long map_key; unsigned long desc_size; u32 desc_version; efi_status_t ret; From patchwork Tue Oct 17 22:02:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827335 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGqDP6VJtz9s7g for ; Wed, 18 Oct 2017 09:12:05 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 974F1C21E50; Tue, 17 Oct 2017 22:06:03 +0000 (UTC) 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 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 6FBECC21EBA; Tue, 17 Oct 2017 22:03:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AF73FC21E7C; Tue, 17 Oct 2017 22:03:16 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id CC0F3C21DC1 for ; Tue, 17 Oct 2017 22:03:11 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MDn8s-1e0f8i29fy-00HALs; Wed, 18 Oct 2017 00:03:10 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:35 +0200 Message-Id: <20171017220244.8549-10-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:0Ijga6i7bFxbK06Bea8MgDyQ/5J8mNbn0iwz5gmhPugVBxVddOS zCmJ08Ost/Vr2wlhXMTxesVNrHamq4AdvVKuu+NItDjT+K2k0RHfo4hhOsbiwQOPKeA7XWm pZxKbXMuvwL9va3BlJDpiH4IdxiQvzb0+PUG/gXBtZ5J7vgTXPrPo2WXTVAxhmEv7dTkq2I D8uMDkp8F5V/Ji0x9Ay0w== X-UI-Out-Filterresults: notjunk:1; V01:K0:XBpakAMLQEI=:CBddeEYcU1tPvdlVwF13/v 6Kgo+rMNv9WUTaDJy0HkQ5lWsANWhsnHk0ASu6nrqoLgEosdBPbDtXNao0VJfaMltkPBAVZLi j7Iyy7JG1JdLsMiwm5r4ZjXa+8rB9zjCLHxdSIreJGyCZ094YsA56MlzV65lvUhwrVX+IvVIU IxQtW1DKvsR3kf80ZNDiVMK6oEQ5o/pFQCySK0eLSppBoIA2YK+E7vFsRZfSS6c27S5+NSalo q11YUnnd7W6uiU6yHkhPUcyz8xQ493tehS3pSj9XrcSIpqAvKOpxpbWd/KCBRYc5inVPW9vxU v6sR+eJGNrGf5wYblEgLcMCuNFtvVX9YDLaPXqWsAVGrrfCA6hcD1Ydf1ofTWBSu1/NZoFray H8H4ivrxjRS/CRHXng3wV5p+6JRV8IUU0IKIJsg43/Ib+WPLaLUI0ZI9UAH6auH5+p8k5McdA 64vzWektZJdGk/CUfXEtUCDXhds9bZjIxUrNu3hHUFCFVSy2sd3Q+Gq9Hkxo5aZesnef+cuwZ dCfiWjeSJfenQ3Mm/6b+Gy76VGq8vMK3qLRy/Yy7xwSsXFsqrj3iakVt7mw1RI9BEPC+Xwprj BhDKpP/F4G7kKkuOpqiSFq/3Bctm6IaAvVbpGrgJKRy78osRGsavAU5B5+RDkrpZmRfjNUl6W 407g0BhpY6hLQ9hBJ/4sALSrQ0GqK1SiQJ2m5DzJezj643VBiEqzIvUi1E9NHye9Ph6sMxXfM mc1MCzopGUEp32RKaJF50u37Rr6GseoO+UjwIGFSKa2GwKdpsrcVRgNb1aTjKWH5ZMc9zR6v6 4Pp9r1a6dcUI7tMKKlRPLCtkzG/NA== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 09/18] efi_selftest: efi_st_memcmp should return 0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" If the compared memory areas match the return value should be 0. We should not use the unrelated constant EFI_ST_SUCCESS. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 new patch split off --- lib/efi_selftest/efi_selftest_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_selftest/efi_selftest_util.c b/lib/efi_selftest/efi_selftest_util.c index 5cffe383d8..5f81f251c4 100644 --- a/lib/efi_selftest/efi_selftest_util.c +++ b/lib/efi_selftest/efi_selftest_util.c @@ -21,5 +21,5 @@ int efi_st_memcmp(const void *buf1, const void *buf2, size_t length) ++pos1; ++pos2; } - return EFI_ST_SUCCESS; + return 0; } From patchwork Tue Oct 17 22:02:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827340 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGqHC4P4bz9t3f for ; Wed, 18 Oct 2017 09:14:31 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6F9F9C21E1D; Tue, 17 Oct 2017 22:07:15 +0000 (UTC) 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 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4E932C21EE6; Tue, 17 Oct 2017 22:03:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 55B56C21E50; Tue, 17 Oct 2017 22:03:18 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 1DECAC21DDA for ; Tue, 17 Oct 2017 22:03:12 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MFi1J-1dzId93SWT-00EgRb; Wed, 18 Oct 2017 00:03:10 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:36 +0200 Message-Id: <20171017220244.8549-11-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:Li6EW5TQ+3iaGA28MbCuXiIVx2AETyD6GSHrteKNz7Lto0HGwVs 7/CH8+rCG8NwbqGhYlyajlmzkfEOlwkXX3qDdUWvwaiL/sgJSFVh9zTjhoxi+nbrUirhhj1 SW7jtugZYhFDO9EclyTD3XPVxYT+Ju29dWq1zPmmcSnlGa2lvMnpsiGMyWLsdtmGRknI3EY mtQbdgLMqvyl8tHCubClg== X-UI-Out-Filterresults: notjunk:1; V01:K0:JaSrmVgvHvI=:s2C8rl95c5EXQqwBjsUsoS 8Ts+J7KRDqtwJRv5f1F6oVQn73+YmE1TqwbyQdRb3PFbOW2wYhzWIxo+LQD4kej12IbBd1SVN UQqQtrgadk9BLue5gS8cXS80pQ+C/bCbZmZxQKXbAM/zz01RtkFcNrb6aRtxKYX/bgL8WEAHT b1jF1ZuY8h2Fsv1AAJe64EJYXIOvcDnNcJT8T7swENXqcN+Fle+4fom1m+hW3njpK0lwf39Ku zAzIQdzWkSbB0S+pHRREW8+/OkaW9/lDNymI4U7H5VquhRF77TvY4IqewBkGAKmns3ufFLox9 GkU+p9pMrfGbmZZ4lNcV+qqYC3vZtPv+PaclNMZ71jTboAsBUBHRoIUT1Bt3JD0q6JEHypsIl xQQGMXy4Lqz0yql9g9FQUJvqhBGnBOzKwm+IoGkwnV5S+iFX04v73bdHZfvUeNt9ogLZ27ppk A5ZaE5kzQ3FV8CMC8CB8GU7WB1PqQdI5H2z+WVIYGIQycGszpgUoarxXA4ndB8aOv9yC0pib8 FTMAHWa0RPoj/ecNA4u2KZ/k05t4ExmkTM+cOrfHONNgo4nz3IjqTmOMPW48LuIFel5x15Cri fqsokI7QjlX5/iQhif4HHeXVoz7j3fl8Ca/88MOzF6FpKu56e9/I8ct5OKp/8fujo0nxV2cHM Bjxm1aRIY9ZTczjkMjrD/zIAmCVJDVW3WWGGZ6n384bjTrz87uGunzgZrmjtP5zRxBuAPZALN L3tMw/MAQiPfCRR+7mtP4zSQbYhqkLLbPgGPeRzGrgdlyGJHwCdRckLilAZDdZC2UmlP1MzhP VI53QbmSjrf6yyEwQnrMHaHBcjT5A== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 10/18] efi_selftest: deduplicate code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Move duplicate code to the new function efi_st_do_tests. Suggested-by: Alexander Graf Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 new patch --- lib/efi_selftest/efi_selftest.c | 71 ++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/lib/efi_selftest/efi_selftest.c b/lib/efi_selftest/efi_selftest.c index c2c339a7be..73f074d9e1 100644 --- a/lib/efi_selftest/efi_selftest.c +++ b/lib/efi_selftest/efi_selftest.c @@ -9,6 +9,13 @@ #include #include +/* + * Constants for test step bitmap + */ +#define EFI_ST_SETUP 1 +#define EFI_ST_EXECUTE 2 +#define EFI_ST_TEARDOWN 4 + static const struct efi_system_table *systable; static const struct efi_boot_services *boottime; static const struct efi_runtime_services *runtime; @@ -133,6 +140,31 @@ static int teardown(struct efi_unit_test *test, unsigned int *failures) return ret; } +/* + * Execute test steps of one phase. + * + * @phase test phase + * @steps steps to execute + * failures returns EFI_ST_SUCCESS if all test steps succeeded + */ +void efi_st_do_tests(unsigned int phase, unsigned int steps, + unsigned int *failures) +{ + struct efi_unit_test *test; + + for (test = ll_entry_start(struct efi_unit_test, efi_unit_test); + test < ll_entry_end(struct efi_unit_test, efi_unit_test); ++test) { + if (test->phase != phase) + continue; + if (steps & EFI_ST_SETUP) + setup(test, failures); + if (steps & EFI_ST_EXECUTE) + execute(test, failures); + if (steps & EFI_ST_TEARDOWN) + teardown(test, failures); + } +} + /* * Execute selftest of the EFI API * @@ -153,7 +185,6 @@ static int teardown(struct efi_unit_test *test, unsigned int *failures) efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle, struct efi_system_table *systab) { - struct efi_unit_test *test; unsigned int failures = 0; systable = systab; @@ -169,41 +200,23 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle, ll_entry_count(struct efi_unit_test, efi_unit_test)); /* Execute boottime tests */ - for (test = ll_entry_start(struct efi_unit_test, efi_unit_test); - test < ll_entry_end(struct efi_unit_test, efi_unit_test); ++test) { - if (test->phase == EFI_EXECUTE_BEFORE_BOOTTIME_EXIT) { - setup(test, &failures); - execute(test, &failures); - teardown(test, &failures); - } - } + efi_st_do_tests(EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, + EFI_ST_SETUP | EFI_ST_EXECUTE | EFI_ST_TEARDOWN, + &failures); /* Execute mixed tests */ - for (test = ll_entry_start(struct efi_unit_test, efi_unit_test); - test < ll_entry_end(struct efi_unit_test, efi_unit_test); ++test) { - if (test->phase == EFI_SETUP_BEFORE_BOOTTIME_EXIT) - setup(test, &failures); - } + efi_st_do_tests(EFI_SETUP_BEFORE_BOOTTIME_EXIT, + EFI_ST_SETUP, &failures); efi_st_exit_boot_services(); - for (test = ll_entry_start(struct efi_unit_test, efi_unit_test); - test < ll_entry_end(struct efi_unit_test, efi_unit_test); ++test) { - if (test->phase == EFI_SETUP_BEFORE_BOOTTIME_EXIT) { - execute(test, &failures); - teardown(test, &failures); - } - } + efi_st_do_tests(EFI_SETUP_BEFORE_BOOTTIME_EXIT, + EFI_ST_EXECUTE | EFI_ST_TEARDOWN, &failures); /* Execute runtime tests */ - for (test = ll_entry_start(struct efi_unit_test, efi_unit_test); - test < ll_entry_end(struct efi_unit_test, efi_unit_test); ++test) { - if (test->phase == EFI_SETUP_AFTER_BOOTTIME_EXIT) { - setup(test, &failures); - execute(test, &failures); - teardown(test, &failures); - } - } + efi_st_do_tests(EFI_SETUP_AFTER_BOOTTIME_EXIT, + EFI_ST_SETUP | EFI_ST_EXECUTE | EFI_ST_TEARDOWN, + &failures); /* Give feedback */ efi_st_printf("\nSummary: %u failures\n\n", failures); From patchwork Tue Oct 17 22:02:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827337 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGqDz2Rtgz9s7g for ; Wed, 18 Oct 2017 09:12:35 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 1912CC21E97; Tue, 17 Oct 2017 22:06:20 +0000 (UTC) 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 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5384EC21E6C; Tue, 17 Oct 2017 22:03:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C12BEC21E4C; Tue, 17 Oct 2017 22:03:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id A205CC21E13 for ; Tue, 17 Oct 2017 22:03:12 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M2FhY-1dCkPb0XkS-00s3eA; Wed, 18 Oct 2017 00:03:11 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:37 +0200 Message-Id: <20171017220244.8549-12-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:pm5siDP2WN8zwVtI8uzuLB4b/jVE7fh86ernAoZhzg5JVP6Rb7Q m3tuyvpVS5mhx+30kIv3m+K/3D01diLjbWjApld/0DFkfSJP+/rjmEGj+xKy0Zj5hzqLpJa 3yZLZ6G88BBgosERJ7kqXHjxj1EqiVtG12QHO8f823DHtyTpY2nLDUszXP8mu46BJz9HUga yDQL8pnsLsWGORFwo1sRA== X-UI-Out-Filterresults: notjunk:1; V01:K0:24+tyweo5Lo=:yij8oUxkWiVrsdRVdkYCQ/ 3Z0drIgBRh6Myx6SpnR6sswcsKlabBXfogGmzBMGfx07nOtHOJR9LO1yimvIPI6Yf/2dbj8/T pSRWivae+Y8kzEroyvf44YgifgFHLnYn+hDk11YmK6L6orGbtD9D2EUO8UNHEsHx9NNW/ROWz 5DNZkDfSJwH6zJqJIKz0fd1HS1B5VeK45sFmBr2WKkBO4+jnTQBz2txEdoI1Xx2dOHqwO6Od/ xI1I6bzc3zWUQLj8Ym5mTtAzneIFKqSDlvdYbabk+JiWD5p1jMGsLnLxqSVRXhcjk9l+EBc0m hIF11ePIOWdvnsskneO9Bi8R5IPlMPWRwrg7mavARn56P1BoUZJq0EyGnAvVaKuhHPXPUZXbO 7M25YzIS8Ve8ULV8MqP4NZf5j4bpIPaMZ0uXRqYnPrmbQ4X4LKlDNj8Emss5w5eSrjAYyyPWZ X14JsoTlDbAklKrO5l/eR9sX7JuZLdlP+PQtxOjkefoPp0RktrQ74uwn2xrqz/e9dOSbUZbO/ 8HjrEh+dkB/Yrv2CObNhxR/415gfd+5ij8wH4WAR3aNH21FdA2G1vgfvLiEBS8TviMSbrLSqP 3OksCI+Fhz//s8JfoHhmowBHFtGrqJFfB0TMWQ0aLpl6ZyLmQ2fKgwSVdT5WDLrMq/nAgn+QF wwXK0rhk3JEM3upNwDti0Akyo1bu22FVTTcvN6LbG+5qUlp3jk1/Esj8GXvWk1C0Wx9zCSYfM lLjK/X208ILETI16+z1dhT1BIoiot5QAHqtCzKDodqlrQhxFATLGoa74a5K2+3kM6urPYLp58 JARkSMR8BKWb2eqOXgzc3oh1T4vsw== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 11/18] efi_selftest: allow to select a single test for exexution X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Environment variable efi_selftest is passed as load options to the selftest application. It is used to select a single test to be executed. The load options are an UTF8 string. Yet I decided to keep the name propertiy of the tests as char[] to reduce code size. Special value 'list' displays a list of all available tests. Tests get an on_request property. If this property is set the tests are only executed if explicitly requested. The invocation of efi_selftest is changed to reflect that bootefi selftest with efi_selftest = 'list' will call the Exit bootservice. Signed-off-by: Heinrich Schuchardt --- v3 split off unrelated changes to separate patches v2 use an environment variable to choose a test --- cmd/bootefi.c | 37 +++++++++++++- include/efi_selftest.h | 18 +++++++ lib/efi_selftest/efi_selftest.c | 90 ++++++++++++++++++++++++++++++--- lib/efi_selftest/efi_selftest_console.c | 10 ++++ lib/efi_selftest/efi_selftest_util.c | 9 ++++ 5 files changed, 155 insertions(+), 9 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index d497381ac3..18331536dd 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -6,10 +6,12 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include #include #include #include #include +#include #include #include #include @@ -50,6 +52,32 @@ static void efi_init_obj_list(void) efi_get_time_init(); } +/* + * Set the load options of an image from an environment variable. + * + * @loaded_image_info: the image + * @env_var: name of the environment variable + */ +static void set_load_options(struct efi_loaded_image *loaded_image_info, + const char *env_var) +{ + size_t size; + const char *env = env_get(env_var); + + loaded_image_info->load_options = NULL; + loaded_image_info->load_options_size = 0; + if (!env) + return; + size = strlen(env) + 1; + loaded_image_info->load_options = calloc(size, sizeof(u16)); + if (!loaded_image_info->load_options) { + printf("ERROR: Out of memory\n"); + return; + } + utf8_to_utf16(loaded_image_info->load_options, (u8 *)env, size); + loaded_image_info->load_options_size = size * 2; +} + static void *copy_fdt(void *fdt) { u64 fdt_size = fdt_totalsize(fdt); @@ -317,7 +345,12 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* Initialize and populate EFI object list */ if (!efi_obj_list_initalized) efi_init_obj_list(); - return efi_selftest(&loaded_image_info, &systab); + /* Transfer environment variable efi_selftest as load options */ + set_load_options(&loaded_image_info, "efi_selftest"); + /* Execute the test */ + r = efi_selftest(&loaded_image_info, &systab); + free(loaded_image_info.load_options); + return r; } else #endif if (!strcmp(argv[1], "bootmgr")) { @@ -363,6 +396,8 @@ static char bootefi_help_text[] = #ifdef CONFIG_CMD_BOOTEFI_SELFTEST "bootefi selftest\n" " - boot an EFI selftest application stored within U-Boot\n" + " Use environment variable efi_selftest to select a single test.\n" + " Use 'setenv efi_selftest list' to enumerate all tests.\n" #endif "bootmgr [fdt addr]\n" " - load and boot EFI payload based on BootOrder/BootXXXX variables.\n" diff --git a/include/efi_selftest.h b/include/efi_selftest.h index 7ec42a0406..978ca2a7ea 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #define EFI_ST_SUCCESS 0 @@ -71,6 +72,15 @@ void efi_st_printf(const char *fmt, ...) */ int efi_st_memcmp(const void *buf1, const void *buf2, size_t length); +/* + * Compare an u16 string to a char string. + * + * @buf1: u16 string + * @buf2: char string + * @return: 0 if both buffers contain the same bytes + */ +int efi_st_strcmp_16_8(const u16 *buf1, const char *buf2); + /* * Reads an Unicode character from the input device. * @@ -88,6 +98,7 @@ u16 efi_st_get_key(void); * @setup: set up the unit test * @teardown: tear down the unit test * @execute: execute the unit test + * @on_request: test is only executed on request */ struct efi_unit_test { const char *name; @@ -96,10 +107,17 @@ struct efi_unit_test { const struct efi_system_table *systable); int (*execute)(void); int (*teardown)(void); + bool on_request; }; /* Declare a new EFI unit test */ #define EFI_UNIT_TEST(__name) \ ll_entry_declare(struct efi_unit_test, __name, efi_unit_test) +#define EFI_SELFTEST_TABLE_GUID \ + EFI_GUID(0xbc3ebe57, 0x09e5, 0xa59d, 0xdb, 0x87, \ + 0xf5, 0x79, 0x61, 0x62, 0x06, 0xde) + +extern const efi_guid_t efi_selftest_table_guid; + #endif /* _EFI_SELFTEST_H */ diff --git a/lib/efi_selftest/efi_selftest.c b/lib/efi_selftest/efi_selftest.c index 73f074d9e1..5d8bb54d53 100644 --- a/lib/efi_selftest/efi_selftest.c +++ b/lib/efi_selftest/efi_selftest.c @@ -22,6 +22,8 @@ static const struct efi_runtime_services *runtime; static efi_handle_t handle; static u16 reset_message[] = L"Selftest completed"; +const efi_guid_t efi_selftest_table_guid = EFI_SELFTEST_TABLE_GUID; + /* * Exit the boot services. * @@ -140,20 +142,59 @@ static int teardown(struct efi_unit_test *test, unsigned int *failures) return ret; } +/* + * Check that a test exists. + * + * @testname: name of the test + * @return: test + */ +static struct efi_unit_test *find_test(const u16 *testname) +{ + struct efi_unit_test *test; + + for (test = ll_entry_start(struct efi_unit_test, efi_unit_test); + test < ll_entry_end(struct efi_unit_test, efi_unit_test); ++test) { + if (!efi_st_strcmp_16_8(testname, test->name)) + return test; + } + efi_st_printf("\nTest '%ps' not found\n", testname); + return NULL; +} + +/* + * List all available tests. + */ +static void list_all_tests(void) +{ + struct efi_unit_test *test; + + /* List all tests */ + efi_st_printf("\nAvailable tests:\n"); + for (test = ll_entry_start(struct efi_unit_test, efi_unit_test); + test < ll_entry_end(struct efi_unit_test, efi_unit_test); ++test) { + efi_st_printf("'%s'%s\n", test->name, + test->on_request ? " - on request" : ""); + } +} + /* * Execute test steps of one phase. * + * @testname name of a single selected test or NULL * @phase test phase * @steps steps to execute * failures returns EFI_ST_SUCCESS if all test steps succeeded */ -void efi_st_do_tests(unsigned int phase, unsigned int steps, - unsigned int *failures) +void efi_st_do_tests(const u16 *testname, unsigned int phase, + unsigned int steps, unsigned int *failures) { struct efi_unit_test *test; for (test = ll_entry_start(struct efi_unit_test, efi_unit_test); test < ll_entry_end(struct efi_unit_test, efi_unit_test); ++test) { + if (testname ? + efi_st_strcmp_16_8(testname, test->name) : test->on_request) + continue; if (test->phase != phase) continue; if (steps & EFI_ST_SETUP) @@ -186,6 +227,9 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle, struct efi_system_table *systab) { unsigned int failures = 0; + const u16 *testname = NULL; + struct efi_loaded_image *loaded_image; + efi_status_t ret; systable = systab; boottime = systable->boottime; @@ -194,27 +238,57 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle, con_out = systable->con_out; con_in = systable->con_in; + ret = boottime->handle_protocol(image_handle, &efi_guid_loaded_image, + (void **)&loaded_image); + if (ret != EFI_SUCCESS) { + efi_st_error("Cannot open loaded image protocol"); + return ret; + } + + if (loaded_image->load_options) + testname = (u16 *)loaded_image->load_options; + + if (testname) { + if (!efi_st_strcmp_16_8(testname, "list") || + !find_test(testname)) { + list_all_tests(); + /* + * TODO: + * Once the Exit boottime service is correctly + * implemented we should call + * boottime->exit(image_handle, EFI_SUCCESS, 0, NULL); + * here, cf. + * https://lists.denx.de/pipermail/u-boot/2017-October/308720.html + */ + return EFI_SUCCESS; + } + } + efi_st_printf("\nTesting EFI API implementation\n"); - efi_st_printf("\nNumber of tests to execute: %u\n", - ll_entry_count(struct efi_unit_test, efi_unit_test)); + if (testname) + efi_st_printf("\nSelected test: '%ps'\n", testname); + else + efi_st_printf("\nNumber of tests to execute: %u\n", + ll_entry_count(struct efi_unit_test, + efi_unit_test)); /* Execute boottime tests */ - efi_st_do_tests(EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, + efi_st_do_tests(testname, EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, EFI_ST_SETUP | EFI_ST_EXECUTE | EFI_ST_TEARDOWN, &failures); /* Execute mixed tests */ - efi_st_do_tests(EFI_SETUP_BEFORE_BOOTTIME_EXIT, + efi_st_do_tests(testname, EFI_SETUP_BEFORE_BOOTTIME_EXIT, EFI_ST_SETUP, &failures); efi_st_exit_boot_services(); - efi_st_do_tests(EFI_SETUP_BEFORE_BOOTTIME_EXIT, + efi_st_do_tests(testname, EFI_SETUP_BEFORE_BOOTTIME_EXIT, EFI_ST_EXECUTE | EFI_ST_TEARDOWN, &failures); /* Execute runtime tests */ - efi_st_do_tests(EFI_SETUP_AFTER_BOOTTIME_EXIT, + efi_st_do_tests(testname, EFI_SETUP_AFTER_BOOTTIME_EXIT, EFI_ST_SETUP | EFI_ST_EXECUTE | EFI_ST_TEARDOWN, &failures); diff --git a/lib/efi_selftest/efi_selftest_console.c b/lib/efi_selftest/efi_selftest_console.c index 840e2290c6..6a7fd20da5 100644 --- a/lib/efi_selftest/efi_selftest_console.c +++ b/lib/efi_selftest/efi_selftest_console.c @@ -142,6 +142,7 @@ void efi_st_printf(const char *fmt, ...) const char *c; u16 *pos = buf; const char *s; + const u16 *u; va_start(args, fmt); @@ -179,9 +180,18 @@ void efi_st_printf(const char *fmt, ...) case 'p': ++c; switch (*c) { + /* MAC address */ case 'm': mac(va_arg(args, void*), &pos); break; + + /* u16 string */ + case 's': + u = va_arg(args, u16*); + /* Ensure string fits into buffer */ + for (; *u && pos < buf + 120; ++u) + *pos++ = *u; + break; default: --c; pointer(va_arg(args, void*), &pos); diff --git a/lib/efi_selftest/efi_selftest_util.c b/lib/efi_selftest/efi_selftest_util.c index 5f81f251c4..1b17bf4d4b 100644 --- a/lib/efi_selftest/efi_selftest_util.c +++ b/lib/efi_selftest/efi_selftest_util.c @@ -23,3 +23,12 @@ int efi_st_memcmp(const void *buf1, const void *buf2, size_t length) } return 0; } + +int efi_st_strcmp_16_8(const u16 *buf1, const char *buf2) +{ + for (; *buf1 || *buf2; ++buf1, ++buf2) { + if (*buf1 != *buf2) + return *buf1 - *buf2; + } + return 0; +} From patchwork Tue Oct 17 22:02:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827339 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGqFR5SMJz9s7g for ; Wed, 18 Oct 2017 09:12:59 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 608DCC21E55; Tue, 17 Oct 2017 22:07:48 +0000 (UTC) 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, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E570BC21ED6; Tue, 17 Oct 2017 22:03:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3925DC21EE2; Tue, 17 Oct 2017 22:03:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id B6FC9C21E2F for ; Tue, 17 Oct 2017 22:03:12 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MMHaL-1eAKAs1qM1-0083fL; Wed, 18 Oct 2017 00:03:11 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:38 +0200 Message-Id: <20171017220244.8549-13-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:DBOfdQeJ0iOpq1oc+GPxlcvJeLXJjZolvSvVPf/Nqdx6oii/qyS PDnQu89RCbg+x10/6J1u6At+NLxY18p8/VK3OL6n6l5/aQhji8/wPe09GX6lFyJYidsMSvt y8MphbTO0fN9cRKzg2+ZpD012PJVPpf9HTMcBQE9z6W3xMsEyz2Vcn9YjAg4p8nfadG3vFR LIuzg300IPaBO3I7g5T/A== X-UI-Out-Filterresults: notjunk:1; V01:K0:ne3E5WK+mwM=:2xGUbZJV88F0PHBjdwffeW Rs1yUinVRpTsr631QULAi+2+wPzl5kkydDLG3c4YGVHU5Q7OQ+hZoO4LVTXRd+8RV89kl9Toy DE/Ac4W0qrO5WLO0/CiGzy6Pv0hCYQkn0jHbOrfqYdN3xMnry4bMPlh7id96/YTK5AbbSoAdJ Nwsn3M25F9rJA2/ah6RR3Rq4EREZNlFZn0lwUqImNRtgjn3uOpQaKZostYbJx/ahlDm5u0gwT iVf+pRZaxwXEdHnGvJZbD9XjHm6tWoucSTKhJ/yCaD7ueUEaASK+IMr3gpBn4PiMfaifm5yOf ez23pZ60t5ptIEAjHMywSPfMpAUds0OImPJb8mnaFVQi5OIZHORsJqD4K8ZdvNA6WqPmsJv4I Se3JGEjmIM4kMTCCLprQMk+Sl8lwOk9fbEQaX8bLlYRSvUDJpLWyDHjONYL3zFUqn9hvW2Np3 MbH7aeD5NMoMsGgomrVD0km8doJ50m+9KAgrzye+HLyUXGDEpl/88OrEsZTkQlPojS/ml4Zny 8qkdcF2dY5ksPfL18vVtFPX+oRBjPZRDY5XjVC0s6nMCp23mZdyyvo6VXc+HwEfhHR6mhUI3E zJnbfuKBoJZRUzWiPOLPzYw+IWY+QQVNswGgOglxit3lijHeDUKw6rCtjmJkowSrdau/K+sUu fL72G/zXlDLPnYrXXxMD4Hufsz7BMUZ1z/5tTBbAm5ScJJUi7lZyzy51weNk/vwbIemAB8cev YWlCVHwKxXT5Z+YPQnAOLsW46i/XU5R0NaLwWu5lWRDRanavNTUnw3JvmtNT071/kJmyAZBrG KbsTeh9TNMlWM0M3nQZXWhPkXuurQ== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 12/18] efi_selftest: correctly cleanup after selftest X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" After executing bootefi selftest * restore GD * unlink the load image handle * return 0 or 1 and not a truncated efi_status_t. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 new patch split off --- cmd/bootefi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 18331536dd..40834f3899 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -349,8 +349,10 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) set_load_options(&loaded_image_info, "efi_selftest"); /* Execute the test */ r = efi_selftest(&loaded_image_info, &systab); + efi_restore_gd(); free(loaded_image_info.load_options); - return r; + list_del(&loaded_image_info_obj.link); + return r != EFI_SUCCESS; } else #endif if (!strcmp(argv[1], "bootmgr")) { From patchwork Tue Oct 17 22:02:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827338 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGqFP0315z9s7g for ; Wed, 18 Oct 2017 09:12:56 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9FF00C21EA2; Tue, 17 Oct 2017 22:06:45 +0000 (UTC) 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, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 44D06C21E48; Tue, 17 Oct 2017 22:03:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 66180C21E45; Tue, 17 Oct 2017 22:03:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 0E389C21DA2 for ; Tue, 17 Oct 2017 22:03:13 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LmNHK-1dUy1F33VC-00ZyIS; Wed, 18 Oct 2017 00:03:11 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:39 +0200 Message-Id: <20171017220244.8549-14-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:i6CRJu/tPNDq38dYsd6/heNa8R7QeghWDkRihBtPSlIxC+CJLXC rm6j/lO9AO9PRhcURN/QLYw593hey2R3dqqulltflUdjqfaDOVgRqiRFt6CfhrmIjQEefdP 5bGynWfbXD8ry0/vSa3HeQ4Dz17Z4uYx2TEl+4+V26yu28s2VFvOlL8nfnz3MpDKRh1L5qL /zeRAh4QMv36RdNumoddQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:KoOlDmvRr/g=:0+5FA/7WSk1/cA43Btra6O 1a2YOBXp4pWRGSqIXh1nmG1OXPN6JgU5JpqsuCNhCcp4t1RsMaEFKWM/+XmbZfTQ3alt5v6NM pSp1AFOEhMLRH5yuPOSyj+MXei+eRQNxuvGK1fqhXkL0WJVhqMuV4B7fSSZBBfzenIWTVntaJ MWuyBTgy+Z4sMHQojB/tkExNR93446h24idk6FWSRPJ0WV+rmONle36RULvOAAXiNglik2mXJ O7ARAaNQ3CwyA4hEn3NchBDbgG8pmQWCuNmH/B+IweXuzvtF+0Rve7FzXKFXVE/Oc6EWVJ46t 2nQrSbN+dDpR4SQIszP1jo//85dG++QCPmgM6vTDLzutim+96/4kKxmPZsBiD4+/hAinv8SMb gy2MMaHfMaQBojCloJ5+f7Ue1sGmGoxWdWVqhu3mKIHlaf+PR+kJPxnE1EhYyRMOVCz0WAbtk MvRydCxof6DLz+OD0C3QWgXj8NjdBPA+A0uO4fcTz24iwdzLHRUlGQoHRpcUuI18OxdI3EVm1 x7lPZA2MAgdlhtG64zuC0/uJPGJ3+1Ls5LFYNWvbAxwC8u+6EDgIF10EO8DqYLXBQFtEN1wkq EZTQE9TcvAZre7qfgwGb5dtYcoeTN5BzCLLN8Xndx1kbs1GKQ+H5GxFP6FjtMcdWeObus41DY DdxzlkEP5OgVtyVcUDQo1V29LzVdZ8x/AS4gR9Y/5z/1WnpEBACZaSyEGmWSsI7hl8Zjb8hSn hI83iaDxKVrVyY3hIKOc89Txp/qLP/H6CPnh3z2hudl9wXhvB44cUdY9mDKgoEV6TIBdtLW6Q j/2XTaT/31S0i/T9CiMX7/RNNCMfQ== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 13/18] efi_loader: use bootargs as load options X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Use environment variable bootargs used as load options for bootefi payloads. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 new patch split off --- cmd/bootefi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 40834f3899..ff659fc02f 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -218,6 +218,8 @@ static efi_status_t do_bootefi_exec(void *efi, void *fdt, efi_install_configuration_table(&fdt_guid, NULL); } + /* Transfer environment variable bootargs as load options */ + set_load_options(&loaded_image_info, "bootargs"); /* Load the EFI payload */ entry = efi_load_pe(efi, &loaded_image_info); if (!entry) { From patchwork Tue Oct 17 22:02:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827341 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGqHh1Vv8z9t3H for ; Wed, 18 Oct 2017 09:14:56 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id EF182C21E4D; Tue, 17 Oct 2017 22:07:32 +0000 (UTC) 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, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 268EAC21EEE; Tue, 17 Oct 2017 22:03:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D74ABC21EBC; Tue, 17 Oct 2017 22:03:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 621F4C21E43 for ; Tue, 17 Oct 2017 22:03:13 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M1RHp-1dGJqr09F3-00tR5n; Wed, 18 Oct 2017 00:03:12 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:40 +0200 Message-Id: <20171017220244.8549-15-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:seYpgN4hY2fNaARJGwDZzoY6V+u5tBYaVSZLZ5D+c7E1MoVE8OG xv0NEkzrWgouCRkwmrKdJnD33AlH3Z8v/s7P43kYdtLBePGGCWNj1gK0j0pC04XtAUYW/bt JXBo6vDQqjBc0dJwObWPKZ5YHdnot/j5I4uTD7ZddC4Xdk1BgrQCSj0Dh+eDm3rvH98LuXg 03M+ExDPFz7y9XkL1xCrQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:ULYibJan52c=:DUV2544w8kmuR4R90ImJyn FBacqr3rHEs3tBRafVtuW+mq6fO7iwYCSCB8cVBhaJPgCRF+G1aBfzb/I0919YRw3phJNB7r4 tDiFTzs5pO0oQdtpNDh5S5LuaZdjVacGVFSQdVTUz+Omu9vzYVVrmuP9D8/Dn7hdV/HyydIAD a3zhKNTR/pTDOEr3H5KfnLzcxtq5ME7bT9YdTZ7hpDPaddxVJbtUSoyIqgapCklV7MUqQlz4a wHX0OEwKi3YIeraRMA8Xun9okSDYttyzm5hxzqd4PQm0QpzntoqiBRjrAOk9g4bpmYaUX2/2l OlRiFS1sqgPyRYnzp5UKuFUrIaWcNPEpXzcQaM+BCSYf2sS4Kr1jsluyWMRC4qZPMz77NxXjO 4UsGdwsHxmo559Q2KdqY87RwzNOZ2uY7/ZxWpL8Y06azahE6bYNZDypnSbwk6N1r7CX7XV04D 5ZjDxsTaOr6TY/37DNiV8jSTdWDscd3ihWTZHjZ9Y0D3oavGGiHA00nLxXFkogK5xIckvd3H2 e38goC+iTCnJi5TvUFoktqtpO8MybU9sX8foEfpQk0EKfvC9bcM/oNdkow/kavJm0dw5s4Jlh NsV5OpmnGUqYH/W640I/lcMPajUAGEtEZdy/BoG421zfqN2Kz90P8HROQzg28IcErXcaYeq4S HgV79oKULBHGrJQXNV6q/WVLOCEQm4soFZz4Nrki1jmW6J1tDLH4V1PGiiwf2AvySGogP3GzC CMutVWKqZJqJEqBeGyz3NZ12cQYF2MT4507zy8GW/mRQuMfm4E7NsXjNRu5WvEzp8W/02wadt VmH5lc42iVNR0vgnQO3ZojoIs9pIQ== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 14/18] efi_selftest: test reboot by watchdog X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" A test is added that verifies that the watchdog timer actually causes a reboot upon timeout. The test is only executed on request using setenv efi_selftest watchdog reboot bootefi selftest Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 correct comments v2 no change --- lib/efi_selftest/efi_selftest_watchdog.c | 68 ++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/lib/efi_selftest/efi_selftest_watchdog.c b/lib/efi_selftest/efi_selftest_watchdog.c index f8c5404000..e4af38407f 100644 --- a/lib/efi_selftest/efi_selftest_watchdog.c +++ b/lib/efi_selftest/efi_selftest_watchdog.c @@ -5,11 +5,16 @@ * * SPDX-License-Identifier: GPL-2.0+ * - * This unit test checks that the watchdog timer will not cause - * a system restart during the timeout period after a timer reset. + * The 'watchdog timer' unit test checks that the watchdog timer + * will not cause a system restart during the timeout period after + * a timer reset. * - * Testing that the watchdog timer actually will reset the system - * after a timeout is not possible within the used framework. + * The 'watchdog reboot' unit test checks that the watchdog timer + * actually reboots the system after a timeout. The test is only + * executed on explicit request. Use the following commands: + * + * setenv efi_selftest watchdog reboot + * bootefi selftest */ #include @@ -28,6 +33,7 @@ static struct efi_event *event_notify; static struct efi_event *event_wait; static struct efi_boot_services *boottime; static struct notify_context notification_context; +static bool watchdog_reset; /* * Notification function, increments the notfication count if parameter @@ -88,6 +94,34 @@ static int setup(const efi_handle_t handle, return EFI_ST_SUCCESS; } +/* + * Execute the test resetting the watchdog in a timely manner. No reboot occurs. + * + * @handle: handle of the loaded image + * @systable: system table + * @return: EFI_ST_SUCCESS for success + */ +static int setup_timer(const efi_handle_t handle, + const struct efi_system_table *systable) +{ + watchdog_reset = true; + return setup(handle, systable); +} + +/* + * Execute the test without resetting the watchdog. A system reboot occurs. + * + * @handle: handle of the loaded image + * @systable: system table + * @return: EFI_ST_SUCCESS for success + */ +static int setup_reboot(const efi_handle_t handle, + const struct efi_system_table *systable) +{ + watchdog_reset = false; + return setup(handle, systable); +} + /* * Tear down unit test. * @@ -146,11 +180,14 @@ static int execute(void) efi_st_error("Setting watchdog timer failed\n"); return EFI_ST_FAILURE; } - /* Set 600 ms timer */ - ret = boottime->set_timer(event_notify, EFI_TIMER_PERIODIC, 6000000); - if (ret != EFI_SUCCESS) { - efi_st_error("Could not set timer\n"); - return EFI_ST_FAILURE; + if (watchdog_reset) { + /* Set 600 ms timer */ + ret = boottime->set_timer(event_notify, EFI_TIMER_PERIODIC, + 6000000); + if (ret != EFI_SUCCESS) { + efi_st_error("Could not set timer\n"); + return EFI_ST_FAILURE; + } } /* Set 1350 ms timer */ ret = boottime->set_timer(event_wait, EFI_TIMER_RELATIVE, 13500000); @@ -176,10 +213,19 @@ static int execute(void) return EFI_ST_SUCCESS; } -EFI_UNIT_TEST(watchdog) = { +EFI_UNIT_TEST(watchdog1) = { .name = "watchdog timer", .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, - .setup = setup, + .setup = setup_timer, + .execute = execute, + .teardown = teardown, +}; + +EFI_UNIT_TEST(watchdog2) = { + .name = "watchdog reboot", + .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, + .setup = setup_reboot, .execute = execute, .teardown = teardown, + .on_request = true, }; From patchwork Tue Oct 17 22:02:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827330 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGq9M20Prz9s7g for ; Wed, 18 Oct 2017 09:09:27 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 05D98C21E52; Tue, 17 Oct 2017 22:08:03 +0000 (UTC) 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, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D74AFC21EE7; Tue, 17 Oct 2017 22:03:36 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0F345C21EDD; Tue, 17 Oct 2017 22:03:21 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id A15DDC21E33 for ; Tue, 17 Oct 2017 22:03:13 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M9eHT-1dwYX91U35-00D3cb; Wed, 18 Oct 2017 00:03:12 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:41 +0200 Message-Id: <20171017220244.8549-16-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:EW94JizE4/XpubHsYRSGgkBM2YgZOMIzFckQ+CSCsFAAzIDGcvg K3rprVaAyQunOICU7w1Hm+BFb1V0UskCiT5ciKrXOoCP1aI1Nds9OANWimVoIYeXg9t6fkK bEQbFIPSg0mF2GWuJY46/6I2jtiLZ/QUfGZu5ouVjoWEi0n8Ib+bki4Nmr31pJxRvb4JvT3 yeyHnpiyGSqYbPAZkuYzw== X-UI-Out-Filterresults: notjunk:1; V01:K0:J45kv26oWwk=:5l8I3lnwkFpXLd+fL7HAet rKJ/Wm/7MpIo+c72OChxAcWWbt5W30g+77U/EIgEvgmC/xuCo6iRNcDwul+L5uvzbFMX2ZEsN IPR9FT/SvGv0vr6y8ZfOj/YEw/efUXIjzdMOH42JYlBUO2faI7y7MYQMMFKg8Vw82O8KoNfC2 8iqWagvv79VEIUCw9j2Vyh8GPrtW0aFVPcr1fvNiO82pFiwiDWllgx8e4eyzTZF4Q6mvZRR/N ZSXx1PKX77eBm3tFQpxg8mrNf/8G+ZR8qQkssYAd8+DlCajr4dBroGiTFVLfZM7LAU+TWjvMw 4RlsSewkt9IGMHY5qSs4WZQgk4BByt7PqZ5I644ukRFKZlMz+/6ywkJ0PDe8KD1Kh8IbRWxJ0 jCjKnMYGq4Yo15ShDeOw9XPZff++I/zUGEePbNl5pCt3fuB2/+EGaP9ROAGXJhe7MUzqsho4f 6x5b5lMm8VuE86ALZrZD9WGZaIntUCVGkErtqrLRkQ4GiTSM8a26mDoU6jF1Crb+ZWOPyqzJD 9EUFkDK+wQpWmJ6E9D5qWGbPtpT5wrPYI8QttujxIupTFIZtyyZKm3VPZrlCCB3AcJOu5zMI1 LwM574M4DICadYxHr5E2faqXy7CswqSYe7PSXmcY7/J0dzaak0oLgSP52XMKwSZjlt4neovzj VJk4Th41AiAEqfA2Lh9kvQSWyUC0yTx0SCLHIwrClDGZPjWhcDBBOGilJhtIQApQ7Rt/zYsyv GXblTWQiLP6BmPKavenWWITu62qHI/mDYlqAzIlJDQnUlotyD50bz6zbbB+pTLvioeuJQWTjb xD6gzC/5yAtzqw6z/4Q7rds10PPlg== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 15/18] test/py: test reboot by EFI watchdog X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Clear environment variable efi_selftest before executing the default tests. Provide a test verifying that the EFI watchdog reboots the system upon timeout. The test depends on CONFIG_CMD_EFI_SELFTEST=y. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 no change v2 choose test via environment variable --- test/py/tests/test_efi_selftest.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/py/tests/test_efi_selftest.py b/test/py/tests/test_efi_selftest.py index 76e282a6c7..66b799bed6 100644 --- a/test/py/tests/test_efi_selftest.py +++ b/test/py/tests/test_efi_selftest.py @@ -1,4 +1,3 @@ -# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2017, Heinrich Schuchardt # # SPDX-License-Identifier: GPL-2.0 @@ -14,6 +13,7 @@ def test_efi_selftest(u_boot_console): Run bootefi selftest """ + u_boot_console.run_command(cmd='setenv efi_selftest') u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False) m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key']) if m != 0: @@ -23,3 +23,15 @@ def test_efi_selftest(u_boot_console): if m != 0: raise Exception('Reset failed during the EFI selftest') u_boot_console.restart_uboot(); + +@pytest.mark.buildconfigspec('cmd_bootefi_selftest') +def test_efi_selftest_watchdog_reboot(u_boot_console): + u_boot_console.run_command(cmd='setenv efi_selftest list') + output = u_boot_console.run_command('bootefi selftest') + assert '\'watchdog reboot\'' in output + u_boot_console.run_command(cmd='setenv efi_selftest watchdog reboot') + u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False) + m = u_boot_console.p.expect(['resetting', 'U-Boot']) + if m != 0: + raise Exception('Reset failed in \'watchdog reboot\' test') + u_boot_console.restart_uboot(); From patchwork Tue Oct 17 22:02:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827329 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGq9053F9z9s7g for ; Wed, 18 Oct 2017 09:09:08 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 78F36C21E64; Tue, 17 Oct 2017 22:07:00 +0000 (UTC) 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, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 48D05C21EAB; Tue, 17 Oct 2017 22:03:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5C3DEC21DC3; Tue, 17 Oct 2017 22:03:21 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id DDE14C21E48 for ; Tue, 17 Oct 2017 22:03:13 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Lo3IS-1dc5pg2mam-00g0yI; Wed, 18 Oct 2017 00:03:12 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:42 +0200 Message-Id: <20171017220244.8549-17-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:aJ+Rha4r5JB4mlFp3qs6LTfPFC1X3jP7h8ROJh/zZJSA/6IR+26 eDFnBO6/Y/jOU7l+KtCjZoCAkkgtXuHZzti2xFVcVxG/Nd3g2++DWi+9ohZEEFLf61AjpoR 4k/A+iqrgZ1XnqAIwmN9T9r8R5LYGNImNkG2Dut+DyO36xjMfDsV9imWxDqwqmrvpRKvht0 AaHWT/3f68tZxB1Gf9zig== X-UI-Out-Filterresults: notjunk:1; V01:K0:v4Rf5U9euN0=:2KFLdXC6gs3EQYxunyZO+2 s8c11qmNpGtAuEcTFwfwAJCHNaktEzG7KSWFUTZP4Jl3jn/yzMThvH1EzaiIX/w+KfKkWd3HD 4dXYATvLVJpUFEKMx76VjRfGBst1Jz39lnoCH0R9jD+yoWlMSdBfDwsdQCDu5Cl9KbTX31G2G 9r4kXyYZfkft0fDd9KxPLUsQ3DEK2fd170GY2P0JNCbfDMH7udIyk3zwSL9Buv6kPDcgbN6Sw dJKYDPGo/8cU4dPo1vL+5hxZLWZlsaaBS5It/VBUYAUrDDypRxqXT0Zad8TzS/V6tWheB9vP6 aqk2vMBl/OH9PVtOufR/OwaJVqn9qHMMm1Sd3Nu71BH5KYSS3KwyRimg9rtsUZ8eXjUeS/25E WXhhPhLSAgJrhgKiDC/+jPnxIG0mmyKoapZQBtiY8NwNcH3Y4KaYHrSalzNaxGm/ZCXqw5M0I 0tCaeYIYQbO4AVOaCUrvPh/jSTmSAqM0LYa6j0UVtNZtbOeeOMuTdgc+jPpFouwA+wLOz2dPn /0nA2KNvfY9koh9rWcrA0VzdOVNfCa1OARr/lts4ciIySDig2m5/DYKPSeHxg/ubo35TihAxQ avqUQU2ZBhUr3tXCoGXACr62QMDtwNQ3oiGBqXIJrhBAj2wrnCEIwhr0A8Ta58tOBIdCZPBU2 Us+sdVb8tRIYDCWwd2t7xLY/o/qdfw8EwZXtnT9M1zdxjYIaje9qUITGMfIv04TKcvAL++Rtk 5pGe6BA8JJ9HnYP3oeLvhqU54DjdDG3t4HluARR5YrnPTCa1r0YI6Klvu7gFetdvD9hBQH+Ey d2P2NZbnHrQHlB74eOslO6852+CAw== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 16/18] test/py: fix typo in test_efi_loader.py X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Make a comment line easier to read. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 no change v2 no change --- test/py/tests/test_efi_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/py/tests/test_efi_loader.py b/test/py/tests/test_efi_loader.py index 5d7f5dbfb2..4d391e13ef 100644 --- a/test/py/tests/test_efi_loader.py +++ b/test/py/tests/test_efi_loader.py @@ -12,7 +12,7 @@ import u_boot_utils """ Note: This test relies on boardenv_* containing configuration values to define -which the network environment available for testing. Without this, the parts +which network environment is available for testing. Without this, the parts that rely on network will be automatically skipped. For example: From patchwork Tue Oct 17 22:02:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827331 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGqBV5q2Hz9t3H for ; Wed, 18 Oct 2017 09:10:26 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9B79CC21E76; Tue, 17 Oct 2017 22:08:35 +0000 (UTC) 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, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BFCA4C21F10; Tue, 17 Oct 2017 22:03:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 20909C21DC1; Tue, 17 Oct 2017 22:03:23 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 3DE54C21E51 for ; Tue, 17 Oct 2017 22:03:14 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MSp1l-1ddFWn41Mj-00RpaB; Wed, 18 Oct 2017 00:03:13 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:43 +0200 Message-Id: <20171017220244.8549-18-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:UsDuTNntL7OdPj45NYIDat3oz4/L25P75u5Sg2c4AFUZnZiFMjg PAZb0QkTDtjaGWhvBPH0wY9Gz7y4QSfKLPIM4e3nCeR631DDgESd0VtsrmJYiPYjHnn+iRd noe7ESTcf9loztwqTCNmGZDM0EVlj53EJE3RDQAayQLof4cBTs68mJTRq0UaZYd058CFTWd A0MTrUNKrU8xULfkJTsjA== X-UI-Out-Filterresults: notjunk:1; V01:K0:ZF+QcEqLPsU=:iVQJcWApICTPPZGIEpPM6/ atpdttCiplvUCAtT75ngrO69C99pRKELhzfbet8prB49yvNXfKhardD0yHokzD4JY23LtDlCA E1cYRDefe3aEx4niKn6iB9HK3D4vIuDpuQ0Yp11pj1jPOmoD5Y+xgEoRf5SmdS+bebpR28TMU yl3Vw8h2JUDFGr3TQVsFlXbx6CL7+5LPoL7TtbGzkgM5rInfW4l1GGGgSinsp9JLgXK/4JoAj RRqv+YICph2kXKNj8ACyNiADe70VWybSKGOinY7+d1kWChoyldhKmfURS642di3N8sHBDG7gZ 49LzgnbXKUyp+/45s+8NFwtg3TuTa9kQS+tG2A6ZBx6l2nwcYRWKlZ+UvsoKpHIftwAh5ykdP T/4xsOLtuHm2cIqnLXVlOnv+MMKbAQ2vqZqTheZE5f/kSp3GirMxGDXg49O1v8fL5BRxizy5a RjKc5nzW7/1LvpLo+ddUv9ZJYH6sJaSnk6nz+qdw+DBdvL3THP1Hh2BpwgYplNxjkQmxuRKvY Vog+Y5s+Zy2chD95Kz6mT+MQ6hlKvTyqcBVBfoxJoaVh/VTCUi17O+xIbmMiz5ZJCfx1EPZR4 YO0kNXufvSVl/AuFQN6a3xfkkWBoSNQn2hzDR2tlOlQmYaAy+QE7N/6iqU/EJsB3RwgpfGfCY aefYkMzIwlQrbSH57lnY+Y4cC+yJKPxtpHKProDXyizYUgBlaf13/fkJx23C/AXNj2ec2Utma RkOJ52GKI40uoZw4tcWowwXrDsZiaE0k8zsS7vwc1gl71a2tlYoTv1xtaiWgtdG0/78vIAy8p DUsvGXdgV/o1QF+ePLhvwg5S+a5hw== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 17/18] efi_selftest: provide test for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The following services are tested: OutputString, TestString, SetAttribute. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 new patch --- lib/efi_selftest/Makefile | 5 ++- lib/efi_selftest/efi_selftest_textoutput.c | 53 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 lib/efi_selftest/efi_selftest_textoutput.c diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index 3e5c9a6d16..b1385383ed 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -17,7 +17,9 @@ CFLAGS_efi_selftest_exitbootservices.o := $(CFLAGS_EFI) CFLAGS_REMOVE_efi_selftest_exitbootservices.o := $(CFLAGS_NON_EFI) CFLAGS_efi_selftest_snp.o := $(CFLAGS_EFI) CFLAGS_REMOVE_efi_selftest_snp.o := $(CFLAGS_NON_EFI) -CFLAGS_efi_selftest_tpl.o := $(CFLAGS_EFI) +CFLAGS_efi_selftest_text_output.o := $(CFLAGS_EFI) +CFLAGS_REMOVE_efi_selftest_tpl.o := $(CFLAGS_NON_EFI) +CFLAGS_efi_selftest_text_output.o := $(CFLAGS_EFI) CFLAGS_REMOVE_efi_selftest_tpl.o := $(CFLAGS_NON_EFI) CFLAGS_efi_selftest_util.o := $(CFLAGS_EFI) CFLAGS_REMOVE_efi_selftest_util.o := $(CFLAGS_NON_EFI) @@ -30,6 +32,7 @@ efi_selftest_console.o \ efi_selftest_events.o \ efi_selftest_exitbootservices.o \ efi_selftest_snp.o \ +efi_selftest_textoutput.o \ efi_selftest_tpl.o \ efi_selftest_util.o \ efi_selftest_watchdog.o diff --git a/lib/efi_selftest/efi_selftest_textoutput.c b/lib/efi_selftest/efi_selftest_textoutput.c new file mode 100644 index 0000000000..7bc4d2f446 --- /dev/null +++ b/lib/efi_selftest/efi_selftest_textoutput.c @@ -0,0 +1,53 @@ +/* + * efi_selftest_textoutput + * + * Copyright (c) 2017 Heinrich Schuchardt + * + * SPDX-License-Identifier: GPL-2.0+ + * + * Test the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. + * + * The following services are tested: + * OutputString, TestString, SetAttribute. + */ + +#include + +/* + * Execute unit test. + * + * @return: EFI_ST_SUCCESS for success + */ +static int execute(void) +{ + size_t foreground; + size_t background; + size_t attrib; + efi_status_t ret; + + /* SetAttribute */ + efi_st_printf("\nColor palette\n"); + for (foreground = 0; foreground < 0x10; ++foreground) { + for (background = 0; background < 0x80; background += 0x10) { + attrib = foreground | background; + con_out->set_attribute(con_out, attrib); + efi_st_printf("%p", (void *)attrib); + } + con_out->set_attribute(con_out, 0); + efi_st_printf("\n"); + } + /* TestString */ + ret = con_out->test_string(con_out, + L" !\"#$%&'()*+,-./0-9:;<=>?@A-Z[\\]^_`a-z{|}~\n"); + if (ret != EFI_ST_SUCCESS) { + efi_st_error("TestString failed for ANSI characters\n"); + return EFI_ST_FAILURE; + } + return EFI_ST_SUCCESS; +} + +EFI_UNIT_TEST(textoutput) = { + .name = "text output", + .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, + .execute = execute, +}; From patchwork Tue Oct 17 22:02:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827334 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yGqDH0ZPYz9t3H for ; Wed, 18 Oct 2017 09:11:59 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CB709C21E52; Tue, 17 Oct 2017 22:08:19 +0000 (UTC) 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 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C4C3FC21DA0; Tue, 17 Oct 2017 22:03:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EBCDBC21E88; Tue, 17 Oct 2017 22:03:23 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 887D2C21E0C for ; Tue, 17 Oct 2017 22:03:14 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M51eM-1dIllX14r0-00zCFY; Wed, 18 Oct 2017 00:03:13 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 00:02:44 +0200 Message-Id: <20171017220244.8549-19-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171017220244.8549-1-xypron.glpk@gmx.de> References: <20171017220244.8549-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:c+EGkiGuSXtK4BKbGnMiaHI+IsTURli4gzEWap+3zgLtniATQAO rGNX7u0wxZiBS1CAHa+PSxG315puCjGRzuojcJLykNGOzD7E8BiyDMWSAu77zeNVlgjgV/b J0hnv4Pkx3hOu/DahOQvikCIKbxNXi4rfkwxhd+34zHAjRDw2hiE3tJdOnl1/OgG1RxecAE MvhvtP3z4vfMaVq2r4Kow== X-UI-Out-Filterresults: notjunk:1; V01:K0:p5oaLJZBXyA=:Iqr5NKIRkOqouL1mXHOw73 nemPC/ns6vHvxecgLtROPbh7l3js4jiJ8HEmhUNCp2fug+8crp4hCDgH/9iUMNauwIHEum681 t1QTKL/DkXUUVCnYoEQYGecbhGr4GwWdZkG2L3eseKYOBMx/ahF+Yj6Jq1/n5OXq7eOqCYVEo t87EBNWZp1Eei1m8zh/8VWFLTaG1rjJln6er2d4Hi6HhZYxXmdDGh/fXihYlYtE723dTXYDXQ UxcVPxLo/PTlOjK9Vl/NrAjzA846X70Yips3+ddwizyGOje7ZADEse2b0gkHA8Rk2uJ5SeXQY 4gwdlk3cak+c+rTEPepiArwbtS5laMBfjdWRjLi+TRHtgpgMA1qlchL23stOLgJexSIN8J1mL 4l719D/uv6EgFfEo+MinRI6m8/WqSsHUKeSpOIeNNlOXCoPBRxRfaO/49DSkAhU/+15N5FIgi V5QLbzl9Yt2H6RFM/R5zV17egYdDbmn7dD4GN9MkeIQwPbXo5TT9ifmeNlOvX5OXxQCBHAbbD hpcRdUEd9oopfebqdllutgcD8h05OoXlWLWxbYKcsSd8kJ099h/BQAE+YX9vbCoG4XFLDsIdl rG207zjnAkemtzucIHcqR6WmF3g7r1+aMXoc4q/1H3F4F1dvRB0b7+Oz2nOu5H96KEJJ2hCw9 d7sOerXlddIvptVWgBRVQ7eEbqt52osibmGQLLKbh0DLHqtx/l7uFmTPOAlkbaPnyztCP53iC +eoA2boknHSozrU5PuAXHW9c5+Tqzgh6dKfNHoLYb3ggsP4wuZT1MdbtgWAYIS8EzqLAAiAh4 9swORTRE7RtLnfEpXLa/xgKecmAAw== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 18/18] efi_loader: set parent handle in efi_load_image X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The parent_handle of the loaded image must be set. Set the system table. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3 new patch --- lib/efi_loader/efi_boottime.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index fd8d15655b..f70d8658ab 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1282,6 +1282,8 @@ static efi_status_t EFIAPI efi_load_image(bool boot_policy, return EFI_EXIT(EFI_UNSUPPORTED); } + info->system_table = &systab; + info->parent_handle = parent_image; *image_handle = info; return EFI_EXIT(EFI_SUCCESS);