1/*	$NetBSD: iris_scsicmd.h,v 1.1 2019/01/12 16:44:47 tsutsui Exp $	*/
2
3/*
4 * Copyright (c) 2018 Naruaki Etomi
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28/*
29 * Silicon Graphics "IRIS" series MIPS processors machine bootloader.
30 */
31
32/*
33 * scsipi_xfer status flags
34 */
35#define XS_STS_DONE		0x00000001
36
37/* SCSI Commands */
38#define CMD_TEST_UNIT_READY		0x00
39#define CMD_REQUEST_SENSE		0x03
40#define CMD_INQUIRY			0x12
41#define CMD_SEND_DIAGNOSTIC		0x1D
42
43#define CMD_REWIND			0x01
44#define CMD_REZERO			0x01
45#define CMD_FORMAT_UNIT			0x04
46#define CMD_READ_BLOCK_LIMITS		0x05
47#define CMD_REASSIGN_BLOCKS		0x07
48#define CMD_READ			0x08
49#define CMD_WRITE			0x0A
50#define CMD_WRITE_FILEMARK		0x10
51#define CMD_SPACE			0x11
52#define CMD_MODE_SELECT			0x15
53#define CMD_RELEASE_UNIT		0x17
54#define CMD_ERASE			0x19
55#define CMD_MODE_SENSE			0x1A
56#define CMD_LOADUNLOAD			0x1B
57#define CMD_RECEIVE_DIAG		0x1C
58#define CMD_SEND_DIAG			0x1D
59#define CMD_P_A_MEDIA_REMOVAL		0x1E
60#define CMD_READ_CAPACITY		0x25
61#define CMD_READ_EXT			0x28
62#define CMD_WRITE_EXT			0x2A
63#define CMD_READ_DEFECT_DATA		0x37
64#define 	SD_MANUFAC_DEFECTS	0x14000000
65#define 	SD_GROWN_DEFECTS	0x0c000000
66#define CMD_READ_BUFFER			0x3B
67#define CMD_WRITE_BUFFER		0x3C
68#define CMD_READ_FULL			0xF0
69#define CMD_MEDIA_TEST			0xF1
70#define CMD_ACCESS_LOG			0xF2
71#define CMD_WRITE_FULL			0xFC
72#define CMD_MANAGE_PRIMARY		0xFD
73#define CMD_EXECUTE_DATA		0xFE
74
75/* command descriptor blocks */
76
77struct scsi_cdb6 {
78	uint8_t	cmd;		/* command code */
79	uint8_t	lun:  3,	/* logical unit on ctlr */
80		lbah: 5;	/* msb of read/write logical block addr */
81	uint8_t	lbam;		/* middle byte of l.b.a. */
82	uint8_t	lbal;		/* lsb of l.b.a. */
83	uint8_t	len;		/* transfer length */
84	uint8_t	xtra;
85};
86
87struct scsi_cdb10 {
88	uint8_t	cmd;		/* command code */
89	uint8_t	lun: 3,		/* logical unit on ctlr */
90		   : 4,
91		rel: 1;		/* l.b.a. is relative addr if =1 */
92	uint8_t	lbah;		/* msb of read/write logical block addr */
93	uint8_t	lbahm;		/* high middle byte of l.b.a. */
94	uint8_t	lbalm;		/* low middle byte of l.b.a. */
95	uint8_t	lbal;		/* lsb of l.b.a. */
96	uint8_t	reserved;
97	uint8_t	lenh;		/* msb transfer length */
98	uint8_t	lenl;		/* lsb transfer length */
99	uint8_t	xtra;
100};
101