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.

179 lines
3.4 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. if (BlTerminalHandleLoaderFailure()) {
  85. ArcRestart();
  86. }
  87. } else {
  88. REBOOT(0);
  89. }
  90. }
  91. VOID
  92. BlInitializeTerminal(
  93. VOID
  94. )
  95. /*++
  96. Routine Description:
  97. Does x86-specific initialization of a dumb terminal connected to a serial port.
  98. Arguments:
  99. None.
  100. Return Value:
  101. None.
  102. --*/
  103. {
  104. //
  105. // Try to initialize the headless port.
  106. //
  107. BlInitializeHeadlessPort();
  108. if( LoaderRedirectionInformation.PortNumber == 0 ) {
  109. //
  110. // we didn't get anything from the BIOS. See if StartROM
  111. // was redirecting.
  112. //
  113. if( (BOOLEAN)(BIOS_REDIRECT_SERVICE(1) != -1) ) {
  114. //
  115. // He is. Pick up his settings.
  116. //
  117. RtlZeroMemory( &LoaderRedirectionInformation, sizeof(HEADLESS_LOADER_BLOCK) );
  118. LoaderRedirectionInformation.PortNumber = (ULONG)BIOS_REDIRECT_SERVICE(1);
  119. LoaderRedirectionInformation.BaudRate = (ULONG)BIOS_REDIRECT_SERVICE(2);
  120. LoaderRedirectionInformation.Parity = (BOOLEAN)BIOS_REDIRECT_SERVICE(3);
  121. LoaderRedirectionInformation.StopBits = (UCHAR)BIOS_REDIRECT_SERVICE(4);
  122. //
  123. // Now try again, this time with feeling...
  124. //
  125. BlInitializeHeadlessPort();
  126. }
  127. }
  128. }