Skip to content

Commit

Permalink
Merge pull request #4736 from maron2000/refine_log
Browse files Browse the repository at this point in the history
Refine log regarding attaching images to BIOS & IDE
  • Loading branch information
joncampbell123 authored Jan 13, 2024
2 parents ffc3519 + 19a4a7a commit f52ef91
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 27 deletions.
16 changes: 8 additions & 8 deletions src/dos/dos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,14 +981,14 @@ void HostAppRun() {
/* called by shell to flush keyboard buffer right before executing the program to avoid
* having the Enter key in the buffer to confuse programs that act immediately on keyboard input. */
void DOS_FlushSTDIN(void) {
LOG_MSG("Flush STDIN");
uint8_t handle=RealHandle(STDIN);
if (handle!=0xFF && Files[handle] && Files[handle]->IsName("CON")) {
uint8_t c;uint16_t n;
while (DOS_GetSTDINStatus()) {
n=1; DOS_ReadFile(STDIN,&c,&n);
}
}
LOG(LOG_DOSMISC, LOG_DEBUG)("Flush STDIN");
uint8_t handle=RealHandle(STDIN);
if (handle!=0xFF && Files[handle] && Files[handle]->IsName("CON")) {
uint8_t c;uint16_t n;
while (DOS_GetSTDINStatus()) {
n=1; DOS_ReadFile(STDIN,&c,&n);
}
}
}

static Bitu DOS_21Handler(void) {
Expand Down
12 changes: 5 additions & 7 deletions src/dos/dos_programs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4817,6 +4817,7 @@ bool AttachToBiosByLetter(imageDisk* image, const char drive) {
return AttachToBiosByIndex(image, index);
}
}
LOG_MSG("BIOS: Warning: Four hard drives (Disk no. 2-5) attached to BIOS already. Drive %c not attached", drive);
}
else if (IS_PC98_ARCH) {
//for pc-98 machines, mount floppies at first available index
Expand All @@ -4841,6 +4842,7 @@ bool AttachToBiosAndIdeByLetter(imageDisk* image, const char drive, const unsign
return AttachToBiosAndIdeByIndex(image, index, ide_index, ide_slave);
}
}
LOG_MSG("BIOS: Warning: Four hard drives (Disk no. 2-5) attached to BIOS already. Drive %c not attached", drive);
}
else if (IS_PC98_ARCH) {
//for pc-98 machines, mount floppies at first available index
Expand All @@ -4856,7 +4858,7 @@ bool AttachToBiosAndIdeByLetter(imageDisk* image, const char drive, const unsign
return false;
}

char * GetIDEPosition(unsigned char bios_disk_index);
std::string GetIDEPosition(unsigned char bios_disk_index);
class IMGMOUNT : public Program {
public:
std::vector<std::string> options;
Expand Down Expand Up @@ -4912,7 +4914,7 @@ class IMGMOUNT : public Program {
}
if (!swaps) swaps=1;
sprintf(swapstr, "%d / %d", swaps==1?1:swapPosition+1, swaps);
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_STATUS_NUMBER_FORMAT"), std::to_string(index).c_str(), dynamic_cast<imageDiskElToritoFloppy *>(imageDiskList[index])!=NULL?"El Torito floppy drive":imageDiskList[index]->diskname.c_str(), GetIDEPosition(index), swapstr);
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_STATUS_NUMBER_FORMAT"), std::to_string(index).c_str(), dynamic_cast<imageDiskElToritoFloppy *>(imageDiskList[index])!=NULL?"El Torito floppy drive":imageDiskList[index]->diskname.c_str(), GetIDEPosition(index).c_str(), swapstr);
none=false;
}
}
Expand Down Expand Up @@ -5052,7 +5054,6 @@ class IMGMOUNT : public Program {
if(isdigit(tdr) && tdr - '0' >= 2) { //Allocate to respective slots if drive number is specified
ide_index = (tdr - '2') / 2; // Drive number 2 = 1m (index=0, slave=false), 3 = 1s (index=0, slave=true), ...
ide_slave = (tdr - '2') & 1 ? true : false;
LOG_MSG("IDE: index %d slave=%d", ide_index, ide_slave ? 1 : 0);
} else if(ideattach == "auto") {
//LOG_MSG("IDE: attach=auto type=%s", type);
if(type != "floppy") {
Expand All @@ -5063,13 +5064,11 @@ class IMGMOUNT : public Program {
}
}
if (ide_index < 0) IDE_Auto(ide_index, ide_slave);
LOG_MSG("IDE: index %d slave=%d", ide_index, ide_slave ? 1 : 0);
}
}
else if (ideattach != "none" && isdigit(ideattach[0]) && ideattach[0] > '0') { /* takes the form [controller]<m/s> such as: 1m for primary master */
ide_index = ideattach[0] - '1';
if (ideattach.length() >= 2) ide_slave = (ideattach[1] == 's');
LOG_MSG("IDE: index %d slave=%d",ide_index,ide_slave?1:0);
}

//if floppy, don't attach to ide controller
Expand Down Expand Up @@ -5177,7 +5176,6 @@ class IMGMOUNT : public Program {
ide_slave = false;
}
else IDE_Auto(ide_index, ide_slave);
LOG_MSG("IDE: index %d slave=%d", ide_index, ide_slave ? 1 : 0);
}
} else if (!strcasecmp(ext, ".ima")) {
type="floppy";
Expand Down Expand Up @@ -5255,7 +5253,7 @@ class IMGMOUNT : public Program {
else {
if (AttachToBiosAndIdeByIndex(newImage, (unsigned char)driveIndex, (unsigned char)ide_index, ide_slave)) {
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_MOUNT_NUMBER"), drive - '0', (!paths.empty()) ? (wpcolon&&paths[0].length()>1&&paths[0].c_str()[0]==':'?paths[0].c_str()+1:paths[0].c_str()) : (el_torito != ""?"El Torito floppy drive":(type == "ram"?"RAM drive":"-")));
const char *ext = strrchr(paths[0].c_str(), '.');
const char *ext = strrchr(paths[0].c_str(), '.');
if (ext != NULL) {
if ((!IS_PC98_ARCH && strcasecmp(ext,".img") && strcasecmp(ext,".ima") && strcasecmp(ext,".vhd") && strcasecmp(ext,".qcow2")) ||
(IS_PC98_ARCH && strcasecmp(ext,".hdi") && strcasecmp(ext,".nhd") && strcasecmp(ext,".img") && strcasecmp(ext,".ima"))){
Expand Down
2 changes: 1 addition & 1 deletion src/gui/sdl_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2625,7 +2625,7 @@ class ShowDriveInfo : public GUI::ToplevelWindow {
}
};

char * GetIDEPosition(unsigned char bios_disk_index);
std::string GetIDEPosition(unsigned char bios_disk_index);
class ShowDriveNumber : public GUI::ToplevelWindow {
protected:
GUI::Input *name;
Expand Down
38 changes: 27 additions & 11 deletions src/hardware/ide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ class IDEController:public Module_base{
void lower_irq();
};

const char* ideslot[] = { "Primary", "Secondary", "Tertiary", "Quaternary", "Quinternary","Sexternary", "Septernary", "Octernary" };
const char* master_slave[] = { "Master", "Slave" };

static IDEController* idecontroller[MAX_IDE_CONTROLLERS]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};

static void IDE_DelayedCommand(Bitu pk/*which IDE device*/);
Expand Down Expand Up @@ -2704,10 +2707,14 @@ void IDE_CDROM_Attach(signed char index,bool slave,unsigned char drive_index) {

if (index < 0 || index >= MAX_IDE_CONTROLLERS) return;
c = idecontroller[index];
if (c == NULL) return;
if(c == NULL) {
LOG_MSG("IDE: WARNING: IDE %s controller not available. Check setting or specify another controller.", ideslot[index]);
return;
}


if (c->device[slave?1:0] != NULL) {
LOG_MSG("IDE: Controller %u %s already taken\n",index,slave?"slave":"master");
LOG_MSG("IDE: WARNING: IDE controller %s %s already occupied, specify another slot.",ideslot[index],master_slave[slave?1:0]);
return;
}

Expand All @@ -2717,9 +2724,13 @@ void IDE_CDROM_Attach(signed char index,bool slave,unsigned char drive_index) {
}

dev = new IDEATAPICDROMDevice(c,drive_index,slave);
if (dev == NULL) return;
if(dev == NULL) {
LOG_MSG("IMGMOUNT: Failed to allocate CD-ROM drive %c to IDE %s %s", drive_index + 'A', ideslot[index], master_slave[slave ? 1 : 0]);
return;
}
dev->update_from_cdrom();
c->device[slave?1:0] = (IDEDevice*)dev;
LOG_MSG("IMGMOUNT: CD-ROM image mounted to drive %c (IDE %s %s)", drive_index + 'A', ideslot[index], master_slave[slave ? 1 : 0]);
}

/* drive_index = drive letter 0...A to 25...Z */
Expand Down Expand Up @@ -2778,10 +2789,13 @@ void IDE_Hard_Disk_Attach(signed char index,bool slave,unsigned char bios_disk_i

if (index < 0 || index >= MAX_IDE_CONTROLLERS) return;
c = idecontroller[index];
if (c == NULL) return;
if(c == NULL) {
LOG_MSG("IDE: WARNING: IDE %s controller not available. Check setting or specify another controller.", ideslot[index]);
return;
}

if (c->device[slave?1:0] != NULL) {
LOG_MSG("IDE: Controller %u %s already taken\n",index,slave?"slave":"master");
LOG_MSG("IDE: WARNING: IDE controller %s %s already occupied, specify another slot.", ideslot[index], master_slave[slave ? 1 : 0]);
return;
}

Expand All @@ -2794,6 +2808,7 @@ void IDE_Hard_Disk_Attach(signed char index,bool slave,unsigned char bios_disk_i
if (dev == NULL) return;
dev->update_from_biosdisk();
c->device[slave?1:0] = (IDEDevice*)dev;
LOG_MSG("IMGMOUNT: HDD image mounted to drive no. %d (IDE %s %s)", bios_disk_index, ideslot[index], master_slave[slave?1:0]);
}

/* bios_disk_index = index into BIOS INT 13h disk array: imageDisk *imageDiskList[MAX_DISK_IMAGES]; */
Expand All @@ -2812,25 +2827,26 @@ void IDE_Hard_Disk_Detach(unsigned char bios_disk_index) {
}
}

char idepos[4];
char * GetIDEPosition(unsigned char bios_disk_index) {

std::string GetIDEPosition(unsigned char bios_disk_index) {
std::string idepos;
for (int index = 0; index < MAX_IDE_CONTROLLERS; index++) {
IDEController *c = GetIDEController(index);
if (c)
for (int slave = 0; slave < 2; slave++) {
IDEATADevice *dev = dynamic_cast<IDEATADevice*>(c->device[slave]);
if (dev && dev->bios_disk_index == bios_disk_index) {
sprintf(idepos, "%d%c", index+1, slave?'s':'m');
idepos = std::to_string(index + 1) + (slave ? 's' : 'm');
return idepos;
}
}
}
return (char*)("");
idepos = "n/a";
return idepos;
}

std::string info="";
std::string GetIDEInfo() {
info="";
std::string info;
for (int index = 0; index < MAX_IDE_CONTROLLERS; index++) {
IDEController *c = GetIDEController(index);
if (c)
Expand Down

0 comments on commit f52ef91

Please sign in to comment.