1 #ifndef _SPARC64_MDESC_H 2 #define _SPARC64_MDESC_H 3 4 #include <linux/types.h> 5 #include <linux/cpumask.h> 6 #include <asm/prom.h> 7 8 struct mdesc_handle; 9 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 struct mdesc_handle *mdesc_grab(void); 16 void mdesc_release(struct mdesc_handle *); 17 18 #define MDESC_NODE_NULL (~(u64)0) 19 #define MDESC_MAX_STR_LEN 256 20 21 u64 mdesc_node_by_name(struct mdesc_handle *handle, 22 u64 from_node, const char *name); 23 #define mdesc_for_each_node_by_name(__hdl, __node, __name) \ 24 for (__node = mdesc_node_by_name(__hdl, MDESC_NODE_NULL, __name); \ 25 (__node) != MDESC_NODE_NULL; \ 26 __node = mdesc_node_by_name(__hdl, __node, __name)) 27 28 /* Access to property values returned from mdesc_get_property() are 29 * only valid inside of a mdesc_grab()/mdesc_release() sequence. 30 * Once mdesc_release() is called, the memory backed up by these 31 * pointers may reference freed up memory. 32 * 33 * Therefore callers must make copies of any property values 34 * they need. 35 * 36 * These same rules apply to mdesc_node_name(). 37 */ 38 const void *mdesc_get_property(struct mdesc_handle *handle, 39 u64 node, const char *name, int *lenp); 40 const char *mdesc_node_name(struct mdesc_handle *hp, u64 node); 41 42 /* MD arc iteration, the standard sequence is: 43 * 44 * unsigned long arc; 45 * mdesc_for_each_arc(arc, handle, node, MDESC_ARC_TYPE_{FWD,BACK}) { 46 * unsigned long target = mdesc_arc_target(handle, arc); 47 * ... 48 * } 49 */ 50 51 #define MDESC_ARC_TYPE_FWD "fwd" 52 #define MDESC_ARC_TYPE_BACK "back" 53 54 u64 mdesc_next_arc(struct mdesc_handle *handle, u64 from, 55 const char *arc_type); 56 #define mdesc_for_each_arc(__arc, __hdl, __node, __type) \ 57 for (__arc = mdesc_next_arc(__hdl, __node, __type); \ 58 (__arc) != MDESC_NODE_NULL; \ 59 __arc = mdesc_next_arc(__hdl, __arc, __type)) 60 61 u64 mdesc_arc_target(struct mdesc_handle *hp, u64 arc); 62 63 void mdesc_update(void); 64 65 struct mdesc_notifier_client { 66 void (*add)(struct mdesc_handle *handle, u64 node, 67 const char *node_name); 68 void (*remove)(struct mdesc_handle *handle, u64 node, 69 const char *node_name); 70 const char *node_name; 71 struct mdesc_notifier_client *next; 72 }; 73 74 void mdesc_register_notifier(struct mdesc_notifier_client *client); 75 76 union md_node_info { 77 struct vdev_port { 78 u64 id; /* id */ 79 u64 parent_cfg_hdl; /* parent config handle */ 80 const char *name; /* name (property) */ 81 } vdev_port; 82 struct ds_port { 83 u64 id; /* id */ 84 } ds_port; 85 }; 86 87 u64 mdesc_get_node(struct mdesc_handle *hp, const char *node_name, 88 union md_node_info *node_info); 89 int mdesc_get_node_info(struct mdesc_handle *hp, u64 node, 90 const char *node_name, union md_node_info *node_info); 91 92 void mdesc_fill_in_cpu_data(cpumask_t *mask); 93 void mdesc_populate_present_mask(cpumask_t *mask); 94 void mdesc_get_page_sizes(cpumask_t *mask, unsigned long *pgsz_mask); 95 96 void sun4v_mdesc_init(void); 97 98 #endif 99