summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/scsi.h
blob: 7097cf38147c2897f05e8c5688afbaada55a6b06 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/***************************************************************************

 scsi.h - Header which defines the interface between SCSI device handlers
          and SCSI interfaces.

***************************************************************************/

#ifndef _SCSI_H_
#define _SCSI_H_

#include "driver.h"

typedef int (*pSCSIDispatch)( int operation, void *file, INT64 intparm, void *ptrparm );

typedef struct _SCSIClass
{
	struct _SCSIClass *baseClass;
	pSCSIDispatch dispatch;
	int sizeofData;
} SCSIClass;

typedef struct
{
	SCSIClass *scsiClass;
} SCSIInstance;

// commands accepted by a SCSI device's dispatch handler
enum
{
	SCSIOP_EXEC_COMMAND = 0,	// execute a command packet
	SCSIOP_SET_COMMAND,			// set a command packet
	SCSIOP_GET_COMMAND,			// get a command packet
	SCSIOP_READ_DATA,			// data transfer from the device
	SCSIOP_WRITE_DATA,			// data transfer to the device
	SCSIOP_ALLOC_INSTANCE,		// allocate an instance of the device
	SCSIOP_DELETE_INSTANCE,		// delete an instance of the device
	SCSIOP_GET_DEVICE,			// get the device's internal device (CDROM or HDD pointer)
	SCSIOP_SET_DEVICE,			// set the device's internal device (CDROM or HDD pointer)
	SCSIOP_RESET_DEVICE,		// reset the device
	SCSIOP_SET_PHASE,
	SCSIOP_GET_PHASE,
};

typedef struct scsiconfigitem
{
	int scsiID;
	int diskID;
	SCSIClass *scsiClass;
} SCSIConfigItem;

#define SCSI_MAX_DEVICES	(16)

typedef struct scsiconfigtable
{
	int devs_present;
	SCSIConfigItem devices[SCSI_MAX_DEVICES];
} SCSIConfigTable;

// SCSI IDs
enum
{
	SCSI_ID_0 = 0,
	SCSI_ID_1,
	SCSI_ID_2,
	SCSI_ID_3,
	SCSI_ID_4,
	SCSI_ID_5,
	SCSI_ID_6,
	SCSI_ID_7
};


#define SCSI_PHASE_DATAOUT ( 0 )
#define SCSI_PHASE_DATAIN ( 1 )
#define SCSI_PHASE_COMMAND ( 2 )
#define SCSI_PHASE_STATUS ( 3 )
#define SCSI_PHASE_MESSAGE_OUT ( 6 )
#define SCSI_PHASE_MESSAGE_IN ( 7 )

extern void SCSIAllocInstance( SCSIClass *scsiClass, SCSIInstance **instance, int diskId );
extern void SCSIDeleteInstance( SCSIInstance *instance );
extern void SCSISetDevice( SCSIInstance *instance, void *device );
extern void SCSIGetDevice( SCSIInstance *instance, void **device );
extern void SCSIReset( SCSIInstance *instance );
extern void SCSISetCommand( SCSIInstance *instance, UINT8 *command, int commandLength );
extern void SCSIGetCommand( SCSIInstance *instance, UINT8 **command, int *commandLength );
extern void SCSIExecCommand( SCSIInstance *instance, int *resultLength );
extern void SCSIWriteData( SCSIInstance *instance, void *data, int dataLength );
extern void SCSIReadData( SCSIInstance *instance, void *data, int dataLength );
extern void SCSISetPhase( SCSIInstance *instance, int phase );
extern void SCSIGetPhase( SCSIInstance *instance, int *phase );

extern SCSIInstance *SCSIMalloc( SCSIClass *scsiClass );
extern int SCSIBase( SCSIClass *scsiClass, int operation, void *file, INT64 intparm, UINT8 *ptrparm );
extern void *SCSIThis( SCSIClass *scsiClass, SCSIInstance *instance );
extern int SCSISizeof( SCSIClass *scsiClass );
extern int SCSILengthFromUINT8( UINT8 *length );
extern int SCSILengthFromUINT16( UINT8 *length );

#endif

// include these here to avoid changing the drivers.
#include "machine/scsicd.h"
#include "machine/scsihd.h"