/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _PDEVINFO_H
#define _PDEVINFO_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/* structures necessary to hold Openprom data */
/*
* 128 is the size of the largest (currently) property name
* 4096 - MAXPROPSIZE - sizeof (int) is the size of the largest
* (currently) property value that is allowed.
* the sizeof (u_int) is from struct openpromio
*/
typedef union {
void *val_ptr;
} Oppbuf;
/*
* The prop structures associated with a Prom_node were formerly statically
* sized - via the buf element of the Oppbuf union. This was highly memory
* inefficient, so dynamic sizing capabilities have been introduced.
*
* This has been achieved via the creation of dynopenpromio and dynOppbuf
* structs, and altering the prop structure. The prop structure's name and value
* elements are now typed as dynOppbuf instead of Oppbuf.
*
* For legacy purposes, static_prop has been created. It is essentially the same
* as the former prop structure, but the *next element now points to a
* static_prop structure instead of a prop structure.
*/
struct static_prop {
};
/*
* dynopenpromio structs are similar to openpromio structs, but with 2 major
* differences. The first is that the opio_u.b element is char * instead of
* char [], which allows for dynamic sizing.
*
* The second regards opio_u.i, which was an int, but is now int []. In almost
* all cases, only opio_u.i (opio_u.i[0]) will be referenced. However, certain
* platforms rely on the fact that Prop structures formerly contained Oppbuf
* unions, the buf element of which was statically sized at 4k. In theory, this
* enabled those platforms to validly reference any part of the union up to 4k
* from the start. In reality, no element greater than opio_u.i[4] is currently
* referenced, hence OPROM_NODE_SIZE (named because opio_u.i is usually
* referenced as oprom_node) being set to 5.
*
* A minor difference is that the holds_array element has been added, which
* affords an easy way to determine whether opio_u contains char * or int.
*/
struct dynopenpromio {
union {
char *b;
int i[OPROM_NODE_SIZE];
} opio_u;
};
/*
* dynOppbuf structs are a dynamic alternative to Oppbuf unions. The statically
* sized Oppbuf.buf element has been removed, and the opp element common to both
* is of type struct dynopenpromio instead of struct openpromio. This allows us
* to take advantage of dynopenpromio's dynamic sizing capabilities.
*/
struct dynoppbuf {
char *val_ptr;
};
struct prop {
};
struct prom_node {
};
/*
* Defines for board types.
*/
struct board_node {
int node_id;
int board_num;
int board_type;
};
struct system_tree {
};
int do_prominfo(int, char *, int, int);
int is_openprom(void);
void promclose(void);
int promopen(int);
extern char *badarchmsg;
/* Functions for building the user copy of the device tree. */
/* functions for searching for Prom nodes */
char *get_node_name(Prom_node *);
char *get_node_type(Prom_node *);
int node_failed(Prom_node *);
int next(int);
int has_board_num(Prom_node *);
int get_board_num(Prom_node *);
int child(int);
/* functions for searching for properties, extracting data from them */
void *get_prop_val(Prop *);
void getpropval(struct openpromio *);
#ifdef __cplusplus
}
#endif
#endif /* _PDEVINFO_H */