summaryrefslogtreecommitdiff
path: root/disk
diff options
context:
space:
mode:
authorPetr Kulhavy <[email protected]>2016-09-09 10:27:16 +0200
committerTom Rini <[email protected]>2016-10-01 20:04:51 -0400
commitb6dd69a4d6b20862a2075f402f9edfb0de6d14ed (patch)
treecde16c70cc63077087cdfb209d812a1d7a5980b8 /disk
parent87b8530fe24408b0ef41c9b80f38c395ccafad2c (diff)
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 <[email protected]> Reviewed-by: Tom Rini <[email protected]> Acked-by: Steve Rae <[email protected]> Reviewed-by: Simon Glass <[email protected]>
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 82266012efd..8e6aae57369 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,