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.

224 lines
4.9 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 setupldr
  7. Author:
  8. John Vert (jvert) 14-Oct-1993
  9. Revision History:
  10. --*/
  11. #include "setupldr.h"
  12. #include "bldrx86.h"
  13. #include "msgs.h"
  14. #include <string.h>
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17. #include <netboot.h>
  18. ARC_STATUS
  19. SlInit(
  20. IN ULONG Argc,
  21. IN PCHAR Argv[],
  22. IN PCHAR Envp[]
  23. );
  24. BOOLEAN
  25. BlDetectHardware(
  26. IN ULONG DriveId,
  27. IN PCHAR LoadOptions
  28. );
  29. VOID
  30. BlStartup(
  31. IN PCHAR PartitionName
  32. )
  33. /*++
  34. Routine Description:
  35. Does x86-specific initialization, particularly running NTDETECT, then
  36. calls to the common setupldr.
  37. Arguments:
  38. PartitionName - Supplies the ARC name of the partition (or floppy) that
  39. setupldr was loaded from.
  40. Return Value:
  41. Does not return
  42. --*/
  43. {
  44. ULONG Argc;
  45. PCHAR Argv[10];
  46. CHAR SetupLoadFileName[129];
  47. CHAR LoadOptions[100];
  48. ARC_STATUS Status;
  49. ULONG DriveId;
  50. ULONGLONG NetRebootParameter;
  51. BOOLEAN UseCommandConsole = FALSE;
  52. BOOLEAN RollbackEnabled = FALSE;
  53. extern BOOLEAN FwDescriptorsValid;
  54. extern BOOLEAN TryASRViaNetwork;
  55. if (BlBootingFromNet) {
  56. //
  57. // Go retrieve all the information passed to us from StartROM.
  58. // Once we have that, we'll call BlGetHeadlessRestartBlock and
  59. // get all the port settings that StartROM sent us. These,
  60. // in turn, will then be used in BlInitializeTerminal(), which
  61. // we'are about to call.
  62. //
  63. NetGetRebootParameters(
  64. &NetRebootParameter,
  65. NULL,
  66. NULL,
  67. NULL,
  68. NULL,
  69. NULL,
  70. NULL,
  71. FALSE
  72. );
  73. if (NetRebootParameter == NET_REBOOT_COMMAND_CONSOLE_ONLY) {
  74. UseCommandConsole = TRUE;
  75. }
  76. if (NetRebootParameter == NET_REBOOT_ASR) {
  77. TryASRViaNetwork = TRUE;
  78. }
  79. }
  80. //
  81. // Initialize any dumb terminal that may be connected.
  82. //
  83. BlInitializeHeadlessPort();
  84. //
  85. // Open the boot partition so we can load NTDETECT off it.
  86. //
  87. Status = ArcOpen(PartitionName, ArcOpenReadOnly, &DriveId);
  88. if (Status != ESUCCESS) {
  89. BlPrint(BlFindMessage(SL_DRIVE_ERROR),PartitionName);
  90. return;
  91. }
  92. if (_stricmp( (PCHAR)(0x7c03), "cmdcons" ) == 0) {
  93. UseCommandConsole = TRUE;
  94. } else if (strcmp ((PCHAR)(0x7c03), "undo") == 0) {
  95. //
  96. // NTLDR wrote the exact text "undo" (including the nul
  97. // terminator). We know the address this text was written
  98. // to -- 0x7C03. If we find the token, then enable rollback
  99. // mode. This triggers an argument to be passed to textmode
  100. // setup, plus a different boot message.
  101. //
  102. RollbackEnabled = TRUE;
  103. }
  104. //
  105. // Initialize dbcs font and display.
  106. //
  107. TextGrInitialize(DriveId, &BootFontImageLength);
  108. if (UseCommandConsole) {
  109. BlPrint(BlFindMessage(SL_NTDETECT_CMDCONS));
  110. } else if (RollbackEnabled) {
  111. BlPrint(BlFindMessage(SL_NTDETECT_ROLLBACK));
  112. } else {
  113. BlPrint(BlFindMessage(SL_NTDETECT_MSG));
  114. }
  115. //
  116. // See if we need to send /noirqscan to ntdetect
  117. //
  118. Argv[0] = NULL;
  119. if(WinntSifHandle != NULL) {
  120. Argv[0] = SlGetSectionKeyIndex(WinntSifHandle,"SetupData","OsLoadOptionsVar",0);
  121. }
  122. //
  123. // detect HAL here.
  124. //
  125. if (!BlDetectHardware(DriveId, Argv[0])) {
  126. BlPrint(BlFindMessage(SL_NTDETECT_FAILURE));
  127. return;
  128. }
  129. FwDescriptorsValid = FALSE;
  130. BlKernelChecked=TRUE;
  131. //
  132. // NOTE:
  133. // If you are testing the changes on read only Jaz drive uncomment this line
  134. // and put the correct value for rdisk(?). You also need to make sure
  135. // that SCSI BIOS emulation for the jaz drive is turned on for this trick
  136. // to work.
  137. //
  138. //strcpy(PartitionName, "multi(0)disk(0)rdisk(1)partition(1)");
  139. //
  140. // Close the drive, the loader will re-open it.
  141. //
  142. ArcClose(DriveId);
  143. //
  144. // Create arguments, call off to setupldr
  145. //
  146. if (BlBootingFromNet) {
  147. strcpy(SetupLoadFileName, PartitionName);
  148. strcat(SetupLoadFileName, "\\i386\\SETUPLDR");
  149. } else {
  150. strcpy(SetupLoadFileName, PartitionName);
  151. strcat(SetupLoadFileName, "\\SETUPLDR");
  152. }
  153. Argv[0] = SetupLoadFileName;
  154. Argc = 1;
  155. if (UseCommandConsole) {
  156. Argv[Argc++] = "ImageType=cmdcons";
  157. }
  158. if (RollbackEnabled) {
  159. //
  160. // Rollback is a special case where we know there can be no
  161. // OsLoadOptions.
  162. //
  163. Argv[Argc++] = "ImageType=rollback";
  164. }
  165. Status = SlInit( Argc, Argv, NULL );
  166. //
  167. // We should never return here, something
  168. // horrible has happened.
  169. //
  170. while (TRUE) {
  171. if (BlTerminalHandleLoaderFailure()) {
  172. ArcRestart();
  173. }
  174. }
  175. return;
  176. }