Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

325 lines
5.9 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Copyright (c) 1994 MOTOROLA, INC. All Rights Reserved. This file
  4. contains copyrighted material. Use of this file is restricted
  5. by the provisions of a Motorola Software License Agreement.
  6. Copyright (c) 1994, 95, 96 International Buisness Machines Corporation.
  7. Module Name:
  8. pxmemctl.c
  9. Abstract:
  10. The module initializes any planar registers.
  11. This module also implements machince check parity error handling.
  12. Author:
  13. Jim Wooldridge (jimw@austin.vnet.ibm.com)
  14. Revision History:
  15. Chris Karamatas (ckaramatas@vnet.ibm.com) - added HalpHandleMemoryError
  16. --*/
  17. #include "halp.h"
  18. #include <pxmemctl.h>
  19. #include "pxidaho.h"
  20. #include "pci.h"
  21. #include "pcip.h"
  22. BOOLEAN
  23. HalpInitPlanar (
  24. VOID
  25. )
  26. {
  27. return TRUE;
  28. }
  29. BOOLEAN
  30. HalpMapPlanarSpace (
  31. VOID
  32. )
  33. /*++
  34. Routine Description:
  35. This routine maps the interrupt acknowledge and error address
  36. spaces for a PowerPC system.
  37. Arguments:
  38. None.
  39. Return Value:
  40. If the initialization is successfully completed, than a value of TRUE
  41. is returned. Otherwise, a value of FALSE is returned.
  42. --*/
  43. {
  44. PHYSICAL_ADDRESS physicalAddress;
  45. //
  46. // Map interrupt control space.
  47. //
  48. physicalAddress.HighPart = 0;
  49. physicalAddress.LowPart = INTERRUPT_PHYSICAL_BASE;
  50. HalpInterruptBase = MmMapIoSpace(physicalAddress,
  51. PAGE_SIZE,
  52. FALSE);
  53. return TRUE;
  54. }
  55. BOOLEAN
  56. HalpMapBusConfigSpace (
  57. VOID
  58. )
  59. /*++
  60. Routine Description:
  61. This routine maps the HAL PCI config
  62. spaces for a PowerPC system.
  63. Arguments:
  64. None.
  65. Return Value:
  66. If the initialization is successfully completed, than a value of TRUE
  67. is returned. Otherwise, a value of FALSE is returned.
  68. --*/
  69. {
  70. HalpPciConfigBase = (PVOID) IO_CONTROL_PHYSICAL_BASE;
  71. return TRUE;
  72. }
  73. BOOLEAN
  74. HalpPhase0MapBusConfigSpace (
  75. VOID
  76. )
  77. /*++
  78. Routine Description:
  79. This routine maps the HAL PCI config
  80. spaces for a PowerPC system.
  81. Arguments:
  82. None.
  83. Return Value:
  84. If the initialization is successfully completed, than a value of TRUE
  85. is returned. Otherwise, a value of FALSE is returned.
  86. --*/
  87. {
  88. HalpPciConfigBase = (PVOID) IO_CONTROL_PHYSICAL_BASE;
  89. if (HalpIoControlBase == NULL) {
  90. HalpIoControlBase = (PUCHAR)KePhase0MapIo(IO_CONTROL_PHYSICAL_BASE, 0x400000);
  91. }
  92. if (HalpIoControlBase == NULL)
  93. return FALSE;
  94. else
  95. return TRUE;
  96. }
  97. VOID
  98. HalpPhase0UnMapBusConfigSpace (
  99. VOID
  100. )
  101. /*++
  102. Routine Description:
  103. This routine maps the HAL PCI config
  104. spaces for a PowerPC system.
  105. Arguments:
  106. None.
  107. Return Value:
  108. If the initialization is successfully completed, than a value of TRUE
  109. is returned. Otherwise, a value of FALSE is returned.
  110. --*/
  111. {
  112. }
  113. VOID
  114. HalpDisplayRegister(
  115. PUCHAR RegHex,
  116. int Bytes
  117. )
  118. /*++
  119. Routine Description:
  120. Displays (via HalDisplayString) a new-line terminated
  121. string of hex digits representing the input value. The
  122. input value is pointed to by the first argument is
  123. from 1 to 4 bytes in length.
  124. Arguments:
  125. RegHex Pointer to the value to be displayed.
  126. Bytes Length of input value in bytes (1-4).
  127. Return Value:
  128. None.
  129. --*/
  130. {
  131. #define DISP_MAX 4
  132. UCHAR RegString[(DISP_MAX * 2) + 2];
  133. UCHAR Num, High, Low;
  134. PUCHAR Byte = &RegString[(DISP_MAX * 2) + 1];
  135. *Byte = '\0';
  136. *--Byte = '\n';
  137. if ( (unsigned)Bytes > DISP_MAX ) {
  138. Bytes = DISP_MAX;
  139. }
  140. while (Bytes--) {
  141. Num = *RegHex++;
  142. High = (Num >> 4) + '0';
  143. Low = (Num & 0xf) + '0';
  144. if ( High > '9' ) {
  145. High += ('A' - '0' - 0xA);
  146. }
  147. if ( Low > '9' ) {
  148. Low += ('A' - '0' - 0xA);
  149. }
  150. *--Byte = Low;
  151. *--Byte = High;
  152. }
  153. HalDisplayString(Byte);
  154. }
  155. VOID
  156. HalpHandleMemoryError(
  157. VOID
  158. )
  159. {
  160. int byte;
  161. IDAHO_CONFIG PCI_Config_Space;
  162. UCHAR BusAddress[4];
  163. //
  164. // Make sure Options Reg.1 (0xBA) and Enable Detection Reg. (0xC0)
  165. // are programed. Reset Error Det Reg when done ?
  166. //
  167. HalGetBusData(PCIConfiguration,
  168. 0,
  169. 0,
  170. &PCI_Config_Space,
  171. sizeof(IDAHO_CONFIG));
  172. //
  173. // Dump Error Detection Reg, Bus Address, Status Error,
  174. //
  175. HalDisplayString ("TEA/MCP: System Error.\n");
  176. HalDisplayString ("Error Detection Register 1: ");
  177. HalpDisplayRegister (&PCI_Config_Space.ErrorDetection1,1);
  178. //
  179. // The error may have been detected during xfers on: cpu (local),
  180. // memory, or pci bus.
  181. //
  182. // Idaho will NOT generate/check Local Bus Parity
  183. //
  184. if (PCI_Config_Space.ErrorDetection1 & 0x03) {
  185. //
  186. // idaho <-> 603 :Local bus Cycle
  187. //
  188. HalDisplayString ("Unsupported Local Bus Cycle\n");
  189. for (byte = 0; byte < 4; byte++) {
  190. //
  191. // Correct endianess if address is local
  192. //
  193. BusAddress[byte] = PCI_Config_Space.ErrorAddress[3-byte];
  194. }
  195. HalDisplayString ("Local Bus Error Address: ");
  196. HalpDisplayRegister(BusAddress,4);
  197. HalDisplayString ("CPU Bus Error Status - TT(0:4);TSIZ(0:2): ");
  198. HalpDisplayRegister(&PCI_Config_Space.CpuBusErrorStatus,1);
  199. } else if (PCI_Config_Space.ErrorDetection1 & 0x08) {
  200. //
  201. // PCI Cycle
  202. //
  203. HalDisplayString ("PCI Cycle\n");
  204. for (byte=0; byte<4; byte++) {
  205. BusAddress[byte] = PCI_Config_Space.ErrorAddress[byte];
  206. }
  207. HalDisplayString ("PCI Bus Address: ");
  208. HalpDisplayRegister(BusAddress,4);
  209. HalDisplayString ("PCI Bus Error Status: ");
  210. HalpDisplayRegister(&PCI_Config_Space.PciBusErrorStatus,1);
  211. HalDisplayString ("PCI Device Status Register D(15:8): ");
  212. HalpDisplayRegister(&PCI_Config_Space.DeviceStatus[1],1);
  213. }
  214. }