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