summaryrefslogtreecommitdiff
path: root/include/part.h
Commit message (Collapse)AuthorAgeLines
* disk: part: refactor generic name creation for DOS and ISOPetr Kulhavy2016-10-01-0/+14
| | | | | | | | | | | | | In both DOS and ISO partition tables the same code to create partition name like "hda1" was repeated. Code moved to into a new function part_set_generic_name() in part.c and optimized. Added recognition of MMC and SD types, name is like "mmcsda1". Signed-off-by: Petr Kulhavy <brain@jikos.cz> Reviewed-by: Tom Rini <trini@konsulko.com> Acked-by: Steve Rae <steve.rae@raedomain.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* fastboot: add support for writing MBRPetr Kulhavy2016-10-01-0/+23
| | | | | | | | | | | | Add special target "mbr" (otherwise configurable via CONFIG_FASTBOOT_MBR_NAME) to write MBR partition table. Partitions are now searched using the generic function which finds any partiiton by name. For MBR the partition names hda1, sda1, etc. are used. Signed-off-by: Petr Kulhavy <brain@jikos.cz> Reviewed-by: Tom Rini <trini@konsulko.com> Acked-by: Steve Rae <steve.rae@raedomain.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* disk: part: implement generic function part_get_info_by_name()Petr Kulhavy2016-10-01-12/+20
| | | | | | | | | | | | | | | | | So far partition search by name has been supported only on the EFI partition table. This patch extends the search to all partition tables. Rename part_get_info_efi_by_name() to part_get_info_by_name(), move it from part_efi.c into part.c and make it a generic function which traverses all part drivers and searches all partitions (in the order given by the linked list). For this a new variable struct part_driver.max_entries is added, which limits the number of partitions searched. For EFI this was GPT_ENTRY_NUMBERS. Similarly the limit is defined for DOS, ISO, MAC and AMIGA partition tables. Signed-off-by: Petr Kulhavy <brain@jikos.cz> Reviewed-by: Tom Rini <trini@konsulko.com> Acked-by: Steve Rae <steve.rae@raedomain.com>
* dm: mmc: Add support for driver-model block devicesSimon Glass2016-05-17-18/+0
| | | | | | | Add support for enabling CONFIG_BLK with MMC. This involves changing a few functions to use struct udevice and adding a MMC block device driver. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: part: Drop the get_dev() methodSimon Glass2016-05-17-1/+0
| | | | | | | This is now handled by the legacy block driver. The get_dev() method is no-longer used. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: sandbox: Drop the host_get_dev() functionSimon Glass2016-05-17-2/+0
| | | | | | This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: systemace: Drop the get_dev() functionSimon Glass2016-05-17-2/+0
| | | | | | This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: sata: Drop the get_dev() functionSimon Glass2016-05-17-2/+0
| | | | | | | | | This function is implemented by the legacy block functions now. Drop it. We cannot yet make sata_dev_desc[] private to common/sata.c as it is used by the SATA drivers. This will require the SATA interface to be reworked. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: scsi: Drop the get_dev() functionSimon Glass2016-05-17-2/+0
| | | | | | This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: mmc: Drop the get_dev() functionSimon Glass2016-05-17-2/+0
| | | | | | This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: ide: Drop the get_dev() functionSimon Glass2016-05-17-2/+0
| | | | | | This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: usb: Drop the get_dev() functionSimon Glass2016-05-17-2/+0
| | | | | | This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* disk: part: Enable get_info pointer for CONFIG_SPL_FAT_SUPPORTMichal Simek2016-04-11-1/+1
| | | | | | | | | | | | | | The patch "dm: part: Convert partition API use to linker lists" (sha1: 96e5b03c8ab749b6547f6a3ceb4d4b9f274211aa) is adding new dependency for enabling SPL_EXT_SUPPORT to be able to get information about DOS partition. get_info is also required for FAT support only which is used on Xilinx Zynq boards. Reported-by: Nathan Rossi <nathan@nathanrossi.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* disk/part.c: Expose list of available block driversAlexander Graf2016-03-15-0/+7
| | | | | | | | | | | | | | We have a pretty nice and generic interface to ask for a specific block device. However, that one is still based around the magic notion that we know the driver name. In order to be able to write fully generic disk access code, expose the currently internal list to other source files so that they can scan through all available block drivers. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
* dm: part: Rename some partition functionsSimon Glass2016-03-14-11/+10
| | | | | | | | Rename three partition functions so that they start with part_. This makes it clear what they relate to. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com>
* dm: part: Convert partition API use to linker listsSimon Glass2016-03-14-31/+48
| | | | | | | | | | | | | | | | | | | We can use linker lists instead of explicitly declaring each function. This makes the code shorter by avoiding switch() statements and lots of header file declarations. While this does clean up the code it introduces a few code issues with SPL. SPL never needs to print partition information since this all happens from commands. SPL mostly doesn't need to obtain information about a partition either, except in a few cases. Add these cases so that the code will be dropped from each partition driver when not needed. This avoids code bloat. I think this is still a win, since it is not a bad thing to be explicit about which features are used in SPL. But others may like to weigh in. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com> Tested-by: Stephen Warren <swarren@nvidia.com>
* dm: blk: Rename get_device_and_partition()Simon Glass2016-03-14-4/+38
| | | | | | | | | | Rename this function to blk_get_device_part_str(). This is a better name because it makes it clear that the function returns a block device and parses a string. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
* dm: blk: Rename get_device() to blk_get_device_by_str()Simon Glass2016-03-14-4/+30
| | | | | | | | | | The current name is too generic. The function returns a block device based on a provided string. Rename it to aid searching and make its purpose clearer. Also add a few comments. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
* dm: blk: Rename get_dev() to blk_get_dev()Simon Glass2016-03-14-3/+3
| | | | | | | | | The current name is too generic. Add a 'blk_' prefix to aid searching and make its purpose clearer. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
* dm: blk: Add comments to a few functionsSimon Glass2016-03-14-0/+30
| | | | | | | | | The block interface is not well documented in the code. Pick two important functions and add comments. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
* dm: Add a new header for block devicesSimon Glass2016-03-14-48/+1
| | | | | | | | | | | At present block devices are tied up with partitions. But not all block devices have partitions within them. They are in fact separate concepts. Create a separate blk.h header file for block devices. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
* dm: part: Drop the common.h headerSimon Glass2016-03-14-1/+0
| | | | | | | | | We should not include <common.h> in header files. Each C file should include it if needed. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
* dm: Drop the block_dev_desc_t typedefSimon Glass2016-03-14-62/+68
| | | | | | | | | Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long and causes 80-column violations, rename it to struct blk_desc. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
* part: Drop duplication declaration of block_dev_desc_tSimon Glass2016-01-25-2/+0
| | | | | | | | | | This is already defined in ide.h, which part.h includes. So we don't need the duplicate typedef. At least with my old blackfin gcc 4.3.5 tool chain, this causes an error. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Andreas Bießmann <andreas.devel@googlemail.com>
* mmc: store hwpart in the block deviceStephen Warren2016-01-13-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will allow us to have multiple block device structs each referring to the same eMMC device, yet different HW partitions. For now, there is still a single block device per eMMC device. As before, this block device always accesses whichever HW partition was most recently selected. Clients wishing to make use of multiple block devices referring to different HW partitions can simply take a copy of this block device once it points at the correct HW partition, and use each one as they wish. This feature will be used by the next patch. In the future, perhaps get_device() could be enhanced to return a dynamically allocated block device struct, to avoid the client needing to copy it in order to maintain multiple block devices. However, this would require all users to be updated to free those block device structs at some point, which is rather a large change. Most callers of mmc_switch_part() wish to permanently switch the default MMC block device's HW partition. Enhance mmc_switch_part() so that it does this. This removes the need for callers to do this. However, common/env_mmc.c needs to save and restore the current HW partition. Make it do this more explicitly. Replace use of mmc_switch_part() with mmc_select_hwpart() in order to remove duplicate code that skips the call if that HW partition is already selected. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* block: pass block dev not num to read/write/erase()Stephen Warren2016-01-13-5/+7
| | | | | | | | | | | This will allow the implementation to make use of data in the block_dev structure beyond the base device number. This will be useful so that eMMC block devices can encompass the HW partition ID rather than treating this out-of-band. Equally, the existence of the priv field is crying out for this patch to exist. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* gpt: part: Definition and declaration of GPT verification functionsLukasz Majewski2015-11-23-0/+35
| | | | | | | | | | | | | This commit provides definition and declaration of GPT verification functions - namely gpt_verify_headers() and gpt_verify_partitions(). The former is used to only check CRC32 of GPT's header and PTEs. The latter examines each partition entry and compare attributes such as: name, start offset and size with ones provided at '$partitions' env variable. Signed-off-by: Lukasz Majewski <l.majewski@majess.pl> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Przemyslaw Marczak <p.marczak@samsung.com>
* gpt: add optional parameter type in gpt commandPatrick Delaunay2015-11-12-0/+3
| | | | | | | | | | | | | | | | code under flag CONFIG_PARTITION_TYPE_GUID add parameter "type" to select partition type guid example of use with gpt command : partitions = uuid_disk=${uuid_gpt_disk}; \ name=boot,size=0x6bc00,uuid=${uuid_gpt_boot}; \ name=root,size=0x7538ba00,uuid=${uuid_gpt_root}, \ type=0fc63daf-8483-4772-8e79-3d69d8477de4; gpt write mmc 0 $partitions Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
* fastboot: handle flash write to GPT partitionsSteve Rae2014-12-18-0/+20
| | | | | | | | | | | Implement a feature to allow fastboot to write the downloaded image to the space reserved for the Protective MBR and the Primary GUID Partition Table. Additionally, prepare and write the Backup GUID Partition Table. Signed-off-by: Steve Rae <srae@broadcom.com> Tested-by: Lukasz Majewski <l.majewski@samsung.com> [Test HW: Exynos4412 - Trats2]
* disk: part_efi: add get_partition_info_efi_by_name()Steve Rae2014-06-05-0/+11
| | | | | | | | Add function to find a GPT table entry by name. Tested on little endian ARMv7 and ARMv8 configurations Signed-off-by: Steve Rae <srae@broadcom.com>
* mmc: provide a select_hwpart implementation for get_device()Stephen Warren2014-05-23-0/+2
| | | | | | | | | This enables specifying which eMMC HW partition to target for any U-Boot command that uses the generic get_partition() function to parse its command-line arguments. Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Stephen Warren <swarren@nvidia.com>
* part: header fixMateusz Zalega2014-05-05-0/+1
| | | | | | | | | | Implementation made use of types defined in common.h, even though it wasn't #included. It worked in circumstances when .c files included every needed header (all). Signed-off-by: Mateusz Zalega <m.zalega@samsung.com> Cc: Tom Rini <trini@ti.com> Cc: Minkyu Kang <mk7.kang@samsung.com>
* sandbox: block driver using host file/device as backing storeHenrik Nordström2014-01-08-0/+5
| | | | | | | | | | | | | | | | | | | Provide a way to use any host file or device as a block device in U-Boot. This can be used to provide filesystem access within U-Boot to an ext2 image file on the host, for example. The support is plumbed into the filesystem and partition interfaces. We don't want to print a message in the driver every time we find a missing device. Pass the information back to the caller where a message can be printed if desired. Signed-off-by: Henrik Nordström <henrik@henriknordstrom.net> Signed-off-by: Simon Glass <sjg@chromium.org> - Removed change to part.c get_device_and_partition() Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* Coding Style cleanup: remove trailing white spaceWolfgang Denk2013-10-14-1/+1
| | | | Signed-off-by: Wolfgang Denk <wd@denx.de>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-24-17/+1
| | | | | | Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
* Fix ext2/ext4 filesystem accesses beyond 2TiBFrederic Leroy2013-07-15-2/+2
| | | | | | | | | | | | | | | | | With CONFIG_SYS_64BIT_LBA, lbaint_t gets defined as a 64-bit type, which is required to represent block numbers for storage devices that exceed 2TiB (the block size usually is 512B), e.g. recent hard drives We now use lbaint_t for partition offset to reflect the lbaint_t change, and access partitions beyond or crossing the 2.1TiB limit. This required changes to signature of ext4fs_devread(), and type of all variables relatives to block sector. ext2/ext4 fs uses logical block represented by a 32 bit value. Logical block is a multiple of device block sector. To avoid overflow problem when calling ext4fs_devread(), we need to cast the sector parameter. Signed-off-by: Frédéric Leroy <fredo@starox.org>
* Fix block device accesses beyond 2TiBSascha Silbe2013-06-26-3/+3
| | | | | | | | | | | | | | | | | | With CONFIG_SYS_64BIT_LBA, lbaint_t gets defined as a 64-bit type, which is required to represent block numbers for storage devices that exceed 2TiB (the block size usually is 512B), e.g. recent hard drives. For some obscure reason, the current U-Boot code uses lbaint_t for the number of blocks to read (a rather optimistic estimation of how RAM sizes will evolve), but not for the starting address. Trying to access blocks beyond the 2TiB boundary will simply wrap around and read a block within the 0..2TiB range. We now use lbaint_t for block start addresses, too. This required changes to all block drivers as the signature of block_read(), block_write() and block_erase() in block_dev_desc_t changed. Signed-off-by: Sascha Silbe <t-uboot@infra-silbe.de>
* part/dev_desc: Add log2 of blocksize to block_dev_desc data structEgbert Eich2013-05-01-0/+5
| | | | | | | | | | log2 of the device block size serves as the shift value used to calculate the block number to read in file systems when implementing avaiable block sizes. It is needed quite often in file systems thus it is pre-calculated and stored in the block device descriptor. Signed-off-by: Egbert Eich <eich@suse.com>
* disk/gpt: Fix GPT partition handling for blocksize != 512Egbert Eich2013-05-01-0/+4
| | | | | | | | Disks beyond 2T in size use blocksizes of 4096 bytes. However a lot of code in u-boot still assumes a 512 byte blocksize. This patch fixes the handling of GPTs. Signed-off-by: Egbert Eich <eich@suse.com>
* gpt: Support for GPT (GUID Partition Table) restorationLukasz Majewski2012-12-13-0/+52
| | | | | | | | | The restoration of GPT table (both primary and secondary) is now possible. Function 'gpt_restore' presents example of partition restoration process. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
* disk: part_efi: parse and store partition UUIDStephen Warren2012-09-25-0/+3
| | | | | | | | | | | Each EFI partition table entry contains a UUID. Extend U-Boot's struct disk_partition to be able to store this information, and modify get_partition_info_efi() to fill it in. The implementation of uuid_string() was derived from the Linux kernel, tag v3.6-rc4 file lib/vsprintf.c function uuid_string(). Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk: get_device_and_partition() "auto" partition and cleanupStephen Warren2012-09-25-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rework get_device_and_partition() to: a) Implement a new partition ID of "auto", which requests that U-Boot search for the first "bootable" partition, and fall back to the first valid partition if none is found. This way, users don't need to specify an explicit partition in their commands. b) Make use of get_device(). c) Add parameter to indicate whether returning a whole device is acceptable, or whether a partition is mandatory. d) Make error-checking of the user's device-/partition-specification more complete. In particular, if strtoul() doesn't convert all characters, it's an error rather than just ignored. The resultant device/partition returned by the function will be as follows, based on whether the disk has a partition table (ptable) or not, and whether the calling command allows the whole device to be returned or not. (D and P are integers, P >= 1) D D: No ptable: !allow_whole_dev: error allow_whole_dev: device D ptable: device D partition 1 D:0 !allow_whole_dev: error allow_whole_dev: device D D:P No ptable: error ptable: device D partition P D:auto No ptable: !allow_whole_dev: error allow_whole_dev: device D ptable: first partition in device D with bootable flag set. If none, first valid paratition in device D. Note: In order to review this patch, it's probably easiest to simply look at the file contents post-application, rather than reading the patch itself. Signed-off-by: Rob Herring <rob.herring@calxeda.com> [swarren: Rob implemented scanning for bootable partitions. I fixed a couple of issues there, switched the syntax to ":auto", added the error-checking rework, and ":0" syntax for the whole device] Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk: introduce get_device()Stephen Warren2012-09-25-0/+5
| | | | | | | | | This patch introduces function get_device(). This looks up a block_dev_desc_t from an interface name (e.g. mmc) and device number (e.g. 0). This function is essentially the non-partition-specific prefix of get_device_and_partition(). Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk/part: introduce get_device_and_partitionRob Herring2012-09-25-2/+11
| | | | | | | | | | | | All block device related commands (scsiboot, fatload, ext2ls, etc.) have simliar duplicated device and partition parsing and selection code. This adds a common function to replace various implementations. The new function has an enhancement over current versions. If no device or partition is specified on the command line, the bootdevice env variable will be used (scsiboot does this). Signed-off-by: Rob Herring <rob.herring@calxeda.com>
* disk/part: check bootable flag for DOS partitionsRob Herring2012-09-25-0/+1
| | | | | | | Determine which partitions are bootable/active. In the partition listing, print "Boot" for partitions with the bootable/active flag set. Signed-off-by: Rob Herring <rob.herring@calxeda.com>
* include/part.h: fix indentation of lbaAnatolij Gustschin2012-05-22-1/+1
| | | | | | Indent at the same level as other struct members. Signed-off-by: Anatolij Gustschin <agust@denx.de>
* disk/part.c: Make features optionalMatthew McClintock2011-07-26-1/+17
| | | | | | | | | If we don't want to build support for any partition types we can now add #undef CONFIG_PARTITIONS in a board config file to keep this from being compiled in. Otherwise boards assume this is compiled in by default Signed-off-by: Matthew McClintock <msm@freescale.com>
* MMC: add erase function to both mmc and sdLei Wen2011-07-15-0/+3
| | | | | | | | | | | Erase is a very basic function since the begin of sd specification is announced. Although we could write a bulk of full 0xff memory to the range to take place of erase, it is more convenient and safe to implement the erase function itself. Signed-off-by: Lei Wen <leiwen@marvell.com> Signed-off-by: Andy Fleming <afleming@freescale.com> Acked-by: Mike Frysinger <vapier@gentoo.org>
* mflash: Initial mflash supportunsik Kim2009-04-03-0/+1
| | | | | | | | | | | | | | | | | | | | Mflash is fusion memory device mainly targeted consumer eletronic and mobile phone. Internally, it have nand flash and other hardware logics and supports some different operation (ATA, IO, XIP) modes. IO mode is custom mode for the host that doesn't have IDE interface. (Many mobile targeted SoC doesn't have IDE bus) This driver support mflash IO mode. Followings are brief descriptions about IO mode. 1. IO mode based on ATA protocol and uses some custom command. (read confirm, write confirm) 2. IO mode uses SRAM bus interface. Signed-off-by: unsik Kim <donari75@gmail.com>
* Add support for CONFIG_EFI_PARTITION (GUID Partition Table)richardretanubun2008-10-18-0/+8
| | | | | | | | | The GUID (Globally Unique Identifier) Partition Table (GPT) is a part of EFI. See http://en.wikipedia.org/wiki/GUID_Partition_Table Based on linux/fs/partitions/efi.[ch] Signed-off-by: Richard Retanubun <RichardRetanubun@RugggedCom.com>