Source code of Windows XP (NT5)
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.

340 lines
7.7 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. initx86.c
  5. Abstract:
  6. Does any x86-specific initialization, then starts the common ARC osloader
  7. Author:
  8. John Vert (jvert) 4-Nov-1993
  9. Revision History:
  10. --*/
  11. #include "bldrx86.h"
  12. #include "msg.h"
  13. #include <string.h>
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16. #if defined(REMOTE_BOOT)
  17. #include <netboot.h>
  18. #endif // defined(REMOTE_BOOT)
  19. BOOLEAN
  20. BlpPaeSupported(
  21. VOID
  22. );
  23. BOOLEAN
  24. BlpChipsetPaeSupported(
  25. VOID
  26. );
  27. ARC_STATUS
  28. Blx86IsPaeImage(
  29. IN ULONG LoadDeviceId,
  30. IN PCHAR ImagePath,
  31. OUT PBOOLEAN IsPae
  32. );
  33. BOOLEAN
  34. Blx86IsKernelCompatible(
  35. IN ULONG LoadDeviceId,
  36. IN PCHAR ImagePath,
  37. IN BOOLEAN ProcessorSupportsPae,
  38. IN OUT PBOOLEAN UsePae
  39. );
  40. UCHAR BootPartitionName[80];
  41. UCHAR KernelBootDevice[80];
  42. UCHAR OsLoadFilename[100];
  43. UCHAR OsLoaderFilename[100];
  44. UCHAR SystemPartition[100];
  45. UCHAR OsLoadPartition[100];
  46. UCHAR OsLoadOptions[100];
  47. UCHAR ConsoleInputName[50];
  48. UCHAR MyBuffer[SECTOR_SIZE+32];
  49. UCHAR ConsoleOutputName[50];
  50. UCHAR X86SystemPartition[sizeof("x86systempartition=") + sizeof(BootPartitionName)];
  51. extern BOOLEAN ForceLastKnownGood;
  52. extern ULONG BlHighestPage;
  53. VOID
  54. BlStartup(
  55. IN PCHAR PartitionName
  56. )
  57. /*++
  58. Routine Description:
  59. Does x86-specific initialization, particularly presenting the boot.ini
  60. menu and running NTDETECT, then calls to the common osloader.
  61. Arguments:
  62. PartitionName - Supplies the ARC name of the partition (or floppy) that
  63. setupldr was loaded from.
  64. Return Value:
  65. Does not return
  66. --*/
  67. {
  68. ULONG Argc = 0;
  69. PUCHAR Argv[10];
  70. ARC_STATUS Status;
  71. ULONG BlLogFileId = (ULONG)-1;
  72. ULONG Read;
  73. PCHAR p,q;
  74. ULONG i;
  75. ULONG DriveId;
  76. ULONG FileSize;
  77. ULONG Count;
  78. LARGE_INTEGER SeekPosition;
  79. PCHAR LoadOptions = NULL;
  80. BOOLEAN UseTimeOut=TRUE;
  81. BOOLEAN AlreadyInitialized = FALSE;
  82. extern BOOLEAN FwDescriptorsValid;
  83. PCHAR BadLinkName = NULL;
  84. BOOLEAN SPCRTestSucceeded = FALSE;
  85. //
  86. // Open the boot partition so we can load boot drivers off it.
  87. //
  88. Status = ArcOpen(PartitionName, ArcOpenReadWrite, &DriveId);
  89. if (Status != ESUCCESS) {
  90. BlPrint("Couldn't open drive %s\n",PartitionName);
  91. BlPrint(BlFindMessage(BL_DRIVE_ERROR),PartitionName);
  92. goto BootFailed;
  93. }
  94. //
  95. // Initialize dbcs font and display support.
  96. //
  97. TextGrInitialize(DriveId, NULL);
  98. //
  99. // Initialize ARC StdIo functionality
  100. //
  101. strcpy(ConsoleInputName,"consolein=multi(0)key(0)keyboard(0)");
  102. strcpy(ConsoleOutputName,"consoleout=multi(0)video(0)monitor(0)");
  103. Argv[0]=ConsoleInputName;
  104. Argv[1]=ConsoleOutputName;
  105. BlInitStdio (2, Argv);
  106. //
  107. // Re-open the boot partition as a temporary work around
  108. // for NTFS caching bug.
  109. //
  110. ArcClose(DriveId);
  111. Status = ArcOpen(PartitionName, ArcOpenReadWrite, &DriveId);
  112. if (Status != ESUCCESS) {
  113. BlPrint("Couldn't open drive %s\n",PartitionName);
  114. BlPrint(BlFindMessage(BL_DRIVE_ERROR),PartitionName);
  115. goto BootFailed;
  116. }
  117. RtlZeroMemory( &LoaderRedirectionInformation,
  118. sizeof(HEADLESS_LOADER_BLOCK) );
  119. //
  120. // See if we get something from the BIOS.
  121. //
  122. if( BlRetrieveBIOSRedirectionInformation() ) {
  123. BlInitializeHeadlessPort();
  124. BlPrint("SPCR table detected.\r\n" );
  125. BlPrint(" PortAddress: %lx\r\n", LoaderRedirectionInformation.PortAddress );
  126. BlPrint(" PortNumber: %d\r\n", LoaderRedirectionInformation.PortNumber );
  127. BlPrint(" BaudRate: %d\r\n", LoaderRedirectionInformation.BaudRate );
  128. BlPrint(" Parity: %d\r\n", LoaderRedirectionInformation.Parity ? 1 : 0 );
  129. BlPrint(" AddressSpace: %s\r\n", LoaderRedirectionInformation.IsMMIODevice ? "MMIO" : "SysIO" );
  130. BlPrint(" StopBits: %d\r\n", LoaderRedirectionInformation.StopBits );
  131. BlPrint(" PciDeviceId: %lx\r\n", LoaderRedirectionInformation.PciDeviceId );
  132. BlPrint(" PciVendorId: %lx\r\n", LoaderRedirectionInformation.PciVendorId );
  133. BlPrint(" PciBusNumber: %lx\r\n", LoaderRedirectionInformation.PciBusNumber );
  134. BlPrint(" PciSlotNumber: %lx\r\n", LoaderRedirectionInformation.PciSlotNumber );
  135. BlPrint(" PciFunctionNumber: %lx\r\n", LoaderRedirectionInformation.PciFunctionNumber );
  136. BlPrint(" PciFlags: %lx\r\n", LoaderRedirectionInformation.PciFlags );
  137. if( BlIsTerminalConnected() ) {
  138. ULONG RandomNumber1 = 0;
  139. ULONG RandomNumber2 = 0;
  140. ULONG ch = 0;
  141. BlPrint("\r\nUART address verified.\r\n" );
  142. TryAgain:
  143. //
  144. // Now generate a (semi)random string.
  145. //
  146. RandomNumber1 = (ArcGetRelativeTime() & 0x7FFF) << 16;
  147. RandomNumber1 += (ArcGetRelativeTime() & 0xFFFF) << 1;
  148. RandomNumber2 = 0;
  149. //
  150. // Send the string, then ask the user to send it back.
  151. //
  152. BlPrint( "\r\nPlease enter the following test string: '%d'\r\n", RandomNumber1 );
  153. do {
  154. // Get a key.
  155. while( !(ch = BlGetKey()) ) {
  156. }
  157. ch &= 0xFF;
  158. if( (ch <= '9') && (ch >= '0') ) {
  159. RandomNumber2 = (RandomNumber2 * 10) + (ch - 0x30);
  160. }
  161. } while( (ch != 0) && (ch != '\r') && (ch != '\n') );
  162. if( RandomNumber1 == RandomNumber2 ) {
  163. BlPrint( "Identical string returned. '%d'\r\n", RandomNumber2 );
  164. SPCRTestSucceeded = TRUE;
  165. } else {
  166. //
  167. // We failed the check. Inform the user and try again.
  168. //
  169. BlPrint( "Inconsistent string returned. '%d'\r\n", RandomNumber2 );
  170. // clear the input buffer
  171. while( (ch = BlGetKey()) );
  172. goto TryAgain;
  173. }
  174. } else {
  175. BlPrint("\r\nUnable to verify UART address.\r\n" );
  176. }
  177. } else {
  178. BlPrint("No SPCR table detected.\r\n");
  179. }
  180. //
  181. // Log the results.
  182. //
  183. Status = BlOpen( DriveId,
  184. "\\spcrtest.txt",
  185. ArcSupersedeReadWrite,
  186. &BlLogFileId );
  187. if (Status != ESUCCESS) {
  188. BlPrint("Couldn't open logfile on boot drive.\n");
  189. goto BootFailed;
  190. } else {
  191. UCHAR Buffer[30];
  192. LONG Count;
  193. Count = sizeof(Buffer);
  194. RtlFillMemory( Buffer, Count, ' ' );
  195. if( SPCRTestSucceeded ) {
  196. sprintf( Buffer, "SPCR test succeeded." );
  197. } else {
  198. sprintf( Buffer, "SPCR test failed." );
  199. }
  200. BlWrite( BlLogFileId, Buffer, Count, &Count );
  201. BlClose( BlLogFileId );
  202. }
  203. BootFailed:
  204. while(1);
  205. }
  206. VOID
  207. DoApmAttemptReconnect(
  208. VOID
  209. )
  210. {
  211. }
  212. BOOLEAN
  213. Blx86CheckForPaeKernel(
  214. IN BOOLEAN UserSpecifiedPae,
  215. IN BOOLEAN UserSpecifiedNoPae,
  216. IN PCHAR UserSpecifiedKernelImage,
  217. IN PCHAR HalImagePath,
  218. IN ULONG LoadDeviceId,
  219. IN ULONG SystemDeviceId,
  220. OUT PULONG HighestSystemPage,
  221. OUT PBOOLEAN UsePaeMode,
  222. IN OUT PCHAR KernelPath
  223. )
  224. {
  225. return TRUE;
  226. }
  227. BOOLEAN
  228. Blx86IsKernelCompatible(
  229. IN ULONG LoadDeviceId,
  230. IN PCHAR ImagePath,
  231. IN BOOLEAN ProcessorSupportsPae,
  232. OUT PBOOLEAN UsePae
  233. )
  234. {
  235. return TRUE;
  236. }
  237. ARC_STATUS
  238. Blx86IsPaeImage(
  239. IN ULONG LoadDeviceId,
  240. IN PCHAR ImagePath,
  241. OUT PBOOLEAN IsPae
  242. )
  243. {
  244. return ESUCCESS;
  245. }
  246. BOOLEAN
  247. BlpChipsetPaeSupported(
  248. VOID
  249. )
  250. {
  251. return(TRUE);
  252. }
  253. ARC_STATUS
  254. BlpCheckVersion(
  255. IN ULONG LoadDeviceId,
  256. IN PCHAR ImagePath
  257. )
  258. {
  259. return ESUCCESS;
  260. }