blob: dc372df23fb350109e44b7db0fe2b5fa63afa657 [file] [log] [blame]
David S. Miller5cbc3072007-05-25 15:49:59 -07001#ifndef _SPARC64_MDESC_H
2#define _SPARC64_MDESC_H
3
4#include <linux/types.h>
5#include <asm/prom.h>
6
David S. Miller43fdf272007-07-12 13:47:50 -07007struct mdesc_handle;
David S. Miller5cbc3072007-05-25 15:49:59 -07008
David S. Miller43fdf272007-07-12 13:47:50 -07009/* Machine description operations are to be surrounded by grab and
10 * release calls. The mdesc_handle returned from the grab is
11 * the first argument to all of the operational calls that work
12 * on mdescs.
13 */
14extern struct mdesc_handle *mdesc_grab(void);
15extern void mdesc_release(struct mdesc_handle *);
David S. Miller5cbc3072007-05-25 15:49:59 -070016
David S. Miller43fdf272007-07-12 13:47:50 -070017#define MDESC_NODE_NULL (~(u64)0)
David S. Miller5cbc3072007-05-25 15:49:59 -070018
David S. Miller43fdf272007-07-12 13:47:50 -070019extern u64 mdesc_node_by_name(struct mdesc_handle *handle,
20 u64 from_node, const char *name);
21#define mdesc_for_each_node_by_name(__hdl, __node, __name) \
22 for (__node = mdesc_node_by_name(__hdl, MDESC_NODE_NULL, __name); \
23 (__node) != MDESC_NODE_NULL; \
24 __node = mdesc_node_by_name(__hdl, __node, __name))
25
David S. Miller83292e02007-07-12 14:16:22 -070026/* Access to property values returned from mdesc_get_property() are
27 * only valid inside of a mdesc_grab()/mdesc_release() sequence.
28 * Once mdesc_release() is called, the memory backed up by these
29 * pointers may reference freed up memory.
30 *
31 * Therefore callers must make copies of any property values
32 * they need.
33 *
34 * These same rules apply to mdesc_node_name().
35 */
David S. Miller43fdf272007-07-12 13:47:50 -070036extern const void *mdesc_get_property(struct mdesc_handle *handle,
37 u64 node, const char *name, int *lenp);
David S. Miller83292e02007-07-12 14:16:22 -070038extern const char *mdesc_node_name(struct mdesc_handle *hp, u64 node);
39
40/* MD arc iteration, the standard sequence is:
41 *
42 * unsigned long arc;
43 * mdesc_for_each_arc(arc, handle, node, MDESC_ARC_TYPE_{FWD,BACK}) {
44 * unsigned long target = mdesc_arc_target(handle, arc);
45 * ...
46 * }
47 */
David S. Miller43fdf272007-07-12 13:47:50 -070048
49#define MDESC_ARC_TYPE_FWD "fwd"
50#define MDESC_ARC_TYPE_BACK "back"
51
52extern u64 mdesc_next_arc(struct mdesc_handle *handle, u64 from,
53 const char *arc_type);
54#define mdesc_for_each_arc(__arc, __hdl, __node, __type) \
55 for (__arc = mdesc_next_arc(__hdl, __node, __type); \
56 (__arc) != MDESC_NODE_NULL; \
57 __arc = mdesc_next_arc(__hdl, __arc, __type))
58
59extern u64 mdesc_arc_target(struct mdesc_handle *hp, u64 arc);
60
David S. Miller43fdf272007-07-12 13:47:50 -070061extern void mdesc_update(void);
David S. Miller5cbc3072007-05-25 15:49:59 -070062
63extern void sun4v_mdesc_init(void);
64
65#endif