From 32e0e40ddecceeb03045bb790c7f9e19f7b1709c Mon Sep 17 00:00:00 2001 From: Jonathan Campbell Date: Mon, 21 Oct 2013 01:30:58 -0700 Subject: [PATCH] add mount option and support in INT 13h code for "reserved cylinder" emulation --- include/bios_disk.h | 3 +++ src/dos/dos_programs.cpp | 11 ++++++++++- src/ints/bios_disk.cpp | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/bios_disk.h b/include/bios_disk.h index 8818bf223..3405b023d 100644 --- a/include/bios_disk.h +++ b/include/bios_disk.h @@ -50,6 +50,8 @@ public: Bit8u Read_AbsoluteSector(Bit32u sectnum, void * data); Bit8u Write_AbsoluteSector(Bit32u sectnum, void * data); + void Set_Reserved_Cylinders(Bitu resCyl); + Bit32u Get_Reserved_Cylinders(); void Set_Geometry(Bit32u setHeads, Bit32u setCyl, Bit32u setSect, Bit32u setSectSize); void Get_Geometry(Bit32u * getHeads, Bit32u *getCyl, Bit32u *getSect, Bit32u *getSectSize); Bit8u GetBiosType(void); @@ -65,6 +67,7 @@ public: Bit32u sector_size; Bit32u heads,cylinders,sectors; + Bit32u reserved_cylinders; Bit64u current_fpos; }; diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index dce036359..ff971bd51 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -1935,10 +1935,18 @@ public: if (type=="floppy" || type=="hdd" || type=="iso") { Bit16u sizes[4]; bool imgsizedetect=false; - + int reserved_cylinders=0; + std::string reservecyl; std::string str_size; mediaid=0xF8; + /* DOSBox-X: to please certain 32-bit drivers like Windows 3.1 WDCTRL, or to emulate older h/w configurations, + * we allow the user or script to specify the number of reserved cylinders. older BIOSes were known + * to subtract 1 or 2 additional cylinders from the total in the fixed disk param table. the -reservecyl + * option allows the number we subtract from the total in INT 13H to be set */ + cmd->FindString("-reservecyl",reservecyl,true); + if (reservecyl != "") reserved_cylinders = atoi(reservecyl.c_str()); + /* DOSBox-X: we allow "-ide" to allow controlling which IDE controller and slot to attach the hard disk/CD-ROM to */ cmd->FindString("-ide",ideattach,true); @@ -2306,6 +2314,7 @@ public: newImage = new imageDisk(newDisk, (Bit8u *)temp_line.c_str(), imagesize, (imagesize > 2880)); if(imagesize>2880) newImage->Set_Geometry(sizes[2],sizes[3],sizes[1],sizes[0]); + if (reserved_cylinders > 0) newImage->Set_Reserved_Cylinders(reserved_cylinders); } } else { WriteOut(MSG_Get("PROGRAM_IMGMOUNT_TYPE_UNSUPPORTED"),type.c_str()); diff --git a/src/ints/bios_disk.cpp b/src/ints/bios_disk.cpp index 24b78658c..6c9ffd8ed 100644 --- a/src/ints/bios_disk.cpp +++ b/src/ints/bios_disk.cpp @@ -201,11 +201,20 @@ Bit8u imageDisk::Write_AbsoluteSector(Bit32u sectnum, void *data) { } +void imageDisk::Set_Reserved_Cylinders(Bitu resCyl) { + reserved_cylinders = resCyl; +} + +Bit32u imageDisk::Get_Reserved_Cylinders() { + return reserved_cylinders; +} + imageDisk::imageDisk(FILE *imgFile, Bit8u *imgName, Bit32u imgSizeK, bool isHardDisk) { heads = 0; cylinders = 0; sectors = 0; sector_size = 512; + reserved_cylinders = 0; diskimg = imgFile; memset(diskname,0,512); @@ -519,6 +528,15 @@ static Bitu INT13_DiskHandler(void) { else tmpcyl--; // cylinder count -> max cylinder if (tmpheads==0) LOG(LOG_BIOS,LOG_ERROR)("INT13 DrivParm: head count zero!"); else tmpheads--; // head count -> max head + + /* older BIOSes were known to subtract 1 or 2 additional "reserved" cylinders. + * some code, such as Windows 3.1 WDCTRL, might assume that fact. emulate that here */ + { + Bit32u reserv = imageDiskList[drivenum]->Get_Reserved_Cylinders(); + if (tmpcyl > reserv) tmpcyl -= reserv; + else tmpcyl = 0; + } + reg_ch = (Bit8u)(tmpcyl & 0xff); reg_cl = (Bit8u)(((tmpcyl >> 2) & 0xc0) | (tmpsect & 0x3f)); reg_dh = (Bit8u)tmpheads;