1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SYS_1394_CMD1394_H 28*0Sstevel@tonic-gate #define _SYS_1394_CMD1394_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate /* 33*0Sstevel@tonic-gate * cmd1394.h 34*0Sstevel@tonic-gate * Contains the enums, command structures, and error codes used with 35*0Sstevel@tonic-gate * the 1394 Framework's t1394_read(), t1394_write(), and t1394_lock() 36*0Sstevel@tonic-gate * interfaces. 37*0Sstevel@tonic-gate * For outgoing (Asynchronous Transmit - AT) commands, target drivers 38*0Sstevel@tonic-gate * allocate a command using t1394_alloc_cmd(), fill it in with the 39*0Sstevel@tonic-gate * transmit info, and send it using one of t1394_read(), t1394_write(), 40*0Sstevel@tonic-gate * of t1394_lock(). 41*0Sstevel@tonic-gate * The target driver can choose whether to get a callback when the 42*0Sstevel@tonic-gate * command completes, block until it completes, or poll on the return 43*0Sstevel@tonic-gate * status in the command. 44*0Sstevel@tonic-gate * For incoming (Asynchronous Receive - AR) requests, the same command 45*0Sstevel@tonic-gate * structure is used and most of the information has the same or a 46*0Sstevel@tonic-gate * similar meaning to what it does on the AT side. The major differences 47*0Sstevel@tonic-gate * are that nodeID indicates the node from which the command was sent 48*0Sstevel@tonic-gate * and broadcast informs a target driver whether the incoming request 49*0Sstevel@tonic-gate * was broadcast to everyone. 50*0Sstevel@tonic-gate */ 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate #include <sys/types.h> 53*0Sstevel@tonic-gate #include <sys/stream.h> 54*0Sstevel@tonic-gate #include <sys/note.h> 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate #include <sys/1394/s1394_impl.h> 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate #ifdef __cplusplus 59*0Sstevel@tonic-gate extern "C" { 60*0Sstevel@tonic-gate #endif 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate /* 63*0Sstevel@tonic-gate * cmd1394_cmd.cmd_type 64*0Sstevel@tonic-gate * Used to select/indicate the request packet type 65*0Sstevel@tonic-gate */ 66*0Sstevel@tonic-gate typedef enum { 67*0Sstevel@tonic-gate CMD1394_ASYNCH_RD_QUAD = 0, 68*0Sstevel@tonic-gate CMD1394_ASYNCH_WR_QUAD = 1, 69*0Sstevel@tonic-gate CMD1394_ASYNCH_RD_BLOCK = 2, 70*0Sstevel@tonic-gate CMD1394_ASYNCH_WR_BLOCK = 3, 71*0Sstevel@tonic-gate CMD1394_ASYNCH_LOCK_32 = 4, 72*0Sstevel@tonic-gate CMD1394_ASYNCH_LOCK_64 = 5 73*0Sstevel@tonic-gate } cmd1394_cmd_type_t; 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate /* 76*0Sstevel@tonic-gate * cmd1394_cmd.flags 77*0Sstevel@tonic-gate * Used to select the request's behavior, including 78*0Sstevel@tonic-gate * how the destination address is determined, how 79*0Sstevel@tonic-gate * a large request will be broken into smaller requests, 80*0Sstevel@tonic-gate * whether the command should be resent after a 81*0Sstevel@tonic-gate * bus reset has happened, etc. 82*0Sstevel@tonic-gate */ 83*0Sstevel@tonic-gate typedef enum { 84*0Sstevel@tonic-gate CMD1394_CANCEL_ON_BUS_RESET = (1 << 0), 85*0Sstevel@tonic-gate CMD1394_OVERRIDE_ADDR = (1 << 1), 86*0Sstevel@tonic-gate CMD1394_OVERRIDE_MAX_PAYLOAD = (1 << 2), 87*0Sstevel@tonic-gate CMD1394_DISABLE_ADDR_INCREMENT = (1 << 3), 88*0Sstevel@tonic-gate CMD1394_BLOCKING = (1 << 4), 89*0Sstevel@tonic-gate CMD1394_OVERRIDE_SPEED = (1 << 5) 90*0Sstevel@tonic-gate } cmd1394_flags_t; 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate /* 93*0Sstevel@tonic-gate * cmd1394_cmd.arg.l.lock_type 94*0Sstevel@tonic-gate * Used to select/indicate the type of lock operation 95*0Sstevel@tonic-gate * in the request. Some are supported by the 1394 spec 96*0Sstevel@tonic-gate * others (0x10000+) are supported locally in software. 97*0Sstevel@tonic-gate */ 98*0Sstevel@tonic-gate typedef enum { 99*0Sstevel@tonic-gate /* Reserved = 0x0000 */ 100*0Sstevel@tonic-gate CMD1394_LOCK_MASK_SWAP = 0x0001, 101*0Sstevel@tonic-gate CMD1394_LOCK_COMPARE_SWAP = 0x0002, 102*0Sstevel@tonic-gate CMD1394_LOCK_FETCH_ADD = 0x0003, 103*0Sstevel@tonic-gate CMD1394_LOCK_LITTLE_ADD = 0x0004, 104*0Sstevel@tonic-gate CMD1394_LOCK_BOUNDED_ADD = 0x0005, 105*0Sstevel@tonic-gate CMD1394_LOCK_WRAP_ADD = 0x0006, 106*0Sstevel@tonic-gate /* Vendor-Defined = 0x0007 */ 107*0Sstevel@tonic-gate /* Reserved = 0x0008 - 0xFFFF */ 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gate CMD1394_LOCK_BIT_AND = 0x10000, 110*0Sstevel@tonic-gate CMD1394_LOCK_BIT_OR = 0x10001, 111*0Sstevel@tonic-gate CMD1394_LOCK_BIT_XOR = 0x10002, 112*0Sstevel@tonic-gate CMD1394_LOCK_INCREMENT = 0x10003, 113*0Sstevel@tonic-gate CMD1394_LOCK_DECREMENT = 0x10004, 114*0Sstevel@tonic-gate CMD1394_LOCK_ADD = 0x10005, 115*0Sstevel@tonic-gate CMD1394_LOCK_SUBTRACT = 0x10006, 116*0Sstevel@tonic-gate CMD1394_LOCK_THRESH_ADD = 0x10007, 117*0Sstevel@tonic-gate CMD1394_LOCK_THRESH_SUBTRACT = 0x10008, 118*0Sstevel@tonic-gate CMD1394_LOCK_CLIP_ADD = 0x10009, 119*0Sstevel@tonic-gate CMD1394_LOCK_CLIP_SUBTRACT = 0x1000A 120*0Sstevel@tonic-gate } cmd1394_lock_type_t; 121*0Sstevel@tonic-gate 122*0Sstevel@tonic-gate /* Asynchronous Command (Data Quadlet) */ 123*0Sstevel@tonic-gate typedef struct cmd1394_quadlet { 124*0Sstevel@tonic-gate uint32_t quadlet_data; 125*0Sstevel@tonic-gate } cmd1394_quadlet_t; 126*0Sstevel@tonic-gate 127*0Sstevel@tonic-gate /* Asynchronous Command (Data Block) */ 128*0Sstevel@tonic-gate typedef struct cmd1394_block { 129*0Sstevel@tonic-gate mblk_t *data_block; 130*0Sstevel@tonic-gate size_t blk_length; 131*0Sstevel@tonic-gate size_t bytes_transferred; 132*0Sstevel@tonic-gate uint_t max_payload; 133*0Sstevel@tonic-gate } cmd1394_block_t; 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate /* Asynchronous Command (Lock Cmd - 32 bit) */ 136*0Sstevel@tonic-gate typedef struct cmd1394_lock32 { 137*0Sstevel@tonic-gate uint32_t old_value; 138*0Sstevel@tonic-gate uint32_t data_value; 139*0Sstevel@tonic-gate uint32_t arg_value; 140*0Sstevel@tonic-gate uint_t num_retries; 141*0Sstevel@tonic-gate cmd1394_lock_type_t lock_type; 142*0Sstevel@tonic-gate } cmd1394_lock32_t; 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate /* Asynchronous Command (Lock Cmd - 64 bit) */ 145*0Sstevel@tonic-gate typedef struct cmd1394_lock64 { 146*0Sstevel@tonic-gate uint64_t old_value; 147*0Sstevel@tonic-gate uint64_t data_value; 148*0Sstevel@tonic-gate uint64_t arg_value; 149*0Sstevel@tonic-gate uint_t num_retries; 150*0Sstevel@tonic-gate cmd1394_lock_type_t lock_type; 151*0Sstevel@tonic-gate } cmd1394_lock64_t; 152*0Sstevel@tonic-gate 153*0Sstevel@tonic-gate /* cmd1394_cmd: cmd1394 - common command type */ 154*0Sstevel@tonic-gate typedef struct cmd1394_cmd 155*0Sstevel@tonic-gate { 156*0Sstevel@tonic-gate int cmd_version; 157*0Sstevel@tonic-gate volatile int cmd_result; 158*0Sstevel@tonic-gate cmd1394_flags_t cmd_options; 159*0Sstevel@tonic-gate cmd1394_cmd_type_t cmd_type; 160*0Sstevel@tonic-gate void (*completion_callback)(struct cmd1394_cmd *); 161*0Sstevel@tonic-gate opaque_t cmd_callback_arg; 162*0Sstevel@tonic-gate uint64_t cmd_addr; 163*0Sstevel@tonic-gate uint_t cmd_speed; 164*0Sstevel@tonic-gate uint_t bus_generation; 165*0Sstevel@tonic-gate uint_t nodeID; 166*0Sstevel@tonic-gate uint_t broadcast; 167*0Sstevel@tonic-gate union { 168*0Sstevel@tonic-gate cmd1394_quadlet_t q; 169*0Sstevel@tonic-gate cmd1394_block_t b; 170*0Sstevel@tonic-gate cmd1394_lock32_t l32; 171*0Sstevel@tonic-gate cmd1394_lock64_t l64; 172*0Sstevel@tonic-gate } cmd_u; 173*0Sstevel@tonic-gate } cmd1394_cmd_t; 174*0Sstevel@tonic-gate 175*0Sstevel@tonic-gate /* 176*0Sstevel@tonic-gate * NOTE: Make sure CMD1394_ERR_LAST is updated if a new error code is 177*0Sstevel@tonic-gate * added. t1394_errmsg.c uses *FIRST and *LAST as bounds checks. 178*0Sstevel@tonic-gate */ 179*0Sstevel@tonic-gate /* cmd1394_cmd.result - Immediate failures (with DDI_FAILURE) */ 180*0Sstevel@tonic-gate #define CMD1394_ENULL_MBLK (-10) 181*0Sstevel@tonic-gate #define CMD1394_EMBLK_TOO_SMALL (-11) 182*0Sstevel@tonic-gate #define CMD1394_ESTALE_GENERATION (-12) 183*0Sstevel@tonic-gate #define CMD1394_EDEVICE_REMOVED (-13) 184*0Sstevel@tonic-gate #define CMD1394_EINVALID_CONTEXT (-14) 185*0Sstevel@tonic-gate #define CMD1394_EINVALID_COMMAND (-15) 186*0Sstevel@tonic-gate #define CMD1394_EUNKNOWN_ERROR (-16) 187*0Sstevel@tonic-gate #define CMD1394_NOSTATUS (-17) 188*0Sstevel@tonic-gate #define CMD1394_EFATAL_ERROR (-18) 189*0Sstevel@tonic-gate #define CMD1394_ENO_ATREQ (-19) 190*0Sstevel@tonic-gate #define CMD1394_EDEVICE_ERROR (-20) /* bad tcode or ack or... */ 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gate /* cmd1394_cmd.result - Returned with completion_callback */ 193*0Sstevel@tonic-gate #define CMD1394_CMDSUCCESS (0) 194*0Sstevel@tonic-gate #define CMD1394_EDEVICE_BUSY (-30) 195*0Sstevel@tonic-gate #define CMD1394_ERETRIES_EXCEEDED (-31) 196*0Sstevel@tonic-gate #define CMD1394_ETYPE_ERROR (-32) 197*0Sstevel@tonic-gate #define CMD1394_EDATA_ERROR (-33) 198*0Sstevel@tonic-gate #define CMD1394_EBUSRESET (-34) 199*0Sstevel@tonic-gate #define CMD1394_EADDRESS_ERROR (-35) 200*0Sstevel@tonic-gate #define CMD1394_ETIMEOUT (-36) 201*0Sstevel@tonic-gate #define CMD1394_ERSRC_CONFLICT (-37) 202*0Sstevel@tonic-gate 203*0Sstevel@tonic-gate #define CMD1394_ERR_FIRST CMD1394_CMDSUCCESS 204*0Sstevel@tonic-gate #define CMD1394_ERR_LAST CMD1394_ERSRC_CONFLICT 205*0Sstevel@tonic-gate 206*0Sstevel@tonic-gate /* Warlock directives for cmd1394 */ 207*0Sstevel@tonic-gate 208*0Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("One per call", cmd1394_cmd_t)) 209*0Sstevel@tonic-gate 210*0Sstevel@tonic-gate #ifdef __cplusplus 211*0Sstevel@tonic-gate } 212*0Sstevel@tonic-gate #endif 213*0Sstevel@tonic-gate 214*0Sstevel@tonic-gate #endif /* _SYS_1394_CMD1394_H */ 215