Commit Graph

80 Commits

Author SHA1 Message Date
Stephen Warren
d27b5f9398 disk: part_msdos: parse and store partition UUID
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-25 15:05:45 -07:00
Stephen Warren
894bfbbfb7 disk: part_efi: parse and store partition UUID
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>
2012-09-25 15:05:44 -07:00
Stephen Warren
c04d68c694 disk: part_efi: range-check partition number
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>
2012-09-25 14:58:51 -07:00
Stephen Warren
10a37fd7a4 disk: get_device_and_partition() "auto" partition and cleanup
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>
2012-09-25 14:58:48 -07:00
Stephen Warren
2023e60861 disk: introduce get_device()
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>
2012-09-25 14:49:33 -07:00
Rob Herring
99d2c205d4 disk/part: introduce get_device_and_partition
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>
2012-09-25 14:44:40 -07:00
Rob Herring
40e0e5686a disk/part: check bootable flag for DOS partitions
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-09-25 14:43:19 -07:00
Stephen Warren
2f50164627 disk: make get_partition_info() always available to disk.c
Now that get_device_and_partition() always calls get_partition_info()
when disk.c is compiled, we must always compile the function, rather
than ifdef it away.

The implementation must be conditional based on CONFIG_CMD_* etc., since
that's what e.g. part_dos.c uses to ifdef out get_partition_info_dos();
CONFIG_DOS_PARTITION can be enabled even without those commands being
enabled.

Technically, this change is required before Rob's "disk/part: introduce
get_device_and_partition" patch. However, at least when the compiler
optimizer is turned on, it isn't required before then in practice,
since get_device_and_partition() calls get_dev(), which is stubbed out
in disk.c under exactly the same conditions that get_partition_info()
is not compiled, and hence the compiler never generates code for the
call to the missing function. However, in my later patch "disk:
get_device_and_partition() "auto" partition and cleanup", the optimizer
doesn't succeed at this, and may attempt to reference the undefined
function.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
2012-09-25 14:43:19 -07:00
Benoît Thébaudeau
64a08a9ffc part_mac: dcache: allocate cacheline-aligned buffers
This patch forces the correct alignment for DMA operations of buffers used by
part_mac.c.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Cc: Wolfgang Denk <wd@denx.de>
2012-09-02 17:08:31 +02:00
Marek Vasut
b37d41aa24 Block: Remove MG DISK support
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-06-21 20:53:09 +02:00
Eric Nelson
dec049d924 part_dos: align disk buffers on cache line to enable DMA and cache
Signed-off-by: Eric Nelson <eric.nelson@boundarydevices.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2012-04-30 16:54:50 +02:00
Tim Kientzle
7e71dc6884 disk/part.c: Fix device enumeration through API
The patch below fixes device enumeration through the U-Boot API.

Device enumeration crashes when the system in question doesn't
have any RAM mapped to address zero (I discovered this on a
BeagleBone board), since the enumeration calls get_dev with a
NULL ifname sometimes which then gets passed down to strncmp().

This fix simply ensures that get_dev returns NULL when invoked
with a NULL ifname.

Signed-off-by: Tim Kientzle <kientzle@freebsd.org>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
2012-03-27 11:46:33 +02:00
Sanjeev Premi
29b7042add part_efi: Fix compile errors
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>
2011-12-06 23:59:30 +01:00
Stephen Warren
4715a81136 disk: part_efi: fix regression due to incorrect buffer usage
Commit deb5ca8027 "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>
2011-12-05 22:23:21 +01:00
Doug Anderson
deb5ca8027 disk: part_efi: fix **pgpt_pte == NULL
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>
2011-10-27 23:53:59 +02:00
Doug Anderson
df70b1c2e2 cosmetic: Replace __FUNCTION__ with __func__ in part_efi.c
This makes checkpatch happy.

Signed-off-by: Doug Anderson <dianders@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2011-10-27 23:53:59 +02:00
Anton staaf
f75dd584cd part_efi: dcache: allocate cacheline aligned buffers
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>
2011-10-25 09:26:34 +02:00
Lei Wen
6eecc03079 part: show efi partition name when print out partition info
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>
2011-10-06 20:42:47 +02:00
Sergei Shtylyov
54193c5d81 part_dos: fix crash with big sector size
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>
2011-07-27 23:41:33 +02:00
Matthew McClintock
df3fc52608 disk/part.c: Make features optional
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>
2011-07-26 14:10:14 +02:00
Lei Wen
b16aadf411 disk/part.c: fix potential stack overflow bug
If the param pass to get_dev is not the one defined in the block_drvr,
it could make uboot becomes unstable, for it would continue run after
search complete the block_drvr table.

Signed-off-by: Lei Wen <leiwen@marvell.com>
2011-04-12 22:58:35 +02:00
Sebastien Carlier
6d8962e814 Switch from archive libraries to partial linking
Before this commit, weak symbols were not overridden by non-weak symbols
found in archive libraries when linking with recent versions of
binutils.  As stated in the System V ABI, "the link editor does not
extract archive members to resolve undefined weak symbols".

This commit changes all Makefiles to use partial linking (ld -r) instead
of creating library archives, which forces all symbols to participate in
linking, allowing non-weak symbols to override weak symbols as intended.
This approach is also used by Linux, from which the gmake function
cmd_link_o_target (defined in config.mk and used in all Makefiles) is
inspired.

The name of each former library archive is preserved except for
extensions which change from ".a" to ".o".  This commit updates
references accordingly where needed, in particular in some linker
scripts.

This commit reveals board configurations that exclude some features but
include source files that depend these disabled features in the build,
resulting in undefined symbols.  Known such cases include:
- disabling CMD_NET but not CMD_NFS;
- enabling CONFIG_OF_LIBFDT but not CONFIG_QE.

Signed-off-by: Sebastien Carlier <sebastien.carlier@gmail.com>
2010-11-17 21:02:18 +01:00
Wolfgang Denk
2e5167ccad Replace CONFIG_RELOC_FIXUP_WORKS by CONFIG_NEEDS_MANUAL_RELOC
By now, the majority of architectures have working relocation
support, so the few remaining architectures have become exceptions.
To make this more obvious, we make working relocation now the default
case, and flag the remaining cases with CONFIG_NEEDS_MANUAL_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>
2010-10-29 21:32:07 +02:00
Heiko Schocher
23090dacd2 disk/part.c: fix relocation fixup
Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
2010-09-19 19:29:52 +02:00
Lei Wen
8f3b96427a mmc: print out partition table
Signed-off-by: Lei Wen <leiwen@marvell.com>
2010-09-18 23:47:28 +02:00
Sergei Trofimovich
69a2a4d9a5 disk/part.c: 'usb storage' avoiding overflow when output capacity
Before:
    Marvell>> usb storage
      Device 0: Vendor: StoreJet Rev:  Prod:  Transcend
                Type: Hard Disk
                Capacity: 28759.9 MB = 28.0 GB (488397168 x 512)
After:
    Marvell>> usb storage
      Device 0: Vendor: StoreJet Rev:  Prod:  Transcend
                Type: Hard Disk
                Capacity: 238475.1 MB = 232.8 GB (488397168 x 512)

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2010-08-10 23:08:55 +02:00
Wolfgang Denk
66c2d73cfc FAT32: fix support for superfloppy-format (PBR)
"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>
2010-07-24 20:53:43 +02:00
Heiko Schocher
4b142febff common: delete CONFIG_SYS_64BIT_VSPRINTF and CONFIG_SYS_64BIT_STRTOUL
There is more and more usage of printing 64bit values,
so enable this feature generally, and delete the
CONFIG_SYS_64BIT_VSPRINTF and CONFIG_SYS_64BIT_STRTOUL
defines.

Signed-off-by: Heiko Schocher <hs@denx.de>
2009-12-08 22:14:07 +01:00
Daniel Mack
78f4ca7976 part_dos: check status flags of partitions
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-10-18 22:50:21 +02:00
Peter Tyser
521af04d85 Conditionally perform common relocation fixups
Add #ifdefs where necessary to not perform relocation fixups.  This
allows boards/architectures which support relocation to trim a decent
chunk of code.

Note that this patch doesn't add #ifdefs to architecture-specific code
which does not support relocation.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
2009-10-03 10:17:57 +02:00
Wolfgang Denk
716655288a Partition support: remove newline from partition name
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-08-09 22:52:38 +02:00
Wolfgang Denk
af75a45d23 IDE: bail out of dev_print() for unknown device types
Commit 574b319512 introduced a subtle bug by mixing a list of tests
for "dev_desc->type" and "dev_desc->if_type" into one switch(), which
then mostly did not work because "dev_desc->type" cannot take any
"IF_*" type values. A later fix in commit 8ec6e332ea changed the
switch() into testing "dev_desc->if_type", but at this point the
initial test for unknown device types was completely lost, which
resulted in output like that for IDE ports without device attached:

  Device 1: Model:  Firm:  Ser#:
            Type: # 1F #
            Capacity: not available

This patch re-introduces the missing test for unknown device types.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
2009-05-15 22:30:13 +02:00
unsik Kim
75eb82ec7c mflash: Initial mflash support
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-04-03 23:47:06 +02:00
Mike Frysinger
6c6166f529 vsprintf: pull updates from Linux kernel
This brings in support for the %p modifier which allows us to easily print
out things like ip addresses, mac addresses, and pointers.

It also converts the rarely used 'q' length modifier to the common 'L'
modifier when dealing with quad types.

While this new code is a bit larger (~1k .text), most of it should be made
up by converting the existing ip/mac address code to use format modifiers.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-03-20 22:39:09 +01:00
Mike Frysinger
7bd2722e89 disk: convert part_* files to COBJ-$(CONFIG_XXX) style
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>
2009-02-18 00:50:51 +01:00
Richard Retanubun
5097083971 part_efi: Fix partition size calculation due to inclusive ending LBA.
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>
2009-01-27 23:03:57 +01:00
Wolfgang Denk
3cbd823116 Coding Style cleanup, update CHANGELOG
Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-11-02 16:14:22 +01:00
Jean-Christophe PLAGNIOL-VILLARD
6d0f6bcf33 rename CFG_ macros to CONFIG_SYS
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-10-18 21:54:03 +02:00
richardretanubun
07f3d789b9 Add support for CONFIG_EFI_PARTITION (GUID Partition Table)
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>
2008-10-18 21:54:01 +02:00
Remy Bohmer
6e24a1eb14 Add missing device types to dev_print() in part.c
Signed-off-by: Remy Bohmer <linux@bohmer.net>
2008-09-22 23:10:37 +02:00
Nícolas Carneiro Lebedenco
47bebe34ca Fix dev_print when called from usb_stor_info (usb storage command)
Fix output of the usb storage command. It was printing "Device 0: not
available" because IF_TYPE_USB was not included into the switch
statement.

Signed-off-by: Nicolas Lebedenco <nicolas.lebedenco@tasksistemas.com.br>
2008-09-09 16:04:09 +02:00
Tor Krill
8ec6e332ea Fix incorrect switch for IF_TYPE in part.c
Use correct field in block_dev_desc_t when writing interface type in
dev_print. Error introduced in 574b3195.

Also added fix from Martin Krause

Signed-off-by: Tor Krill <tor@excito.com>
2008-06-03 21:46:39 +02:00
Wolfgang Denk
53677ef18e Big white-space cleanup.
This commit gets rid of a huge amount of silly white-space issues.
Especially, all sequences of SPACEs followed by TAB characters get
removed (unless they appear in print statements).

Also remove all embedded "vim:" and "vi:" statements which hide
indentation problems.

Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-05-21 00:14:08 +02:00
Detlev Zundel
726c0f1e5f cosmetic: Adjust coding style for switch statements to be consistent
Signed-off-by: Detlev Zundel <dzu@denx.de>
2008-05-09 21:26:38 +02:00
Detlev Zundel
574b319512 Fix disk type output in disk/part.c
Signed-off-by: Detlev Zundel <dzu@denx.de>
2008-05-09 21:26:34 +02:00
Dave Liu
c7057b529c ata: add the support for SATA framework
- add the SATA framework
- add the SATA command line

Signed-off-by: Dave Liu <daveliu@freescale.com>
2008-03-26 23:38:51 +01:00
Grant Likely
f0037c56b0 Build: split COBJS value into multiple lines
This change is in preparation for condtitionial compile support in the
build system.  By spliting them all into seperate lines now, subsequent
patches that change 'COBJS-y += ' into 'COBJS-$(CONFIG_<blah>) += ' will
be less invasive and easier to review

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2007-11-15 11:05:18 -07:00
Andy Fleming
6bf6f114dc Merge branch 'testing' into working
Conflicts:

	CHANGELOG
	fs/fat/fat.c
	include/configs/MPC8560ADS.h
	include/configs/pcs440ep.h
	net/eth.c
2007-08-03 02:23:23 -05:00
Jon Loeliger
b3aff0cb9e disk/ doc/ lib_*/ and tools/: Remove lingering references to CFG_CMD_* symbols.
Fixed some broken instances of "#ifdef CMD_CFG_IDE" too.
Those always evaluated TRUE, and thus were always compiled
even when IDE really wasn't defined/wanted.

Signed-off-by: Jon Loeliger <jdl@freescale.com>
2007-07-10 11:19:50 -05:00
Jon Loeliger
cde5c64d17 disk/: Remove obsolete references to CONFIG_COMMANDS
Signed-off-by: Jon Loeliger <jdl@freescale.com>
2007-07-09 17:22:37 -05:00