summaryrefslogtreecommitdiffstats
path: root/drivers/block/efi-block-io.c
Commit message (Collapse)AuthorAgeFilesLines
* efi: block: move definitions into header fileAhmad Fatoum2024-03-051-27/+0
| | | | | | | | | We will need these definitions for the EFI loader as well, so move them into a header. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-68-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* block: record block device typeAhmad Fatoum2024-03-051-0/+1
| | | | | | | | | | Software running under EFI can query the type of a block device. For barebox to be able to report this, start assigning types to all block devices it can create. No functional change yet. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-24-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* block: parse partition table on block device registrationAhmad Fatoum2023-06-121-9/+1
| | | | | | | | | | | | | | | Every instance of block device registration is followed by an attempt to parse the partition table. Thus move partition table parsing into blockdevice_register. We do away with the warning print as it's superfluous: parse_partition_table doesn't return an error if partition table is missing and all other errors already result in an error message. Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230607120714.3083182-13-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* efi: don't skip default efi devinfo for old EFI block revisionsAhmad Fatoum2023-05-221-2/+3
| | | | | | | | | | We early exit to skip info that doesn't apply to older EFI block protocol revisions. This also means we skip the default efi devinfo callback, which may not want. Fix this. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20230522053725.1043129-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-101-4/+4
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/efi'Sascha Hauer2022-08-111-1/+2
|\
| * block: efi: allow disabling /dev/usbdiskX renamingAhmad Fatoum2022-07-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some buggy UEFI implementations have been observed to not set EFI_USB_IO protocol on handles that were instantiated from USB mass storage. This leads to confusing behavior when barebox uses /dev/usbdisk for some USB sticks and doesn't for some others. The proper behavior is not relying on the UEFI and instead check e.g. GUID of the boot disk image: if [ "$bootsource" = usb ]; then mydisk = /dev/usbdisk${bootsource_instance} else mydisk = /dev/disk${bootsource_instance} fi devlookup -v bootdiskguid $mydisk guid if [ "$bootdiskguid" = "my-guid" ]; then boot ${mydisk}.1 else boot boochooser fi When going that way, the renaming to usbdisk is just annoying, so allow disabling it to simplify scripting. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220630124035.4019644-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootsource: rename existing bootsource_set to bootsource_set_rawAhmad Fatoum2022-08-091-1/+1
|/ | | | | | | | | | | | | | | | | Patterns like [ "$bootsource" = mmc ] && boot mmc$bootsource_instance expect that ${bootsource_instance} and MMC aliases align, which may not always be the case. In preparation for adding a new bootsource_set function that consults an optional mapping table from bootrom bootsource_instance to board-specific device numbering, rename all existing instances to bootsource_set_raw. While at it, clean up the legacy split into bootsource_set and bootsource_set_instance and have the new bootsource_set_raw accept both arguments at once. No functional change intended. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220720055042.3510276-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* block: efi-block-io: add devinfo callback for media infoAhmad Fatoum2022-01-201-15/+27
| | | | | | | | | | | | There's some useful info in efi_block_io_media that's only compiled in at debug log level. While we need not print it always, it would be nice to have this printed when doing devinfo. Add a custom devinfo callback that does so and that invokes the normal EFI devinfo afterwards. Defining DEBUG in the file will still print it early in probe as before. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2021-12-151-1/+1
|\
| * drivers: migrate "GPL-2.0" license identifiers to SPDX 2.0Roland Hieber2021-11-221-1/+1
| | | | | | | | | | | | | | | | | | | | "GPL-2.0-only" was introduced in SPDX 2.0, and the old identifier "GPL-2.0" is now considered deprecated; see <https://spdx.org/licenses>. Fixes: 28f4a6a4df76f0f1581d (2021-10-30, "drivers: add missing SPDX-License-Identifier") Signed-off-by: Roland Hieber <rhi@pengutronix.de> Link: https://lore.barebox.org/20211117113851.2022669-2-rhi@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: rename <efi/efi.h> to <efi/efi-payload.h>Ahmad Fatoum2021-11-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | The split between <efi.h> and <efi/efi.h> is confusing: The former contains universal definitions, while the latter contains barebox utilities on top. To make the distinction clear, rename <efi/efi.h> to <efi/efi-payload.h> as it's used for EFI payloads. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211122084732.2597109-14-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | block : efi: rename driver variable from efi_fs_driver to efi_bio_driverAhmad Fatoum2021-11-251-2/+2
|/ | | | | | | | | Rename the copy-pasted second efi_fs_driver to a more fitting efi_bio_driver. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211122084732.2597109-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: add missing SPDX-License-IdentifierAhmad Fatoum2021-11-011-0/+1
| | | | | | | | | | | | | | | | | | | | This adds the suitable SPDX-License-Identifier to all files in drivers/ that previously lacked one. To aid manual inspection, following heuristics can be used: * No changes outside of comments/whitespace: git show -U0 HEAD | rg -v '^(@@|diff|index)|[-+]([-+]|//|#|[\s/]\*)' * -or-later come in pairs: git show --inter-hunk-context=19 HEAD | \ perl -0777 -F'/^@/gm' -ne 'for (@F) { @m = /later/g; print if @m & 1 }' Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175632.2276077-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* block: use 64-bit types for sector offset and count on all platformsAhmad Fatoum2021-02-181-4/+4
| | | | | | | | | | | barebox' use of int for the sector offset puts an upper bound of 1TB on the size of supported block devices, which is already exceeded by common place USB mass storage. Increasing the sizes involved to 64 bit like Linux does won't magically add missing driver support, but it gives us at least a fighting chance. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* efi: add and use new efi_device_has_guid helperAhmad Fatoum2019-12-091-9/+2
| | | | | | | | | | We have at least two places where we check if a efidev has a particular guid and a follow-up commit will introduce a third place. So lets factor it out into a helper. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* efi: populate boot source instanceAhmad Fatoum2019-10-281-4/+13
| | | | | | | | | | | We already determine the boot source variable at core init level, but so far we didn't populate the instance because the numbering of the block devices isn't known that early. Introduce a helper to check if a block device is the boot source and if it is, have the block device driver populate the missing boot source instance. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* efi: cleanupsOleksij Rempel2019-02-181-1/+1
| | | | | | | make local functions static and remove unused code Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* efi-block: detect when the block device is a USB DiskJean-Christophe PLAGNIOL-VILLARD2017-10-271-1/+16
| | | | | | | | | | use usbdisk as a basename This will be usefull as example when we want to search for a usb disk for failsafe update or install. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* efi: move bus driver to driver/efiJean-Christophe PLAGNIOL-VILLARD2017-02-241-2/+2
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* efi: move block io driver to driver/blockJean-Christophe PLAGNIOL-VILLARD2017-02-241-0/+174
so it can be reused on any ARCH Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>