mdesc.h 3.0 KB

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