More general cleanups and bugfixes.
This commit is contained in:
@@ -70,12 +70,9 @@ uint8_t scsi_cdrom_drives[16][8] = { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } };
|
||||
|
||||
#ifdef __MSC__
|
||||
# pragma pack(push,1)
|
||||
|
||||
#pragma pack(push,1)
|
||||
static struct
|
||||
#else
|
||||
static struct __attribute__((__packed__))
|
||||
#endif
|
||||
{
|
||||
uint8_t opcode;
|
||||
uint8_t polled;
|
||||
@@ -85,24 +82,17 @@ static struct __attribute__((__packed__))
|
||||
uint16_t len;
|
||||
uint8_t control;
|
||||
} *gesn_cdb;
|
||||
#ifdef __MSC__
|
||||
# pragma pack(pop)
|
||||
#endif
|
||||
#pragma pack(pop)
|
||||
|
||||
#ifdef __MSC__
|
||||
# pragma pack(push,1)
|
||||
#pragma pack(push,1)
|
||||
static struct
|
||||
#else
|
||||
static struct __attribute__((__packed__))
|
||||
#endif
|
||||
{
|
||||
uint16_t len;
|
||||
uint8_t notification_class;
|
||||
uint8_t supported_events;
|
||||
} *gesn_event_header;
|
||||
#ifdef __MSC__
|
||||
# pragma pack(pop)
|
||||
#endif
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
/* Table of all SCSI commands and their flags, needed for the new disc change / not ready handler. */
|
||||
uint8_t cdrom_command_flags[0x100] =
|
||||
@@ -3989,24 +3979,41 @@ void cdrom_hard_reset(void)
|
||||
}
|
||||
}
|
||||
|
||||
void cdrom_general_init(void)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
#if 0
|
||||
/* Peform a master init on the entire module. */
|
||||
void
|
||||
cdrom_global_init(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
/* Clear the global data. */
|
||||
memset(cdrom, 0x00, sizeof(cdrom));
|
||||
memset(cdrom_drives, 0x00, sizeof(cdrom_drives));
|
||||
|
||||
/* Initialize the host devices, if any. */
|
||||
cdrom_init_host_drives();
|
||||
#endif
|
||||
|
||||
/* Set all drives to NULL mode. */
|
||||
for (c=0; c<CDROM_NUM; c++)
|
||||
cdrom_null_open(c, cdrom_drives[c].host_drive);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
cdrom_global_reset(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c=0; c<CDROM_NUM; c++) {
|
||||
if (cdrom_drives[c].bus_type) {
|
||||
SCSIReset(cdrom_drives[c].scsi_device_id, cdrom_drives[c].scsi_device_lun);
|
||||
}
|
||||
|
||||
pclog("CDROM global_reset drive=%d host=%02x\n", c, cdrom_drives[c].host_drive);
|
||||
if (cdrom_drives[c].host_drive == 200) {
|
||||
image_open(c, cdrom_image[c].image_path);
|
||||
} else
|
||||
if ((cdrom_drives[c].host_drive>='A') && (cdrom_drives[c].host_drive <= 'Z'))
|
||||
{
|
||||
if ((cdrom_drives[c].host_drive>='A') && (cdrom_drives[c].host_drive <= 'Z')) {
|
||||
ioctl_open(c, cdrom_drives[c].host_drive);
|
||||
} else {
|
||||
cdrom_null_open(c, cdrom_drives[c].host_drive);
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
* Implementation of the CD-ROM drive with SCSI(-like)
|
||||
* commands, for both ATAPI and SCSI usage.
|
||||
*
|
||||
* Version: @(#)cdrom.h 1.0.1 2017/06/03
|
||||
* Version: @(#)cdrom.h 1.0.2 2017/10/12
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2016-2017 Miran Grca.
|
||||
*
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
*/
|
||||
#ifndef EMU_CDROM_H
|
||||
#define EMU_CDROM_H
|
||||
@@ -41,6 +42,7 @@ typedef struct {
|
||||
int (*ready)(uint8_t id);
|
||||
int (*medium_changed)(uint8_t id);
|
||||
int (*media_type_id)(uint8_t id);
|
||||
|
||||
void (*audio_callback)(uint8_t id, int16_t *output, int len);
|
||||
void (*audio_stop)(uint8_t id);
|
||||
int (*readtoc)(uint8_t id, uint8_t *b, uint8_t starttrack, int msf, int maxlen, int single);
|
||||
@@ -61,7 +63,6 @@ typedef struct {
|
||||
void (*exit)(uint8_t id);
|
||||
} CDROM;
|
||||
|
||||
#pragma pack(push,1)
|
||||
typedef struct {
|
||||
uint8_t previous_command;
|
||||
|
||||
@@ -132,9 +133,7 @@ typedef struct {
|
||||
|
||||
int init_length;
|
||||
} cdrom_t;
|
||||
#pragma pack(pop)
|
||||
|
||||
#pragma pack(push,1)
|
||||
typedef struct {
|
||||
int max_blocks_at_once;
|
||||
|
||||
@@ -155,7 +154,6 @@ typedef struct {
|
||||
unsigned int sound_on;
|
||||
unsigned int atapi_dma;
|
||||
} cdrom_drive_t;
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct {
|
||||
int image_is_iso;
|
||||
@@ -229,14 +227,15 @@ int cdrom_lba_to_msf_accurate(int lba);
|
||||
}
|
||||
#endif
|
||||
|
||||
void cdrom_reset(uint8_t id);
|
||||
void cdrom_set_signature(int id);
|
||||
void cdrom_request_sense_for_scsi(uint8_t id, uint8_t *buffer, uint8_t alloc_length);
|
||||
void cdrom_update_cdb(uint8_t *cdb, int lba_pos, int number_of_blocks);
|
||||
void cdrom_insert(uint8_t id);
|
||||
extern void cdrom_close(uint8_t id);
|
||||
extern void cdrom_reset(uint8_t id);
|
||||
extern void cdrom_set_signature(int id);
|
||||
extern void cdrom_request_sense_for_scsi(uint8_t id, uint8_t *buffer, uint8_t alloc_length);
|
||||
extern void cdrom_update_cdb(uint8_t *cdb, int lba_pos, int number_of_blocks);
|
||||
extern void cdrom_insert(uint8_t id);
|
||||
|
||||
int find_cdrom_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun);
|
||||
int cdrom_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t *len);
|
||||
extern int find_cdrom_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun);
|
||||
extern int cdrom_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t *len);
|
||||
|
||||
#define cdrom_sense_error cdrom[id].sense[0]
|
||||
#define cdrom_sense_key cdrom[id].sense[2]
|
||||
@@ -244,9 +243,9 @@ int cdrom_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t *len
|
||||
#define cdrom_ascq cdrom[id].sense[13]
|
||||
#define cdrom_drive cdrom_drives[id].host_drive
|
||||
|
||||
extern void cdrom_close(uint8_t id);
|
||||
extern void cdrom_global_init(void);
|
||||
extern void cdrom_global_reset(void);
|
||||
extern void cdrom_hard_reset(void);
|
||||
extern void cdrom_general_init(void);
|
||||
|
||||
|
||||
#endif /*EMU_CDROM_H*/
|
||||
|
||||
@@ -991,7 +991,7 @@ int image_open(uint8_t id, wchar_t *fn)
|
||||
|
||||
if (!cdrom_image[id].image_inited || cdrom_image[id].image_changed)
|
||||
{
|
||||
swprintf(cdrom_image[id].image_path, sizeof(cdrom_image[id].image_path)/sizeof(wchar_t), L"%ws", fn);
|
||||
swprintf(cdrom_image[id].image_path, sizeof(cdrom_image[id].image_path)/sizeof(wchar_t), L"%S", fn);
|
||||
}
|
||||
|
||||
if (! wcscasecmp(get_extension_w(fn), L"ISO"))
|
||||
|
||||
Reference in New Issue
Block a user