1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_PICLDEVTREE_H
28 #define	_PICLDEVTREE_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include "picldefs.h"
35 
36 #define	DEVICE_TYPE_BLOCK	"block"
37 #define	DEVICE_TYPE_BYTE	"byte"
38 #define	DEVICE_TYPE_DISK	"disk"
39 #define	DEVICE_TYPE_SES		"ses"
40 #define	DEVICE_TYPE_FP		"fp"
41 
42 #define	HASH_TABLE_SIZE		64
43 #define	HASH_INDEX(s, x)	((int)((x) & ((s) - 1)))
44 
45 #define	MAX_NAMEVAL_SIZE	80
46 #define	CONFFILE_LINELEN_MAX	1024
47 
48 #define	KSTAT_STATE_BEGIN	"state_begin"
49 #define	KSTAT_CPU_INFO		"cpu_info"
50 #define	ASR_DISABLED		"disabled"
51 #define	ASR_FAILED		"failed"
52 
53 #define	DEVTREE_CONFFILE_NAME		"picldevtree.conf"
54 #define	ASRTREE_CONFFILE_NAME		"picl_asr.conf"
55 #define	CONFFILE_COMMENT_CHAR		'#'
56 
57 /*
58  * Constants
59  */
60 #define	FFB_MANUF_BUFSIZE	256
61 #define	SUPPORTED_NUM_CELL_SIZE	2	/* #size-cells */
62 #define	MAX_STATE_SIZE			32
63 
64 /*
65  * Hash table structure
66  */
67 typedef struct hash_elem {
68 	picl_nodehdl_t		hdl;
69 	struct hash_elem	*next;
70 } hash_elem_t;
71 
72 typedef struct {
73 	int			hash_size;
74 	hash_elem_t		**tbl;
75 } hash_t;
76 
77 /*
78  * name to class map entries in the conf file
79  */
80 typedef struct conf_entries {
81 	char			*name;
82 	char			*piclclass;
83 	struct conf_entries	*next;
84 } conf_entries_t;
85 
86 /*
87  * name to address to class map for asr2
88  */
89 typedef struct asr_conf_entries {
90 	char			*name;
91 	char			*piclclass;
92 	char			*status;
93 	char			*address;
94 	char			*props;
95 	struct asr_conf_entries	*next;
96 } asr_conf_entries_t;
97 
98 /*
99  * type, name, val property triplet for asr2
100  */
101 typedef struct asr_prop_triplet {
102 	char			*proptype;
103 	char			*propname;
104 	char			*propval;
105 } asr_prop_triplet_t;
106 
107 /*
108  * built-in name to class mapping table
109  */
110 typedef struct {
111 	char	name[MAX_NAMEVAL_SIZE];
112 	char	piclclass[PICL_CLASSNAMELEN_MAX];
113 } builtin_map_t;
114 
115 /*
116  * property name to type mapping table
117  */
118 typedef struct {
119 	char	pname[PICL_PROPNAMELEN_MAX];
120 	int	type;
121 } pname_type_map_t;
122 
123 /* known values for manufacturer's JED code */
124 #define	MANF_BROOKTREE		214
125 #define	MANF_MITSUBISHI		28
126 #define	FFB_NAME		"ffb"
127 #define	FFBIOC			('F' << 8)
128 #define	FFB_SYS_INFO		(FFBIOC| 80)
129 
130 /* FFB strap reg union */
131 typedef union {
132 	struct {
133 		uint32_t	unused:24;
134 		uint32_t	afb_flag:1;
135 		uint32_t	major_rev:2;
136 		uint32_t	board_rev:2;
137 		uint32_t	board_mem:1;
138 		uint32_t	cbuf:1;
139 		uint32_t	bbuf:1;
140 	} fld;
141 	uint32_t		ffb_strap_bits;
142 } strap_un_t;
143 
144 /* FFB mnufacturer union */
145 typedef union {
146 	struct {
147 		uint32_t	version:4;	/* version of part number */
148 		uint32_t	partno:16;	/* part number */
149 		uint32_t	manf:11;	/* manufacturer's JED code */
150 		uint32_t	one:1;		/* always set to '1' */
151 	} fld;
152 	uint32_t		encoded_id;
153 } manuf_t;
154 
155 typedef struct ffb_sys_info {
156 	strap_un_t	ffb_strap_bits;	/* ffb_strapping register	*/
157 	manuf_t		fbc_version;	/* revision of FBC chip		*/
158 	manuf_t		dac_version;	/* revision of DAC chip		*/
159 	manuf_t		fbram_version;	/* revision of FBRAMs chip	*/
160 	uint32_t	flags;		/* miscellaneous flags		*/
161 	uint32_t	afb_nfloats;	/* no. of Float asics in AFB	*/
162 	uint32_t	pad[58];	/* padding for AFB chips & misc. */
163 } ffb_sys_info_t;
164 
165 typedef struct memspecs {
166 	uint32_t physlo;
167 	uint32_t physhi;
168 	uint64_t size;
169 } memspecs_t;
170 
171 /*
172  * UnitAddress property related constants and data structures
173  */
174 
175 #define	DEFAULT_ADDRESS_CELLS		2
176 #define	MAX_UNIT_ADDRESS_LEN		256
177 
178 typedef int unitaddr_func_t(char *, int, uint32_t *, uint_t);
179 
180 typedef struct {
181 	char		*class;		/* class name */
182 	unitaddr_func_t	*func;		/* function to encode unit address */
183 	int		addrcellcnt;	/* #addrcell expected, if non-zero */
184 } unitaddr_map_t;
185 
186 #ifdef	__cplusplus
187 }
188 #endif
189 
190 #endif	/* _PICLDEVTREE_H */
191