{"id":806182,"url":"http://patchwork.ozlabs.org/api/patches/806182/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170826225444.7608-4-xypron.glpk@gmx.de/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170826225444.7608-4-xypron.glpk@gmx.de>","list_archive_url":null,"date":"2017-08-26T22:54:44","name":"[U-Boot,23/23] efi_loader: implement SetWatchdogTimer","commit_ref":null,"pull_url":null,"state":"superseded","archived":true,"hash":"d7fa65d3dbaf9d1b626f357150e1a559714146ae","submitter":{"id":61270,"url":"http://patchwork.ozlabs.org/api/people/61270/?format=json","name":"Heinrich Schuchardt","email":"xypron.glpk@gmx.de"},"delegate":{"id":3400,"url":"http://patchwork.ozlabs.org/api/users/3400/?format=json","username":"agraf","first_name":"Alexander","last_name":"Graf","email":"agraf@suse.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170826225444.7608-4-xypron.glpk@gmx.de/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/806182/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/806182/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xftv53J4Zz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 27 Aug 2017 09:06:25 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 3A77AC221F8; Sat, 26 Aug 2017 22:56:54 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 1461AC221E7;\n\tSat, 26 Aug 2017 22:56:52 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 6487DC221B8; Sat, 26 Aug 2017 22:55:38 +0000 (UTC)","from mout.gmx.net (mout.gmx.net [212.227.17.22])\n\tby lists.denx.de (Postfix) with ESMTPS id CEFF1C221BF\n\tfor <u-boot@lists.denx.de>; Sat, 26 Aug 2017 22:55:37 +0000 (UTC)","from localhost.localdomain ([84.118.154.110]) by mail.gmx.com\n\t(mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id\n\t0LoaCE-1dJX2Z0ani-00gaKP; Sun, 27 Aug 2017 00:54:57 +0200"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.7 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,\n\tRCVD_IN_MSPIKE_WL autolearn=unavailable\n\tautolearn_force=no version=3.4.0","From":"Heinrich Schuchardt <xypron.glpk@gmx.de>","To":"Alexander Graf <agraf@suse.de>","Date":"Sun, 27 Aug 2017 00:54:44 +0200","Message-Id":"<20170826225444.7608-4-xypron.glpk@gmx.de>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20170826225444.7608-1-xypron.glpk@gmx.de>","References":"<20170826225110.7381-1-xypron.glpk@gmx.de>\n\t<20170826225444.7608-1-xypron.glpk@gmx.de>","X-Provags-ID":"V03:K0:vZWv2jSlCV/PEQRmUwFAX1N1BJyguwHnSPm5CMARDT6u2krvcbP\n\t78humLL59CowH99s0KlQfBerEjn+kEftfhDZNnfTqghGaglVRrpk1XKseg8opORgNjgfYND\n\tf81tZ5hDMRVAwtMhWtTz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denx.de","Subject":"[U-Boot] [PATCH 23/23] efi_loader: implement SetWatchdogTimer","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"The watchdog is initialized with a 5 minute timeout period.\nIt can be reset by SetWatchdogTimer.\nIt is stopped by ExitBoottimeServices.\n\nSigned-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>\n---\n cmd/bootefi.c                 |  1 +\n include/efi_loader.h          |  4 +++\n lib/efi_loader/Makefile       |  2 +-\n lib/efi_loader/efi_boottime.c |  3 ++-\n lib/efi_loader/efi_watchdog.c | 58 +++++++++++++++++++++++++++++++++++++++++++\n 5 files changed, 66 insertions(+), 2 deletions(-)\n create mode 100644 lib/efi_loader/efi_watchdog.c","diff":"diff --git a/cmd/bootefi.c b/cmd/bootefi.c\nindex 3196d86040..47771f87cc 100644\n--- a/cmd/bootefi.c\n+++ b/cmd/bootefi.c\n@@ -132,6 +132,7 @@ static void efi_init_obj_list(void)\n #ifdef CONFIG_GENERATE_SMBIOS_TABLE\n \tefi_smbios_register();\n #endif\n+\tefi_watchdog_register();\n \n \t/* Initialize EFI runtime services */\n \tefi_reset_system_init();\ndiff --git a/include/efi_loader.h b/include/efi_loader.h\nindex f9f33e1d01..0c1f4e21ca 100644\n--- a/include/efi_loader.h\n+++ b/include/efi_loader.h\n@@ -150,11 +150,15 @@ int efi_disk_register(void);\n int efi_gop_register(void);\n /* Called by bootefi to make the network interface available */\n int efi_net_register(void **handle);\n+/* Called by bootefi to make the watchdog available */\n+int efi_watchdog_register(void);\n /* Called by bootefi to make SMBIOS tables available */\n void efi_smbios_register(void);\n \n /* Called by networking code to memorize the dhcp ack package */\n void efi_net_set_dhcp_ack(void *pkt, int len);\n+/* Called by efi_set_watchdog_timer to reset the timer */\n+efi_status_t efi_set_watchdog(unsigned long timeout);\n \n /* Called from places to check whether a timer expired */\n void efi_timer_check(void);\ndiff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile\nindex 30bf343a36..6bca05aeb4 100644\n--- a/lib/efi_loader/Makefile\n+++ b/lib/efi_loader/Makefile\n@@ -15,7 +15,7 @@ always := $(efiprogs-y)\n \n obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o\n obj-y += efi_image_loader.o efi_boottime.o efi_runtime.o efi_console.o\n-obj-y += efi_memory.o efi_device_path_to_text.o\n+obj-y += efi_memory.o efi_device_path_to_text.o efi_watchdog.o\n obj-$(CONFIG_LCD) += efi_gop.o\n obj-$(CONFIG_DM_VIDEO) += efi_gop.o\n obj-$(CONFIG_PARTITIONS) += efi_disk.o\ndiff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c\nindex 477809e4ca..8f06209794 100644\n--- a/lib/efi_loader/efi_boottime.c\n+++ b/lib/efi_loader/efi_boottime.c\n@@ -928,6 +928,7 @@ static efi_status_t EFIAPI efi_exit_boot_services(void *image_handle,\n \tbootm_disable_interrupts();\n \n \t/* Give the payload some time to boot */\n+\tefi_set_watchdog(0);\n \tWATCHDOG_RESET();\n \n \treturn EFI_EXIT(EFI_SUCCESS);\n@@ -955,7 +956,7 @@ static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout,\n {\n \tEFI_ENTRY(\"%ld, 0x%\"PRIx64\", %ld, %p\", timeout, watchdog_code,\n \t\t  data_size, watchdog_data);\n-\treturn efi_unsupported(__func__);\n+\treturn EFI_EXIT(efi_set_watchdog(timeout));\n }\n \n static efi_status_t efi_bind_controller(\ndiff --git a/lib/efi_loader/efi_watchdog.c b/lib/efi_loader/efi_watchdog.c\nnew file mode 100644\nindex 0000000000..58c098e8bd\n--- /dev/null\n+++ b/lib/efi_loader/efi_watchdog.c\n@@ -0,0 +1,58 @@\n+/*\n+ *  EFI device path interface\n+ *\n+ *  Copyright (c) 2017 Heinrich Schuchardt\n+ *\n+ *  SPDX-License-Identifier:     GPL-2.0+\n+ */\n+\n+#include <common.h>\n+#include <efi_loader.h>\n+\n+static struct efi_event *watchdog_timer_event;\n+\n+static void EFIAPI efi_watchdog_timer_notify(struct efi_event *event,\n+\t\t\t\t\t     void *context)\n+{\n+\tEFI_ENTRY(\"%p, %p\", event, context);\n+\n+\tprintf(\"\\nEFI: Watchdog timeout\\n\");\n+\tEFI_CALL_VOID(efi_reset_system(EFI_RESET_COLD, EFI_SUCCESS, 0, NULL));\n+\n+\tEFI_EXIT(EFI_UNSUPPORTED);\n+}\n+\n+efi_status_t efi_set_watchdog(unsigned long timeout)\n+{\n+\tefi_status_t r;\n+\n+\tif (timeout)\n+\t\t/* Reset watchdog */\n+\t\tr = efi_set_timer(watchdog_timer_event, EFI_TIMER_RELATIVE,\n+\t\t\t\t  10000000 * timeout);\n+\telse\n+\t\t/* Deactivate watchdog */\n+\t\tr = efi_set_timer(watchdog_timer_event, EFI_TIMER_STOP, 0);\n+\treturn r;\n+}\n+\n+/* This gets called from do_bootefi_exec(). */\n+int efi_watchdog_register(void)\n+{\n+\tefi_status_t r;\n+\n+\tr = efi_create_event(EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK,\n+\t\t\t     efi_watchdog_timer_notify, NULL,\n+\t\t\t     &watchdog_timer_event);\n+\tif (r != EFI_SUCCESS) {\n+\t\tprintf(\"ERROR: Failed to register watchdog event\\n\");\n+\t\treturn r;\n+\t}\n+\t/* Set watchdog to trigger after 5 minutes */\n+\tr = efi_set_watchdog(300);\n+\tif (r != EFI_SUCCESS) {\n+\t\tprintf(\"ERROR: Failed to set watchdog timer\\n\");\n+\t\treturn r;\n+\t}\n+\treturn 0;\n+}\n","prefixes":["U-Boot","23/23"]}