From patchwork Fri May 11 10:09:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 911888 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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40j5V13kbYz9s16 for ; Fri, 11 May 2018 20:11:37 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 336AEC22346; Fri, 11 May 2018 10:10:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id F0472C2230A; Fri, 11 May 2018 10:09:36 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1CF7CC21FA1; Fri, 11 May 2018 10:09:33 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lists.denx.de (Postfix) with ESMTPS id B8476C222BF for ; Fri, 11 May 2018 10:09:32 +0000 (UTC) Received: from localhost.localdomain ([89.204.154.43]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LpsIh-1ecoQ82sBb-00fgXN; Fri, 11 May 2018 12:09:31 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Fri, 11 May 2018 12:09:22 +0200 Message-Id: <20180511100923.29659-4-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180511100923.29659-1-xypron.glpk@gmx.de> References: <20180511100923.29659-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K1:eC3WQwhxhTghRhe3LeIHGz9/MhJqGbuiz4CPmpw7fowcUCWFuOP x4OrpsbdoEWWlIjSbHx+g874DTmMKjcIk8hZ5T2gRL5hEKnQPJaSdkL7vWI8Vs2/bAvgAdf 3vtViF8REOL+n07ItEVi24vPhP8gaw5booFdoFHiLtvheQfz8J/jniNIGsz9bgK3YTU7h6L tEPPx0iwa6d3TKTpx9www== X-UI-Out-Filterresults: notjunk:1; V01:K0:KEfNZuji4M0=:breqsmW1zIfBRHiiquxshR DUBln3hR77V+Mj0ECcoMXYG1i9Lcfr/Szi9w38OB5hKqwWVQEgyXmDvnTZnwFyMeb8tDAc26I jLW6kD4Cvnn5vR8eucB3lDcQ0d0yoQUKoyahz2D5u3br+4vUm9g/U7Ksp48D0HGM8922x+MOk n12uMwr5in75kF7W/yQ0hLfqGa6OYp7PNRQZUtDJN/LJ2chjgAGPodBeITBCuFXyzB/xZZ4Ao tHQq8nkIXprPlqK9a++6yh0yB4E9RlkxD9Nj3LVjYCigZh0XRy2YGYkN8ild77SswbCPEpvvX 0w2Iym2If70MH6LDIVdMBPlKphR4JVhXLD7WNNNO/6sM0hwxerNazdgovMNW+/cAz7whdIr0s uWz9SrCIfz2kUPVf8U4Xzw0ok2B/WwcEmrPTCJ6BPFs9rIAulsZd+7Gs5tTKUKuBft61q6kIJ 5jHyy/A7ltUnxPc2pSnhruUFdCAvKJCh2DmFBkm8An18N+TYugVDPeKYKn4tWBUX5kxT8idhr 0z0jZfC2vobdv/DeqgoL1gfZouwT2cRB7TG9dnY31GPiKYXaNCmZzGxkgPswBk0sWSS7VeMhm l2u+BmgT6RBGQzuSEVyCJu38VI/PUdRkwfI6K7Fx6RJzOsA5gjV65gTBEWl3qtwj51RjaJ6xj Mwd2Fg9itgNue/8DO+PUasxE8gsUgAzZiDztdE3dto0iL8bJSZ3E36OTPiMYH1yV5LrRz7gLl H8rhDBB0ojET7p/P7bzpaPbdYsj+A/g5IhoU0I5m7qahemmV2EUlPILZW1Y= Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 3/4] efi_loader: implement ReinstallProtocolInterface 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 ReinstallProtocolInterface boot time service is implemented. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_boottime.c | 66 +++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index bfaef29d3e6..8abbdfcec4c 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1022,29 +1022,6 @@ out: return EFI_EXIT(r); } -/* - * Reinstall protocol interface. - * - * This function implements the ReinstallProtocolInterface service. - * See the Unified Extensible Firmware Interface (UEFI) specification - * for details. - * - * @handle handle on which the protocol shall be - * reinstalled - * @protocol GUID of the protocol to be installed - * @old_interface interface to be removed - * @new_interface interface to be installed - * @return status code - */ -static efi_status_t EFIAPI efi_reinstall_protocol_interface( - efi_handle_t handle, const efi_guid_t *protocol, - void *old_interface, void *new_interface) -{ - EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, old_interface, - new_interface); - return EFI_EXIT(EFI_ACCESS_DENIED); -} - /* * Get all drivers associated to a controller. * The allocated buffer has to be freed with free(). @@ -2775,6 +2752,49 @@ out: return EFI_EXIT(ret); } +/* + * Reinstall protocol interface. + * + * This function implements the ReinstallProtocolInterface service. + * See the Unified Extensible Firmware Interface (UEFI) specification + * for details. + * + * The old interface is uninstalled. The new interface is installed. + * Drivers are connected. + * + * @handle handle on which the protocol shall be + * reinstalled + * @protocol GUID of the protocol to be installed + * @old_interface interface to be removed + * @new_interface interface to be installed + * @return status code + */ +static efi_status_t EFIAPI efi_reinstall_protocol_interface( + efi_handle_t handle, const efi_guid_t *protocol, + void *old_interface, void *new_interface) +{ + efi_status_t ret; + + EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, old_interface, + new_interface); + ret = EFI_CALL(efi_uninstall_protocol_interface(handle, protocol, + old_interface)); + if (ret != EFI_SUCCESS) + goto out; + ret = EFI_CALL(efi_install_protocol_interface(&handle, protocol, + EFI_NATIVE_INTERFACE, + new_interface)); + if (ret != EFI_SUCCESS) + goto out; + /* + * The returned status code has to be ignored. + * Do not create an error if no suitable driver for the handle exists. + */ + EFI_CALL(efi_connect_controller(handle, NULL, NULL, true)); +out: + return EFI_EXIT(ret); +} + /* * Get all child controllers associated to a driver. * The allocated buffer has to be freed with free().