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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * BK Id: SCCS/s.error_log.c 1.6 05/17/01 18:14:21 cort
  3.  */
  4. /*
  5.  *  arch/ppc/kernel/error_log.c
  6.  *  
  7.  *  Copyright (c) 2000 Tilmann Bitterberg
  8.  *  (tilmann@bitterberg.de)
  9.  *
  10.  *  Error processing of errors found by rtas even-scan routine
  11.  *  which is done with every heartbeat. (chrp_setup.c)
  12.  */
  13. #include <linux/sched.h>
  14. #include <asm/prom.h>
  15. #include "error_log.h"
  16. /* ****************************************************************** */
  17. /* 
  18.  * EVENT-SCAN
  19.  * The whole stuff below here doesn't take any action when it found
  20.  * an error, it just prints as much information as possible and 
  21.  * then its up to the user to decide what to do.
  22.  *
  23.  * Returns 0 if no errors were found
  24.  * Returns 1 if there may be more errors
  25.  */
  26. int ppc_rtas_errorlog_scan(void)
  27. {
  28. const char *_errlog_severity[] = {
  29. #ifdef VERBOSE_ERRORS
  30. "No Errornt
  31. Should require no further information",
  32. "Eventnt
  33. This is not really an error, it is an event. I use eventsnt
  34. to communicate with RTAS back and forth.",
  35. "Warningnt
  36. Indicates a non-state-losing error, either fully recoverednt
  37. by RTAS or not needing recovery. Ignore it.",
  38. "Error syncnt
  39. May only be fatal to a certain program or thread. Recoverynt
  40. and continuation is possible, if I only had a handler fornt
  41. this. Less serious",
  42. "Errornt
  43. Less serious, but still causing a loss of data and state.nt
  44. I can't tell you exactly what to do, You have to decident
  45. with help from the target and initiator field, what kindnt
  46. of further actions may take place.",
  47. "Fatalnt
  48. Represent a permanent hardware failure and I believe thisnt
  49. affects my overall performance and behaviour. I would notnt
  50. attempt to continue normal operation."
  51. #else
  52. "No Error",
  53. "Event",
  54. "Warning",
  55. "Error sync",
  56. "Error",
  57. "Fatal"
  58. #endif /* VERBOSE_ERRORS */
  59. };
  60. #if 0 /* unused?? */
  61. const char *_errlog_disposition[] = {
  62. #ifdef VERBOSE_ERRORS
  63. "Fully recoverednt
  64. There was an error, but it is fully recovered by RTAS.",
  65. "Limited recoverynt
  66. RTAS was able to recover the state of the machine, but soment
  67. feature of the machine has been disabled or lost (for examplent
  68. error checking) or performance may suffer.",
  69. "Not recoverednt
  70. Whether RTAS did not try to recover anything or recovery failed:nt
  71. HOUSTON, WE HAVE A PROBLEM!"
  72. #else
  73. "Fully recovered",
  74. "Limited recovery",
  75. "Not recovered"
  76. #endif /* VERBOSE_ERRORS */
  77. };
  78. #endif
  79. const char *_errlog_extended[] = {
  80. #ifdef VERBOSE_ERRORS
  81. "Not presentnt
  82. Sad, the RTAS call didn't return an extended error log.",
  83. "Presentnt
  84. The extended log is present and hopefully it contains a lot ofnt
  85. useful information, which leads to the solution of the problem."
  86. #else
  87. "Not present",
  88. "Present"
  89. #endif /* VERBOSE_ERRORS */
  90. };
  91. const char *_errlog_initiator[] = { 
  92. "Unknown or not applicable",
  93. "CPU",
  94. "PCI",
  95. "ISA",
  96. "Memory",
  97. "Power management"
  98. };
  99. const char *_errlog_target[] = { 
  100. "Unknown or not applicable",
  101. "CPU",
  102. "PCI",
  103. "ISA",
  104. "Memory",
  105. "Power management"
  106. };
  107. rtas_error_log error_log;
  108. char logdata[1024];
  109. int error;
  110. #if 0 /* unused?? */
  111. int retries = 0; /* if HW error, try 10 times */
  112. #endif
  113. error = call_rtas ("event-scan", 4, 1, (unsigned long *)&error_log,
  114. INTERNAL_ERROR | EPOW_WARNING,
  115. 0, __pa(logdata), 1024);
  116. if (error == 1) /* no errors found */
  117. return 0;
  118. if (error == -1) {
  119. printk(KERN_ERR "Unable to get errors. Do you a favor and throw this box awayn");
  120. return 0;
  121. }
  122. if (error_log.version != 1)
  123. printk(KERN_WARNING "Unknown version (%d), please implement men", 
  124. error_log.version);
  125. switch (error_log.disposition) {
  126. case DISP_FULLY_RECOVERED:
  127. /* there was an error, but everything is fine now */
  128. return 0;
  129. case DISP_NOT_RECOVERED:
  130. printk("We have a really serious Problem!n");
  131. case DISP_LIMITED_RECOVERY:
  132. printk("Error classificationn");
  133. printk("Severity  : %sn", 
  134. ppc_rtas_errorlog_check_severity (error_log));
  135. printk("Initiator : %sn", 
  136. ppc_rtas_errorlog_check_initiator (error_log));
  137. printk("Target    : %sn", 
  138. ppc_rtas_errorlog_check_target (error_log));
  139. printk("Type      : %sn", 
  140. ppc_rtas_errorlog_check_type (error_log));
  141. printk("Ext. log  : %sn", 
  142. ppc_rtas_errorlog_check_extended (error_log));
  143. if (error_log.extended)
  144. ppc_rtas_errorlog_disect_extended (logdata);
  145. return 1;
  146. default:
  147. /* nothing */
  148. break;
  149. }
  150. return 0;
  151. }
  152. /* ****************************************************************** */
  153. const char * ppc_rtas_errorlog_check_type (rtas_error_log error_log)
  154. {
  155. const char *_errlog_type[] = {
  156. "unknown type",
  157. "too many tries failed",
  158. "TCE error",
  159. "RTAS device failed",
  160. "target timed out",
  161. "parity error on data", /* 5 */
  162. "parity error on address",
  163. "parity error on external cache",
  164. "access to invalid address",
  165. "uncorrectable ECC error",
  166. "corrected ECC error" /* 10 */
  167. };
  168. if (error_log.type == TYPE_EPOW) 
  169. return "EPOW"; 
  170. if (error_log.type >= TYPE_PMGM_POWER_SW_ON)
  171. return "PowerMGM Event (not handled right now)";
  172. return _errlog_type[error_log.type];
  173. }