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.

921 lines
30 KiB

  1. #include <precomp.h>
  2. //
  3. // Global Coordinates
  4. //
  5. #define COL_TITLE 0
  6. #define ROW_TITLE 0
  7. #define COL_OSOPTIONS 2
  8. #define ROW_OSOPTIONS 2
  9. #define COL_PROMPT 0
  10. #define ROW_PROMPT 2
  11. #define CLEAR_LINE L" "
  12. #define PROMPT L"Select> "
  13. #define NUMBER_OF_USER_OPTIONS 3 // options, plus a space seperator
  14. #define MAX_OPTIONS_PER_VAR 7
  15. #define BACKUPNVRFILE L"\\bootentries.bak"
  16. BOOLEAN AllowExpertCommands = FALSE;
  17. VOID
  18. InitializeStdOut(
  19. IN struct _EFI_SYSTEM_TABLE *SystemTable
  20. )
  21. {
  22. //
  23. // Stash some of the efi stdout pointers
  24. //
  25. ConOut = SystemTable->ConOut;
  26. ClearScreen = ConOut->ClearScreen;
  27. SetCursorPosition = ConOut->SetCursorPosition;
  28. SetMode = ConOut->SetMode;
  29. CursorRow = ConOut->Mode->CursorRow;
  30. CursorColumn = ConOut->Mode->CursorColumn;
  31. EnableCursor = ConOut->EnableCursor;
  32. ConIn = SystemTable->ConIn;
  33. //
  34. // Set the mode to 80, 25 and clear the screen
  35. //
  36. SetMode( ConOut, 0 );
  37. }
  38. VOID
  39. PrintTitle(
  40. )
  41. {
  42. CHAR16 Buffer[256];
  43. ClearScreen( ConOut );
  44. #if 0
  45. PrintAt( 0, 30, L"%H%s%N\n", TITLE1 );
  46. PrintAt( 0, 30, L"%H%s%N", VER_PRODUCTBUILD );
  47. #endif
  48. SPrint(
  49. Buffer,
  50. sizeof(Buffer),
  51. L"%s [Version %d.%d.%d]",
  52. TITLE1,
  53. VER_PRODUCTMAJORVERSION,
  54. VER_PRODUCTMINORVERSION,
  55. VER_PRODUCTBUILD
  56. );
  57. PrintAt(0, 0, L"%H%s%N\n", Buffer);
  58. }
  59. BOOLEAN
  60. isWindowsOsUserSelection(
  61. UINTN userSelection
  62. )
  63. {
  64. BOOLEAN status;
  65. status = isWindowsOsBootOption((char*)LoadOptions[userSelection],
  66. LoadOptionsSize[userSelection]
  67. );
  68. return status;
  69. }
  70. INTN
  71. BackupBootOptions(
  72. CHAR16* filePath
  73. )
  74. {
  75. INTN status;
  76. //
  77. // backup current boot options
  78. //
  79. Print(L"\nBacking up boot options...\n");
  80. status = SaveAllBootOptions(filePath);
  81. if(status != -1) {
  82. Print(L"Backed up Boot Options to file: %H%s%N\n",filePath);
  83. Print(L"Use %HImport%N command to retrieve saved boot options\n");
  84. } else {
  85. Print(L"Could not backup Boot Options to file: %H%s%N!\n",filePath);
  86. }
  87. return status;
  88. }
  89. VOID
  90. DisplayMainMenu(
  91. )
  92. {
  93. UINT32 done = FALSE;
  94. UINT32 nUserSelection, nSubUserSelection, nModifyVar;
  95. CHAR16 szUserSelection[1024];
  96. CHAR16 szOsLoader[1024];
  97. CHAR16 szInput[512];
  98. VOID* SourceBuffer = NULL;
  99. UINT32 PartitionCount;
  100. EFI_DEVICE_PATH *FilePath;
  101. //
  102. // Display boot options from nvram.
  103. //
  104. PrintTitle();
  105. GetBootManagerVars();
  106. DisplayBootOptions();
  107. //
  108. // Process user input.
  109. //
  110. while( !done ) {
  111. GetUserSelection( szUserSelection );
  112. //
  113. // Handle char string commands
  114. //
  115. if( (!StriCmp( szUserSelection, L"q")) || (!StriCmp( szUserSelection, L"quit"))
  116. || (!StriCmp( szUserSelection, L"Q")) || (!StriCmp( szUserSelection, L"exit")) ) {
  117. //
  118. // Quit
  119. //
  120. done = TRUE;
  121. }
  122. else if( (!StriCmp( szUserSelection, L"d")) || (!StriCmp( szUserSelection, L"D"))
  123. || (!StriCmp( szUserSelection, L"display")) ) {
  124. //
  125. // Display command
  126. //
  127. //
  128. // Choose selection
  129. //
  130. Print( L"\n" );
  131. nSubUserSelection = GetSubUserSelection( L"Enter boot option to display: ", (UINT32) GetOsBootOptionsCount() );
  132. if( nSubUserSelection != 0 ) {
  133. nSubUserSelection--;
  134. if (isWindowsOsUserSelection(nSubUserSelection) == FALSE) {
  135. Print (L"\n\nThis tool only displays Windows OS boot options\n");
  136. } else {
  137. if(DisplayExtended( nSubUserSelection ))
  138. ;
  139. else {
  140. Print( L"\n" );
  141. Print( L"Wrong Boot Option %d Selected\n", nSubUserSelection+1 );
  142. }
  143. }
  144. Print( L"\n" );
  145. Input( L"Press enter to continue", szInput, sizeof(szInput) );
  146. }
  147. //
  148. // Display boot options from nvram
  149. //
  150. PrintTitle();
  151. DisplayBootOptions();
  152. }
  153. else if( (!StriCmp( szUserSelection, L"e")) || (!StriCmp( szUserSelection, L"E"))
  154. || (!StriCmp( szUserSelection, L"erase")) ) {
  155. //
  156. // Erase command
  157. //
  158. BOOLEAN selectedAll;
  159. //
  160. // Choose selection
  161. //
  162. Print( L"\n" );
  163. nSubUserSelection = GetSubUserSelectionOrAll( L"Enter OS boot option to erase (* = All - Maximum of 30): ",
  164. (UINT32) GetOsBootOptionsCount(),
  165. &selectedAll
  166. );
  167. //
  168. // choose the path based on if the user wants all the os boot options whacked or not
  169. //
  170. if (selectedAll) {
  171. UINTN OsBootOptionsCount = GetOsBootOptionsCount();
  172. //
  173. // get user confirmation
  174. //
  175. Print( L"\n" );
  176. Input( L"This will erase all OS boot options. Are you Sure? ", szInput, sizeof(szInput) );
  177. if( (!StriCmp( szInput, L"y")) || (!StriCmp( szInput, L"Y"))) {
  178. //
  179. // backup current boot options first
  180. //
  181. if (BackupBootOptions(BACKUPNVRFILE) != -1) {
  182. if(EraseAllOsBootOptions()) {
  183. Print(L"\n%d Boot Options Erased.\n", OsBootOptionsCount);
  184. GetBootManagerVars();
  185. }
  186. else {
  187. Print(L"\nThere are no OS Boot Options to Erase.\n");
  188. }
  189. }
  190. Print( L"\n" );
  191. Input( L"Press enter to continue", szInput, sizeof(szInput) );
  192. }
  193. } else {
  194. CHAR16 buf[256];
  195. if( nSubUserSelection > 0 ) {
  196. SPrint (buf, sizeof(buf), L"This will erase OS boot option %d. Are you Sure? ", nSubUserSelection);
  197. // get user confirmation
  198. //
  199. Print( L"\n" );
  200. Input( buf, szInput, sizeof(szInput) );
  201. if( (!StriCmp( szInput, L"y")) || (!StriCmp( szInput, L"Y"))) {
  202. nSubUserSelection--;
  203. if(EraseOsBootOption(nSubUserSelection)) {
  204. Print(L"\nBoot Option %d erased.\n", nSubUserSelection + 1);
  205. FreeBootManagerVars();
  206. GetBootManagerVars();
  207. }
  208. else {
  209. Print(L"\nInvalid OS Boot Options specified.\n");
  210. }
  211. Print( L"\n" );
  212. Input( L"Press enter to continue", szInput, sizeof(szInput) );
  213. }
  214. }
  215. }
  216. //
  217. // Display boot options from nvram
  218. //
  219. PrintTitle();
  220. DisplayBootOptions();
  221. } else if( (!StriCmp( szUserSelection, L"p")) || (!StriCmp( szUserSelection, L"P"))
  222. || (!StriCmp( szUserSelection, L"push")) ) {
  223. //
  224. // Push command
  225. //
  226. //
  227. // Choose selection
  228. //
  229. Print( L"\n" );
  230. nSubUserSelection = GetSubUserSelection( L"Enter the boot option you want to push to top? ", (UINT32) GetOsBootOptionsCount() );
  231. if( nSubUserSelection > 0 ) {
  232. nSubUserSelection--;
  233. if(PushToTop( nSubUserSelection )) {
  234. FreeBootManagerVars();
  235. GetBootManagerVars();
  236. Print( L"\n" );
  237. Print( L"OS Boot Option %d pushed to top of boot order\n", nSubUserSelection+1 );
  238. }
  239. else {
  240. Print( L"\n" );
  241. Print( L"Wrong Boot Option %d Selected\n", nSubUserSelection+1 );
  242. }
  243. Input( L"Press enter to continue", szInput, sizeof(szInput) );
  244. }
  245. //
  246. // Display boot options from nvram
  247. //
  248. PrintTitle();
  249. DisplayBootOptions();
  250. } else if( (!StriCmp( szUserSelection, L"c")) || (!StriCmp( szUserSelection, L"C"))
  251. || (!StriCmp( szUserSelection, L"copy")) ) {
  252. //
  253. // Copy command
  254. //
  255. //
  256. // Choose selection
  257. //
  258. Print( L"\n" );
  259. nSubUserSelection = GetSubUserSelection( L"Enter OS boot option to copy: ", (UINT32) GetOsBootOptionsCount() );
  260. if( nSubUserSelection != 0 ) {
  261. nSubUserSelection--;
  262. if(!CopyVar( nSubUserSelection )) {
  263. Print( L"\n" );
  264. Print( L"Could not Copy Boot Option %d\n",nSubUserSelection+1);
  265. }
  266. else {
  267. SetBootManagerVars();
  268. FreeBootManagerVars();
  269. GetBootManagerVars();
  270. Print( L"\n" );
  271. Print( L"Boot Option %d Copied. ",nSubUserSelection+1);
  272. }
  273. Print( L"\n" );
  274. Input( L"Press enter to continue", szInput, sizeof(szInput) );
  275. }
  276. //
  277. // Display boot options from nvram
  278. //
  279. PrintTitle();
  280. DisplayBootOptions();
  281. } else if( (!StriCmp( szUserSelection, L"x")) || (!StriCmp( szUserSelection, L"X"))
  282. || (!StriCmp( szUserSelection, L"export")) ) {
  283. //
  284. // Save command
  285. //
  286. CHAR16 filePath[512];
  287. BOOLEAN selectedAll;
  288. //
  289. // Choose selection
  290. //
  291. Print( L"\n" );
  292. nSubUserSelection = GetSubUserSelectionOrAll( L"Enter OS boot option to export (* = All - Maximum of 30): ",
  293. (UINT32) GetOsBootOptionsCount(),
  294. &selectedAll
  295. );
  296. if (nSubUserSelection > 0 || selectedAll) {
  297. Print( L"\n" );
  298. Input( L"Enter EXPORT file path: ", filePath, sizeof(filePath) );
  299. if (StrLen(filePath) > 0) {
  300. //
  301. // choose the path based on if the user wants all the os boot options exported or just one
  302. //
  303. if (selectedAll) {
  304. Print(L"\nSaving %d boot options...\n", GetOsBootOptionsCount());
  305. if(SaveAllBootOptions(filePath) != -1) {
  306. Print(L"Saved Boot Options to file: %H%s%N\n",filePath);
  307. Print(L"Use %HImport%N command to retrieve saved boot options\n");
  308. } else {
  309. Print(L"Could not save Boot Options to file: %H%s%N!\n",filePath);
  310. }
  311. } else {
  312. Print(L"\nSaving boot option %d...\n", nSubUserSelection);
  313. if(SaveBootOption(filePath, nSubUserSelection-1) != -1) {
  314. Print(L"Saved Boot Option %d to file: %H%s%N\n",nSubUserSelection, filePath);
  315. Print(L"Use %HImport%N command to retrieve saved boot option\n");
  316. } else {
  317. Print(L"Could not save Boot Option to file: %H%s%N!\n",filePath);
  318. }
  319. }
  320. }
  321. }
  322. Print( L"\n" );
  323. Input( L"Press enter to continue", szInput, sizeof(szInput) );
  324. //
  325. // Display boot options from nvram
  326. //
  327. PrintTitle();
  328. DisplayBootOptions();
  329. } else if( (!StriCmp( szUserSelection, L"i")) || (!StriCmp( szUserSelection, L"I"))
  330. || (!StriCmp( szUserSelection, L"import")) ) {
  331. //
  332. // Restore command
  333. //
  334. CHAR16 filePath[512];
  335. Print( L"\n" );
  336. Input( L"Enter IMPORT file path: ", filePath, sizeof(filePath) );
  337. if (StrLen(filePath) > 0) {
  338. if(RestoreFileExists(filePath) == TRUE) {
  339. if(RestoreNvr(filePath) != -1) {
  340. Print( L"\n" );
  341. Print(L"Imported Boot Options from file: %H%s%N\n",filePath);
  342. FreeBootManagerVars();
  343. GetBootManagerVars();
  344. }
  345. else {
  346. Print(L"Restore failed!\n");
  347. }
  348. } else {
  349. Print(L"\n\nError: Restore file not found: %s\n\n", filePath);
  350. }
  351. }
  352. Print( L"\n" );
  353. Input( L"Press enter to continue", szInput, sizeof(szInput) );
  354. //
  355. // Display boot options from nvram
  356. //
  357. PrintTitle();
  358. DisplayBootOptions();
  359. }
  360. #if 0
  361. else if( (!StriCmp( szUserSelection, L"a")) || (!StriCmp( szUserSelection, L"A"))
  362. || (!StriCmp( szUserSelection, L"add")) ) {
  363. //
  364. // Add command
  365. //
  366. //
  367. // Get EFI system partition
  368. //
  369. PartitionCount = GetPartitions();
  370. if( PartitionCount > 0 ) {
  371. Print( L"\n" );
  372. Input( L"Name of New BootOption: ", szInput, sizeof(szInput) );
  373. FilePath = FileDevicePath(
  374. GetDeviceHandleForPartition(),
  375. L"os\\winnt50\\ia64ldr.efi"
  376. );
  377. PackAndWriteToNvr(
  378. -1,
  379. "multi(0)disk(0)rdisk(0)partition(1)",
  380. "multi(0)disk(0)rdisk(0)partition(1)\\os\\winnt50\\ia64ldr.efi",
  381. "multi(0)disk(0)rdisk(0)partition(2)",
  382. "\\WINNT64",
  383. szInput[0] ? szInput : L"New Boot Option",
  384. "",
  385. (char*) FilePath
  386. );
  387. Print( L"\nAdded %H%s%N. Use %HModify%N command to change any of the default values.\n",
  388. szInput[0] ? szInput : L"New Boot Option" );
  389. Input( L"Press enter to continue", szInput, sizeof(szInput) );
  390. FreeBootManagerVars();
  391. GetBootManagerVars();
  392. } else {
  393. Print( L"No partitions found. To use this option, you must have an EFI or FAT16\n" );
  394. Print( L"partition that will be used as your System Partition.\n" );
  395. Input( L"Press enter to continue", szInput, sizeof(szInput) );
  396. }
  397. //
  398. // Display boot options from nvram
  399. //
  400. PrintTitle();
  401. DisplayBootOptions();
  402. }
  403. #endif
  404. else if( (!StriCmp( szUserSelection, L"h")) || (!StriCmp( szUserSelection, L"H"))
  405. || (!StriCmp( szUserSelection, L"help")) ) {
  406. //
  407. // Help command
  408. //
  409. PrintTitle();
  410. //
  411. // Display Help text.
  412. //
  413. Print( L"\n" );
  414. if ( AllowExpertCommands ) {
  415. Print( L"ExpertCommands Mode enabled.\n\n" );
  416. }
  417. Print( L"%HDisplay%N - Display an OS boot option's environment variables.\n" );
  418. Print( L"%HModify%N - Modify an OS boot option's environment variable.\n" );
  419. Print( L"%HCopy%N - Copy (duplicate) an OS boot option.\n" );
  420. Print( L"%HExport%N - Export all/one OS boot option(s) to disk.\n" );
  421. Print( L"%HImport%N - Import (and append) OS boot option(s) from disk.\n" );
  422. Print( L"%HErase%N - Erase all OS boot options from NVRAM.\n" );
  423. Print( L"%HPush%N - Push a OS boot option to top of boot order.\n" );
  424. Print( L"%HHelp%N - This display.\n" );
  425. Print( L"%HQuit%N - Quit.\n" );
  426. Print( L"\n");
  427. Print( L"Note: When importing/exporting boot options, all specified file paths\n");
  428. Print( L" are absolute and relative to the current disk device.\n");
  429. Print( L"\n");
  430. Print( L" Example: To import Boot0000 from the Windows loader directory WINNT50.0\n");
  431. Print( L" on fs1, you would run nvrboot.efi on fs1 and use the path:\n");
  432. Print( L"\n");
  433. Print( L" \\EFI\\Microsoft\\WINNT50.0\\Boot0000\n");
  434. Print( L"\n");
  435. Input( L"Press enter to continue", szInput, sizeof(szInput) );
  436. //
  437. // Display boot options from nvram
  438. //
  439. PrintTitle();
  440. DisplayBootOptions();
  441. }
  442. else if( (!StriCmp( szUserSelection, L"a")) || (!StriCmp( szUserSelection, L"Advanced")) ) {
  443. AllowExpertCommands = TRUE;
  444. }
  445. else if( (!StriCmp( szUserSelection, L"m")) || (!StriCmp( szUserSelection, L"M"))
  446. || (!StriCmp( szUserSelection, L"modify")) ) {
  447. //
  448. // Modify command
  449. //
  450. //
  451. // Choose selection
  452. //
  453. Print( L"\n" );
  454. nSubUserSelection = GetSubUserSelection( L"Enter OS boot option to modify: ", (UINT32) GetOsBootOptionsCount() );
  455. if( nSubUserSelection > 0 ) {
  456. nSubUserSelection--;
  457. if (isWindowsOsUserSelection(nSubUserSelection) == FALSE) {
  458. Print( L"\n\nThis tool only modifies Windows OS boot options\n" );
  459. } else {
  460. if(DisplayExtended( nSubUserSelection )) {
  461. //
  462. // Choose var
  463. //
  464. nModifyVar = GetSubUserSelection( L"Enter var to modify: ", MAX_OPTIONS_PER_VAR );
  465. if( nModifyVar > 0) {
  466. Print( L"\n" );
  467. //
  468. // Map variable to env var
  469. //
  470. switch( nModifyVar ) {
  471. case 1:
  472. Input( L"LoadIdentifier = ", szInput, sizeof(szInput) );
  473. nModifyVar = DESCRIPTION;
  474. break;
  475. case 2:
  476. Input( L"OsLoadOptions = ", szInput, sizeof(szInput) );
  477. nModifyVar = OSLOADOPTIONS;
  478. break;
  479. case 3:
  480. if (!AllowExpertCommands) {
  481. Print (L"This field currently not modifiable\n");
  482. nModifyVar = 0;
  483. } else {
  484. Input( L"EfiOsLoaderFilePath = ", szInput, sizeof(szInput) );
  485. nModifyVar = EFIFILEPATHLIST;
  486. }
  487. break;
  488. case 4:
  489. if (!AllowExpertCommands) {
  490. Print (L"This field currently not modifiable\n");
  491. nModifyVar = 0;
  492. } else {
  493. Input( L"OsLoaderFilePath = ", szInput, sizeof(szInput) );
  494. nModifyVar = OSFILEPATHLIST;
  495. }
  496. break;
  497. default:
  498. break;
  499. }
  500. if (nModifyVar != 0) {
  501. //
  502. // Write all vars to NV-RAM
  503. //
  504. SetFieldFromLoadOption(
  505. nSubUserSelection,
  506. nModifyVar,
  507. szInput
  508. );
  509. DisplayExtended(nSubUserSelection);
  510. FreeBootManagerVars();
  511. GetBootManagerVars();
  512. }
  513. }
  514. Print( L"\n" );
  515. }
  516. }
  517. Input( L"Press enter to continue", szInput, sizeof(szInput) );
  518. }
  519. }
  520. //
  521. // Display boot options from nvram
  522. //
  523. PrintTitle();
  524. DisplayBootOptions();
  525. }
  526. }
  527. UINT32
  528. GetConfirmation(
  529. IN CHAR16 *szConfirm
  530. )
  531. {
  532. CHAR16 szIn[80];
  533. UINT32 saveRow;
  534. Print( L"\n" );
  535. saveRow = CursorRow;
  536. if( szConfirm ) {
  537. Input( szConfirm, szIn, sizeof(szIn) );
  538. } else {
  539. Input( L"Are you sure? ", szIn, sizeof(szIn) );
  540. }
  541. // Clear previous input
  542. SetCursorPosition( ConOut, 0, saveRow );
  543. PrintAt( 0, saveRow, CLEAR_LINE );
  544. if( (!StriCmp( szIn, L"y")) || (!StriCmp( szIn, L"yes")) )
  545. return TRUE;
  546. return FALSE;
  547. }
  548. VOID
  549. GetUserSelection(
  550. OUT CHAR16 *szUserSelection
  551. )
  552. {
  553. UINT32 numSelections;
  554. UINT32 row, col;
  555. numSelections = (UINT32) GetOsBootOptionsCount();
  556. numSelections += NUMBER_OF_USER_OPTIONS;
  557. // note, we use ROW_PROMPT as an offset
  558. row = ROW_OSOPTIONS + numSelections + ROW_PROMPT;
  559. col = COL_PROMPT;
  560. // Clear previous input
  561. //SetCursorPosition( ConOut, col, row );
  562. //PrintAt( col, row, CLEAR_LINE );
  563. // Get the input
  564. //SetCursorPosition( ConOut, col, row );
  565. Print(L"\n");
  566. Input( PROMPT, szUserSelection, 1024 );
  567. }
  568. //
  569. // jamschw: got rid of the column settings in the PrintAt's. PrintAt
  570. // attempts to set the cursor position. When it fails, it simply
  571. // prints at the next location. Take this into account since the
  572. // vmode was set to 80x25, but nobody wrote anything special to
  573. // make this a 25 line app. So instead of having inconsistent UI,
  574. // just let the information scroll off the screen in a consistent
  575. // mannar.
  576. //
  577. VOID
  578. DisplayBootOptions(
  579. )
  580. {
  581. UINT32 i;
  582. UINT32 j;
  583. CHAR16 LoadIdentifier[200];
  584. UINTN bootOrderCount;
  585. bootOrderCount = GetBootOrderCount();
  586. if (bootOrderCount > 0) {
  587. for ( i=0,j=0; i<GetOsBootOptionsCount(); i++ ) {
  588. if(LoadOptionsSize[i] == 0) {
  589. //
  590. // It's possible a null load option could be in the list
  591. // we naturally want to catch this...
  592. //
  593. #if EFI_DEBUG
  594. Print(L"\nNVRAM Boot Entry %d has 0 length!\n", i);
  595. ASSERT(LoadOptionsSize[i] > 0);
  596. #endif
  597. //
  598. // if we are not in debug mode, just let the use know what is
  599. // going on other wise the menu may be screwed up
  600. //
  601. PrintAt( 0, ROW_OSOPTIONS + j, L" %2d. (0 length Boot Entry)\n", i+1);
  602. } else if(GetLoadIdentifier( i, LoadIdentifier)) {
  603. if (isWindowsOsBootOption((char*)LoadOptions[i], LoadOptionsSize[i]) == TRUE)
  604. {
  605. PrintAt( 0, ROW_OSOPTIONS + j, L" *%2d. %s\n", i+1, LoadIdentifier );
  606. }
  607. else {
  608. PrintAt( 0, ROW_OSOPTIONS + j, L" %2d. %s\n", i+1, LoadIdentifier );
  609. }
  610. j++;
  611. }
  612. }
  613. if (GetBootOrderCount() != GetOsBootOptionsCount()) {
  614. PrintAt( 0, ROW_OSOPTIONS + ++j, L" [Nvrboot does not support more than %d Boot Entries]\n", MAXBOOTVARS);
  615. }
  616. Print(L"\n");
  617. PrintAt( 0, ROW_OSOPTIONS + ++j, L" * = Windows OS boot option\n" );
  618. Print(L"\n");
  619. j++;
  620. } else {
  621. PrintAt( 0, ROW_OSOPTIONS, L" [No Boot Entries Present]\n");
  622. j = 2;
  623. }
  624. //
  625. // Display Maitainence Menu
  626. //
  627. #if 0
  628. PrintAt( COL_OSOPTIONS, ROW_OSOPTIONS + ++j, L"%H(D)%Nisplay %H(M)%Nodify %H(C)%Nopy\n" );
  629. PrintAt( COL_OSOPTIONS, ROW_OSOPTIONS + ++j, L"%H(S)%Nave %H(R)%Nestore %H(E)%Nrase\n" );
  630. // PrintAt( COL_OSOPTIONS, ROW_OSOPTIONS + ++j, L"%H(A)%Ndd %H(P)%Nush %H(H)%Nelp %H(Q)%Nuit\n" );
  631. PrintAt( COL_OSOPTIONS, ROW_OSOPTIONS + ++j, L"%H(P)%Nush %H(H)%Nelp %H(Q)%Nuit\n" );
  632. #endif
  633. PrintAt( 0, ROW_OSOPTIONS + ++j, L" %H(D)%Nisplay %H(M)%Nodify %H(C)%Nopy E%H(x)%Nport %H(I)%Nmport %H(E)%Nrase %H(P)%Nush %H(H)%Nelp %H(Q)%Nuit\n" );
  634. }
  635. #if 0
  636. #define L_SYSTEMPARTITION L"SystemPartition"
  637. #define L_OSLOADER L"OsLoader"
  638. #define L_OSLOADPARTITION L"OsLoadPartition"
  639. #define L_OSLOADFILENAME L"OsLoadFilename"
  640. #define L_LOADIDENTIFIER L"LoadIdentifier"
  641. #define L_OSLOADOPTIONS L"OsLoadOptions"
  642. #define L_OSLOADPATH L"OsLoadOptions"
  643. #define L_EFIFILEPATH L"EfiOsLoaderFilePath"
  644. #define L_COUNTDOWN L"COUNTDOWN"
  645. #define L_AUTOLOAD L"AUTOLOAD"
  646. #define L_LASTKNOWNGOOD L"LastKnownGood"
  647. #define L_BOOTSELECTION L"BootSelection"
  648. #endif
  649. BOOLEAN
  650. DisplayExtended(
  651. IN UINT32 Selection
  652. )
  653. {
  654. char OsLoadOptions[200];
  655. CHAR16 LoadIdentifier[200];
  656. unsigned char EfiFilePath[1024];
  657. unsigned char OsLoadPath[1024];
  658. CHAR16 FilePathShort[200];
  659. BOOLEAN status;
  660. PFILE_PATH pFilePath;
  661. EFI_GUID DiskGuid;
  662. #if DEBUG_PACK
  663. DisplayELOFromLoadOption(Selection);
  664. #endif
  665. status = GetOsLoadOptionVars(
  666. Selection,
  667. LoadIdentifier,
  668. OsLoadOptions,
  669. EfiFilePath,
  670. OsLoadPath
  671. );
  672. if (status == FALSE) {
  673. return status;
  674. }
  675. Print( L"\n" );
  676. Print( L"1. LoadIdentifier = %s\n", LoadIdentifier );
  677. Print( L"2. OsLoadOptions = %s\n", OsLoadOptions );
  678. GetFilePathShort( (EFI_DEVICE_PATH*) EfiFilePath, FilePathShort );
  679. GetDiskGuidFromPath( (EFI_DEVICE_PATH*) EfiFilePath, &DiskGuid );
  680. Print( L"3. EfiOsLoaderFilePath = %g :: %s\n", &DiskGuid, FilePathShort );
  681. pFilePath = (FILE_PATH*)OsLoadPath;
  682. GetFilePathShort( (EFI_DEVICE_PATH*)pFilePath->FilePath, FilePathShort );
  683. GetDiskGuidFromPath( (EFI_DEVICE_PATH*) pFilePath->FilePath, &DiskGuid );
  684. Print( L"4. OsLoaderFilePath = %g :: %s\n", &DiskGuid, FilePathShort );
  685. return TRUE;
  686. }
  687. UINT32
  688. GetSubUserSelectionOrAll(
  689. IN CHAR16* szConfirm,
  690. IN UINT32 MaxSelection,
  691. OUT BOOLEAN* selectedAll
  692. )
  693. {
  694. CHAR16 szIn[80];
  695. UINT32 nUserSelection = 0;
  696. if( szConfirm ) {
  697. Input( szConfirm, szIn, sizeof(szIn) );
  698. } else {
  699. Input( L"Enter Selection (* = ALL - Maximum of 30)? ", szIn, sizeof(szIn) );
  700. }
  701. *selectedAll = FALSE;
  702. if (StrCmp(szIn, L"*") == 0) {
  703. *selectedAll = TRUE;
  704. } else {
  705. nUserSelection = (int) Atoi( szIn );
  706. if(( nUserSelection>0 ) && ( nUserSelection <= MaxSelection))
  707. return nUserSelection;
  708. }
  709. return 0;
  710. }
  711. UINT32
  712. GetSubUserSelection(
  713. IN CHAR16 *szConfirm,
  714. IN UINT32 MaxSelection
  715. )
  716. {
  717. CHAR16 szIn[80];
  718. UINT32 nUserSelection = 0;
  719. if( szConfirm ) {
  720. Input( szConfirm, szIn, sizeof(szIn) );
  721. } else {
  722. Input( L"Enter Selection? ", szIn, sizeof(szIn) );
  723. }
  724. nUserSelection = (int) Atoi( szIn );
  725. if(( nUserSelection>0 ) && ( nUserSelection <= MaxSelection))
  726. return nUserSelection;
  727. return 0;
  728. }