2020-04-01 19:04:53 +02:00
|
|
|
/*
|
|
|
|
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
|
|
|
|
* running old operating systems and software designed for IBM
|
|
|
|
|
* PC systems and compatibles from 1981 through fairly recent
|
|
|
|
|
* system designs based on the PCI bus.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of the 86Box distribution.
|
|
|
|
|
*
|
|
|
|
|
* Implementation of a generic Magneto-Optical Disk drive
|
|
|
|
|
* commands, for both ATAPI and SCSI usage.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Authors: Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
|
|
|
|
* Miran Grca, <mgrca8@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2020 Miran Grca.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-02-18 19:42:21 -05:00
|
|
|
#ifndef EMU_MO_H
|
|
|
|
|
# define EMU_MO_H
|
2020-04-01 19:04:53 +02:00
|
|
|
|
|
|
|
|
#define MO_NUM 4
|
|
|
|
|
|
|
|
|
|
#define BUF_SIZE 32768
|
|
|
|
|
|
|
|
|
|
#define MO_TIME 10.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
uint32_t sectors;
|
|
|
|
|
uint16_t bytes_per_sector;
|
|
|
|
|
} mo_type_t;
|
|
|
|
|
|
|
|
|
|
#define KNOWN_MO_TYPES 10
|
|
|
|
|
static const mo_type_t mo_types[KNOWN_MO_TYPES] = {
|
|
|
|
|
// 3.5" standard M.O. disks
|
2020-07-19 17:49:58 +02:00
|
|
|
{ 248826, 512 },
|
|
|
|
|
{ 446325, 512 },
|
|
|
|
|
{ 1041500, 512 },
|
|
|
|
|
{ 310352, 2048 },
|
|
|
|
|
{ 605846, 2048 },
|
|
|
|
|
{ 1063146, 2048 },
|
2020-04-01 19:04:53 +02:00
|
|
|
// 5.25" M.O. disks
|
2020-07-19 17:49:58 +02:00
|
|
|
{573624, 512 },
|
|
|
|
|
{314568, 1024 },
|
|
|
|
|
{904995, 512 },
|
|
|
|
|
{637041, 1024 },
|
2020-04-01 19:04:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2022-01-06 20:35:01 +06:00
|
|
|
const char vendor[9];
|
2020-07-19 17:49:58 +02:00
|
|
|
const char model[16];
|
2020-07-24 20:57:38 +02:00
|
|
|
const char revision[5];
|
2020-04-01 19:04:53 +02:00
|
|
|
int8_t supported_media[KNOWN_MO_TYPES];
|
|
|
|
|
} mo_drive_type_t;
|
|
|
|
|
|
2020-07-15 09:03:30 +08:00
|
|
|
#define KNOWN_MO_DRIVE_TYPES 22
|
|
|
|
|
static const mo_drive_type_t mo_drive_types[KNOWN_MO_DRIVE_TYPES] = {
|
2020-04-01 19:04:53 +02:00
|
|
|
{"86BOX", "MAGNETO OPTICAL", "1.00",{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}},
|
|
|
|
|
{"FUJITSU", "M2512A", "1314",{1, 1, 0, 0, 0, 0, 0, 0, 0}},
|
|
|
|
|
{"FUJITSU", "M2513-MCC3064SS", "1.00",{1, 1, 1, 1, 0, 0, 0, 0, 0, 0}},
|
|
|
|
|
{"FUJITSU", "MCE3130SS", "0070",{1, 1, 1, 1, 1, 0, 0, 0, 0, 0}},
|
|
|
|
|
{"FUJITSU", "MCF3064SS", "0030",{1, 1, 1, 1, 0, 0, 0, 0, 0, 0}},
|
|
|
|
|
{"FUJITSU", "MCJ3230UB-S", "0040",{1, 1, 1, 1, 1, 1, 0, 0, 0, 0}},
|
|
|
|
|
{"HP", "S6300.65", "1.00",{0, 0, 0, 0, 0, 0, 1, 1, 0, 0}},
|
|
|
|
|
{"HP", "C1716C", "1.00",{0, 0, 0, 0, 0, 0, 1, 1, 0, 1}},
|
|
|
|
|
{"IBM", "0632AAA", "1.00",{0, 0, 0, 0, 0, 0, 1, 1, 0, 0}},
|
|
|
|
|
{"IBM", "0632CHC", "1.00",{0, 0, 0, 0, 0, 0, 1, 1, 0, 1}},
|
|
|
|
|
{"IBM", "0632CHX", "1.00",{0, 0, 0, 0, 0, 0, 1, 1, 0, 1}},
|
|
|
|
|
{"IBM", "MD3125A", "1.00",{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
|
|
|
|
{"IBM", "MD3125B", "1.00",{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
|
|
|
|
{"IBM", "MTA-3127", "1.00",{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
|
|
|
|
{"IBM", "MTA-3230", "1.00",{1, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
|
|
|
|
|
{"MATSHITA", "LF-3000", "1.00",{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
|
|
|
|
{"MOST", "RMD-5100", "1.00",{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
|
|
|
|
{"RICOH", "RO-5031E", "1.00",{0, 0, 0, 0, 0, 0, 1, 1, 0, 0}},
|
|
|
|
|
{"SONY", "SMO-C301", "1.00",{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
|
|
|
|
{"SONY", "SMO-C501", "1.00",{0, 0, 0, 0, 0, 0, 1, 1, 0, 0}},
|
|
|
|
|
{"TEAC", "OD-3000", "1.00",{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
|
|
|
|
{"TOSHIBA", "OD-D300", "1.00",{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
MO_BUS_DISABLED = 0,
|
PIC rewrite, proper SMRAM API, complete SiS 471 rewrite and addition of 40x, 460, and 461, changes to mem.c/h, disabled Voodoo memory dumping on exit, bumped SDL Hardware scale quality to 2, bumped IDE/ATAPI drives to ATA-6, finally bumped emulator version to 3.0, redid the bus type ID's to allow for planned ATAPI hard disks, made SST flash set its high mappings to the correct address if the CPU is 16-bit, and added the SiS 401 AMI 486 Clone, AOpen Vi15G, and the Soyo 4SA2 (486 with SiS 496/497 that can boot from CD-ROM), assorted 286+ protected mode fixes (for slightly more accuracy), and fixes to 808x emulation (MS Word 1.0 and 1.10 for DOS now work correctly from floppy).
2020-10-14 23:15:01 +02:00
|
|
|
MO_BUS_ATAPI = 5,
|
2020-04-01 19:04:53 +02:00
|
|
|
MO_BUS_SCSI,
|
|
|
|
|
MO_BUS_USB
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2020-11-16 00:01:21 +01:00
|
|
|
uint8_t id;
|
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
uint8_t res, res0, /* Reserved for other ID's. */
|
|
|
|
|
res1,
|
|
|
|
|
ide_channel, scsi_device_id;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
uint8_t bus_type, /* 0 = ATAPI, 1 = SCSI */
|
2020-04-01 19:04:53 +02:00
|
|
|
bus_mode, /* Bit 0 = PIO suported;
|
|
|
|
|
Bit 1 = DMA supportd. */
|
|
|
|
|
read_only, /* Struct variable reserved for
|
|
|
|
|
media status. */
|
|
|
|
|
pad, pad0;
|
|
|
|
|
|
|
|
|
|
FILE *f;
|
2020-07-19 06:07:58 +02:00
|
|
|
void *priv;
|
2020-04-01 19:04:53 +02:00
|
|
|
|
2021-03-14 20:35:01 +01:00
|
|
|
char image_path[1024],
|
2020-04-01 19:04:53 +02:00
|
|
|
prev_image_path[1024];
|
2020-07-19 06:07:58 +02:00
|
|
|
|
|
|
|
|
uint32_t type, medium_size,
|
|
|
|
|
base;
|
|
|
|
|
uint16_t sector_size;
|
|
|
|
|
|
2020-04-01 19:04:53 +02:00
|
|
|
} mo_drive_t;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2020-07-15 09:03:30 +08:00
|
|
|
mode_sense_pages_t ms_pages_saved;
|
2020-04-01 19:04:53 +02:00
|
|
|
|
2020-07-15 09:03:30 +08:00
|
|
|
mo_drive_t *drv;
|
2020-04-01 19:04:53 +02:00
|
|
|
|
2020-07-15 09:03:30 +08:00
|
|
|
uint8_t *buffer,
|
|
|
|
|
atapi_cdb[16],
|
|
|
|
|
current_cdb[16],
|
|
|
|
|
sense[256];
|
2020-04-01 19:04:53 +02:00
|
|
|
|
2020-07-15 09:03:30 +08:00
|
|
|
uint8_t status, phase,
|
|
|
|
|
error, id,
|
2021-03-23 06:32:18 +01:00
|
|
|
features, cur_lun,
|
|
|
|
|
pad0, pad1;
|
2020-04-01 19:04:53 +02:00
|
|
|
|
2020-07-15 09:03:30 +08:00
|
|
|
uint16_t request_length, max_transfer_len;
|
2020-04-01 19:04:53 +02:00
|
|
|
|
2020-07-15 09:03:30 +08:00
|
|
|
int requested_blocks, packet_status,
|
2020-07-19 06:07:58 +02:00
|
|
|
total_length, do_page_save,
|
|
|
|
|
unit_attention, request_pos,
|
|
|
|
|
old_len, pad3;
|
2020-04-01 19:04:53 +02:00
|
|
|
|
2020-07-15 09:03:30 +08:00
|
|
|
uint32_t sector_pos, sector_len,
|
|
|
|
|
packet_len, pos;
|
2020-04-01 19:04:53 +02:00
|
|
|
|
2020-07-15 09:03:30 +08:00
|
|
|
double callback;
|
2020-04-01 19:04:53 +02:00
|
|
|
} mo_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern mo_t *mo[MO_NUM];
|
|
|
|
|
extern mo_drive_t mo_drives[MO_NUM];
|
|
|
|
|
extern uint8_t atapi_mo_drives[8];
|
|
|
|
|
extern uint8_t scsi_mo_drives[16];
|
|
|
|
|
|
|
|
|
|
#define mo_sense_error dev->sense[0]
|
|
|
|
|
#define mo_sense_key dev->sense[2]
|
|
|
|
|
#define mo_asc dev->sense[12]
|
|
|
|
|
#define mo_ascq dev->sense[13]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
extern void mo_disk_close(mo_t *dev);
|
|
|
|
|
extern void mo_disk_reload(mo_t *dev);
|
|
|
|
|
extern void mo_insert(mo_t *dev);
|
|
|
|
|
|
|
|
|
|
extern void mo_global_init(void);
|
|
|
|
|
extern void mo_hard_reset(void);
|
|
|
|
|
|
|
|
|
|
extern void mo_reset(scsi_common_t *sc);
|
2021-03-14 20:35:01 +01:00
|
|
|
extern int mo_load(mo_t *dev, char *fn);
|
2020-04-01 19:04:53 +02:00
|
|
|
extern void mo_close();
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /*EMU_MO_H*/
|