1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _SPARC64_MDESC_H
3 #define _SPARC64_MDESC_H
5 #include <linux/types.h>
6 #include <linux/cpumask.h>
11 /* Machine description operations are to be surrounded by grab and
12 * release calls. The mdesc_handle returned from the grab is
13 * the first argument to all of the operational calls that work
16 struct mdesc_handle
*mdesc_grab(void);
17 void mdesc_release(struct mdesc_handle
*);
19 #define MDESC_NODE_NULL (~(u64)0)
20 #define MDESC_MAX_STR_LEN 256
22 u64
mdesc_node_by_name(struct mdesc_handle
*handle
,
23 u64 from_node
, const char *name
);
24 #define mdesc_for_each_node_by_name(__hdl, __node, __name) \
25 for (__node = mdesc_node_by_name(__hdl, MDESC_NODE_NULL, __name); \
26 (__node) != MDESC_NODE_NULL; \
27 __node = mdesc_node_by_name(__hdl, __node, __name))
29 /* Access to property values returned from mdesc_get_property() are
30 * only valid inside of a mdesc_grab()/mdesc_release() sequence.
31 * Once mdesc_release() is called, the memory backed up by these
32 * pointers may reference freed up memory.
34 * Therefore callers must make copies of any property values
37 * These same rules apply to mdesc_node_name().
39 const void *mdesc_get_property(struct mdesc_handle
*handle
,
40 u64 node
, const char *name
, int *lenp
);
41 const char *mdesc_node_name(struct mdesc_handle
*hp
, u64 node
);
43 /* MD arc iteration, the standard sequence is:
46 * mdesc_for_each_arc(arc, handle, node, MDESC_ARC_TYPE_{FWD,BACK}) {
47 * unsigned long target = mdesc_arc_target(handle, arc);
52 #define MDESC_ARC_TYPE_FWD "fwd"
53 #define MDESC_ARC_TYPE_BACK "back"
55 u64
mdesc_next_arc(struct mdesc_handle
*handle
, u64 from
,
56 const char *arc_type
);
57 #define mdesc_for_each_arc(__arc, __hdl, __node, __type) \
58 for (__arc = mdesc_next_arc(__hdl, __node, __type); \
59 (__arc) != MDESC_NODE_NULL; \
60 __arc = mdesc_next_arc(__hdl, __arc, __type))
62 u64
mdesc_arc_target(struct mdesc_handle
*hp
, u64 arc
);
64 void mdesc_update(void);
66 struct mdesc_notifier_client
{
67 void (*add
)(struct mdesc_handle
*handle
, u64 node
,
68 const char *node_name
);
69 void (*remove
)(struct mdesc_handle
*handle
, u64 node
,
70 const char *node_name
);
71 const char *node_name
;
72 struct mdesc_notifier_client
*next
;
75 void mdesc_register_notifier(struct mdesc_notifier_client
*client
);
80 u64 parent_cfg_hdl
; /* parent config handle */
81 const char *name
; /* name (property) */
88 u64
mdesc_get_node(struct mdesc_handle
*hp
, const char *node_name
,
89 union md_node_info
*node_info
);
90 int mdesc_get_node_info(struct mdesc_handle
*hp
, u64 node
,
91 const char *node_name
, union md_node_info
*node_info
);
93 void mdesc_fill_in_cpu_data(cpumask_t
*mask
);
94 void mdesc_populate_present_mask(cpumask_t
*mask
);
95 void mdesc_get_page_sizes(cpumask_t
*mask
, unsigned long *pgsz_mask
);
97 void sun4v_mdesc_init(void);