summaryrefslogtreecommitdiffstats
path: root/disk/part_efi.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix GCC format-security errors and convert sprintfs.Ben Whitten2016-01-141-1/+1
| | | | | | | | | | | With format-security errors turned on, GCC picks up the use of sprintf with a format parameter not being a string literal. Simple uses of sprintf are also converted to use strcpy. Signed-off-by: Ben Whitten <ben.whitten@gmail.com> Acked-by: Wolfgang Denk <wd@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
* block: pass block dev not num to read/write/erase()Stephen Warren2016-01-131-18/+16
| | | | | | | | | | | 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>
* part:efi: add bootable parameter in gpt commandPatrick Delaunay2015-11-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The optional parameter bootable is added in gpt command to set the partition attribute flag "Legacy BIOS bootable" This flag is used in extlinux and so in with distro to select the boot partition where is located the configuration file (please check out doc/README.distro for details). With this parameter, U-Boot can be used to create the boot partition needed for device using distro. example of use: setenv partitions "name=u-boot,size=60MiB;name=boot,size=60Mib,bootable;\ name=rootfs,size=0" > gpt write mmc 0 $partitions > part list mmc 0 Partition Map for MMC device 0 -- Partition Type: EFI Part Start LBA End LBA Name Attributes Type GUID Partition GUID 1 0x00000022 0x0001e021 "u-boot" attrs: 0x0000000000000000 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 guid: cceb0b18-39cb-d547-9db7-03b405fa77d4 2 0x0001e022 0x0003c021 "boot" attrs: 0x0000000000000004 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 guid: d4981a2b-0478-544e-9607-7fd3c651068d 3 0x0003c022 0x003a9fde "rootfs" attrs: 0x0000000000000000 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 guid: 6d6c9a36-e919-264d-a9ee-bd00379686c7 > part list mmc 0 -bootable devplist > printenv devplist devplist=2 Then the distro scripts will search extlinux in partition 2 and not in the first partition. Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
* gpt: part: Definition and declaration of GPT verification functionsLukasz Majewski2015-11-231-0/+110
| | | | | | | | | | | | | 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>
* uuid: add selection by string for known partition type GUIDPatrick Delaunay2015-11-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | short strings can be used in type parameter of gpt command to replace the guid string for the types known by u-boot partitions = name=boot,size=0x6bc00,type=data; \ name=root,size=0x7538ba00,type=linux; gpt write mmc 0 $partitions and they are also used to display the type of partition in "part list" command Partition Map for MMC device 0 -- Partition Type: EFI Part Start LBA End LBA Name Attributes Type GUID Partition GUID 1 0x00000022 0x0000037f "boot" attrs: 0x0000000000000000 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 type: data guid: d117f98e-6f2c-d04b-a5b2-331a19f91cb2 2 0x00000380 0x003a9fdc "root" attrs: 0x0000000000000000 type: 0fc63daf-8483-4772-8e79-3d69d8477de4 type: linux guid: 25718777-d0ad-7443-9e60-02cb591c9737 Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
* gpt: add optional parameter type in gpt commandPatrick Delaunay2015-11-121-0/+25
| | | | | | | | | | | | | | | | 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>
* Move ALLOC_CACHE_ALIGN_BUFFER() to the new memalign.h headerSimon Glass2015-09-111-0/+1
| | | | | | | Now that we have a new header file for cache-aligned allocation, we should move the stack-based allocation macro there also. Signed-off-by: Simon Glass <sjg@chromium.org>
* gpt: Fix the protective MBR partition sizeMaxime Ripard2015-01-081-1/+1
| | | | | | | | | | | | | | According to the UEFI Spec (Table 16, section 5.2.3 of the version 2.4 Errata B), the protective MBR partition record size must be set to the size of the disk minus one, in LBAs. However, the current code was setting the size as the total number of LBAs on the disk, resulting in an off-by-one error. This confused the AM335x ROM code, and will probably confuse other tools as well. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
* fastboot: handle flash write to GPT partitionsSteve Rae2014-12-181-0/+93
| | | | | | | | | | | 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: move code to static functionsSteve Rae2014-12-181-73/+102
| | | | | | Signed-off-by: Steve Rae <srae@broadcom.com> Tested-by: Lukasz Majewski <l.majewski@samsung.com> [Test HW: Exynos4412 - Trats2]
* sandbox: Fix warnings due to 64-bit printf() stringsSimon Glass2014-11-261-10/+11
| | | | | | | Now that we have inttypes.h, use it in a few more places to avoid compiler warnings on sandbox when building on 64-bit machines. Signed-off-by: Simon Glass <sjg@chromium.org>
* disk: part_efi: add get_partition_info_efi_by_name()Steve Rae2014-06-051-1/+20
| | | | | | | | 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>
* disk: part_efi: clarify lbaint_t usageSteve Rae2014-06-051-25/+26
| | | | | | | | | | - update the comments regarding lbaint_t usage - cleanup casting of values related to the lbaint_t type - cleanup of a type that requires a u64 Tested on little endian ARMv7 and ARMv8 configurations Signed-off-by: Steve Rae <srae@broadcom.com>
* disk: part_efi: resolve endianness issuesSteve Rae2014-06-051-2/+3
| | | | | | Tested on little endian ARMv7 and ARMv8 configurations Signed-off-by: Steve Rae <srae@broadcom.com>
* disk: part_efi: add support for the Backup GPTSteve Rae2014-05-121-3/+19
| | | | | | | | Check the Backup GPT table if the Primary GPT table is invalid. Renamed "Secondary GPT" to "Backup GPT" as per: UEFI Specification (Version 2.3.1, Errata A) Signed-off-by: Steve Rae <srae@broadcom.com>
* lib: uuid: code refactor for proper maintain between uuid bin and stringPrzemyslaw Marczak2014-04-021-8/+9
| | | | | | | | | | | | | | | | | | | | | | | Changes in lib/uuid.c to: - uuid_str_to_bin() - uuid_bin_to_str() New parameter is added to specify input/output string format in listed functions This change allows easy recognize which UUID type is or should be stored in given string array. Binary data of UUID and GUID is always stored in big endian, only string representations are different as follows. String byte: 0 36 String char: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx string UUID: be be be be be string GUID: le le le be be This patch also updates functions calls and declarations in a whole code. Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Cc: Stephen Warren <swarren@nvidia.com> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: trini@ti.com
* part_efi: move uuid<->string conversion functions into lib/uuid.cPrzemyslaw Marczak2014-04-021-79/+11
| | | | | | | | | | | | | | | | This commit introduces cleanup for uuid library. Changes: - move uuid<->string conversion functions into lib/uuid.c so they can be used by code outside part_efi.c. - rename uuid_string() to uuid_bin_to_str() for consistency with existing uuid_str_to_bin() - add an error return code to uuid_str_to_bin() - update existing code to the new library functions. Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Cc: Stephen Warren <swarren@nvidia.com> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: trini@ti.com
* part_efi: fix protective mbr struct allocationHector Palacios2014-02-241-5/+3
| | | | | | | | | | The calloc() call was allocating space for the sizeof the struct pointer rather than for the struct contents. Besides, since this buffer is passed to mmc for writing and some platforms may use cache, the legacy_mbr struct should be cache-aligned. Signed-off-by: Hector Palacios <hector.palacios@digi.com> Tested-by: Lukasz Majewski <l.majewski@samsung.com>
* part_efi: make sure the gpt_pte is freedMark Langsdorf2013-09-201-1/+2
| | | | | | | | | | | | the gpt_pte wasn't being freed if it was checked against an invalid partition. The resulting memory leakage could make it impossible to repeatedly attempt to load non-existent files in a script. Also, downgrade the message for not finding an invalid partition from a printf() to a debug() so as to minimize message spam in perfectly normal situations. Signed-off-by: Mark Langsdorf <mark.langsdorf@calxeda.com>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-241-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-151-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 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>
* disk: Fix possible out-of-bounds access in part_efi.cMarek Vasut2013-06-041-3/+8
| | | | | | | | | | | | | | | | | | | Make sure to never access beyond bounds of either EFI partition name or DOS partition name. This situation is happening: part.h: disk_partition_t->name is 32-byte long part_efi.h: gpt_entry->partition_name is 36-bytes long The loop in part_efi.c copies over 36 bytes and thus accesses beyond the disk_partition_t->name . Fix this by picking the shortest of source and destination arrays and make sure the destination array is cleared so the trailing bytes are zeroed-out and don't cause issues with string manipulation. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Tom Rini <trini@ti.com> Cc: Simon Glass <sjg@chromium.org>
* disk/gpt: Fix GPT partition handling for blocksize != 512Egbert Eich2013-05-011-16/+22
| | | | | | | | 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>
* disk: fix unaligned access in efi partitionsMarc Dietrich2013-04-021-1/+2
| | | | | | | start_sect is not aligned to a 4 byte boundary thus causing exceptions on ARM platforms. Access this field via the get_unaligned_le32 macro. Signed-off-by: Marc Dietrich <marvin24@gmx.de>
* disk: define HAVE_BLOCK_DEVICE in a common placeStephen Warren2013-03-141-7/+1
| | | | | | | | | | This set of ifdefs is used in a number of places. Move its definition somewhere common so it doesn't have to be repeated. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Tom Rini <trini@ti.com> Signed-off-by: Tom Warren <twarren@nvidia.com>
* gpt: Support for GPT (GUID Partition Table) restorationLukasz Majewski2012-12-131-3/+278
| | | | | | | | | 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>
* gpt: The leXX_to_int() calls replaced with ones defined at <compiler.h>Chang Hyun Park2012-12-131-71/+42
| | | | | | | | | | | | Custom definitions of le_XX_to_int functions have been replaced with standard ones, defined at <compiler.h> Replacement of several GPT related structures members with ones indicating its endianness and proper size. Signed-off-by: Chang Hyun Park <heartinpiece@outlook.com> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
* disk: Address cast and format errorsTaylor Hutt2012-10-221-3/+4
| | | | | | | | This change addresses a few printf-formatting errors, and a typecast error. Signed-off-by: Taylor Hutt <thutt@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
* disk: part_efi: set bootable flag in partition objectsStephen Warren2012-10-171-0/+10
| | | | | | | | A partition is considered bootable if it either has the "legacy BIOS bootable" flag set, or if the partition type UUID matches the standard "system" type. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk: part_efi: print raw partition attributesStephen Warren2012-10-171-0/+2
| | | | | | | When printing the EFI partition table, print the raw attributes. Convert struct gpt_entry_attributes to a union to allow raw access. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk: part_efi: print partition UUIDsStephen Warren2012-10-171-22/+28
| | | | | | | | When printing the partition table, print the partition type UUID and the individual partition UUID. Do this unconditionally, since partition UUIDs are useful. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk: part_efi: re-order partition list printf, change caseStephen Warren2012-10-171-4/+4
| | | | | | | | | | | | | The partition name is a long variable-length string. Move it last on the line to ensure consistent layout and that the entries align with the "header" line. Also, surround it in quotes, so if it's empty, it's obvious that something is still being printed. Also, change the case of the LBA numbers; lower-case looks nicer in my opinion, and will be more consistent with the UUID printing that is added later in this series. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk: part_efi: remove indent level from loopStephen Warren2012-10-171-8/+7
| | | | | | | | Simplify the partition printing loop in print_part_efi() to bail out early when the first invalid partition is found, rather than indenting the whole body of the loop. This simplifies later patches. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk: part_efi: parse and store partition UUIDStephen Warren2012-09-251-0/+25
| | | | | | | | | | | 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: part_efi: range-check partition numberStephen Warren2012-09-251-0/+7
| | | | | | | | Enhance get_partition_info_efi() to range-check the partition number. This prevents invalid partitions being accessed, and prevents access beyond the end of the gpt_pte[] array. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* Block: Remove MG DISK supportMarek Vasut2012-06-211-1/+0
| | | | | | | | This driver is unused and obsolete. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Wolfgang Denk <wd@denx.de> Cc: unsik Kim <donari75@gmail.com>
* part_efi: Fix compile errorsSanjeev Premi2011-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Fix errors noticed after enabling CONFIG_EFI_PARTITION for the OMAP3 EVM board: part_efi.c: In function 'print_part_efi': part_efi.c:133:5: warning: passing argument 3 of 'is_gpt_valid' from incompatible pointer type part_efi.c:95:12: note: expected 'struct gpt_header *' but arg ument is of type 'struct gpt_header **' part_efi.c: In function 'get_partition_info_efi': part_efi.c:173:4: warning: passing argument 3 of 'is_gpt_valid ' from incompatible pointer type part_efi.c:95:12: note: expected 'struct gpt_header *' but arg ument is of type 'struct gpt_header **' part_efi.c: In function 'alloc_read_gpt_entries': part_efi.c:384:18: error: 'CONFIG_SYS_CACHELINE_SIZE' undeclare d (first use in this function) Signed-off-by: Sanjeev Premi <premi@ti.com> Cc: Tom Rini <tom.rini@gmail.com> Cc: Anton staaf <robotboy@chromium.org> Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
* disk: part_efi: fix regression due to incorrect buffer usageStephen Warren2011-12-051-2/+2
| | | | | | | | | | | | | | | | | | Commit deb5ca80275e8cfa74d5680b41204e08a095eca5 "disk: part_efi: fix **pgpt_pte == NULL" modified the code to pass "&gpt_head" to is_gpt_valid() rather than the previous "gpt_head". However, gpt_head is a pointer to the buffer, not the actual buffer, since it was allocated using ALLOC_CACHE_ALIGN_BUFFER. This caused is_gpt_valid() to read the disk block onto the stack rather than into the buffer, causing the code to fail. This change reverts that portion of the commit mentioned above. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Doug Anderson <dianders@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org> Tested-by: Anton Staaf <robotboy@chromium.org>
* disk: part_efi: fix **pgpt_pte == NULLDoug Anderson2011-10-271-23/+15
| | | | | | | | | | Code was setting **pgpt_pte == NULL, which meant that the pointer to the gpt_pte would be stored at RAM address 00000000. This 'worked' on T20 (SDRAM starts @ 0x00000000), but hung gpt/EFI access on T30 (SDRAM starts @ 0x80000000). Signed-off-by: Tom Warren <twarren@nvidia.com> Signed-off-by: Doug Anderson <dianders@chromium.org>
* cosmetic: Replace __FUNCTION__ with __func__ in part_efi.cDoug Anderson2011-10-271-14/+14
| | | | | | | This makes checkpatch happy. Signed-off-by: Doug Anderson <dianders@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* part_efi: dcache: allocate cacheline aligned buffersAnton staaf2011-10-251-9/+9
| | | | | | | | | | | | | | | Currently part_efi.c allocates buffers for the gpt_header, the legacy_mbr, and the pte (partition table entry) that may be incorrectly aligned for DMA operations. This patch uses ALLOC_CACHE_ALIGN_BUFFER for the stack allocated buffers and memalign to replace the malloc of the pte. Signed-off-by: Anton Staaf <robotboy@chromium.org> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: Mike Frysinger <vapier@gentoo.org> Cc: Albert ARIBAUD <albert.u.boot@aribaud.net> Acked-by: Mike Frysinger <vapier@gentoo.org>
* part: show efi partition name when print out partition infoLei Wen2011-10-061-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | Previous output: Marvell>> mmc part Partition Map for MMC device 1 -- Partition Type: EFI Part Start LBA End LBA gpt1 0x8C00 0xCBFF gpt2 0xCC00 0x57BFF gpt3 0x57C00 0xA2BFF gpt4 0xA2C00 0xECBFDE With the patch, the output becomes: Marvell>> mmc part Partition Map for MMC device 1 -- Partition Type: EFI Part Name Start LBA End LBA 1 ramdisk 0x00008C00 0x0000CBFF 2 system 0x0000CC00 0x00057BFF 3 userdata 0x00057C00 0x000A2BFF 4 remaining 0x000A2C00 0x00ECBFDE Signed-off-by: Lei Wen <leiwen@marvell.com>
* Partition support: remove newline from partition nameWolfgang Denk2009-08-091-1/+1
| | | | | | | Remove bogus newline character that got added to the .name field of the disk_partition_t structure. Signed-off-by: Wolfgang Denk <wd@denx.de>
* mflash: Initial mflash supportunsik Kim2009-04-031-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>
* disk: convert part_* files to COBJ-$(CONFIG_XXX) styleMike Frysinger2009-02-181-6/+6
| | | | | | | Move the CONFIG_XXX out of the part_XXX.c file and into Makefile to avoid pointless compiles. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* part_efi: Fix partition size calculation due to inclusive ending LBA.Richard Retanubun2009-01-271-1/+3
| | | | | | | | | | The ending LBA is inclusive. Hence, the partition size should be ((ending-LBA + 1) - starting-LBA) to get the proper partition size. This is confirmed against the results from the parted tool. (e.g. use parted /dev/sda -s unit S print) and observe the size. Signed-off-by: Richard Retanubun <RichardRetanubun@RuggedCom.com>
* rename CFG_ macros to CONFIG_SYSJean-Christophe PLAGNIOL-VILLARD2008-10-181-2/+2
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* Add support for CONFIG_EFI_PARTITION (GUID Partition Table)richardretanubun2008-10-181-0/+425
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>
OpenPOWER on IntegriCloud