From ff6d78bb1373700d3ca4563efccb47db58a94ccd Mon Sep 17 00:00:00 2001 From: shermp <14854761+shermp@users.noreply.github.com> Date: Thu, 15 Nov 2018 14:02:38 +1300 Subject: [PATCH] Remove PCem specific limits --- minivhd.c | 7 +++---- minivhd.h | 8 +++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/minivhd.c b/minivhd.c index f209fd5..4ba6472 100644 --- a/minivhd.c +++ b/minivhd.c @@ -329,13 +329,12 @@ VHDGeom vhd_calc_chs(uint32_t sz_mb) VHDGeom chs; uint32_t ts = ((uint64_t)sz_mb * 1024 * 1024) / VHD_SECTOR_SZ; uint32_t spt, heads, cyl, cth; - /* PCem does not currently support spt > 63 */ - // if (ts > 65535 * 16 * 255) - // ts = 65535 * 16 * 255; + if (ts > 65535 * 16 * 255) + ts = 65535 * 16 * 255; if (ts >= 65535 * 16 * 63) { ts = 65535 * 16 * 63; - spt = 63; + spt = 255; heads = 16; cth = ts / spt; } diff --git a/minivhd.h b/minivhd.h index 90e3a50..fc333de 100644 --- a/minivhd.h +++ b/minivhd.h @@ -49,10 +49,12 @@ #define VHD_SPARSE_BLK 0xffffffff #define VHD_DEF_BLOCK_SZ 2097152 #define VHD_START_TS 946684800 -// #define MAX_BAT_SIZE_BYTES 16896 -#define VHD_MAX_BAT_SIZE_BYTES 64512 /* Enough entries for largest VHD PCem can create */ + +/* Enough entries for largest VHD MiniVHD can create. + Calculated by ceil(65535 * 16 * 255 / 4096) * 4 */ +#define VHD_MAX_BAT_SIZE_BYTES 261120 #define VHD_MAX_CYL 65535 /* VHD stores the cylinders as a 16-bit unsigned int */ -#define VHD_MAX_SZ_MB 32255 /* Using max (65535 * 16 * 63) geom */ +#define VHD_MAX_SZ_MB 130559 /* Using max (65535 * 16 * 255) geom */ /* Win 10 appears to add 7 sectors of zero padding between blocks, and before the footer. */ #define VHD_BLK_PADDING 3584