mdesc.h 2.4 KB

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