The scsi_cdrom[], zip[], and scsi_disk[] arrays are now gone.

This commit is contained in:
OBattler
2018-10-26 04:47:21 +02:00
parent 5641519d5f
commit 473b71436d
12 changed files with 81 additions and 83 deletions

View File

@@ -8,7 +8,7 @@
*
* Generic CD-ROM drive core.
*
* Version: @(#)cdrom.c 1.0.3 2018/10/21
* Version: @(#)cdrom.c 1.0.4 2018/10/26
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -264,6 +264,8 @@ cdrom_close(void)
if (dev->close)
dev->close(dev->p);
dev->p = NULL;
cdrom_drive_reset(dev);
}
}

View File

@@ -8,7 +8,7 @@
*
* Generic CD-ROM drive core header.
*
* Version: @(#)cdrom.h 1.0.15 2018/10/17
* Version: @(#)cdrom.h 1.0.16 2018/10/26
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -96,7 +96,7 @@ typedef struct cdrom {
void *image;
void *p;
void *priv;
void (*insert)(void *p);
void (*close)(void *p);

View File

@@ -8,7 +8,7 @@
*
* Definitions for the hard disk image handler.
*
* Version: @(#)hdd.h 1.0.6 2018/06/09
* Version: @(#)hdd.h 1.0.7 2018/10/26
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -92,6 +92,8 @@ typedef struct {
at_spt, /* [Translation] parameters */
at_hpc;
void *priv;
FILE *f; /* current file handle to image */
wchar_t fn[260]; /* name of current image file */

View File

@@ -9,7 +9,7 @@
* Implementation of the Iomega ZIP drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage.
*
* Version: @(#)zip.c 1.0.29 2018/10/25
* Version: @(#)zip.c 1.0.30 2018/10/26
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -51,7 +51,6 @@
#define zipbufferb dev->buffer
zip_t *zip[ZIP_NUM] = { NULL, NULL, NULL, NULL };
zip_drive_t zip_drives[ZIP_NUM];
@@ -2638,7 +2637,6 @@ void
zip_global_init(void)
{
/* Clear the global data. */
memset(zip, 0x00, sizeof(zip));
memset(zip_drives, 0x00, sizeof(zip_drives));
}
@@ -2738,21 +2736,24 @@ zip_identify(void *p, int ide_has_dma)
static void
zip_drive_reset(int c)
{
zip_t *dev;
scsi_device_t *sd;
ide_t *id;
if (!zip[c]) {
zip[c] = (zip_t *) malloc(sizeof(zip_t));
memset(zip[c], 0, sizeof(zip_t));
if (!zip_drives[c].priv) {
zip_drives[c].priv = (zip_t *) malloc(sizeof(zip_t));
memset(zip_drives[c].priv, 0, sizeof(zip_t));
}
zip[c]->id = c;
dev = (zip_t *) zip_drives[c].priv;
dev->id = c;
if (zip_drives[c].bus_type == ZIP_BUS_SCSI) {
/* SCSI ZIP, attach to the SCSI bus. */
sd = &scsi_devices[zip_drives[c].scsi_device_id];
sd->p = zip[c];
sd->p = dev;
sd->command = zip_command;
sd->callback = zip_callback;
sd->err_stat_to_scsi = zip_err_stat_to_scsi;
@@ -2767,7 +2768,7 @@ zip_drive_reset(int c)
otherwise, we do nothing - it's going to be a drive
that's not attached to anything. */
if (id) {
id->p = zip[c];
id->p = dev;
id->get_max = zip_get_max;
id->get_timings = zip_get_timings;
id->identify = zip_identify;
@@ -2788,6 +2789,7 @@ zip_drive_reset(int c)
void
zip_hard_reset(void)
{
zip_t *dev;
int c;
for (c = 0; c < ZIP_NUM; c++) {
@@ -2804,15 +2806,17 @@ zip_hard_reset(void)
zip_drive_reset(c);
zip[c]->id = c;
zip[c]->drv = &zip_drives[c];
dev = (zip_t *) zip_drives[c].priv;
zip_init(zip[c]);
dev->id = c;
dev->drv = &zip_drives[c];
zip_init(dev);
if (wcslen(zip_drives[c].image_path))
zip_load(zip[c], zip_drives[c].image_path);
zip_load(dev, zip_drives[c].image_path);
zip_mode_sense_load(zip[c]);
zip_mode_sense_load(dev);
if (zip_drives[c].bus_type == ZIP_BUS_SCSI)
zip_log("SCSI ZIP drive %i attached to SCSI ID %i\n", c, zip_drives[c].scsi_device_id);
@@ -2830,13 +2834,13 @@ zip_close(void)
int c;
for (c = 0; c < ZIP_NUM; c++) {
dev = zip[c];
dev = (zip_t *) zip_drives[c].priv;
if (dev) {
zip_disk_close(dev);
free(zip[c]);
zip[c] = NULL;
free(dev);
zip_drives[c].priv = NULL;
}
}
}

View File

@@ -9,7 +9,7 @@
* Implementation of the Iomega ZIP drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage.
*
* Version: @(#)zip.h 1.0.6 2018/04/30
* Version: @(#)zip.h 1.0.7 2018/10/26
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -54,6 +54,7 @@ typedef struct {
uint32_t medium_size, base;
FILE *f;
void *priv;
} zip_drive_t;
typedef struct {

View File

@@ -10,7 +10,7 @@
* word 0 - base address
* word 1 - bits 1-15 = byte count, bit 31 = end of transfer
*
* Version: @(#)intel_piix.c 1.0.19 2018/10/17
* Version: @(#)intel_piix.c 1.0.20 2018/10/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -831,12 +831,12 @@ piix_reset(void *p)
int i = 0;
for (i = 0; i < CDROM_NUM; i++) {
if (cdrom[i].bus_type == CDROM_BUS_ATAPI)
scsi_cdrom_reset(scsi_cdrom[i]);
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && cdrom[i].priv)
scsi_cdrom_reset(cdrom[i].priv);
}
for (i = 0; i < ZIP_NUM; i++) {
if (zip_drives[i].bus_type == ZIP_BUS_ATAPI)
zip_reset(zip[i]);
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && zip_drives[i].priv)
zip_reset(zip_drives[i].priv);
}
}

View File

@@ -8,7 +8,7 @@
*
* Main emulator module where most things are controlled.
*
* Version: @(#)pc.c 1.0.86 2018/10/19
* Version: @(#)pc.c 1.0.87 2018/10/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -495,7 +495,6 @@ usage:
mouse_init();
cdrom_global_init();
zip_global_init();
scsi_disk_global_init();
/* Load the configuration file. */
config_load();

View File

@@ -9,7 +9,7 @@
* Implementation of the CD-ROM drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage.
*
* Version: @(#)scsi_cdrom.c 1.0.56 2018/10/26
* Version: @(#)scsi_cdrom.c 1.0.57 2018/10/26
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -54,9 +54,6 @@
#define cdbufferb dev->buffer
scsi_cdrom_t *scsi_cdrom[CDROM_NUM] = { NULL, NULL, NULL, NULL };
#pragma pack(push,1)
typedef struct
{
@@ -2989,13 +2986,9 @@ static void
scsi_cdrom_close(void *p)
{
scsi_cdrom_t *dev = (scsi_cdrom_t *) p;
uint8_t id;
if (dev) {
id = dev->id;
free(scsi_cdrom[id]);
scsi_cdrom[id] = NULL;
}
if (dev)
free(dev);
}
@@ -3100,6 +3093,7 @@ void
scsi_cdrom_drive_reset(int c)
{
cdrom_t *drv = &cdrom[c];
scsi_cdrom_t *dev;
scsi_device_t *sd;
ide_t *id;
@@ -3111,26 +3105,27 @@ scsi_cdrom_drive_reset(int c)
if ((drv->bus_type == CDROM_BUS_ATAPI) && (drv->ide_channel > 7))
return;
if (!scsi_cdrom[c]) {
scsi_cdrom[c] = (scsi_cdrom_t *) malloc(sizeof(scsi_cdrom_t));
memset(scsi_cdrom[c], 0, sizeof(scsi_cdrom_t));
if (!drv->priv) {
drv->priv = (scsi_cdrom_t *) malloc(sizeof(scsi_cdrom_t));
memset(drv->priv, 0, sizeof(scsi_cdrom_t));
}
scsi_cdrom[c]->id = c;
scsi_cdrom[c]->drv = drv;
drv->p = scsi_cdrom[c];
dev = (scsi_cdrom_t *) drv->priv;
dev->id = c;
dev->drv = drv;
drv->insert = scsi_cdrom_insert;
drv->get_volume = scsi_cdrom_get_volume;
drv->get_channel = scsi_cdrom_get_channel;
drv->close = scsi_cdrom_close;
scsi_cdrom_init(scsi_cdrom[c]);
scsi_cdrom_init(dev);
if (drv->bus_type == CDROM_BUS_SCSI) {
/* SCSI CD-ROM, attach to the SCSI bus. */
sd = &scsi_devices[drv->scsi_device_id];
sd->p = scsi_cdrom[c];
sd->p = dev;
sd->command = scsi_cdrom_command;
sd->callback = scsi_cdrom_callback;
sd->err_stat_to_scsi = scsi_cdrom_err_stat_to_scsi;
@@ -3147,7 +3142,7 @@ scsi_cdrom_drive_reset(int c)
otherwise, we do nothing - it's going to be a drive
that's not attached to anything. */
if (id) {
id->p = scsi_cdrom[c];
id->p = dev;
id->get_max = scsi_cdrom_get_max;
id->get_timings = scsi_cdrom_get_timings;
id->identify = scsi_cdrom_identify;

View File

@@ -6,7 +6,7 @@
*
* Emulation of SCSI fixed disks.
*
* Version: @(#)scsi_disk.c 1.0.25 2018/10/18
* Version: @(#)scsi_disk.c 1.0.26 2018/10/26
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -53,10 +53,6 @@
#define scsi_disk_ascq dev->sense[13]
scsi_disk_t *scsi_disk[HDD_NUM] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
/* Table of all SCSI commands and their flags, needed for the new disc change / not ready handler. */
const uint8_t scsi_disk_command_flags[0x100] = {
IMPLEMENTED | CHECK_READY | NONDATA, /* 0x00 */
@@ -1238,19 +1234,11 @@ scsi_disk_callback(void *p)
}
/* Peform a master init on the entire module. */
void
scsi_disk_global_init(void)
{
/* Clear the global data. */
memset(scsi_disk, 0x00, sizeof(scsi_disk));
}
void
scsi_disk_hard_reset(void)
{
int c;
scsi_disk_t *dev;
scsi_device_t *sd;
for (c = 0; c < HDD_NUM; c++) {
@@ -1269,15 +1257,17 @@ scsi_disk_hard_reset(void)
if (! hdd_image_load(c))
continue;
if (!scsi_disk[c]) {
scsi_disk[c] = (scsi_disk_t *) malloc(sizeof(scsi_disk_t));
memset(scsi_disk[c], 0, sizeof(scsi_disk_t));
if (!hdd[c].priv) {
hdd[c].priv = (scsi_disk_t *) malloc(sizeof(scsi_disk_t));
memset(hdd[c].priv, 0, sizeof(scsi_disk_t));
}
dev = (scsi_disk_t *) hdd[c].priv;
/* SCSI disk, attach to the SCSI bus. */
sd = &scsi_devices[hdd[c].scsi_id];
sd->p = scsi_disk[c];
sd->p = dev;
sd->command = scsi_disk_command;
sd->callback = scsi_disk_callback;
sd->err_stat_to_scsi = scsi_disk_err_stat_to_scsi;
@@ -1286,10 +1276,10 @@ scsi_disk_hard_reset(void)
sd->read_capacity = scsi_disk_read_capacity;
sd->type = SCSI_FIXED_DISK;
scsi_disk[c]->id = c;
scsi_disk[c]->drv = &hdd[c];
dev->id = c;
dev->drv = &hdd[c];
scsi_disk_mode_sense_load(scsi_disk[c]);
scsi_disk_mode_sense_load(dev);
scsi_disk_log("SCSI disk %i attached to SCSI ID %i\n", c, hdd[c].scsi_id);
}
@@ -1304,13 +1294,13 @@ scsi_disk_close(void)
int c;
for (c = 0; c < HDD_NUM; c++) {
dev = scsi_disk[c];
dev = hdd[c].priv;
if (dev) {
hdd_image_close(c);
free(scsi_disk[c]);
scsi_disk[c] = NULL;
free(dev);
hdd[c].priv = NULL;
}
}
}

View File

@@ -6,7 +6,7 @@
*
* Emulation of SCSI fixed and removable disks.
*
* Version: @(#)scsi_disk.h 1.0.6 2018/10/10
* Version: @(#)scsi_disk.h 1.0.7 2018/10/26
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2017,2018 Miran Grca.
@@ -45,6 +45,5 @@ typedef struct {
extern scsi_disk_t *scsi_disk[HDD_NUM];
extern void scsi_disk_global_init(void);
extern void scsi_disk_hard_reset(void);
extern void scsi_disk_close(void);

View File

@@ -8,7 +8,7 @@
*
* Handle the platform-side of CDROM drives.
*
* Version: @(#)win_cdrom.c 1.0.11 2018/10/21
* Version: @(#)win_cdrom.c 1.0.12 2018/10/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -61,10 +61,12 @@ plat_cdrom_ui_update(uint8_t id, uint8_t reload)
void
zip_eject(uint8_t id)
{
zip_disk_close(zip[id]);
zip_t *dev = (zip_t *) zip_drives[id].priv;
zip_disk_close(dev);
if (zip_drives[id].bus_type) {
/* Signal disk change to the emulated machine. */
zip_insert(zip[id]);
zip_insert(dev);
}
ui_sb_update_icon_state(SB_ZIP | id, 1);
@@ -78,7 +80,9 @@ zip_eject(uint8_t id)
void
zip_reload(uint8_t id)
{
zip_disk_reload(zip[id]);
zip_t *dev = (zip_t *) zip_drives[id].priv;
zip_disk_reload(dev);
if (wcslen(zip_drives[id].image_path) == 0) {
ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
ui_sb_update_icon_state(SB_ZIP|id, 1);

View File

@@ -8,7 +8,7 @@
*
* Implement the application's Status Bar.
*
* Version: @(#)win_stbar.c 1.0.22 2018/10/19
* Version: @(#)win_stbar.c 1.0.23 2018/10/26
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -777,10 +777,12 @@ ui_sb_mount_floppy_img(uint8_t id, int part, uint8_t wp, wchar_t *file_name)
void
ui_sb_mount_zip_img(uint8_t id, int part, uint8_t wp, wchar_t *file_name)
{
zip_disk_close(zip[id]);
zip_t *dev = (zip_t *) zip_drives[id].priv;
zip_disk_close(dev);
zip_drives[id].ui_writeprot = wp;
zip_load(zip[id], file_name);
zip_insert(zip[id]);
zip_load(dev, file_name);
zip_insert(dev);
if (sb_ready) {
ui_sb_update_icon_state(SB_ZIP | id, wcslen(zip_drives[id].image_path) ? 0 : 1);
EnableMenuItem(sb_menu_handles[part], IDM_ZIP_EJECT | id, MF_BYCOMMAND | (wcslen(zip_drives[id].image_path) ? MF_ENABLED : MF_GRAYED));
@@ -914,7 +916,7 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
cdrom_image_open(&(cdrom[id]), temp_path);
/* Signal media change to the emulated machine. */
if (cdrom[id].insert)
cdrom[id].insert(cdrom[id].p);
cdrom[id].insert(cdrom[id].priv);
cdrom[id].host_drive = (wcslen(cdrom[id].image_path) == 0) ? 0 : 200;
if (cdrom[id].host_drive == 200) {
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_EMPTY | id, MF_UNCHECKED);