summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/i2o/i2omsg.h
blob: bad40e2733d8b03dbf5d26648f25a99fbb4ebe0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
/*
 * Copyright (c) 1998-1999 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * *************************************************************************
 * All software on this website is made available under the following
 * terms and conditions. By downloading this software, you agree to
 * abide by these terms and conditions with respect to this software.
 *
 * I2O SIG All rights reserved.
 *
 * These header files are provided, pursuant to your I2O SIG membership
 * agreement, free of charge on an as-is basis without warranty of any
 * kind, either express or implied, including but not limited to,
 * implied warranties or merchantability and fitness for a particular
 * purpose. I2O SIG does not warrant that this program will meet the
 * user's requirements or that the operation of these programs will be
 * uninterrupted or error-free. Acceptance and use of this program
 * constitutes the user's understanding that he will have no recourse
 * to I2O SIG for any actual or consequential damages including, but
 * not limited to, loss profits arising out of use or inability to use
 * this program.
 *
 * Member is permitted to create deriavative works to this header-file
 * program. However, all copies of the program and its derivative
 * works must contain the I2O SIG copyright notice.
 * *************************************************************************
 */

/*
 * *************************************************************************
 * i2omsg.h -- I2O Message defintion file
 *
 * This file contains information presented in Chapter 3, 4 and 6 of
 * the I2O(tm) Specification and most of the I2O Global defines and
 * Typedefs.
 * *************************************************************************
 */

#ifndef _SYS_I2OMSG_H
#define	_SYS_I2OMSG_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#ifdef	__cplusplus
extern "C" {
#endif

#define	I2OMSG_REV 1_5_4 /* I2OMsg header file revision string */

/*
 * *************************************************************************
 * NOTES:
 *
 * Gets, reads, receives, etc. are all even numbered functions.
 * Sets, writes, sends, etc. are all odd numbered functions.
 * Functions that both send and receive data can be either but an attempt is
 * made to use the function number that indicates the greater transfer amount.
 * Functions that do not send or receive data use odd function numbers.
 *
 * Some functions are synonyms like read, receive and send, write.
 *
 * All common functions will have a code of less than 0x80.
 * Unique functions to a class will start at 0x80.
 * Executive Functions start at 0xA0.
 *
 * Utility Message function codes range from 0 - 0x1f
 * Base Message function codes range from 0x20 - 0xfe
 * Private Message function code is 0xff.
 * *************************************************************************
 */

#include <sys/types.h>
#include <sys/dditypes.h>

/* Set to 1 for 64 bit Context Fields */
#define	I2O_64BIT_CONTEXT	0

/* ************************************************************************** */

/* Common functions accross all classes. */

#define	I2O_PRIVATE_MESSAGE			0xFF

/* ************************************************************************** */
/* Class ID and Code Assignments */


#define	I2O_CLASS_VERSION_10			0x00
#define	I2O_CLASS_VERSION_11			0x01

/* Class Code Names: Table 6-1 Class Code Assignments. */

#define	I2O_CLASS_EXECUTIVE			0x000
#define	I2O_CLASS_DDM				0x001
#define	I2O_CLASS_RANDOM_BLOCK_STORAGE		0x010
#define	I2O_CLASS_SEQUENTIAL_STORAGE		0x011
#define	I2O_CLASS_LAN				0x020
#define	I2O_CLASS_WAN				0x030
#define	I2O_CLASS_FIBRE_CHANNEL_PORT		0x040
#define	I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL	0x041
#define	I2O_CLASS_SCSI_PERIPHERAL		0x051
#define	I2O_CLASS_ATE_PORT			0x060
#define	I2O_CLASS_ATE_PERIPHERAL		0x061
#define	I2O_CLASS_FLOPPY_CONTROLLER		0x070
#define	I2O_CLASS_FLOPPY_DEVICE			0x071
#define	I2O_CLASS_BUS_ADAPTER_PORT		0x080
/* Class Codes 0x090 - 0x09f are reserved for Peer-to-Peer classes */
#define	I2O_CLASS_MATCH_ANYCLASS		0xffffffff

#define	I2O_SUBCLASS_i960			0x001
#define	I2O_SUBCLASS_HDM			0x020
#define	I2O_SUBCLASS_ISM			0x021

/* ************************************************************************** */
/* Message Frame defines and structures */

/* Defines for the Version_Status field. */

#define	I2O_VERSION_10				0x00
#define	I2O_VERSION_11				0x01

#define	I2O_VERSION_OFFSET_NUMBER_MASK		0x07
#define	I2O_VERSION_OFFSET_SGL_TRL_OFFSET_MASK	0xF0

/*
 * Defines for the Message Flags Field.
 * Please Note that the FAIL bit is only set in the Transport Fail Message.
 */
#define	I2O_MESSAGE_FLAGS_STATIC		0x01
#define	I2O_MESSAGE_FLAGS_64BIT_CONTEXT		0x02
#define	I2O_MESSAGE_FLAGS_MULTIPLE		0x10
#define	I2O_MESSAGE_FLAGS_FAIL			0x20
#define	I2O_MESSAGE_FLAGS_LAST			0x40
#define	I2O_MESSAGE_FLAGS_REPLY			0x80

/* Defines for Request Status Codes: Table 3-1 Reply Status Codes. */

#define	I2O_REPLY_STATUS_SUCCESS		0x00
#define	I2O_REPLY_STATUS_ABORT_DIRTY		0x01
#define	I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER	0x02
#define	I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER	0x03
#define	I2O_REPLY_STATUS_ERROR_DIRTY		0x04
#define	I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER	0x05
#define	I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER	0x06
#define	I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY	0x08
#define	I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER	0x09
#define	I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER	0x0A
#define	I2O_REPLY_STATUS_TRANSACTION_ERROR	0x0B
#define	I2O_REPLY_STATUS_PROGRESS_REPORT	0x80

/*
 * DetailedStatusCode defines for ALL messages: Table 3-2 Detailed Status Codes.
 */

#define	I2O_DETAIL_STATUS_SUCCESS			0x0000
#define	I2O_DETAIL_STATUS_BAD_KEY			0x0002
#define	I2O_DETAIL_STATUS_TCL_ERROR			0x0003
#define	I2O_DETAIL_STATUS_REPLY_BUFFER_FULL		0x0004
#define	I2O_DETAIL_STATUS_NO_SUCH_PAGE			0x0005
#define	I2O_DETAIL_STATUS_INSUFFICIENT_RESOURCE_SOFT	0x0006
#define	I2O_DETAIL_STATUS_INSUFFICIENT_RESOURCE_HARD	0x0007
#define	I2O_DETAIL_STATUS_CHAIN_BUFFER_TOO_LARGE	0x0009
#define	I2O_DETAIL_STATUS_UNSUPPORTED_FUNCTION		0x000A
#define	I2O_DETAIL_STATUS_DEVICE_LOCKED			0x000B
#define	I2O_DETAIL_STATUS_DEVICE_RESET			0x000C
#define	I2O_DETAIL_STATUS_INAPPROPRIATE_FUNCTION	0x000D
#define	I2O_DETAIL_STATUS_INVALID_INITIATOR_ADDRESS	0x000E
#define	I2O_DETAIL_STATUS_INVALID_MESSAGE_FLAGS		0x000F
#define	I2O_DETAIL_STATUS_INVALID_OFFSET		0x0010
#define	I2O_DETAIL_STATUS_INVALID_PARAMETER		0x0011
#define	I2O_DETAIL_STATUS_INVALID_REQUEST		0x0012
#define	I2O_DETAIL_STATUS_INVALID_TARGET_ADDRESS	0x0013
#define	I2O_DETAIL_STATUS_MESSAGE_TOO_LARGE		0x0014
#define	I2O_DETAIL_STATUS_MESSAGE_TOO_SMALL		0x0015
#define	I2O_DETAIL_STATUS_MISSING_PARAMETER		0x0016
#define	I2O_DETAIL_STATUS_TIMEOUT			0x0017
#define	I2O_DETAIL_STATUS_UNKNOWN_ERROR			0x0018
#define	I2O_DETAIL_STATUS_UNKNOWN_FUNCTION		0x0019
#define	I2O_DETAIL_STATUS_UNSUPPORTED_VERSION		0x001A
#define	I2O_DEATIL_STATUS_DEVICE_BUSY			0x001B
#define	I2O_DETAIL_STATUS_DEVICE_NOT_AVAILABLE		0x001C

/* Common I2O Field sizes */

#define	I2O_TID_SZ			12
#define	I2O_FUNCTION_SZ			8
#define	I2O_UNIT_ID_SZ			16
#define	I2O_SEGMENT_NUMBER_SZ		12

#define	I2O_IOP_ID_SZ			12
#define	I2O_GROUP_ID_SZ			16
#define	I2O_IOP_STATE_SZ		8
#define	I2O_MESSENGER_TYPE_SZ		8

#define	I2O_CLASS_ID_SZ			12
#define	I2O_CLASS_ORGANIZATION_ID_SZ	16

#define	I2O_4BIT_VERSION_SZ		4
#define	I2O_8BIT_FLAGS_SZ		8
#define	I2O_COMMON_LENGTH_FIELD_SZ	16

#define	I2O_DEVID_DESCRIPTION_SZ	16
#define	I2O_DEVID_VENDOR_INFO_SZ	16
#define	I2O_DEVID_PRODUCT_INFO_SZ	16
#define	I2O_DEVID_REV_LEVEL_SZ		8
#define	I2O_MODULE_NAME_SZ		24

#define	I2O_BIOS_INFO_SZ		8

#define	I2O_RESERVED_4BITS		4
#define	I2O_RESERVED_8BITS		8
#define	I2O_RESERVED_12BITS		12
#define	I2O_RESERVED_16BITS		16
#define	I2O_RESERVED_20BITS		20
#define	I2O_RESERVED_24BITS		24
#define	I2O_RESERVED_28BITS		28

typedef uint32_t	I2O_PARAMETER_TID;

#if  I2O_64BIT_CONTEXT

typedef union {
	void		(* i2o_msg_complete)(void *, ddi_acc_handle_t);
	uint64_t	initiator_context_64bits;
} i2o_initiator_context_t;

typedef uint64_t	 i2o_transaction_context_t;

#else

typedef union {
	void		(* i2o_msg_complete)(void *, ddi_acc_handle_t);
	uint32_t	initiator_context_32bits;
} i2o_initiator_context_t;

typedef uint32_t i2o_transaction_context_t;

#endif

/* Serial Number format defines */

#define	I2O_SERIAL_FORMAT_UNKNOWN	0
#define	I2O_SERIAL_FORMAT_BINARY	1
#define	I2O_SERIAL_FORMAT_ASCII		2
#define	I2O_SERIAL_FORMAT_UNICODE	3
#define	I2O_SERIAL_FORMAT_LAN_MAC	4
#define	I2O_SERIAL_FORMAT_WAN		5

/* Special TID Assignments */

#define	I2O_IOP_TID			0
#define	I2O_HOST_TID			1


/* ************************************************************************** */

/* I2O Message Frame common for all messages */

#if defined(_BIT_FIELDS_LTOH) && defined(_LITTLE_ENDIAN)

typedef struct i2o_message_frame {
	uint8_t			VersionOffset;
	uint8_t			MsgFlags;
	uint16_t		MessageSize;
	union {
	    struct {
		uint32_t	TargetAddress:12;
		uint32_t	InitiatorAddress:12;
		uint32_t	Function:8;
	    } s2;
	    uint32_t		w2;
	} u2;
	i2o_initiator_context_t  InitiatorContext;
} i2o_message_frame_t;

/* macros to access the bit fields in Message Frame */

#define	get_msg_TargetAddress(mp, hdl) \
			(mp)->u2.s2.TargetAddress
#define	put_msg_TargetAddress(mp, id, hdl) \
			((mp)->u2.s2.TargetAddress = (id))
#define	get_msg_InitiatorAddress(mp, hdl) \
			(mp)->u2.s2.InitiatorAddress
#define	put_msg_InitiatorAddress(mp, id, hdl) \
			((mp)->u2.s2.InitiatorAddress = (id))
#define	get_msg_Function(mp, hdl) \
			(mp)->u2.s2.Function
#define	put_msg_Function(mp, n, hdl) \
			((mp)->u2.s2.Function = (n))
#endif

#if defined(_BIT_FIELDS_HTOL) && defined(_BIG_ENDIAN)

typedef struct i2o_message_frame {
	uint8_t			VersionOffset;
	uint8_t			MsgFlags;
	uint16_t		MessageSize;
	union {
	    struct {
		uint32_t	Function:8;
		uint32_t	InitiatorAddress:12;
		uint32_t	TargetAddress:12;
	    } s2;
	    uint32_t		w2;
	} u2;
	i2o_initiator_context_t  InitiatorContext;
} i2o_message_frame_t;

/* macros to access the bit fields in Message Frame */

#define	get_msg_Function(mp, hdl) \
	(mp)->u2.s2.Function
#define	put_msg_Function(mp, n, hdl) \
	((mp)->u2.s2.Function = (n))

#define	get_msg_TargetAddress(mp, hdl) \
	(ddi_get32(hdl, &(mp)->u2.w2) & 0xFFF)
#define	put_msg_TargetAddress(mp, id, hdl) \
	ddi_put32(hdl, &(mp)->u2.w2, \
		(ddi_get32(hdl, &(mp)->u2.w2) & ~0xFFF) | ((id) & 0xFFF))

#define	get_msg_InitiatorAddress(mp, hdl) \
	((ddi_get32(hdl, &(mp)->u2.w2) >> 12) & 0xFFF)
#define	put_msg_InitiatorAddress(mp, id, hdl) \
	ddi_put32(hdl, &(mp)->u2.w2, (ddi_get32(hdl, &(mp)->u2.w2) & \
			~0xFFF000) | (((id) & 0xFFF) << 12))
#endif


/* ************************************************************************** */

/* Transaction Reply Lists (TRL) Control Word structure */

#define	I2O_TRL_FLAGS_SINGLE_FIXED_LENGTH	0x00
#define	I2O_TRL_FLAGS_SINGLE_VARIABLE_LENGTH	0x40
#define	I2O_TRL_FLAGS_MULTIPLE_FIXED_LENGTH	0x80

typedef struct i2o_trl_control_word {
	uint8_t			TrlCount;
	uint8_t			TrlElementSize;
	uint8_t			reserved;
	uint8_t			TrlFlags;
#if  I2O_64BIT_CONTEXT
	uint32_t		Padding;	 /* Padding for 64 bit */
#endif
} i2o_trl_control_word_t;

/* ************************************************************************** */

/* I2O Successful Single Transaction Reply Message Frame structure. */

typedef struct i2o_single_reply_message_frame {
	i2o_message_frame_t	StdMessageFrame;
	i2o_transaction_context_t TransactionContext;
	uint16_t		DetailedStatusCode;
	uint8_t			reserved;
	uint8_t			ReqStatus;
	/*			ReplyPayload	*/
} i2o_single_reply_message_frame_t;

/* ************************************************************************** */

/* I2O Successful Multiple Transaction Reply Message Frame structure. */

typedef struct i2o_multiple_reply_message_frame {
	i2o_message_frame_t	StdMessageFrame;
	i2o_trl_control_word_t	TrlControlWord;
	uint16_t		DetailedStatusCode;
	uint8_t			reserved;
	uint8_t			ReqStatus;
	/*			TransactionDetails[]	*/
} i2o_multiple_reply_message_frame_t;

/* ************************************************************************** */

/* I2O Private Message Frame structure. */

typedef struct i2o_private_message_frame {
	i2o_message_frame_t	StdMessageFrame;
	i2o_transaction_context_t TransactionContext;
	uint16_t		XFunctionCode;
	uint16_t		OrganizationID;
	/*			PrivatePayload[]	*/
} i2o_private_message_frame_t;

/* ************************************************************************** */

/* Message Failure Severity Codes */

#define	I2O_SEVERITY_FORMAT_ERROR	0x1
#define	I2O_SEVERITY_PATH_ERROR		0x2
#define	I2O_SEVERITY_PATH_STATE		0x4
#define	I2O_SEVERITY_CONGESTION		0x8

/* Transport Failure Codes: Table 3-3 Mesasge Failure Codes */

#define	I2O_FAILURE_CODE_TRANSPORT_SERVICE_SUSPENDED		0x81
#define	I2O_FAILURE_CODE_TRANSPORT_SERVICE_TERMINATED		0x82
#define	I2O_FAILURE_CODE_TRANSPORT_CONGESTION			0x83
#define	I2O_FAILURE_CODE_TRANSPORT_FAIL				0x84
#define	I2O_FAILURE_CODE_TRANSPORT_STATE_ERROR			0x85
#define	I2O_FAILURE_CODE_TRANSPORT_TIME_OUT			0x86
#define	I2O_FAILURE_CODE_TRANSPORT_ROUTING_FAILURE  		0x87
#define	I2O_FAILURE_CODE_TRANSPORT_INVALID_VERSION  		0x88
#define	I2O_FAILURE_CODE_TRANSPORT_INVALID_OFFSET  		0x89
#define	I2O_FAILURE_CODE_TRANSPORT_INVALID_MSG_FLAGS 		0x8A
#define	I2O_FAILURE_CODE_TRANSPORT_FRAME_TOO_SMALL  		0x8B
#define	I2O_FAILURE_CODE_TRANSPORT_FRAME_TOO_LARGE  		0x8C
#define	I2O_FAILURE_CODE_TRANSPORT_INVALID_TARGET_ID 		0x8D
#define	I2O_FAILURE_CODE_TRANSPORT_INVALID_INITIATOR_ID 	0x8E
#define	I2O_FAILURE_CODE_TRANSPORT_INVALID_INITIATOR_CONTEXT 	0x8F
#define	I2O_FAILURE_CODE_TRANSPORT_UNKNOWN_FAILURE  		0xFF

/* IOP_ID and Severity sizes */

#define	I2O_FAILCODE_SEVERITY_SZ	8
#define	I2O_FAILCODE_CODE_SZ		8

/* I2O Transport Message Reply for Message Failure. */

#if defined(_BIT_FIELDS_LTOH) && defined(_LITTLE_ENDIAN)

typedef struct i2o_failure_reply_message_frame {
	i2o_message_frame_t	StdMessageFrame;
	i2o_transaction_context_t TransactionContext;
	uint8_t			LowestVersion;
	uint8_t			HighestVersion;
	uint8_t			Severity;
	uint8_t			FailureCode;
	union {
	    struct {
		uint16_t	FailingIOP_ID:12;
		uint16_t	reserved:4;
	    } s;
	    uint16_t		h;
	} u1;
	uint16_t		FailingHostUnitID;
	uint32_t		AgeLimit;
	i2o_message_frame_t	*PreservedMFA;
} i2o_failure_reply_message_frame_t;

/* macros to access the bit field(s) */

#define	get_reply_msg_FailingIOP_ID(p, hdl) \
	((p)->u1.s.FailingIOP_ID)
#endif

#if defined(_BIT_FIELDS_HTOL) && defined(_BIG_ENDIAN)

typedef struct i2o_failure_reply_message_frame {
	i2o_message_frame_t	StdMessageFrame;
	i2o_transaction_context_t TransactionContext;
	uint8_t			LowestVersion;
	uint8_t			HighestVersion;
	uint8_t			Severity;
	uint8_t			FailureCode;
	union {
	    struct {
		uint16_t	reserved:4;
		uint16_t	FailingIOP_ID:12;
	    } s;
	    uint16_t		h;
	} u1;
	uint16_t		FailingHostUnitID;
	uint32_t		AgeLimit;
	i2o_message_frame_t	*PreservedMFA;
} i2o_failure_reply_message_frame_t;

/* macros to access the bit field(s) */

#define	get_reply_msg_FailingIOP_ID(p, hdl) \
	(ddi_get16(hdl, &(p)->u1.h) & 0xFFF)
#endif

/* I2O Transport Message Reply for Transaction Error. */

typedef struct i2o_transaction_error_reply_message_frame {
	i2o_message_frame_t	StdMessageFrame;
	i2o_transaction_context_t TransactionContext;
	uint16_t		DetailedStatusCode;
	uint8_t			reserved;
	uint8_t			ReqStatus; /* Should Transaction Error */
	uint32_t		ErrorOffset;
	uint8_t			BitOffset;
	uint8_t			reserved1;
	uint16_t		reserved2;
} i2o_transaction_error_reply_message_frame_t;

/* ************************************************************************** */

/* Misc. commonly used structures */

#define	I2O_MAX_SERIAL_NUMBER_SZ		 256

typedef struct i2o_serial_info {
	uint8_t			SerialNumberLength;
	uint8_t			SerialNumberFormat;
	uint8_t			SerialNumber[I2O_MAX_SERIAL_NUMBER_SZ];
} i2o_serial_info_t;


/* ************************************************************************** */
/* Hardware Resource Table (HRT) and Logical Configuration Table (LCT) */
/* ************************************************************************** */

/* Bus Type Code defines */

#define	I2O_LOCAL_BUS			0
#define	I2O_ISA_BUS			1
#define	I2O_EISA_BUS			2
#define	I2O_PCI_BUS			4
#define	I2O_PCMCIA_BUS			5
#define	I2O_NUBUS_BUS			6
#define	I2O_CARDBUS_BUS			7
#define	I2O_OTHER_BUS			0x80

#define	I2O_HRT_STATE_SZ		4
#define	I2O_HRT_BUS_NUMBER_SZ		8
#define	I2O_HRT_BUS_TYPE_SZ		8


/* Bus Structures */

/* PCI Bus */
typedef struct i2o_pci_bus_info {
	uint8_t			PciFunctionNumber;
	uint8_t			PciDeviceNumber;
	uint8_t			PciBusNumber;
	uint8_t			reserved;
	uint16_t		PciVendorID;
	uint16_t		PciDeviceID;
} i2o_pci_bus_info_t;

/* Local Bus */
typedef struct i2o_local_bus_info {
	uint16_t		LbBaseIOPort;
	uint16_t		reserved;
	uint32_t		LbBaseMemoryAddress;
} i2o_local_bus_info_t;

/* ISA Bus */
typedef struct i2o_isa_bus_info {
	uint16_t		IsaBaseIOPort;
	uint8_t			CSN;
	uint8_t			reserved;
	uint32_t		IsaBaseMemoryAddress;
} i2o_isa_bus_info_t;

/* EISA Bus */
typedef struct i2o_eisa_bus_info {
	uint16_t		EisaBaseIOPort;
	uint8_t			reserved;
	uint8_t			EisaSlotNumber;
	uint32_t		EisaBaseMemoryAddress;
} i2o_eisa_bus_info_t;

/* Other Bus */
typedef struct i2o_other_bus_info {
	uint16_t		BaseIOPort;
	uint16_t		reserved;
	uint32_t		BaseMemoryAddress;
} i2o_other_bus_info_t;


/* HRT Entry Block */

#if defined(_BIT_FIELDS_LTOH) && defined(_LITTLE_ENDIAN)

typedef struct i2o_hrt_entry {
	uint32_t		AdapterID;
	union	{
	    struct {
		uint16_t	ControllingTID:12;
		uint16_t	AdapterState:4;
	    } s2;
	    uint16_t		h2;
	} u2;
	uint8_t			BusNumber;
	uint8_t			BusType;
	union {
	    /* PCI Bus */
	    i2o_pci_bus_info_t		PCIBus;

	    /* Local Bus */
	    i2o_local_bus_info_t	LocalBus;

	    /* ISA Bus */
	    i2o_isa_bus_info_t		ISABus;

	    /* EISA Bus */
	    i2o_eisa_bus_info_t		EISABus;

	    /* Other. */
	    i2o_other_bus_info_t	OtherBus;
	} uBus;
} i2o_hrt_entry_t;

/* macros to access the bit fields */

#define	get_hrt_entry_ControllingTID(p, hdl) (p)->u2.s2.ControllingTID
#define	get_hrt_entry_AdapterState(p, hdl) (p)->u2.s2.AdapterState

#endif

#if defined(_BIT_FIELDS_HTOL) && defined(_BIG_ENDIAN)

typedef struct i2o_hrt_entry {
	uint32_t		AdapterID;
	union	{
	    struct {
		uint16_t	AdapterState:4;
		uint16_t	ControllingTID:12;
	    } s2;
	    uint16_t		h2;
	} u2;
	uint8_t			BusNumber;
	uint8_t			BusType;
	union {
	    /* PCI Bus */
	    i2o_pci_bus_info_t		PCIBus;

	    /* Local Bus */
	    i2o_local_bus_info_t	LocalBus;

	    /* ISA Bus */
	    i2o_isa_bus_info_t		ISABus;

	    /* EISA Bus */
	    i2o_eisa_bus_info_t		EISABus;

	    /* Other. */
	    i2o_other_bus_info_t	OtherBus;
	} uBus;
} i2o_hrt_entry_t;

/* macros to access the bit fields */

#define	get_hrt_entry_ControllingTID(p, hdl) \
	(ddi_get16(hdl, &(p)->u2.h2) & 0xFFF)
#define	get_hrt_entry_AdapterState(p, hdl) \
	((ddi_get16(hdl, &(p)->u2.h2) >> 12) & 0xF)
#endif

/* I2O Hardware Resource Table structure. */

typedef struct i2o_hrt {
	uint16_t		NumberEntries;
	uint8_t			EntryLength;
	uint8_t			HRTVersion;
	uint32_t		CurrentChangeIndicator;
	i2o_hrt_entry_t		HRTEntry[1];
} i2o_hrt_t;


/* ************************************************************************** */
/* Logical Configuration Table */
/* ************************************************************************** */

/* I2O Logical Configuration Table structures. */

#define	I2O_IDENTITY_TAG_SZ			8

/* I2O Logical Configuration Table Device Flags */

#define	I2O_LCT_DEVICE_FLAGS_CONF_DIALOG_REQUEST	0x01
#define	I2O_LCT_DEVICE_FLAGS_MORE_THAN_1_USER		0x02
#define	I2O_LCT_DEVICE_FLAGS_PEER_SERVICE_DISABLED	0x10
#define	I2O_LCT_DEVICE_FLAGS_MANAGEMENT_SERVICE_DISABLED 0x20

/* LCT Entry Block */

#if defined(_BIT_FIELDS_LTOH) && defined(_LITTLE_ENDIAN)

typedef struct i2o_lct_entry {
	union {
	    struct {
		uint32_t	TableEntrySize:16;
		uint32_t	LocalTID:12;
		uint32_t	reserved:4;
	    } s1;
	    uint32_t		w1;
	} u1;
	uint32_t		ChangeIndicator;
	uint32_t		DeviceFlags;
	union {
	    struct i2o_class_id {
		uint32_t	Class:12;
		uint32_t	Version:4;
		uint32_t	OrganizationID:16;
	    } s4;
	    uint32_t		w4;
	} u4;
	uint32_t		SubClassInfo;
	union {
	    struct {
		uint32_t	UserTID:12;
		uint32_t	ParentTID:12;
		uint32_t	BiosInfo:8;
	    } s6;
	    uint32_t		w6;
	} u6;
	uint8_t			IdentityTag[I2O_IDENTITY_TAG_SZ];
	uint32_t		EventCapabilities;
} i2o_lct_entry_t;

/* macros to access the bit fields */

#define	get_lct_entry_LocalTID(p, hdl) (p)->u1.s1.LocalTID
#define	get_lct_entry_TableEntrySize(p, hdl) (p)->u1.s1.TableEntrySize

#define	get_lct_entry_Class(p, hdl) (p)->u4.s4.Class
#define	get_lct_entry_Version(p, hdl) (p)->u4.s4.Version
#define	get_lct_entry_OrganizationID(p, hdl) (p)->u4.s4.OrganizationID

#define	get_lct_entry_BiosInfo(p, hdl) (p)->u6.s6.BiosInfo
#define	get_lct_entry_ParentTID(p, hdl) (p)->u6.s6.ParentTID
#define	get_lct_entry_UserTID(p, hdl) (p)->u6.s6.UserTID

#endif

#if defined(_BIT_FIELDS_HTOL) && defined(_BIG_ENDIAN)

typedef struct i2o_lct_entry {
	union {
	    struct {
		uint32_t	reserved:4;
		uint32_t	LocalTID:12;
		uint32_t	TableEntrySize:16;
	    } s1;
	    uint32_t		w1;
	} u1;
	uint32_t		ChangeIndicator;
	uint32_t		DeviceFlags;
	union {
	    struct i2o_class_id {
		uint32_t	OrganizationID:16;
		uint32_t	Version:4;
		uint32_t	Class:12;
	    } s4;
	    uint32_t		w4;
	} u4;
	uint32_t		SubClassInfo;
	union {
	    struct {
		uint32_t	BiosInfo:8;
		uint32_t	ParentTID:12;
		uint32_t	UserTID:12;
	    } s6;
	    uint32_t		w6;
	} u6;
	uint8_t			IdentityTag[I2O_IDENTITY_TAG_SZ];
	uint32_t		EventCapabilities;
} i2o_lct_entry_t;

/* macros to access the bit fields */

#define	get_lct_entry_TableEntrySize(p, hdl) \
	(ddi_get32(hdl, &(p)->u1.w1) & 0xFFFF)
#define	get_lct_entry_LocalTID(p, hdl) \
	((ddi_get32(hdl, (p)->u1.w1) >> 16) & 0xFFF)

#define	get_lct_entry_OrganizationID(p, hdl) \
	((ddi_get16(hdl, (p)->u4.w4) >> 16) & 0xFFFF)
#define	get_lct_entry_Version(p, hdl) \
	((ddi_get32(hdl, &(p)->u4.w4) >> 12) & 0xF)
#define	get_lct_entry_Class(p, hdl) \
	(ddi_get32(hdl, &(p)->u4.w4) & 0xFFF)

#define	get_lct_entry_BiosInfo(p, hdl) (p)->u6.s6.BiosInfo
#define	get_lct_entry_ParentTID(p, hdl) \
	((ddi_get32(hdtl, &(p)->u6.w6) >> 12) & 0xFFF)
#define	get_lct_entry_UserTID(p, hdl) \
	(ddi_get32(hdtl, &(p)->u6.w6) & 0xFFF)

#endif

/* I2O Logical Configuration Table structure. */

#if defined(_BIT_FIELDS_LTOH) && defined(_LITTLE_ENDIAN)

typedef struct i2o_lct {
	uint16_t		TableSize;
	union {
	    struct {
		uint16_t	BootDeviceTID:12;
		uint16_t	LctVer:4;
	    } s1;
	    uint16_t		h1;
	} u1;
	uint32_t		IopFlags;
	uint32_t		CurrentChangeIndicator;
	i2o_lct_entry_t		LCTEntry[1];
} i2o_lct_t;

/* macros to access the bit fields */

#define	get_lct_BootDeviceTID(p, hdl)	(p)->u1.s1.BootDeviceTID
#define	get_lct_LctVer(p, hdl)		(p)->u1.s1.LctVer

#endif

#if defined(_BIT_FIELDS_HTOL) && defined(_BIG_ENDIAN)

typedef struct i2o_lct {
	uint16_t		TableSize;
	union {
	    struct {
		uint16_t	LctVer:4;
		uint16_t	BootDeviceTID:12;
	    } s1;
	    uint16_t		h1;
	} u1;
	uint32_t		IopFlags;
	uint32_t		CurrentChangeIndicator;
	i2o_lct_entry_t		LCTEntry[1];
} i2o_lct_t;

/* macros to access the bit fields */

#define	get_lct_BootDeviceTID(p, hdl) \
		((ddi_get32(hdl, &(p)->u1.w1) >> 16) & 0xFFF)
#define	get_lct_LctVer(p, hdl) \
		((ddi_get32(hdl, &(p)->u1.w1) >> 28) & 0xF)

#endif

/* ************************************************************************** */

/* Memory Addressing structures and defines. */

/* SglFlags defines. */

#define	I2O_SGL_FLAGS_LAST_ELEMENT		0x80
#define	I2O_SGL_FLAGS_END_OF_BUFFER		0x40

#define	I2O_SGL_FLAGS_IGNORE_ELEMENT		0x00
#define	I2O_SGL_FLAGS_TRANSPORT_ELEMENT		0x04
#define	I2O_SGL_FLAGS_BIT_BUCKET_ELEMENT	0x08
#define	I2O_SGL_FLAGS_IMMEDIATE_DATA_ELEMENT	0x0C
#define	I2O_SGL_FLAGS_SIMPLE_ADDRESS_ELEMENT	0x10
#define	I2O_SGL_FLAGS_PAGE_LIST_ADDRESS_ELEMENT 0x20
#define	I2O_SGL_FLAGS_CHAIN_POINTER_ELEMENT	0x30
#define	I2O_SGL_FLAGS_LONG_TRANSACTION_ELEMENT  0x40
#define	I2O_SGL_FLAGS_SHORT_TRANSACTION_ELEMENT 0x70
#define	I2O_SGL_FLAGS_SGL_ATTRIBUTES_ELEMENT	0x7C

#define	I2O_SGL_FLAGS_BC0			0x01
#define	I2O_SGL_FLAGS_BC1			0x02
#define	I2O_SGL_FLAGS_DIR			0x04
#define	I2O_SGL_FLAGS_LOCAL_ADDRESS		0x08

#define	I2O_SGL_FLAGS_CONTEXT_COUNT_MASK	0x03
#define	I2O_SGL_FLAGS_ADDRESS_MODE_MASK		0x3C
#define	I2O_SGL_FLAGS_NO_CONTEXT		0x00

/* Scatter/Gather Truth Table */

/*
 *
 * typedef enum _SG_TYPE {
 *	INVALID,
 *	Ignore,
 *	TransportDetails,
 *	BitBucket,
 *	ImmediateData,
 *	Simple,
 *	PageList,
 *	ChainPointer,
 *	ShortTransaction,
 *	LongTransaction,
 *	SGLAttributes,
 *	INVALID/ReservedLongFormat,
 *	INVALID/ReservedShortFormat
 * } SG_TYPE, *PSG_TYPE;
 *
 *
 *	0x00 Ignore;
 *	0x04 TransportDetails;
 *	0x08 BitBucket;
 *	0x0C ImmediateData;
 *	0x10 Simple;
 *	0x14 Simple;
 *	0x18 Simple;
 *	0x1C Simple;
 *	0x20 PageList;
 *	0x24 PageList;
 *	0x28 PageList;
 *	0x2C PageList;
 *	0x30 ChainPointer;
 *	0x34 INVALID;
 *	0x38 ChainPointer;
 *	0x3C INVALID;
 *	0x40 LongTransaction;
 *	0x44 INVALID/ReservedLongFormat;
 *	0x48 BitBucket;
 *	0x4C ImmediateData;
 *	0x50 Simple;
 *	0x54 Simple;
 *	0x58 Simple;
 *	0x5C Simple;
 *	0x60 PageList;
 *	0x64 PageList;
 *	0x68 PageList;
 *	0x6C PageList;
 *	0x70 ShortTransaction;
 *	0x74 INVALID/ReservedShortFormat;
 *	0x78 INVALID/ReservedShortFormat;
 *	0X7C SGLATTRIBUTES;
 */


/* 32 Bit Context Field defines */

#define	I2O_SGL_FLAGS_CONTEXT32_NULL		0x00
#define	I2O_SGL_FLAGS_CONTEXT32_U32		0x01
#define	I2O_SGL_FLAGS_CONTEXT32_U64		0x02
#define	I2O_SGL_FLAGS_CONTEXT32_U96		0x03

#define	I2O_SGL_FLAGS_CONTEXT32_NULL_SZ		0x00
#define	I2O_SGL_FLAGS_CONTEXT32_U32_SZ		0x04
#define	I2O_SGL_FLAGS_CONTEXT32_U64_SZ		0x08
#define	I2O_SGL_FLAGS_CONTEXT32_U96_SZ		0x0C

/* 64 Bit Context Field defines */

#define	I2O_SGL_FLAGS_CONTEXT64_NULL		0x00
#define	I2O_SGL_FLAGS_CONTEXT64_U64		0x01
#define	I2O_SGL_FLAGS_CONTEXT64_U128		0x02
#define	I2O_SGL_FLAGS_CONTEXT64_U192		0x03

#define	I2O_SGL_FLAGS_CONTEXT64_NULL_SZ		0x00
#define	I2O_SGL_FLAGS_CONTEXT64_U64_SZ		0x08
#define	I2O_SGL_FLAGS_CONTEXT64_U128_SZ		0x10
#define	I2O_SGL_FLAGS_CONTEXT64_U192_SZ		0x18

/* SGL Attribute Element defines */

#define	I2O_SGL_ATTRIBUTE_FLAGS_BIT_BUCKET_HINT		0x0400
#define	I2O_SGL_ATTRIBUTE_FLAGS_IMMEDIATE_DATA_HINT	0x0200
#define	I2O_SGL_ATTRIBUTE_FLAGS_LOCAL_ADDRESS_HINT	0x0100
#define	I2O_SGL_ATTRIBUTE_FLAGS_32BIT_TRANSACTION	0x0000
#define	I2O_SGL_ATTRIBUTE_FLAGS_64BIT_TRANSACTION	0x0004
#define	I2O_SGL_ATTRIBUTE_FLAGS_32BIT_LOCAL_ADDRESS	0x0000

/* SG Size defines */

#define	I2O_SG_COUNT_SZ			24
#define	I2O_SG_FLAGS_SZ			8

/* Standard Flags and Count fields for SG Elements */

#if defined(_BIT_FIELDS_LTOH) && defined(_LITTLE_ENDIAN)

typedef union i2o_flags_count {
	struct {
		uint32_t		Count:24;
		uint32_t		Flags:8;
	} flags_count;
	uint32_t			cword;
} i2o_flags_count_t;

#define	get_flags_count_Count(p, hdl)	(p)->flags_count.Count
#define	put_flags_count_Count(p, v, hdl)	((p)->flags_count.Count = (v))
#define	get_flags_count_Flags(p, hdl)	(p)->flags_count.Flags
#define	put_flags_count_Flags(p, v, hdl)	((p)->flags_count.Flags = (v))

#endif

#if defined(_BIT_FIELDS_HTOL) && defined(_BIG_ENDIAN)

typedef union i2o_flags_count {
	struct {
		uint32_t		Flags:8;
		uint32_t		Count:24;
	} flags_count;
	uint32_t			cword;
} i2o_flags_count_t;

#define	get_flags_count_Count(p, hdl) \
	(ddi_get32(hdl, &(p)->cword) & 0xFFFFFF)
#define	put_flags_count_Count(p, v, hdl) \
	ddi_put32(hdl, &(p)->cword, \
		(ddi_get32(hdl, &(p)->cword) & ~0xFFFFFF) | \
		((uint32_t)(v) & 0xFFFFFF))
#define	get_flags_count_Flags(p, hdl) \
	((ddi_get32(hdl, &(p)->cword) >> 24) & 0xFF)
#define	put_flags_count_Flags(p, v, hdl) \
	ddi_put32(hdl, &(p)->cword, \
	    (ddi_get32(hdl, &(p)->cword) & ~0xFF000000) | ((uint32_t)(v) << 24))
#endif

/* Bit Bucket Element */

typedef struct i2o_sge_bit_bucket_element {
	i2o_flags_count_t	FlagsCount;
	uint32_t		BufferContext;
} i2o_sge_bit_bucket_element_t;

/* Chain Addressing Scatter-Gather Element */

typedef struct i2o_sge_chain_element {
	i2o_flags_count_t	FlagsCount;
	uint32_t		PhysicalAddress;
} i2o_sge_chain_element_t;

/* Chain Addressing with Context Scatter-Gather Element */

typedef struct i2o_sge_chain_context_element {
	i2o_flags_count_t	FlagsCount;
	uint32_t		Context[1];
	uint32_t		PhysicalAddress;
} i2o_sge_chain_context_element_t;

/* Ignore Scatter-Gather Element */

typedef struct i2o_sge_ignore_element {
	i2o_flags_count_t	FlagsCount;
} i2o_sge_ignore_element_t;

/* Immediate Data Element */

typedef struct i2o_sge_immediate_data_element {
	i2o_flags_count_t	FlagsCount;
} i2o_sge_immediate_data_element_t;

/* Immediate Data with Context Element */

typedef struct i2o_sge_immediate_data_context_element {
	i2o_flags_count_t	FlagsCount;
	uint32_t		BufferContext;
} i2o_sge_immediate_data_context_element_t;

/* Long Transaction Parameters Element */

#if defined(_BIT_FIELDS_LTOH) && defined(_LITTLE_ENDIAN)

typedef struct i2o_sge_long_transaction_element {
	union {
		struct {
			uint32_t	LongElementLength:24;
			uint32_t	Flags:8;
		} s1;
		uint32_t		w1;
	} u1;
	uint32_t			BufferContext;
} i2o_sge_long_transaction_element_t;

#define	get_sge_long_LongElementLength(p, hdl) \
	(p)->u1.s1.LongElementLength
#define	put_sge_long_LongElementLength(p, v, hdl) \
	((p)->u1.s1.LongElementLength = (v))
#define	get_sge_long_Flags(p, hdl) \
	(p)->u1.s1.Flags
#define	put_sge_long_Flags(p, v, hdl) \
	((p)->u1.s1.Flags = (v))

#endif

#if defined(_BIT_FIELDS_HTOL) && defined(_BIG_ENDIAN)

typedef struct i2o_sge_long_transaction_element {
	union {
		struct {
			uint32_t	Flags:8;
			uint32_t	LongElementLength:24;
		} s1;
		uint32_t		w1;
	} u1;
	uint32_t			BufferContext;
} i2o_sge_long_transaction_element_t;

#define	get_sge_long_LongElementLength(p, hdl) \
	(ddi_get32(hdl, &(p)->u1.w1) & 0xFFFFFF)
#define	put_sge_long_LongElementLength(p, v, hdl) \
	ddi_put32(hdl, &(p)->u1.w1, \
		(ddi_get32(hdl, &(p)->u1.w1) & ~0xFFFFFF) | \
		((uint32_t)(v) & 0xFFFFFF))
#define	get_sge_long_Flags(p, hdl) \
	(ddi_get32(hdl, &(p)->u1.w1) >> 24)
#define	put_sge_long_Flags(p, v, hdl) \
	ddi_put32(hdl, &(p)->u1.w1, \
		(ddi_get32(hdl, &(p)->u1.w1) & ~0xFF000000) | \
		((uint32_t)(v) << 24))
#endif

/* Page List Scatter-Gather Element */

typedef struct i2o_sge_page_element {
	i2o_flags_count_t	FlagsCount;
	uint32_t		PhysicalAddress[1];
} i2o_sge_page_element_t;

/* Page List with Context Scatter-Gather Element */

typedef struct i2o_sge_page_context_element {
	i2o_flags_count_t	FlagsCount;
	uint32_t		BufferContext[1];
	uint32_t		PhysicalAddress[1];
} i2o_sge_page_context_element_t;

/* SGL Attribute Element */

typedef struct i2o_sge_sgl_attributes_element {
	uint16_t		SglAttributeFlags;
	uint8_t			ElementLength;
	uint8_t			Flags;
	uint32_t		PageFrameSize;
} i2o_sge_sgl_attributes_element_t;

/* Short Transaction Parameters Element */

typedef struct i2o_sge_short_transaction_element {
	uint16_t		ClassFields;
	uint8_t			ElementLength;
	uint8_t			Flags;
	uint32_t		BufferContext;
} i2o_sge_short_transaction_element_t;

/* Simple Addressing Scatter-Gather Element */

typedef struct i2o_sge_simple_element {
	i2o_flags_count_t	FlagsCount;
	uint32_t		PhysicalAddress;
} i2o_sge_simple_element_t;

/* Simple Addressing with Context Scatter-Gather Element */

typedef struct i2o_sge_simple_context_element {
	i2o_flags_count_t	FlagsCount;
	uint32_t		BufferContext[1];
	uint32_t		PhysicalAddress;
} i2o_sge_simple_context_element_t;

/* Transport Detail Element */

typedef struct i2o_sge_transport_element {
	uint_t			LongElementLength:24;
	uint_t			Flags:8;
} i2o_sge_transport_element_t;

typedef struct i2o_sg_element {
	union {
	    /* Bit Bucket Element */
	    i2o_sge_bit_bucket_element_t		BitBucket;

	    /* Chain Addressing Element */
	    i2o_sge_chain_element_t			Chain;

	    /* Chain Addressing with Context Element */
	    i2o_sge_chain_context_element_t		ChainContext;

	    /* Ignore Scatter-Gather Element */
	    i2o_sge_ignore_element_t			Ignore;

	    /* Immediate Data Element */
	    i2o_sge_immediate_data_element_t		ImmediateData;

	    /* Immediate Data with Context Element */
	    i2o_sge_immediate_data_context_element_t	ImmediateDataContext;

	    /* Long Transaction Parameters Element */
	    i2o_sge_long_transaction_element_t		LongTransaction;

	    /* Page List Element */
	    i2o_sge_page_element_t			Page;

	    /* Page List with Context Element */
	    i2o_sge_page_context_element_t		PageContext;

	    /* SGL Attribute Element */
	    i2o_sge_sgl_attributes_element_t		SGLAttribute;

	    /* Short Transaction Parameters Element */
	    i2o_sge_short_transaction_element_t		ShortTransaction;

	    /* Simple Addressing Element */
	    i2o_sge_simple_element_t			Simple[1];

	    /* Simple Addressing with Context Element */
	    i2o_sge_simple_context_element_t		SimpleContext[1];

	    /* Transport Detail Element */
	    i2o_sge_transport_element_t			Transport;
	} u1;
} i2o_sg_element_t;

/* ************************************************************************** */
/* Basic Parameter Group Access */
/* ************************************************************************** */

/* Operation Function Numbers */

#define	I2O_PARAMS_OPERATION_FIELD_GET		0x0001
#define	I2O_PARAMS_OPERATION_LIST_GET		0x0002
#define	I2O_PARAMS_OPERATION_MORE_GET		0x0003
#define	I2O_PARAMS_OPERATION_SIZE_GET		0x0004
#define	I2O_PARAMS_OPERATION_TABLE_GET		0x0005
#define	I2O_PARAMS_OPERATION_FIELD_SET		0x0006
#define	I2O_PARAMS_OPERATION_LIST_SET		0x0007
#define	I2O_PARAMS_OPERATION_ROW_ADD		0x0008
#define	I2O_PARAMS_OPERATION_ROW_DELETE		0x0009
#define	I2O_PARAMS_OPERATION_TABLE_CLEAR	0x000A

/* Operations List Header */

typedef struct i2o_param_operations_list_header {
	uint16_t		OperationCount;
	uint16_t		Reserved;
} i2o_param_operations_list_header_t;

/* Results List Header */

typedef struct i2o_param_results_list_header {
	uint16_t		ResultCount;
	uint16_t		Reserved;
} i2o_param_results_list_header_t;

/* Read Operation Result Block Template Structure */

typedef struct i2o_param_read_operation_result {
	uint16_t		BlockSize;
	uint8_t			BlockStatus;
	uint8_t			ErrorInfoSize;
	/*			Operations Results	*/
	/*			Pad (if any)		*/
	/*			ErrorInformation (if any) */
} i2o_param_read_operation_result_t;

typedef struct i2o_table_read_operation_result {
	uint16_t		BlockSize;
	uint8_t			BlockStatus;
	uint8_t			ErrorInfoSize;
	uint16_t		RowCount;
	uint16_t		MoreFlag;
	/*			Operations Results	*/
	/*			Pad (if any)		*/
	/*			ErrorInformation (if any) */
} i2o_table_read_operation_result_t;

/* Error Information Template Structure */

typedef struct i2o_param_error_info_template {
	uint16_t		OperationCode;
	uint16_t		GroupNumber;
	uint16_t		FieldIdx;
	uint8_t			AdditionalStatus;
	uint8_t			NumberKeys;
	/*			List of Key Values (variable) */
	/*			Pad (if any)		 */
} i2o_param_error_info_template_t;

/* Operation Template for Specific Fields */

typedef struct i2o_param_operation_specific_template {
	uint16_t		Operation;
	uint16_t		GroupNumber;
	uint16_t		FieldCount;
	uint16_t		FieldIdx[1];
	/*			Pad (if any)		 */
} i2o_param_operation_specific_template_t;

/* Operation Template for All Fields */

typedef struct i2o_param_operation_all_template {
	uint16_t		Operation;
	uint16_t		GroupNumber;
	uint16_t		FieldCount;
	/*			Pad (if any)		 */
} i2o_param_operation_all_template_t;

/* Operation Template for All List Fields */

typedef struct i2o_param_operation_all_list_template {
	uint16_t		Operation;
	uint16_t		GroupNumber;
	uint16_t		FieldCount;
	uint16_t		KeyCount;
	uint8_t			KeyValue;
	/*			Pad (if any)		 */
} i2o_param_operation_all_list_template_t;

/* Modify Operation Result Block Template Structure */

typedef struct i2o_param_modify_operation_result {
	uint16_t		BlockSize;
	uint8_t			BlockStatus;
	uint8_t			ErrorInfoSize;
	/*			ErrorInformation (if any) */
} i2o_param_modify_operation_result_t;

/* Operation Template for Row Delete */

typedef struct i2o_param_operation_row_delete_template {
	uint16_t		Operation;
	uint16_t		GroupNumber;
	uint16_t		RowCount;
	uint8_t			KeyValue;
} i2o_param_operation_row_delete_template_t;

/* Operation Template for Table Clear */

typedef struct i2o_param_operation_table_clear_template {
	uint16_t		Operation;
	uint16_t		GroupNumber;
} i2o_param_operation_table_clear_template_t;

/* Status codes and Error Information for Parameter functions */

#define	I2O_PARAMS_STATUS_SUCCESS		0x00
#define	I2O_PARAMS_STATUS_BAD_KEY_ABORT		0x01
#define	I2O_PARAMS_STATUS_BAD_KEY_CONTINUE	0x02
#define	I2O_PARAMS_STATUS_BUFFER_FULL		0x03
#define	I2O_PARAMS_STATUS_BUFFER_TOO_SMALL	0x04
#define	I2O_PARAMS_STATUS_FIELD_UNREADABLE	0x05
#define	I2O_PARAMS_STATUS_FIELD_UNWRITEABLE	0x06
#define	I2O_PARAMS_STATUS_INSUFFICIENT_FIELDS	0x07
#define	I2O_PARAMS_STATUS_INVALID_GROUP_ID	0x08
#define	I2O_PARAMS_STATUS_INVALID_OPERATION	0x09
#define	I2O_PARAMS_STATUS_NO_KEY_FIELD		0x0A
#define	I2O_PARAMS_STATUS_NO_SUCH_FIELD		0x0B
#define	I2O_PARAMS_STATUS_NON_DYNAMIC_GROUP	0x0C
#define	I2O_PARAMS_STATUS_OPERATION_ERROR	0x0D
#define	I2O_PARAMS_STATUS_SCALAR_ERROR		0x0E
#define	I2O_PARAMS_STATUS_TABLE_ERROR		0x0F
#define	I2O_PARAMS_STATUS_WRONG_GROUP_TYPE	0x10


/* ************************************************************************** */
/* GROUP Parameter Groups */
/* ************************************************************************** */

/* GROUP Configuration and Operating Structures and Defines */

/* Groups Numbers */

#define	I2O_UTIL_PARAMS_DESCRIPTOR_GROUP_NO		0xF000
#define	I2O_UTIL_PHYSICAL_DEVICE_TABLE_GROUP_NO 	0xF001
#define	I2O_UTIL_CLAIMED_TABLE_GROUP_NO			0xF002
#define	I2O_UTIL_USER_TABLE_GROUP_NO			0xF003
#define	I2O_UTIL_PRIVATE_MESSAGE_EXTENSIONS_GROUP_NO 	0xF005
#define	I2O_UTIL_AUTHORIZED_USER_TABLE_GROUP_NO  	0xF006
#define	I2O_UTIL_DEVICE_IDENTITY_GROUP_NO		0xF100
#define	I2O_UTIL_DDM_IDENTITY_GROUP_NO			0xF101
#define	I2O_UTIL_USER_INFORMATION_GROUP_NO		0xF102
#define	I2O_UTIL_SGL_OPERATING_LIMITS_GROUP_NO		0xF103
#define	I2O_UTIL_SENSORS_GROUP_NO			0xF200

/* UTIL Group F000h - GROUP DESCRIPTORS Parameter Group */

#define	I2O_UTIL_GROUP_PROPERTIES_GROUP_TABLE		0x01
#define	I2O_UTIL_GROUP_PROPERTIES_ROW_ADDITION		0x02
#define	I2O_UTIL_GROUP_PROPERTIES_ROW_DELETION		0x04
#define	I2O_UTIL_GROUP_PROPERTIES_CLEAR_OPERATION	0x08

typedef struct i2o_util_group_descriptor_table {
	uint16_t		GroupNumber;
	uint16_t		FieldCount;
	uint16_t		RowCount;
	uint8_t			Properties;
	uint8_t			reserved;
} i2o_util_group_descriptor_table_t;

/* UTIL Group F001h - Physical Device Table Parameter Group */

typedef struct i2o_util_physical_device_table {
	uint32_t		AdapterID;
} i2o_util_physical_device_table_t;

/* UTIL Group F002h - Claimed Table Parameter Group */

typedef struct i2o_util_claimed_table {
	uint16_t		ClaimedTID;
} i2o_util_claimed_table_t;

/* UTIL Group F003h - User Table Parameter Group */

typedef struct i2o_util_user_table {
	uint16_t		Instance;
	uint16_t		UserTID;
	uint8_t			ClaimType;
	uint8_t			reserved1;
	uint16_t		reserved2;
} i2o_util_user_table_t;

/* UTIL Group F005h - Private Message Extensions Parameter Group */

typedef struct i2o_util_private_message_extensions_table {
	uint16_t		ExtInstance;
	uint16_t		OrganizationID;
	uint16_t		XFunctionCode;
} i2o_util_private_message_extensions_table_t;

/* UTIL Group F006h - Authorized User Table Parameter Group */

typedef struct i2o_util_authorized_user_table {
	uint16_t		AlternateTID;
} i2o_util_authorized_user_table_t;

/* UTIL Group F100h - Device Identity Parameter Group */

typedef struct i2o_util_device_identity_scalar {
	uint32_t		ClassID;
	uint16_t		OwnerTID;
	uint16_t		ParentTID;
	uint8_t			VendorInfo[I2O_DEVID_VENDOR_INFO_SZ];
	uint8_t			ProductInfo[I2O_DEVID_PRODUCT_INFO_SZ];
	uint8_t			Description[I2O_DEVID_DESCRIPTION_SZ];
	uint8_t			ProductRevLevel[I2O_DEVID_REV_LEVEL_SZ];
	uint8_t			SNFormat;
	uint8_t			SerialNumber[I2O_MAX_SERIAL_NUMBER_SZ];
} i2o_util_device_identity_scalar_t;

/* UTIL Group F101h - DDM Identity Parameter Group */

typedef struct i2o_util_ddm_identity_scalar {
	uint16_t		DdmTID;
	uint8_t			ModuleName[I2O_MODULE_NAME_SZ];
	uint8_t			ModuleRevLevel[I2O_DEVID_REV_LEVEL_SZ];
	uint8_t			SNFormat;
	uint8_t			SerialNumber[I2O_MAX_SERIAL_NUMBER_SZ];
} i2o_util_ddm_identity_scalar_t;

/* UTIL Group F102h - User Information Parameter Group */

#define	I2O_USER_DEVICE_NAME_SZ		64
#define	I2O_USER_SERVICE_NAME_SZ	64
#define	I2O_USER_PHYSICAL_LOCATION_SZ	64

typedef struct i2o_util_user_information_scalar {
	uint8_t			DeviceName[I2O_USER_DEVICE_NAME_SZ];
	uint8_t			ServiceName[I2O_USER_SERVICE_NAME_SZ];
	uint8_t			PhysicalLocation[I2O_USER_PHYSICAL_LOCATION_SZ];
	uint32_t		InstanceNumber;
} i2o_util_user_information_scalar_t;

/* UTIL Group F103h - SGL Operating Limits Parameter Group */

typedef struct i2o_util_sgl_operating_limits_scalar {
	uint32_t		SglChainSize;
	uint32_t		SglChainSizeMax;
	uint32_t		SglChainSizeTarget;
	uint16_t		SglFragCount;
	uint16_t		SglFragCountMax;
	uint16_t		SglFragCountTarget;
} i2o_util_sgl_operating_limits_scalar_t;

/* UTIL Group F200h - Sensors Parameter Group */

#define	I2O_SENSOR_COMPONENT_OTHER		0x00
#define	I2O_SENSOR_COMPONENT_PLANAR_LOGIC_BOARD	0x01
#define	I2O_SENSOR_COMPONENT_CPU		0x02
#define	I2O_SENSOR_COMPONENT_CHASSIS		0x03
#define	I2O_SENSOR_COMPONENT_POWER_SUPPLY	0x04
#define	I2O_SENSOR_COMPONENT_STORAGE		0x05
#define	I2O_SENSOR_COMPONENT_EXTERNAL		0x06

#define	I2O_SENSOR_SENSOR_CLASS_ANALOG		0x00
#define	I2O_SENSOR_SENSOR_CLASS_DIGITAL		0x01

#define	I2O_SENSOR_SENSOR_TYPE_OTHER		0x00
#define	I2O_SENSOR_SENSOR_TYPE_THERMAL		0x01
#define	I2O_SENSOR_SENSOR_TYPE_DC_VOLTAGE	0x02
#define	I2O_SENSOR_SENSOR_TYPE_AC_VOLTAGE	0x03
#define	I2O_SENSOR_SENSOR_TYPE_DC_CURRENT	0x04
#define	I2O_SENSOR_SENSOR_TYPE_AC_CURRENT	0x05
#define	I2O_SENSOR_SENSOR_TYPE_DOOR_OPEN	0x06
#define	I2O_SENSOR_SENSOR_TYPE_FAN_OPERATIONAL  0x07

#define	I2O_SENSOR_SENSOR_STATE_NORMAL		0x00
#define	I2O_SENSOR_SENSOR_STATE_ABNORMAL	0x01
#define	I2O_SENSOR_SENSOR_STATE_UNKNOWN		0x02
#define	I2O_SENSOR_SENSOR_STATE_LOW_CAT		0x03
#define	I2O_SENSOR_SENSOR_STATE_LOW		0x04
#define	I2O_SENSOR_SENSOR_STATE_LOW_WARNING	0x05
#define	I2O_SENSOR_SENSOR_STATE_HIGH_WARNING	0x06
#define	I2O_SENSOR_SENSOR_STATE_HIGH		0x07
#define	I2O_SENSOR_SENSOR_STATE_HIGH_CAT	0x08

#define	I2O_SENSOR_EVENT_ENABLE_STATE_CHANGE	0x0001
#define	I2O_SENSOR_EVENT_ENABLE_LOW_CATASTROPHIC 0x0002
#define	I2O_SENSOR_EVENT_ENABLE_LOW_READING	0x0004
#define	I2O_SENSOR_EVENT_ENABLE_LOW_WARNING	0x0008
#define	I2O_SENSOR_EVENT_ENABLE_CHANGE_TO_NORMAL 0x0010
#define	I2O_SENSOR_EVENT_ENABLE_HIGH_WARNING	0x0020
#define	I2O_SENSOR_EVENT_ENABLE_HIGH_READING	0x0040
#define	I2O_SENSOR_EVENT_ENABLE_HIGH_CATASTROPHIC 0x0080

typedef struct i2o_util_sensors_table {
	uint16_t		SensorInstance;
	uint8_t			Component;
	uint16_t		ComponentInstance;
	uint8_t			SensorClass;
	uint8_t			SensorType;
	int8_t			ScalingExponent;
	int32_t			ActualReading;
	int32_t			MinimumReading;
	int32_t			Low2LowCatThreshold;
	int32_t			LowCat2LowThreshold;
	int32_t			LowWarn2LowThreshold;
	int32_t			Low2LowWarnThreshold;
	int32_t			Norm2LowWarnThreshold;
	int32_t			LowWarn2NormThreshold;
	int32_t			NominalReading;
	int32_t			HiWarn2NormThreshold;
	int32_t			Norm2HiWarnThreshold;
	int32_t			High2HiWarnThreshold;
	int32_t			HiWarn2HighThreshold;
	int32_t			HiCat2HighThreshold;
	int32_t			Hi2HiCatThreshold;
	int32_t			MaximumReading;
	uint8_t			SensorState;
	uint16_t		EventEnable;
} i2o_util_sensors_table_t;

/*
 * *************************************************************************
 * Definitions used in Solaris for I2O Framework support.
 *
 * (NOTE: Current commitment level is PROJECT PRIVATE.)
 * *************************************************************************
 */

#define	I2O_MSG_SLEEP		DDI_DMA_SLEEP
#define	I2O_MSG_DONTWAIT	DDI_DMA_DONTWAIT

typedef void *i2o_iop_handle_t;
typedef void *i2o_msg_handle_t;

int i2o_msg_osm_register(dev_info_t *dip, i2o_iop_handle_t *handlep);
int i2o_msg_get_lct(i2o_iop_handle_t iop, void *buf,
	size_t buf_size, size_t *lct_sizep, size_t *real_sizep);
int i2o_msg_alloc(i2o_iop_handle_t iop, int (*waitfp)(caddr_t), caddr_t arg,
	void **msgp, i2o_msg_handle_t *msg_handlep,
	ddi_acc_handle_t *acc_handlep);
int i2o_msg_send(i2o_iop_handle_t iop, void *msg, i2o_msg_handle_t handle);
void i2o_msg_osm_unregister(i2o_iop_handle_t *iop);

/*
 * PCI Extensions to I2O Spec 1.5.
 *
 * (Note: Should these definitons go into pci.h?)
 */
#define	PCI_I2O_BASE_CLASS		0x0E
#define	PCI_I2O_SUB_CLASS		0x00
#define	PCI_I2O_PROG_CLASS0		0x00	/* no IOP interrupt */
#define	PCI_I2O_PROG_CLASS1		0x01	/* IOP interrupt supported */

/* Offset definitions for FIFO registers in IOP's shared memory */

#define	PCI_IOP_INBOUND_FREELIST_FIFO	0x40
#define	PCI_IOP_INBOUND_POSTLIST_FIFO	0x40
#define	PCI_IOP_OUTBOUND_FREELIST_FIFO	0x44
#define	PCI_IOP_OUTBOUND_POSTLIST_FIFO	0x44

/* Offset definitions for Interrupt Control registers in IOP's shared memory */

#define	PCI_IOP_INTR_MASK_REG		0x34
#define	PCI_IOP_INTR_STATUS_REG		0x30

/* Bit definitions in Interrupt Mask Register */
#define	I2O_OUTBOUND_POSTLIST_SERVICE_INTR_MASK		0x08

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_I2OMSG_H */