- 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
This commit is contained in:
Volker Ruppert 2004-08-19 19:42:22 +00:00
parent c57ffcb654
commit 99a42a8dbc
5 changed files with 58 additions and 43 deletions

View File

@ -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

View File

@ -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; channel<BX_MAX_ATA_CHANNEL; channel++) {
if (bx_options.ata[channel].Opresent->get() == 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),

View File

@ -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 <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifndef _MSC_VER
#include <unistd.h>
#include <fcntl.h>
#ifndef _MSC_VER
#include <unistd.h>
#else
#include <io.h>
#endif
#include <stdio.h>
#include <stdlib.h>
@ -19,9 +21,6 @@
#include <assert.h>
#ifdef WIN32
# include <conio.h>
#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))

View File

@ -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 <conio.h>
# include <windows.h>
# include <winioctl.h>
#ifdef _MSC_VER
# include <io.h>
#endif
#endif
#include <stdio.h>
#include <stdlib.h>
@ -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

View File

@ -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"