⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scsi.h

📁 早期freebsd实现
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 1992, 1993 *	The Regents of the University of California.  All rights reserved. * * This code is derived from software contributed to Berkeley by * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * *	@(#)scsi.h	8.1 (Berkeley) 6/10/93 * * scsi.h -- * *	Common declarations for SCSI command formaters. This file only covers *	definitions pertaining to the SCSI common command set that are *	common to all SCSI device types (ie disk, tapes, WORM, printers, etc). *	Some of the references from the proceedings of the *	1984 Mini/Micro Northeast conference might help in understanding SCSI.  * * from: $Header: /sprite/src/kernel/dev/RCS/scsi.h, *	v 9.1 90/02/13 23:11:24 jhh Exp $ SPRITE (Berkeley) */#ifndef _SCSI_H#define _SCSI_H/* * "Standard" SCSI Commands. * SCSI commands are divided into 8 groups as follows: *	Group0	(0x00 - 0x1f).	Basic commands. 6 bytes long *	Group1	(0x20 - 0x3f).	Extended command. 10 bytes. *	Group2	(0x40 - 0x5f).	Reserved. *	Group2	(0x60 - 0x7f).	Reserved. *	Group2	(0x80 - 0x9f).	Reserved. *	Group2	(0xa0 - 0xbf).	Reserved. *	Group6	(0xc0 - 0xdf).	Vendor Unique *	Group7	(0xe0 - 0xff).	Vendor Unique *//* * Scsi Group0 commands all are 6 bytes and have a format according to  * struct ScsiGroup0Cmd. */#define SCSI_TEST_UNIT_READY	0x00#define SCSI_REZERO_UNIT	0x01#define SCSI_REWIND		0x01#define SCSI_REQUEST_SENSE	0x03#define	SCSI_FORMAT_UNIT	0x04#define	SCSI_READ_BLOCK_LIMITS	0x05#define SCSI_REASSIGN_BLOCKS	0x07#define SCSI_READ		0x08#define SCSI_WRITE		0x0a#define SCSI_SEEK		0x0b#define	SCSI_TRACK_SELECT	0x0b#define	SCSI_READ_REVERSE	0x0f#define SCSI_WRITE_EOF		0x10#define SCSI_SPACE		0x11#define SCSI_INQUIRY		0x12#define SCSI_VERIFY		0x13#define	SCSI_READ_BUFFER	0x14#define SCSI_MODE_SELECT	0x15#define	SCSI_RESERVE_UNIT	0x16#define	SCSI_RELEASE_UNIT	0x17#define SCSI_COPY		0x18#define SCSI_ERASE_TAPE		0x19#define SCSI_MODE_SENSE		0x1a#define SCSI_START_STOP		0x1b#define	SCSI_LOAD_UNLOAD	0x1b#define	SCSI_RECV_DIAG_RESULTS	0x1c#define SCSI_SEND_DIAGNOSTIC	0x1d#define SCSI_PREVENT_ALLOW	0x1e/* * Group1 commands are all 10 bytes and have a format according to * struct ScsiGroup1Cmd. */#define SCSI_READ_CAPACITY	0x25	#define	SCSI_READ_EXT		0x28#define	SCSI_WRITE_EXT		0x2a#define	SCSI_SEEK_EXT		0x2b#define	SCSI_WRITE_VERIFY	0x2e#define	SCSI_VERIFY_EXT		0x2f#define	SCSI_SEARCH_HIGH	0x30#define SCSI_SEARCH_EQUAL	0x31#define	SCSI_SEARCH_LOW		0x32#define	SCSI_SET_LIMITS		0x33#define	SCSI_COMPARE		0x39#define	SCSI_COPY_VERIFY	0x3a/* * Control byte flags for Group0 and Group1 commands. * * SCSI_CTRL_LINK - This is used to prevent a bus free phase between commands. *	If the command terminates successfully, a SCSI_LINKED_CMD_COMPLETE *	message is returned instead of the normal SCSI_COMMAND_COMPLETE message. *	The last command in a chain should not have this bit set *	(and consequently gets a normal SCSI_COMMAND_COMPLETE message). * SCSI_CTRL_LINK_FLAG - This bit should only set when SCSI_CTRL_LINK is set and *	causes a SCSI_LINKED_FLAGED_CMD_COMPLETE to be returned instead of *	a SCSI_LINKED_CMD_COMPLETE. */#define SCSI_CTRL_LINK		0x01	/* Link commands (no bus free phase) */#define SCSI_CTRL_LINK_INTR	0x02	/* Interrupt after linked command *//* * The standard group0 6-byte SCSI control block.  Note that the  * fields between highAddr and blockCount inclusive are command dependent. * The definitions Addr and BlockCount cover most of the commands we will * use. */typedef struct ScsiGroup0Cmd {	u_char	command;		/* command code, defined below.  The					 * upper three bits of this are zero					 * to indicate the control block is					 * only 6 bytes long */#if BYTE_ORDER == BIG_ENDIAN	u_char	unitNumber	:3;	/* Logical Unit (LUN) to which to					 * pass the command.  The device					 * has already been selected using					 * the "targetID" bit. */	u_char	highAddr	:5;	/* High bits of address */#else	u_char	highAddr	:5;	/* High bits of address */	u_char	unitNumber	:3;	/* Logical Unit (LUN) to which to					 * pass the command.  The device					 * has already been selected using					 * the "targetID" bit. */#endif	u_char	midAddr;		/* Middle bits of address */	u_char	lowAddr;		/* Low bits of address */	u_char	blockCount;		/* Blocks to transfer */	u_char	control;		/* See flags for common bits */} ScsiGroup0Cmd;/* * Format of a SCSI_START_STOP command. This is a group 0 command, but * the command contents are different. */typedef struct ScsiStartStopCmd {#if BYTE_ORDER == BIG_ENDIAN	u_char	command;		/* command code, defined below.  The					 * upper three bits of this are zero					 * to indicate the control block is					 * only 6 bytes long */	u_char	unitNumber	:3;	/* Logical Unit (LUN) to which to					 * pass the command.  The device					 * has already been selected using					 * the "targetID" bit. */	u_char	pad1		:4;	/* Reserved */	u_char	immed		:1;	/* Immediate status bit */	u_char	pad2;			/* Reserved */	u_char	pad3;			/* Reserved */	u_char	pad4		:6;	/* Reserved */	u_char	loadEject	:1;	/* Load or eject medium */	u_char	start		:1;	/* Start or stop medium */	u_char	control;		/* See flags for common bits */#else	u_char	command;		/* command code, defined below.  The					 * upper three bits of this are zero					 * to indicate the control block is					 * only 6 bytes long */	u_char	immed		:1;	/* Immediate status bit */	u_char	pad1		:4;	/* Reserved */	u_char	unitNumber	:3;	/* Logical Unit (LUN) to which to					 * pass the command.  The device					 * has already been selected using					 * the "targetID" bit. */	u_char	pad2;			/* Reserved */	u_char	pad3;			/* Reserved */	u_char	start		:1;	/* Start or stop medium */	u_char	loadEject	:1;	/* Load or eject medium */	u_char	pad4		:6;	/* Reserved */	u_char	control;		/* See flags for common bits */#endif} ScsiStartStopCmd;/* * The standard group1 10-byte SCSI control block.  Note that the  * fields between highAddr and blockCount inclusive are command dependent. * The definitions Addr and BlockCount cover most of the commands we will * use. */typedef struct ScsiGroup1Cmd {	u_char	command;		/* command code, defined below.  The					 * upper three bits of this are zero					 * to indicate the control block is					 * only 6 bytes long */#if BYTE_ORDER == BIG_ENDIAN	u_char	unitNumber	:3;	/* Logical Unit (LUN) to which to					 * pass the command.  The device					 * has already been selected using					 * the "targetID" bit. */	u_char	pad1		:5;	/* Reserved */#else	u_char	pad1		:5;	/* Reserved */	u_char	unitNumber	:3;	/* Logical Unit (LUN) to which to					 * pass the command.  The device					 * has already been selected using					 * the "targetID" bit. */#endif	u_char	highAddr;		/* High bits of address */	u_char	midHighAddr;		/* Middle high bits of address */	u_char	midLowAddr;		/* Middle low bits of address */	u_char	lowAddr;		/* Low bits of address */	u_char	pad2;			/* Reserved */	u_char	highBlockCount;	/* High bits of blocks to transfer */	u_char	lowBlockCount;	/* Low bits of blocks to transfer */	u_char	control;		/* See flags for common bits */} ScsiGroup1Cmd;/* * SCSI status completion information. * This is returned by the device when a command completes.  */#define	SCSI_STATUS_CHECKCOND	0x02	/* Check Condition (ie., read sense) */#define	SCSI_STATUS_CONDMET	0x04	/* Condition Met (ie., search worked) */#define	SCSI_STATUS_BUSY	0x08#define	SCSI_STATUS_INTERMED	0x10	/* Intermediate status sent */#define	SCSI_STATUS_EXT		0x80	/* Extended status valid *//* * Sense information provided after some errors.  This is divided into * two kinds, classes 0-6, and class 7.  This is 30 bytes big to allow * for the drive specific sense bytes that follow the standard 4 byte header. * * For extended sense, this buffer may be cast into another type.  Also * The actual size of the sense data returned is used to detect what * kind of tape drive is out there.  Kludgy, but true. */typedef struct ScsiClass0Sense {#if BYTE_ORDER == BIG_ENDIAN	u_char	valid		:1;	/* Sense data is valid */	u_char	error		:7;	/* 3 bits class and 4 bits code */#else	u_char	error		:7;	/* 3 bits class and 4 bits code */	u_char	valid		:1;	/* Sense data is valid */#endif	u_char	highAddr;		/* High byte of block address */	u_char	midAddr;		/* Middle byte of block address */	u_char	lowAddr;		/* Low byte of block address */	u_char	sense[26];		/* Target specific sense data */} ScsiClass0Sense;/* * Definitions for errors in the sense data.  The error field is specified * as a 3 bit class and 4 bit code, but it is easier to treat it as a * single 7 bit field. */#define SCSI_NO_SENSE_DATA		0x00#define SCSI_NOT_READY			0x04#define SCSI_NOT_LOADED			0x09#define SCSI_INSUF_CAPACITY		0x0a#define SCSI_HARD_DATA_ERROR		0x11#define SCSI_WRITE_PROTECT		0x17

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -