From patchwork Sun Sep 24 19:57: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: 817978 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 3y0dTV0G9Gz9t3R for ; Mon, 25 Sep 2017 06:04:13 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 9EF70C2211A; Sun, 24 Sep 2017 20:00:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0C224C22145; Sun, 24 Sep 2017 19:58:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 283A8C220B8; Sun, 24 Sep 2017 19:58:16 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id B3C04C220D2 for ; Sun, 24 Sep 2017 19:58:13 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MQdAP-1dmfzA1M8j-00U2EF; Sun, 24 Sep 2017 21:57:29 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:00 +0200 Message-Id: <20170924195716.3433-2-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:mUYIUmJlNC1HWdRyUHHIwEBAJkyAqGGc2yQdfA6VwxGU9M3YhAP iuKj2eKjfcBSOPzGYdCJtxOaC2BEy5f55o7pzARMB+exsDaXpNkkhly6xWjzZ0PVaTPoZaR d/yRQJurTcI8YMXROS2LWmq99wIAup0h09HM7wFdpTkCCTH8v3HfRu5459G7F6JHNgIvao8 IAhk7x03aEANCq/3fNzXA== X-UI-Out-Filterresults: notjunk:1; V01:K0:8hR9wjZ36nU=:HKl5TgfX+6maql9gQ4hU2q VCUJLZ+a1IAydxZcSu0gw946ZiKPnLOPT+KNuKpPoKocQXMbGHwTnQz3zCK8Qiq+VsByBPKhA rTJEs2uT8EeOS7GFKyoRMoFH7io8Ye6XHpxSKBeXR+WdzyTzJJjicEftMaC/KNKMoSt/PpHW7 MWrXu5OWSM8jQu3t5s/nZMDk9HRktkgq80Rsq1NuKxrDtam6SS2FDHNlwLKdThTizclSqKmjM +AL4fcHIxY5yNqlWOHZwC1FfZHEER0WO9DTqOLJEhlIUoCvAfvLe0zkJp27Tr0ycjsGBXbRSH 9GsvkCgpBjjFvgP8cqLQW9eeBHlujp28XDzvw5EuVsQxTEkuYww+fUIsvyG9ISEiqcMRw9Yid /7SR0DVGYRuZOMITEUICOZE+vEOY3OBSV/hMJUP5ozAvKbkcapMVEBONz7n/outHqy7hOEyx1 wwoXJpGbEE5pGwyc7cwWbSBQTyjOvG7SHIjNFgH4NSCHctdSFflJO1K6Y/d3JzXq1AMkKly8I 0s5x0EUrJKqIteQA1WyyYDtUzkBNaDufibZ30MXVQ0ztpegTKfJ3n1hmy2+ozCGlZho2eCNJW U0B0HZhDL8N8Az6P1/QmmMpau9VaNiCDUbweGDDLRAqQEdDDPSSak5BhsGww8QhgUvHCvWVeT URLtBMFK8t5cp2W3H6uVjA8Amsqd/P70sXyXApHmIvbtDSh2PpHv9SIGTMX8WuaE2/udSljWI APCo0TaOyJdA14Jl2553jvoTb0fT2LNpVDbwXgrz15FZSrq8khnS4T8vlEKy6MdkmZ6/uZFd6 O3cy3WZ8LlcAIQVA9C4fK4gdG15cg== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 cbc4007f7b..2c2620a46d 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1882,6 +1882,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); } /* @@ -1899,6 +1900,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 Sun Sep 24 19:57: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: 817971 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 3y0dPP4hgQz9t1t for ; Mon, 25 Sep 2017 06:00:41 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 5F9DCC22147; Sun, 24 Sep 2017 19:59:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 66FAAC21C2B; Sun, 24 Sep 2017 19:58:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A09E1C2212D; Sun, 24 Sep 2017 19:58:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 3B5BAC220E5 for ; Sun, 24 Sep 2017 19:58:16 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M7DVi-1dBgDv2cDe-00wz4K; Sun, 24 Sep 2017 21:57:29 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:01 +0200 Message-Id: <20170924195716.3433-3-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:54UCKfhK5kWsdyNiVmraWO2OOpyvIUkC8o1vopU27U6I/tU2TT5 b/de3QnU3clptqVnPHAnL823mgHGRdVdMoktgMGUqFQLqh/0mB4ikHt7210+hchqJkFgmqU nO0h0BtYFJspj9spq/wWn/o+ZhDLariTgiajTjhaZbD59/2Cuxaq74is3xB4cJH4/kRB8+v FxDHIMG/h7GGXf7VGWoVw== X-UI-Out-Filterresults: notjunk:1; V01:K0:NQk1DX+/y9k=:vCjZQQSpbaG1prKuk4a5O0 aYA+vqbcHcZCNksr6CQSAJbaJ06mu6wUJRQzYaYz4WtVMRye6nDIlKHwDmrs7aH54FofNTuJ7 xcj2ImIZEZ3sFrM0DWMsINKfPP4F5C1XoRuxe4qhLM3bEkHV03pqKVTYeNsROULDJmSQ5qgyT s0JegScIbGLcC9/BIEr5EvkiWNw9GsvlNbn3NA2IVozVMkZkZX5KU+jIXjAEeHqdJ1lhJvAc5 0nEhZTlZdPFA8pVvaMJH/RsBZGazAYy1x92our5o1NcFRJfe8fNaH7DI3k2lq6GNAF14Gjna0 LuDaiYoGc8ayirHvr/VMp0SbZubT6E9W0qhydfdMvT006x3ex/g2yxhjQ8ZrZe8SdqmDyV8+g eYpub5ZgjFZxhhHCEG8CEXdFNIhTQ4yGw8keHQzdA9pYKBjH3f7oAuUSjixRXANgxORY1j+lg JzJTrLvnjknYDRn71jtmMCxtItGUqFeqYgAaZ5aH2jfKJVn2VD3ZJEMWrTbUxzR7Z+YPljERc fBi/58h9yjgpxCco+C4OTSpDZwiEVHUoUoxuRbgdOobmXxF0qu+U6aXV7NZeKqz5C3B5/dq/U xy62ckRS4tyUL+oW/yZbLDe9ay1P60De2/sY+b02XNyG28Hw0RLRvl65EKtUmmUs84UMI/hGd 2dt6QaEKxtplr7fh9VMzHZDYgdTes9WeeaerhenN6MQtRxYYqUFDYY6hG/dTzMdsDGkAIh0OV mVpm+b2Vnp/IvKp7roDPlYlva+CbdrBWMotu+k3DhTqV11/OZSaC/6IyG+BRuR65ahJp0tKvQ wSoxnoyxv7H93bSIawgAlHoq3iilw== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 2c2620a46d..22e6e6c569 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1877,10 +1877,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); } @@ -1896,9 +1896,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 Sun Sep 24 19:57: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: 817975 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 3y0dRF1S8tz9t30 for ; Mon, 25 Sep 2017 06:02:17 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id DD025C22127; Sun, 24 Sep 2017 19:59: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.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 27830C22124; Sun, 24 Sep 2017 19:58:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DF0BCC220E5; Sun, 24 Sep 2017 19:58:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 586D6C2209B for ; Sun, 24 Sep 2017 19:58:16 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MGoU1-1e9jgW3z9d-00DaFD; Sun, 24 Sep 2017 21:57:30 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:02 +0200 Message-Id: <20170924195716.3433-4-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:39eFKdQFjuIWVfL3QY0qLxCMFbeNcRzt8ATW8pe+0qE2Rmn/O8w YekC0yG5Mdl1YMNWdlSKNjtKJ5DdUyMuxM4IN5afxM4mMPSniiw1XeI5iqKq7TsRUnkgxiW 5WBkd5nK7mqClkRYqlEXXFBdK+e6NRH546K7OwVsJex53qboj9dSCiwihub6ALwHlatZFAT 9xrIb5Wg3o0PLkFc1O3GA== X-UI-Out-Filterresults: notjunk:1; V01:K0:uAQnt2PdK68=:ay4sxS/djvtxdC6w5+vkZ3 AdrLaNYVGzjZZo5x+e3Bilzj9jPUSmWDig5N8+RVNA7T4M3YjX7OHKN9lyDMqsFHw+OskMT3A o2uejaF+PWX1/dam2JKz9P6BSHyeOpDqURLtFkV+uezeHqVFj7Dmsra2s2PCu+hgAokbaLGir JTjG1KpkkKQZsL/VO8i6WqoR5TupzFqzd7kGf6J585PS6CfBEdIb0lNGvkFd9pYjwhSM/mPTL GJKDcDjKj83KY9vKBFak5pMiVT0GlgYD38ABucP8SnUAJXWDdDjbCU6et+TLvoeFhO27K+VX5 ZlngA2mjinnrSHoLLmkjdf+Dkkl24LPsbXk6/+1RgcWDkjtQnQ9vGjAD0mu69OhA5YgW1yI8R FyLnj3dQsc/xICyKW6UnhurED1Y+oD8RNCtHxUIapJPNCVhQ6MSa3zeGphJGI+eh/ow2rIq/M NhgZehqzr6LbSbzeqi6bfcjl4SPyKhTgnv4WW3sgDqxDMjOND2bABk5obmcUzEBacKoXr8QOW 7n+YEV4ylcrXDBIZ5KSdIFvTrt37deu5FE0k3TKI1YXu+VPFiJO77JTfojG/18XXnKrFnaTk5 3X0AojCwd3O0VrZEc2TkE/dZrggJA3k8ZZUvFZTz2qwox1DiBdYQzj5sZvbB5/CWPMvimddib wjGbvapE3AeKHKFtr2VAf0I7mpLI3Nh+zTAtuREvT6BE2QDDxvKL/nL+nHL8IjzJ8UqIXVcUU tQrnAaLAWKfkxD/RadT/6WtPz3Fzz15TdiA0XBp4vrpJgDvKxRBoWOedMEN3afxZKQH0jn3l8 jd0P0xv4T/3qfdmW3hB4HolNY0BrA== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 22e6e6c569..b053b47262 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -719,7 +719,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; @@ -790,7 +790,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, @@ -816,7 +816,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, @@ -837,7 +837,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; @@ -890,7 +890,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); @@ -911,9 +911,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); @@ -931,7 +932,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; @@ -968,7 +969,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; @@ -1020,7 +1021,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, @@ -1042,7 +1043,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) { @@ -1581,7 +1583,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) { @@ -1604,7 +1606,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) { @@ -1693,7 +1695,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; @@ -1735,7 +1737,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) { @@ -1788,7 +1790,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; @@ -1919,7 +1921,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) { @@ -2003,7 +2005,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 Sun Sep 24 19:57: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: 817968 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 3y0dLp5v8Cz9t1t for ; Mon, 25 Sep 2017 05:58:25 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4280CC22127; Sun, 24 Sep 2017 19:58:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5E9DBC21D9E; Sun, 24 Sep 2017 19:58:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9ABA4C21D9E; Sun, 24 Sep 2017 19:58:05 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 42B7FC21C2B for ; Sun, 24 Sep 2017 19:58:05 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MWhRH-1dqXs916E7-00XrzB; Sun, 24 Sep 2017 21:57:30 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:03 +0200 Message-Id: <20170924195716.3433-5-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:VNaLScouZmWf4uGeC5Z4Ikux9+2Cosf+AUdcWfKkVEN3UzoKeXl S+pSrHT22RCaAcIVfk1Hxo5D6m4APYigQRVxY7xW2zQDKs3W17fHwFNnpHygVXTyjYmTW1I lqiZRiCDbxwbGopBen2HY0yz/ITAnFk52C7EdKSefe4f+1ypOnJi8KLxEHqdanwWqy8nyyw 9keF9ZY2cmM3okGCKy5LQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:FgngBK14cbA=:H0uAiLeyPWZuOYhlrndIQY arSlMQv1m6XDjM5dgsVgTlJlZ4qPRoAaBxcmzeOKVmCR7q+K3a+BS4/XZFi2gpbjEuKni/F9H +CYC/7HtlGuUFSvGFxRnXwQpe1ixvpPMdMyc7a+nylkvXAq9k/GnAQz+gnBrrAhNiivAkk/4v 29dphelAe/kd38Ar9ZTxpGzD9NAs3CLdgMrdU+tfMRkObCbd+oicsABclZW2NDq+SIh3Ayy05 18e9Ml59pOR7M5NfBkselGNubjIpPeRYE0W15WBb0B6GkgwScAuUY3Lg0Wr9Xg8eAyDYksgqb hADea8RGz+heK00ZIvd7D45T5oHq2MMDlrZsEXAMrNGGjSbk4XP0wuNWy38lkBemzxqRLAzEW jgOm2gKx67EHL/fOcMCIjcwkvt0tggfTtPDytviE+DhGeshyrGN+UfKMky34q3CBcjppIsXFu G9sVRX4rLpAyW6tJHfWlNjte2R7ps1F4BHNzZ107cqZ6LbnrJ7W6GxKTBWKG1PUwy2RrRmuOI 7da+NB+aYZfUODXlUe1oTeWXZUiDHE2hMKiG5+HorlaPkG09KxbgAshwjglLU3jnSzOZTnwON DY5s/+mWTR++GnsPCgRPnO+ZQG7E++ZwZbSLZrlJnN4rM3SCcrzy+Vi6CbJu6XNe33uSIL01L JajuVvKUnoS6afCac5F3VO104qYCRwmM93oRB26bLRoSMUGOcQCz/lHEjbZ3NysNrVsbChJBl 8vODFgwJU9AaKeb1pukdLmKDs17Yb4GEC2CdDy8eivt55UZWr+HauynogOtyzBY/UtWY5tDsr qQrx4GMI4+scHgCHMvnI90m/FPoqg== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 b053b47262..0970d0ce7e 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -568,7 +568,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 c4f66952b9..5cd182723d 100644 --- a/lib/efi_selftest/efi_selftest_events.c +++ b/lib/efi_selftest/efi_selftest_events.c @@ -101,7 +101,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 90ace0f51e..6880463eda 100644 --- a/lib/efi_selftest/efi_selftest_tpl.c +++ b/lib/efi_selftest/efi_selftest_tpl.c @@ -104,7 +104,7 @@ static int teardown(void) */ static int execute(void) { - unsigned long index; + size_t index; efi_status_t ret; UINTN old_tpl; From patchwork Sun Sep 24 19:57: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: 817970 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 3y0dNP4NFZz9t1t for ; Mon, 25 Sep 2017 05:59:49 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 491B1C21C2B; Sun, 24 Sep 2017 19:58:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 42E19C22120; Sun, 24 Sep 2017 19:58:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CE58FC220D2; Sun, 24 Sep 2017 19:58:13 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 5B614C2209B for ; Sun, 24 Sep 2017 19:58:10 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LcEPJ-1dXM3r2ak1-00jdCd; Sun, 24 Sep 2017 21:57:30 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:04 +0200 Message-Id: <20170924195716.3433-6-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:xgqR+e2jbvk4/vZRpa7Tnc3LBXnGT5dmv0B8ge9vt8s5ye6qkp1 FRghgjspL8C4yuB6S3uMIkp3vjaHamv67NSyY+ooD+5vCHi2x7NtwXcLVSl30CyVqYsGqsF im8bbNsbkUq2WTdtfV54XtbG357v+bNCSRY8I0JLE5CA672VxglewIdiPS1EkLCTijO/iij TyfgvIHlWtjrtmXtG3Ppg== X-UI-Out-Filterresults: notjunk:1; V01:K0:XZ/MHp6hMSU=:vDb85LliWi8qs6FUnySfIo ywQg2XqgGPVZEW4lR7JfS3Sp852PJR/mmMQRLNF2FzYE8j40hrOtiG0htawacjnjHKP6XhDvu fR7ejGNfkCUZx7Fzoy/niNDieOjWGGZv6La1+/to/V87a2a1UsQ90MdJ14ZwMIdwYqebHpjsk H9MdsNJsN7DLm3UVzkRXj7dNMkyTat9Q3cXiIJD838PBCm8Es7qvbIgpBDX5RFvVitNmmWBzj tmRiviO4KCsCKUzHeT1gbxN20Ns9ryu2MzdFtYzE2JKfcQeFHryegF+7hcnvlvYNjhc5Ckzr4 pXTxTIdtNQ+UOW/9LZDXGyD7Ze8HWXIAtsjFUmet0CQvcdTadCabY+/Y33L3t6INRm1H1Rbmm cl5/47+ViVZkatClbWEjRBAtgcC+fP653qDaetkCe9OaNQtAJw4BNwhlNS6ykpMhib9HKhRh7 lSbBJYvbrCX/eanW8KDm9SnPcgtuypRqF6xClZHl7JCJlSqcAEYMCXvKkc8Hw3DCfWFqWgkUP 5JkhOaiqtKE97+Ih4St1covpSrp2nYeMGOxRvW9HiuKwsRG/Apb7i9IaFuG7CQU5CFBTcpmnb XBrt8z+i4QJp1WROf5E9yDzM8ygM53t3ryXcOTSRBSdvRYBNDxKPpVrbkSFSm2K7ylktTuRqq 6+guEM+5z2PALELupiDnEMLpp7Lz1HHDYUK2l+buxZPmQHWGlQDQmfKvEdQ6o9by1/UeJP+hv tE2GiOZ3heNtrFxETi0QIiCfvhLWhrr2zDAz4rKAtcjTYk/HkGicOHrKV/+XzUXqfFxUt+zYV qI/7hbotUHzJlE3MkRqBnW5u7HmUQ== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 Sun Sep 24 19:57: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: 817981 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 3y0dY85lgBz9t3R for ; Mon, 25 Sep 2017 06:07:24 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 8B53AC2214B; Sun, 24 Sep 2017 20:02:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A0C6CC220FC; Sun, 24 Sep 2017 19:58:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AD872C2214E; Sun, 24 Sep 2017 19:58:13 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 6AB4BC220F1 for ; Sun, 24 Sep 2017 19:58:10 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LrqNe-1dDt8H01rK-013dxg; Sun, 24 Sep 2017 21:57:31 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:05 +0200 Message-Id: <20170924195716.3433-7-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:D77RxmoLNnNxkl4cYCo0eS00uTAI4jZDXdSqDey/o0KDLhGeWFJ NAGMed8F220xpZn23tJA989GOqAtVwKhKimuRw+OOfJjg4hhZfbypH20DRj0uMgI13IdSlK o/GJLTjIMQhplG6kA12Dui1EBqlLjECkrnZRRV7mfDuExoMVn7hn8ZEBIo31sIZ+fqndIuG Ps+r2NpXh40eCgou6SLiQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:IzYkU3kQcqY=:LTIIK8iM7XOHiKpaN3+HCY 6aiLhIzUpCrJyVhLApGZtttfxx1ptvG3AVJiQ2aO7xX0U28vkR7aoUTA6C806rF9lUipNo9Og T7S7k8xLI/XWDOLdK9xLinv8ROIO2VMsufBbb1St0fmKyQhju6iA5aPKn1u+4+5rdWdcy1VyP FnZDKZW4zyoIlzZYKIOOLqlNO1+hVVBid1VJ8KH8GVhzs+bnzru2sypH6BsE7WfI8lmO8+/vc lHhsv/oaD3Hm8Y0XetzIx93ZRJSA/53tCF36DOaebvMqpp82B2722N5hcjXrOZMw4lJfJRI0L FZOqQoj1z2fLeMTmIk5HUw4+qx4sjIZYlEnUH/t+k+kfPp960L7u/mZf5vn7420d/8+zT6tZO 2x++Cm8lklDDGMpSzP5dHZg9BLx1kZs013O65xerdX5TSRm6SCCw6mibLaDfxNG5udr1D+o7I Cp+hgI9XNeTJy98T7rXAMtQXgEu42ziMV+M46UlyBdEL+XXRflb3lDGPEF7JBARcd3BINay31 dPtlroQZZH6xGmZcm6kddcS/7LOFE6SoYEMSusCk0cREdfUNqnu88Ii1sIVix8AEHKKj7ASuI GrSBfdkz2K2xcwc1q1cdpokfK0e80bDvBqJuSJ+8GZglBajyVvD2xNycCQ6Uqsq18bZOQlNRR f8MJpS1CFkPTpV+QqhKnNnED9KlrknjMD/UsBNmwlMXDwmCbNuVIDS6xhch3wt723bsjlTfTE Etspv/jCqG6ndG21ChRStz96vmLr2UMwQPSATs/3F+ZiyAtFVfm513trbyvkAFFvnJpauE0uS l2udpv2NZ2ahN2XXhyBkSjFPRvcfg== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 Sun Sep 24 19:57: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: 817984 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 3y0db503ZDz9t3R for ; Mon, 25 Sep 2017 06:09:04 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id DEF99C22138; Sun, 24 Sep 2017 20:01:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D007EC220BB; Sun, 24 Sep 2017 19:58:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4DB52C2212D; Sun, 24 Sep 2017 19:58:22 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 406F9C21D9E for ; Sun, 24 Sep 2017 19:58:19 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Lkzph-1dOWNC1Ok9-00anVz; Sun, 24 Sep 2017 21:57:31 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:06 +0200 Message-Id: <20170924195716.3433-8-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:zHvfLYLSNf/xomE9xt87CZX8plhfYGN4uWfUNJuc/CJsxWx7xZ1 6UIBbS4WkOu4OQVCIQF2lmg0fbOOGGkiL0JEhxQPL9Hf1bvF7BOIWWs9nZnEKwcrhNMpWKT 8TKsSByfMiVj665qqhBK8t0hGpsP3vpfFRIavwtL3ch5EB87vWami50HBcJwRMJ+iz2mzkW K+NxYhRqj10WX/+/galhQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:gTZRAmyMmgI=:3H/CKHgQKuFZcH/gsHc2Bb GV45a7LLcD/1wAw2rXegoSdRSTMu4Y6E6XbDQNKrLmz0BahAVCElXgFX02VZFAQzQuhvw25Vk PuLII4tzrZDkG9Fl8vNVdHe1EOlqQF3A1OEKD2hoP9juqzTMv8q2mRxoxabzNLaLOeOz8a0GV GY+AfLjAofmsqQbdfMTfimwObep604UCP8dJijhV1eWnaXlHf+EqOkAShhWYOD/ArY6MxpGCg fqFYJa3etRBJnWTyDno6ZLOjxV4SU3thkyDx2uNv7uF6lpAvXJi33ORFbadJNSCK1V/OWkzGE cVjEeCdOoJlnx8t1atHgPiWzywxjq4Zw3mEjuv7C6lHgbCY8ocpF6X0O0w/T7j413CIm+IqMs 837g6QOZ8Tg2PDb/jGyNrjGmME6w4j2ieefR0rsOsL2TCgPKcBvPNfmymZiYdcnuPoohuFyor 0a0/nSasMNOlemmSyvWlbJZIsrsZd9yntY9iFxwJ+9CW2NdsIl9a1HMSxbAgw5qgeu7PMkDR1 T6SpNs1KXTNAc2Gbr9EzM0PjO/iZbjpVDAgjJGAQEZc1og1QNJN/aVJJiz28jT8RgCg/4O38y 6VJDawpglonZRgNVu72Q5yKuZoDxrZw7TN9A9Ue+nHIZTQhIKsD59Ftw9BHs4zZT0a3jWqdVn HHiGD6nZBB8LuOJmgoIbpuvdq7mnmF7Ln8TThpCABwS8vgjpMpqpCsQI/Glipm3OhhZqC1RX3 GafprLnSDDOA/UoNWCYsdpBvPkyRBd/rh39yO0WG/QPWqe5xXpOwqkmombrvJvVnY8Vu+xNGh 5lP86gUQC4bi2G9dfwdNO21YCpnqg== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 Sun Sep 24 19:57: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: 817983 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 3y0dZ91p29z9t3R for ; Mon, 25 Sep 2017 06:08:17 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id F196FC22124; Sun, 24 Sep 2017 20:02:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 95E66C2214E; Sun, 24 Sep 2017 19:58:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 96DAEC2215A; Sun, 24 Sep 2017 19:58:14 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 81136C220D8 for ; Sun, 24 Sep 2017 19:58:11 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Li1hG-1dawpd2sj4-00nBye; Sun, 24 Sep 2017 21:57:31 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:07 +0200 Message-Id: <20170924195716.3433-9-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:OxID6guXKmuDVX1YBeGJkSeW5V5Imw87/bGCVQR4jhwNZ526+66 oKmzb3bwJM98LHvfiIWDIU/qIDWkZdV+sS1qTWYdG/25LVXRyBTfqDuHBtCxgLZjByulphF I6sburwWdzGnzIrDRCDnJWpplBOD8qEte12mpfi9nNKQ35VCAXi59qBcuV3hQF+HV3w6IGz yWqnGtth97nLzBRYiyCsQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:0fh9ZRxBWZ0=:vGLufLRNSG0/ggsxryJP3u 0nt7Ut4B15pVbC27I03fDbCbPjXEGJCTtIj4gh7/+GHVANuViX4JR4bGUl79qMIWM/DiKE0zq w4UFigapURHAYftTprt4zr0qs9NZpKu4g/XZOZrysW0fkIN7LXRjqZMnwcaYiyH+7f8vNR3CR g3DEm8yYtbXTZQW09XajnY6TNHLfds0y5Gq/8w86UXQ9cl0Ql/OCWSZWBjVCNwnDa1hlyZsld m6lQAOmnq4nRY1TOX7qzHHaRs/PJu0Y3BqRYAR6PbzyhKmYmagsT2zRIcr1wAoMw4MtH/W6DM C2zwQkwPf31JC0xXKF6UdNjBrD6G9kIQrWSU9nnpuneTC+oviXNq71inGoxY+9OCX2wxtstAt R3WF9fHFoMrJ/pOP5mzZ07qbCODNr1S+rfMyvLUULhlp+zawYI8i2/DYj2s2mJb7AfPX2Q8uY /Fu0P9dRLZz+wJ0tIAn7ZNdKhMab5dE2xtdsrjKjd63M7PrLiL5vCibI/ZEncuH0If3Fvvjho UgYDPVTUx8U9I/25ptSnrFF5scsxjWVC8vOZZ7cz0IRSc0tfhnvQS01K5O76hCV4uILgZm5As VkF9YilYnckELAsftV04/ofo32UTd6lfwGUTYcjW5F38aJSueRIhi8qWZjadiVpThp1Ibm9VB 9wtUUMxczZzEWCK+ChWrRFaDnEFKFa3nauEtH6C7ZYYAjT4V7Ref1cXFInJTI4kxSD8MWk9qH OHNTIFHh4OV7fqkLBxjGdBH2PBLcMJUPNiuqH+74h7MCAjsihhUFujbq6mVk85kIHop0qu4iA JWwqmOh/Rl0xEyHwUAY1FbpibP4Kg== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 Sun Sep 24 19:57:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 817972 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 3y0dPY390Lz9t3R for ; Mon, 25 Sep 2017 06:00:49 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1AF63C220F1; Sun, 24 Sep 2017 20:00:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4656EC220D2; Sun, 24 Sep 2017 19:58:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7CC0EC22124; Sun, 24 Sep 2017 19:58:14 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 2B6CFC220B8 for ; Sun, 24 Sep 2017 19:58:11 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Lkzph-1dOWN701dF-00anVz; Sun, 24 Sep 2017 21:57:32 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:08 +0200 Message-Id: <20170924195716.3433-10-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:mt4xsWa235tyBhsCKcM9diALmePEyoXTCTcNYE7pEplbgfr40Xb CxDXRLz0jfmVU2Vxk6jjYfUg2nRQS1R39XCOID2y50MbFqw4Ptvx2Wja1vc2CSacPjBn4rf ziiW3uLsXnW+DB7Kad66XwtPeDhFVcQc3VhTSXfGu3sOkr0u4lmuUTuR7bTsteuCUsNmPdT u9wyVbuFPA8w9iuTggKYw== X-UI-Out-Filterresults: notjunk:1; V01:K0:8dLKjVGDETI=:x9CjnfQ5QVtDxU+iWNnbSq uEvqvnPbSnmgZqo3nIm2v5Ap9xqClR05x1FMivLKHHwxa925Z4uLG4VPC+VBG8u6nEfRIUnxk QcBXgvrUtL5CEnAUeUxddI7D69bEmAmvkm4y3xsK8sNUnaH/Hjm4FWipSh88brNIA0QYj7XZf tmW2NX7VAO3hrZVnzlLaOlzgrgDt/xTFq6x1jmj3GX3FuHEsTf1qZGsYrR/HWs0T8aRGijMQn C8MIQo+eA8XR12v4NVqqhsFXVp7nmfEpVvOy/FzBTwuRTAVXwZIOH8z2CtbrhkyXtqyDDv6dJ cwks+a9bXJ1NS197anN7W0YUD95PfzX9Ok3k0sJq8JXQCT9PXEKvFu6rfxKS64WJpPLK/PbAw nrChFfvgWcwhz9A8XmRZLXiwoCbXAoJX/00mR+I69QvajNrUFKd12rbanfIufTCbrwZxcSn8i 3jS6oIIy2WmIFQBs95/OQ4EJJBCIj3McUdWmsd6TXgeQFl2pPG0VBvat1zq5levEcICDGVUr+ xKAz9Cjwv04mbVWeVThBhHGsH5ZA6ezyJankElGIvRG3VtPCi3DG3ZUdGK2JA23AG6xoWVl9y kdmkBrsCIENA+RmG3F8hmZJ9jSJbOw6QKZ3kmgmTTK1YTGy1Pe1BAjhT+v5OBp360coQykS8+ rvKs16Dd4JSwWomyn1/zjokVUvqATeGm32pm2pmwpUVU0jym7TRG6eGv2yrD5cp3Ar4PGrHcB h+uIfjkCHafFN88pF+cX2CabVjR5Ka4dQ/QH+rRl03g/vJ3Rv76L4SkETc9QfImE/SHKdcSKS /gtj2pIrkIkNr2nTe7mkUJVmA2xVA== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 Sun Sep 24 19:57:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 817980 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 3y0dXd5fb0z9t3R for ; Mon, 25 Sep 2017 06:06:57 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 6F065C22149; Sun, 24 Sep 2017 20:00:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2338CC2212D; Sun, 24 Sep 2017 19:58:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 31742C22150; Sun, 24 Sep 2017 19:58:16 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 42D9DC2210F for ; Sun, 24 Sep 2017 19:58:13 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M4B71-1d6RYd1RMB-00rmOz; Sun, 24 Sep 2017 21:57:32 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:09 +0200 Message-Id: <20170924195716.3433-11-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:KRiHEP7Qh3udrDLsVppPRXZUeZD0iaWLYzZW84AZVyCt+ICruFg bLuCp9chAKQBYQiyjMOxbn+Bmi27J7APsybxrpr3t2kojDcBM/7a0WkOkGXVJFRD+GFIF6Y Cv+kdAIFjJB83y9TWVhvOx9WKQcvFVKj3hMpyWfdguGBrgBFHT5wks9lHZGpOimeSEdtfoT IApRwnyatZZQOjuWAFOFg== X-UI-Out-Filterresults: notjunk:1; V01:K0:f3kB3fnz0FA=:+C98HzHnvl2nEYPI7o4RRx 0XCc/feYcO/z2RUtXcYMbF9k90gNaq0PPEy1SWQM5MmXvm7VoHCyX6NUTelRXNmtMmqDTh4je jNUTvGNwTEnfIxDf5+XuaFeGMkZ45sMoy3UR0PMJsRSLhjHB1YA4atYRbkXEXIE2F6zmbxPv/ 0CWgAyrA5KPEikbex+JVAdpyUe7WjOPaEffcIDS8TyILJoMh7E3i/+vjakw7Vy1r7NQAtdL1N M8js1JGg0lsHtEYJlGr5dQgE8W+9mFjydi365x+SxtxBcyWspCb0d9/6jsgXYVMTdAgOBcTTZ NteVFtosu9xR3UdpDL716y8Am+pfabEsP0Xh1nFEzke0Yn7cpKZdvVHJ4EuYYeZDFEmtMYb6+ l9YtSkfZsO8blFjrR5r6wN6uF7mNQQdBERZ595m7IS+1Dor8incuF9D7HpY61xg6uAooiIEzk npNIU8X+SI+4j91fIJ17UBLZX+u5hSN9DJ540LC+z1FLCpO+H6n+u6uJQGFHfLz4yc6jBFufT D1AqNu6YsntqcFPU+2OJN52nkJBIRp3oiGSsKGRu4OUt0EGB6nzpVLiZ+SDfVWH1QKkDoG3iA iI4Q/m12C02nbkzjcY6aAH8jHyZaRenkluZd/s7MwYEYzdpVjRnC9sq2eu0r5NhuAZ0wonG/p hnfYwqExK1J++57Z93fiXbDS9c2So3MhRyCh8531eZWybLPwcXsSl7vxZIZZW0vK8ZT6RTkNO 4ZkrNdJS0jIpN518CvlXvLCrQ+/o6/vFn4MJlgU4+l08ARg9DlWUTFQeSM+52HvvwZM+WHyG7 0ISEwT1myseAwSOPxJXhI2nDfFyGA== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 Sun Sep 24 19:57:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 817974 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 3y0dQz4l4Gz9t1t for ; Mon, 25 Sep 2017 06:02:03 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 04A94C22122; Sun, 24 Sep 2017 19:59:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 556B7C2210F; Sun, 24 Sep 2017 19:58:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DE354C21C2B; Sun, 24 Sep 2017 19:58:18 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id C5B76C22031 for ; Sun, 24 Sep 2017 19:58:14 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0La2Xx-1dV98L2oCD-00lq83; Sun, 24 Sep 2017 21:57:32 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:10 +0200 Message-Id: <20170924195716.3433-12-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:uLebkHcwo6DiMZrrlYRNvwc0yNquTTfsZEZg0g0tSYzqwaz4w+q JbZhv4IyVtM9zHvKywu590CW8LOdmQS6s1ROAceyvii3R8DJ9vHML9PoWDvxG9X9sWbtvo7 3AHkiZHn4y8vOwvUWYRjNQX7Q/UM2err85IRpHKWL4JCKEphjmAIzH9CJ5dUZh9ne2dAlpI RDUy6zdUIIJephgmot9XA== X-UI-Out-Filterresults: notjunk:1; V01:K0:lc4kW3XlooU=:/u8fYm2JzSFJorPWM/YrwB iQ70+Fi9x6ZdvWaiKxoPCjDMWFgAzIgLmjOh7kxo/L00EuhQLMBzSSnLbLPPJpeR5AI8WGmuw 5pMFqbPCZKlIMkP14c0Tai6pSLT44DSgd8koaGhYvBEX7v+xbXcOSNIDOCzOO9iynYDc9pRax p8MnJpq1sxgxxxAOMCKJ/gAeG11ZZiH04vd2t4JFd1kjwWwvXU7i459vW+y4RbVoU8icM1JmK XKQMQ0HWhMsDUQ4aXuQAswXb3ht1S7jLeizLCK9rMLWpBt8fRLaKw4AXR8ux+woS+X9dr/0wp DgHFrCB412/G9nTmjyY+s3rWqRcCG21VjEVFUxGXwOu4a7XgiJnOe+41MfJ2yERJCJBBMN2Hp hxvWnlou4QUlkhsB8vhFSIxr6blm5GYiUQhChIhWjXn+hdK1nKWbx3KEbYSIE7fNmzARXei9i 6OY68/fTA2JRv4RPc3aWW3w7fergx7JtHoLivPL5ZDDgAJfzhjLV4KNfiR5vvrPZnl2OZY5C1 isb7wCR05GulqOiIS8SZ4jyK1TOd01wp8mYQMp7B4LpsGfbyT2kCl+aCWGko8tkLtCiN/YVXo qXqSpqd/Mar+hOu2cuutsv1LPiHy1RJkDzDXJ4uzfT7xZucGYBP76ByuAohMolkWPCmK7TVZL ZmjLnAjWyzZyXe7jWBfiI3VcB2u/7cqCEnf6wmSz97UQpVV/Oe1X3zT/1xZ6t3O190ZO+2f5l 4leYh8jt5EQ+ZXZvAkOSxVE4dY6L/ex9u4znmqgBmLifzmxYtu+HgQV/PnLe11e+qkZyUtJRl 1DoAwFFhD3ZtZysNljithGKSuVI9A== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 tha a network package has been received by the SimpleNetworkProtocol. Signed-off-by: Heinrich Schuchardt --- 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..72a023803d 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->signaled = 1; 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 Sun Sep 24 19:57:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 817973 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 3y0dQQ4dMXz9t1t for ; Mon, 25 Sep 2017 06:01:34 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 57CECC220D2; Sun, 24 Sep 2017 20:00:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2D477C22142; Sun, 24 Sep 2017 19:58:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8E153C22106; Sun, 24 Sep 2017 19:58:20 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id B035EC22127 for ; Sun, 24 Sep 2017 19:58:16 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M7m0a-1dA2KS45ei-00vLB0; Sun, 24 Sep 2017 21:57:33 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:11 +0200 Message-Id: <20170924195716.3433-13-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:SzBov9O31V61Hu5eCuGqjAW7LjUnqaMij3GyLevlW1dN6ZUtTp2 ARAOSHiRiZS7i5lyFppEELqb0/GVh+CCVdoMC7ya1fmCGT1i5VfIMAwdpxfRp7RZqwZnELr hYI2FC7HBDuPgD5Burh+t9kWlkcVHwsLvhVDZ37Nm27/YwXFL663y5LJc4/Lw/PySYPGzXX gRonFxRxRGJuxZ//GN8hw== X-UI-Out-Filterresults: notjunk:1; V01:K0:IIF8wHI4c7Q=:IAa5YIaL8cE9Fn8GIe9S5G 8hB1BbELBsNRCEe+DBuglpRUVZ2x2+wTQ/bqmNmDEMVwyFoTXAAFBsgRbIZ7uQQaRqEy9L1A3 av/HMyxXEHNVzBIvoLwmWQBK/kGti8KZoGcRe/RG83kXwBliuq5Bi5latW5D3m5z1WwOtKL5k OdVU93u97NQIubD/zfFk/zKQSl/l5k1dTiWM0M1h02q6vO5fPDugP6VBSbPN+IKm8Z3FEjp9r BcXFMFhO77a1V8F6HFmcoU9iT6Pn7AcPiaSEhfq4Yz05WrgYGCFdNgWPBzZWLdOaiUK2dj11P EJbXFfNaNgDVc7wR6ElkfFMlReyxz9vLhbYjuMbTDRmNHNOS7MHnKIN+nhe5zguqkyBtW1dhc /HpA+a9nVFEjrRohnRd7s8FvhUmW1sGHDZDV4gi5uasvx3rD7NRF2VnmhooTMpOGaGOB6LxNz M8f8HFHuvQxhkppQrokWbNWjkJsCfIW4A9xkjO2lBUkYJb9EE6EOzio6KKD10TXeS+/7DnYXD re1VfxPtizPBERvqW8wYZvGoZPiK42RJlbXwck2C9DiSzUrwbFGZzYzueZlBOUVNF6IX+2PWB c3+AVl390fNsA6+1Dny5oWpoz5xdMdEjd3c07CuNi3/Z2T43agTLo1t9FsDREi3mSYS5mttrB gJ5AW/rytCZNupGWfqPrELUYdi8KgUFS1aGgmT0obSiHcE1J5cQ6c14wvfzDiI49QSplTTaX4 JB/3cQESgEKqfiV7MpcNJ7xAvuzDCkz3WnEL5158dn+ko/J+jk8t7XKCNX8BwMPGLn8Kff3XU Km/KnV9NTcql+Wwqmqml+j96J+f9g== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 72a023803d..89dc2006f1 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 Sun Sep 24 19:57:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 817976 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 3y0dSW6nnQz9t1t for ; Mon, 25 Sep 2017 06:03:23 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 81B6FC2214A; Sun, 24 Sep 2017 20:01: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.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id DC256C22154; Sun, 24 Sep 2017 19:58:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AA5C2C2213A; Sun, 24 Sep 2017 19:58:18 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id ED561C21C2B for ; Sun, 24 Sep 2017 19:58:14 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LdKs1-1dWG8C1HQP-00iXH5; Sun, 24 Sep 2017 21:57:33 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:12 +0200 Message-Id: <20170924195716.3433-14-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:o+ee/Vyz0ImmREKMXo41fDDmYQm6JnK0tEn1hl7T2PvH86KcSid 7n7+rOs4ptBhOjD6mA7MBX0oBmNkR+HjRSjE58DKlLg88xqIZ9gAcNWla1ZNEin3nr4VfmO SG4ct98xY+BQV1IrF/Zt4tMZJsRtx9IuqqIRzrDpumpqFtadfEwmoDpn+gfsvgIKJA3jwGv 6p9RHEg4HmjksiKC5eItw== X-UI-Out-Filterresults: notjunk:1; V01:K0:FPJL196reTM=:hDgNmd9RTuSP4eXySFe8rD foPKQzZFfjEUpdW/8+P/0Eq9SoIu0qdWT2ABDPb3Fzn9zo56sJqMY37zNDLYNNzZlYBcYS6W7 tDr5aJsLLYpOP0J5JKe6ccTl/lpZ3ZZdvZiN3qJW1N+SA3V11dGGV5qBKLq7A/NB640/SC65i dOyJPFBPNMWdR6npBua6STbxLlZ+g35luFsrbe3V6mqkgb9E8KRToFOwjZ3Hur1LBd/vVge6j a57Q+Che3LhhnnKXLpIdJ8S9sTcq+4MIT1T/c2cQDY+U89Zqf7H81y3ZcDRqGYXGoJORPSxuu hSrXeYUaoLmnRZkpIj3YodBGudToYCW2wsRiYkJ/TTBTN2CNv5O/OrdtRL0dEgkg8UJVvNd1J buPCnBGPHImMsuFNwigpwuH0kEL1ru5csjn4BoxD2YKtnnOMECy+0H2J6K5D2xUzKxhr46NqN mTWaXdaUVR3lI98ZS5qeiQGRCTwrocMtFvpynF2Rr++j6E/aR4qLVZv4qOYiEWtsodOg3jKWE 98V+aZ3HhzjDzJaed0/Kp3yaykuZp6U6D1t7TEncggNAL0TBUbrTARfRqzOHx4JpJcfuBf5Cu f+u4uVKj1DliWlJum8YnJjppWC0b2hr37AKu7xI7rDXIf1YjuYsgo2SVjLk+wwLFLPjq5qfxL 5V1LC30ok6N+bvBsw4p3q/gnaGwuj+Avh/N1kh7pGKU0/ANUNTgrxUN96t3tGGu6CTTk/2SA3 XDI9lFnU8Pz4tNCXkiEIlrCzsTZ2t7t+ssfZ+W1l7HYfLsreeA0sEknzgR3yRsU7c17ztNEXI LT7QQ8puw2HcFv8zsAb9ur0dOYHNw== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 89dc2006f1..5344210fff 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 Sun Sep 24 19:57:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 817985 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 3y0dbM72x0z9t30 for ; Mon, 25 Sep 2017 06:09:19 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id B3443C22153; Sun, 24 Sep 2017 20:02: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.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A889AC2216F; Sun, 24 Sep 2017 19:59:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A0D40C22153; Sun, 24 Sep 2017 19:58:17 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id B5799C220B8 for ; Sun, 24 Sep 2017 19:58:14 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MJmcS-1dxIxV2fUi-001BmU; Sun, 24 Sep 2017 21:57:33 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:13 +0200 Message-Id: <20170924195716.3433-15-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:uuTqyTjLHKlZhKI8GXkv3wax4LnNGb3a4P0YFmbLaTbvtn0dAIk 1SLO8/wPgG/iTirCUSaxbeN0ljbZdN1mgloqPxURxbTLr7TiurE7atoccmlfzv4WkRO2LPQ Qt9kfNhTyMR5bYrsQkxA9YEzn5sfcUGQq0K8tAWMlgT9B0hSemvYdmaR8hBOGPobpznwt3+ wK+U1eHewMnnThU11SUkA== X-UI-Out-Filterresults: notjunk:1; V01:K0:g4q9XZtlrBY=:+A9m+MQcno+ARMF7zdTdAo z/ratxd2WqWZLHmJSe2xhok0Fu9fkdwnAhN7OWxGr8eJ8qbJvHDB1JUIq6zd6/UE++Ek5meec VRqSA54gNmHZFgt27FgMLVuEIY/6EFty8yNs54gwbv7RcRtZq5cRAasvQ+6XUoxl8eLZ6hOxV jq3kL89/NhYCLiSiVSrRdE87ET4iJE+yi5DQoVZsoSB6R2i9S2w+V8axChxY3CLGcIH3+Kwjj FjrEuG5QtB7HIg4nCe4rKkvlJOjqzms2/fAQ+QbQ/igm1pPyx0lZi1CLjmqzckVcDPTYMIBan knzZ9h6c/NXqWd+WO5e/OT46xeeo7SUdRqM6iDokByI0/uUC8xgnLkw3hcA3N8mq7J0FIB9z6 Sbn7B0/rX9opfI8lTrBbYVIOzgTeJ6bO2Lxbpl8aY9S3VfACVIRNc7WoYF/K1CsRyibtG3cHA Dkq4OLOkSA9Iwqp8CvET4zaQy74LROEQHYYr90xVB/CjteISq8d91laT0fm13zt9u6AA4TeRW 6KEMl3y2ILZSQJ75DzrHbf/R/qLctsyMZnYLMQocoJ1K3v/uyhs3Y56yphM70LgYAftTuEsoO HVTX69n7yP6Kxuf5Y0MGPY4GJovMzXCx0XRuxtTpPR9rB8i6oREGR0PgnLBuf3n7Il0ee3PNu 34a5yYxpiQqhyWybq9agWnsLtYS+zWHfn7eTT5XQoekld++f4JdAvWYCm072dhYDS7XRx+9Tw Brr39AY+Ncwn7FCkKE418XcldJm5q3fZQGNHLJTCybzxrzm+y4Pf76eqAz6qlHNNA0DsavdXj hFih3CHjUS8kstLfXI9MyYAWD3EBg== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 5344210fff..e5faa3386e 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 Sun Sep 24 19:57:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 817979 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 3y0dXB4rgdz9t3k for ; Mon, 25 Sep 2017 06:06:34 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 64BE4C2214F; Sun, 24 Sep 2017 20:02:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9E32BC22160; Sun, 24 Sep 2017 19:58:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 13FA0C2210A; Sun, 24 Sep 2017 19:58:17 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 3C230C220AE for ; Sun, 24 Sep 2017 19:58:14 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MgHHO-1dkjvP46kw-00NeJk; Sun, 24 Sep 2017 21:57:34 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:14 +0200 Message-Id: <20170924195716.3433-16-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:iIFFviBb+z3lOKqKXtdsdllwSj+wDJIVbwBhifRQg53iESuHxjN 3MPIZvO6qwPMV/9hPgSerkLlNUz6WNTcXH6qnUNFR9AG45T0y2eXaQDx6VdQuQarx4tWnEl IcvSozBcVFwPUrJubizioZh4gyYYP+RYPeiKitrHO5mZTfA/f12VlwKuH+0GyMXmThTa2id P2YjearHGS23czWVklk6Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:X+07ig6L3pM=:lXjDmseWKixwcWOT4IqyPn 1hjRZ2kdKEC9c1/fjwhHh6zwGU57oesw15f1tVWPDebJWjpL085g2A69f1Vlcus/W5RW2yB9u ILHFArFLyNtKUjDS65cpH9KYejdB4vwkKPiFsQ/TyS0uwU7mX5QJRq+5ng2dtOztxMMqk61lZ zNo1hnpGg/37m1SoJIeaoReLYmYdjUf1AKV2E1w6rdSqnBevyUulxilgMDesK9e3+ayQpLZS6 EE1iS86DtbP6OkTG7PSazQkoAUvNTO8cykwWEt0w1l6Kj4vi9ezGFWiIvlAeDgYPdvMTcd9PA VazQYLMN5GwiJk8JsV7yTSYVYMUPICzK/ae7kJcxUbmiJoGCkuhUneV1BfvYY1tQwRFEQ29wD I24TL97Rv8Zj2A590We6gBZ9Stup9ybpSVjBOy+ChmF+QfRrZbZ7WauD1FLx93B390V8rUGWO B54ktDHZPAiIbwfT/tO4m3ojlXL1aq/6myQdoA6yfsdAfo/iQ7o+EuxdD3QQAM5IalwVzXzN9 uwJCmWU3Lyuk5Ebrr6Pc48cIE1XylMzASIZ76mGFtS668uggenktVTfiwcKGNeTI9jyOD77Im 5DLf8SsHtfbj7lgrnTGSre2EKegSwbe3wzcPIZQ/v3MU+VHgcdGtgzBaz8mUPSAuv4Nu2LeMc B+xesYkfCqPoIGE5FXCBDI2UNkPWE+cXupWe/7xEA9dHoqXWSLPY55BqtMl24UmaONZKvLGg0 Kwbv7zzg3pHoGi1GMjLzygi13Rm/u7JkanWBvNX5at0wCsSGBCVj41OPHphvhcqNXLj/oN7BV bPyPqdCLbS1FSpZ4qW0bkBN1CheCw== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 76304a2b2a..7273a0f49a 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -20,8 +20,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 Sun Sep 24 19:57:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 817982 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 3y0dYd1t6Sz9t3R for ; Mon, 25 Sep 2017 06:07:49 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 06E74C22139; Sun, 24 Sep 2017 20:02:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9EA7EC22169; Sun, 24 Sep 2017 19:58:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3DFB3C2214E; Sun, 24 Sep 2017 19:58:20 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id EF168C22114 for ; Sun, 24 Sep 2017 19:58:16 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LlXnX-1dP4Kv1K11-00bLTl; Sun, 24 Sep 2017 21:57:34 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:15 +0200 Message-Id: <20170924195716.3433-17-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:Hp1qQ48GV4gEFWVFxXyqMdqqqyLyWgHZPZHBETSm9bJEEYojLD7 gZudPPzgA4HBzaQJRU3tkoQ/rNs+EKfk9cBALO59u43nCnn4qsowLUYZjt/hWiOj+oXILdw hmtzfrvHy23R7NGBmBDa5lN8behGBPIT9pJLyYuYkPx6NO6Pe2SRQeoHh9RcBBfb+Bjwfi4 L/xTDb7mPYJJV0A2kbABg== X-UI-Out-Filterresults: notjunk:1; V01:K0:KQ6/Ri7Fq+8=:DmELr8cdgDkXhfOiJa70zP Je3EA7hwHhrcstpKLc50TA0w5FLGyTs0R44QGsoOkA3IsN0N8C79jobx1T/FiEJh9mQ0Oao84 rhloWFAbnzSYsumI+phsYqozHCgHU3eR5JBGWoKWFXxzFyQaXsQPX0Lq0N342vVLdp3dyw+v7 bNO1oSIJdzgtIToX7PqQEwYzox7RHyYWDCu9ARULlpPnaiy9NyXpaqw6X7RPObamKpPoRciAk gjkerqAtIeQmasQHQrTpICxznBuVlunj+HOZavABY80rXkqd8a1wszon2GSRX8RQJu8v4hhFY lRhFVG0DYsw4EIa7BoliPz/jYeeUpGjWSHmhV+pNp+B3rriQHumA1sNcwCl8EZgewcSHIaDYW KBgZ3WnJtm06zEduCRy/cpYg02i1kVacsutmdmy87VluMIe3vNKRG1DlpqgIRI6644T9ucMrx sTDFQSxIZQn5sxz29mzn7VqlsCMOVGV4NDAz8uxhCqaVo5KgzXDJc6735O9tSibwWLldI+/oN jKAB8NP9KAUZC5v904S8x8voOii2t6RKKk59M6T3exqM3b1mnQX3T/V5dtQCIflK7FBqdk1VL Ow4J6ynvUIGqpz0Z2N7F/G8PMPeLWAGBLBhq3SL1XzIpsf2OqCHsU2WGsAI4aCSdmFRIOgFUk 757+vQ+Rx3GF62NTtKAor+14okmL/5N6nQ3NIcyX0waaoQPU0EAlpJXdPcV0Tk+wtMvXvn5HD qJ2ivDYlxrSAX1wGfRJHu6ChBSep9PHKE7MYqZdLDGM7oXFw+txy91LjsEEOLCvAOX7LOzMbM 7a8puHiJX9PBSMpAe3V0i+g/Hc62Q== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- 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 Sun Sep 24 19:57:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 817977 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 3y0dT86gnVz9t3R for ; Mon, 25 Sep 2017 06:03:56 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 89B47C220FC; Sun, 24 Sep 2017 20:01:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id AAD69C2213F; Sun, 24 Sep 2017 19:58:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8B7F0C22141; Sun, 24 Sep 2017 19:58:21 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id E2C01C220F3 for ; Sun, 24 Sep 2017 19:58:17 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LnUna-1dR09A2pG2-00hf8y; Sun, 24 Sep 2017 21:57:34 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 24 Sep 2017 21:57:16 +0200 Message-Id: <20170924195716.3433-18-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924195716.3433-1-xypron.glpk@gmx.de> References: <20170924195716.3433-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:FndgS0nGPFX+/1qgWofcfTLSdUQCSALt6xErLwkm0YiWiqTBXGr i4cqRUBGgV/7eJLCRhdB1VUz3BkW1ByQQw7+Pzu6tt0BHydX9NlFWCyj2FQ7SHx2k3B0Od8 tfcjwyHP+mrIJN0jOehE2GJOC00lBLOe0Z1OgL8d7LCIjo6+6xuVmm3ND64OBZtGwx2ZZ/d SlUAQAuVQpuUwoFKmsXqw== X-UI-Out-Filterresults: notjunk:1; V01:K0:AeI6eVIf2ek=:la2KIWSw+hV3d74IfaB2xm E/LtpHEKjf0GrOtnfMOBl0yN5i7nFn71qys+sR8EE8t4e9IgYbytIQQUMQlvqaWfTdnnuz155 jKaRMo1VjVIrPflysBnUh/Fb7SAcCYKp1b9/WRfaKTpExj5rtq96yCf3W7z2jNUWU8+7+VA1o FKXAHs0FWtdZFrWCTOIcPjYSm+wH78R7I8F8WYKpwyI4KdgPL1m6u2TMvCKxE+ckOn03PQ9++ cMw+8EscB8LtL1DdVkMoNerJzCAk+Rl8sEWCKhq+rm4hqDQIAvJeqGlNnPzZH7uX8PcLlu2v4 K0RgGGKeujNzas+00t3X+0UxV0gLKeR02a6fq3I5RuLqC8+iOBDcSdU1pwJ7I7y9kjuI6O7sA DXcZ0l+hnHXniRrdIy7iVJelFeQjEu9jEgSJ1UyiGhcMlfM4OVnUHgbPelTUgxr+MedeMjMxh cZOQBy05m3Sth3h74JBpdBopbNKHuotGf3Lg6yr6qQaWgGCbYerrqcih/S/pPvGffxVI9wUMr h7Xhr6hrvLZ73AzYYRSZ69nqATryjRbSBqwdvRwnlaIFQruk4Xaqy/v+tMEmv6lhQhvlBQXPz mNYQZoBV3tZkLWqSFohCX/xwky2tJtaaVaAWD9/mAmhmrF6xPNYHMUTERSuD/8JsMQfR6gaS1 0I2PFZQq0T15HL6XmTvZXplilA20xac/+yctIZ9eD6/Z87Z3OsEetxrkC9RI5vCmvra7uXdrK yrFQ5J0o2bVL2R89ZjidPXJZzCdDGLaqfvHlR+pQk1+ifLNCoV+8dRDwhPrZeuFPillFMLjri LROLSS+Gkl80ur9yjlirCoQELX/yg== Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 --- lib/efi_selftest/Makefile | 3 + lib/efi_selftest/efi_selftest_snp.c | 442 ++++++++++++++++++++++++++++++++++++ 2 files changed, 445 insertions(+) create mode 100644 lib/efi_selftest/efi_selftest_snp.c diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index 30f1960933..9bfecf357b 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -15,6 +15,8 @@ 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) @@ -23,4 +25,5 @@ efi_selftest.o \ efi_selftest_console.o \ efi_selftest_events.o \ efi_selftest_exitbootservices.o \ +efi_selftest_snp.o \ efi_selftest_tpl.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..7bb81208ad --- /dev/null +++ b/lib/efi_selftest/efi_selftest_snp.c @@ -0,0 +1,442 @@ +/* + * 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; + +/* + * Compare memory. + * We cannot use lib/string.c due to different CFLAGS values. + * + * Returns 0 if both buffers contain the same bytes. + * + * @buf1 first buffer + * @buf2 second buffer + * @length number of bytes to compare + */ +static 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 0; +} + +/* + * 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 + */ +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 + */ +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 1; + } + /* + * 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 1; + } + /* + * 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 1; + } + /* + * Check hardware address size. + */ + if (!net->mode) { + efi_st_error("Mode not provided\n"); + return 1; + } + if (net->mode->hwaddr_size != ARP_HLEN) { + efi_st_error("HwAddressSize = %u, expected %u\n", + net->mode->hwaddr_size, ARP_HLEN); + return 1; + } + /* + * Check that WaitForPacket event exists. + */ + if (!net->wait_for_packet) { + efi_st_error("WaitForPacket event missing\n"); + return 1; + } + /* + * Initialize network adapter. + */ + ret = net->initialize(net, 0, 0); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to initialize network adapter\n"); + return 1; + } + /* + * Start network adapter. + */ + ret = net->start(net); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to start network adapter\n"); + return 1; + } + return 0; +} + +/* + * Execute unit test. + * + * A DHCP discover message is sent. The test is successful if a + * DHCP reply is received within 10 seconds. + */ +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 1; + + /* + * 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 1; + } + /* + * Send further DHCP discover message + */ + ret = send_dhcp_discover(); + if (ret != EFI_SUCCESS) + return 1; + 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 1; + } + /* + * 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 0; +} + +/* + * Tear down unit test. + * + * Close the timer event created in setup. + * Shut down the network adapter. + */ +static int teardown(void) +{ + efi_status_t ret; + int exit_status = 0; + + 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 = 1; + } + /* + * Close timer event. + */ + ret = boottime->close_event(timer); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to close event"); + exit_status = 1; + } + } + if (net) { + /* + * Stop network adapter. + */ + ret = net->stop(net); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to stop network adapter\n"); + exit_status = 1; + } + /* + * Shut down network adapter. + */ + ret = net->shutdown(net); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to shut down network adapter\n"); + exit_status = 1; + } + } + + return exit_status; +} + +EFI_UNIT_TEST(snp) = { + .name = "simple network protocol", + .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, + .setup = setup, + .execute = execute, + .teardown = teardown, +};