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
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.
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]
23 * Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
36 /* structures necessary to hold Openprom data */
39 * 128 is the size of the largest (currently) property name
40 * 4096 - MAXPROPSIZE - sizeof (int) is the size of the largest
41 * (currently) property value that is allowed.
42 * the sizeof (u_int) is from struct openpromio
44 #define MAXPROPSIZE 128
45 #define MAXVALSIZE (4096 - MAXPROPSIZE - sizeof (uint_t))
46 #define BUFSIZE (MAXPROPSIZE + MAXVALSIZE + sizeof (uint_t))
49 struct openpromio opp
;
54 * The prop structures associated with a Prom_node were formerly statically
55 * sized - via the buf element of the Oppbuf union. This was highly memory
56 * inefficient, so dynamic sizing capabilities have been introduced.
58 * This has been achieved via the creation of dynopenpromio and dynOppbuf
59 * structs, and altering the prop structure. The prop structure's name and value
60 * elements are now typed as dynOppbuf instead of Oppbuf.
62 * For legacy purposes, static_prop has been created. It is essentially the same
63 * as the former prop structure, but the *next element now points to a
64 * static_prop structure instead of a prop structure.
66 typedef struct static_prop StaticProp
;
71 int size
; /* size of data in bytes */
75 * dynopenpromio structs are similar to openpromio structs, but with 2 major
76 * differences. The first is that the opio_u.b element is char * instead of
77 * char [], which allows for dynamic sizing.
79 * The second regards opio_u.i, which was an int, but is now int []. In almost
80 * all cases, only opio_u.i (opio_u.i[0]) will be referenced. However, certain
81 * platforms rely on the fact that Prop structures formerly contained Oppbuf
82 * unions, the buf element of which was statically sized at 4k. In theory, this
83 * enabled those platforms to validly reference any part of the union up to 4k
84 * from the start. In reality, no element greater than opio_u.i[4] is currently
85 * referenced, hence OPROM_NODE_SIZE (named because opio_u.i is usually
86 * referenced as oprom_node) being set to 5.
88 * A minor difference is that the holds_array element has been added, which
89 * affords an easy way to determine whether opio_u contains char * or int.
91 #define OPROM_NODE_SIZE 5
92 struct dynopenpromio
{
96 int i
[OPROM_NODE_SIZE
];
102 * dynOppbuf structs are a dynamic alternative to Oppbuf unions. The statically
103 * sized Oppbuf.buf element has been removed, and the opp element common to both
104 * is of type struct dynopenpromio instead of struct openpromio. This allows us
105 * to take advantage of dynopenpromio's dynamic sizing capabilities.
107 typedef struct dynoppbuf dynOppbuf
;
109 struct dynopenpromio opp
;
113 typedef struct prop Prop
;
118 int size
; /* size of data in bytes */
121 typedef struct prom_node Prom_node
;
123 Prom_node
*parent
; /* points to parent node */
124 Prom_node
*child
; /* points to child PROM node */
125 Prom_node
*sibling
; /* point to next sibling */
126 Prop
*props
; /* points to list of properties */
130 * Defines for board types.
133 typedef struct board_node Board_node
;
139 Board_node
*next
; /* link for list */
142 typedef struct system_tree Sys_tree
;
144 Prom_node
*sys_mem
; /* System memory node */
145 Prom_node
*boards
; /* boards node holds bif info if present */
146 Board_node
*bd_list
; /* node holds list of boards */
147 int board_cnt
; /* number of boards in the system */
150 int do_prominfo(int, char *, int, int);
151 int is_openprom(void);
152 void promclose(void);
154 extern char *badarchmsg
;
155 int _error(char *fmt
, ...);
157 /* Functions for building the user copy of the device tree. */
158 Board_node
*find_board(Sys_tree
*, int);
159 Board_node
*insert_board(Sys_tree
*, int);
161 /* functions for searching for Prom nodes */
162 char *get_node_name(Prom_node
*);
163 char *get_node_type(Prom_node
*);
164 Prom_node
*dev_find_node(Prom_node
*, char *);
165 Prom_node
*dev_next_node(Prom_node
*, char *);
166 Prom_node
*dev_find_node_by_type(Prom_node
*root
, char *type
, char *property
);
167 Prom_node
*dev_next_node_by_type(Prom_node
*root
, char *type
, char *property
);
168 Prom_node
*dev_find_type(Prom_node
*, char *);
169 Prom_node
*dev_next_type(Prom_node
*, char *);
170 Prom_node
*sys_find_node(Sys_tree
*, int, char *);
171 Prom_node
*find_failed_node(Prom_node
*);
172 Prom_node
*next_failed_node(Prom_node
*);
173 Prom_node
*dev_find_node_by_compatible(Prom_node
*root
, char *compat
);
174 Prom_node
*dev_next_node_by_compatible(Prom_node
*root
, char *compat
);
175 int node_failed(Prom_node
*);
176 int node_status(Prom_node
*node
, char *status
);
177 void dump_node(Prom_node
*);
179 int has_board_num(Prom_node
*);
180 int get_board_num(Prom_node
*);
183 /* functions for searching for properties, extracting data from them */
184 void *get_prop_val(Prop
*);
185 void getpropval(struct openpromio
*);
186 Prop
*find_prop(Prom_node
*, char *);
192 #endif /* _PDEVINFO_H */