David S. Miller | 5cbc307 | 2007-05-25 15:49:59 -0700 | [diff] [blame] | 1 | #ifndef _SPARC64_MDESC_H |
| 2 | #define _SPARC64_MDESC_H |
| 3 | |
| 4 | #include <linux/types.h> |
David S. Miller | 4f0234f | 2007-07-13 16:03:42 -0700 | [diff] [blame] | 5 | #include <linux/cpumask.h> |
David S. Miller | 5cbc307 | 2007-05-25 15:49:59 -0700 | [diff] [blame] | 6 | #include <asm/prom.h> |
| 7 | |
David S. Miller | 43fdf27 | 2007-07-12 13:47:50 -0700 | [diff] [blame] | 8 | struct mdesc_handle; |
David S. Miller | 5cbc307 | 2007-05-25 15:49:59 -0700 | [diff] [blame] | 9 | |
David S. Miller | 43fdf27 | 2007-07-12 13:47:50 -0700 | [diff] [blame] | 10 | /* Machine description operations are to be surrounded by grab and |
| 11 | * release calls. The mdesc_handle returned from the grab is |
| 12 | * the first argument to all of the operational calls that work |
| 13 | * on mdescs. |
| 14 | */ |
| 15 | extern struct mdesc_handle *mdesc_grab(void); |
| 16 | extern void mdesc_release(struct mdesc_handle *); |
David S. Miller | 5cbc307 | 2007-05-25 15:49:59 -0700 | [diff] [blame] | 17 | |
David S. Miller | 43fdf27 | 2007-07-12 13:47:50 -0700 | [diff] [blame] | 18 | #define MDESC_NODE_NULL (~(u64)0) |
David S. Miller | 5cbc307 | 2007-05-25 15:49:59 -0700 | [diff] [blame] | 19 | |
David S. Miller | 43fdf27 | 2007-07-12 13:47:50 -0700 | [diff] [blame] | 20 | extern u64 mdesc_node_by_name(struct mdesc_handle *handle, |
| 21 | u64 from_node, const char *name); |
| 22 | #define mdesc_for_each_node_by_name(__hdl, __node, __name) \ |
| 23 | for (__node = mdesc_node_by_name(__hdl, MDESC_NODE_NULL, __name); \ |
| 24 | (__node) != MDESC_NODE_NULL; \ |
| 25 | __node = mdesc_node_by_name(__hdl, __node, __name)) |
| 26 | |
David S. Miller | 83292e0 | 2007-07-12 14:16:22 -0700 | [diff] [blame] | 27 | /* Access to property values returned from mdesc_get_property() are |
| 28 | * only valid inside of a mdesc_grab()/mdesc_release() sequence. |
| 29 | * Once mdesc_release() is called, the memory backed up by these |
| 30 | * pointers may reference freed up memory. |
| 31 | * |
| 32 | * Therefore callers must make copies of any property values |
| 33 | * they need. |
| 34 | * |
| 35 | * These same rules apply to mdesc_node_name(). |
| 36 | */ |
David S. Miller | 43fdf27 | 2007-07-12 13:47:50 -0700 | [diff] [blame] | 37 | extern const void *mdesc_get_property(struct mdesc_handle *handle, |
| 38 | u64 node, const char *name, int *lenp); |
David S. Miller | 83292e0 | 2007-07-12 14:16:22 -0700 | [diff] [blame] | 39 | extern const char *mdesc_node_name(struct mdesc_handle *hp, u64 node); |
| 40 | |
| 41 | /* MD arc iteration, the standard sequence is: |
| 42 | * |
| 43 | * unsigned long arc; |
| 44 | * mdesc_for_each_arc(arc, handle, node, MDESC_ARC_TYPE_{FWD,BACK}) { |
| 45 | * unsigned long target = mdesc_arc_target(handle, arc); |
| 46 | * ... |
| 47 | * } |
| 48 | */ |
David S. Miller | 43fdf27 | 2007-07-12 13:47:50 -0700 | [diff] [blame] | 49 | |
| 50 | #define MDESC_ARC_TYPE_FWD "fwd" |
| 51 | #define MDESC_ARC_TYPE_BACK "back" |
| 52 | |
| 53 | extern u64 mdesc_next_arc(struct mdesc_handle *handle, u64 from, |
| 54 | const char *arc_type); |
| 55 | #define mdesc_for_each_arc(__arc, __hdl, __node, __type) \ |
| 56 | for (__arc = mdesc_next_arc(__hdl, __node, __type); \ |
| 57 | (__arc) != MDESC_NODE_NULL; \ |
| 58 | __arc = mdesc_next_arc(__hdl, __arc, __type)) |
| 59 | |
| 60 | extern u64 mdesc_arc_target(struct mdesc_handle *hp, u64 arc); |
| 61 | |
David S. Miller | 43fdf27 | 2007-07-12 13:47:50 -0700 | [diff] [blame] | 62 | extern void mdesc_update(void); |
David S. Miller | 5cbc307 | 2007-05-25 15:49:59 -0700 | [diff] [blame] | 63 | |
David S. Miller | 920c3ed | 2007-07-17 21:37:35 -0700 | [diff] [blame] | 64 | struct mdesc_notifier_client { |
| 65 | void (*add)(struct mdesc_handle *handle, u64 node); |
| 66 | void (*remove)(struct mdesc_handle *handle, u64 node); |
| 67 | |
| 68 | const char *node_name; |
| 69 | struct mdesc_notifier_client *next; |
| 70 | }; |
| 71 | |
| 72 | extern void mdesc_register_notifier(struct mdesc_notifier_client *client); |
| 73 | |
David S. Miller | 4f0234f | 2007-07-13 16:03:42 -0700 | [diff] [blame] | 74 | extern void mdesc_fill_in_cpu_data(cpumask_t mask); |
| 75 | |
David S. Miller | 5cbc307 | 2007-05-25 15:49:59 -0700 | [diff] [blame] | 76 | extern void sun4v_mdesc_init(void); |
| 77 | |
| 78 | #endif |