commands.h revision 8a16ae8f6efb5a6c02ab0aec860e229706335bb9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_SCSI_IMPL_COMMANDS_H
#define _SYS_SCSI_IMPL_COMMANDS_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Implementation dependent command definitions.
* This file is included by <sys/scsi/generic/commands.h>
*/
/*
* Implementation dependent view of a SCSI command descriptor block
*/
/*
* Standard SCSI control blocks definitions.
*
* These go in or out over the SCSI bus.
*
* The first 8 bits of the command block are the same for all
* defined command groups. The first byte is an operation which consists
* of a command code component and a group code component.
*
* The group code determines the length of the rest of the command.
* Group 0 commands are 6 bytes, Group 1 and 2 are 10 bytes, Group 4
* are 16 bytes, and Group 5 are 12 bytes. Groups 3 is Reserved.
* Groups 6 and 7 are Vendor Unique.
*
*/
union scsi_cdb { /* scsi command description block */
struct {
#if defined(_BIT_FIELDS_LTOH)
#elif defined(_BIT_FIELDS_HTOL)
#else
#endif /* _BIT_FIELDS_LTOH */
union {
/*
* G R O U P 0 F O R M A T (6 bytes)
*/
/*
* defines for SCSI tape cdb.
*/
struct scsi_g0 {
#if defined(_BIT_FIELDS_LTOH)
#elif defined(_BIT_FIELDS_HTOL)
#else
#endif /* _BIT_FIELDS_LTOH */
} g0;
/*
* G R O U P 1, 2 F O R M A T (10 byte)
*/
struct scsi_g1 {
#if defined(_BIT_FIELDS_LTOH)
#elif defined(_BIT_FIELDS_HTOL)
#else
#endif /* _BIT_FIELDS_LTOH */
} g1;
/*
* G R O U P 4 F O R M A T (16 byte)
*/
struct scsi_g4 {
#if defined(_BIT_FIELDS_LTOH)
#elif defined(_BIT_FIELDS_HTOL)
#else
#endif /* _BIT_FIELDS_LTOH */
} g4;
/*
* G R O U P 5 F O R M A T (12 byte)
*/
struct scsi_g5 {
#if defined(_BIT_FIELDS_LTOH)
#elif defined(_BIT_FIELDS_HTOL)
#else
#endif /* _BIT_FIELDS_LTOH */
} g5;
}sg;
} cdb_un;
};
/*
* Various useful Macros for SCSI commands
*/
/*
* because the address to be read or written may not be on a proper alignment.
*/
#define SCSI_READ16(Sr16_Addr) \
#define SCSI_READ32(Sr32_Addr) \
#define SCSI_READ64(Sr64_Addr) \
/*
*/
(cdb)->g4_addtl_cdb_data3 = \
(cdb)->g4_addtl_cdb_data2 = \
(cdb)->g4_addtl_cdb_data1 = \
(cdb)->g4_addtl_cdb_data0 = \
(addr) & 0xFF
(addtl_cdb_data) >> 24; \
(cdb)->g4_addtl_cdb_data2 = \
(cdb)->g4_addtl_cdb_data1 = \
(cdb)->g4_addtl_cdb_data0 = \
(addtl_cdb_data) & 0xFF
((cdb)->scc5_addr0)
((cdb)->scc5_count0)
/*
* Shorthand macros for forming commands
*
* Works only with pre-SCSI-3 because they put lun as part of CDB.
* scsi_setup_cdb() is the recommended interface.
*/
/*
* Direct access disk format defines and parameters.
*
* This is still pretty ugly and is mostly derived
* from Emulex MD21 specific formatting.
*/
/*
* defines for value of fmt_parm_bits.
*/
/*
* Defines for value of defect_list_descrip.
*/
/*
* Disk defect list - used by format command.
*/
#define RDEF_ALL 0 /* read all defects */
#define ESDI_NDEFECT ST506_NDEFECT
struct scsi_bfi_defect { /* defect in bytes from index format */
unsigned cyl : 24;
unsigned head : 8;
int bytes_from_index;
};
struct scsi_format_params { /* BFI format list */
};
/*
* Defect list returned by READ_DEFECT_LIST command.
*/
struct scsi_defect_hdr { /* For getting defect list size */
};
struct scsi_defect_list { /* BFI format list */
};
/*
*
* Direct Access device Reassign Block parameter
*
* Defect list format used by reassign block command (logical block format).
*
* This defect list is limited to 1 defect, as that is the only way we use it.
*
*/
struct scsi_reassign_blk {
};
/*
* Direct Access Device Capacity Structure -- 8 byte version
*/
struct scsi_capacity {
};
/*
* Direct Access Device Capacity Structure -- 16 byte version
*/
struct scsi_capacity_16 {
#if defined(_BIT_FIELDS_LTOH)
#elif defined(_BIT_FIELDS_HTOL)
#else
#endif /* _BIT_FIELDS_LTOH */
};
#ifdef _KERNEL
/*
* Functional versions of the above macros, and other functions.
* the makecom functions have been deprecated. Please use
* scsi_setup_cdb()
*/
#ifdef __STDC__
#else /* __STDC__ */
extern void makecom_g0();
extern void makecom_g0_s();
extern void makecom_g1();
extern void makecom_g5();
extern int scsi_setup_cdb();
#endif /* __STDC__ */
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SCSI_IMPL_COMMANDS_H */