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.

224 lines
5.1 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. ARC_STATUS Status;
  48. ULONG DriveId;
  49. ULONGLONG NetRebootParameter;
  50. BOOLEAN UseCommandConsole = FALSE;
  51. BOOLEAN RollbackEnabled = FALSE;
  52. extern BOOLEAN FwDescriptorsValid;
  53. extern BOOLEAN TryASRViaNetwork;
  54. if (BlBootingFromNet) {
  55. //
  56. // Go retrieve all the information passed to us from StartROM.
  57. // Once we have that, we'll call BlGetHeadlessRestartBlock and
  58. // get all the port settings that StartROM sent us. These,
  59. // in turn, will then be used in BlInitializeTerminal(), which
  60. // we'are about to call.
  61. //
  62. NetGetRebootParameters(
  63. &NetRebootParameter,
  64. NULL,
  65. NULL,
  66. NULL,
  67. NULL,
  68. NULL,
  69. NULL,
  70. FALSE
  71. );
  72. if (NetRebootParameter == NET_REBOOT_COMMAND_CONSOLE_ONLY) {
  73. UseCommandConsole = TRUE;
  74. }
  75. if (NetRebootParameter == NET_REBOOT_ASR) {
  76. TryASRViaNetwork = TRUE;
  77. }
  78. }
  79. //
  80. // Initialize any dumb terminal that may be connected.
  81. //
  82. BlInitializeHeadlessPort();
  83. //
  84. // Open the boot partition so we can load NTDETECT off it.
  85. //
  86. Status = ArcOpen(PartitionName, ArcOpenReadOnly, &DriveId);
  87. if (Status != ESUCCESS) {
  88. BlPrint(BlFindMessage(SL_DRIVE_ERROR),PartitionName);
  89. return;
  90. }
  91. if (_stricmp( (PCHAR)(0x7c03), "cmdcons" ) == 0) {
  92. UseCommandConsole = TRUE;
  93. } else if (strcmp ((PCHAR)(0x7c03), "undo") == 0) {
  94. //
  95. // NTLDR wrote the exact text "undo" (including the nul
  96. // terminator). We know the address this text was written
  97. // to -- 0x7C03. If we find the token, then enable rollback
  98. // mode. This triggers an argument to be passed to textmode
  99. // setup, plus a different boot message.
  100. //
  101. RollbackEnabled = TRUE;
  102. }
  103. //
  104. // Initialize dbcs font and display.
  105. //
  106. TextGrInitialize(DriveId, &BootFontImageLength);
  107. if (UseCommandConsole) {
  108. BlPrint(BlFindMessage(SL_NTDETECT_CMDCONS));
  109. } else if (RollbackEnabled) {
  110. BlPrint(BlFindMessage(SL_NTDETECT_ROLLBACK));
  111. } else {
  112. BlPrint(BlFindMessage(SL_NTDETECT_MSG));
  113. }
  114. //
  115. // detect HAL here.
  116. //
  117. if (!BlDetectHardware(DriveId, "FASTDETECT")) {
  118. BlPrint(BlFindMessage(SL_NTDETECT_FAILURE));
  119. return;
  120. }
  121. FwDescriptorsValid = FALSE;
  122. BlKernelChecked=TRUE;
  123. //
  124. // NOTE:
  125. // If you are testing the changes on read only Jaz drive uncomment this line
  126. // and put the correct value for rdisk(?). You also need to make sure
  127. // that SCSI BIOS emulation for the jaz drive is turned on for this trick
  128. // to work.
  129. //
  130. //strcpy(PartitionName, "multi(0)disk(0)rdisk(1)partition(1)");
  131. //
  132. // Close the drive, the loader will re-open it.
  133. //
  134. ArcClose(DriveId);
  135. //
  136. // Create arguments, call off to setupldr
  137. //
  138. if (BlBootingFromNet) {
  139. strcpy(SetupLoadFileName, PartitionName);
  140. strcat(SetupLoadFileName, "\\i386\\SETUPLDR");
  141. } else {
  142. strcpy(SetupLoadFileName, PartitionName);
  143. strcat(SetupLoadFileName, "\\SETUPLDR");
  144. }
  145. Argv[0] = SetupLoadFileName;
  146. Argc = 1;
  147. if (UseCommandConsole) {
  148. Argv[Argc++] = "ImageType=cmdcons";
  149. }
  150. if (RollbackEnabled) {
  151. //
  152. // Rollback is a special case where we know there can be no
  153. // OsLoadOptions.
  154. //
  155. Argv[Argc++] = "ImageType=rollback";
  156. }
  157. Status = SlInit( Argc, Argv, NULL );
  158. //
  159. // We should never return here, something
  160. // horrible has happened.
  161. //
  162. if (!BlIsTerminalConnected()) {
  163. //
  164. // typical case. wait for user to press a key and then
  165. // restart
  166. //
  167. while(!BlGetKey());
  168. }
  169. else {
  170. //
  171. // headless case. present user with mini sac
  172. //
  173. while(!BlTerminalHandleLoaderFailure());
  174. }
  175. ArcRestart();
  176. return;
  177. }