[PATCH 2/2] Check for SCSI enabling and partition counts in relevant places |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- Subject: [PATCH 2/2] Check for SCSI enabling and partition counts in relevant places
- From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
- Date: Mon, 31 Aug 2020 00:17:01 +0300
These should fix following issues (which had been missed in testing):
- "--gemdos-drive skip" not skipping SCSI drives,
due to missing SCSI partition count
- Partition count being wrong after ACSI / SCSI UnInit(),
due to SCSI drives not being deducted on SCSI UnInit()
- (Emu)TOS booting from A: although SCSI drive was enabled
- TOS patch being applied when SCSI is enabled although it shouldn't
(Not sure about last one, but ACSI is taken account for it,
so I assume SCSI should also be.)
---
src/floppy.c | 3 ++-
src/gemdos.c | 3 ++-
src/hdc.c | 3 ++-
src/includes/ncr5380.h | 5 ++++-
src/ncr5380.c | 25 ++++++++++++++++++++-----
src/tos.c | 4 +++-
6 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/src/floppy.c b/src/floppy.c
index 1c6c54a6..4485e8d2 100644
--- a/src/floppy.c
+++ b/src/floppy.c
@@ -33,6 +33,7 @@ const char Floppy_fileid[] = "Hatari floppy.c : " __DATE__ " " __TIME__;
#include "floppy.h"
#include "gemdos.h"
#include "hdc.h"
+#include "ncr5380.h"
#include "log.h"
#include "memorySnapShot.h"
#include "st.h"
@@ -174,7 +175,7 @@ void Floppy_GetBootDrive(void)
if (!ConfigureParams.HardDisk.bBootFromHardDisk)
return;
- if (bAcsiEmuOn || ConfigureParams.Ide[0].bUseDevice)
+ if (bAcsiEmuOn || bScsiEmuOn || ConfigureParams.Ide[0].bUseDevice)
{
nBootDrive = 2; /* Drive C */
}
diff --git a/src/gemdos.c b/src/gemdos.c
index d52815ba..6ec60b47 100644
--- a/src/gemdos.c
+++ b/src/gemdos.c
@@ -49,6 +49,7 @@ const char Gemdos_fileid[] = "Hatari gemdos.c : " __DATE__ " " __TIME__;
#include "ide.h"
#include "inffile.h"
#include "hdc.h"
+#include "ncr5380.h"
#include "gemdos.h"
#include "gemdos_defines.h"
#include "log.h"
@@ -699,7 +700,7 @@ void GemDOS_InitDrives(void)
}
}
- ImagePartitions = nAcsiPartitions + nIDEPartitions;
+ ImagePartitions = nAcsiPartitions + nScsiPartitions + nIDEPartitions;
if (ConfigureParams.HardDisk.nGemdosDrive == DRIVE_SKIP)
SkipPartitions = ImagePartitions;
else
diff --git a/src/hdc.c b/src/hdc.c
index ccdf6679..ef84738f 100644
--- a/src/hdc.c
+++ b/src/hdc.c
@@ -915,7 +915,8 @@ void HDC_UnInit(void)
free(AcsiBus.buffer);
AcsiBus.buffer = NULL;
- Ncr5380_UnInit();
+ if (bScsiEmuOn)
+ nNumDrives -= Ncr5380_UnInit();
if (bAcsiEmuOn)
nNumDrives -= nAcsiPartitions;
diff --git a/src/includes/ncr5380.h b/src/includes/ncr5380.h
index 1fc666c3..231bb6e6 100644
--- a/src/includes/ncr5380.h
+++ b/src/includes/ncr5380.h
@@ -8,8 +8,11 @@
#ifndef NCR5380_H
#define NCR5380_H
+extern int nScsiPartitions;
+extern bool bScsiEmuOn;
+
int Ncr5380_Init(void);
-void Ncr5380_UnInit(void);
+int Ncr5380_UnInit(void);
void Ncr5380_Reset(void);
void Ncr5380_WriteByte(int addr, Uint8 byte);
Uint8 Ncr5380_ReadByte(int addr);
diff --git a/src/ncr5380.c b/src/ncr5380.c
index caf30119..bfb8fdac 100644
--- a/src/ncr5380.c
+++ b/src/ncr5380.c
@@ -31,6 +31,9 @@ const char NCR5380_fileid[] = "Hatari ncr5380.c";
#define WITH_NCR5380 1
+int nScsiPartitions;
+bool bScsiEmuOn;
+
static SCSI_CTRLR ScsiBus;
#define MAX_TOTAL_SCSI_DEVICES 8
@@ -1013,7 +1016,10 @@ void ncr5380_bput(struct soft_scsi *scsi, int reg, uae_u8 v)
int Ncr5380_Init(void)
{
#if WITH_NCR5380
- int i, partitions = 0;
+ int i;
+
+ nScsiPartitions = 0;
+ bScsiEmuOn = false;
memset(&ScsiBus, 0, sizeof(ScsiBus));
ScsiBus.typestr = "SCSI";
@@ -1029,18 +1035,21 @@ int Ncr5380_Init(void)
if (!ConfigureParams.Scsi[i].bUseDevice)
continue;
if (HDC_InitDevice(&ScsiBus.devs[i], ConfigureParams.Scsi[i].sDeviceFile, ConfigureParams.Scsi[i].nBlockSize) == 0)
- partitions += HDC_PartitionCount(ScsiBus.devs[i].image_file, TRACE_SCSI_CMD, NULL);
+ nScsiPartitions += HDC_PartitionCount(ScsiBus.devs[i].image_file, TRACE_SCSI_CMD, NULL);
}
- return partitions;
+ if (nScsiPartitions)
+ bScsiEmuOn = true;
+ return nScsiPartitions;
#else
return 0;
#endif
}
-void Ncr5380_UnInit(void)
+/* return number of SCSI partitions disabled on UnInit() */
+int Ncr5380_UnInit(void)
{
#if WITH_NCR5380
- int i;
+ int i, partitions = nScsiPartitions;
for (i = 0; i < MAX_SCSI_DEVS; i++)
{
@@ -1053,6 +1062,12 @@ void Ncr5380_UnInit(void)
}
free(ScsiBus.buffer);
ScsiBus.buffer = NULL;
+
+ nScsiPartitions = 0;
+ bScsiEmuOn = false;
+ return partitions;
+#else
+ return 0;
#endif
}
diff --git a/src/tos.c b/src/tos.c
index 78d26baf..a6d29b50 100644
--- a/src/tos.c
+++ b/src/tos.c
@@ -25,6 +25,7 @@ const char TOS_fileid[] = "Hatari tos.c : " __DATE__ " " __TIME__;
#include "file.h"
#include "gemdos.h"
#include "hdc.h"
+#include "ncr5380.h"
#include "ioMem.h"
#include "log.h"
#include "m68000.h"
@@ -757,7 +758,8 @@ static void TOS_FixRom(Uint32 *logopatch_addr)
#endif
/* Only apply the patch if it is really needed: */
if (pPatch->Flags == TP_ALWAYS
- || (pPatch->Flags == TP_HDIMAGE_OFF && !bAcsiEmuOn
+ || (pPatch->Flags == TP_HDIMAGE_OFF
+ && !(bAcsiEmuOn || bScsiEmuOn)
&& !ConfigureParams.Ide[0].bUseDevice
&& ConfigureParams.System.bFastBoot)
|| (pPatch->Flags == TP_ANTI_STE && Config_IsMachineST())
--
2.20.1
--------------D68940423E139D2DEF4AEC03
Content-Type: text/x-patch; charset=UTF-8;
name="0001-Remove-define-obfuscating-bAcsiEmuOn-variable-name.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename*0="0001-Remove-define-obfuscating-bAcsiEmuOn-variable-name.patc";
filename*1="h"