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.

293 lines
6.8 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. initia64.c
  5. Abstract:
  6. Does any ia64-specific initialization, then starts the common ARC osloader
  7. Author:
  8. John Vert (jvert) 4-Nov-1993
  9. Revision History:
  10. --*/
  11. #include "bldria64.h"
  12. #include "msg.h"
  13. #include <netboot.h>
  14. #include <string.h>
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17. #include <efi.h>
  18. UCHAR Argv0String[100];
  19. UCHAR BootPartitionName[80];
  20. UCHAR KernelBootDevice[80];
  21. UCHAR OsLoadFilename[100];
  22. UCHAR OsLoaderFilename[100];
  23. UCHAR SystemPartition[100];
  24. UCHAR OsLoadPartition[100];
  25. UCHAR OsLoadOptions[100];
  26. UCHAR ConsoleInputName[50];
  27. UCHAR ConsoleOutputName[50];
  28. UCHAR FullKernelPath[200];
  29. extern ULONGLONG BootFlags;
  30. ARC_STATUS
  31. BlGetEfiBootOptions(
  32. OUT PUCHAR Argv0String OPTIONAL,
  33. OUT PUCHAR SystemPartition OPTIONAL,
  34. OUT PUCHAR OsLoaderFilename OPTIONAL,
  35. OUT PUCHAR OsLoadPartition OPTIONAL,
  36. OUT PUCHAR OsLoadFilename OPTIONAL,
  37. OUT PUCHAR FullKernelPath OPTIONAL,
  38. OUT PUCHAR OsLoadOptions OPTIONAL
  39. );
  40. VOID
  41. BlPreProcessLoadOptions(
  42. PCHAR szOsLoadOptions
  43. );
  44. #define MAXBOOTVARSIZE 1024
  45. #if defined(_MERCED_A0_)
  46. VOID
  47. KiProcessorWorkAround(
  48. );
  49. #endif
  50. VOID
  51. BlStartup(
  52. IN PCHAR PartitionName
  53. )
  54. /*++
  55. Routine Description:
  56. Does Intel-specific initialization, particularly presenting the boot.ini
  57. menu and running NTDETECT, then calls to the common osloader.
  58. Arguments:
  59. PartitionName - Supplies the ARC name of the partition (or floppy) that
  60. setupldr was loaded from.
  61. Return Value:
  62. Does not return
  63. --*/
  64. {
  65. ULONG Argc = 0;
  66. PUCHAR Argv[10];
  67. ARC_STATUS Status;
  68. #if !defined(NO_LEGACY_DRIVERS)
  69. PCHAR p;
  70. ULONG DriveId;
  71. #endif
  72. #ifdef FW_HEAP
  73. extern BOOLEAN FwDescriptorsValid;
  74. #endif
  75. UNREFERENCED_PARAMETER( PartitionName );
  76. //
  77. // Initialize ARC StdIo functionality
  78. //
  79. strcpy((PCHAR)ConsoleInputName,"consolein=multi(0)key(0)keyboard(0)");
  80. strcpy((PCHAR)ConsoleOutputName,"consoleout=multi(0)video(0)monitor(0)");
  81. Argv[0]=ConsoleInputName;
  82. Argv[1]=ConsoleOutputName;
  83. BlInitStdio (2, (PCHAR *)Argv);
  84. //
  85. // Check ntldr partition for hiberation image
  86. //
  87. do {
  88. BlClearScreen();
  89. Status = BlGetEfiBootOptions(
  90. Argv0String,
  91. SystemPartition,
  92. OsLoaderFilename,
  93. OsLoadPartition,
  94. OsLoadFilename,
  95. FullKernelPath,
  96. OsLoadOptions
  97. );
  98. if ( Status != ESUCCESS ) {
  99. BlPrint(BlFindMessage(BL_EFI_OPTION_FAILURE));
  100. goto BootFailed;
  101. }
  102. BlClearScreen();
  103. #if !defined(NO_LEGACY_DRIVERS)
  104. p = FullKernelPath;
  105. //
  106. // Initialize SCSI boot driver, if necessary.
  107. //
  108. if(!_strnicmp(p,"scsi(",5)) {
  109. AEInitializeIo(DriveId);
  110. }
  111. #endif // NO_LEGACY_DRIVERS
  112. #if FW_HEAP
  113. //
  114. // Indicate that fw memory descriptors cannot be changed from
  115. // now on.
  116. //
  117. FwDescriptorsValid = FALSE;
  118. #endif
  119. //
  120. // convert it to all one case
  121. //
  122. if (OsLoadOptions[0]) {
  123. _strupr((PCHAR)OsLoadOptions);
  124. }
  125. Argv[Argc++]=Argv0String;
  126. Argv[Argc++]=OsLoaderFilename;
  127. Argv[Argc++]=SystemPartition;
  128. Argv[Argc++]=OsLoadFilename;
  129. Argv[Argc++]=OsLoadPartition;
  130. Argv[Argc++]=OsLoadOptions;
  131. BlPreProcessLoadOptions( (PCHAR)OsLoadOptions );
  132. //
  133. // In the x86 case, we would have already initialized the
  134. // headless port so that the user could actually make his
  135. // boot selection over the headless port. However, on ia64,
  136. // that selection is happening during firmware.
  137. //
  138. // If the user wants us to redirect (via the OsLoadOptions), then
  139. // we should try to do it here.
  140. //
  141. if( strstr((PCHAR)OsLoadOptions, "/REDIRECT")) {
  142. //
  143. // Yep, then want us to redirect. Try and initialize the
  144. // port.
  145. //
  146. BlInitializeHeadlessPort();
  147. #if 0
  148. if( LoaderRedirectionInformation.PortNumber == 0 ) {
  149. //
  150. // We couldn't get any redirection information
  151. // from the firmware. But the user really wants
  152. // us to redirect. Better guess.
  153. //
  154. LoaderRedirectionInformation.PortNumber = 1;
  155. LoaderRedirectionInformation.BaudRate = 9600;
  156. //
  157. // Now try again, this time with feeling...
  158. //
  159. BlInitializeHeadlessPort();
  160. }
  161. #endif
  162. }
  163. Status = BlOsLoader( Argc, (PCHAR *)Argv, NULL );
  164. BootFailed:
  165. if (Status != ESUCCESS) {
  166. if (BootFlags & BOOTFLAG_REBOOT_ON_FAILURE) {
  167. ULONG StartTime = ArcGetRelativeTime();
  168. BlPrint(TEXT("\nRebooting in 5 seconds...\n"));
  169. while ( ArcGetRelativeTime() - StartTime < 5) {}
  170. ArcRestart();
  171. }
  172. //
  173. // Boot failed, wait for reboot
  174. //
  175. if (!BlIsTerminalConnected()) {
  176. //
  177. // typical case. wait for user to press a key and then
  178. // restart
  179. //
  180. while(!BlGetKey());
  181. }
  182. else {
  183. //
  184. // headless case. present user with mini sac
  185. //
  186. while(!BlTerminalHandleLoaderFailure());
  187. }
  188. ArcRestart();
  189. }
  190. } while (TRUE);
  191. }
  192. VOID
  193. BlPreProcessLoadOptions(
  194. PCHAR szOsLoadOptions
  195. )
  196. {
  197. CHAR szTemp[MAXBOOTVARSIZE];
  198. PCHAR p;
  199. ULONG MaxMemory = 0;
  200. ULONG MaxPage = 0;
  201. ULONG ConfigFlagValue=0;
  202. strcpy( szTemp, szOsLoadOptions );
  203. _strupr( szTemp );
  204. #if 0
  205. if( p = strstr( szTemp, ";" ) ) {
  206. *p = '\0';
  207. }
  208. #endif
  209. //
  210. // Process MAXMEM
  211. //
  212. if( (p = strstr( szTemp, "/MAXMEM=" )) != NULL ) {
  213. MaxMemory = atoi( p + sizeof("/MAXMEM=") - 1 );
  214. MaxPage = MaxMemory * ((1024 * 1024) / PAGE_SIZE) - 1;
  215. BlTruncateDescriptors( MaxPage );
  216. }
  217. #if defined(_MERCED_A0_)
  218. //
  219. // Process CONFIGFLAG
  220. //
  221. if ( (p = strstr(szTemp, "CONFIGFLAG")) != NULL ) {
  222. if ( (p = strstr(p, "=")) != NULL ) {
  223. ConfigFlagValue = atol(p+1);
  224. KiProcessorWorkAround(ConfigFlagValue);
  225. }
  226. }
  227. #endif
  228. }