summaryrefslogtreecommitdiff
path: root/disk
Commit message (Collapse)AuthorAgeFilesLines
* blk: Rename if_type to uclass_idSimon Glass2022-09-252-11/+11
| | | | | | Use the word 'uclass' instead of 'if_type' to complete the conversion. Signed-off-by: Simon Glass <sjg@chromium.org>
* Merge branch 'master' into nextTom Rini2022-09-191-1/+1
|\ | | | | | | Signed-off-by: Tom Rini <trini@konsulko.com>
| * disk: part: remove dependency to ubifs for splStefan Herbrechtsmeier2022-08-261-1/+1
| | | | | | | | | | | | | | The spl doesn't support ubifs and thereby doesn't provide the ubifs_is_mounted function. Remove the dependency to ubifs for the spl. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
* | disk: Handle UCLASS_EFI_MEDIA in dev_print()Simon Glass2022-09-161-1/+4
| | | | | | | | | | | | | | | | | | This is currently missing. Add it. Fix the code style for the function while we are here. Suggested-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Simon Glass <sjg@chromium.org>
* | blk: Switch over to using uclass IDsSimon Glass2022-09-161-26/+26
| | | | | | | | | | | | | | | | | | | | | | | | We currently have an if_type (interface type) and a uclass id. These are closely related and we don't need to have both. Drop the if_type values and use the uclass ones instead. Maintain the existing, subtle, one-way conversion between UCLASS_USB and UCLASS_MASS_STORAGE for now, and add a comment. Signed-off-by: Simon Glass <sjg@chromium.org>
* | blk: Drop IF_TYPE_SDSimon Glass2022-09-161-2/+0
| | | | | | | | | | | | This is not really needed since it does the same things as MMC. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* | blk: Drop IF_TYPE_ATAPISimon Glass2022-09-161-5/+0
| | | | | | | | | | | | This is not really needed since it does the same things as IDE. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* | blk: Drop IF_TYPE_DOCSimon Glass2022-09-161-9/+0
| | | | | | | | | | | | | | | | | | This doesn't seem to be used for anything and it isn't clear what it is. It dates from the first U-Boot commit. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* | blk: Rename HAVE_BLOCK_DEVICESimon Glass2022-09-162-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This option is fact really related to SPL. For U-Boot proper we always use driver model for block devices, so CONFIG_BLK is enabled if block devices are in use. It is only for SPL that we have two cases: - SPL_BLK is enabled, in which case we use driver model and blk-uclass.c - SPL_BLK is not enabled, in which case (if we need block devices) we must use blk_legacy.c Rename the symbol to SPL_LEGACY_BLOCK to make this clear. This is different enough from BLK and SPL_BLK that there should be no confusion. Signed-off-by: Simon Glass <sjg@chromium.org>
* | blk: Use a function for whether block devices are availableSimon Glass2022-09-161-47/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At present we use HAVE_BLOCK_DEVICE to indicate when block devices are available. This is a very strange option, since it partially duplicates the BLK option used by driver model. It also covers both U-Boot proper and SPL, even though one might have block devices and another not. As a first step towards correcting this, create a new inline function called blk_enabled() which indicates if block devices are available. This cannot be used in Makefiles, or #if clauses, but can be used in C code. A function is useful because we cannot use CONFIG_IS_ENABLED(BLK) to decide if block devices are needed, since we must consider the legacy block interface, enabled by HAVE_BLOCK_DEVICE Update a few places where it can be used and drop some unnecessary #if checks around some functions in disk/part.c - rely on the compiler's dead-code elimination instead. Signed-off-by: Simon Glass <sjg@chromium.org>
* | disk: Use Makefile to omit partition driversSimon Glass2022-09-166-17/+4
| | | | | | | | | | | | | | | | | | | | | | At present these files have an #ifdef covering the whole file. Move the condition to the Makefile instead. Add BLK to the condition since future patches will adjust things so that HAVE_BLOCK_DEVICE is only for SPL, but the partition drivers are needed in U-Boot proper too. Signed-off-by: Simon Glass <sjg@chromium.org>
* | disk: Correct help for TPL_PARTITIONSSimon Glass2022-09-161-4/+4
|/ | | | | | | Fix a few typos in this help text. Fix a typo in SPL_PARTITIONS while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
* arch: mvebu: Disable by default unused peripherals in SPLPali Rohár2022-07-211-0/+2
| | | | | | | | | | | | | SPL on mvebu loads proper U-Boot from custom Marvell kwbimage format and therefore support for other binary formats is not required to be present in SPL. Boot source of proper U-Boot is defined by compile time options and therefore it is not required to enable all possible and unused peripherals in SPL by default. This change decrease size of SPL binaries. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de>
* disk: honor CONFIG_SYS_64BIT_LBAHeinrich Schuchardt2022-07-021-0/+1
| | | | | | | | | | | | | | Without the patch for qemu-x86_defconfig: * sizeof(lbaint_t) = 4 in dev_read() * sizeof(lbaint_t) = 8 in blkcache_read() CONFIG_SYS_64BIT_LBA is defined in common.h via include/configs/x86-common.h:22. We have to include common.h before including blk.h. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* disk: incorrect message in is_gpt_valid()Heinrich Schuchardt2022-05-281-3/+1
| | | | | | | alloc_read_gpt_entries() writes differentiated error messages. The caller is_gpt_valid() should not write an extra possibly wrong message. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* disk: part_efi: add support to repair gpt tablePhilippe Reynes2022-05-061-0/+86
| | | | | | | | | | If a gpt table is corrupted (after a power cut for example), then the gpt table should repaired. The function gpt_repair_headers check if at least one gpt table is valid, and then only write the corrupted gpt table. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
* dm: disk: add read/write interfaces with udeviceAKASHI Takahiro2022-04-231-0/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | In include/blk.h, Simon suggested: ===> /* * These functions should take struct udevice instead of struct blk_desc, * but this is convenient for migration to driver model. Add a 'd' prefix * to the function operations, so that blk_read(), etc. can be reserved for * functions with the correct arguments. */ unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, void *buffer); unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, const void *buffer); unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt); <=== So new interfaces are provided with this patch. They are expected to be used everywhere in U-Boot at the end. The exceptions are block device drivers, partition drivers and efi_disk which should know details of blk_desc structure. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* dm: disk: add UCLASS_PARTITIONAKASHI Takahiro2022-04-232-0/+156
| | | | | | | | | | NOTE: probably we have to update config dependencies, in particular, SPL/TPL_PRINTF? With this new function, UCLASS_PARTITION devices will be created as child nodes of UCLASS_BLK device. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* disk: don't compile in partition support for spl/tpl if not really necessaryAKASHI Takahiro2022-04-231-18/+19
| | | | | | | | | | | Under the current Kconfigs, disk/part.c will be compiled in even if none of partition table types are enabled. This will lead to the size growth of SPL /TPL code. With this patch, CONFIG_PARTITIONS is selected only if, at least, one of CONFIG_*_PARTITION is enabled. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* disk: part: add the device search failed log msgOleksii Bidnichenko2022-04-121-0/+2
| | | | | | | Add missing error message to blk_get_device_part_str. Signed-off-by: Oleksii Bidnichenko <oleksii.bidnichenko@toradex.com> Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
* disk: Correct the conditions for SPLSimon Glass2022-04-061-5/+5
| | | | | | | These filesystems may have different settings for SPL and TPL. Use the correct Makefile variable to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
* fs: Add semihosting filesystemSean Anderson2022-04-011-2/+2
| | | | | | | | | | | This adds a filesystem which is backed by the host's filesystem. It is modeled off of sandboxfs, which has very similar aims. Semihosting doesn't support listing directories (except with SYS_SYSTEM), so neither do we. it's possible to optimize a bit for the common case of reading a whole file by omitting a call to smh_seek, but this is left as a future optimization. Signed-off-by: Sean Anderson <sean.anderson@seco.com>
* disk: Add an option for partitions in SPLSimon Glass2022-03-252-5/+21
| | | | | | | In some cases we do not want to enable partition support in SPL. Add an option to allow this. Signed-off-by: Simon Glass <sjg@chromium.org>
* Merge tag 'efi-2022-04-rc1-2' of ↵Tom Rini2022-01-221-13/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://source.denx.de/u-boot/custodians/u-boot-efi Pull request for efi-2022-04-rc1-2 Documentation: * describe printf() format codes UEFI * enable more algorithms for UEFI image verification, e.g. SHA256-RSA2048 General * simplify printing short texts for GUIDs * provide a unit test for printing GUIDs
| * disk: simplify part_print_efi()Heinrich Schuchardt2022-01-191-13/+8
| | | | | | | | | | | | | | Use printf code %pUs to print the text representation of the partition type GUID. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* | doc: replace @return by Return:Heinrich Schuchardt2022-01-192-2/+2
|/ | | | | | | | | | | | Sphinx expects Return: and not @return to indicate a return value. find . -name '*.c' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; find . -name '*.h' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* disk: gpt: print all partitionsHeinrich Schuchardt2022-01-151-2/+2
| | | | | | | | | | | | | | For GPT partition tables the 'part list' command stops at the first invalid partition number. But Ubuntu has images with partitions number 1, 12, 13, 14, 15 In this case only partition 1 was listed by 'part list'. Fixes: 38a3021edc54 ("disk: part_efi: remove indent level from loop") Reported-by: Alexandre Ghiti <alexandre.ghiti@canonical.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Tested-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
* Merge tag 'v2022.01-rc4' into nextTom Rini2021-12-201-2/+6
|\ | | | | | | Prepare v2022.01-rc4
| * part: call part_init() in blk_get_device_by_str() only for MMCAKASHI Takahiro2021-12-181-1/+2
| | | | | | | | | | | | | | | | | | | | In blk_get_device_by_str(), the comment says: "Updates the partition table for the specified hw partition." Since hw partition is supported only on MMC, it makes no sense to do so for other devices. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
| * efi: Add uclass for devices provided by UEFI firmwareSimon Glass2021-12-091-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | UCLASS_EFI_LOADER is used for devices created by applications and drivers loaded by U-Boots UEFI implementation. This patch provides a new uclass (UCLASS_EFI_MEDIA) to be used for devices that provided by a UEFI firmware calling U-Boot as an EFI application. If the two uclasses can be unified, is left to future redesign. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* | Merge tag 'v2022.01-rc3' into nextTom Rini2021-11-291-0/+7
|\ \ | |/ | | | | | | | | Prepare v2022.01-rc3 Signed-off-by: Tom Rini <trini@konsulko.com>
| * part: return -ENOSYS when get_info not valid.schspa2021-11-181-0/+7
| | | | | | | | | | | | | | | | In some case, get_info() interface can be NULL, add this check to stop from crash. Signed-off-by: schspa <schspa@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | disk: part_dos: Fix a NULL pointer errorSimon Glass2021-11-281-4/+6
|/ | | | | | | | When ext is NULL we cannot dereference it. Update the code flow to avoid this, so that layout_mbr_partitions() can be used with partition tables that do not include an extended partition. Signed-off-by: Simon Glass <sjg@chromium.org>
* WS cleanup: remove SPACE(s) followed by TABWIP/2021-09-30-whitespace-cleanupsWolfgang Denk2021-09-301-1/+1
| | | | Signed-off-by: Wolfgang Denk <wd@denx.de>
* treewide: fdt: Move fdt_get_config_... to ofnode_conf_read...Simon Glass2021-09-251-5/+3
| | | | | | | | | | | | The current API is outdated as it requires a devicetree pointer. Move these functions to use the ofnode API and update this globally. Add some tests while we are here. Correct the call in exynos_dsim_config_parse_dt() which is obviously wrong. Signed-off-by: Simon Glass <sjg@chromium.org>
* cmd/part: correct alignment of partition listHeinrich Schuchardt2021-09-021-1/+1
| | | | | | | | | | | | | When running 'part list' for an ISO partition the numbers are not under the labels. Correct the alignment of the ISO partition list. With the patch the output looks like: Part Start Sect x Size Type 1 3720 5024 512 U-Boot Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* global: Convert simple_strtoul() with decimal to dectoul()Simon Glass2021-08-021-2/+2
| | | | | | | It is a pain to have to specify the value 10 in each call. Add a new dectoul() function and update the code to use it. Signed-off-by: Simon Glass <sjg@chromium.org>
* global: Convert simple_strtoul() with hex to hextoul()Simon Glass2021-08-021-3/+3
| | | | | | | | | It is a pain to have to specify the value 16 in each call. Add a new hextoul() function and update the code to use it. Add a proper comment to simple_strtoul() while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
* disk: Tidy up #ifdefs in part_efiSimon Glass2021-07-281-5/+6
| | | | | | | | | | | | | This file does not correctly handle the various cases, sometimes producing warnings about partition_basic_data_guid being defined but not used. Fix it. There was some discussion about adjusting Kconfig or making HAVE_BLOCK_DEVICE a prerequisite for PARTITIONS, but apparently this is not feasible. Such changes can be undertaken separate from the goal of this series. Signed-off-by: Simon Glass <sjg@chromium.org>
* disk/part_dos.c: Fix a variable typo in write_mbr_partitions()Christian Melki2021-06-221-1/+1
| | | | | | | | This function is passed *dev not *dev_desc, so pass the right name to part_init(). Fixes: f14c5ee5ab8b ("disk: part_dos: update partition table entries after write") Signed-off-by: Christian Melki <christian.melki@t2data.com>
* part: Add check for NULL dev_part_strSean Anderson2021-05-261-1/+5
| | | | | | | | | | | | | | | Some callers (e.g. cmd/fs.c) of fs_set_blk_dev may use a NULL dev_part_str. While blk_get_device_part_str handles this fine, part_get_info_by_dev_and_name does not. This fixes commands crashing when implicitly using bootdevice. The unit test has also been updated to set bootdevice to a known value and to restore it after we are done. Fixes: 7194527b6a ("cmd: fs: Use part_get_info_by_dev_and_name_or_num to parse partitions") Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* part: Fix bogus return from part_get_info_by_dev_and_nameSean Anderson2021-04-221-1/+1
| | | | | | | | blk_get_device_by_str returns the device number on success. So we must check if the return was negative to determine an error. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* disk: gpt: verify alternate LBA points to last usable LBAStefan Herbrechtsmeier2021-04-121-0/+9
| | | | | | | | | The gpt command require the GPT backup header at the standard location at the end of the device. Check the alternate LBA value before reading the GPT backup header from the last usable LBA of the device. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* part: Support string block devices in part_get_info_by_dev_and_nameSean Anderson2021-02-261-19/+22
| | | | | | | | This adds support for things like "#partname" and "0.1#partname". The block device parsing is done like in blk_get_device_part_str. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* part: Support getting whole disk from part_get_info_by_dev_and_name_or_numSean Anderson2021-02-261-2/+3
| | | | | | | | This adds an option to part_get_info_by_dev_and_name_or_num to allow callers to specify whether whole-disk partitions are fine. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* part: Give several functions more useful return valuesSean Anderson2021-02-261-22/+28
| | | | | | | | | Several functions in disk/part.c just return -1 on error. This makes them return different errnos for different failures. This helps callers differentiate between failures, even if they cannot read stdout. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* common: Drop asm/global_data.h from common headerWIP/2021-02-02-drop-asm_global_data-when-unusedSimon Glass2021-02-021-0/+1
| | | | | | | | | | | | Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
* disk: part_dos: update partition table entries after writeGary Bisson2021-02-011-0/+6
| | | | | | | Fixes issues when switching from GPT to MBR partition tables. Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
* Merge tag 'dm-pull-30jan21' of ↵Tom Rini2021-01-311-0/+1
|\ | | | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-dm tpm fixes for coral binman fixes support for symbols in sub-sections support for additional cros_ec commands various minor fixes / tweaks
| * disk: part: sandbox support in dev_print()Heinrich Schuchardt2021-01-301-0/+1
| | | | | | | | | | | | | | | | Commands like 'fatinfo' call dev_print() to print device information. If the block device is created via 'host bind', we should print accurate information. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>