From patchwork Thu Oct 5 14:35:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821837 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 3y7Fhm4SWzz9sNc for ; Fri, 6 Oct 2017 01:36:56 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6440CC21FC3; Thu, 5 Oct 2017 14:36:54 +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 7DBD0C21DAB; Thu, 5 Oct 2017 14:36:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 39C0AC21E31; Thu, 5 Oct 2017 14:36:50 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id C9745C21DAB for ; Thu, 5 Oct 2017 14:36:49 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Lxdfb-1dFlno00nT-017Cu3; Thu, 05 Oct 2017 16:36:15 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:35:51 +0200 Message-Id: <20171005143607.25955-2-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:k2DrLW3qSfF2unMtZ4tpz2tSWCIzwlZ16dug6yutkJ15odhxSS1 au7+Kkpb+FCXUg2zQwGgmhwpTed+Wn6/CB2iZR1sD4H6UhjoMPLsXv8Vyu7YYUs9WVeUSkT AzSrv4PxmijNOPle9VUdM8xOsNdxHE0DrAJfAo1uzVyM+mLBjy8fPnM/tlmK7e0fMyJkbMJ n1+senDGosyDNzGQvHPAg== X-UI-Out-Filterresults: notjunk:1; V01:K0:GRj42SKVYdk=:iHxxnNs2vKJ9MLFENhM101 u8hUj03Na3us+eqZd/vbBlux9qX8E6bNVgnvYPJixtWQatDE1e+jZJz4pyToYW/AsDvH2wBsT uvse06RW2M9TF8t8J29nKWwgwlNMw6orO1Ut7lhxxgxId0r4fmTJpyHZX2+Xx3XsW+sd0HRMd wFddGQoMW3hti54sdhj8yrK9n9H01H/Vy720Ml98batOju+2bdvqeAnOfmgn4H2oXKbmQ6xcH aTODvBduqLILE7UV9nmvne27hDcNw94BAJzdzN0UsyGyGlCiNVLrHDvjrQtMqQv1jzhB6RGhA /Q73YCgw0QchuiM8gAPeQbbhoJAAPllB9T5AH+RYlRf6jwtRKZmr/+uOxTWZJ9aFgJbLQtW29 fOMsRpwCEbKpTWAI8+tW4rm/rxzIP2vzdaruK4UP+kVmUlcEVR9Fi3syKUQIi0YUvKyOkGLm0 WGomGB8ZevR1zOJc7awaNrsMuehM8+3UmPQDSLdM7ReIRAr9vhALnH5706swSh0Wjr/a27/XM un4uRPtjRVdO80sxOGhB+NC9Jw0ednLwmHyJVG4adNuQTJLmS9DYmKugFSyOWfJvN8yaoWD8J kvU3VH8btDGuCAh08S7l4F3bDkSnpG3xsigfqow1iEUjeIW/e0w9Ywt7v6UXy53aD2I0q3crC Uso7nsiIkr7nLGTO503ZR0KdWG+w/Rh3czWOOSGZ6xg8Nh9TD/hu4y4veDN10hcCiT33PEp9H faWI/v/cHUGMzfcsAUO0ayt3bJF9nSArMkl52M9U5mHgC/B/eY8cGr7Qt6eXF1WJvSO96SbYH njShl4a5i30+pb+KNZMUS9ekAmKmg== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 01/17] efi_loader: call EFI_EXIT in efi_copy_mem, efi_set_mem 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" EFI_ENTRY and EFI_EXIT calls must match. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- 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 66ce92f654..b8b98f2c4a 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1868,6 +1868,7 @@ static void EFIAPI efi_copy_mem(void *destination, void *source, { EFI_ENTRY("%p, %p, %ld", destination, source, length); memcpy(destination, source, length); + EFI_EXIT(EFI_SUCCESS); } /* @@ -1885,6 +1886,7 @@ static void EFIAPI efi_set_mem(void *buffer, unsigned long size, uint8_t value) { EFI_ENTRY("%p, %ld, 0x%x", buffer, size, value); memset(buffer, value, size); + EFI_EXIT(EFI_SUCCESS); } /* From patchwork Thu Oct 5 14:35:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821842 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 3y7Fjm4txXz9sNw for ; Fri, 6 Oct 2017 01:37:48 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 48B7DC21FAB; Thu, 5 Oct 2017 14:37: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 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 DE250C21DF3; Thu, 5 Oct 2017 14:36:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4C306C21DAB; Thu, 5 Oct 2017 14:36:51 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 19548C21DF3 for ; Thu, 5 Oct 2017 14:36:50 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LgeFd-1dUgag1SLt-00o0pB; Thu, 05 Oct 2017 16:36:15 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:35:52 +0200 Message-Id: <20171005143607.25955-3-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:cXZLg1lsrvoFAKqY815DulHS9z1TocYSOrfyVKYMjBH6rP1Y2jn vrqRGO9tadMkm3NQNP0j+B7a0kh2nCY+iW6hqoG9Sp8nKG1cBD06S9lpwozuT/u20Eu0pB1 QVkiWfKc1/bVipg484CMsZoOGrXsmcVYz7EOvEWIZP72SnP35gsVLSsZbFV4ucWDPDDSb2F h4smKp6bfFqI4UgpUyyzw== X-UI-Out-Filterresults: notjunk:1; V01:K0:a4NKt3cI4uE=:KyexSgUcAvIh7RqSruEwGU ELIOPINv6NV+h14WqR//ffNDhsR8ycvYP/Xs+1/7MkeRDb5TVDchui8p191rxBQMOXdZwjSR4 hJ+yJiywHMh4L6DUEE3vjgOWxTvw7l/c5hatcuZfJQj/MHx1AUZO9kdbVafn/2H6CrVlFS4CU O6Mo9X3toP55V9bP7Yiz++U8JWl26RV6VyosLrT1hY0YuVXpgiHo7DScGkSGjf7fktuVtgpcU CK3akS5pWZcCUVaJDbfOxk2NnA+G5Bk1qbTUqRCKIqhDuRJxL8VtC5jnXiYL2Pqnzi6E90u+r /kWcAS7ryoPNu9xO+JX2cwnvShDZz2KGgQyAq6Md9gYbm2Q9DoO2T68yjNuhMSLFWKX9lDoSU 4LyvKPYoy3+MOc79pwTYIwwwlUQb/j9ZuiyzNT/JHa0KEKjSrTucmWEdnMykYAICyblKPWCKc nt4JP7v2mkks4rTWGQcQ7LpTRU9ZoGzfcgepBgeb0s4bGtGcXs9VPls65BSwRtR9gAUy2w2k6 UHxSxz3dCve3nYdnFnIiV2qGcAqmJaje2L0f4AlksJYOtp2KcPp8DYZG0x+9hPvsQwfaPx6eL BycYTuI0mrjsTHlX5thrKOvJ+giDgxfs0m6yK1pgo29QGRKhNwYH3FSd0vlcIeIqlmewIyLHh SsGM8PTjc7EOmUbgQcOvJ8juPV+ktnIfeyN4p5GWSSsNfJOqeYyKtN1SWr/UwVpvENcLhBjQs w7u+BJwa9jGLlryeZ/pO9sfW1SCwwXV4vpSKphT6QedZXmchwjoWTznMIN2Vzm/5e6MgvWhcF NnCapz704HUZJGvQIw5zAl1xk84TA== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 02/17] efi_loader: parameters of CopyMem and SetMem 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 UEFI spec defines the length parameters of CopyMem and SetMem as UINTN. We should size_t here. The source buffer of CopyMem should be marked as const. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- include/efi_api.h | 7 +++---- lib/efi_loader/efi_boottime.c | 10 +++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index c3b9032a48..0b1a383e61 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -156,10 +156,9 @@ struct efi_boot_services { void *handle, ...); efi_status_t (EFIAPI *calculate_crc32)(void *data, unsigned long data_size, uint32_t *crc32); - void (EFIAPI *copy_mem)(void *destination, void *source, - unsigned long length); - void (EFIAPI *set_mem)(void *buffer, unsigned long size, - uint8_t value); + void (EFIAPI *copy_mem)(void *destination, const void *source, + size_t length); + void (EFIAPI *set_mem)(void *buffer, size_t size, uint8_t value); void *create_event_ex; }; diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index b8b98f2c4a..c48ff2cd2a 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1863,10 +1863,10 @@ static efi_status_t EFIAPI efi_calculate_crc32(void *data, * @source source of the copy operation * @length number of bytes to copy */ -static void EFIAPI efi_copy_mem(void *destination, void *source, - unsigned long length) +static void EFIAPI efi_copy_mem(void *destination, const void *source, + size_t length) { - EFI_ENTRY("%p, %p, %ld", destination, source, length); + EFI_ENTRY("%p, %p, %ld", destination, source, (unsigned long)length); memcpy(destination, source, length); EFI_EXIT(EFI_SUCCESS); } @@ -1882,9 +1882,9 @@ static void EFIAPI efi_copy_mem(void *destination, void *source, * @size size of buffer in bytes * @value byte to copy to the buffer */ -static void EFIAPI efi_set_mem(void *buffer, unsigned long size, uint8_t value) +static void EFIAPI efi_set_mem(void *buffer, size_t size, uint8_t value) { - EFI_ENTRY("%p, %ld, 0x%x", buffer, size, value); + EFI_ENTRY("%p, %ld, 0x%x", buffer, (unsigned long)size, value); memset(buffer, value, size); EFI_EXIT(EFI_SUCCESS); } From patchwork Thu Oct 5 14:35:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821854 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 3y7FsL31YJz9t2h for ; Fri, 6 Oct 2017 01:44:22 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 2AD77C21FCA; Thu, 5 Oct 2017 14:38:08 +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 9651DC21FBA; Thu, 5 Oct 2017 14:37:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D557EC21FD2; Thu, 5 Oct 2017 14:36:55 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 14718C21F89 for ; Thu, 5 Oct 2017 14:36:52 +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-1dBs3C2sbB-00tRGL; Thu, 05 Oct 2017 16:36:15 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:35:53 +0200 Message-Id: <20171005143607.25955-4-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:FIGYxd+fcXqA8ULeLSIqGZNWnJgGwP0GtxfVQZXvXZXqcwLl1mg SCgCokVaKxAN2trq/ekITE9C86cvdrvNI6UfwVfxjLXhPBrLqfOM+JM5/x6FWIKidZ2nueD a0QzFTwC3/oWf979kNh/fRtfiSyVLg7g6lb2GsG9Tz2t86ANpJ1Q96MrirVx+Bgc0wkQHeQ EZ+SMFVmGZJjVPEIx1pEA== X-UI-Out-Filterresults: notjunk:1; V01:K0:1CCD+F2DQqo=:FEv+Ec89jP1UdiyLAXwwu2 i5Jv4Vp2i3RrWIHdS2dyTCSNTJatQxTURYkBhAf8E+N43GjXp7TrQ11PVR8LgiCYZgA0jVsEH Plps8v4Ugd4BRyQ9KFlFRiTQRa9spaGD5/8KIPYA2cYjm3GwZfm/C4vSBXraw9HebZlM9EhpY hJ5jRU88nLfAtHB5ftVECqrnMLXZI4pPpKgM9DtYZx3IS/qgstaPxEuwp+EvmlUbP3S+0YK85 oQnfaMdeGTui5+KI1QEXOc2ZSMrqbIboeyT9zuBKJEZugtcZNzgncdmBtHKa+NnHko6apSoJZ 8Jkiek+H3TFe+ClH6KWSCG1z7uk0UQGhkw4f+PXr2J8Rir2YYML83MnUtZtfbmqGRRb4tkkxq B9OSLvZPlK3iJXo5VMzm7NjguOT8iN7N8gw/BhBIq+7oJcklZ3FWwRPs7wbm01b5LZswzxcAd zRPscAdfP0zuOEKxTlC3za4FKTicbmPS2u+1xn2h07u/SKRQVao9ksrgmbCYNYa34yEN3LEzw +MTSy9k/tcgb4AHu+9QUqeIg0JVXANKuKssVUHTyBV4LdEQDi+255DNamslUQ/YZdzKBYuiqF eaCWcFzqBnGbOz6coxhB4TL/G6wkPvIOc4UDmI/C8wUMOF5S1wKFO62CjFewaKYrGgybHZlhi HorywJQdyWz9ltPmX+DDMc/zFfd1A/w9rHTsGNfINWC1N4pCL5tR6RRu74ceoLQAz6UNs4nOT 7EmbyT9LaWCfh3Vtn+Ig5nUzWhv3yesVmezMMXuRfMl2Z7uqsur5LlcyOXXcfXIZR6hljF4S8 aBZtevq/wp/+Vo43Xjs7/8GtVuQ4Q== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 03/17] efi_loader: pass GUIDs as const efi_guid_t * 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" We need to call some boottime services internally. Our GUIDs are stored as const efi_guid_t *. The boottime services never change GUIDs. So we can define the parameters as const efi_guid_t *. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- include/efi_api.h | 27 ++++++++++++++------------- lib/efi_loader/efi_boottime.c | 40 +++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 0b1a383e61..aa4306aac9 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -77,24 +77,25 @@ struct efi_boot_services { efi_status_t (EFIAPI *check_event)(struct efi_event *event); #define EFI_NATIVE_INTERFACE 0x00000000 efi_status_t (EFIAPI *install_protocol_interface)( - void **handle, efi_guid_t *protocol, + void **handle, const efi_guid_t *protocol, int protocol_interface_type, void *protocol_interface); efi_status_t (EFIAPI *reinstall_protocol_interface)( - void *handle, efi_guid_t *protocol, + void *handle, const efi_guid_t *protocol, void *old_interface, void *new_interface); efi_status_t (EFIAPI *uninstall_protocol_interface)(void *handle, - efi_guid_t *protocol, void *protocol_interface); - efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, efi_guid_t *, - void **); + const efi_guid_t *protocol, void *protocol_interface); + efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, + const efi_guid_t *protocol, + void **protocol_interface); void *reserved; efi_status_t (EFIAPI *register_protocol_notify)( - efi_guid_t *protocol, struct efi_event *event, + const efi_guid_t *protocol, struct efi_event *event, void **registration); efi_status_t (EFIAPI *locate_handle)( enum efi_locate_search_type search_type, - efi_guid_t *protocol, void *search_key, + const efi_guid_t *protocol, void *search_key, unsigned long *buffer_size, efi_handle_t *buffer); - efi_status_t (EFIAPI *locate_device_path)(efi_guid_t *protocol, + efi_status_t (EFIAPI *locate_device_path)(const efi_guid_t *protocol, struct efi_device_path **device_path, efi_handle_t *device); efi_status_t (EFIAPI *install_configuration_table)( @@ -131,14 +132,14 @@ struct efi_boot_services { #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle, - efi_guid_t *protocol, void **interface, + const efi_guid_t *protocol, void **interface, efi_handle_t agent_handle, efi_handle_t controller_handle, u32 attributes); efi_status_t (EFIAPI *close_protocol)(void *handle, - efi_guid_t *protocol, void *agent_handle, + const efi_guid_t *protocol, void *agent_handle, void *controller_handle); efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle, - efi_guid_t *protocol, + const efi_guid_t *protocol, struct efi_open_protocol_info_entry **entry_buffer, unsigned long *entry_count); efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle, @@ -146,9 +147,9 @@ struct efi_boot_services { unsigned long *protocols_buffer_count); efi_status_t (EFIAPI *locate_handle_buffer) ( enum efi_locate_search_type search_type, - efi_guid_t *protocol, void *search_key, + const efi_guid_t *protocol, void *search_key, unsigned long *no_handles, efi_handle_t **buffer); - efi_status_t (EFIAPI *locate_protocol)(efi_guid_t *protocol, + efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol, void *registration, void **protocol_interface); efi_status_t (EFIAPI *install_multiple_protocol_interfaces)( void **handle, ...); diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index c48ff2cd2a..e5adc17fab 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -704,7 +704,7 @@ static efi_status_t EFIAPI efi_check_event(struct efi_event *event) * @return status code */ static efi_status_t EFIAPI efi_install_protocol_interface(void **handle, - efi_guid_t *protocol, int protocol_interface_type, + const efi_guid_t *protocol, int protocol_interface_type, void *protocol_interface) { struct list_head *lhandle; @@ -776,7 +776,7 @@ out: * @return status code */ static efi_status_t EFIAPI efi_install_protocol_interface_ext(void **handle, - efi_guid_t *protocol, int protocol_interface_type, + const efi_guid_t *protocol, int protocol_interface_type, void *protocol_interface) { EFI_ENTRY("%p, %pUl, %d, %p", handle, protocol, protocol_interface_type, @@ -802,7 +802,7 @@ static efi_status_t EFIAPI efi_install_protocol_interface_ext(void **handle, * @return status code */ static efi_status_t EFIAPI efi_reinstall_protocol_interface(void *handle, - efi_guid_t *protocol, void *old_interface, + const efi_guid_t *protocol, void *old_interface, void *new_interface) { EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, old_interface, @@ -823,7 +823,7 @@ static efi_status_t EFIAPI efi_reinstall_protocol_interface(void *handle, * @return status code */ static efi_status_t EFIAPI efi_uninstall_protocol_interface(void *handle, - efi_guid_t *protocol, void *protocol_interface) + const efi_guid_t *protocol, void *protocol_interface) { struct list_head *lhandle; int i; @@ -876,7 +876,7 @@ out: * @return status code */ static efi_status_t EFIAPI efi_uninstall_protocol_interface_ext(void *handle, - efi_guid_t *protocol, void *protocol_interface) + const efi_guid_t *protocol, void *protocol_interface) { EFI_ENTRY("%p, %pUl, %p", handle, protocol, protocol_interface); @@ -897,9 +897,10 @@ static efi_status_t EFIAPI efi_uninstall_protocol_interface_ext(void *handle, * @registration key for retrieving the registration information * @return status code */ -static efi_status_t EFIAPI efi_register_protocol_notify(efi_guid_t *protocol, - struct efi_event *event, - void **registration) +static efi_status_t EFIAPI efi_register_protocol_notify( + const efi_guid_t *protocol, + struct efi_event *event, + void **registration) { EFI_ENTRY("%pUl, %p, %p", protocol, event, registration); return EFI_EXIT(EFI_OUT_OF_RESOURCES); @@ -917,7 +918,7 @@ static efi_status_t EFIAPI efi_register_protocol_notify(efi_guid_t *protocol, * @return 0 if the handle implements the protocol */ static int efi_search(enum efi_locate_search_type search_type, - efi_guid_t *protocol, void *search_key, + const efi_guid_t *protocol, void *search_key, struct efi_object *efiobj) { int i; @@ -954,7 +955,7 @@ static int efi_search(enum efi_locate_search_type search_type, */ static efi_status_t efi_locate_handle( enum efi_locate_search_type search_type, - efi_guid_t *protocol, void *search_key, + const efi_guid_t *protocol, void *search_key, unsigned long *buffer_size, efi_handle_t *buffer) { struct list_head *lhandle; @@ -1006,7 +1007,7 @@ static efi_status_t efi_locate_handle( */ static efi_status_t EFIAPI efi_locate_handle_ext( enum efi_locate_search_type search_type, - efi_guid_t *protocol, void *search_key, + const efi_guid_t *protocol, void *search_key, unsigned long *buffer_size, efi_handle_t *buffer) { EFI_ENTRY("%d, %pUl, %p, %p, %p", search_type, protocol, search_key, @@ -1028,7 +1029,8 @@ static efi_status_t EFIAPI efi_locate_handle_ext( * @device handle of the device * @return status code */ -static efi_status_t EFIAPI efi_locate_device_path(efi_guid_t *protocol, +static efi_status_t EFIAPI efi_locate_device_path( + const efi_guid_t *protocol, struct efi_device_path **device_path, efi_handle_t *device) { @@ -1567,7 +1569,7 @@ static efi_status_t EFIAPI efi_disconnect_controller(void *controller_handle, * @return status code */ static efi_status_t EFIAPI efi_close_protocol(void *handle, - efi_guid_t *protocol, + const efi_guid_t *protocol, void *agent_handle, void *controller_handle) { @@ -1590,7 +1592,7 @@ static efi_status_t EFIAPI efi_close_protocol(void *handle, * @return status code */ static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle, - efi_guid_t *protocol, + const efi_guid_t *protocol, struct efi_open_protocol_info_entry **entry_buffer, unsigned long *entry_count) { @@ -1679,7 +1681,7 @@ static efi_status_t EFIAPI efi_protocols_per_handle(void *handle, */ static efi_status_t EFIAPI efi_locate_handle_buffer( enum efi_locate_search_type search_type, - efi_guid_t *protocol, void *search_key, + const efi_guid_t *protocol, void *search_key, unsigned long *no_handles, efi_handle_t **buffer) { efi_status_t r; @@ -1721,7 +1723,7 @@ out: * @registration registration key passed to the notification function * @protocol_interface interface implementing the protocol */ -static efi_status_t EFIAPI efi_locate_protocol(efi_guid_t *protocol, +static efi_status_t EFIAPI efi_locate_protocol(const efi_guid_t *protocol, void *registration, void **protocol_interface) { @@ -1774,7 +1776,7 @@ static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces( EFI_ENTRY("%p", handle); va_list argptr; - efi_guid_t *protocol; + const efi_guid_t *protocol; void *protocol_interface; efi_status_t r = EFI_SUCCESS; int i = 0; @@ -1905,7 +1907,7 @@ static void EFIAPI efi_set_mem(void *buffer, size_t size, uint8_t value) * @return status code */ static efi_status_t EFIAPI efi_open_protocol( - void *handle, efi_guid_t *protocol, + void *handle, const efi_guid_t *protocol, void **protocol_interface, void *agent_handle, void *controller_handle, uint32_t attributes) { @@ -1989,7 +1991,7 @@ out: * @return status code */ static efi_status_t EFIAPI efi_handle_protocol(void *handle, - efi_guid_t *protocol, + const efi_guid_t *protocol, void **protocol_interface) { return efi_open_protocol(handle, protocol, protocol_interface, NULL, From patchwork Thu Oct 5 14:35:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821841 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 3y7Fjm33L0z9sNr for ; Fri, 6 Oct 2017 01:37:48 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 1ADB1C21F98; Thu, 5 Oct 2017 14:37:11 +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 12FECC21FA5; Thu, 5 Oct 2017 14:36:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 352C6C21E31; Thu, 5 Oct 2017 14:36:51 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id D796CC21DAB for ; Thu, 5 Oct 2017 14:36:50 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LbxQO-1dYnJc07hU-00jM7Y; Thu, 05 Oct 2017 16:36:16 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:35:54 +0200 Message-Id: <20171005143607.25955-5-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:U8C0j0Ru5gnrkPbKKScSMVpGodeGDjbZyYjnq5WsvzXA/ltVdTY UHux1/feQcBIcUwPG5a9DfVzqTJhQghTSKhoGJ6s8dbHa7+p3H33NaBYTSi6WKzreIq3Hlw NezCZMMpE7f0eFVrk0EliHzcOQ4ekLE8wrgoAd2oXG4FGP3jf/zb5uQg/l4DF3Q8SEnITVu mAmJGMWHxB50HqMjxYlWg== X-UI-Out-Filterresults: notjunk:1; V01:K0:mr9AuPw/iB0=:OX0CeTJ9ms4TeqRG9nhCpv F4ICM769ntyDp9VBGaXDeAgYviYNJVof60+9LkqeO5+lRoxoSe3WPkY0sNmnhbOeLQw3RB0Js fhfci+/HaVQFRd0llyOGxKA7Cx3cGAHvypy/bC4f8mZrXyHHkGIVIrwvkCt7Fr+nTsqRR1pCw q/CWgceVPbp9vbfLHMBYOFcHteyudg/DSfdGJuOnNZnSbOkCOAm/Tg5DgTnrUSLvtMiKjZOce BDpdoovFvnLa+J7kqlHbAUpsIqTCRtk7g5O7Gb/oHEU60R/AgNN1xRSYD2LqqbdtDzys632F3 AEWJPdceKUhtiQg/lPGrGie+2IqEjUt5SuFYtZNAHudc5ep9IS4AcqDC7iVD/QLV8L9dmFgtA j0tvcc+YlCeINdgpz2cJyK57vGev70DKSzXLJi7+KEoAijYniISIeu2H6xWGQfgb2GtkW5OBj 5amjrODNnGrfhRGfPzMHQTW4bU6UVpZ3iJtcvSdoxzVTxlQqNoadnvBk4BLoib99gpJCzkyYX iCCM6sqBtE7tVqVSV1quLpcWES+Sn4JUZwdGmPShC4liDQZLFtAhB8tmAACYfwurCQi18HUId PmArIIyq9udtZR4Q4vXyWBbtr/uMgNWSub15EubrLu2kSaYUkHFSo/UqWTmZPUNxT+f14e09m AQPfEUpkB2yqW+d5lJtwpIbFxxprPDZgU3R6ZQ60pB+AO5l+fXJqkswUZVe9Hl1Ph+D8G5T4U 8v44WAIobzDzxPPALm/wq6Lcpbp84ZyUl8Z/Rmd4fvp6fm4zem4kNoxvR/W55ryUUnOADhaCm pAi141OKQL70Y9HRWGjWbhI4tBN1g== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 04/17] efi_loader: wrong type in wait_for_event 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 UEFI spec defines parameter index of WaitForEvent as UINTN*. So we should use size_t here. I deliberately do not use UINTN because I hold a following patch that will eliminate UINTN because uppercase types to not match the U-Boot coding style. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- include/efi_api.h | 2 +- lib/efi_loader/efi_boottime.c | 2 +- lib/efi_selftest/efi_selftest_events.c | 2 +- lib/efi_selftest/efi_selftest_tpl.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index aa4306aac9..c44dc9d0cb 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -71,7 +71,7 @@ struct efi_boot_services { enum efi_timer_delay type, uint64_t trigger_time); efi_status_t (EFIAPI *wait_for_event)(unsigned long number_of_events, - struct efi_event **event, unsigned long *index); + struct efi_event **event, size_t *index); efi_status_t (EFIAPI *signal_event)(struct efi_event *event); efi_status_t (EFIAPI *close_event)(struct efi_event *event); efi_status_t (EFIAPI *check_event)(struct efi_event *event); diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index e5adc17fab..976d5822f7 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -553,7 +553,7 @@ static efi_status_t EFIAPI efi_set_timer_ext(struct efi_event *event, */ static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events, struct efi_event **event, - unsigned long *index) + size_t *index) { int i, j; diff --git a/lib/efi_selftest/efi_selftest_events.c b/lib/efi_selftest/efi_selftest_events.c index 532f165d43..b2cdc150da 100644 --- a/lib/efi_selftest/efi_selftest_events.c +++ b/lib/efi_selftest/efi_selftest_events.c @@ -108,7 +108,7 @@ static int teardown(void) */ static int execute(void) { - unsigned long index; + size_t index; efi_status_t ret; /* Set 10 ms timer */ diff --git a/lib/efi_selftest/efi_selftest_tpl.c b/lib/efi_selftest/efi_selftest_tpl.c index 5d13f3b52d..0b78ee7595 100644 --- a/lib/efi_selftest/efi_selftest_tpl.c +++ b/lib/efi_selftest/efi_selftest_tpl.c @@ -110,7 +110,7 @@ static int teardown(void) */ static int execute(void) { - unsigned long index; + size_t index; efi_status_t ret; UINTN old_tpl; From patchwork Thu Oct 5 14:35:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821853 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 3y7FsJ0PnJz9t2h for ; Fri, 6 Oct 2017 01:44:20 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CA634C21FCA; Thu, 5 Oct 2017 14:38:54 +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 5E5D2C21F99; Thu, 5 Oct 2017 14:37:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 72393C21FD0; Thu, 5 Oct 2017 14:36:55 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 96257C21FA0 for ; Thu, 5 Oct 2017 14:36:52 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Lxu7U-1dCkC41c9s-015Gh2; Thu, 05 Oct 2017 16:36:16 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:35:55 +0200 Message-Id: <20171005143607.25955-6-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:r8WUEamRGOOKr9n9OvbPzeGveAOY4JNyPc33Yez2WngZJlTOufn sVTDEflB0aoX2KhyVmJB+oElMl8T9PFX8R+x/Psm0rkcxjgjtTuRHwwZ6wysGT5GMq7Totw U2oWZSXSzNvwaI2MPCkEqfgWNI+14cJAyQa/KKIiUJX5QWpA/OYRZkTLjvEpVx0rxzgr0Q3 ZV9j7eFVmFK/jhHecnvuQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:XcwQpvgwRkc=:086qMTIgu3qvB8WW6bz4VW /Pcre2eqwipteaiUKWPi7nOYE3zGqW/A78f6pq+vVd0vOrQh7NVXskeQRYPI18XaTyDx605cc PIvG48YbXBT2X2p45qXhO6T62AaJCnACJkoBTak6ovQq4s69qgiAJRtdXmcJK/2m7sWW6RxrZ roXB8RKi1rbtjTI1u5GprTlUAsmiFJYjCBrCF52IGVRLSGYTE3oe+ugWC/3Pa+ijeCD1YRA0z tnjOi67AZ2DkLM7FpdCz8+BbkRBhb91RM0kBSyiqLa4XrVdtiEbWpRD179xvaIqFoY/B2VEZJ JVHhVrkZX2mJO5UaPbHBwfsVq87Qysq1blZOQOXOE93hPgFxVFWD0h7QkOXWu2j9blnGuf6HX T+0M7mJWLpV9+3AaJExZIsskFZtyoFI6sGwSKuzf5WURvayvYOkKOqzlRdyzzMicr3NSUrOox 5rJGoK3ZbCg5gSwcHAkRC3oD+zW2oLXv6nuT8LXsqwMpwdYtaySYzevAbgHMmbuDpHB5rWxJ+ rol6tSmc7ueziCKMwLZGhffmU20A4u4gafFYhCQuPVD7NhCwDuhRT8sK/ohjDqulXRnLOf7hQ 1zmLSc2fkz0yHIHi+cciOfNLVFcfnvfO2HSex/In7lBRlgAxd6TBhaOhm+MhUzoGg9ObHzoBA UUPLnOeFThXUCOy9JxtbMOqsL47G1VWTaZ94YOO//7BNt1GMzhFn5j04wHdYnNkRE7k239DXt 4qjsKWhGlcfcYUyL8NGZm7P0THKqUAYhNep2aMp+PUp5F1Jizc4iorxGOFl4imEeZodr/4hUy G+NFouaPGiaYpMxFXQRIVeh5jOAgg== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 05/17] efi_loader: incorrect definition of EFI_SIMPLE_NETWORK_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" WaitForPacket is an event and not a function pointer. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- include/efi_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/efi_api.h b/include/efi_api.h index c44dc9d0cb..308baeec49 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -633,7 +633,7 @@ struct efi_simple_network ulong *header_size, ulong *buffer_size, void *buffer, struct efi_mac_address *src_addr, struct efi_mac_address *dest_addr, u16 *protocol); - void (EFIAPI *waitforpacket)(void); + struct efi_event *wait_for_packet; struct efi_simple_network_mode *mode; }; From patchwork Thu Oct 5 14:35:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821843 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 3y7Fm14S7Sz9sNw for ; Fri, 6 Oct 2017 01:39:45 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5C8E3C21FBB; Thu, 5 Oct 2017 14:38:36 +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 5D4A3C21E31; Thu, 5 Oct 2017 14:37:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7DBB6C21FD1; Thu, 5 Oct 2017 14:36:56 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 1300FC21FAB for ; Thu, 5 Oct 2017 14:36:53 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M1iGk-1dB2qI3DJK-00tiVm; Thu, 05 Oct 2017 16:36:16 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:35:56 +0200 Message-Id: <20171005143607.25955-7-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:JegOAxdOnLxYx9uX3qAiWtEHDT25QZilp1LlOe2VebZIrD/euk7 KIsxtLnIJHWf/CXqrN81REqK8NVIZGq+xnOddGixU+1RdTTeA4UowN24rEblyeOHL7mChA+ TM2jbBbnuTCiy0n10ipYcX/R0DMuJNH2J65bw4QybsiaLFvK86EqYlxYirYl3DSYL1t81Hl Ok58leWB6JbAIxv9jucEQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:PHzOViwbWhc=:3gNhLTYK8qABxNs1F6qIRH 3Xdhk/tq5PH02MmrbLEAUY6enE+wDDGn1onMZfyHZyGSLayqPlf3IG5ulgyrqNBeywOC9N9j1 WRvnS6hKtTWOxLGGzaWSS4m7X0SNZNqyeKKx2MyzIkaJ460x6WnGi5taghOnv/lbIx71s4Ndn knZks5u82w806nhzNGKVNSrtiq6vYioK905lc+atGa1UbYc/vJxtATeIprTu0Q69vGsOOpjAt twNljjWaEYNXJeWm30XKM56wJvPv/Ch3kGcJH/F7bukf1RXYlxYFI6jf+lkbLDXh0HtXHzXvK w6DZ6sEf76bdt0oyLAgsNrkUj6+OTZBx3ESjZuhhiAR9GOXNyfv2jAIY042KQvKAjfmmM0gVJ 9DKPnPHUz07X+IGr4GDygr3qPNijXdxWSjuTMVZcR5fWCZK0bBN6AyD3Kd1o53ANTxGUEuk6d eieTeMQTzSp/Nti8DrgJNjgFB1qwWXLKPv8+LYcu77yme6UMPTuJonKZqMq2fsxPt6watXtLA vC1JnCSoZ/ebXbofYNQSXnKCg9D2s79Dakd5d3Uq1dyCWqTU8oTGD3TkI1dzm7ivs6NkWxEG0 NQJeFubiCK2zXlCa08Tp7pvCqiiW4ZHyZ+IhJs9jw4A46Ps0HS89kuo7YNxop1zO1vABWMaQ6 2d0z/jk7S35TIj+syrg/RXs+3zEd5s8uygPNraVVDjQ81xgtIgwvsiP260KGLB8PO74s+W8ZN xFim8uEyLkoLCqzUsEpRXhAkDeU0BUd5FmmJnnv/HR4KASNfNgxty4ffXf7UVLRkfLduA+m5c oeQtsiWDhjmnasmuJ7Gfmg9Z1DkPA== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 06/17] efi_loader: correct bits of receive_filters bit mask 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 extraneous commas. Add comment. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- include/efi_api.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 308baeec49..8c227ce703 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -593,11 +593,12 @@ struct efi_simple_network_mode { u8 media_present; }; -#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01, -#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02, -#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04, -#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08, -#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10, +/* receive_filters bit mask */ +#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01 +#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02 +#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04 +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08 +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10 struct efi_simple_network { From patchwork Thu Oct 5 14:35:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821857 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 3y7FtL1H9Fz9t2h for ; Fri, 6 Oct 2017 01:45:12 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 58861C21FD9; Thu, 5 Oct 2017 14:42:02 +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 93FF6C2200D; Thu, 5 Oct 2017 14:37:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 57D20C21FAB; Thu, 5 Oct 2017 14:37:04 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 70645C21FCB for ; Thu, 5 Oct 2017 14:37:00 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M0bo2-1d9wul0JQs-00uoRS; Thu, 05 Oct 2017 16:36:17 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:35:57 +0200 Message-Id: <20171005143607.25955-8-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:9LCoiXQIc4Qkqm4buTBUmuY9cjY0/Ueo1/K2lD6fZI199RamvJf Eq/bSsoruVb8uUw3j/bVEF7ZMvAFoUB5RdH4ZR2x+JBBXyFrBZVbeX9pVmmtiwc+lmr69HI TTu/ZzKcc7f8AUt3GGeI+jWAxNaiRwzefTSCVsPFDVgYSxiKn825BJtZwM76Yi1xbgcU2ex rWoMC0J4ktnt6hmB1eQ+A== X-UI-Out-Filterresults: notjunk:1; V01:K0:QCISLJMPnF4=:SsV+J1l8LMF3H92+S/CbnS id3O54fi4SBkXWEBC70litSDYOVWrzv5mUqUXC1O5gWFlVcVeBjBAajQNtQTxEq8LfHSXI1Yn kdXur8ykFJCinDCtV4lJzlMOMvut2jWI6vuT67Qq+Rz5qJlW7WxjGBxBBeVm26bMbDD3IhVkU oXoIU2a6mdCe9rx/60bivwey2ewc4pi/cW6ZK9qIGy8gpmEROavnaqkSHZBj9BYmR3mobX6tf jySSuibtm15ivbkJkZTOAC7rFn92CdcfXVEyx4iUJyMoSNjiWrSP64OUA0rSewuXTTlwLR6rN krNMtXq72cah6nn9AbaB3QkhbhvrhBzh+K+PIStRUcqe+SBlesYwqW6U4UNtVnDSs2f0ObnF0 usypCnZ7ww1ZVpnUUFCk+GGr7HVLnJilKsVaS+PJeE9R4OgY94imByrsjf00eWq968mxD/OnN etHzPgFU0BZ/OfCRzIcsoaeAC9bIBx/8iDxtKVlGNafYJQCzH4snSQQLETac367U8x7m25OO2 g+EWQpAhAsBONlHcbz+evJp5V84xGv/hk1snvDzcaqdT4unMl/YGH1714mnzlf5+op9rC0Rhb MeRXdh1KdjWEw3B85VTxi4BHUr25LAx2vDa5F1qkh8ICzDuAB7t4y9Bleczz3E6zW5M7DXG9u yG8AYUR+0xhAU/QTSPvqcIZFydhsyHfzKmAtdqhLjMssBATjVDA7p9Vr0xvR3K8jyZE61u9En il4vh+wWDVQLQzW6fFs75KeCCCVZf37RARG6d/8TsrbtGbSE5ESFOrGm5IZE39De0v+pg5yLK bhBpknoYkGzJbInqMyuC4ow9zcw7Q== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 07/17] efi_loader: fill simple network protocol revision 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 the simple network protocol revision. This revision number could be used to identify backwards compatible enhancements of the protocol. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- include/efi_api.h | 3 +++ lib/efi_loader/efi_net.c | 1 + 2 files changed, 4 insertions(+) diff --git a/include/efi_api.h b/include/efi_api.h index 8c227ce703..2f31464cb3 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -600,6 +600,9 @@ struct efi_simple_network_mode { #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10 +/* revision of the simple network protocol */ +#define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000 + struct efi_simple_network { u64 revision; diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index 91f1e4a69e..fb23bcf633 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -228,6 +228,7 @@ int efi_net_register(void) netobj->parent.protocols[2].guid = &efi_pxe_guid; netobj->parent.protocols[2].protocol_interface = &netobj->pxe; netobj->parent.handle = &netobj->net; + netobj->net.revision = EFI_SIMPLE_NETWORK_PROTOCOL_REVISION; netobj->net.start = efi_net_start; netobj->net.stop = efi_net_stop; netobj->net.initialize = efi_net_initialize; From patchwork Thu Oct 5 14:35:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821852 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 3y7FrW45z0z9sNw for ; Fri, 6 Oct 2017 01:43:39 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 4C033C21FD9; Thu, 5 Oct 2017 14:39:10 +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 4B809C21FE1; Thu, 5 Oct 2017 14:37:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B8232C21FD0; Thu, 5 Oct 2017 14:36:57 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 79A7FC21FAC for ; Thu, 5 Oct 2017 14:36:53 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Mam2Q-1dk6Xr1iyQ-00KNh4; Thu, 05 Oct 2017 16:36:17 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:35:58 +0200 Message-Id: <20171005143607.25955-9-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:168IhWPZg7/JY4wmh8aZYy2A4c6uV6GgTXkIWy+zQz6cmJAX6pw Jttw8Jh1TFcArLUgkhV/8OhOm3URJHMrqCb1Zd2YfUs1Nzsu7sqqztNgV7+ZSJULDFE6U1F kdmDeoOdETgZtlLXxo8PNTZ9Nq1UlRX0WiKVkAWvq7V5OxFmA0nkAwf5aQWbL79m3RJM0VE rHH6x500rdCMv/o4Ks+Cw== X-UI-Out-Filterresults: notjunk:1; V01:K0:Ef/DXn2F2uY=:vglWqGeoLpp6zJDT3VWQ36 RwnqfnpT+4JtFz850aIb7SxxexYqq3yXEYFbj2S0iSLLeRVj6Agc39kQERPC4FJm+bR7pi9cj grD8v5z6uFLQT+pDGPHdCgPspo1B6VplwR+z1pZ0NSjAu+DSLEEHgk5IhZFUf7kwLoqef4niH MkheW5+Njy2srmRT9JP8iasngwrMP6Ng7TMqRAaB7lvuyHQxjhiBISBY/1CQZvwNHCcrUmmMI hd/+SZBwLNRRyPU2tIG7CVnU8OStJs5uMzuwip7Coer3my3xcixz7hv3OeojtQ/iQ3gBih5j1 F/UwKV+XMS74b3eEw0ec8UHb5InjByCMtfqgYM0CSlfUKd0rjwxZY+rt9VYUiup2ANNDf+yxW ZvYCJuoPrErVBUuud9aCluszIQpzsqZr6uTmzdd/ODo6JkdiNpR3BnEwGpKyl3tmzBO+0oGMj ijC2CpmWxIQEhYsm54eNwMLUiK6gIhb0MgDZOJMklv+r9/r27g4/5+gkLMq08rvZEdeOsRbOK 4EGgypyhKveo0pplAqLTzGcQ5bCT8FSBzTXXVXmcSdLWwKjmqaLBRpQQ8w+DjEy4yIkPjstb4 FQxMLc/Grvv1o4tnI1DTbk8dnmsBZvItDj3yOX4XdkJLs/b7DTap/PO80Z7urZQINDs9Rkf9A l1b7qPxZi/2cz0Q4l3PJItt3jLkbhmrhUIPdc1iMTpQp5XuOIhjW/jQyh9ibOcuf/2sxusLcI jubicRwt3YjyaDmHkiwN+yfRxYdyyuICt9GjRMNPvChgOXvIV1+KEkGVMKe8JuijdTsKb/Bor SCJXgrdrGVc0rFbcIUToDc/9t1d+A== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 08/17] efi_loader: efi_net: hwaddr_size = 6 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 length of a MAC address is 6. We have to set this length in the EFI_SIMPLE_NETWORK_MODE structure of the EFI_SIMPLE_NETWORK_PROTOCOL. Without this patch iPXE fails to initialize the network with error message SNP MAC(001e0633bcbf,0x0) has invalid hardware address length 0 Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- lib/efi_loader/efi_net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index fb23bcf633..9def34cf93 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -245,6 +245,7 @@ int efi_net_register(void) netobj->net.mode = &netobj->net_mode; netobj->net_mode.state = EFI_NETWORK_STARTED; memcpy(netobj->net_mode.current_address.mac_addr, eth_get_ethaddr(), 6); + netobj->net_mode.hwaddr_size = ARP_HLEN; netobj->net_mode.max_packet_size = PKTSIZE; netobj->pxe.mode = &netobj->pxe_mode; From patchwork Thu Oct 5 14:35:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821864 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 3y7Fvy36wTz9t2m for ; Fri, 6 Oct 2017 01:46:38 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 2177BC21FD7; Thu, 5 Oct 2017 14:40:57 +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 D7576C21FCB; Thu, 5 Oct 2017 14:37:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4CA4BC21FBF; Thu, 5 Oct 2017 14:37:03 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 4611AC21E31 for ; Thu, 5 Oct 2017 14:37:00 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LjdS8-1dTGTx3Jge-00bdQe; Thu, 05 Oct 2017 16:36:17 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:35:59 +0200 Message-Id: <20171005143607.25955-10-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:YfjGD3um1uGcmHswhIHiAxhG/aQG16N3So4cowcvnLER+6qkVSt G9A5zbIUr4i4HfMnKg8fjTT8vGO77MYJ+Q94QAQB0i0Edw15F6IqqLNhh1nwMrZYeMW3YlE YWdvw7/HplViEvtuSoa+3raOpNGRjH5wnJ8Izptuu4uxtj4y4LpxjPSnN8l7wLEkOgcxOnv 6pyxPKEBSMFksv1uIPR9Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:/zZqn5a+Hm8=:LIW5u3Fhq2DFbBpedAlxYA Rd4d0lqOqLimAG1g8t6hQu7RmQspq1oBDE+hkTj/fmOSETZW3ROFa3DlpXksihHj4ZpXEcQ3I 1QsQ3K8hHN3Wcstl0o6kq/swpe8YbVrExOatGSmahbk6SHGg7/vM6EEBqw1Rpl32hxPRsn1bt mkeznRufc3ROSt0gJbiKcxdjtOt9er/oloihA20Qtcap+yj4uOmz77dHRZ5bFuybvy9CkYVYd irLgI7z0EVS3bG1bNeYzSo3ib4X3+G7xUG88ZMwQ5C/N8knkeJZUqXcth8Z9gW1wNtjNG626d VdcZi3vLtLgBW/1RfooQ8MrWsET4Gng9+u4QJsSslIlbdkDLBnJDONRsVBOSGCvKNpi+Ph8DM 186OpCawWG1hnvDqr2bbzBLUQSwcPQt9KfSCR8s5TLzoKu8xhizJuXYo0p095lXP/OB9gkNIo xI1wSyTrGoCpheACzSjSoMS8pOY+5QGDxZKn4jWXc7khcfpBnoPXxap9kXZYPMfgKYG/UnivJ YhdnmOnyeBhrCMsMDpVBUfnE+mxJcdTx6gZnGqGWy1DbOwboDi5alUAE6DAiB8hNS2Rx35nQR D6n6RLAf0BH343MKqNNq7yyg9LZ2CtEo6XNt2iu0uq5AQlS372IqhYV1w0SHagJ48DHMY7Y/t sZUwZR6kAE/FAdbG+KD1YVf/y+dWk9hz0rFFsUBodSUxCU0i7qnPD+FbC3Kf9EZtZn+40rP1s fkUxU+4x0CMSgiphnmnQOGwnma5MWRAlme4V2Ae+LrO0r9nmDgGIUUY6ETqrz/VPusIEVssfX c1OgfIa3Ejs6f2JNnJ6feTZFdmG2w== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 09/17] efi_net: return EFI_UNSUPPORTED where appropriate 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" U-Boot does not implement all functions of the simple network protocol. The unimplemented functions return either of EFI_SUCCESS and EFI_INVALID_PARAMETER. The UEFI spec foresees to return EFI_UNSUPPORTED in these cases. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- lib/efi_loader/efi_net.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index 9def34cf93..569bf367a8 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -78,9 +78,7 @@ static efi_status_t EFIAPI efi_net_receive_filters( EFI_ENTRY("%p, %x, %x, %x, %lx, %p", this, enable, disable, reset_mcast_filter, mcast_filter_count, mcast_filter); - /* XXX Do we care? */ - - return EFI_EXIT(EFI_SUCCESS); + return EFI_EXIT(EFI_UNSUPPORTED); } static efi_status_t EFIAPI efi_net_station_address( @@ -89,7 +87,7 @@ static efi_status_t EFIAPI efi_net_station_address( { EFI_ENTRY("%p, %x, %p", this, reset, new_mac); - return EFI_EXIT(EFI_INVALID_PARAMETER); + return EFI_EXIT(EFI_UNSUPPORTED); } static efi_status_t EFIAPI efi_net_statistics(struct efi_simple_network *this, @@ -98,7 +96,7 @@ static efi_status_t EFIAPI efi_net_statistics(struct efi_simple_network *this, { EFI_ENTRY("%p, %x, %p, %p", this, reset, stat_size, stat_table); - return EFI_EXIT(EFI_INVALID_PARAMETER); + return EFI_EXIT(EFI_UNSUPPORTED); } static efi_status_t EFIAPI efi_net_mcastiptomac(struct efi_simple_network *this, @@ -118,7 +116,7 @@ static efi_status_t EFIAPI efi_net_nvdata(struct efi_simple_network *this, EFI_ENTRY("%p, %x, %lx, %lx, %p", this, read_write, offset, buffer_size, buffer); - return EFI_EXIT(EFI_INVALID_PARAMETER); + return EFI_EXIT(EFI_UNSUPPORTED); } static efi_status_t EFIAPI efi_net_get_status(struct efi_simple_network *this, From patchwork Thu Oct 5 14:36:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821859 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 3y7Ftx6FMbz9t2h for ; Fri, 6 Oct 2017 01:45:45 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A0FB6C21FC7; Thu, 5 Oct 2017 14:42:17 +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 E312DC21FB7; Thu, 5 Oct 2017 14:37:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7EA11C2201D; Thu, 5 Oct 2017 14:37:03 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 164B7C21FB5 for ; Thu, 5 Oct 2017 14:37:00 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LzYY2-1dDHtI0Z1e-014izi; Thu, 05 Oct 2017 16:36:18 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:36:00 +0200 Message-Id: <20171005143607.25955-11-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:oHiipYyEtQkKn++K+UlZnwavai961w85QlmV+TNtanAWrrfuibG TEE7AP190n2EjXFwkXW3m+1UytIMRpF/5CaLeKvFowssTC7A9GXjUUCJFDx5PwPjMYzRKTX GaMJAKXpCRYeeLPF927VhPg9tJTViHT3Bzu+3KZD0CXXzhe2F38cXdJ+pEkoD3X3TrxLUVR MAgYTWrwS1tX9iBRQ36WQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:NdeSxDWVfn8=:FIcFIU7l5LDOcl/cJimt0l 6gZv2nmxRNPUgWIquGaxbRU0+ZQRtnYxYTPqXDRJrN6j4y6IheoF34bEdepf7udqi1/53FTvW d8Ze6mqy4dREnVKJe4j9p4Q75rFdwYKlrS5z4fHtWnxsNiLeTNwnubI04YSzgnVowif4dndoE eFzVMZcLcVI/NJ4oxuOO48HCP7TfWBLn+ZldfWKVBNYK/AhoIWK7VdttbU4/n7ZTTBiQ/psb2 s+Kj92jASnWVnozX4bRVxX2q9NrQZzoEtLa0FnSR05uWXmO3nl8/npT2Kj2yiTgvzdPI9tPpH dJ10GCJOItye6x29Ewi26qRryxGmubyu/KRdgiZdbF8Rn70PS/u/wHiWBfcrXtWhk6VXX2/c/ GyK4F2doh3Y/kMFJKohh1weObp+ZSEGiU2CZk7kEfQOGG53UreK6fnKodTe6KRXRqaPE/1sL7 2QwYm7errNy9PLO2GwoxypDTp5SEfDLyJqJJ3q404HvBw8R2tdIf5Ebw5PNU2yKjNKHpvcIp5 8BlIYCE/NuJR1spzfcLy40V66AL03UCdiEfFTa9eiBa0P4Ije4/BVSEWa0MLc1P/TMGiz6Zi1 nUzDl/SDqo4Wwsy/uBp1xczpprcDbRY4nAPccYDlO3ogEr/kwuL3xloj/plYXWSWOcqLpoiiH AVgr8cIEAhZTtE+IO1YAYDoCvmk19eCHHQ4ZsMwBlsS6ta7MjlmK4WJR/wPmasCVJXbd5gHX8 aLGqG1LKRFNTz7ZiXzePmM5QY0uP+Cuz9JGvE9bZp73DdWS4uDawdnULrc0V4+89G1RhVdvhB hQhjMBpNKDWvrbpOPnwPVJiyJNAXw== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 10/17] efi_loader: use events for efi_net_receive 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 timer event is defined. The timer handler cares for receiving new packets. efi_timer_check is called both in efi_net_transmit and efi_net_receive to enable events during network communication. Calling efi_timer_check in efi_net_get_status is implemented in a separate patch. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- lib/efi_loader/efi_net.c | 53 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index 569bf367a8..3498b96f7a 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -19,6 +19,11 @@ static const efi_guid_t efi_pxe_guid = EFI_PXE_GUID; static struct efi_pxe_packet *dhcp_ack; static bool new_rx_packet; static void *new_tx_packet; +/* + * The notification function of this event is called in every timer cycle + * to check if a new network packet has been received. + */ +static struct efi_event *network_timer_event; struct efi_net_obj { /* Generic EFI object parent class data */ @@ -143,6 +148,8 @@ static efi_status_t EFIAPI efi_net_transmit(struct efi_simple_network *this, EFI_ENTRY("%p, %lx, %lx, %p, %p, %p, %p", this, header_size, buffer_size, buffer, src_addr, dest_addr, protocol); + efi_timer_check(); + if (header_size) { /* We would need to create the header if header_size != 0 */ return EFI_EXIT(EFI_INVALID_PARAMETER); @@ -174,9 +181,7 @@ static efi_status_t EFIAPI efi_net_receive(struct efi_simple_network *this, EFI_ENTRY("%p, %p, %p, %p, %p, %p, %p", this, header_size, buffer_size, buffer, src_addr, dest_addr, protocol); - push_packet = efi_net_push; - eth_rx(); - push_packet = NULL; + efi_timer_check(); if (!new_rx_packet) return EFI_EXIT(EFI_NOT_READY); @@ -204,10 +209,32 @@ void efi_net_set_dhcp_ack(void *pkt, int len) memcpy(dhcp_ack, pkt, min(len, maxsize)); } +/* + * Check if a new network packet has been received. + * + * This notification function is called in every timer cycle. + * + * @event the event for which this notification function is registered + * @context event context - not used in this function + */ +static void EFIAPI efi_network_timer_notify(struct efi_event *event, + void *context) +{ + EFI_ENTRY("%p, %p", event, context); + + if (!new_rx_packet) { + push_packet = efi_net_push; + eth_rx(); + push_packet = NULL; + } + EFI_EXIT(EFI_SUCCESS); +} + /* This gets called from do_bootefi_exec(). */ int efi_net_register(void) { struct efi_net_obj *netobj; + efi_status_t r; if (!eth_get_dev()) { /* No eth device active, don't expose any */ @@ -253,5 +280,25 @@ int efi_net_register(void) /* Hook net up to the device list */ list_add_tail(&netobj->parent.link, &efi_obj_list); + /* + * Create a timer event. + * + * The notification function is used to check if an new networkd packet + * has been received. + */ + r = efi_create_event(EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, + efi_network_timer_notify, NULL, + &network_timer_event); + if (r != EFI_SUCCESS) { + printf("ERROR: Failed to register network event\n"); + return r; + } + /* Network is time critical, create event in every timer cyle */ + r = efi_set_timer(network_timer_event, EFI_TIMER_PERIODIC, 0); + if (r != EFI_SUCCESS) { + printf("ERROR: Failed to set network timer\n"); + return r; + } + return 0; } From patchwork Thu Oct 5 14:36:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821851 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 3y7FrR56DGz9sNw for ; Fri, 6 Oct 2017 01:43:35 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 7B932C21FC3; Thu, 5 Oct 2017 14:40:23 +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 2A816C21FF3; Thu, 5 Oct 2017 14:37:15 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 30AD5C21FAD; Thu, 5 Oct 2017 14:37:02 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 70157C21F9C for ; Thu, 5 Oct 2017 14:36:59 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LcmN9-1dYW4D24m7-00kBKp; Thu, 05 Oct 2017 16:36:18 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:36:01 +0200 Message-Id: <20171005143607.25955-12-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:smjevVEMX5yPyn40iDFLX+3hsiPMgalm4aU4TBXwgoPXav74nbw IhV7kPQljumPg8bq+/4dymWPp2bInJ9jEcRUPummARmR4VGhB1VXChVhvkTOViWHbURS+sE CxJdVXCHneMC9/3npGB6MjIWR6qlrlOi99q0xfxZ+EAxkXl0ozZ2u8YsemR+t3luTh+Lwq1 p5hK2vxYKB3fGnBm2rBVA== X-UI-Out-Filterresults: notjunk:1; V01:K0:i/xJKy02CRE=:NKO9J642j87P7rruu9YHGR v/fw/V01EiZl5cpKQ34s9UDI0ezTyeTEa/avw4LS2KIC+wpK6IPlHW6bEo3QCYWODwBPJDt+p vKhEHwtXg9uxOac3ZhctJIpnXgn0yqpptRZdbzOJA47pmiJ/dpQhgTbqfjDCZn1FDQXdSnor9 XHGdQqHVQfZGNCq76gGRZQnQEML6w+MYosNVTWqQpJBRwqdhy2RyHSCZZHBrKu/t4HpgLdeoz e2U+Qj1czlY5vwNhV7PzXDmvw1Xii+3iEeyEpyPc5fwGyErTBncxsMV8IbC5yyT01Up7GhzFi k7rzZEgzcQ6Zak3FVpdbyE1CgBrFutVQkYI5ZZgdNk5alnRRGznMnNmEyU6DIPoLLd96nU9o9 mGmNe5+bGO5CUgKWfd1+gnTEqH7oRvD0QJnDSeILxGFKIJ41Lv8YIQ27ITood+VS6YirenAO+ xcDB6NVF2FiBBF2r5co/OZrHxzuBHtUmQHueAe92VjHWBo4wJ3yF8JyC5B1QWxsM5lJ7ZT+vp sxrwmYHz9Gav/i1hVyXKkBGf74AmHO6W+OoA4cRFNZuIUM3wLx3AKZkbYxdjKMIu1Vzptcl/r s4XDh8dqasPNUDBN7jNW4iXmWElN0ntTdALGEbyU+NJ9o7hZVKoqAaJbmyV1p8BTZuy0wIIzF 1a5PMTQLuGBqq+tYSMGNZlhH46YxGgn7cRzImRjQQtATLwXkL+kap9bBCLRDfaZEepCxNV/Z7 LqeIzjzQ9DfxYUDDVGHche3Kl74eYFVWBMB1WMVR5NZPEMrMdoVRAzxz3Vbkhzl2MFusI5Xrp usREsE/4TkTYaH/NpuiTsW6tz/G5g== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 11/17] efi_loader: implement WaitForPacket event 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 WaitForPacket event informs that a network package has been received by the SimpleNetworkProtocol. Signed-off-by: Heinrich Schuchardt --- v2 signaled has been renamed to is_signaled and is bool --- lib/efi_loader/efi_net.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index 3498b96f7a..f63db686af 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -24,6 +24,10 @@ static void *new_tx_packet; * to check if a new network packet has been received. */ static struct efi_event *network_timer_event; +/* + * This event is signaled when a packet has been received. + */ +static struct efi_event *wait_for_packet; struct efi_net_obj { /* Generic EFI object parent class data */ @@ -227,6 +231,8 @@ static void EFIAPI efi_network_timer_notify(struct efi_event *event, eth_rx(); push_packet = NULL; } + if (!new_rx_packet) + wait_for_packet->is_signaled = true; EFI_EXIT(EFI_SUCCESS); } @@ -280,6 +286,17 @@ int efi_net_register(void) /* Hook net up to the device list */ list_add_tail(&netobj->parent.link, &efi_obj_list); + /* + * Create WaitForPacket event. + */ + r = efi_create_event(EVT_NOTIFY_WAIT, TPL_CALLBACK, + efi_network_timer_notify, NULL, + &wait_for_packet); + if (r != EFI_SUCCESS) { + printf("ERROR: Failed to register network event\n"); + return r; + } + netobj->net.wait_for_packet = wait_for_packet; /* * Create a timer event. * From patchwork Thu Oct 5 14:36:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821855 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 3y7FsY4KVkz9t2h for ; Fri, 6 Oct 2017 01:44:33 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 356ADC21FB8; Thu, 5 Oct 2017 14:41:47 +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 B9567C22010; Thu, 5 Oct 2017 14:37:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 22A1FC2200F; Thu, 5 Oct 2017 14:37:02 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id BAFABC21FBF for ; Thu, 5 Oct 2017 14:36:58 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LiWzQ-1dSAYQ3bKu-00cjMK; Thu, 05 Oct 2017 16:36:18 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:36:02 +0200 Message-Id: <20171005143607.25955-13-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:J32f72WI1icvWwXexWssF2SigvUpopcidJL9EKzUsJdUjt1cKD+ DmUBSfeJ4FTP7QHKKGL0dUsClCB7Hf+8BxKJfs+HVZtO6f/limV2b9HuYdQac8aOuOvq9nS ypj/yVw9out/Dr70LzK6/og99cTdL+pARqEuBe+Qlc8jvWFw32B8u/a7Kc4xxwO9CaMeMsY L0VWFVFnQGPrhZ701svAw== X-UI-Out-Filterresults: notjunk:1; V01:K0:2VRcoWdKt1A=:Q/2O/Nj+OIOErnfhzRJRz+ qR6pxFXx9hs8C+ZVvHMDXSuzakw3Zpr4S9rGMMn5D3I0fOAe4uvtA6BlbSPylh9YX+ESd80DI qNyG3+4pkIL1f+S0YaUW/Y2HHUkJyufFLXs+h8AL714xmsd0ar7sfRQa2TLwwzZuuOagFW0DH myXjBowbjpgGnaV7RHCCE2JFAm2oFAbJ2lMcdFiN1/NkLEIDdvh8lTdkMOxyhs10yUp9Tu379 5v/tiTQ0bu/gt+Y8AC9ozMXKuFZwdw6Nw7iOhoinZZk8LvUSyHd92Ym2g2v5jHocZWKCIewiO GainuYE/ji3cXdfiYbSHQy2Xg/UVz3IXQCjYmkHHD6VdVdEL+weuhN1cX/FPWW2fMugLpKyP3 RTWyMBXwFe8bhW7dBnRD1xbsUQv+w7QNAS7UMPWrPboiV/CipiYdip/Svbk+A7To2YVvnwe+a PTa4wABmnO0AvTSp1YY1X8E8obxo0nvaB4YxWqDD26IlSYGKurblTdo/Wua+tEnf5S0UodCQi y+C9h9JqtlxD/BpCR6vH2DLluksthDPs+lgyYqMlnCF4JwaO8GV+hE3Iyo9C57l+GKI4oqYHY EQavEma8IqE1J/zxxoNPoBdLnMHfx+1i291JYzyZAQOhvH0kMxM3HqbKY9f3AE65On/5o9vnP Oi+EPUAEOM9NNLYXzlKqV4SUYztTu4nsb5SV5wHSnxc2BaQ5SKeX5cpNDzUeE6gSWLdrQrf8s f8jLQ3r/nZdOZN0UKfWNksGlNQnyLLi8n/VQH6YwOCu+JzCRv5CBRsSSEn7gDBzuJUu9Qcop7 AYqDnozKqC0FiqgdmHRErdGAW0LeA== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 12/17] efi_loader: fix efi_net_get_status 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 returned interrupt status was wrong. As out transmit buffer is empty we need to always set EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT. When we have received a packet we need to set EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT. Furthermore we should call efi_timer_check() to handle events. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- include/efi_api.h | 6 ++++++ lib/efi_loader/efi_net.c | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 2f31464cb3..1f349db246 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -600,6 +600,12 @@ struct efi_simple_network_mode { #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10 +/* interrupt status bit mask */ +#define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01 +#define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02 +#define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04 +#define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08 + /* revision of the simple network protocol */ #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000 diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index f63db686af..5866119817 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -133,9 +133,14 @@ static efi_status_t EFIAPI efi_net_get_status(struct efi_simple_network *this, { EFI_ENTRY("%p, %p, %p", this, int_status, txbuf); - /* We send packets synchronously, so nothing is outstanding */ - if (int_status) - *int_status = 0; + efi_timer_check(); + + if (int_status) { + /* We send packets synchronously, so nothing is outstanding */ + *int_status = EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT; + if (new_rx_packet) + *int_status |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT; + } if (txbuf) *txbuf = new_tx_packet; From patchwork Thu Oct 5 14:36:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821862 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 3y7Fvh3swjz9t2h for ; Fri, 6 Oct 2017 01:46:24 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 59E15C21FC5; Thu, 5 Oct 2017 14:40:38 +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 0CE89C21FDA; Thu, 5 Oct 2017 14:37:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 71C76C21FB4; Thu, 5 Oct 2017 14:37:03 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id D34C0C21FBA for ; Thu, 5 Oct 2017 14:36:59 +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-1d8IDf0kw0-00s3Hg; Thu, 05 Oct 2017 16:36:19 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:36:03 +0200 Message-Id: <20171005143607.25955-14-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:KcW+r9hoiVAy0TlOawU61IuyLkgOPsLsEWI2nYRUmdl5P1abc84 bQDU3ymCTtNGtL9ROgFu01dBTBSeNDUwowRcHCqeQhbK0/Aih5+OtBad1IhYyAcaTbUSjU0 vPmJW+GOxpwQRwxj593iwxYG5+AhQyp8vDbVfdnbDNmgt4x+gjzKqgrIpWcoNy/2F6jLhRc eYMwC3NEjqDkP7/3XyV7A== X-UI-Out-Filterresults: notjunk:1; V01:K0:gjWvayfOzJg=:NlhvqMpEONNttBp+bT9qHW XAbG3D2X0lXUB8omSpeqX9o/gFaoEQtzK5m62LwNnqMcPs9eHHtZMPaPMu/VmagYXoRt9+869 wRT7VrqnPgPZiY7RbMTPRrnWFNOk8W+eStFlnMCgPplDIuTZGqGoYVNoTJey5Ho6OrKpoNr/8 q4ebjqu+QrBr2orpj9aIfpDQ8SZ9AR2I0NW0iEc1ODtPbFVlIbO5YM+s/lKia7zZ6Qx6sGgxq ydrEoNgjkxtJ+lnTAEg9ocuWHelzre03wUDHcYjqzJkgrNTUENpOPEcdjnhPJGj5naoCr3Xlw i9ajgqam4CLdkfElOxOdvxVoB7qo+Vbss8xwq9vHQBY6is+DDWy1bXStpxaSE9Wd55OVw26PT NycpwipodoHJ8I2roqVUQ7P0YWl2qEO85c43yfD1L1uJfgz4w5155pLPqaRQGcuG6EvaoWw+m 5ZiGTXycceNHXVwbXJTKNvfHzjcmYJ0b3Hrk9FCzd5RIJjA93UIfJ0f657hNLIPwJDBRJysBL eMoiMTKpUW2r386njCAkw++lg+KhkXAoHvh/VgvqkH2Xfxw62Xcl7k0gdF15cbYvqueLpjwun U3i1FQVMHf2SWF7PD/22DA4Q69oNMN6ZjBXwYzSReLkcls2Bvig7nWG+ivXj7GXteaod+dqvw iq6IT8liEzA4QfSfn6xE98bPNLmjjdxRYNGWKWksYkqBwGIQtgxgNG9kcfqJm9EDgD0gSlYnq Dav63BdEFxCphoms4z2IuO0PQkoYqAeElh+ZHlcDl9Rg+AiXZ8y9JmDpWZ/b6LsTGQvaJ5iVC Quw7i4HkQitZvT7fYZlqu6kra+ZKQ== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 13/17] efi_loader: size fields in SimpleNetworkProtocol 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 size fields in the Simple Network Protocol are all UINTN in the UEFI spec. So use size_t. Provide a function description of the receive function. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- include/efi_api.h | 4 ++-- lib/efi_loader/efi_net.c | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 1f349db246..a9a6494afe 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -636,11 +636,11 @@ struct efi_simple_network efi_status_t (EFIAPI *get_status)(struct efi_simple_network *this, u32 *int_status, void **txbuf); efi_status_t (EFIAPI *transmit)(struct efi_simple_network *this, - ulong header_size, ulong buffer_size, void *buffer, + size_t header_size, size_t buffer_size, void *buffer, struct efi_mac_address *src_addr, struct efi_mac_address *dest_addr, u16 *protocol); efi_status_t (EFIAPI *receive)(struct efi_simple_network *this, - ulong *header_size, ulong *buffer_size, void *buffer, + size_t *header_size, size_t *buffer_size, void *buffer, struct efi_mac_address *src_addr, struct efi_mac_address *dest_addr, u16 *protocol); struct efi_event *wait_for_packet; diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index 5866119817..f8ae5578ba 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -150,12 +150,13 @@ static efi_status_t EFIAPI efi_net_get_status(struct efi_simple_network *this, } static efi_status_t EFIAPI efi_net_transmit(struct efi_simple_network *this, - ulong header_size, ulong buffer_size, void *buffer, + size_t header_size, size_t buffer_size, void *buffer, struct efi_mac_address *src_addr, struct efi_mac_address *dest_addr, u16 *protocol) { - EFI_ENTRY("%p, %lx, %lx, %p, %p, %p, %p", this, header_size, - buffer_size, buffer, src_addr, dest_addr, protocol); + EFI_ENTRY("%p, %lu, %lu, %p, %p, %p, %p", this, + (unsigned long)header_size, (unsigned long)buffer_size, + buffer, src_addr, dest_addr, protocol); efi_timer_check(); @@ -182,8 +183,23 @@ static void efi_net_push(void *pkt, int len) new_rx_packet = true; } +/* + * Receive a packet from a network interface. + * + * This function implements the Receive service of the Simple Network Protocol. + * See the UEFI spec for details. + * + * @this the instance of the Simple Network Protocol + * @header_size size of the media header + * @buffer_size size of the buffer to receive the packet + * @buffer buffer to receive the packet + * @src_addr source MAC address + * @dest_addr destination MAC address + * @protocol protocol + * @return status code + */ static efi_status_t EFIAPI efi_net_receive(struct efi_simple_network *this, - ulong *header_size, ulong *buffer_size, void *buffer, + size_t *header_size, size_t *buffer_size, void *buffer, struct efi_mac_address *src_addr, struct efi_mac_address *dest_addr, u16 *protocol) { From patchwork Thu Oct 5 14:36:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821861 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 3y7Fv052kPz9t2h for ; Fri, 6 Oct 2017 01:45:48 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 7149CC21FBC; Thu, 5 Oct 2017 14:41:12 +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 AED2AC21FD7; Thu, 5 Oct 2017 14:37:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7A957C22004; Thu, 5 Oct 2017 14:36:58 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 11F73C21FBB for ; Thu, 5 Oct 2017 14:36:54 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MbJTE-1dhLvD28kG-00IiSy; Thu, 05 Oct 2017 16:36:19 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:36:04 +0200 Message-Id: <20171005143607.25955-15-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:2LP/5nQt8gWgIxtKhcnIXEjYgD3XlOR2BftzLDTJ0AIzg/0dhkf JYNO0s1ml2UsTq6k6Huh++McUbJi8cl+DMap25J23TgH8IYVC8eWbTy0s5H4SaaaS9/ANos v9P92I8ScUCZY//Zgc6nFDUnMhU7jK0CeR+Mh2WeYc8i6kYHkjnQC8X3Mo8qx/xD5sYGc0Y hM/MhB0AMUqOzUiceiZIw== X-UI-Out-Filterresults: notjunk:1; V01:K0:hyxzt3DmmbQ=:YPFiJPrbDOhgyGbSPC5XIj Zj6Yqet3sdo0IpChS5dP4jhNgRuHgxXEJ/4Qyh4rOc43zdrJscN1utij053jJhKdS/QihPzos LhqR8QJBY4Jl9don7/Jp1XSRC14KuiQDN6YgBB6FPRxVDqMc5Yf9+ofMMDCOkt4Je6Y4UIljd RucpcV1Uh59ClSW/4SGZZpn4/NCfyp7KV34JZCxZWjGy7Mbdl0B1qxgXGEmXJtfJP6dhedVZ9 OPPPBOHFPn+J+TMYn4+1fr/vsBP+9OqdZp+x+G74XpeXomc/g50NmX8kNFlXihYuVypcGKYOg 24ypVfLnAtk5BDJWFFS6hBy9rPac6vBukDIUjlnstUu1bAYCbrJO8OabH2D48aOVAZaaSrP0W d4owQbcEaG1zli94EuPeNrqGQ3NNcREss4GSdfJBTztUd4q5gfvEtRfP7VR1j4LbT9oars1Ma NOl9a3hkextRjIH0h+b1zqeq98RJvf80uZIJQT6ZBmKk4XOtbh/CclDMZrvV2AF5cUK2A9kWK B0gxbrsFIn3dxXDYAwjktgpnG181ADEo5gJO4dEzVC/H+RqKIrVTsMdK9SkQA9/ibk66v4OO4 soKo5GFojyauJVCq8veT37CtCN7VYp306VRG/4GkEYXi7oVkRycwJM4h9h0WSvCumo5R61Wvx vS8uiQq3ZmR9EIOL1Vvd82W9pjguY4jefNxe+lvI25FTlUzlPecTxbkhCY4Y1IEDYlNXfR+Xl ESAj77QuerprB6mujPJvGqzBb9hfvBBrZjHo19H6+w5Memn/jF53S6zCdBtQL45Wjv2cTdKiC Gu519hYnFT88B4xRcRtJfv43qyjHQ== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 14/17] efi_loader: fill return values in SimpleNetworkProtocol 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" In the receive function all return values should be filled. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- lib/efi_loader/efi_net.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index f8ae5578ba..9c85e1b72f 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -203,6 +203,10 @@ static efi_status_t EFIAPI efi_net_receive(struct efi_simple_network *this, struct efi_mac_address *src_addr, struct efi_mac_address *dest_addr, u16 *protocol) { + struct ethernet_hdr *eth_hdr; + size_t hdr_size = sizeof(struct ethernet_hdr); + u16 protlen; + EFI_ENTRY("%p, %p, %p, %p, %p, %p, %p", this, header_size, buffer_size, buffer, src_addr, dest_addr, protocol); @@ -210,13 +214,32 @@ static efi_status_t EFIAPI efi_net_receive(struct efi_simple_network *this, if (!new_rx_packet) return EFI_EXIT(EFI_NOT_READY); - + /* Check that we at least received an Ethernet header */ + if (net_rx_packet_len < sizeof(struct ethernet_hdr)) { + new_rx_packet = false; + return EFI_EXIT(EFI_NOT_READY); + } + /* Fill export parameters */ + eth_hdr = (struct ethernet_hdr *)net_rx_packet; + protlen = ntohs(eth_hdr->et_protlen); + if (protlen == 0x8100) { + hdr_size += 4; + protlen = ntohs(*(u16 *)&net_rx_packet[hdr_size - 2]); + } + if (header_size) + *header_size = hdr_size; + if (dest_addr) + memcpy(dest_addr, eth_hdr->et_dest, ARP_HLEN); + if (src_addr) + memcpy(src_addr, eth_hdr->et_src, ARP_HLEN); + if (protocol) + *protocol = protlen; if (*buffer_size < net_rx_packet_len) { /* Packet doesn't fit, try again with bigger buf */ *buffer_size = net_rx_packet_len; return EFI_EXIT(EFI_BUFFER_TOO_SMALL); } - + /* Copy packet */ memcpy(buffer, net_rx_packet, net_rx_packet_len); *buffer_size = net_rx_packet_len; new_rx_packet = false; From patchwork Thu Oct 5 14:36:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821860 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 3y7Fty3SVtz9t2m for ; Fri, 6 Oct 2017 01:45:46 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3BE7CC21FCB; Thu, 5 Oct 2017 14:40: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 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 2876EC21FEB; Thu, 5 Oct 2017 14:37:13 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AB519C21FDA; Thu, 5 Oct 2017 14:36:58 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 63278C21FC1 for ; Thu, 5 Oct 2017 14:36:54 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MQu9K-1drqIv3gWU-00UJJO; Thu, 05 Oct 2017 16:36:20 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:36:05 +0200 Message-Id: <20171005143607.25955-16-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:lk1IYi7YYe8Faguz1ybanVvKZLde0q3PwR19xMO3nGtiKhBFIGc sV3EC6dxZKxtrQFVJr+8aKChlfDYqOVtv4ag6olHu+/TK+ZZmnI7tGAbt3EpiPPbypTXbCN KIi9snieHpqKOLgp1yo3Df9/yHBcX1BN47npnXcfFDtb9RX82ccA3PA+gLeEdwnL7NUq2GP 7LDEGB4O0VcIwLIrUaKFg== X-UI-Out-Filterresults: notjunk:1; V01:K0:Wnq3PYda9zY=:fe9qCF515riv08wJyXqU5M aGYqx9eXEM2rHiQgf5fdLquCclnaCCNojf+y2Ikxbd91ugrMhy7zmKvniIOol2Cbt0SyKILho Lqa2S8Y2vvVzdldS+ZMaUo3yn/nEy7q5B/BPgp4VWTm8oOZFF9UDPv9x/uznXYg3MgQWOMR0Y 8EQ1LHmbcX/Lf4yNd6OCa/OrKQISiHfyUR0rTyTsVPuc/hjezsj11RhewtfFG2RMQm+nJf+bj IX/Cj8gk1W9jlypie0JIllu1lWnhJ25kKdqWUWFXVTzjR9RaSNn0z2E17P3SFqpK6wOr72lkD 79GXfDLRMYLUWPxIEX39V8T86SWQvuVqITRzJ+2I+i/McqutqvXQuUIJ4umfXbAPHfDoYwOZ2 oHQWpmZNFzGwvbvexPdiVNn5yqtD8Ors2KvHhQoqwnPGa9rutTf+OZq3IgAL7bRemXFWuEg7U JWxtBmBOms7fZYBLbfbt8JYWgH31OUAEcU5GhHnKnxCnT4b6j6HwwcQ0Uyl0pJUMEy2ROjniX kkxRbsjSrw2qKM00zIA7tuCLyaSOAo6TCaObtB3y6siAZ4rxjL6FY9PYZgzFMxE6kT+CZf4Ga vYm0BAo9H6qJlBpX+KTkMHO8BNzg9HBkMPexkWnIeeEBTznWrNKJCNgYjJiu4TxZCZJID862/ trq31ztrTf0jqlbxFxirKeQZA3+NyHP24DAmbT6fmy5kKn+rcx3PgcIo53Hy940Z2EkrEYlge bzgJ8QdQsSc+I/9Dns/knxbcPnvJACfwnobHUM+XavqwfZpgK+oS5zjlK5wuVAi3EXXFq7est Uk2Vx0uYnEO68o0wAxTqheFy73wkQ== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 15/17] efi_selftest: correct definition of efi_st_error 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" Enclose definition in parantheses to allow using efi_st_error like a void function. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- include/efi_selftest.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/efi_selftest.h b/include/efi_selftest.h index beb662d4e1..2f0992f06e 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -23,8 +23,8 @@ * @... format string followed by fields to print */ #define efi_st_error(...) \ - efi_st_printf("%s(%u):\nERROR: ", __FILE__, __LINE__); \ - efi_st_printf(__VA_ARGS__) \ + (efi_st_printf("%s(%u):\nERROR: ", __FILE__, __LINE__), \ + efi_st_printf(__VA_ARGS__)) \ /* * A test may be setup and executed at boottime, From patchwork Thu Oct 5 14:36:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821856 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 3y7Fsd1hxbz9t2h for ; Fri, 6 Oct 2017 01:44:37 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 11847C21FD9; Thu, 5 Oct 2017 14:41: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 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 28799C22002; Thu, 5 Oct 2017 14:37:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8E8E8C21FB4; Thu, 5 Oct 2017 14:36:59 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id A2067C21DAB for ; Thu, 5 Oct 2017 14:36:54 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Lpgew-1dL1gQ11RG-00fSNy; Thu, 05 Oct 2017 16:36:20 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:36:06 +0200 Message-Id: <20171005143607.25955-17-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:I4xYStMfH7cNg7MvatE7/dNwfwf0Bbn+3BxSEnTgKLWJ6wuc7w7 s8KeIz59I8UMK27MQh8wCycHpP+ZAKzQpMfMKvCznGgkB3bR4AM5v8PMVclPsD8Zq00rFtm LbzbzFsPy3kQ8JTZRSe2Lla7cxdwAJ3nZr4BmHEcL1jRVOqlYOrw4aYh52bMx62fV/L1Ch1 eCmvDyfmGdXAAmM1cDyYQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:a13oUnHSeEY=:gcYH46RIZGLukZq5FUpyfs ZSwISh8yzIav2ikr1Kt8ffj4bLhh6cjdcIprpQ/BrxY1iM5aXFfj6UpkWCZXkz405EfiYbetd CiUbseCc6w0wtgXuFtnrl5Vsmx8GHKTSnJvPI+3aBVQ4S20X+RVPcmq0CYldFEUbUXLqVv5Ka tZ8/ZI9g04ia90nSepeZJPMjelBrXMhgDXUogviX/jFTCPSRNHwgjQft63fKgmng2dm9oumZb svOwHqgeg71/s66RM7aQVLYCmSfnFt4kzmvrqTGodkLA53m9/ogzNLmf6q1x+xXc2Ufk/3z3C nX0apy9ARjvhWruBF3nQoK3k/TaCQj3HD8AWp7Zj5+vqOXZAoukZbCEAr/qxNAljYSDHEn8pk G4qoXihI6ma5EUXxIUUAunziW3CQTNxAdGpIB/1sfTSgvMy19tuR9a/58QTrYXvMdigO8gXgr ZygYaszawBv8sb9XKLGnh0orkFBEtQOjlxdO9zVRtp9f1Mq7Vmat1sFNz/8uhExasXHS9D3hj 2aS+sjbYx2+aNHlR9y9gXVcbKP3ApkTP2M2AcqRtZWaXUwrZ4H9pTV3EcWC0Pq6am9Z+lamIs 7xL3hgMvFoEiWwU9Zwo0VvLPp8ZDSw6m4Wg8DRFR3dEvZDvbi1oze8zTuq+QvINwq4g+h2vKV u1QykzU8vqXgWtObE2LNcOW8DOl/FPHWpZgo+dnr6B3Sow0W7tP0iOZms6HzMWDl3eSTh2HoI RwShCujPszK48uP7b1st7+uhLzguanWDeJCJVoBU4pjkyVcarmFz0YVuUh3zxb9yDx/0tdJ7P 6eUSYhiKLvfTGrU3x0IaYSScrw05w== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 16/17] efi_selftest: allow printing MAC addresses 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" Add %pm as format string to print a MAC address. This is helpful when analyzing network problems. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 no change --- lib/efi_selftest/efi_selftest_console.c | 41 ++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/efi_selftest/efi_selftest_console.c b/lib/efi_selftest/efi_selftest_console.c index 7b5b724a61..840e2290c6 100644 --- a/lib/efi_selftest/efi_selftest_console.c +++ b/lib/efi_selftest/efi_selftest_console.c @@ -12,6 +12,37 @@ struct efi_simple_text_output_protocol *con_out; struct efi_simple_input_interface *con_in; +/* + * Print a MAC address to an u16 string + * + * @pointer: mac address + * @buf: pointer to buffer address + * on return position of terminating zero word + */ +static void mac(void *pointer, u16 **buf) +{ + int i, j; + u16 c; + u8 *p = (u8 *)pointer; + u8 byte; + u16 *pos = *buf; + + for (i = 0; i < ARP_HLEN; ++i) { + if (i) + *pos++ = ':'; + byte = p[i]; + for (j = 4; j >= 0; j -= 4) { + c = (byte >> j) & 0x0f; + c += '0'; + if (c > '9') + c += 'a' - '9' - 1; + *pos++ = c; + } + } + *pos = 0; + *buf = pos; +} + /* * Print a pointer to an u16 string * @@ -146,7 +177,15 @@ void efi_st_printf(const char *fmt, ...) int2dec(va_arg(args, s32), &pos); break; case 'p': - pointer(va_arg(args, void*), &pos); + ++c; + switch (*c) { + case 'm': + mac(va_arg(args, void*), &pos); + break; + default: + --c; + pointer(va_arg(args, void*), &pos); + } break; case 's': s = va_arg(args, const char *); From patchwork Thu Oct 5 14:36:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 821858 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 3y7FtM5tS6z9t2h for ; Fri, 6 Oct 2017 01:45:15 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9E8C8C21FC3; Thu, 5 Oct 2017 14:39: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 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 64E42C21FAF; Thu, 5 Oct 2017 14:37:12 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8AFDCC21FD8; Thu, 5 Oct 2017 14:36:59 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id DAD37C21FB8 for ; Thu, 5 Oct 2017 14:36:55 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Lxdfb-1dFlnj2TyF-017Cu3; Thu, 05 Oct 2017 16:36:20 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Thu, 5 Oct 2017 16:36:07 +0200 Message-Id: <20171005143607.25955-18-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171005143607.25955-1-xypron.glpk@gmx.de> References: <20171005143607.25955-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:aTNm4mL4bVC0W7XVUtMONGwxvIJcB5ahNvGg0QOZDI88IF2oYuo wHXR86WlkKhPke177WLEhtHAvtxz/7P0flLB3owiPCKUcQqhEI8AiP/dOSO/ONuO9oTgdcC vOnLxJRA7FYVJh56E4UG0fES7xzzPPTMx1fZJkew4BHs/telY+DvB1tKFaRUMvnn2vJUXBi kueN8eDepRbC7JneVA4jw== X-UI-Out-Filterresults: notjunk:1; V01:K0:DzpTszAfmb8=:GHb2XtvmttdhNxMeWLV7Sn ZS0RkrjBfD73eruKhIAVAc6P18lOYmdZVcpLUFvQ5b/p60g/pgSruCzY/JwDKV8mG8Ujw53J3 YXakzTmpjepLL7hb5re/WJreJhVclLQPu70wEIvlJYXBP/ttXGwtKlADifZuU1lTudK2Hp9RY USi+ZwS6ROFLNH1Gcq0jA4xtqhcIjADmdDGbEHTr3bRogP5Qsczg8KTW6M5Ey/qNtLGbPrNQP wS1muLx+Kjino3ejLWCMFlKk0OlZIIEvAhRMRlKAbFq0pgJTDEKJdbnyWpqxzAOkTfcROqn/9 d994v4cc4jA/F0SjW70ZJNdjxXhk/36xYcuK84+Jtr/oZVrVt5VqIihDx3zHi0LNUteaQJ8kx 4amH6aS/Xo+yhIF6onqrxHL7ETy3vgzK7OFNwl4E9VENiWZobZcRJWpXS7q3Yb1vN1FlPPo73 dx+VJEK/HbiI4Yamr0qX1+94l3F8tEFnCOV4dSI/dRRflRzqHsqkDowArC5+WhzR8pTQO8har n21P2B42BJ3KsbQbolHIAhOPLc3gnXywP7esCZfGyHgqg//oEbYj9NZuemspwVNL4UkNMC22b K9cIvjSXiwx5WfybkGK3Um+CiC2ItlDLfvFFZGg7xCQKf9FaGd3zfqlcpxA14+Gma6b0s323C cR91EPjKxGNTMolh1coEKYx7KA+UDJp7mY2zUs7zG7ZA7r4DDJlfDBH7S807eOXI5D4CcoIeX nJzn4x4RAGeZUItoX9P/UjVkSpyoYq7VDuSlK+pfCTc7SGoT5u7Gr1CCuDedGX9ib/OwrD9no AeHqoVv7lH79bmqA/CYrX6N324Ucw== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 17/17] efi_loader: supply EFI network test 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" This patch provices an EFI application to check the correct function of the Simple Network Protocol implementation. It sends a DHCP request and analyzes the DHCP offer. Different error conditions including a 10s timeout are checked. A successful execution will look like this: => bootefi nettest Scanning disk ide.blk#0... Found 1 disks WARNING: Invalid device tree, expect boot to fail Network test DHCP Discover DHCP reply received from 192.168.76.2 (52:55:c0:a8:4c:02) as broadcast message. OK. The test was completed successfully. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2 move efi_st_memcmp to efi_selftest_util.c The function can be reused for other tests. Use constants for return values. --- include/efi_selftest.h | 11 + lib/efi_selftest/Makefile | 8 +- lib/efi_selftest/efi_selftest_snp.c | 424 +++++++++++++++++++++++++++++++++++ lib/efi_selftest/efi_selftest_util.c | 25 +++ 4 files changed, 467 insertions(+), 1 deletion(-) create mode 100644 lib/efi_selftest/efi_selftest_snp.c create mode 100644 lib/efi_selftest/efi_selftest_util.c diff --git a/include/efi_selftest.h b/include/efi_selftest.h index 2f0992f06e..7ec42a0406 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -60,6 +60,17 @@ void efi_st_exit_boot_services(void); void efi_st_printf(const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))); +/* + * Compare memory. + * We cannot use lib/string.c due to different CFLAGS values. + * + * @buf1: first buffer + * @buf2: second buffer + * @length: number of bytes to compare + * @return: 0 if both buffers contain the same bytes + */ +int efi_st_memcmp(const void *buf1, const void *buf2, size_t length); + /* * Reads an Unicode character from the input device. * diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index 30f1960933..e446046e02 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -15,12 +15,18 @@ CFLAGS_efi_selftest_events.o := $(CFLAGS_EFI) CFLAGS_REMOVE_efi_selftest_events.o := $(CFLAGS_NON_EFI) 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_REMOVE_efi_selftest_tpl.o := $(CFLAGS_NON_EFI) +CFLAGS_efi_selftest_util.o := $(CFLAGS_EFI) +CFLAGS_REMOVE_efi_selftest_util.o := $(CFLAGS_NON_EFI) obj-$(CONFIG_CMD_BOOTEFI_SELFTEST) += \ efi_selftest.o \ efi_selftest_console.o \ efi_selftest_events.o \ efi_selftest_exitbootservices.o \ -efi_selftest_tpl.o +efi_selftest_snp.o \ +efi_selftest_tpl.o \ +efi_selftest_util.o diff --git a/lib/efi_selftest/efi_selftest_snp.c b/lib/efi_selftest/efi_selftest_snp.c new file mode 100644 index 0000000000..638be0147d --- /dev/null +++ b/lib/efi_selftest/efi_selftest_snp.c @@ -0,0 +1,424 @@ +/* + * efi_selftest_snp + * + * Copyright (c) 2017 Heinrich Schuchardt + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This unit test covers the Simple Network Protocol as well as + * the CopyMem and SetMem boottime services. + * + * A DHCP discover message is sent. The test is successful if a + * DHCP reply is received. + * + * TODO: Once ConnectController and DisconnectController are implemented + * we should connect our code as controller. + */ + +#include + +/* + * MAC address for broadcasts + */ +static const u8 BROADCAST_MAC[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + +struct dhcp_hdr { + u8 op; +#define BOOTREQUEST 1 +#define BOOTREPLY 2 + u8 htype; +# define HWT_ETHER 1 + u8 hlen; +# define HWL_ETHER 6 + u8 hops; + u32 xid; + u16 secs; + u16 flags; +#define DHCP_FLAGS_UNICAST 0x0000 +#define DHCP_FLAGS_BROADCAST 0x0080 + u32 ciaddr; + u32 yiaddr; + u32 siaddr; + u32 giaddr; + u8 chaddr[16]; + u8 sname[64]; + u8 file[128]; +}; + +/* + * Message type option. + */ +#define DHCP_MESSAGE_TYPE 0x35 +#define DHCPDISCOVER 1 +#define DHCPOFFER 2 +#define DHCPREQUEST 3 +#define DHCPDECLINE 4 +#define DHCPACK 5 +#define DHCPNAK 6 +#define DHCPRELEASE 7 + +struct dhcp { + struct ethernet_hdr eth_hdr; + struct ip_udp_hdr ip_udp; + struct dhcp_hdr dhcp_hdr; + u8 opt[128]; +} __packed; + +static struct efi_boot_services *boottime; +static struct efi_simple_network *net; +static struct efi_event *timer; +static const efi_guid_t efi_net_guid = EFI_SIMPLE_NETWORK_GUID; +/* IP packet ID */ +static unsigned int net_ip_id; + +/* + * Compute the checksum of the IP header. We cover even values of length only. + * We cannot use net/checksum.c due to different CFLAGS values. + * + * @buf: IP header + * @len: length of header in bytes + * @return: checksum + */ +static unsigned int efi_ip_checksum(const void *buf, size_t len) +{ + size_t i; + u32 sum = 0; + const u16 *pos = buf; + + for (i = 0; i < len; i += 2) + sum += *pos++; + + sum = (sum >> 16) + (sum & 0xffff); + sum += sum >> 16; + sum = ~sum & 0xffff; + + return sum; +} + +/* + * Transmit a DHCPDISCOVER message. + */ +static efi_status_t send_dhcp_discover(void) +{ + efi_status_t ret; + struct dhcp p = {}; + + /* + * Fill ethernet header + */ + boottime->copy_mem(p.eth_hdr.et_dest, (void *)BROADCAST_MAC, ARP_HLEN); + boottime->copy_mem(p.eth_hdr.et_src, &net->mode->current_address, + ARP_HLEN); + p.eth_hdr.et_protlen = htons(PROT_IP); + /* + * Fill IP header + */ + p.ip_udp.ip_hl_v = 0x45; + p.ip_udp.ip_len = htons(sizeof(struct dhcp) - + sizeof(struct ethernet_hdr)); + p.ip_udp.ip_id = htons(++net_ip_id); + p.ip_udp.ip_off = htons(IP_FLAGS_DFRAG); + p.ip_udp.ip_ttl = 0xff; /* time to live */ + p.ip_udp.ip_p = IPPROTO_UDP; + boottime->set_mem(&p.ip_udp.ip_dst, 4, 0xff); + p.ip_udp.ip_sum = efi_ip_checksum(&p.ip_udp, IP_HDR_SIZE); + + /* + * Fill UDP header + */ + p.ip_udp.udp_src = htons(68); + p.ip_udp.udp_dst = htons(67); + p.ip_udp.udp_len = htons(sizeof(struct dhcp) - + sizeof(struct ethernet_hdr) - + sizeof(struct ip_hdr)); + /* + * Fill DHCP header + */ + p.dhcp_hdr.op = BOOTREQUEST; + p.dhcp_hdr.htype = HWT_ETHER; + p.dhcp_hdr.hlen = HWL_ETHER; + p.dhcp_hdr.flags = htons(DHCP_FLAGS_UNICAST); + boottime->copy_mem(&p.dhcp_hdr.chaddr, + &net->mode->current_address, ARP_HLEN); + /* + * Fill options + */ + p.opt[0] = 0x63; /* DHCP magic cookie */ + p.opt[1] = 0x82; + p.opt[2] = 0x53; + p.opt[3] = 0x63; + p.opt[4] = DHCP_MESSAGE_TYPE; + p.opt[5] = 0x01; /* length */ + p.opt[6] = DHCPDISCOVER; + p.opt[7] = 0x39; /* maximum message size */ + p.opt[8] = 0x02; /* length */ + p.opt[9] = 0x02; /* 576 bytes */ + p.opt[10] = 0x40; + p.opt[11] = 0xff; /* end of options */ + + /* + * Transmit DHCPDISCOVER message. + */ + ret = net->transmit(net, 0, sizeof(struct dhcp), &p, NULL, NULL, 0); + if (ret != EFI_SUCCESS) + efi_st_error("Sending a DHCP request failed\n"); + else + efi_st_printf("DHCP Discover\n"); + return ret; +} + +/* + * Setup unit test. + * + * Create a 1 s periodic timer. + * Start the network driver. + * + * @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; + + /* + * Create a timer event. + */ + ret = boottime->create_event(EVT_TIMER, TPL_CALLBACK, NULL, NULL, + &timer); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to create event\n"); + return EFI_ST_FAILURE; + } + /* + * Set timer period to 1s. + */ + ret = boottime->set_timer(timer, EFI_TIMER_PERIODIC, 10000000); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to locate simple network protocol\n"); + return EFI_ST_FAILURE; + } + /* + * Find an interface implementing the SNP protocol. + */ + ret = boottime->locate_protocol(&efi_net_guid, NULL, (void **)&net); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to locate simple network protocol\n"); + return EFI_ST_FAILURE; + } + /* + * Check hardware address size. + */ + if (!net->mode) { + efi_st_error("Mode not provided\n"); + return EFI_ST_FAILURE; + } + if (net->mode->hwaddr_size != ARP_HLEN) { + efi_st_error("HwAddressSize = %u, expected %u\n", + net->mode->hwaddr_size, ARP_HLEN); + return EFI_ST_FAILURE; + } + /* + * Check that WaitForPacket event exists. + */ + if (!net->wait_for_packet) { + efi_st_error("WaitForPacket event missing\n"); + return EFI_ST_FAILURE; + } + /* + * Initialize network adapter. + */ + ret = net->initialize(net, 0, 0); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to initialize network adapter\n"); + return EFI_ST_FAILURE; + } + /* + * Start network adapter. + */ + ret = net->start(net); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to start network adapter\n"); + return EFI_ST_FAILURE; + } + return EFI_ST_SUCCESS; +} + +/* + * Execute unit test. + * + * A DHCP discover message is sent. The test is successful if a + * DHCP reply is received within 10 seconds. + * + * @return: EFI_ST_SUCCESS for success + */ +static int execute(void) +{ + efi_status_t ret; + struct efi_event *events[2]; + size_t index; + union { + struct dhcp p; + u8 b[PKTSIZE]; + } buffer; + struct efi_mac_address srcaddr; + struct efi_mac_address destaddr; + size_t buffer_size; + u8 *addr; + /* + * The timeout is to occur after 10 s. + */ + unsigned int timeout = 10; + + /* + * Send DHCP discover message + */ + ret = send_dhcp_discover(); + if (ret != EFI_SUCCESS) + return EFI_ST_FAILURE; + + /* + * If we would call WaitForEvent only with the WaitForPacket event, + * our code would block until a packet is received which might never + * occur. By calling WaitFor event with both a timer event and the + * WaitForPacket event we can escape this blocking situation. + * + * If the timer event occurs before we have received a DHCP reply + * a further DHCP discover message is sent. + */ + events[0] = timer; + events[1] = net->wait_for_packet; + for (;;) { + /* + * Wait for packet to be received or timer event. + */ + boottime->wait_for_event(2, events, &index); + if (index == 0) { + /* + * The timer event occurred. Check for timeout. + */ + --timeout; + if (!timeout) { + efi_st_error("Timeout occurred\n"); + return EFI_ST_FAILURE; + } + /* + * Send further DHCP discover message + */ + ret = send_dhcp_discover(); + if (ret != EFI_SUCCESS) + return EFI_ST_FAILURE; + continue; + } + /* + * Receive packet + */ + buffer_size = sizeof(buffer); + net->receive(net, NULL, &buffer_size, &buffer, + &srcaddr, &destaddr, NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to receive packet"); + return EFI_ST_FAILURE; + } + /* + * Check the packet is meant for this system. + * Unfortunately QEMU ignores the broadcast flag. + * So we have to check for broadcasts too. + */ + if (efi_st_memcmp(&destaddr, &net->mode->current_address, + ARP_HLEN) && + efi_st_memcmp(&destaddr, BROADCAST_MAC, ARP_HLEN)) + continue; + /* + * Check this is a DHCP reply + */ + if (buffer.p.eth_hdr.et_protlen != ntohs(PROT_IP) || + buffer.p.ip_udp.ip_hl_v != 0x45 || + buffer.p.ip_udp.ip_p != IPPROTO_UDP || + buffer.p.ip_udp.udp_src != ntohs(67) || + buffer.p.ip_udp.udp_dst != ntohs(68) || + buffer.p.dhcp_hdr.op != BOOTREPLY) + continue; + /* + * We successfully received a DHCP reply. + */ + break; + } + + /* + * Write a log message. + */ + addr = (u8 *)&buffer.p.ip_udp.ip_src; + efi_st_printf("DHCP reply received from %u.%u.%u.%u (%pm) ", + addr[0], addr[1], addr[2], addr[3], &srcaddr); + if (!efi_st_memcmp(&destaddr, BROADCAST_MAC, ARP_HLEN)) + efi_st_printf("as broadcast message.\n"); + else + efi_st_printf("as unicast message.\n"); + + return EFI_ST_SUCCESS; +} + +/* + * Tear down unit test. + * + * Close the timer event created in setup. + * Shut down the network adapter. + * + * @return: EFI_ST_SUCCESS for success + */ +static int teardown(void) +{ + efi_status_t ret; + int exit_status = EFI_ST_SUCCESS; + + if (timer) { + /* + * Stop timer. + */ + ret = boottime->set_timer(timer, EFI_TIMER_STOP, 0); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to stop timer"); + exit_status = EFI_ST_FAILURE; + } + /* + * Close timer event. + */ + ret = boottime->close_event(timer); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to close event"); + exit_status = EFI_ST_FAILURE; + } + } + if (net) { + /* + * Stop network adapter. + */ + ret = net->stop(net); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to stop network adapter\n"); + exit_status = EFI_ST_FAILURE; + } + /* + * Shut down network adapter. + */ + ret = net->shutdown(net); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to shut down network adapter\n"); + exit_status = EFI_ST_FAILURE; + } + } + + return exit_status; +} + +EFI_UNIT_TEST(snp) = { + .name = "simple network protocol", + .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, + .setup = setup, + .execute = execute, + .teardown = teardown, +}; diff --git a/lib/efi_selftest/efi_selftest_util.c b/lib/efi_selftest/efi_selftest_util.c new file mode 100644 index 0000000000..c9c295e2fb --- /dev/null +++ b/lib/efi_selftest/efi_selftest_util.c @@ -0,0 +1,25 @@ +/* + * efi_selftest_util + * + * Copyright (c) 2017 Heinrich Schuchardt + * + * SPDX-License-Identifier: GPL-2.0+ + * + * Utility functions + */ + +#include + +int efi_st_memcmp(const void *buf1, const void *buf2, size_t length) +{ + const u8 *pos1 = buf1; + const u8 *pos2 = buf2; + + for (; length; --length) { + if (*pos1 != *pos2) + return pos1 - pos2; + ++pos1; + ++pos2; + } + return EFI_ST_SUCCESS; +}