klgraph_hack.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:5k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* $Id$
  2.  *
  3.  * This file is subject to the terms and conditions of the GNU General Public
  4.  * License.  See the file "COPYING" in the main directory of this archive
  5.  * for more details.
  6.  *
  7.  * Copyright (C) 1992 - 1997, 2000-2002 Silicon Graphics, Inc. All rights reserved.
  8.  */
  9. /*
  10.  * This is a temporary file that statically initializes the expected 
  11.  * initial klgraph information that is normally provided by prom.
  12.  */
  13. #include <linux/types.h>
  14. #include <linux/slab.h>
  15. #include <linux/vmalloc.h>
  16. #include <asm/sn/sgi.h>
  17. #include <asm/sn/io.h>
  18. #include <asm/sn/klconfig.h>
  19. void * real_port;
  20. void * real_io_base;
  21. void * real_addr;
  22. char *BW0 = NULL;
  23. kl_config_hdr_t *linux_klcfg;
  24. #ifdef DEFINE_DUMP_RTNS
  25. /* forward declarations */
  26. static void dump_ii(void), dump_crossbow(void);
  27. static void clear_ii_error(void);
  28. #endif /* DEFINE_DUMP_RTNS */
  29. #define SYNERGY_WIDGET          ((char *)0xc0000e0000000000)
  30. #define SYNERGY_SWIZZLE         ((char *)0xc0000e0000000400)
  31. #define HUBREG                  ((char *)0xc0000a0001e00000)
  32. #define WIDGET0                 ((char *)0xc0000a0000000000)
  33. #define WIDGET4                 ((char *)0xc0000a0000000004)
  34. #define SYNERGY_WIDGET          ((char *)0xc0000e0000000000)
  35. #define SYNERGY_SWIZZLE         ((char *)0xc0000e0000000400)
  36. #define HUBREG                  ((char *)0xc0000a0001e00000)
  37. #define WIDGET0                 ((char *)0xc0000a0000000000)
  38. void
  39. klgraph_hack_init(void)
  40. {
  41. /*
  42.  * We need to know whether we are booting from PROM or 
  43.  * boot from disk.
  44.  */
  45. linux_klcfg = (kl_config_hdr_t *)0xe000000000030000;
  46. if (linux_klcfg->ch_magic == 0xbeedbabe) {
  47. return;
  48. } else {
  49. panic("klgraph_hack_init: Unable to locate KLCONFIG TABLEn");
  50. }
  51. }
  52. #ifdef DEFINE_DUMP_RTNS
  53. /* 
  54.  * these were useful for printing out registers etc
  55.  * during bringup  
  56.  */
  57. static void
  58. xdump(long long *addr, int count)
  59. {
  60. int ii;
  61. volatile long long *xx = addr;
  62. for ( ii = 0; ii < count; ii++, xx++ ) {
  63. printk("0x%p : 0x%pn", (void *)xx, (void *)*xx);
  64. }
  65. }
  66. static void
  67. xdump32(unsigned int *addr, int count)
  68. {
  69. int ii;
  70. volatile unsigned int *xx = addr;
  71. for ( ii = 0; ii < count; ii++, xx++ ) {
  72. printk("0x%p : 0x%0xn", (void *)xx, (int)*xx);
  73. }
  74. }
  75. static void
  76. clear_ii_error(void)
  77. {
  78. volatile long long *tmp;
  79. printk("... WSTAT ");
  80. xdump((long long *)0xc0000a0001c00008, 1);
  81. printk("... WCTRL ");
  82. xdump((long long *)0xc0000a0001c00020, 1);
  83. printk("... WLCSR ");
  84. xdump((long long *)0xc0000a0001c00128, 1);
  85. printk("... IIDSR ");
  86. xdump((long long *)0xc0000a0001c00138, 1);
  87.         printk("... IOPRBs ");
  88. xdump((long long *)0xc0000a0001c00198, 9);
  89. printk("... IXSS ");
  90. xdump((long long *)0xc0000a0001c00210, 1);
  91. printk("... IBLS0 ");
  92. xdump((long long *)0xc0000a0001c10000, 1);
  93. printk("... IBLS1 ");
  94. xdump((long long *)0xc0000a0001c20000, 1);
  95.         /* Write IOERR clear to clear the CRAZY bit in the status */
  96.         tmp = (long long *)0xc0000a0001c001f8; *tmp = (long long)0xffffffff;
  97. /* dump out local block error registers */
  98. printk("... ");
  99. xdump((long long *)0xc0000a0001e04040, 1); /* LB_ERROR_BITS */
  100. printk("... ");
  101. xdump((long long *)0xc0000a0001e04050, 1); /* LB_ERROR_HDR1 */
  102. printk("... ");
  103. xdump((long long *)0xc0000a0001e04058, 1); /* LB_ERROR_HDR2 */
  104. /* and clear the LB_ERROR_BITS */
  105. tmp = (long long *)0xc0000a0001e04040; *tmp = 0x0;
  106. printk("clr: ");
  107. xdump((long long *)0xc0000a0001e04040, 1); /* LB_ERROR_BITS */
  108. tmp = (long long *)0xc0000a0001e04050; *tmp = 0x0;
  109. tmp = (long long *)0xc0000a0001e04058; *tmp = 0x0;
  110. }
  111. static void
  112. dump_ii(void)
  113. {
  114. printk("===== Dump the II regs =====n");
  115. xdump((long long *)0xc0000a0001c00000, 2);
  116. xdump((long long *)0xc0000a0001c00020, 1);
  117. xdump((long long *)0xc0000a0001c00100, 37);
  118. xdump((long long *)0xc0000a0001c00300, 98);
  119. xdump((long long *)0xc0000a0001c10000, 6);
  120. xdump((long long *)0xc0000a0001c20000, 6);
  121. xdump((long long *)0xc0000a0001c30000, 2);
  122. xdump((long long *)0xc0000a0000000000, 1);
  123. xdump((long long *)0xc0000a0001000000, 1);
  124. xdump((long long *)0xc0000a0002000000, 1);
  125. xdump((long long *)0xc0000a0003000000, 1);
  126. xdump((long long *)0xc0000a0004000000, 1);
  127. xdump((long long *)0xc0000a0005000000, 1);
  128. xdump((long long *)0xc0000a0006000000, 1);
  129. xdump((long long *)0xc0000a0007000000, 1);
  130. xdump((long long *)0xc0000a0008000000, 1);
  131. xdump((long long *)0xc0000a0009000000, 1);
  132. xdump((long long *)0xc0000a000a000000, 1);
  133. xdump((long long *)0xc0000a000b000000, 1);
  134. xdump((long long *)0xc0000a000c000000, 1);
  135. xdump((long long *)0xc0000a000d000000, 1);
  136. xdump((long long *)0xc0000a000e000000, 1);
  137. xdump((long long *)0xc0000a000f000000, 1);
  138. }
  139. static void
  140. dump_crossbow(void)
  141. {
  142. printk("===== Dump the Crossbow regs =====n");
  143. clear_ii_error();
  144. xdump32((unsigned int *)0xc0000a0000000004, 1);
  145. clear_ii_error();
  146. xdump32((unsigned int *)0xc0000a0000000000, 1);
  147. printk("and again..n");
  148. xdump32((unsigned int *)0xc0000a0000000000, 1);
  149. xdump32((unsigned int *)0xc0000a0000000000, 1);
  150. clear_ii_error();
  151. xdump32((unsigned int *)0xc000020000000004, 1);
  152. clear_ii_error();
  153. xdump32((unsigned int *)0xc000020000000000, 1);
  154. clear_ii_error();
  155. xdump32((unsigned int *)0xc0000a0000800004, 1);
  156. clear_ii_error();
  157. xdump32((unsigned int *)0xc0000a0000800000, 1);
  158. clear_ii_error();
  159. xdump32((unsigned int *)0xc000020000800004, 1);
  160. clear_ii_error();
  161. xdump32((unsigned int *)0xc000020000800000, 1);
  162. clear_ii_error();
  163. }
  164. #endif /* DEFINE_DUMP_RTNS */