[hatari-devel] Assigning GEMDOS HD to unused drive? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi,
There's support in GEMDOS HD emulation for skipping drives that
are assigned for ACSI emulation partitions. However, similar
support is missing for IDE.
Unlike with hdc.c ACSI emulation, I didn't see in IDE emulation
code for checking how many partitions the given image files
have. In attached patch (which also renames ACSI partition
count variable), I've just assumed both master and slave
have 4 partitions, as that's max.
Is that good enough to commit?
Another alternative would be to add separate option for
specifying GEMDOS drive (when multiple GEMDOS HD drives
aren't specified by directory names). Second patch has
that. Would there any point in having support for that
*in addition* to the (ACSI + IDE) partition skipping?
- Eero
diff -r 7a5973eb8ae1 src/options.c
--- a/src/options.c Sat Sep 27 20:45:55 2014 +0200
+++ b/src/options.c Sun Sep 28 22:03:29 2014 +0300
@@ -110,8 +110,10 @@
OPT_FASTFLOPPY,
OPT_WRITEPROT_FLOPPY,
OPT_WRITEPROT_HD,
+ OPT_HARDDRIVE,
OPT_GEMDOS_CASE,
- OPT_HARDDRIVE,
+ OPT_GEMDOS_DRIVE,
+ OPT_GEMDOSDRIVE,
OPT_ACSIHDIMAGE,
OPT_IDEMASTERHDIMAGE,
OPT_IDESLAVEHDIMAGE,
@@ -307,10 +309,12 @@
"<x>", "Write protect floppy image contents (on/off/auto)" },
{ OPT_WRITEPROT_HD, NULL, "--protect-hd",
"<x>", "Write protect harddrive <dir> contents (on/off/auto)" },
+ { OPT_HARDDRIVE, "-d", "--harddrive",
+ "<dir>", "Emulate harddrive partition(s) with <dir> contents" },
{ OPT_GEMDOS_CASE, NULL, "--gemdos-case",
"<x>", "Forcibly up/lowercase new GEMDOS dir/filenames (off/upper/lower)" },
- { OPT_HARDDRIVE, "-d", "--harddrive",
- "<dir>", "Emulate harddrive partition(s) with <dir> contents" },
+ { OPT_GEMDOS_DRIVE, NULL, "--gemdos-drive",
+ "<drive>", "Assign GEMDOS HD <dir> to drive letter <drive> (C-Z)" },
{ OPT_ACSIHDIMAGE, NULL, "--acsi",
"<file>", "Emulate an ACSI harddrive with an image <file>" },
{ OPT_IDEMASTERHDIMAGE, NULL, "--ide-master",
@@ -1329,6 +1333,20 @@
return Opt_ShowError(OPT_GEMDOS_CASE, argv[i], "Unknown option value");
break;
+ case OPT_GEMDOS_DRIVE:
+ i += 1;
+ if (strlen(argv[i]) == 1)
+ {
+ int drive = toupper(argv[i][0]);
+ if (drive >= 'C' && drive <= 'Z')
+ {
+ drive = drive - 'C' + DRIVE_C;
+ ConfigureParams.HardDisk.nHardDiskDir = drive;
+ break;
+ }
+ }
+ return Opt_ShowError(OPT_GEMDOS_DRIVE, argv[i], "Invalid <drive>");
+
case OPT_HARDDRIVE:
i += 1;
ok = Opt_StrCpy(OPT_HARDDRIVE, false, ConfigureParams.HardDisk.szHardDiskDirectories[0],
diff -r 7a5973eb8ae1 src/includes/hdc.h
--- a/src/includes/hdc.h Sat Sep 27 20:45:55 2014 +0200
+++ b/src/includes/hdc.h Sun Sep 28 22:03:29 2014 +0300
@@ -49,7 +49,7 @@
#define ACSI_EMU_ON bAcsiEmuOn /* Do we have HDC emulation? */
-extern int nPartitions;
+extern int nAcsiPartitions;
extern bool bAcsiEmuOn;
/**
diff -r 7a5973eb8ae1 src/includes/ide.h
--- a/src/includes/ide.h Sat Sep 27 20:45:55 2014 +0200
+++ b/src/includes/ide.h Sun Sep 28 22:03:29 2014 +0300
@@ -10,6 +10,8 @@
#include "sysdeps.h"
+extern int nIDEPartitions;
+
extern void Ide_Init(void);
extern void Ide_UnInit(void);
extern uae_u32 Ide_Mem_bget(uaecptr addr);
diff -r 7a5973eb8ae1 src/gemdos.c
--- a/src/gemdos.c Sat Sep 27 20:45:55 2014 +0200
+++ b/src/gemdos.c Sun Sep 28 22:03:29 2014 +0300
@@ -42,6 +42,7 @@
#include "configuration.h"
#include "file.h"
#include "floppy.h"
+#include "ide.h"
#include "hdc.h"
#include "gemdos.h"
#include "gemdos_defines.h"
@@ -630,6 +631,7 @@
int i;
int nMaxDrives;
int DriveNumber;
+ int ImagePartitions;
bool bMultiPartitions;
/* intialize data for harddrive emulation: */
@@ -645,16 +647,18 @@
}
bMultiPartitions = GemDOS_DetermineMaxPartitions(&nMaxDrives);
+ ImagePartitions = nAcsiPartitions + nIDEPartitions;
/* Now initialize all available drives */
for(i = 0; i < nMaxDrives; i++)
{
- // Create the letter equivalent string identifier for this drive
- char sDriveLetter[] = { PATHSEP, (char)('C' + i), '\0' };
-
- /* If single partition mode, skip to the right entry */
+ /* If single partition mode, skip to first free drive/partition */
if (!bMultiPartitions)
- i += nPartitions;
+ {
+ i += ImagePartitions;
+ if (ConfigureParams.HardDisk.nHardDiskDir > i)
+ i = ConfigureParams.HardDisk.nHardDiskDir;
+ }
/* Allocate emudrives entry for this drive */
emudrives[i] = malloc(sizeof(EMULATEDDRIVE));
@@ -672,8 +676,10 @@
/* Add Requisit Folder ID */
if (bMultiPartitions)
+ {
+ char sDriveLetter[] = { PATHSEP, (char)('C' + i), '\0' };
strcat(emudrives[i]->hd_emulation_dir, sDriveLetter);
-
+ }
/* drive number (C: = 2, D: = 3, etc.) */
DriveNumber = 2 + i;
@@ -685,7 +691,7 @@
strcpy(emudrives[i]->fs_currpath, emudrives[i]->hd_emulation_dir);
File_AddSlashToEndFileName(emudrives[i]->fs_currpath); /* Needs trailing slash! */
/* If the GemDos Drive letter is free then */
- if (i >= nPartitions)
+ if (i >= ImagePartitions)
{
Log_Printf(LOG_INFO, "GEMDOS HDD emulation, %c: <-> %s.\n",
'A'+DriveNumber, emudrives[i]->hd_emulation_dir);
diff -r 7a5973eb8ae1 src/hdc.c
--- a/src/hdc.c Sat Sep 27 20:45:55 2014 +0200
+++ b/src/hdc.c Sun Sep 28 22:03:29 2014 +0300
@@ -76,7 +76,7 @@
/* HDC globals */
SCSI_CTRLR AcsiBus;
-int nPartitions = 0;
+int nAcsiPartitions = 0;
bool bAcsiEmuOn = false;
@@ -684,7 +684,7 @@
for(i=0;i<4;i++)
if(hdinfo[4 + 12*i])
- nPartitions++;
+ nAcsiPartitions++;
fseek(dev->image_file, offset, 0);
}
@@ -699,7 +699,7 @@
int i;
memset(&AcsiBus, 0, sizeof(AcsiBus));
- nPartitions = 0;
+ nAcsiPartitions = 0;
bAcsiEmuOn = false;
for (i = 0; i < MAX_ACSI_DEVS; i++)
@@ -735,7 +735,7 @@
}
/* set number of partitions */
- nNumDrives += nPartitions;
+ nNumDrives += nAcsiPartitions;
return bAcsiEmuOn;
}
@@ -762,8 +762,8 @@
AcsiBus.devs[i].enabled = false;
}
- nNumDrives -= nPartitions;
- nPartitions = 0;
+ nNumDrives -= nAcsiPartitions;
+ nAcsiPartitions = 0;
bAcsiEmuOn = false;
}
diff -r 7a5973eb8ae1 src/ide.c
--- a/src/ide.c Sat Sep 27 20:45:55 2014 +0200
+++ b/src/ide.c Sun Sep 28 22:03:29 2014 +0300
@@ -27,7 +27,7 @@
# include <malloc.h>
#endif
-
+int nIDEPartitions = 0;
struct IDEState;
@@ -2716,10 +2689,12 @@
bdrv_open(hd_table[1], ConfigureParams.HardDisk.szIdeSlaveHardDiskImage, 0);
ide_init2(&opaque_ide_if[0], hd_table[0], hd_table[1]);
+ nIDEPartitions = 8;
}
else
{
ide_init2(&opaque_ide_if[0], hd_table[0], NULL);
+ nIDEPartitions = 4;
}
}
@@ -2757,4 +2732,5 @@
free(opaque_ide_if);
opaque_ide_if = NULL;
}
+ nIDEPartitions = 0;
}