From b6dd69a4d6b20862a2075f402f9edfb0de6d14ed Mon Sep 17 00:00:00 2001 From: Petr Kulhavy Date: Fri, 9 Sep 2016 10:27:16 +0200 Subject: 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 Reviewed-by: Tom Rini Acked-by: Steve Rae Reviewed-by: Simon Glass --- disk/part_dos.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'disk/part_dos.c') 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, -- cgit v1.1