aboutsummaryrefslogtreecommitdiff
path: root/disk
diff options
context:
space:
mode:
authorPetr Kulhavy <brain@jikos.cz>2016-09-09 10:27:16 +0200
committerTom Rini <trini@konsulko.com>2016-10-01 20:04:51 -0400
commitb6dd69a4d6b20862a2075f402f9edfb0de6d14ed (patch)
treecde16c70cc63077087cdfb209d812a1d7a5980b8 /disk
parent87b8530fe24408b0ef41c9b80f38c395ccafad2c (diff)
downloadu-boot-b6dd69a4d6b20862a2075f402f9edfb0de6d14ed.zip
u-boot-b6dd69a4d6b20862a2075f402f9edfb0de6d14ed.tar.gz
u-boot-b6dd69a4d6b20862a2075f402f9edfb0de6d14ed.tar.bz2
fastboot: add support for writing MBR
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>
Diffstat (limited to 'disk')
-rw-r--r--disk/part_dos.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 8226601..8e6aae5 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -297,6 +297,26 @@ int part_get_info_dos(struct blk_desc *dev_desc, int part,
return part_get_info_extended(dev_desc, 0, 0, 1, part, info, 0);
}
+int is_valid_dos_buf(void *buf)
+{
+ return test_block_type(buf) == DOS_MBR ? 0 : -1;
+}
+
+int write_mbr_partition(struct blk_desc *dev_desc, void *buf)
+{
+ if (is_valid_dos_buf(buf))
+ return -1;
+
+ /* write MBR */
+ if (blk_dwrite(dev_desc, 0, 1, buf) != 1) {
+ printf("%s: failed writing '%s' (1 blks at 0x0)\n",
+ __func__, "MBR");
+ return 1;
+ }
+
+ return 0;
+}
+
U_BOOT_PART_TYPE(dos) = {
.name = "DOS",
.part_type = PART_TYPE_DOS,