Leaked source code of windows server 2003
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.

253 lines
7.7 KiB

  1. /*++
  2. Copyright (c) 1992 NCR Corporation
  3. Module Name:
  4. ncrdetect.c
  5. Abstract:
  6. Authors:
  7. Richard Barton (o-richb) 24-Jan-1992
  8. Brian Weischedel 30-Nov-1992
  9. Environment:
  10. Kernel mode only.
  11. Revision History:
  12. --*/
  13. #ifndef _NTOS_
  14. #include "nthal.h"
  15. #endif
  16. PVOID
  17. HalpMapPhysicalMemory(
  18. IN PVOID PhysicalAddress,
  19. IN ULONG NumberPages
  20. );
  21. VOID
  22. ReadCMOS(
  23. IN ULONG StartingOffset,
  24. IN ULONG Count,
  25. IN PUCHAR ReturnValuePtr);
  26. ULONG NCRPlatform;
  27. #define NCR3450 0x35333433 // Copied here to build standalone
  28. #define NCR3550 0x30353834
  29. #define NCR3360 0x33333630
  30. // WPD definitions:
  31. PUCHAR WPDStringID = "NCR Voyager-1";
  32. PUCHAR WPDPlatformName = "System 3360";
  33. #define WPDStringIDLength 13
  34. #define WPDStringIDRangeStart (0xE000 << 4) // physical address
  35. #define WPDStringIDRangeSize 0x10000 // 1 segment (64k)
  36. // MSBU definitions:
  37. PUCHAR MSBUCopyrightString = "Copyright (C) ???? NCR\0";
  38. #define MSBUCopyrightStringLen 23
  39. #define MSBUCopyrightPhysicalPtr ((0xF000 << 4) + (0xE020))
  40. typedef struct {
  41. ULONG ClassFromFirmware;
  42. PUCHAR PlatformName;
  43. } MSBUPlatformMapEntry;
  44. MSBUPlatformMapEntry MSBUPlatformMap[] = {{NCR3450, "System 3450"},
  45. {NCR3550, "System 3550"},
  46. {0, 0}};
  47. PUCHAR
  48. NCRDeterminePlatform(
  49. OUT PBOOLEAN IsConfiguredMp
  50. )
  51. /*++
  52. Routine Description:
  53. Determine on which NCR platform we are running. For now just display
  54. a message. Later we may not continue the boot if we're on an
  55. unrecognized platform.
  56. Arguments:
  57. none.
  58. Return Value:
  59. Pointer to character string identifying which NCR platform. NULL means
  60. it is unrecognized, and we shouldn't continue.
  61. --*/
  62. {
  63. BOOLEAN Matchfound;
  64. MSBUPlatformMapEntry *MSBUPlatformMapPtr;
  65. PVOID BIOSPagePtr;
  66. PUCHAR StringPtr;
  67. PUCHAR CopyrightPtr;
  68. PUCHAR SearchPtr;
  69. UCHAR CpuFlags;
  70. // first check for a WPD platform by searching the 0xE000 BIOS segment
  71. // for a ROM string that identifies this system as a 3360
  72. // get virtual address to the BIOS region (assuming region is both
  73. // page aligned and multiple pages in size)
  74. BIOSPagePtr = HalpMapPhysicalMemory((PVOID) WPDStringIDRangeStart,
  75. (WPDStringIDRangeSize >> 12));
  76. if (BIOSPagePtr != NULL) {
  77. SearchPtr = BIOSPagePtr; // begin search at start of region
  78. Matchfound = FALSE;
  79. // search until string is found or we are beyond the region
  80. while (!Matchfound && (SearchPtr <= (PUCHAR)((ULONG)BIOSPagePtr +
  81. WPDStringIDRangeSize -
  82. WPDStringIDLength))) {
  83. // see if SearchPtr points to the desired string
  84. StringPtr = (PUCHAR)((ULONG)SearchPtr++);
  85. CopyrightPtr = WPDStringID;
  86. // continue compare as long as characters compare
  87. // and not at end of string
  88. while ((Matchfound = (*CopyrightPtr++ == *StringPtr++)) &&
  89. (CopyrightPtr < WPDStringID + WPDStringIDLength));
  90. }
  91. // see if string was found (i.e., if this is a 3360)
  92. if (Matchfound) {
  93. // store system identifier ("3360") for later HAL use
  94. NCRPlatform = NCR3360;
  95. // read CPU good flags from CMOS and determine if MP
  96. ReadCMOS(0x88A, 1, &CpuFlags);
  97. // *IsConfiguredMp = (CpuFlags & (CpuFlags-1)) ? TRUE : FALSE;
  98. // This is an MP hal
  99. *IsConfiguredMp = TRUE;
  100. return(WPDPlatformName);
  101. }
  102. }
  103. // now check for an MSBU platform
  104. /*
  105. * Map in the BIOS text so we can look for our copyright string.
  106. */
  107. BIOSPagePtr = (PVOID)((ULONG)MSBUCopyrightPhysicalPtr &
  108. ~(PAGE_SIZE - 1));
  109. BIOSPagePtr = HalpMapPhysicalMemory(BIOSPagePtr, 2);
  110. if (BIOSPagePtr == NULL)
  111. return(NULL);
  112. StringPtr = (PUCHAR)((ULONG)BIOSPagePtr +
  113. ((ULONG)MSBUCopyrightPhysicalPtr & (PAGE_SIZE - 1)))
  114. + (MSBUCopyrightStringLen - 1);
  115. CopyrightPtr = MSBUCopyrightString + (MSBUCopyrightStringLen - 1);
  116. do {
  117. Matchfound = ((*CopyrightPtr == '?') ||
  118. (*CopyrightPtr == *StringPtr));
  119. --CopyrightPtr;
  120. --StringPtr;
  121. } while (Matchfound && (CopyrightPtr >= MSBUCopyrightString));
  122. //
  123. // /*
  124. // * Clear the mapping to BIOS. We mapped in two pages.
  125. // */
  126. // BIOSPagePtr = MiGetPteAddress(BIOSPagePtr);
  127. // *(PULONG)BIOSPagePtr = 0;
  128. // *(((PULONG)BIOSPagePtr)+1) = 0;
  129. // /*
  130. // * Flush the TLB.
  131. // */
  132. // _asm {
  133. // mov eax, cr3
  134. // mov cr3, eax
  135. // }
  136. //
  137. if (Matchfound) {
  138. /*
  139. * must be an MSBU machine..determine which.
  140. */
  141. ReadCMOS(0xB16, 4, (PUCHAR)&NCRPlatform);
  142. for (MSBUPlatformMapPtr = MSBUPlatformMap;
  143. (MSBUPlatformMapPtr->ClassFromFirmware != 0);
  144. ++MSBUPlatformMapPtr) {
  145. if (MSBUPlatformMapPtr->ClassFromFirmware ==
  146. NCRPlatform) {
  147. *IsConfiguredMp = TRUE;
  148. return(MSBUPlatformMapPtr->PlatformName);
  149. }
  150. }
  151. /*
  152. * prerelease version of firmware had this machine class
  153. * at the wrong offset into CMOS. until all those versions
  154. * of firmware are extinguished from the face of the earth
  155. * we should recognize them with this:
  156. */
  157. ReadCMOS(0xAB3, 4, (PUCHAR)&NCRPlatform);
  158. for (MSBUPlatformMapPtr = MSBUPlatformMap;
  159. (MSBUPlatformMapPtr->ClassFromFirmware != 0);
  160. ++MSBUPlatformMapPtr) {
  161. if (MSBUPlatformMapPtr->ClassFromFirmware ==
  162. NCRPlatform) {
  163. *IsConfiguredMp = TRUE;
  164. return(MSBUPlatformMapPtr->PlatformName);
  165. }
  166. }
  167. }
  168. return(NULL);
  169. }
  170. #ifndef SETUP // if built with Hal, must provide ReadCMOS routine
  171. ULONG
  172. HalpGetCmosData (
  173. IN ULONG SourceLocation,
  174. IN ULONG SourceAddress,
  175. IN PUCHAR Buffer,
  176. IN ULONG Length);
  177. VOID
  178. ReadCMOS(
  179. IN ULONG StartingOffset,
  180. IN ULONG Count,
  181. IN PUCHAR ReturnValuePtr
  182. )
  183. /*++
  184. Routine Description:
  185. This routine simply converts a ReadCMOS call (a routine in setup) to
  186. the corresponding routine provided in the Hal (HalpGetCmosData).
  187. --*/
  188. {
  189. HalpGetCmosData(1, StartingOffset, ReturnValuePtr, Count);
  190. }
  191. #endif