From 63c0ee96ec9dd6fe8ed244e9ffa54f322b34fc3f Mon Sep 17 00:00:00 2001 From: Sergey Svishchev Date: Wed, 8 May 2019 23:26:34 +0300 Subject: imgtool: MT 6693 wip, solves mess_hd issue (nw) --- src/lib/util/chd.cpp | 1 + src/tools/imgtool/imghd.cpp | 19 +++++-------------- src/tools/imgtool/modules/pc_hard.cpp | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/lib/util/chd.cpp b/src/lib/util/chd.cpp index 9714b43535c..3b61d044cd3 100644 --- a/src/lib/util/chd.cpp +++ b/src/lib/util/chd.cpp @@ -788,6 +788,7 @@ chd_error chd_file::open(util::core_file &file, bool writeable, chd_file *parent m_file = &file; m_owns_file = false; m_parent = parent; + m_cachehunk = ~0; return open_common(writeable); } diff --git a/src/tools/imgtool/imghd.cpp b/src/tools/imgtool/imghd.cpp index 17e47a7bf87..b868b692c63 100644 --- a/src/tools/imgtool/imghd.cpp +++ b/src/tools/imgtool/imghd.cpp @@ -53,14 +53,14 @@ imgtoolerr_t imghd_create(imgtool::stream &stream, uint32_t hunksize, uint32_t c chd_error rc; chd_codec_type compression[4] = { CHD_CODEC_NONE }; - /* sanity check args */ - if (hunksize >= 2048) + /* sanity check args -- see parse_hunk_size() in src/lib/util/chd.cpp */ + if (hunksize > (1024 * 1024)) { err = IMGTOOLERR_PARAMCORRUPT; return err; } if (hunksize <= 0) - hunksize = 1024; /* default value */ + hunksize = 4096; /* default value */ /* bail if we are read only */ if (stream.is_read_only()) @@ -80,15 +80,6 @@ imgtoolerr_t imghd_create(imgtool::stream &stream, uint32_t hunksize, uint32_t c return err; } - /* open the new hard drive */ - rc = chd.open(*stream.core_file()); - - if (rc != CHDERR_NONE) - { - err = map_chd_error(rc); - return err; - } - /* write the metadata */ const std::string metadata = string_format(HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, seclen); err = (imgtoolerr_t)chd.write_metadata(HARD_DISK_METADATA_TAG, 0, metadata); @@ -236,7 +227,7 @@ OPTION_GUIDE_START( mess_hd_create_optionguide ) OPTION_INT(mess_hd_createopts_seclen, "seclen", "Sector Bytes" ) OPTION_GUIDE_END -#define mess_hd_create_optionspecs "B[1]-2048;C1-[32]-65536;D1-[8]-64;E1-[128]-4096;F128/256/[512]/1024/2048/4096/8192/16384/32768/65536" +#define mess_hd_create_optionspecs "B1-[4]-2048;C1-[32]-65536;D1-[8]-64;E1-[128]-4096;F128/256/[512]/1024/2048/4096/8192/16384/32768/65536" void hd_get_info(const imgtool_class *imgclass, uint32_t state, union imgtoolinfo *info) @@ -267,5 +258,5 @@ static imgtoolerr_t mess_hd_image_create(imgtool::image &image, imgtool::stream: sectors = createoptions->lookup_int(mess_hd_createopts_sectors); seclen = createoptions->lookup_int(mess_hd_createopts_seclen); - return imghd_create(*stream.get(), blocksize, cylinders, heads, sectors, seclen); + return imghd_create(*stream.get(), blocksize * seclen, cylinders, heads, sectors, seclen); } diff --git a/src/tools/imgtool/modules/pc_hard.cpp b/src/tools/imgtool/modules/pc_hard.cpp index 9973f84e762..c04ad33cce6 100644 --- a/src/tools/imgtool/modules/pc_hard.cpp +++ b/src/tools/imgtool/modules/pc_hard.cpp @@ -61,7 +61,7 @@ OPTION_GUIDE_START( pc_chd_create_optionguide ) OPTION_INT('S', "sectors", "Sectors" ) OPTION_GUIDE_END -static const char pc_chd_create_optionspec[] = "H1-[16]S1-[32]-63T10/20/30/40/50/60/70/80/90/[100]/110/120/130/140/150/160/170/180/190/200"; +static const char pc_chd_create_optionspec[] = "H1-[16];S1-[32]-63;T10/20/30/40/50/60/70/80/90/[100]/110/120/130/140/150/160/170/180/190/200"; static const char fat8_string[8] = { 'F', 'A', 'T', ' ', ' ', ' ', ' ', ' ' }; static const char fat12_string[8] = { 'F', 'A', 'T', '1', '2', ' ', ' ', ' ' }; -- cgit v1.2.3