xref: /freebsd/sys/dev/firewire/iec13213.h (revision 4b2eaea43fec8e8792be611dea204071a10b655a)
1 /*
2  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
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  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the acknowledgement as bellow:
15  *
16  *    This product includes software developed by K. Kobayashi and H. Shimokawa
17  *
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
25  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * $FreeBSD$
34  *
35  */
36 
37 #define CSRTYPE_SHIFT	6
38 #define CSRTYPE_MASK	(3 << CSRTYPE_SHIFT)
39 #define CSRTYPE_I	(0 << CSRTYPE_SHIFT) /* Immediate */
40 #define CSRTYPE_C	(1 << CSRTYPE_SHIFT) /* CSR offset */
41 #define CSRTYPE_L	(2 << CSRTYPE_SHIFT) /* Leaf */
42 #define CSRTYPE_D	(3 << CSRTYPE_SHIFT) /* Directory */
43 
44 #define CSRKEY_MASK	0x3f
45 #define CSRKEY_DESC	0x01 /* Descriptor */
46 #define CSRKEY_BDINFO	0x02 /* Bus_Dependent_Info */
47 #define CSRKEY_VENDOR	0x03 /* Vendor */
48 #define CSRKEY_HW	0x04 /* Hardware_Version */
49 #define CSRKEY_MODULE	0x07 /* Module */
50 #define CSRKEY_NCAP	0x0c /* Node_Capabilities */
51 #define CSRKEY_EUI64	0x0d /* EUI_64 */
52 #define CSRKEY_UNIT	0x11 /* Unit */
53 #define CSRKEY_SPEC	0x12 /* Specifier_ID */
54 #define CSRKEY_VER	0x13 /* Version */
55 #define CSRKEY_DINFO	0x14 /* Dependent_Info */
56 #define CSRKEY_ULOC	0x15 /* Unit_Location */
57 #define CSRKEY_MODEL	0x17 /* Model */
58 #define CSRKEY_INST	0x18 /* Instance */
59 #define CSRKEY_KEYW	0x19 /* Keyword */
60 #define CSRKEY_FEAT	0x1a /* Feature */
61 #define CSRKEY_EROM	0x1b /* Extended_ROM */
62 #define CSRKEY_EKSID	0x1c /* Extended_Key_Specifier_ID */
63 #define CSRKEY_EKEY	0x1d /* Extended_Key */
64 #define CSRKEY_EDATA	0x1e /* Extended_Data */
65 #define CSRKEY_MDESC	0x1f /* Modifiable_Descriptor */
66 #define CSRKEY_DID	0x20 /* Directory_ID */
67 #define CSRKEY_REV	0x21 /* Revision */
68 
69 #define CROM_TEXTLEAF	(CSRTYPE_L | CSRKEY_DESC)	/* 0x81 */
70 #define CROM_LUN	(CSRTYPE_I | CSRKEY_DINFO)	/* 0x14 */
71 
72 /* ???
73 #define CSRKEY_MVID	0x3
74 #define CSRKEY_NUNQ	0x8d
75 #define CSRKEY_NPWR	0x30
76 */
77 
78 #define	CSRVAL_1394TA	0x00a02d
79 #define	CSRVAL_ANSIT10	0x00609e
80 #define	CSR_PROTAVC	0x010001
81 #define	CSR_PROTCAL	0x010002
82 #define	CSR_PROTEHS	0x010004
83 #define	CSR_PROTHAVI	0x010008
84 #define	CSR_PROTCAM104	0x000100
85 #define	CSR_PROTCAM120	0x000101
86 #define	CSR_PROTCAM130	0x000102
87 #define	CSR_PROTDPP	0x0a6be2
88 #define	CSR_PROTIICP	0x4b661f
89 
90 #define	CSRVAL_T10SBP2	0x010483
91 
92 struct csrreg {
93 	u_int32_t val:24,
94 		  key:8;
95 };
96 struct csrhdr {
97 	u_int32_t crc:16,
98 		  crc_len:8,
99 		  info_len:8;
100 };
101 struct csrdirectory {
102 	u_int32_t crc:16,
103 		  crc_len:16;
104 	struct csrreg entry[0];
105 };
106 struct csrtext {
107 	u_int32_t crc:16,
108 		  crc_len:16;
109 	u_int32_t spec_id:24,
110 		  spec_type:8;
111 	u_int32_t lang_id;
112 	u_int32_t text[0];
113 };
114 struct businfo {
115 	u_int32_t crc:16,
116 		  crc_len:8,
117 		  :12,
118 		  max_rec:4,
119 		  clk_acc:8,
120 		  :4,
121 		  bmc:1,
122 		  isc:1,
123 		  cmc:1,
124 		  irmc:1;
125 	u_int32_t c_id_hi:8,
126 		  v_id:24;
127 	u_int32_t c_id_lo;
128 };
129 
130 #define CROM_MAX_DEPTH	10
131 struct crom_ptr {
132 	struct csrdirectory *dir;
133 	int index;
134 };
135 
136 struct crom_context {
137 	int depth;
138 	struct crom_ptr stack[CROM_MAX_DEPTH];
139 };
140 
141 void crom_init_context(struct crom_context *, u_int32_t *);
142 struct csrreg *crom_get(struct crom_context *);
143 void crom_next(struct crom_context *);
144 void crom_parse_text(struct crom_context *, char *, int);
145 u_int16_t crom_crc(u_int32_t *r, int);
146 struct csrreg *crom_search_key(struct crom_context *, u_int8_t);
147 #ifndef _KERNEL
148 char *crom_desc(struct crom_context *, char *, int);
149 #endif
150