From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09B17C433EF for ; Thu, 9 Dec 2021 19:23:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E7B1282F96; Thu, 9 Dec 2021 20:23:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="ixiLlj2L"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 67A3083124; Thu, 9 Dec 2021 20:23:49 +0100 (CET) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8587580C72 for ; Thu, 9 Dec 2021 20:23:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1639077821; bh=dpFmVPiWgfT0VT/8bNkm2YG00y5NEpnT5mE0ERSGdAQ=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=ixiLlj2LTxVyID2aMGsVdekuUxay2f1gB99eezqF+O+Id8ERx02XixFH955SLIZ0Q TMlAExARYn+yX/hQ50G4eQO08QkZiOwKruKVIUFJ6EAJ5bppyP47qZgEaFTwawrwRN g7xeOtuj+008P6qkB32cuweLRV+JCBOZvzNSVJV8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [172.31.56.117] ([216.9.110.2]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MpUYu-1mCSnv2uOS-00pyEb; Thu, 09 Dec 2021 20:23:41 +0100 Message-ID: <48b57524-cd42-5cea-29d7-7394bc70a076@gmx.de> Date: Thu, 9 Dec 2021 11:23:31 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Subject: Re: [PATCH v5 04/28] efi: Locate all block devices in the app Content-Language: en-US From: Heinrich Schuchardt To: Simon Glass Cc: Ilias Apalodimas , Christian Melki , Bin Meng , Tom Rini , Alexander Graf , U-Boot Mailing List References: <20211204155657.2913911-1-sjg@chromium.org> <20211204085647.v5.4.I0774d3540ebe726f31838b851815e829fb6a4056@changeid> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:ktD2ZlCvIjimZDAszc+mx27q0Mp+46kUU9CsjruOGYXcrK19JnA QCR+eIz+A0QjHkhvD7S21bQAf+cr49n9Ry9gYunMPiJBwLJ3mRDgDFvnVFCEayUcfT5GPhi mMcFREqCVtHAX3QwF6dSl+ER7sFVWP+0EBGqwlRRvgShu4ByzvdKiQNI/6qFrxQ8dsscK+p YaJTx21xOU16Cg18owUIg== X-UI-Out-Filterresults: notjunk:1;V03:K0:WFboBxzgiDg=:NAUIAmwRLfFPsPhW7kOWZW VPXp1CVsxFiexeoNQoLG/65qCEXi3uNEzMvbRrQdrt5MNA2DyXgAp/8xWIrIJhHrNwlivYSNT 6kpI/AbW9tBDVFjx/6U8Vkv9lbJv84cy26/B9dV509vuepCw9HpkPNYARb3OLIxrZyqYqGUFC eBwQQLn0I3ypf/3SbFprsYY+YHfm2uEWo7T+bzo/syQkavwOKuXW5TPHx2m2TjoxMwXZbpzha Ochl3k6r6tHvtQWK36QGlJUrFFYE5IuX1DdaUu/iVwY3LF0KOdJfyEnRXRZLv8igsySXweRCJ wV53Nf3hXNNEID+WLR4aKtGw+zmPNuSZfFdTdFuuGuzDd7wYTCz7+LgkrnBC32HtiJw97rGBP MlDOeWqiQPeM88D6BlnjcH/wNgIC2+qyFZbAd7LuSgUpFo/rG+NFWQreik9iWJ4rg+hrla7js GWZF644v0pXlvGfONMAwJ12lJpBm5GO3UHz1HprxQQsFuC88UGT5v67vM8sVWuSKHnZPdcbt1 V45y+Xlpjgj4bY7DfZrlMTjLf25gxx+m7Ps0kXhs2OV5OKM8dFPu8pD7i6ixN8ZArNvLyBlq4 wtXBlVIQOA/2ZjeMRa0Eo6UoEeqqCSW06nM1zyDg1A5bl4V0nMjTO6pvZ3XEQUtSx0afSbMAS K7w5iyqWWNk2TVQQozkCy+ULSl0omUbe5ZyhdzA0ZfTzQgbZ1fzlv1dbbTryf7er92zCPCR3V uxIxFY5cI10+irf+Ylrhwsf4agzW7sOwnwVpTAEVSPzXMpScJM7gbjAaelF/cHPK0FoYwlyYI caNSsaawS7uRTM98z4kgA2guzYfp8QskS0WoIV8J37zYiSN7dsQZ8wLsoB58Dhg0nhJgDv5mh LvpNPLQKhabrCW4uu6M3hlqMP5RjqiCUkL6md9kzBhmJ/m36Uz181wBJJV3fp4mY+qJVUZgjS nbH9ecrH6gIoDIWH6UG0W9KTH8LKQGnePfi8Naq8jrwmv27O2dxeIb16Ua5DOT14ZsxrRp3RO 75oFYj14UvmRrsS3lWd54ogRvkODTwdvJzfAN7fdtMRzsYRIo4RXHCFO46xGAjLMXSEnubYY9 kFsAoCVc8A2YB4= X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 12/4/21 10:43, Heinrich Schuchardt wrote: > On 12/4/21 16:56, Simon Glass wrote: >> When starting the app, locate all block devices and make them available >> to U-Boot. This allows listing partitions and accessing files in >> filesystems. >> >> EFI also has the concept of 'disks', meaning boot media. For now, this >> is not obviously useful in U-Boot, but add code to at least locate thes= e. >> This can be expanded later as needed. >> >> Series-changes; 2 >> - Store device path in struct efi_media_plat >> - Don't export efi_bind_block() >> - Only bind devices for media devices, not for partitions >> - Show devices that are processed >> - Update documentation >> >> Signed-off-by: Simon Glass >> --- >> >> (no changes since v1) >> >> =C2=A0 doc/develop/uefi/u-boot_on_efi.rst |=C2=A0=C2=A0 4 +- >> =C2=A0 include/efi.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 |=C2=A0=C2=A0 6 +- >> =C2=A0 include/efi_api.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 15 ++ >> =C2=A0 lib/efi/efi_app.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 223 ++++++++++= +++++++++++++++++++ >> =C2=A0 4 files changed, 243 insertions(+), 5 deletions(-) >> >> diff --git a/doc/develop/uefi/u-boot_on_efi.rst >> b/doc/develop/uefi/u-boot_on_efi.rst >> index 5f2f850f071..8f81b799072 100644 >> --- a/doc/develop/uefi/u-boot_on_efi.rst >> +++ b/doc/develop/uefi/u-boot_on_efi.rst >> @@ -265,9 +265,7 @@ This work could be extended in a number of ways: >> >> =C2=A0 - Figure out how to solve the interrupt problem >> >> -- Add more drivers to the application side (e.g. block devices, USB, >> -=C2=A0 environment access). This would mostly be an academic exercise = as a >> strong >> -=C2=A0 use case is not readily apparent, but it might be fun. >> +- Add more drivers to the application side (e.g.USB, environment >> access). >> >> =C2=A0 - Avoid turning off boot services in the stub. Instead allow U-B= oot >> to make >> =C2=A0=C2=A0=C2=A0 use of boot services in case it wants to. It is uncl= ear what it >> might want >> diff --git a/include/efi.h b/include/efi.h >> index 0ec5913ddd1..908c5dc6ebd 100644 >> --- a/include/efi.h >> +++ b/include/efi.h >> @@ -419,10 +419,12 @@ struct efi_priv { >> =C2=A0=C2=A0 * >> =C2=A0=C2=A0 * @handle: handle of the controller on which this driver i= s installed >> =C2=A0=C2=A0 * @blkio: block io protocol proxied by this driver >> + * @device_path: EFI path to the device >> =C2=A0=C2=A0 */ >> =C2=A0 struct efi_media_plat { >> -=C2=A0=C2=A0=C2=A0 efi_handle_t=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 handle; >> -=C2=A0=C2=A0=C2=A0 struct efi_block_io=C2=A0=C2=A0=C2=A0 *blkio; >> +=C2=A0=C2=A0=C2=A0 efi_handle_t handle; >> +=C2=A0=C2=A0=C2=A0 struct efi_block_io *blkio; >> +=C2=A0=C2=A0=C2=A0 struct efi_device_path *device_path; >> =C2=A0 }; >> >> =C2=A0 /* Base address of the EFI image */ >> diff --git a/include/efi_api.h b/include/efi_api.h >> index 80109f012bc..ec9fa89a935 100644 >> --- a/include/efi_api.h >> +++ b/include/efi_api.h >> @@ -2035,4 +2035,19 @@ struct efi_firmware_management_protocol { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 const u16 *package_version_name); >> =C2=A0 }; >> >> +#define EFI_DISK_IO_PROTOCOL_GUID=C2=A0=C2=A0=C2=A0 \ >> +=C2=A0=C2=A0=C2=A0 EFI_GUID(0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, \ >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0x00, 0xa0, 0xc9, 0x6= 9, 0x72, 0x3b) >> + >> +struct efi_disk { >> +=C2=A0=C2=A0=C2=A0 u64 revision; >> +=C2=A0=C2=A0=C2=A0 efi_status_t (EFIAPI *read_disk)(struct efi_disk *t= his, u32 >> media_id, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u64 offset, efi_uintn_= t buffer_size, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 void *buffer); >> + >> +=C2=A0=C2=A0=C2=A0 efi_status_t (EFIAPI *write_disk)(struct efi_disk *= this, u32 >> media_id, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u64 offset, efi_= uintn_t buffer_size, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 void *buffer); >> +}; >> + >> =C2=A0 #endif >> diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c >> index f61665686c5..e38d46b15db 100644 >> --- a/lib/efi/efi_app.c >> +++ b/lib/efi/efi_app.c >> @@ -21,6 +21,9 @@ >> =C2=A0 #include >> =C2=A0 #include >> =C2=A0 #include >> +#include >> +#include >> +#include >> >> =C2=A0 DECLARE_GLOBAL_DATA_PTR; >> >> @@ -46,6 +49,64 @@ int efi_info_get(enum efi_entry_t type, void >> **datap, int *sizep) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -ENOSYS; >> =C2=A0 } >> >> +/** >> + * efi_print_str() - Print a UFT-16 string to the U-Boot console >> + * >> + * @str: String to print >> + */ >> +static void efi_print_str(const u16 *str) >> +{ >> +=C2=A0=C2=A0=C2=A0 while (*str) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int ch =3D *str++; >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ch > ' ' && ch < 127) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 put= c(ch); >> +=C2=A0=C2=A0=C2=A0 } >> +} >> + >> +/** >> + * efi_bind_block() - bind a new block device to an EFI device >> + * >> + * Binds a new top-level EFI_MEDIA device as well as a child block >> device so >> + * that the block device can be accessed in U-Boot. >> + * >> + * The device can then be accessed using 'part list efi 0', 'fat ls >> efi 0:1', >> + * for example, just like any other interface type. >> + * >> + * @handle: handle of the controller on which this driver is installed >> + * @blkio: block io protocol proxied by this driver >> + * @device_path: EFI device path structure for this >> + * @len: Length of @device_path in bytes >> + * @devp: Returns the bound device >> + * @return 0 if OK, -ve on error >> + */ >> +int efi_bind_block(efi_handle_t handle, struct efi_block_io *blkio, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct ef= i_device_path *device_path, int len, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct ud= evice **devp) >> +{ >> +=C2=A0=C2=A0=C2=A0 struct efi_media_plat plat; >> +=C2=A0=C2=A0=C2=A0 struct udevice *dev; >> +=C2=A0=C2=A0=C2=A0 char name[18]; >> +=C2=A0=C2=A0=C2=A0 int ret; >> + >> +=C2=A0=C2=A0=C2=A0 plat.handle =3D handle; >> +=C2=A0=C2=A0=C2=A0 plat.blkio =3D blkio; >> +=C2=A0=C2=A0=C2=A0 plat.device_path =3D malloc(device_path->length); >> +=C2=A0=C2=A0=C2=A0 if (!plat.device_path) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return log_msg_ret("path", = -ENOMEM); >> +=C2=A0=C2=A0=C2=A0 memcpy(plat.device_path, device_path, device_path->= length); >> +=C2=A0=C2=A0=C2=A0 ret =3D device_bind(dm_root(), DM_DRIVER_GET(efi_me= dia), "efi_media", >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 &plat, ofnode_null(), &dev); >> +=C2=A0=C2=A0=C2=A0 if (ret) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return log_msg_ret("bind", = ret); >> + >> +=C2=A0=C2=A0=C2=A0 snprintf(name, sizeof(name), "efi_media_%x", dev_se= q(dev)); >> +=C2=A0=C2=A0=C2=A0 device_set_name(dev, name); >> +=C2=A0=C2=A0=C2=A0 *devp =3D dev; >> + >> +=C2=A0=C2=A0=C2=A0 return 0; >> +} >> + >> =C2=A0 static efi_status_t setup_memory(struct efi_priv *priv) >> =C2=A0 { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct efi_boot_services *boot =3D priv-= >boot; >> @@ -105,6 +166,168 @@ static void free_memory(struct efi_priv *priv) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 global_data_ptr =3D NULL; >> =C2=A0 } >> > > > Missing function description > > >> +static int setup_disks(void) >> +{ >> +=C2=A0=C2=A0=C2=A0 /* This is not fully implemented yet */ see hint below. >> +=C2=A0=C2=A0=C2=A0 return 0; >> + >> +=C2=A0=C2=A0=C2=A0 efi_guid_t efi_disk_guid =3D EFI_DISK_IO_PROTOCOL_G= UID; U-Boot does not implement the EFI_DISK_IO_PROTOCOL. So you will not be able to run U-Boot as an EFI app loaded by U-Boot which might be nice for testing. The more basic protocol is the EFI_BLOCK_IO_PROTOCOL. The difference is that the EFI_BLOCK_IO_PROTOCOL requires using a properly aligned buffer. >> +=C2=A0=C2=A0=C2=A0 struct efi_boot_services *boot =3D efi_get_boot(); >> +=C2=A0=C2=A0=C2=A0 struct efi_disk *disk; >> +=C2=A0=C2=A0=C2=A0 int ret; >> + >> +=C2=A0=C2=A0=C2=A0 if (!boot) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return log_msg_ret("sys", -= ENOSYS); >> +=C2=A0=C2=A0=C2=A0 ret =3D boot->locate_protocol(&efi_disk_guid, NULL,= (void **)&disk); If you want to find all handles implementing a protocol, you can use EFI_BOOT_SERVICES.LocateHandleBuffer() with SearchType ByProtocol. I guess we should add this patch to U-Boot once it is completed. Best regards Heinrich >> +=C2=A0=C2=A0=C2=A0 if (ret) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return log_msg_ret("prot", = -ENOTSUPP); >> + >> +=C2=A0=C2=A0=C2=A0 return 0; >> +} >> + >> +/** >> + * devpath_is_partition() - Figure out if a device path is a partition >> + * >> + * Checks if a device path refers to a partition on some media >> device. This >> + * works by checking for a valid partition number in a hard-driver >> media device >> + * as the final component of the device path. >> + * >> + * @return true if a partition, false if not (e.g. it might be media >> which >> + *=C2=A0=C2=A0=C2=A0 contains partitions) > > Please, stick to the format for function descriptions defined in > https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#functio= n-documentation > > > The description for parameter @path: is missing. > @return does not exist. Please, use Return:. > > >> + */ >> +static bool devpath_is_partition(const struct efi_device_path *path) >> +{ >> +=C2=A0=C2=A0=C2=A0 const struct efi_device_path *p; >> +=C2=A0=C2=A0=C2=A0 bool was_part; >> + >> +=C2=A0=C2=A0=C2=A0 for (p =3D path; p->type !=3D DEVICE_PATH_TYPE_END; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 p =3D (void *)p + p->= length) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 was_part =3D false; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (p->type =3D=3D DEVICE_P= ATH_TYPE_MEDIA_DEVICE && >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 p->= sub_type =3D=3D DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 str= uct efi_device_path_hard_drive_path *hd =3D >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (void *)path; >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if = (hd->partition_number) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 was_part =3D true; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> +=C2=A0=C2=A0=C2=A0 } >> + >> +=C2=A0=C2=A0=C2=A0 return was_part; >> +} >> + >> +/** >> + * setup_block() - Find all block devices and setup EFI devices for th= em >> + * >> + * Partitions are ignored, since U-Boot has partition handling. >> Errors with >> + * particular devices produce a warning but execution continues to >> try to >> + * find others. >> + * >> + * @return 0 if found, -ENOSYS if there is no boot-services table, >> -ENOTSUPP >> + *=C2=A0=C2=A0=C2=A0 if a required protocol is not supported > > %s/@return/Return:/ > >> + */ >> +static int setup_block(void) >> +{ >> +=C2=A0=C2=A0=C2=A0 efi_guid_t efi_blkio_guid =3D EFI_BLOCK_IO_PROTOCOL= _GUID; >> +=C2=A0=C2=A0=C2=A0 efi_guid_t efi_devpath_guid =3D EFI_DEVICE_PATH_PRO= TOCOL_GUID; >> +=C2=A0=C2=A0=C2=A0 efi_guid_t efi_pathutil_guid =3D >> EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID; >> +=C2=A0=C2=A0=C2=A0 efi_guid_t efi_pathtext_guid =3D >> EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID; >> +=C2=A0=C2=A0=C2=A0 struct efi_boot_services *boot =3D efi_get_boot(); >> +=C2=A0=C2=A0=C2=A0 struct efi_device_path_utilities_protocol *util; >> +=C2=A0=C2=A0=C2=A0 struct efi_device_path_to_text_protocol *text; >> +=C2=A0=C2=A0=C2=A0 struct efi_device_path *path; >> +=C2=A0=C2=A0=C2=A0 struct efi_block_io *blkio; >> +=C2=A0=C2=A0=C2=A0 efi_uintn_t num_handles; >> +=C2=A0=C2=A0=C2=A0 efi_handle_t *handle; >> +=C2=A0=C2=A0=C2=A0 int ret, i; >> + >> +=C2=A0=C2=A0=C2=A0 if (!boot) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return log_msg_ret("sys", -= ENOSYS); >> + >> +=C2=A0=C2=A0=C2=A0 /* Find all devices which support the block I/O pro= tocol */ >> +=C2=A0=C2=A0=C2=A0 ret =3D boot->locate_handle_buffer(BY_PROTOCOL, &ef= i_blkio_guid, NULL, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &num_handles, &handle); >> +=C2=A0=C2=A0=C2=A0 if (ret) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return log_msg_ret("loc", -= ENOTSUPP); >> +=C2=A0=C2=A0=C2=A0 log_debug("Found %d handles:\n", (int)num_handles); >> + >> +=C2=A0=C2=A0=C2=A0 /* We need to look up the path size and convert it = to text */ >> +=C2=A0=C2=A0=C2=A0 ret =3D boot->locate_protocol(&efi_pathutil_guid, N= ULL, (void >> **)&util); >> +=C2=A0=C2=A0=C2=A0 if (ret) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return log_msg_ret("util", = -ENOTSUPP); >> +=C2=A0=C2=A0=C2=A0 ret =3D boot->locate_protocol(&efi_pathtext_guid, N= ULL, (void >> **)&text); >> +=C2=A0=C2=A0=C2=A0 if (ret) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return log_msg_ret("text", = -ENOTSUPP); >> + >> +=C2=A0=C2=A0=C2=A0 for (i =3D 0; i < num_handles; i++) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct udevice *dev; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const u16 *name; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bool is_part; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int len; >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ret =3D boot->handle_protoc= ol(handle[i], &efi_devpath_guid, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (voi= d **)&path); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ret) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 log= _warning("- devpath %d failed (ret=3D%d)\n", i, ret); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 con= tinue; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ret =3D boot->handle_protoc= ol(handle[i], &efi_blkio_guid, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (voi= d **)&blkio); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ret) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 log= _warning("- blkio %d failed (ret=3D%d)\n", i, ret); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 con= tinue; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 name =3D text->convert_devi= ce_path_to_text(path, true, false); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 is_part =3D devpath_is_part= ition(path); >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!is_part) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 len= =3D util->get_device_path_size(path); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ret= =3D efi_bind_block(handle[i], blkio, path, len, &dev); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if = (ret) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 log_warning("- blkio bind %d failed (ret=3D%d)\n", >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i, r= et); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 continue; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } else { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev= =3D NULL; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * Show the device nam= e if we created one. Otherwise indicate >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * that it is a partit= ion. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * We don't seem to ha= ve have a way to print unicode on the >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * U-Boot console at p= resent, so use our own function. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 printf("%2d: %-12s ", i, de= v ? dev->name : ""); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 efi_print_str(name); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 printf("\n"); >> +=C2=A0=C2=A0=C2=A0 } >> +=C2=A0=C2=A0=C2=A0 boot->free_pool(handle); >> + >> +=C2=A0=C2=A0=C2=A0 return 0; >> +} >> + > > Missing function description. > > Best regards > > Heinrich > >> +int dm_scan_other(bool pre_reloc_only) >> +{ >> +=C2=A0=C2=A0=C2=A0 if (gd->flags & GD_FLG_RELOC) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int ret; >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ret =3D setup_block(); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ret) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ret= urn ret; >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Not needed at present, b= ut could be useful one day? */ >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ret =3D setup_disks(); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ret) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ret= urn ret; >> +=C2=A0=C2=A0=C2=A0 } >> + >> +=C2=A0=C2=A0=C2=A0 return 0; >> +} >> + >> =C2=A0 /** >> =C2=A0=C2=A0 * efi_main() - Start an EFI image >> =C2=A0=C2=A0 * >> >