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.

218 lines
5.3 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. initia64.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. Allen Kay (akay) 19-Mar-1998
  11. --*/
  12. #include "setupldr.h"
  13. #include "bldria64.h"
  14. #include "msgs.h"
  15. #include <netboot.h>
  16. #include "parsebnvr.h"
  17. #if defined(ELTORITO)
  18. extern BOOLEAN ElToritoCDBoot;
  19. #endif
  20. UCHAR MyBuffer[SECTOR_SIZE+32];
  21. ARC_STATUS
  22. SlInit(
  23. IN ULONG Argc,
  24. IN PCHAR Argv[],
  25. IN PCHAR Envp[]
  26. );
  27. BOOLEAN
  28. BlDetectHardware(
  29. IN ULONG DriveId,
  30. IN PCHAR LoadOptions
  31. );
  32. VOID
  33. KiProcessorWorkAround(
  34. ULONG Arg1
  35. );
  36. ARC_STATUS
  37. BlGetEfiBootOptions(
  38. OUT PUCHAR Argv0String OPTIONAL,
  39. OUT PUCHAR SystemPartition OPTIONAL,
  40. OUT PUCHAR OsLoaderFilename OPTIONAL,
  41. OUT PUCHAR OsLoadPartition OPTIONAL,
  42. OUT PUCHAR OsLoadFilename OPTIONAL,
  43. OUT PUCHAR FullKernelPath OPTIONAL,
  44. OUT PUCHAR OsLoadOptions OPTIONAL
  45. );
  46. VOID
  47. BlStartup(
  48. IN PCHAR PartitionName
  49. )
  50. /*++
  51. Routine Description:
  52. Does x86-specific initialization, particularly running NTDETECT, then
  53. calls to the common setupldr.
  54. Arguments:
  55. PartitionName - Supplies the ARC name of the partition (or floppy) that
  56. setupldr was loaded from.
  57. Return Value:
  58. Does not return
  59. --*/
  60. {
  61. ULONG Argc = 0;
  62. PCHAR Argv[10];
  63. CHAR SetupLoadFileName[129], szOSLoadOptions[100], szOSLoadFilename[129], szOSLoadPartition[129];
  64. CHAR SystemPartition[129];
  65. ARC_STATUS Status;
  66. SetupLoadFileName[0] = '\0';
  67. szOSLoadOptions[0] = '\0';
  68. szOSLoadFilename[0] = '\0';
  69. szOSLoadPartition[0] = '\0';
  70. //
  71. // Initialize any dumb terminal that may be connected.
  72. //
  73. BlInitializeHeadlessPort();
  74. if (!BlBootingFromNet) {
  75. //
  76. // Try to read the NVRAM first. This will fail if we were
  77. // boot from the EFI shell, in which case we need to read
  78. // boot.nvr.
  79. //
  80. Status = BlGetEfiBootOptions(
  81. (PUCHAR) SetupLoadFileName,
  82. NULL,
  83. NULL,
  84. (PUCHAR) szOSLoadPartition,
  85. (PUCHAR) szOSLoadFilename,
  86. NULL,
  87. (PUCHAR) szOSLoadOptions
  88. );
  89. if ( Status != ESUCCESS ) {
  90. #if DBG
  91. BlPrint(TEXT("Couldn't get EFI boot options\r\n"));
  92. #endif
  93. //
  94. // It's expected that this fails if we're booting off of CDROM
  95. // since there isn't any windows information in the EFI cdrom boot
  96. // entry
  97. //
  98. if (ElToritoCDBoot ) {
  99. strcpy(SetupLoadFileName, PartitionName);
  100. strcat(SetupLoadFileName, "\\setupldr.efi");
  101. //
  102. // the code was setting these options on a CDBOOT, but I don't
  103. // think these options are at all necessary.
  104. //
  105. // strcpy(szOSLoadOptions, "OSLOADOPTIONS=WINNT32" );
  106. // strcpy(szOSLoadFilename, "OSLOADFILENAME=\\$WIN_NT$.~LS\\IA64" );
  107. // strcpy(szOSLoadPartition, "OSLOADPARTITION=" );
  108. // strcat(szOSLoadPartition, PartitionName);
  109. } else {
  110. //
  111. // uh-oh. no information on this build. we either guess or
  112. // we have to bail out. Let's guess.
  113. //
  114. strcpy(SetupLoadFileName, "multi(0)disk(0)rdisk(0)partition(1)\\setupldr.efi");
  115. strcpy(szOSLoadOptions, "OSLOADOPTIONS=WINNT32" );
  116. strcpy(szOSLoadFilename, "OSLOADFILENAME=\\$WIN_NT$.~LS\\IA64" );
  117. strcpy(szOSLoadPartition, "OSLOADPARTITION=multi(0)disk(0)rdisk(0)partition(3)" );
  118. }
  119. }
  120. } else {
  121. #if DBG
  122. BlPrint(TEXT("setting os load options for PXE boot\r\n"));
  123. #endif
  124. strcpy(SetupLoadFileName, PartitionName);
  125. strcat(SetupLoadFileName, "\\ia64\\setupldr.efi");
  126. }
  127. //
  128. // detect HAL here.
  129. //
  130. //
  131. // Create arguments, call off to setupldr
  132. //
  133. Argv[Argc++]=SetupLoadFileName;
  134. //
  135. // A0 processor workarounds
  136. //
  137. KiProcessorWorkAround(0);
  138. _strlwr(PartitionName);
  139. if( strstr(PartitionName, "rdisk") || (BlBootingFromNet) ) {
  140. Argv[Argc++] = szOSLoadOptions;
  141. Argv[Argc++] = szOSLoadFilename;
  142. Argv[Argc++] = szOSLoadPartition;
  143. }
  144. //
  145. // System partition is needed for automated WinPE boot
  146. //
  147. strcpy(SystemPartition, "systempartition=");
  148. strcat(SystemPartition, PartitionName);
  149. Argv[Argc++] = SystemPartition;
  150. Status = SlInit(Argc, Argv, NULL);
  151. //
  152. // We should never return here, something
  153. // horrible has happened.
  154. //
  155. if (!BlIsTerminalConnected()) {
  156. //
  157. // typical case. wait for user to press a key and then
  158. // restart
  159. //
  160. while(!BlGetKey());
  161. }
  162. else {
  163. //
  164. // headless case. present user with mini sac
  165. //
  166. while(!BlTerminalHandleLoaderFailure());
  167. }
  168. ArcRestart();
  169. return;
  170. }