xref: /illumos-gate/usr/src/uts/intel/sys/prom_emul.h (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_PROM_EMUL_H
28 #define	_SYS_PROM_EMUL_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * The following structure describes a property attached to a node
36  * in the in-kernel copy of the PROM device tree.
37  */
38 struct prom_prop {
39 	struct prom_prop *pp_next;
40 	char		 *pp_name;
41 	int		 pp_len;
42 	void		 *pp_val;
43 };
44 
45 /*
46  * The following structure describes a node in the in-kernel copy
47  * of the PROM device tree.
48  */
49 struct prom_node {
50 	pnode_t	pn_nodeid;
51 	struct prom_prop *pn_propp;
52 	struct prom_node *pn_child;
53 	struct prom_node *pn_sibling;
54 };
55 
56 typedef struct prom_node prom_node_t;
57 
58 /*
59  * These are promif emulation functions, intended only for promif use
60  */
61 extern void promif_create_device_tree(void);
62 
63 extern pnode_t promif_findnode_byname(pnode_t n, char *name);
64 extern pnode_t promif_nextnode(pnode_t n);
65 extern pnode_t promif_childnode(pnode_t n);
66 
67 extern int promif_getproplen(pnode_t n, char *name);
68 extern int promif_getprop(pnode_t n,  char *name, void *value);
69 extern int promif_bounded_getprop(pnode_t, char *name, void *value, int len);
70 char *promif_nextprop(pnode_t n, char *previous, char *next);
71 
72 /*
73  * XXX: The following functions are unsafe and unecessary, and should be
74  * XXX: removed. OS created nodes belong in the OS copy of the device tree.
75  * XXX: The OS should not be creating nodes in the prom's device tree!
76  */
77 extern pnode_t promif_add_child(pnode_t parent, pnode_t child, char *name);
78 extern void promif_create_prop_external(pnode_t, char *name, void *, int);
79 
80 #ifdef	__cplusplus
81 }
82 #endif
83 
84 #endif /* _SYS_PROM_EMUL_H */
85