From 99a42a8dbc707873da973abe020e0b1c9a4e0429 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Thu, 19 Aug 2004 19:42:22 +0000 Subject: [PATCH] - applied SF patch #838601: support for > 2 GB disk size with MSVC++ - support for non-standard disk sizes 1.68 MB and 1.72 MB in bximage - large disk support also works now if compiled in msys/mingw --- bochs/CHANGES | 3 ++- bochs/iodev/harddrv.cc | 30 ++++++++++++++---------------- bochs/misc/bxcommit.c | 23 ++++++++++++----------- bochs/misc/bximage.c | 31 +++++++++++++++++-------------- bochs/osdep.h | 14 +++++++++++++- 5 files changed, 58 insertions(+), 43 deletions(-) diff --git a/bochs/CHANGES b/bochs/CHANGES index 406f07248..ed7eaa5e1 100644 --- a/bochs/CHANGES +++ b/bochs/CHANGES @@ -110,8 +110,9 @@ Changes to next release: [924428] ET bit mismatch between CR0 and MSW [869822] a real SVGA implementation by m_suzu [867045] fix for compiler errors on VC++ by m_suzu + [838601] support for the over 2GB disk size with MSVC++ -- these S.F. bugs were closed +- these S.F. bugs were closed #522111 Host os SIGILL, booting grub from hd #1005052 DMA Controller Model Problem #552939 Bochs window doesn't resize when win311 diff --git a/bochs/iodev/harddrv.cc b/bochs/iodev/harddrv.cc index a1a36528e..3203db740 100644 --- a/bochs/iodev/harddrv.cc +++ b/bochs/iodev/harddrv.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: harddrv.cc,v 1.122 2004-08-11 11:05:11 vruppert Exp $ +// $Id: harddrv.cc,v 1.123 2004-08-19 19:42:21 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -161,7 +161,7 @@ bx_hard_drive_c::init(void) char string[5]; char sbtext[8]; - BX_DEBUG(("Init $Id: harddrv.cc,v 1.122 2004-08-11 11:05:11 vruppert Exp $")); + BX_DEBUG(("Init $Id: harddrv.cc,v 1.123 2004-08-19 19:42:21 vruppert Exp $")); for (channel=0; channelget() == 1) { @@ -2574,25 +2574,23 @@ bx_hard_drive_c::calculate_logical_address(Bit8u channel, off_t *sector) off_t logical_sector; if (BX_SELECTED_CONTROLLER(channel).lba_mode) { - //bx_printf ("disk: calculate: %d %d %d\n", ((Bit32u)BX_SELECTED_CONTROLLER(channel).head_no), ((Bit32u)BX_SELECTED_CONTROLLER(channel).cylinder_no), (Bit32u)BX_SELECTED_CONTROLLER(channel).sector_no); - logical_sector = ((Bit32u)BX_SELECTED_CONTROLLER(channel).head_no) << 24 | - ((Bit32u)BX_SELECTED_CONTROLLER(channel).cylinder_no) << 8 | - (Bit32u)BX_SELECTED_CONTROLLER(channel).sector_no; - //bx_printf ("disk: result: %u\n", logical_sector); + logical_sector = ((Bit32u)BX_SELECTED_CONTROLLER(channel).head_no) << 24 | + ((Bit32u)BX_SELECTED_CONTROLLER(channel).cylinder_no) << 8 | + (Bit32u)BX_SELECTED_CONTROLLER(channel).sector_no; } else - logical_sector = (BX_SELECTED_CONTROLLER(channel).cylinder_no * BX_SELECTED_DRIVE(channel).hard_drive->heads * - BX_SELECTED_DRIVE(channel).hard_drive->sectors) + - (BX_SELECTED_CONTROLLER(channel).head_no * BX_SELECTED_DRIVE(channel).hard_drive->sectors) + - (BX_SELECTED_CONTROLLER(channel).sector_no - 1); + logical_sector = ((Bit32u)BX_SELECTED_CONTROLLER(channel).cylinder_no * BX_SELECTED_DRIVE(channel).hard_drive->heads * + BX_SELECTED_DRIVE(channel).hard_drive->sectors) + + (Bit32u)(BX_SELECTED_CONTROLLER(channel).head_no * BX_SELECTED_DRIVE(channel).hard_drive->sectors) + + (BX_SELECTED_CONTROLLER(channel).sector_no - 1); Bit32u sector_count= - (Bit32u)BX_SELECTED_DRIVE(channel).hard_drive->cylinders * + (Bit32u)BX_SELECTED_DRIVE(channel).hard_drive->cylinders * (Bit32u)BX_SELECTED_DRIVE(channel).hard_drive->heads * (Bit32u)BX_SELECTED_DRIVE(channel).hard_drive->sectors; if (logical_sector >= sector_count) { BX_ERROR (("calc_log_addr: out of bounds (%d/%d)", (Bit32u)logical_sector, sector_count)); - return false; + return false; } *sector = logical_sector; return true; @@ -3763,7 +3761,7 @@ ssize_t sparse_image_t::read_page_fragment(uint32 read_virtual_page, uint32 read if (physical_offset != underlying_current_filepos) { - int ret = ::lseek(fd, physical_offset, SEEK_SET); + off_t ret = ::lseek(fd, physical_offset, SEEK_SET); // underlying_current_filepos update deferred if (ret == -1) panic(strerror(errno)); @@ -3942,7 +3940,7 @@ ssize_t sparse_image_t::write (const void* buf, size_t count) if (physical_offset != underlying_current_filepos) { - int ret = ::lseek(fd, physical_offset, SEEK_SET); + off_t ret = ::lseek(fd, physical_offset, SEEK_SET); // underlying_current_filepos update deferred if (ret == -1) panic(strerror(errno)); @@ -4135,7 +4133,7 @@ redolog_t::print_header() header.standard.magic, header.standard.type, header.standard.subtype, dtoh32(header.standard.version)/0x10000, dtoh32(header.standard.version)%0x10000)); - BX_INFO(("redolog : Specific Header : #entries=%d, bitmap size=%d, exent size = %d disk size = %lld", + BX_INFO(("redolog : Specific Header : #entries=%d, bitmap size=%d, exent size = %d disk size = " FMT_LL "d", dtoh32(header.specific.catalog), dtoh32(header.specific.bitmap), dtoh32(header.specific.extent), diff --git a/bochs/misc/bxcommit.c b/bochs/misc/bxcommit.c index 59b10a230..28280c8ea 100644 --- a/bochs/misc/bxcommit.c +++ b/bochs/misc/bxcommit.c @@ -1,6 +1,6 @@ /* * misc/bximage.c - * $Id: bxcommit.c,v 1.7 2004-04-30 17:26:38 cbothamy Exp $ + * $Id: bxcommit.c,v 1.8 2004-08-19 19:42:22 vruppert Exp $ * * Commits a redolog file in a flat file for bochs images. * @@ -8,9 +8,11 @@ #include #include -#include -#ifndef _MSC_VER -#include +#include +#ifndef _MSC_VER +#include +#else +#include #endif #include #include @@ -19,9 +21,6 @@ #include #ifdef WIN32 # include -#ifndef __MINGW32__ -# define snprintf _snprintf -#endif #endif #include "config.h" @@ -48,11 +47,13 @@ int snprintf (char *s, size_t maxlen, const char *format, ...) #define uint16 Bit16u #define uint32 Bit32u +#include "../osdep.h" + #define INCLUDE_ONLY_HD_HEADERS 1 #include "../iodev/harddrv.h" char *EOF_ERR = "ERROR: End of input"; -char *rcsid = "$Id: bxcommit.c,v 1.7 2004-04-30 17:26:38 cbothamy Exp $"; +char *rcsid = "$Id: bxcommit.c,v 1.8 2004-08-19 19:42:22 vruppert Exp $"; char *divider = "========================================================================"; void myexit (int code) @@ -263,13 +264,13 @@ int commit_redolog (char *flatname, char *redologname ) printf ("\nChecking redolog header: ["); - if (strcmp(header.standard.magic, STANDARD_HEADER_MAGIC) != 0) + if (strcmp((char *)header.standard.magic, STANDARD_HEADER_MAGIC) != 0) fatal ("\nERROR: bad magic in redolog header!"); - if (strcmp(header.standard.type, REDOLOG_TYPE) != 0) + if (strcmp((char *)header.standard.type, REDOLOG_TYPE) != 0) fatal ("\nERROR: bad type in redolog header!"); - if (strcmp(header.standard.subtype, REDOLOG_SUBTYPE_UNDOABLE) != 0) + if (strcmp((char *)header.standard.subtype, REDOLOG_SUBTYPE_UNDOABLE) != 0) fatal ("\nERROR: bad subtype in redolog header!"); if (header.standard.version != htod32(STANDARD_HEADER_VERSION)) diff --git a/bochs/misc/bximage.c b/bochs/misc/bximage.c index 310b2a088..0413873ec 100644 --- a/bochs/misc/bximage.c +++ b/bochs/misc/bximage.c @@ -1,6 +1,6 @@ /* * misc/bximage.c - * $Id: bximage.c,v 1.21 2004-08-19 16:03:03 vruppert Exp $ + * $Id: bximage.c,v 1.22 2004-08-19 19:42:22 vruppert Exp $ * * Create empty hard disk or floppy disk images for bochs. * @@ -10,6 +10,9 @@ # include # include # include +#ifdef _MSC_VER +# include +#endif #endif #include #include @@ -24,6 +27,8 @@ #define uint16 Bit16u #define uint32 Bit32u +#include "../osdep.h" + #define INCLUDE_ONLY_HD_HEADERS 1 #include "../iodev/harddrv.h" @@ -33,7 +38,7 @@ typedef int (*WRITE_IMAGE_WIN32)(HANDLE, Bit64u); #endif char *EOF_ERR = "ERROR: End of input"; -char *rcsid = "$Id: bximage.c,v 1.21 2004-08-19 16:03:03 vruppert Exp $"; +char *rcsid = "$Id: bximage.c,v 1.22 2004-08-19 19:42:22 vruppert Exp $"; char *divider = "========================================================================"; /* menu data for choosing floppy/hard disk */ @@ -42,9 +47,9 @@ char *fdhd_choices[] = { "fd", "hd" }; int fdhd_n_choices = 2; /* menu data for choosing floppy size */ -char *fdsize_menu = "\nChoose the size of floppy disk image to create, in megabytes.\nPlease type 0.36, 0.72, 1.2, 1.44, or 2.88. "; -char *fdsize_choices[] = { "0.36","0.72","1.2","1.44","2.88" }; -int fdsize_n_choices = 5; +char *fdsize_menu = "\nChoose the size of floppy disk image to create, in megabytes.\nPlease type 0.36, 0.72, 1.2, 1.44, 1.68, 1.72, or 2.88. "; +char *fdsize_choices[] = { "0.36","0.72","1.2","1.44","1.68","1.72","2.88" }; +int fdsize_n_choices = 7; /* menu data for choosing disk mode */ char *hdmode_menu = "\nWhat kind of image should I create?\nPlease type flat, sparse or growing. "; @@ -511,7 +516,7 @@ int main() printf (" cyl=%d\n", cyl); printf (" heads=%d\n", heads); printf (" sectors per track=%d\n", spt); - printf (" total sectors=%lld\n", sectors); + printf (" total sectors=" FMT_LL "d\n", sectors); printf (" total size=%.2f megabytes\n", (float)(Bit64s)(sectors/2)/1024.0); if (ask_string ("\nWhat should I name the image?\n", "c.img", filename) < 0) fatal (EOF_ERR); @@ -542,7 +547,9 @@ int main() case 1: name="720k"; cyl=80; heads=2; spt=9; break; /* 0.72 meg */ case 2: name="1_2"; cyl=80; heads=2; spt=15; break; /* 1.2 meg */ case 3: name="1_44"; cyl=80; heads=2; spt=18; break; /* 1.44 meg */ - case 4: name="2_88"; cyl=80; heads=2; spt=36; break; /* 2.88 meg */ + case 4: name="1_44"; cyl=80; heads=2; spt=21; break; /* 1.68 meg */ + case 5: name="1_44"; cyl=82; heads=2; spt=21; break; /* 1.72 meg */ + case 6: name="2_88"; cyl=80; heads=2; spt=36; break; /* 2.88 meg */ default: fatal ("ERROR: fdsize out of range"); } @@ -551,8 +558,8 @@ int main() printf (" cyl=%d\n", cyl); printf (" heads=%d\n", heads); printf (" sectors per track=%d\n", spt); - printf (" total sectors=%lld\n", sectors); - printf (" total bytes=%lld\n", sectors*512); + printf (" total sectors=" FMT_LL "d\n", sectors); + printf (" total bytes=" FMT_LL "d\n", sectors*512); if (ask_string ("\nWhat should I name the image?\n", "a.img", filename) < 0) fatal (EOF_ERR); sprintf (bochsrc_line, "floppya: %s=\"%s\", status=inserted", name, filename); @@ -573,11 +580,7 @@ int main() make_image (sectors, filename, write_function); } #endif -#if defined(WIN32) && !defined(__MINGW32__) - printf ("\nI wrote %I64u bytes to %s.\n", sectors*512, filename); -#else - printf ("\nI wrote %lld bytes to %s.\n", sectors*512, filename); -#endif + printf ("\nI wrote " FMT_LL "d bytes to %s.\n", sectors*512, filename); printf ("\nThe following line should appear in your bochsrc:\n"); printf (" %s\n", bochsrc_line); #ifdef WIN32 diff --git a/bochs/osdep.h b/bochs/osdep.h index bac779cb6..fb5c4deaf 100644 --- a/bochs/osdep.h +++ b/bochs/osdep.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: osdep.h,v 1.21 2004-06-18 14:11:05 sshwarts Exp $ +// $Id: osdep.h,v 1.22 2004-08-19 19:42:21 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -68,8 +68,20 @@ extern "C" { #undef BX_HAVE_VSNPRINTF #define BX_HAVE_SNPRINTF 1 #define BX_HAVE_VSNPRINTF 1 + +#if defined(_MSC_VER) +#define off_t __int64 +#define lseek _lseeki64 +#define fstat _fstati64 +#define stat _stati64 +#endif + #else /* ifndef __MINGW32__ */ #define FMT_LL "%ll" + +#define off_t __int64 +#define lseek _lseeki64 + #endif /* ifndef __MINGW32__ */ #else /* WIN32 */ #define FMT_LL "%ll"