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.

180 lines
3.6 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 "stdio.h"
  14. VOID
  15. BlInitializeTerminal(
  16. VOID
  17. );
  18. UCHAR BootPartitionName[80];
  19. UCHAR KernelBootDevice[80];
  20. UCHAR OsLoadFilename[100];
  21. UCHAR OsLoaderFilename[100];
  22. UCHAR SystemPartition[100];
  23. UCHAR OsLoadPartition[100];
  24. UCHAR OsLoadOptions[100];
  25. UCHAR ConsoleInputName[50];
  26. UCHAR MyBuffer[SECTOR_SIZE+32];
  27. UCHAR ConsoleOutputName[50];
  28. UCHAR X86SystemPartition[sizeof("x86systempartition=") + sizeof(BootPartitionName)];
  29. VOID
  30. BlStartup(
  31. IN PCHAR PartitionName
  32. )
  33. /*++
  34. Routine Description:
  35. Does x86-specific initialization, particularly presenting the boot.ini
  36. menu and running NTDETECT, then calls to the common osloader.
  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 = 0;
  45. PUCHAR Argv[10];
  46. ARC_STATUS Status;
  47. ULONG BootFileId;
  48. PCHAR BootFile;
  49. ULONG Read;
  50. PCHAR p;
  51. ULONG i;
  52. ULONG DriveId;
  53. ULONG FileSize;
  54. ULONG Count;
  55. LARGE_INTEGER SeekPosition;
  56. PCHAR LoadOptions = NULL;
  57. BOOLEAN UseTimeOut=TRUE;
  58. BOOLEAN AlreadyInitialized = FALSE;
  59. extern BOOLEAN FwDescriptorsValid;
  60. //
  61. // Initialize ARC StdIo functionality
  62. //
  63. strcpy(ConsoleInputName,"consolein=multi(0)key(0)keyboard(0)");
  64. strcpy(ConsoleOutputName,"consoleout=multi(0)video(0)monitor(0)");
  65. Argv[0]=ConsoleInputName;
  66. Argv[1]=ConsoleOutputName;
  67. BlInitStdio (2, Argv);
  68. //
  69. // Initialize any dumb terminal that may be connected.
  70. //
  71. BlInitializeTerminal();
  72. //
  73. // Announce the loader
  74. //
  75. BlPrint(OsLoaderVersion);
  76. //
  77. // The main functionality of the OS chooser.
  78. //
  79. BlOsLoader( Argc, Argv, NULL );
  80. //
  81. // If we ever come back here, just wait to reboot.
  82. //
  83. if (!BlIsTerminalConnected()) {
  84. //
  85. // typical case. wait for user to press a key and then
  86. // restart
  87. //
  88. while(!BlGetKey());
  89. }
  90. else {
  91. //
  92. // headless case. present user with mini sac
  93. //
  94. while(!BlTerminalHandleLoaderFailure());
  95. }
  96. ArcRestart();
  97. }
  98. VOID
  99. BlInitializeTerminal(
  100. VOID
  101. )
  102. /*++
  103. Routine Description:
  104. Does x86-specific initialization of a dumb terminal connected to a serial port.
  105. Arguments:
  106. None.
  107. Return Value:
  108. None.
  109. --*/
  110. {
  111. //
  112. // Clear any stale settings.
  113. //
  114. RtlZeroMemory( &LoaderRedirectionInformation, sizeof(HEADLESS_LOADER_BLOCK) );
  115. //
  116. // See if StartROM was redirecting.
  117. //
  118. if( (BOOLEAN)(BIOS_REDIRECT_SERVICE(1) != -1) ) {
  119. //
  120. // He is. Pick up his settings.
  121. //
  122. LoaderRedirectionInformation.PortNumber = (ULONG)BIOS_REDIRECT_SERVICE(1);
  123. LoaderRedirectionInformation.BaudRate = (ULONG)BIOS_REDIRECT_SERVICE(2);
  124. LoaderRedirectionInformation.Parity = (BOOLEAN)BIOS_REDIRECT_SERVICE(3);
  125. LoaderRedirectionInformation.StopBits = (UCHAR)BIOS_REDIRECT_SERVICE(4);
  126. }
  127. //
  128. // Try to initialize the headless port. Note that if we didn't get anything
  129. // from startrom, then this call will go out and query the BIOS for an
  130. // ACPI table to get settings from.
  131. //
  132. BlInitializeHeadlessPort();
  133. }