tree.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * PROM component device tree code.
  7. *
  8. * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
  9. * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org)
  10. * Copyright (C) 1999 Silicon Graphics, Inc.
  11. */
  12. #include <linux/init.h>
  13. #include <asm/fw/arc/types.h>
  14. #include <asm/sgialib.h>
  15. #undef DEBUG_PROM_TREE
  16. pcomponent * __init
  17. ArcGetPeer(pcomponent *Current)
  18. {
  19. if (Current == PROM_NULL_COMPONENT)
  20. return PROM_NULL_COMPONENT;
  21. return (pcomponent *) ARC_CALL1(next_component, Current);
  22. }
  23. pcomponent * __init
  24. ArcGetChild(pcomponent *Current)
  25. {
  26. return (pcomponent *) ARC_CALL1(child_component, Current);
  27. }
  28. pcomponent * __init
  29. ArcGetParent(pcomponent *Current)
  30. {
  31. if (Current == PROM_NULL_COMPONENT)
  32. return PROM_NULL_COMPONENT;
  33. return (pcomponent *) ARC_CALL1(parent_component, Current);
  34. }
  35. LONG __init
  36. ArcGetConfigurationData(VOID *Buffer, pcomponent *Current)
  37. {
  38. return ARC_CALL2(component_data, Buffer, Current);
  39. }
  40. pcomponent * __init
  41. ArcAddChild(pcomponent *Current, pcomponent *Template, VOID *ConfigurationData)
  42. {
  43. return (pcomponent *)
  44. ARC_CALL3(child_add, Current, Template, ConfigurationData);
  45. }
  46. LONG __init
  47. ArcDeleteComponent(pcomponent *ComponentToDelete)
  48. {
  49. return ARC_CALL1(comp_del, ComponentToDelete);
  50. }
  51. pcomponent * __init
  52. ArcGetComponent(CHAR *Path)
  53. {
  54. return (pcomponent *)ARC_CALL1(component_by_path, Path);
  55. }
  56. #ifdef DEBUG_PROM_TREE
  57. static char *classes[] = {
  58. "system", "processor", "cache", "adapter", "controller", "peripheral",
  59. "memory"
  60. };
  61. static char *types[] = {
  62. "arc", "cpu", "fpu", "picache", "pdcache", "sicache", "sdcache",
  63. "sccache", "memdev", "eisa adapter", "tc adapter", "scsi adapter",
  64. "dti adapter", "multi-func adapter", "disk controller",
  65. "tp controller", "cdrom controller", "worm controller",
  66. "serial controller", "net controller", "display controller",
  67. "parallel controller", "pointer controller", "keyboard controller",
  68. "audio controller", "misc controller", "disk peripheral",
  69. "floppy peripheral", "tp peripheral", "modem peripheral",
  70. "monitor peripheral", "printer peripheral", "pointer peripheral",
  71. "keyboard peripheral", "terminal peripheral", "line peripheral",
  72. "net peripheral", "misc peripheral", "anonymous"
  73. };
  74. static char *iflags[] = {
  75. "bogus", "read only", "removable", "console in", "console out",
  76. "input", "output"
  77. };
  78. static void __init
  79. dump_component(pcomponent *p)
  80. {
  81. printk("[%p]:class<%s>type<%s>flags<%s>ver<%d>rev<%d>",
  82. p, classes[p->class], types[p->type],
  83. iflags[p->iflags], p->vers, p->rev);
  84. printk("key<%08lx>\n\tamask<%08lx>cdsize<%d>ilen<%d>iname<%s>\n",
  85. p->key, p->amask, (int)p->cdsize, (int)p->ilen, p->iname);
  86. }
  87. static void __init
  88. traverse(pcomponent *p, int op)
  89. {
  90. dump_component(p);
  91. if(ArcGetChild(p))
  92. traverse(ArcGetChild(p), 1);
  93. if(ArcGetPeer(p) && op)
  94. traverse(ArcGetPeer(p), 1);
  95. }
  96. void __init
  97. prom_testtree(void)
  98. {
  99. pcomponent *p;
  100. p = ArcGetChild(PROM_NULL_COMPONENT);
  101. dump_component(p);
  102. p = ArcGetChild(p);
  103. while(p) {
  104. dump_component(p);
  105. p = ArcGetPeer(p);
  106. }
  107. }
  108. #endif /* DEBUG_PROM_TREE */