From patchwork Tue Jul 18 18:17:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 790461 X-Patchwork-Delegate: agraf@suse.de 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 3xBpPS5tKvz9t2J for ; Wed, 19 Jul 2017 04:20:44 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 97C7FC21DA3; Tue, 18 Jul 2017 18:19:41 +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.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, 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 930C8C21D97; Tue, 18 Jul 2017 18:18:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C8198C21E05; Tue, 18 Jul 2017 18:18:25 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lists.denx.de (Postfix) with ESMTPS id BEB36C21E07 for ; Tue, 18 Jul 2017 18:18:21 +0000 (UTC) Received: from localhost.localdomain ([84.118.154.110]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0Lj1jy-1e323c2Yfe-00dGK9; Tue, 18 Jul 2017 20:17:34 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Tue, 18 Jul 2017 20:17:22 +0200 Message-Id: <20170718181723.1780-7-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170718181723.1780-1-xypron.glpk@gmx.de> References: <20170718181723.1780-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:nn6jzRTlRHyPs6+4lNle32eSmXOAg6Qul0VNED+fwPvw1JAndId VAW/Ot8U/KMWbvgBN+sbhMCQd1eLjlOSv1G/oM+9iHuWWUF7XXkxj8qRCQXvyxaZWX+iupP S9NKgV873XN/kRjk/0QgL8sgkjKEHRXQc54ZDy8g77VmBp+lRbUdvoA97jLtbNHP1RwfrQE O79S0UynCwV1MvtvEhOww== X-UI-Out-Filterresults: notjunk:1; V01:K0:e+s+tSRG66g=:DFVyhDXJR39ELyhRoou8R6 +/o984s8CgjfOJAreYw137pG8xseGPyVml4tweaKufFQ7E0m5NKyAe+GhMSkoTa1DQgybinFA 2SglJXeUc2TY6iaavxESvHgCGN0Xt89UVP8RQkq2JZ+DCFL7Rb1Hf3iXs0kuh4kCI19/JAHfG qwYYKiPMji7e3WOxuh5DfR9HfChzolmUTwFjz2mjflVy7+Wc5Rg9P2ijRTO6ytX9KrCFvnSgr aTNCyVjvvuwVKWEM7oIivX1cf5EdmUNr9A/NzfOGWjlHGLWd9f1D726Oj7utvAvIOQVfqw/dq eh+x2R1cpYojbgDBnLyDhVl97kQ/RxboM1e2+CXNYhKc58rMPRvXNf23qeHHaC5lHp92Fa3Xj UPaWCgHsQM97r7+EeVBBcIo+6lYePnOrZjhhXj/O8edqaKlruv+L7yDfOO7PWh9In1V5Gkj8M N4Y+izbp/VZDjLuiUfaYes8J9EZXwLMVMcNnsUjRsfEGCqfDVXfyO9Mx29DWEHeM/6EkQ46yd oPCFqccHw1QaKSaY148Ein2FZ1WZ5eQlJ3pp06thJbmvbhemhCHNuEMyY7rWw+zwaVsS1NPVf N22Ftt1n3Oj5Q+thcbfwKNWDRqzALDRDuNzSdGwrziNY+JJpU8CZ0Xc+C3tcAgqKzytKva8SG y5Y4uZf/HnyTPlXAPbMzDjR5QpM5827Tu9qIMwHiV5VOkYvWF/JSrdU6V4hxgs+yRpP4V4miC tB2y+BH901g7rKpHgkUKdOBNwtU5lz7Xbc0JsJqs+thcP3CcMKj93s4QIvP40QcjHITfLrAav 4VL8Liytt1qsfg6w+BREfxhdpcoRQ== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 6/7] efi_console: set up events 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" Set up a timer event and the WaitForKey event. In the notify function of the timer event check for console input and signal the WaitForKey event accordingly. Signed-off-by: Heinrich Schuchardt --- v2 dynamically register events to monitor the serial console input --- cmd/bootefi.c | 1 + include/efi_loader.h | 6 +++++- lib/efi_loader/efi_boottime.c | 2 +- lib/efi_loader/efi_console.c | 40 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 966d001d41..cf717564c4 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -112,6 +112,7 @@ static void efi_init_obj_list(void) efi_obj_list_initalized = 1; list_add_tail(&loaded_image_info_obj.link, &efi_obj_list); list_add_tail(&bootefi_device_obj.link, &efi_obj_list); + efi_console_register(); #ifdef CONFIG_PARTITIONS efi_disk_register(); #endif diff --git a/include/efi_loader.h b/include/efi_loader.h index 342e960d14..2abb6b87e1 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -26,7 +26,7 @@ extern struct efi_runtime_services efi_runtime_services; extern struct efi_system_table systab; extern const struct efi_simple_text_output_protocol efi_con_out; -extern const struct efi_simple_input_interface efi_con_in; +extern struct efi_simple_input_interface efi_con_in; extern const struct efi_console_control_protocol efi_console_control; extern const struct efi_device_path_to_text_protocol efi_device_path_to_text; @@ -90,6 +90,8 @@ struct efi_event { /* This list contains all UEFI objects we know of */ extern struct list_head efi_obj_list; +/* Called by bootefi to make console interface available */ +int efi_console_register(void); /* Called by bootefi to make all disk storage accessible as EFI objects */ int efi_disk_register(void); /* Called by bootefi to make GOP (graphical) interface available */ @@ -125,6 +127,8 @@ efi_status_t efi_create_event(enum efi_event_type type, UINTN notify_tpl, /* Call this to set a timer */ efi_status_t efi_set_timer(struct efi_event *event, int type, uint64_t trigger_time); +/* Call this to signal an event */ +void efi_signal_event(struct efi_event *event); /* Generic EFI memory allocator, call this to get memory */ void *efi_alloc(uint64_t len, int memory_type); diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 7f10b6090a..137a4036c6 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -82,7 +82,7 @@ efi_status_t efi_exit_func(efi_status_t ret) return ret; } -static void efi_signal_event(struct efi_event *event) +void efi_signal_event(struct efi_event *event) { if (event->signaled) return; diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 8ef7326fef..dbe98ac08b 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -421,8 +421,46 @@ static efi_status_t EFIAPI efi_cin_read_key_stroke( return EFI_EXIT(EFI_SUCCESS); } -const struct efi_simple_input_interface efi_con_in = { +struct efi_simple_input_interface efi_con_in = { .reset = efi_cin_reset, .read_key_stroke = efi_cin_read_key_stroke, .wait_for_key = NULL, }; + +static struct efi_event *console_timer_event; + +static void efi_key_notify(struct efi_event *event, void *context) +{ +} + +static void efi_console_timer_notify(struct efi_event *event, void *context) +{ + EFI_ENTRY("%p, %p", event, context); + if (tstc()) + efi_signal_event(efi_con_in.wait_for_key); + EFI_EXIT(EFI_SUCCESS); +} + +/* This gets called from do_bootefi_exec(). */ +int efi_console_register(void) +{ + efi_status_t r; + r = efi_create_event(EVT_NOTIFY_WAIT, TPL_CALLBACK, + efi_key_notify, NULL, &efi_con_in.wait_for_key); + if (r != EFI_SUCCESS) { + printf("ERROR: Failed to register WaitForKey event\n"); + return r; + } + r = efi_create_event(EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, + efi_console_timer_notify, NULL, + &console_timer_event); + if (r != EFI_SUCCESS) { + printf("ERROR: Failed to register console event\n"); + return r; + } + /* 5000 ns cycle is sufficient for 2 MBaud */ + r = efi_set_timer(console_timer_event, EFI_TIMER_PERIODIC, 50); + if (r != EFI_SUCCESS) + printf("ERROR: Failed to set console timer\n"); + return r; +}