summaryrefslogtreecommitdiff
path: root/disk/part_dos.c
AgeCommit message (Collapse)Author
2017-10-05disk: part_dos: Use the original allocation scheme for the SPL caseFabio Estevam
Since commit ff98cb90514d ("part: extract MBR signature from partitions") SPL boot on i.MX6 starts to fail: U-Boot SPL 2017.09-00221-g0d6ab32 (Oct 02 2017 - 15:13:19) Trying to boot from MMC1 (keep in loop) Use the original allocation scheme for the SPL case, so that MX6 boards can boot again. This is a temporary solution to avoid the boot regression. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Acked-by: Rob Clark <robdclark@gmail.com> Tested-by: Peter Robinson <pbrobinson@gmail.com>
2017-09-20part: extract MBR signature from partitionsPeter Jones
EFI client programs need the signature information from the partition table to determine the disk a partition is on, so we need to fill that in here. Signed-off-by: Peter Jones <pjones@redhat.com> [separated from efi_loader part, and fixed build-errors for non- CONFIG_EFI_PARTITION case] Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18EFI: find EFI system partition by legacy MBR partition typeAndre Przywara
The UEFI spec allows an EFI system partition (ESP, with the bootloader or kernel EFI apps on it) to reside on a disk using a "legacy" MBR partitioning scheme. But in contrast to actual legacy disks the ESP is not marked as "bootable" using bit 7 in byte 0 of the legacy partition entry, but is instead using partition *type* 0xef (in contrast to 0x0b or 0x0c for a normal FAT partition). The EFI spec isn't 100% clear on this, but it even seems to discourage the use of the bootable flag for ESPs. Also it seems that some EFI implementations (EDK2?) even seem to ignore partitions marked as bootable (probably since they believe they contain legacy boot code). The Debian installer [1] (*not* mini.iso), for instance, contains such an MBR, where none of the two partitions are marked bootable, but the ESP has clearly type 0xef. Now U-Boot cannot find the ESP on such a disk (USB flash drive) and fails to load the EFI grub and thus the installer. Since it all boils down to the distro bootcmds eventually calling "part list -bootable" to find potential boot partitions, it seems logical to just add this "partition type is 0xef" condition to the is_bootable() implementation. This allows the bog standard arm64 Debian-testing installer to boot from an USB pen drive on Allwinner A64 boards (Pine64, BananaPi-M64). (Ubuntu and other distribution installers don't have a legacy MBR, so U-Boot falls back to El Torito there). [1] https://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/arm64/iso-cd/ Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Alexander Graf <agraf@suse.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-02-17SPL: add support to boot from a partition typeDalon Westergreen
the socfpga bootrom supports mmc booting from either a raw image starting at 0x0, or from a partition of type 0xa2. This patch adds support for locating the boot image in the first type 0xa2 partition found. Assigned a partition number of -1 will cause a search for a partition of type CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE and use it to find the u-boot image Signed-off-by: Dalon Westergreen <dwesterg@gmail.com>
2017-01-28cmd, disk: convert CONFIG_PARTITION_UUIDS, CMD_PART and CMD_GPTPatrick Delaunay
We convert CONFIG_PARTITION_UUIDS to Kconfig first. But in order to cleanly update all of the config files we must also update CMD_PART and CMD_GPT to also be in Kconfig in order to avoid complex logic elsewhere to update all of the config files. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com> Signed-off-by: Tom Rini <trini@konsulko.com>
2016-10-01disk: part: refactor generic name creation for DOS and ISOPetr Kulhavy
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>
2016-10-01fastboot: add support for writing MBRPetr Kulhavy
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>
2016-10-01disk: part: implement generic function part_get_info_by_name()Petr Kulhavy
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>
2016-03-14part: Rename test_part_xx() and print_part_xx()Simon Glass
Rename these functions so that part_ is at the start. This more clearly identifies these functions as partition functions. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-03-14dm: block: Adjust device calls to go through helpers functionSimon Glass
To ease conversion to driver model, add helper functions which deal with calling each block device method. With driver model we can reimplement these functions with the same arguments. Use inline functions to avoid increasing code size on some boards. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-03-14dm: block: Rename device number member dev to devnumSimon Glass
This is a device number, and we want to use 'dev' to mean a driver model device. Rename the member. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-03-14dm: part: Rename some partition functionsSimon Glass
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>
2016-03-14dm: part: Convert partition API use to linker listsSimon Glass
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>
2016-03-14dm: Drop the block_dev_desc_t typedefSimon Glass
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>
2016-01-14Fix GCC format-security errors and convert sprintfs.Ben Whitten
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>
2016-01-13block: pass block dev not num to read/write/erase()Stephen Warren
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>
2016-01-13part_dos.c: Don't wrap to negative after 2G sectorsStefan Monnier
In order to support large IDE disks we need to make certain types be lbaint_t now. Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Stefan Monnier <monnier@iro.umontreal.ca>
2015-09-11Move ALLOC_CACHE_ALIGN_BUFFER() to the new memalign.h headerSimon Glass
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>
2014-06-11disk: part_dos.c: Add a PBR check when MBR checking failsDarwin Dingel
Bug: SDCard with a messed up partition but still has a FAT signature intact is readable in Linux but unreadable in uboot with 'fatls'. Fix: When partition info checking fails, there is no checking for a FAT signature (DOS_PBR) which will fail 'fatls'. FAT signature checking is done when no valid partition is found in partition table. If FAT signature is found, the disk will be read as PBR and continue processing. Signed-off-by: Darwin Dingel <darwin.dingel@alliedtelesis.co.nz>
2014-06-05disk: part_efi: clarify lbaint_t usageSteve Rae
- 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>
2013-07-24Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
2013-05-01disk/part_dos: check harder for partition tableEgbert Eich
Devices that used to have a whole disk FAT filesystem but got then partitioned will most likely still have a FAT or FAT32 signature in the first sector as this sector does not get overwritten by a partitioning tool (otherwise the tool would risk to kill the mbr). The current partition search algorithm will erronously detects such a device as a raw FAT device. Instead of looking for the FAT or FAT32 signatures immediately we use the same algorithm as used by the Linux kernel and first check for a valid boot indicator flag on each of the 4 partitions. If the value of this flag is invalid for the first entry we then do the raw partition check. If the flag for any higher partition is wrong we assume the device is neiter a MBR nor PBR device. Signed-off-by: Egbert Eich <eich@suse.com>
2013-03-14disk: define HAVE_BLOCK_DEVICE in a common placeStephen Warren
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>
2012-10-17disk: part_dos: print partition UUID in partition listStephen Warren
This information may be useful to compare against command "part uuid", or if you want to manually paste the information into the kernel command-line. Signed-off-by: Stephen Warren <swarren@nvidia.com> [trini: print_one_part / print_part_dos output strings didn't quite match before the changes] Signed-off-by: Tom Rini <trini@ti.com>
2012-10-17disk: part_dos: checkpatch cleanupsStephen Warren
Minor cleanups required so later patches don't trigger checkpatch. Signed-off-by: Stephen Warren <swarren@nvidia.com>
2012-10-08disk: part_dos: don't claim whole-disk FAT filesystemsStephen Warren
Logically, a disk that contains a raw FAT filesystem does not in fact have a partition table. However, test_part_dos() was claiming that such disks did in fact have a DOS-style partition table. This caused get_device_and_partition() not to return a whole-disk disk_partition_t, since part_type != PART_TYPE_UNKNOWN. part_dos.c's print_partition_extended() detected the raw FAT filesystem condition and printed a fake partition table that encompassed the whole disk. However, part_dos.c's get_partition_info_extended() did not return any valid partitions in this case. This combination caused get_device_and_partition() not to find any valid partitions, and hence to return an error. Fix test_part_dos() not to claim that raw FAT filesystems are DOS partition tables. In turn, this causes get_device_and_partition() to return a whole-disk disk_partition_t, and hence the following commands work: fatls mmc 0 / fatls mmc 0:auto / An alternative would be to modify print_partition_extended() to detect raw FAT filesystems, just like print_partition_extended() does, and to return a fake partition in this case. However, this seems logically incorrect, and also duplicates code, since get_device_and_partition() falls back to returning a whole-disk partition when there is no partition table on the device. Signed-off-by: Stephen Warren <swarren@nvidia.com>
2012-09-25disk: part_msdos: parse and store partition UUIDStephen Warren
The MSDOS/MBR partition table includes a 32-bit unique ID, often referred to as the NT disk signature. When combined with a partition number within the table, this can form a unique ID similar in concept to EFI/GPT's partition UUID. This patch generates UUIDs in the format 0002dd75-01, which matches the format expected by the Linux kernel. Signed-off-by: Stephen Warren <swarren@nvidia.com>
2012-09-25disk/part: check bootable flag for DOS partitionsRob Herring
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>
2012-06-21Block: Remove MG DISK supportMarek Vasut
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>
2012-04-30part_dos: align disk buffers on cache line to enable DMA and cacheEric Nelson
Signed-off-by: Eric Nelson <eric.nelson@boundarydevices.com> Acked-by: Mike Frysinger <vapier@gentoo.org>
2011-07-27part_dos: fix crash with big sector sizeSergei Shtylyov
Apple iPod nanos have sector sizes of 2 or 4 KiB, which crashes U-Boot when it tries to read the MBR into 512-byte buffer situated on stack. Instead use the variable length arrays to be safe with any large sector size. Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
2010-07-24FAT32: fix support for superfloppy-format (PBR)Wolfgang Denk
"Superfloppy" format (in U-Boot called PBR) did not work for FAT32 as the file system type string is at a different location. Add support for FAT32. Signed-off-by: Wolfgang Denk <wd@denx.de>
2009-10-18part_dos: check status flags of partitionsDaniel Mack
Only read partitions which have 0x00 or 0x80 set in their status field. All others are invalid. Signed-off-by: Daniel Mack <daniel@caiaq.de>
2009-08-09Partition support: remove newline from partition nameWolfgang Denk
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>
2009-04-03mflash: Initial mflash supportunsik Kim
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>
2009-02-18disk: convert part_* files to COBJ-$(CONFIG_XXX) styleMike Frysinger
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>
2008-03-26ata: add the support for SATA frameworkDave Liu
- add the SATA framework - add the SATA command line Signed-off-by: Dave Liu <daveliu@freescale.com>
2007-07-09disk/: Remove obsolete references to CONFIG_COMMANDSJon Loeliger
Signed-off-by: Jon Loeliger <jdl@freescale.com>
2007-07-04disk/: Augment CONFIG_COMMANDS tests with defined(CONFIG_CMD_*).Jon Loeliger
This is a compatibility step that allows both the older form and the new form to co-exist for a while until the older can be removed entirely. All transformations are of the form: Before: #if (CONFIG_COMMANDS & CFG_CMD_AUTOSCRIPT) After: #if (CONFIG_COMMANDS & CFG_CMD_AUTOSCRIPT) || defined(CONFIG_CMD_AUTOSCRIPT) Signed-off-by: Jon Loeliger <jdl@freescale.com>
2005-10-13Cleanup for GCC-4.xWolfgang Denk
2005-02-24Cleanup USB and partition defineswdenk
2004-02-23* CVS add missing fileswdenk
* Cleanup compiler warnings * Fix problem with side effects in macros in include/usb.h * Patch by David Benson, 13 Nov 2003: bug 841358 - fix TFTP download size limit * Fixing bug 850768: improper flush_cache() in load_serial() * Fixing bug 834943: MPC8540 - missing volatile declarations * Patch by Stephen Williams, 09 Feb 2004: Add support for Xilinx SystemACE chip: - New files common/cmd_ace.c and include/systemace.h - Hook systemace support into cmd_fat and the partition manager * Patch by Travis Sawyer, 09 Feb 2004: Add bi_opbfreq & bi_iic_fast to 440GX bd_info as needed for Linux
2003-09-10* Patches by Denis Peter, 9 Sep 2003:U-Boot-0_4_8wdenk
add FAT support for IDE, SCSI and USB * Patches by Gleb Natapov, 2 Sep 2003: - cleanup of POST code for unsupported architectures - MPC824x locks way0 of data cache for use as initial RAM; this patch unlocks it after relocation to RAM and invalidates the locked entries. * Patch by Gleb Natapov, 30 Aug 2003: new I2C driver for mpc107 bridge. Now works from flash. * Patch by Dave Ellis, 11 Aug 2003: - JFFS2: fix typo in common/cmd_jffs2.c - JFFS2: fix CFG_JFFS2_SORT_FRAGMENTS option - JFFS2: remove node version 0 warning - JFFS2: accept JFFS2 PADDING nodes - SXNI855T: add AM29LV800 support - SXNI855T: move environment from EEPROM to flash - SXNI855T: boot from JFFS2 in NOR or NAND flash * Patch by Bill Hargen, 11 Aug 2003: fixes for I2C on MPC8240 - fix i2c_write routine - fix iprobe command - eliminates use of global variables, plus dead code, cleanup.
2003-09-10* Add support for USB Mass Storage Devices (BBB)wdenk
(tested with USB memory sticks only) * Avoid flicker on TRAB's VFD
2003-06-29Fix some missing commands, cleanup header filesU-Boot-0_4_1wdenk
(autoscript, bmp, bsp, fat, mmc, nand, portio, ...)
2003-06-27* Code cleanup:LABEL_2003_06_27_2340wdenk
- remove trailing white space, trailing empty lines, C++ comments, etc. - split cmd_boot.c (separate cmd_bdinfo.c and cmd_load.c) * Patches by Kenneth Johansson, 25 Jun 2003: - major rework of command structure (work done mostly by Michal Cendrowski and Joakim Kristiansen)
2003-05-20* Patch by David Updegraff, 22 Apr 2003:LABEL_2003_05_20_1630wdenk
update for CrayL1 board * Patch by Pantelis Antoniou, 21 Apr 2003: add boot support for ARTOS (a proprietary OS) * Patch by Steven Scholz, 11 Apr 2003: Add support for RTC DS1338 * Patch by Rod Boyce, 24 Jan 2003: Fix counting of extended partitions in diskboot command
2002-11-03Initial revisionwdenk