xref: /titanic_52/usr/src/cmd/picl/plugins/common/devtree/picldevtree.h (revision c2580b931007758eab8cb5ae8726ebe1588e259b)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include "picldefs.h"
37 
38 #define	DEVICE_TYPE_BLOCK	"block"
39 #define	DEVICE_TYPE_BYTE	"byte"
40 #define	DEVICE_TYPE_DISK	"disk"
41 #define	DEVICE_TYPE_SES		"ses"
42 #define	DEVICE_TYPE_FP		"fp"
43 
44 #define	HASH_TABLE_SIZE		64
45 #define	HASH_INDEX(s, x)	((int)((x) & ((s) - 1)))
46 
47 #define	MAX_NAMEVAL_SIZE	80
48 #define	CONFFILE_LINELEN_MAX	1024
49 
50 #define	KSTAT_STATE_BEGIN	"state_begin"
51 #define	KSTAT_CPU_INFO		"cpu_info"
52 #define	ASR_DISABLED		"disabled"
53 #define	ASR_FAILED		"failed"
54 
55 #define	DEVTREE_CONFFILE_NAME		"picldevtree.conf"
56 #define	ASRTREE_CONFFILE_NAME		"picl_asr.conf"
57 #define	CONFFILE_COMMENT_CHAR		'#'
58 
59 /*
60  * Constants
61  */
62 #define	FFB_MANUF_BUFSIZE	256
63 #define	SUPPORTED_NUM_CELL_SIZE	2	/* #size-cells */
64 #define	MAX_STATE_SIZE			32
65 
66 /*
67  * Hash table structure
68  */
69 typedef struct hash_elem {
70 	picl_nodehdl_t		hdl;
71 	struct hash_elem	*next;
72 } hash_elem_t;
73 
74 typedef struct {
75 	int			hash_size;
76 	hash_elem_t		**tbl;
77 } hash_t;
78 
79 /*
80  * name to class map entries in the conf file
81  */
82 typedef struct conf_entries {
83 	char			*name;
84 	char			*piclclass;
85 	struct conf_entries	*next;
86 } conf_entries_t;
87 
88 /*
89  * name to address to class map for asr2
90  */
91 typedef struct asr_conf_entries {
92 	char			*name;
93 	char			*piclclass;
94 	char			*status;
95 	char			*address;
96 	char			*props;
97 	struct asr_conf_entries	*next;
98 } asr_conf_entries_t;
99 
100 /*
101  * type, name, val property triplet for asr2
102  */
103 typedef struct asr_prop_triplet {
104 	char			*proptype;
105 	char			*propname;
106 	char			*propval;
107 } asr_prop_triplet_t;
108 
109 /*
110  * built-in name to class mapping table
111  */
112 typedef struct {
113 	char	name[MAX_NAMEVAL_SIZE];
114 	char	piclclass[PICL_CLASSNAMELEN_MAX];
115 } builtin_map_t;
116 
117 /*
118  * property name to type mapping table
119  */
120 typedef struct {
121 	char	pname[PICL_PROPNAMELEN_MAX];
122 	int	type;
123 } pname_type_map_t;
124 
125 /* known values for manufacturer's JED code */
126 #define	MANF_BROOKTREE		214
127 #define	MANF_MITSUBISHI		28
128 #define	FFB_NAME		"ffb"
129 #define	FFBIOC			('F' << 8)
130 #define	FFB_SYS_INFO		(FFBIOC| 80)
131 
132 /* FFB strap reg union */
133 typedef union {
134 	struct {
135 		uint32_t	unused:24;
136 		uint32_t	afb_flag:1;
137 		uint32_t	major_rev:2;
138 		uint32_t	board_rev:2;
139 		uint32_t	board_mem:1;
140 		uint32_t	cbuf:1;
141 		uint32_t	bbuf:1;
142 	} fld;
143 	uint32_t		ffb_strap_bits;
144 } strap_un_t;
145 
146 /* FFB mnufacturer union */
147 typedef union {
148 	struct {
149 		uint32_t	version:4;	/* version of part number */
150 		uint32_t	partno:16;	/* part number */
151 		uint32_t	manf:11;	/* manufacturer's JED code */
152 		uint32_t	one:1;		/* always set to '1' */
153 	} fld;
154 	uint32_t		encoded_id;
155 } manuf_t;
156 
157 typedef struct ffb_sys_info {
158 	strap_un_t	ffb_strap_bits;	/* ffb_strapping register	*/
159 	manuf_t		fbc_version;	/* revision of FBC chip		*/
160 	manuf_t		dac_version;	/* revision of DAC chip		*/
161 	manuf_t		fbram_version;	/* revision of FBRAMs chip	*/
162 	uint32_t	flags;		/* miscellaneous flags		*/
163 	uint32_t	afb_nfloats;	/* no. of Float asics in AFB	*/
164 	uint32_t	pad[58];	/* padding for AFB chips & misc. */
165 } ffb_sys_info_t;
166 
167 typedef struct memspecs {
168 	uint32_t physlo;
169 	uint32_t physhi;
170 	uint64_t size;
171 } memspecs_t;
172 
173 /*
174  * UnitAddress property related constants and data structures
175  */
176 
177 #define	DEFAULT_ADDRESS_CELLS		2
178 #define	MAX_UNIT_ADDRESS_LEN		256
179 
180 typedef int unitaddr_func_t(char *, int, uint32_t *, uint_t);
181 
182 typedef struct {
183 	char		*class;		/* class name */
184 	unitaddr_func_t	*func;		/* function to encode unit address */
185 	int		addrcellcnt;	/* #addrcell expected, if non-zero */
186 } unitaddr_map_t;
187 
188 #ifdef	__cplusplus
189 }
190 #endif
191 
192 #endif	/* _PICLDEVTREE_H */
193