summaryrefslogtreecommitdiff
path: root/disk
AgeCommit message (Collapse)AuthorFilesLines
2024-08-08disk: don't try search for partition type if already setAlexey Romanov1-0/+7
Block devices can already set partition type at initialization stage, so, in this case is no point in searching for partition type. Signed-off-by: Alexey Romanov <avromanov@salutedevices.com> Reviewed-by: Heiko Schocher <hs@denx.de> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
2024-08-08disk: support MTD partitionsAlexey Romanov1-1/+2
Add new MTD partition driver, which can be useful with mtdblock driver combination. Signed-off-by: Alexey Romanov <avromanov@salutedevices.com> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
2024-07-15disk: Remove duplicate newlinesMarek Vasut6-13/+0
Drop all duplicate newlines. No functional change. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-07-05Fix Kconfig coding style from spaces to tabAnand Moon1-1/+1
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^ /\t/' -i */Kconfig Signed-off-by: Anand Moon <linux.amoon@gmail.com>
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"Tom Rini7-7/+2
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini7-2/+7
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-06part: Remove <common.h> and add needed includesTom Rini7-7/+2
Remove <common.h> from all "part/" files and when needed add missing include files directly. Signed-off-by: Tom Rini <trini@konsulko.com>
2024-04-12disk: simplify print_part_header()Heinrich Schuchardt1-44/+3
Using uclass_get_name() reduces the code size. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-04-12part: Check all partitions in part_get_info_by_name()Sam Protsenko1-2/+5
In part_get_info_by_name() the inability to get some partition info shouldn't be a reason for dropping out of the loop. That might happen e.g. if the partition is hidden or unused. An example of such case are Samsung devices, where they use the "unused" GUID type (00000000-0000-0000-0000-000000000000) to indicate that the partition should be hidden from the OS. Such partitions might not be seen in "part list" output, which creates "gaps" in numbering in between of the visible partitions: Part Start LBA End LBA Name 1 0x00000400 0x0000a3ff "efs" 5 0x00026420 0x00026c1f "dtbo" 12 0x0003f390 0x0074738f "super" In that case, the loop in part_get_info_by_name() would break after partition #1, so any attempt to obtain "dtbo" or "super" partition will fail. Fix that by continuing to iterate over the remaining partitions to make sure none of the visible ones is missed. That makes "part" command (e.g. "part start", "part size") able to work with such tables. Fixes: 87b8530fe244 ("disk: part: implement generic function part_get_info_by_name()") Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2023-12-21global: Drop common.h inclusionTom Rini1-1/+0
In order to make it easier to move on to dropping common.h from code directly, remove common.h inclusion from the rest of the header file which had been including it. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2023-10-24cmd: mbr: Allow 4 MBR partitions without need for extendedAlexander Gendin1-1/+1
Current code allows up to 3 MBR partitions without extended one. If more than 3 partitions are required, then extended partition(s) must be used. This commit allows up to 4 primary MBR partitions without the need for extended partition. Add mbr test unit. In order to run the test manually, mmc6.img file of size 12 MiB or greater is required in the same directory as u-boot. Test also runs automatically via ./test/py/test.py tool. Running mbr test is only supported in sandbox mode. Signed-off-by: Alex Gendin <agendin@matrox.com> [ And due to some further changes for testing ] Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-24rockchip: dm: prepare rkmtd UCLASSJohan Jonker1-0/+4
Prepare a rkmtd UCLASS in use for writing Rockchip boot blocks in combination with existing userspace tools and rockusb command. Signed-off-by: Johan Jonker <jbx6244@gmail.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-10disk: part: Handle blkmap device in print_part_header()Bin Meng1-0/+3
Print out the blkmap device type when showing partition header for a blkmap device. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-10disk: part: Print out the unknown device uclass idBin Meng1-1/+1
It's helpful to output the device uclass id for unknown devices during the debugging process. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-09-24common: Drop linux/printk.h from common headerSimon Glass1-0/+1
This old patch was marked as deferred. Bring it back to life, to continue towards the removal of common.h Move this out of the common header and include it only where needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-09-11part: rename disk_partition_type_uuid()Heinrich Schuchardt1-1/+1
Rename disk_partition_type_uuid to disk_partition_type_guid. Provide function descriptions for the getter and setter. Fixes: bcd645428c34 ("part: Add accessors for struct disk_partition type_uuid") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-25part: efi: Add debugging for the signature checkSimon Glass1-2/+11
Add a little more debugging for the initial signature check. Drop the pointless check for NULL. Also set a log category while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: Add accessors for struct disk_partition type_uuidSimon Glass2-10/+7
This field is only present when a CONFIG is set. To avoid annoying #ifdefs in the source code, add accessors. Update all code to use it. Note that the accessor is optional. It can be omitted if it is known that the option is enabled. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: Add accessors for struct disk_partition uuidSimon Glass3-30/+26
This field is only present when a CONFIG is set. To avoid annoying #ifdefs in the source code, add accessors. Update all code to use it. Note that the accessor is optional. It can be omitted if it is known that the option is enabled. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: Add comments for static functionsSimon Glass1-0/+32
Some internal functions could do with a few comments, to explain what they do. Add these, to make the code easier to follow. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: nac: Use desc instead of dev_descSimon Glass1-32/+27
The dev_ prefix is a hangover from the pre-driver model days. The device is now a different thing, with driver model. Update the mac code to just use 'desc'. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: iso: Use desc instead of dev_descSimon Glass1-26/+26
The dev_ prefix is a hangover from the pre-driver model days. The device is now a different thing, with driver model. Update the iso code to just use 'desc'. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: efi: Use desc instead of dev_descSimon Glass1-116/+112
The dev_ prefix is a hangover from the pre-driver model days. The device is now a different thing, with driver model. Update the efi code to just use 'desc'. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: dos: Use desc instead of dev_descSimon Glass1-32/+31
The dev_ prefix is a hangover from the pre-driver model days. The device is now a different thing, with driver model. Update the dos code to just use 'desc'. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: amiga: Use desc instead of dev_descSimon Glass1-17/+17
The dev_ prefix is a hangover from the pre-driver model days. The device is now a different thing, with driver model. Update the amiga code to just use 'desc'. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: Use desc instead of dev_descSimon Glass1-92/+86
The dev_ prefix is a hangover from the pre-driver model days. The device is now a different thing, with driver model. Update the partition code to just use 'desc', as is done with driver model. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-22disk: dos: Infer MBR partition sector size from underlying drive sector sizeMarek Vasut1-3/+14
Block devices with 4k sectors imply the MBR sectors are also 4k instead of regular 512B. Avoid hard-coding the 512B sector size and isntead read the current block device sector size from it, and if the sector size is larger than 512B, use the block device sector size. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-22disk: Move part_create_block_devices() to blk uclassMarek Vasut1-48/+0
Move part_create_block_devices() to blk uclass and unexpose the function. This can now be internal to the block uclass. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-08-22disk: Switch part_blk_*() functions to disk_blk_*()Marek Vasut1-81/+12
The behavior of the part_blk_*() functions is now identical to disk_blk_*() functions, switch the former to the later. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-08-22disk: Extend disk_blk_part_validate() with range checkingMarek Vasut1-0/+8
Check whether access is out of bounds of the partition and return an error. This way there is no danger of esp. write or erase outside of the confines of partition. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-08-22disk: Handle partition to block device offset conversionMarek Vasut1-16/+52
Convert the read/write/erase offset from one within a partition to one within a block device, to correctly access the data on the block device for both write and erase operations. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-08-22disk: Simplify disk_blk_{write, erase}() using blk_{write, erase}()Marek Vasut1-43/+23
These two functions are basically identical, just call the blk_*() functions from disk_blk_*() functions. The only difference is that the disk_blk_*() functions have to use parent block device as the udevice implementing block device operations. Add documentation on what those functions really do. The documentation is not wrong even though it likely does look that way. The write/erase functions really do not take into account the partition offset. This will be fixed in the next patch. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-08-22disk: Simplify disk_blk_read() using blk_read()Marek Vasut1-24/+14
The disk_blk_read() can be simplified using blk_read(), the only things which needs to be handled are the read offset based on the partition properties, and the block device ops which are coming from the parent udevice, not the partition udevice. The later is currently not implemented correctly as far as I can tell, since the current code extracts block device descriptor from the parent udevice which is OK, but extracts block device operations from the partition udevice, which does not seem OK. Switching to the blk_read() fixes that too. The dev_get_blk() usage is simplified using UCLASS_PARTITION check. Add non-confusing documentation what this really does. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-08-22disk: Drop always true conditional checkMarek Vasut1-4/+2
if (device_get_uclass_id(dev) == UCLASS_PARTITION) is always true, because this disk_blk_read() function calls dev_get_blk() above and checks its return value for non-NULL. The dev_get_blk() performs the same device_get_uclass_id(dev) check and returns NULL if not UCLASS_PARTITION. Drop the duplicate check. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-07-30part: check CONFIG_IS_ENABLED(ENV_SUPPORT)Heinrich Schuchardt1-3/+5
In SPL environment variables may not be enabled. Suggested-by: Tom Rini <trini@konsulko.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-07-25part: eliminate part_get_info_by_name_type()Heinrich Schuchardt1-8/+2
Since commit 56670d6fb83f ("disk: part: use common api to lookup part driver") part_get_info_by_name_type() ignores the part_type parameter used to restrict the partition table type. omap_mmc_get_part_size() and part_get_info_by_name() are the only consumers. omap_mmc_get_part_size() calls with part_type = PART_TYPE_EFI because at the time of implementation a speed up could be gained by passing the partition table type. After 5 years experience without this restriction it looks safe to keep it that way. part_get_info_by_name() uses PART_TYPE_ALL. Move the logic of part_get_info_by_name_type() to part_get_info_by_name() and replace the function in omap_mmc_get_part_size(). Fixes: 56670d6fb83f ("disk: part: use common api to lookup part driver") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-17disk: part: Add API to get partitions with specific driverJoshua Watt1-7/+31
Adds part_driver_get_type() API which can be used to force a specific driver to be used when getting partition information instead of relying on auto detection. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-17disk: Use BOOT_DEFAULTS instead of DISTRO_DEFAULTSJonas Karlman1-4/+4
Set default y based on common BOOT_DEFAULTS instead of DISTRO_DEFAULTS. No change is intended, affected options is already implied for DISTRO and BOOTSTD due to BOOT_DEFAULTS imply DOS_PARTITION (USB_STORAGE), EFI_PARTITION and ISO_PARTITION. Fixes: a0c739c184ca ("boot: Create a common BOOT_DEFAULTS for distro and bootstd") Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-17part: Allow setting the partition-table typeSimon Glass1-0/+16
Some devices have multiple partition types available on the same media. It is sometimes useful to see these to check that everything is working correctly. Provide a way to manually set the partition-table type, avoiding the auto-detection process. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-04-05cmd: blkmap: Add blkmap commandTobias Waldekranz1-0/+1
Add a frontend for the blkmap subsystem. In addition to the common block device operations, this allows users to create and destroy devices, and map in memory and slices of other block devices. With that we support two primary use-cases: - Being able to "distro boot" from a RAM disk. I.e., from an image where the kernel is stored in /boot of some filesystem supported by U-Boot. - Accessing filesystems not located on exact partition boundaries, e.g. when a filesystem image is wrapped in an FIT image and stored in a disk partition. Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-03Revert "disk: Use a helper function to reduce duplication"Tom Rini1-25/+21
Per Takahiro Akashi this is not an equivalent rework, so revert it. This reverts commit d87bdb82eae66512c222fd93280acaf4dd1cd4be. Signed-off-by: Tom Rini <trini@konsulko.com>
2023-03-30disk: Use a helper function to reduce duplicationSimon Glass1-21/+25
Reduce the duplicated code slightly by using a helper function to handle the common code. This reduces the code size very slightly. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-02lib: Add an SPL config for LIB_UUIDSimon Glass1-0/+8
This is selected by PARTITION_UUIDS which has a separate option for SPL. Add an SPL option for LIB_UUID also, so that we can keep them consistent. Also add one for PARTITION_TYPE_GUID to avoid a build error in part_efi.c which wants to call a uuid function in SPL. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-10Correct SPL use of PARTITION_TYPE_GUIDSimon Glass1-1/+1
This converts 1 usage of this option to the non-SPL form, since there is no SPL_PARTITION_TYPE_GUID defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-09Correct SPL use of CMD_MBRSimon Glass1-1/+1
This converts 1 usage of this option to the non-SPL form, since there is no SPL_CMD_MBR defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23part: Add a function to find the first bootable partitionSimon Glass1-0/+16
If a disk has a bootable partition we are expected to use it to locate the boot files. Add a function to find it. To test this, update mmc1 to have two paritions, fixing up other tests accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-12-02disk: fix blk_get_device_part_str()Heinrich Schuchardt1-18/+5
blk_get_device_part_str() should always initialize all info fields including sys_ind. As a side effect the code is simplified. Replace '(0 ==' by '(!' to conform with Linux coding style. Fixes: 4d907025d6a5 ("sandbox: restore ability to access host fs through standard commands") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Heiko Schocher <hs@denx.de>
2022-11-07dm: sandbox: Switch over to using the new host uclassSimon Glass1-2/+2
Update the sandbox implementation to use UCLASS_HOST and adjust all the pieces to continue to work: - Update the 'host' command to use the new API - Replace various uses of UCLASS_ROOT with UCLASS_HOST - Disable test_eficonfig since it doesn't work (this should have a unit test to allow this to be debugged) - Update the blk test to use the new API - Drop the old header file Unfortunately it does not seem to be possible to split this change up further. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31disk: Rename block_dev to descSimon Glass1-19/+19
The use of 'block_dev' in this context is confusing, since it is not a pointer to a device, just to some information about it. Rename this to 'desc', as is more commonly used, since it is a block descriptor. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Heinrich Schuchardt <xypron.glplk@gmx.de>
2022-10-31disk: Rename block functionsSimon Glass1-12/+12
Use the uclass type as the first part of the function name, to be consistent with the methods in other block drivers. Signed-off-by: Simon Glass <sjg@chromium.org>