|
|
1.1 root 1: /*
1.1.1.3 root 2: Hatari - hdc.h
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
1.1 root 6:
1.1.1.4 ! root 7: This file contains definitions which are used for hardware-level
1.1.1.3 root 8: harddrive emulation.
1.1 root 9: */
10:
1.1.1.3 root 11: #ifndef HATARI_HDC_H
12: #define HATARI_HDC_H
13:
1.1 root 14:
15: /* HD Command packet macros */
16: #define HD_OPCODE(a) (a.command[0] & 0x1F) /* get opcode (bit 0-4) */
17: #define HD_CONTROLLER(a) ((a.command[0] & 0xE0)>>5) /* get HD controller # (5-7) */
18: #define HD_DRIVENUM(a) ((a.command[1] & 0xE0) >>5) /* get drive # (5-7) */
19:
20: #define HD_LBA_MSB(a) ((unsigned) a.command[1] & 0x1F) /* Logical Block adress, MSB */
21: #define HD_LBA_MID(a) ((unsigned) a.command[2]) /* Logical Block adress */
22: #define HD_LBA_LSB(a) ((unsigned) a.command[3]) /* Logical Block adress, LSB */
23:
24: #define HD_SECTORCOUNT(a) (a.command[4] & 0xFF) /* get sector count */
25: #define HD_CONTROL(a) (a.command[5] & 0xFF) /* get control byte */
26:
27:
28: /* Opcodes */
29: /* The following are multi-sector transfers with seek implied */
30: #define HD_VERIFY_TRACK 0x05 /* Verify track */
31: #define HD_FORMAT_TRACK 0x06 /* Format track */
32: #define HD_READ_SECTOR 0x08 /* Read sector */
33: #define HD_WRITE_SECTOR 0x0A /* Write sector */
34:
35: /* other codes */
1.1.1.4 ! root 36: #define HD_FORMAT_DRIVE 0x04 /* Format the whole drive */
1.1 root 37: #define HD_SEEK 0x0B /* Seek */
38: #define HD_CORRECTION 0x0D /* Correction */
39: #define HD_INQUIRY 0x12 /* Inquiry */
1.1.1.4 ! root 40: #define HD_MODESELECT 0x15 /* Mode select */
1.1 root 41: #define HD_MODESENSE 0x1A /* Mode sense */
42: #define HD_REQ_SENSE 0x03 /* Request sense */
43: #define HD_SHIP 0x1B /* Ship drive */
44:
1.1.1.4 ! root 45: /* Status codes */
! 46: #define HD_STATUS_OK 0x00
! 47: #define HD_STATUS_ERROR 0x02
! 48: #define HD_STATUS_BUSY 0x08
! 49:
! 50: /* Error codes for REQUEST SENSE: */
! 51: #define HD_REQSENS_OK 0x00 /* OK return status */
! 52: #define HD_REQSENS_OPCODE 0x20 /* Opcode not supported */
! 53: #define HD_REQSENS_INVADDR 0x21 /* Invalid block address */
! 54: #define HD_REQSENS_INVARG 0x24 /* Invalid argument */
! 55: #define HD_REQSENS_NODRIVE 0x25 /* Invalid drive */
! 56:
! 57: #define ACSI_EMU_ON bAcsiEmuOn /* Do we have HDC emulation? */
1.1 root 58:
59: /*
60: Structure representing an ACSI command block.
61: */
62: typedef struct {
63: int byteCount; /* count of number of command bytes written */
64: unsigned char command[6];
65: short int returnCode; /* return code from the HDC operation */
66: } HDCOMMAND;
67:
68: extern FILE *hd_image_file;
69: extern HDCOMMAND HDCCommand;
70: extern short int HDCSectorCount;
71: extern int nPartitions;
1.1.1.4 ! root 72: extern BOOL bAcsiEmuOn;
1.1 root 73:
1.1.1.2 root 74: extern BOOL HDC_Init(char *filename);
1.1.1.3 root 75: extern void HDC_UnInit(void);
76: extern void HDC_WriteCommandPacket(void);
77: extern void HDC_DebugCommandPacket(FILE *hdlogFile);
78: extern void HDC_EmulateCommandPacket(void);
79:
80: #endif /* HATARI_HDC_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.