[SPARC64]: Abstract out mdesc accesses for better MD update handling.
[cascardo/linux.git] / include / asm-sparc64 / mdesc.h
1 #ifndef _SPARC64_MDESC_H
2 #define _SPARC64_MDESC_H
3
4 #include <linux/types.h>
5 #include <asm/prom.h>
6
7 struct mdesc_handle;
8
9 /* 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  */
14 extern struct mdesc_handle *mdesc_grab(void);
15 extern void mdesc_release(struct mdesc_handle *);
16
17 #define MDESC_NODE_NULL         (~(u64)0)
18
19 extern 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
26 extern const void *mdesc_get_property(struct mdesc_handle *handle,
27                                       u64 node, const char *name, int *lenp);
28
29 #define MDESC_ARC_TYPE_FWD      "fwd"
30 #define MDESC_ARC_TYPE_BACK     "back"
31
32 extern u64 mdesc_next_arc(struct mdesc_handle *handle, u64 from,
33                           const char *arc_type);
34 #define mdesc_for_each_arc(__arc, __hdl, __node, __type) \
35         for (__arc = mdesc_next_arc(__hdl, __node, __type); \
36              (__arc) != MDESC_NODE_NULL; \
37              __arc = mdesc_next_arc(__hdl, __arc, __type))
38
39 extern u64 mdesc_arc_target(struct mdesc_handle *hp, u64 arc);
40
41 extern const char *mdesc_node_name(struct mdesc_handle *hp, u64 node);
42
43 extern void mdesc_update(void);
44
45 extern void sun4v_mdesc_init(void);
46
47 #endif