1 /* $Id: scsi-msg.h,v 1.3 2007/01/08 00:03:25 fredette Exp $ */
2 
3 /* tme/scsi/scsi-msg.h - header file describing SCSI messages: */
4 
5 /*
6  * Copyright (c) 2003 Matt Fredette
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by Matt Fredette.
20  * 4. The name of the author may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef _TME_SCSI_SCSI_MSG_H
37 #define _TME_SCSI_SCSI_MSG_H
38 
39 #include <tme/common.h>
40 _TME_RCSID("$Id: scsi-msg.h,v 1.3 2007/01/08 00:03:25 fredette Exp $");
41 
42 /* includes: */
43 #include <tme/scsi/scsi-device.h>
44 
45 /* macros: */
46 
47 /* one-byte messages: */
48 #define TME_SCSI_MSG_CMD_COMPLETE		(0x00)
49 #define TME_SCSI_MSG_EXTENDED			(0x01)
50 #define TME_SCSI_MSG_SAVE_DATA_POINTER		(0x02)
51 #define TME_SCSI_MSG_RESTORE_POINTERS		(0x03)
52 #define TME_SCSI_MSG_DISCONNECT			(0x04)
53 #define TME_SCSI_MSG_INITIATOR_ERROR		(0x05)
54 #define TME_SCSI_MSG_ABORT			(0x06)
55 #define TME_SCSI_MSG_MESSAGE_REJECT		(0x07)
56 #define TME_SCSI_MSG_NOP			(0x08)
57 #define TME_SCSI_MSG_PARITY_ERROR		(0x09)
58 #define TME_SCSI_MSG_IDENTIFY			(0x80)
59 #define  TME_SCSI_MSG_IDENTIFY_DISCONNECT	(0x40)
60 #define  TME_SCSI_MSG_IDENTIFY_LUN_MASK		(0x07)
61 
62 /* extended messages: */
63 #define TME_SCSI_MSG_EXT_SDTR			(0x01)
64 
65 /* this evaluates to nonzero iff this is a one-byte message: */
66 #define TME_SCSI_MSG_IS_1(msg)			\
67   (((msg)					\
68     & TME_SCSI_MSG_IDENTIFY)			\
69    || ((msg) < 0x20				\
70        && (msg) != TME_SCSI_MSG_EXTENDED))
71 
72 /* this evaluates to nonzero iff this is a two-byte message: */
73 #define TME_SCSI_MSG_IS_2(msg)			\
74   (((msg) & 0xf0) == 0x20)
75 
76 /* prototypes: */
77 _TME_SCSI_DEVICE_MSG_P(tme_scsi_device_msg_cmd_complete);
78 _TME_SCSI_DEVICE_MSG_P(tme_scsi_device_msg_save_data_pointer);
79 _TME_SCSI_DEVICE_MSG_P(tme_scsi_device_msg_restore_pointers);
80 _TME_SCSI_DEVICE_MSG_P(tme_scsi_device_msg_disconnect);
81 _TME_SCSI_DEVICE_MSG_P(tme_scsi_device_msg_initiator_error);
82 _TME_SCSI_DEVICE_MSG_P(tme_scsi_device_msg_abort);
83 _TME_SCSI_DEVICE_MSG_P(tme_scsi_device_msg_message_reject);
84 _TME_SCSI_DEVICE_MSG_P(tme_scsi_device_msg_nop);
85 _TME_SCSI_DEVICE_MSG_P(tme_scsi_device_msg_parity_error);
86 _TME_SCSI_DEVICE_MSG_P(tme_scsi_device_msg_identify);
87 _TME_SCSI_DEVICE_MSG_P(tme_scsi_device_msg_target_reject);
88 
89 #endif /* !_TME_SCSI_SCSI_MSG_H */
90