Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / dev / raid / pst / pst-iop.h
1 /*-
2  * Copyright (c) 2001,2002 Søren Schmidt <sos@FreeBSD.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer,
10  *    without modification, immediately at the beginning of the file.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * $FreeBSD: src/sys/dev/pst/pst-iop.h,v 1.2.2.1 2002/08/18 12:32:36 sos Exp $
29  */
30
31 /* misc defines */
32 MALLOC_DECLARE(M_PSTIOP);
33 #define I2O_IOP_OUTBOUND_FRAME_COUNT    32
34 #define I2O_IOP_OUTBOUND_FRAME_SIZE     0x20
35
36 /* structure defs */
37 struct out_mfa_buf {
38     u_int32_t   buf[I2O_IOP_OUTBOUND_FRAME_SIZE];
39 };
40
41 struct iop_softc {
42     struct resource             *r_mem;
43     struct resource             *r_irq;
44     caddr_t                     ibase;
45     u_int32_t                   phys_ibase;
46     caddr_t                     obase;
47     u_int32_t                   phys_obase;
48     struct i2o_registers        *reg;
49     struct i2o_status_get_reply *status;
50     int                         lct_count;
51     struct i2o_lct_entry        *lct;
52     device_t                    dev;
53     void                        *handle;
54     struct intr_config_hook     *iop_delayed_attach;
55 };
56
57 /* structure at start of IOP shared mem */
58 struct i2o_registers {
59     volatile u_int32_t  apic_select;
60     volatile u_int32_t  reserved0;
61     volatile u_int32_t  apic_winreg;
62     volatile u_int32_t  reserved1;
63     volatile u_int32_t  iqueue_reg0; 
64     volatile u_int32_t  iqueue_reg1;
65     volatile u_int32_t  oqueue_reg0;
66     volatile u_int32_t  oqueue_reg1;
67     volatile u_int32_t  iqueue_event;
68     volatile u_int32_t  iqueue_intr_status;
69     volatile u_int32_t  iqueue_intr_mask;
70     volatile u_int32_t  oqueue_event;
71     volatile u_int32_t  oqueue_intr_status;
72     volatile u_int32_t  oqueue_intr_mask;
73 #define I2O_OUT_INTR_QUEUE                              0x08
74 #define I2O_OUT_INTR_BELL                               0x04
75 #define I2O_OUT_INTR_MSG1                               0x02
76 #define I2O_OUT_INTR_MSG0                               0x01
77
78     volatile u_int64_t  reserved2;
79     volatile u_int32_t  iqueue;
80     volatile u_int32_t  oqueue;
81     volatile u_int64_t  reserved3;
82     volatile u_int64_t  mac_addr;
83     volatile u_int32_t  ip_addr;
84     volatile u_int32_t  ip_mask;
85 };
86
87 /* Scatter/Gather List management  */
88 struct i2o_sgl {
89     u_int32_t           count:24;
90 #define I2O_SGL_CNT_MASK                                0xffffff
91
92     u_int32_t           flags:8;
93 #define I2O_SGL_SIMPLE                                  0x10
94 #define I2O_SGL_PAGELIST                                0x20
95 #define I2O_SGL_CHAIN                                   0x30
96 #define I2O_SGL_ATTRIBUTE                               0x7c
97 #define I2O_SGL_BC0                                     0x01
98 #define I2O_SGL_BC1                                     0x02
99 #define I2O_SGL_DIR                                     0x04
100 #define I2O_SGL_LA                                      0x08
101 #define I2O_SGL_EOB                                     0x40
102 #define I2O_SGL_END                                     0x80
103
104     u_int32_t           phys_addr[1];
105 } __attribute__((packed));
106
107 #define I2O_SGL_MAX_SEGS        ((I2O_IOP_OUTBOUND_FRAME_SIZE - (8 + 2)) + 1)
108
109 /* i2o command codes */
110 #define I2O_UTIL_NOP                                    0x00
111 #define I2O_UTIL_PARAMS_GET                             0x06
112 #define I2O_UTIL_CLAIM                                  0x09
113 #define I2O_UTIL_CONFIG_DIALOG                          0x10
114 #define I2O_UTIL_EVENT_REGISTER                         0x13
115 #define I2O_BSA_BLOCK_READ                              0x30
116 #define I2O_BSA_BLOCK_WRITE                             0x31
117 #define I2O_BSA_CACHE_FLUSH                             0x37
118 #define I2O_EXEC_STATUS_GET                             0xa0
119 #define I2O_EXEC_OUTBOUND_INIT                          0xa1
120 #define I2O_EXEC_LCT_NOTIFY                             0xa2
121 #define I2O_EXEC_SYSTAB_SET                             0xa3
122 #define I2O_EXEC_IOP_RESET                              0xbd
123 #define I2O_EXEC_SYS_ENABLE                             0xd1
124
125 /* basic message layout */
126 struct i2o_basic_message {
127     u_int8_t            version:4;
128     u_int8_t            offset:4;
129     u_int8_t            message_flags;
130     u_int16_t           message_size;
131     u_int32_t           target_address:12;
132     u_int32_t           initiator_address:12;
133     u_int32_t           function:8;
134     u_int32_t           initiator_context;
135     u_int32_t           transaction_context;
136 } __attribute__((packed));
137
138 /* basic reply layout */
139 struct i2o_single_reply {
140     u_int8_t            version_offset;
141     u_int8_t            message_flags;
142 #define I2O_MESSAGE_FLAGS_STATIC                        0x01
143 #define I2O_MESSAGE_FLAGS_64BIT                         0x02
144 #define I2O_MESSAGE_FLAGS_MULTIPLE                      0x10
145 #define I2O_MESSAGE_FLAGS_FAIL                          0x20
146 #define I2O_MESSAGE_FLAGS_LAST                          0x40
147 #define I2O_MESSAGE_FLAGS_REPLY                         0x80
148
149     u_int16_t           message_size;
150     u_int32_t           target_address:12;
151     u_int32_t           initiator_address:12;
152     u_int32_t           function:8;
153     u_int32_t           initiator_context;
154     u_int32_t           transaction_context;
155     u_int16_t           detailed_status;
156 #define I2O_DETAIL_STATUS_SUCCESS                       0x0000
157 #define I2O_DETAIL_STATUS_BAD_KEY                       0x0002
158 #define I2O_DETAIL_STATUS_TCL_ERROR                     0x0003
159 #define I2O_DETAIL_STATUS_REPLY_BUFFER_FULL             0x0004
160 #define I2O_DETAIL_STATUS_NO_SUCH_PAGE                  0x0005
161 #define I2O_DETAIL_STATUS_INSUFFICIENT_RESOURCE_SOFT    0x0006
162 #define I2O_DETAIL_STATUS_INSUFFICIENT_RESOURCE_HARD    0x0007
163 #define I2O_DETAIL_STATUS_CHAIN_BUFFER_TOO_LARGE        0x0009
164 #define I2O_DETAIL_STATUS_UNSUPPORTED_FUNCTION          0x000a
165 #define I2O_DETAIL_STATUS_DEVICE_LOCKED                 0x000b
166 #define I2O_DETAIL_STATUS_DEVICE_RESET                  0x000c
167 #define I2O_DETAIL_STATUS_INAPPROPRIATE_FUNCTION        0x000d
168 #define I2O_DETAIL_STATUS_INVALID_INITIATOR_ADDRESS     0x000e
169 #define I2O_DETAIL_STATUS_INVALID_MESSAGE_FLAGS         0x000f
170 #define I2O_DETAIL_STATUS_INVALID_OFFSET                0x0010
171 #define I2O_DETAIL_STATUS_INVALID_PARAMETER             0x0011
172 #define I2O_DETAIL_STATUS_INVALID_REQUEST               0x0012
173 #define I2O_DETAIL_STATUS_INVALID_TARGET_ADDRESS        0x0013
174 #define I2O_DETAIL_STATUS_MESSAGE_TOO_LARGE             0x0014
175 #define I2O_DETAIL_STATUS_MESSAGE_TOO_SMALL             0x0015
176 #define I2O_DETAIL_STATUS_MISSING_PARAMETER             0x0016
177 #define I2O_DETAIL_STATUS_TIMEOUT                       0x0017
178 #define I2O_DETAIL_STATUS_UNKNOWN_ERROR                 0x0018
179 #define I2O_DETAIL_STATUS_UNKNOWN_FUNCTION              0x0019
180 #define I2O_DETAIL_STATUS_UNSUPPORTED_VERSION           0x001a
181 #define I2O_DETAIL_STATUS_DEVICE_BUSY                   0x001b
182 #define I2O_DETAIL_STATUS_DEVICE_NOT_AVAILABLE          0x001c
183
184     u_int8_t            retry_count;
185     u_int8_t            status;
186 #define I2O_REPLY_STATUS_SUCCESS                        0x00
187 #define I2O_REPLY_STATUS_ABORT_DIRTY                    0x01
188 #define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER         0x02
189 #define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER         0x03
190 #define I2O_REPLY_STATUS_ERROR_DIRTY                    0x04
191 #define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER         0x05
192 #define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER         0x06
193 #define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY            0x08
194 #define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x09
195 #define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x0a
196 #define I2O_REPLY_STATUS_TRANSACTION_ERROR              0x0b
197 #define I2O_REPLY_STATUS_PROGRESS_REPORT                0x80
198
199     u_int32_t           donecount;
200 } __attribute__((packed));
201
202 struct i2o_fault_reply {
203     u_int8_t            version_offset;
204     u_int8_t            message_flags;
205     u_int16_t           message_size;
206     u_int32_t           target_address:12;
207     u_int32_t           initiator_address:12;
208     u_int32_t           function:8;
209     u_int32_t           initiator_context;
210     u_int32_t           transaction_context;
211     u_int8_t            lowest_version;
212     u_int8_t            highest_version;
213     u_int8_t            severity;
214 #define I2O_SEVERITY_FORMAT_ERROR                       0x01
215 #define I2O_SEVERITY_PATH_ERROR                         0x02
216 #define I2O_SEVERITY_PATH_STATE                         0x04
217 #define I2O_SEVERITY_CONGESTION                         0x08
218
219     u_int8_t            failure_code;
220 #define I2O_FAILURE_CODE_TRANSPORT_SERVICE_SUSPENDED    0x81
221 #define I2O_FAILURE_CODE_TRANSPORT_SERVICE_TERMINATED   0x82
222 #define I2O_FAILURE_CODE_TRANSPORT_CONGESTION           0x83
223 #define I2O_FAILURE_CODE_TRANSPORT_FAIL                 0x84
224 #define I2O_FAILURE_CODE_TRANSPORT_STATE_ERROR          0x85
225 #define I2O_FAILURE_CODE_TRANSPORT_TIME_OUT             0x86
226 #define I2O_FAILURE_CODE_TRANSPORT_ROUTING_FAILURE      0x87
227 #define I2O_FAILURE_CODE_TRANSPORT_INVALID_VERSION      0x88
228 #define I2O_FAILURE_CODE_TRANSPORT_INVALID_OFFSET       0x89
229 #define I2O_FAILURE_CODE_TRANSPORT_INVALID_MSG_FLAGS    0x8A
230 #define I2O_FAILURE_CODE_TRANSPORT_FRAME_TOO_SMALL      0x8B
231 #define I2O_FAILURE_CODE_TRANSPORT_FRAME_TOO_LARGE      0x8C
232 #define I2O_FAILURE_CODE_TRANSPORT_INVALID_TARGET_ID    0x8D
233 #define I2O_FAILURE_CODE_TRANSPORT_INVALID_INITIATOR_ID 0x8E
234 #define I2O_FAILURE_CODE_TRANSPORT_INVALID_INITIATOR_CONTEXT    0x8F
235 #define I2O_FAILURE_CODE_TRANSPORT_UNKNOWN_FAILURE      0xFF
236
237     u_int32_t           failing_iop_id:12;
238     u_int32_t           reserved:4;
239     u_int32_t           failing_host_unit_id:16;
240     u_int32_t           age_limit;
241     u_int64_t           preserved_mfa;
242 } __attribute__((packed));
243
244 struct i2o_exec_iop_reset_message {
245     u_int8_t            version_offset;
246     u_int8_t            message_flags;
247     u_int16_t           message_size;
248     u_int32_t           target_address:12;
249     u_int32_t           initiator_address:12;
250     u_int32_t           function:8;
251     u_int8_t            reserved[16];
252     u_int32_t           status_word_low_addr;
253     u_int32_t           status_word_high_addr;
254 } __attribute__((packed));
255
256 struct i2o_exec_status_get_message {
257     u_int8_t            version_offset;
258     u_int8_t            message_flags;
259     u_int16_t           message_size;
260     u_int32_t           target_address:12;
261     u_int32_t           initiator_address:12;
262     u_int32_t           function:8;
263     u_int8_t            reserved[16];
264     u_int32_t           reply_buf_low_addr;
265     u_int32_t           reply_buf_high_addr;
266     u_int32_t           reply_buf_length;
267 } __attribute__((packed));
268
269 struct i2o_status_get_reply {
270     u_int16_t           organization_id;
271     u_int16_t           reserved;
272     u_int32_t           iop_id:12;
273     u_int32_t           reserved1:4;
274     u_int32_t           host_unit_id:16;
275     u_int32_t           segment_number:12;
276     u_int32_t           i2o_version:4;
277     u_int32_t           iop_state:8;
278 #define I2O_IOP_STATE_INITIALIZING                      0x01
279 #define I2O_IOP_STATE_RESET                             0x02
280 #define I2O_IOP_STATE_HOLD                              0x04
281 #define I2O_IOP_STATE_READY                             0x05
282 #define I2O_IOP_STATE_OPERATIONAL                       0x08
283 #define I2O_IOP_STATE_FAILED                            0x10
284 #define I2O_IOP_STATE_FAULTED                           0x11
285
286     u_int32_t           messenger_type:8;
287     u_int16_t           inbound_mframe_size;
288     u_int8_t            init_code;
289     u_int8_t            reserved2;
290     u_int32_t           max_inbound_mframes;
291     u_int32_t           current_ibound_mframes;
292     u_int32_t           max_outbound_mframes;
293     u_int8_t            product_idstring[24];
294     u_int32_t           expected_lct_size;
295     u_int32_t           iop_capabilities;
296     u_int32_t           desired_private_memsize;
297     u_int32_t           current_private_memsize;
298     u_int32_t           current_private_membase;
299     u_int32_t           desired_private_iosize;
300     u_int32_t           current_private_iosize;
301     u_int32_t           current_private_iobase;
302     u_int8_t            reserved3[3];
303     u_int8_t            sync_byte;
304 } __attribute__((packed));
305
306 struct i2o_exec_init_outqueue_message {
307     u_int8_t            version_offset;
308     u_int8_t            message_flags;
309     u_int16_t           message_size;
310     u_int32_t           target_address:12;
311     u_int32_t           initiator_address:12;
312     u_int32_t           function:8;
313     u_int32_t           initiator_context;
314     u_int32_t           transaction_context;
315     u_int32_t           host_pagesize;
316     u_int8_t            init_code;
317     u_int8_t            reserved;
318     u_int16_t           queue_framesize;
319     struct i2o_sgl      sgl[2];
320 } __attribute__((packed));
321
322 #define I2O_EXEC_OUTBOUND_INIT_IN_PROGRESS              0x01
323 #define I2O_EXEC_OUTBOUND_INIT_REJECTED                 0x02
324 #define I2O_EXEC_OUTBOUND_INIT_FAILED                   0x03
325 #define I2O_EXEC_OUTBOUND_INIT_COMPLETE                 0x04
326
327 struct i2o_exec_systab_set_message {
328     u_int8_t            version_offset;
329     u_int8_t            message_flags;
330     u_int16_t           message_size;
331     u_int32_t           target_address:12;
332     u_int32_t           initiator_address:12;
333     u_int32_t           function:8;
334     u_int32_t           initiator_context;
335     u_int32_t           transaction_context;
336     u_int32_t           iop_id:12;
337 #define I2O_EXEC_SYS_TAB_IOP_ID_LOCAL_IOP               0x000     
338 #define I2O_EXEC_SYS_TAB_IOP_ID_LOCAL_HOST              0x001
339 #define I2O_EXEC_SYS_TAB_IOP_ID_UNKNOWN_IOP             0xfff  
340
341     u_int32_t           reserved1:4;
342     u_int32_t           host_unit_id:16;
343 #define I2O_EXEC_SYS_TAB_HOST_UNIT_ID_LOCAL_UNIT        0x0000 
344 #define I2O_EXEC_SYS_TAB_HOST_UNIT_ID_UNKNOWN_UNIT      0xffff
345
346     u_int32_t           segment_number:12;
347 #define I2O_EXEC_SYS_TAB_SEG_NUMBER_LOCAL_SEGMENT       0x000
348 #define I2O_EXEC_SYS_TAB_SEG_NUMBER_UNKNOWN_SEGMENT     0xfff
349
350     u_int32_t           reserved2:4;
351     u_int32_t           reserved3:8;
352     struct i2o_sgl      sgl[3];
353 } __attribute__((packed));
354
355 struct i2o_exec_systab {
356     u_int8_t            entries;
357     u_int8_t            version;
358 #define    I2O_RESOURCE_MANAGER_VERSION                 0
359
360     u_int16_t           reserved1;
361     u_int32_t           change_id;
362     u_int64_t           reserved2;
363     u_int16_t           organization_id;
364     u_int16_t           reserved3;
365     u_int32_t           iop_id:12;
366     u_int32_t           reserved4:20;
367     u_int32_t           segment_number:12;
368     u_int32_t           i2o_version:4;
369     u_int32_t           iop_state:8;
370     u_int32_t           messenger_type:8;
371     u_int16_t           inbound_mframe_size;
372     u_int16_t           reserved5;
373     u_int32_t           last_changed;
374     u_int32_t           iop_capabilities;
375     u_int64_t           messenger_info;
376 } __attribute__((packed));
377
378 struct i2o_exec_get_lct_message {
379     u_int8_t            version_offset;
380     u_int8_t            message_flags;
381     u_int16_t           message_size;
382     u_int32_t           target_address:12;
383     u_int32_t           initiator_address:12;
384     u_int32_t           function:8;
385     u_int32_t           initiator_context;
386     u_int32_t           transaction_context;
387     u_int32_t           class;
388     u_int32_t           last_change_id;
389     struct i2o_sgl      sgl;
390 } __attribute__((packed));
391
392 #define I2O_TID_IOP                                     0x000
393 #define I2O_TID_HOST                                    0x001
394 #define I2O_TID_NONE                                    0xfff
395
396 struct i2o_lct_entry {
397     u_int32_t           entry_size:16;
398     u_int32_t           local_tid:12;
399     u_int32_t           reserved:4;
400     u_int32_t           change_id;
401     u_int32_t           device_flags;
402     u_int32_t           class:12;
403 #define I2O_CLASS_EXECUTIVE                             0x000
404 #define I2O_CLASS_DDM                                   0x001
405 #define I2O_CLASS_RANDOM_BLOCK_STORAGE                  0x010
406 #define I2O_CLASS_SEQUENTIAL_STORAGE                    0x011
407 #define I2O_CLASS_LAN                                   0x020
408 #define I2O_CLASS_WAN                                   0x030
409 #define I2O_CLASS_FIBRE_CHANNEL_PORT                    0x040
410 #define I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL              0x041
411 #define I2O_CLASS_SCSI_PERIPHERAL                       0x051
412 #define I2O_CLASS_ATE_PORT                              0x060
413 #define I2O_CLASS_ATE_PERIPHERAL                        0x061
414 #define I2O_CLASS_FLOPPY_CONTROLLER                     0x070
415 #define I2O_CLASS_FLOPPY_DEVICE                         0x071
416 #define I2O_CLASS_BUS_ADAPTER_PORT                      0x080
417 #define I2O_CLASS_MATCH_ANYCLASS                        0xffffffff
418
419     u_int32_t           class_version:4;
420     u_int32_t           class_org:16;
421     u_int32_t           sub_class;
422 #define I2O_SUBCLASS_i960                               0x001
423 #define I2O_SUBCLASS_HDM                                0x020
424 #define I2O_SUBCLASS_ISM                                0x021
425
426     u_int32_t           user_tid:12;
427     u_int32_t           parent_tid:12;
428     u_int32_t           bios_info:8;
429     u_int8_t            identity_tag[8];
430     u_int32_t           event_capabilities;
431 } __attribute__((packed));
432
433 #define I2O_LCT_ENTRYSIZE (sizeof(struct i2o_lct_entry)/sizeof(u_int32_t))
434
435 struct i2o_get_lct_reply {
436     u_int32_t           table_size:16;
437     u_int32_t           boot_device:12;
438     u_int32_t           lct_version:4;
439     u_int32_t           iop_flags;
440     u_int32_t           current_change_id;
441     struct i2o_lct_entry entry[1];
442 } __attribute__((packed));
443
444 struct i2o_util_get_param_message {
445     u_int8_t            version_offset;
446     u_int8_t            message_flags;
447     u_int16_t           message_size;
448     u_int32_t           target_address:12;
449     u_int32_t           initiator_address:12;
450     u_int32_t           function:8;
451     u_int32_t           initiator_context;
452     u_int32_t           transaction_context;
453     u_int32_t           operation_flags;
454     struct i2o_sgl      sgl[2];
455 } __attribute__((packed));
456
457 struct i2o_get_param_template {
458     u_int16_t           operation;
459 #define I2O_PARAMS_OPERATION_FIELD_GET                  0x0001
460 #define I2O_PARAMS_OPERATION_LIST_GET                   0x0002
461 #define I2O_PARAMS_OPERATION_MORE_GET                   0x0003
462 #define I2O_PARAMS_OPERATION_SIZE_GET                   0x0004
463 #define I2O_PARAMS_OPERATION_TABLE_GET                  0x0005
464 #define I2O_PARAMS_OPERATION_FIELD_SET                  0x0006
465 #define I2O_PARAMS_OPERATION_LIST_SET                   0x0007
466 #define I2O_PARAMS_OPERATION_ROW_ADD                    0x0008
467 #define I2O_PARAMS_OPERATION_ROW_DELETE                 0x0009
468 #define I2O_PARAMS_OPERATION_TABLE_CLEAR                0x000A
469
470     u_int16_t           group;
471 #define I2O_BSA_DEVICE_INFO_GROUP_NO                    0x0000
472 #define I2O_BSA_OPERATIONAL_CONTROL_GROUP_NO            0x0001
473 #define I2O_BSA_POWER_CONTROL_GROUP_NO                  0x0002
474 #define I2O_BSA_CACHE_CONTROL_GROUP_NO                  0x0003
475 #define I2O_BSA_MEDIA_INFO_GROUP_NO                     0x0004
476 #define I2O_BSA_ERROR_LOG_GROUP_NO                      0x0005
477
478 #define I2O_UTIL_PARAMS_DESCRIPTOR_GROUP_NO             0xF000
479 #define I2O_UTIL_PHYSICAL_DEVICE_TABLE_GROUP_NO         0xF001
480 #define I2O_UTIL_CLAIMED_TABLE_GROUP_NO                 0xF002
481 #define I2O_UTIL_USER_TABLE_GROUP_NO                    0xF003
482 #define I2O_UTIL_PRIVATE_MESSAGE_EXTENSIONS_GROUP_NO    0xF005
483 #define I2O_UTIL_AUTHORIZED_USER_TABLE_GROUP_NO         0xF006
484 #define I2O_UTIL_DEVICE_IDENTITY_GROUP_NO               0xF100
485 #define I2O_UTIL_DDM_IDENTITY_GROUP_NO                  0xF101
486 #define I2O_UTIL_USER_INFORMATION_GROUP_NO              0xF102
487 #define I2O_UTIL_SGL_OPERATING_LIMITS_GROUP_NO          0xF103
488 #define I2O_UTIL_SENSORS_GROUP_NO                       0xF200
489
490     u_int16_t           field_count;
491     u_int16_t           pad;
492 } __attribute__((packed));
493
494 struct i2o_get_param_operation {
495     u_int16_t           operation_count;
496     u_int16_t           reserved;
497     struct i2o_get_param_template operation[1];
498 } __attribute__((packed));
499     
500 struct i2o_get_param_reply {
501     u_int16_t           result_count;;
502     u_int16_t           reserved;
503     u_int16_t           block_size;
504     u_int8_t            block_status;
505     u_int8_t            error_info_size;
506     u_int32_t           result[1];
507 } __attribute__((packed));
508
509 struct i2o_device_identity {
510     u_int32_t           class;
511     u_int16_t           owner;
512     u_int16_t           parent;
513     u_int8_t            vendor[16];
514     u_int8_t            product[16];
515     u_int8_t            description[16];
516     u_int8_t            revision[8];
517     u_int8_t            sn_format;
518     u_int8_t            serial[256];
519 } __attribute__((packed));
520
521 struct i2o_bsa_device {
522     u_int8_t            device_type;
523     u_int8_t            path_count;
524     u_int16_t           power_state;
525     u_int32_t           block_size;
526     u_int64_t           capacity;
527     u_int32_t           capabilities;
528     u_int32_t           state;
529 } __attribute__((packed));
530
531 struct i2o_util_claim_message {
532     u_int8_t            version_offset;
533     u_int8_t            message_flags;
534     u_int16_t           message_size;
535     u_int32_t           target_address:12;
536     u_int32_t           initiator_address:12;
537     u_int32_t           function:8;
538     u_int32_t           initiator_context;
539     u_int32_t           transaction_context;
540     u_int16_t           claim_flags;
541     u_int8_t            reserved;
542     u_int8_t            claim_type;
543 } __attribute__((packed));
544
545 struct i2o_util_event_register_message {
546     u_int8_t            version_offset;
547     u_int8_t            message_flags;
548     u_int16_t           message_size;
549     u_int32_t           target_address:12;
550     u_int32_t           initiator_address:12;
551     u_int32_t           function:8;
552     u_int32_t           initiator_context;
553     u_int32_t           transaction_context;
554     u_int32_t           event_mask;
555 } __attribute__((packed));
556
557 struct i2o_util_event_reply_message {
558     u_int8_t            version_offset;
559     u_int8_t            message_flags;
560     u_int16_t           message_size;
561     u_int32_t           target_address:12;
562     u_int32_t           initiator_address:12;
563     u_int32_t           function:8;
564     u_int32_t           initiator_context;
565     u_int32_t           transaction_context;
566     u_int32_t           event_mask;
567     u_int32_t           event_data[1];
568 } __attribute__((packed));
569
570 struct i2o_util_config_dialog_message {
571     u_int8_t            version_offset;
572     u_int8_t            message_flags;
573     u_int16_t           message_size;
574     u_int32_t           target_address:12;
575     u_int32_t           initiator_address:12;
576     u_int32_t           function:8;
577     u_int32_t           initiator_context;
578     u_int32_t           transaction_context;
579     u_int32_t           page_number;
580     struct i2o_sgl      sgl[2];
581 } __attribute__((packed));
582
583 struct i2o_bsa_rw_block_message {
584     u_int8_t            version_offset;
585     u_int8_t            message_flags;
586     u_int16_t           message_size;
587     u_int32_t           target_address:12;
588     u_int32_t           initiator_address:12;
589     u_int32_t           function:8;
590     u_int32_t           initiator_context;
591     u_int32_t           transaction_context;
592     u_int16_t           control_flags;
593     u_int8_t            time_multiplier;
594     u_int8_t            fetch_ahead;
595     u_int32_t           bytecount;
596     u_int64_t           lba;
597     struct i2o_sgl      sgl;
598 } __attribute__((packed));
599
600 struct i2o_bsa_cache_flush_message {
601     u_int8_t            version_offset;
602     u_int8_t            message_flags;
603     u_int16_t           message_size;
604     u_int32_t           target_address:12;
605     u_int32_t           initiator_address:12;
606     u_int32_t           function:8;
607     u_int32_t           initiator_context;
608     u_int32_t           transaction_context;
609     u_int16_t           control_flags;
610     u_int8_t            time_multiplier;
611     u_int8_t            reserved;
612 } __attribute__((packed));
613
614 /* prototypes */
615 int iop_init(struct iop_softc *);
616 void iop_attach(struct iop_softc *);
617 void iop_intr(void *);
618 int iop_reset(struct iop_softc *);
619 int iop_init_outqueue(struct iop_softc *);
620 int iop_get_lct(struct iop_softc *);
621 struct i2o_get_param_reply *iop_get_util_params(struct iop_softc *,int,int,int);
622 u_int32_t iop_get_mfa(struct iop_softc *);
623 void iop_free_mfa(struct iop_softc *, int);
624 int iop_queue_wait_msg(struct iop_softc *, int, struct i2o_basic_message *);
625 int iop_create_sgl(struct i2o_basic_message *, caddr_t, int, int); 
626
627 /* global prototypes */
628 int pst_add_raid(struct iop_softc *, struct i2o_lct_entry *);