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.

138 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1998 Intel Corporation
  3. Module Name:
  4. mode.c
  5. Abstract:
  6. Shell app "mode"
  7. Revision History
  8. --*/
  9. #include "shell.h"
  10. /*
  11. *
  12. */
  13. EFI_STATUS
  14. InitializeMode (
  15. IN EFI_HANDLE ImageHandle,
  16. IN EFI_SYSTEM_TABLE *SystemTable
  17. );
  18. /*
  19. *
  20. */
  21. EFI_DRIVER_ENTRY_POINT(InitializeMode)
  22. EFI_STATUS
  23. InitializeMode (
  24. IN EFI_HANDLE ImageHandle,
  25. IN EFI_SYSTEM_TABLE *SystemTable
  26. )
  27. {
  28. CHAR16 **Argv;
  29. UINTN Argc;
  30. UINTN NewCol, NewRow;
  31. UINTN Col, Row;
  32. UINTN Index;
  33. INTN Mode;
  34. EFI_STATUS Status;
  35. SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut;
  36. /* Check to see if the app is to install as a "internal command"
  37. * to the shell
  38. */
  39. InstallInternalShellCommand (
  40. ImageHandle, SystemTable, InitializeMode,
  41. L"mode", /* command */
  42. L"mode [col row]", /* command syntax */
  43. L"Set/get current text mode", /* 1 line descriptor */
  44. NULL /* command help page */
  45. );
  46. /*
  47. * Initialize app
  48. */
  49. InitializeShellApplication (ImageHandle, SystemTable);
  50. Argv = SI->Argv;
  51. Argc = SI->Argc;
  52. /*
  53. * Scan args
  54. */
  55. NewRow = 0;
  56. NewCol = 0;
  57. for (Index = 1; Index < Argc; Index += 1) {
  58. if (!NewCol) {
  59. NewCol = Atoi (Argv[Index]);
  60. continue;
  61. }
  62. if (!NewRow) {
  63. NewRow = Atoi (Argv[Index]);
  64. continue;
  65. }
  66. Print (L"%Emode: too many arguments\n");
  67. goto Done;
  68. }
  69. ConOut = ST->ConOut;
  70. /*
  71. * If not setting a new mode, dump the available modes
  72. */
  73. if (!NewRow && !NewCol) {
  74. Print (L"Available modes on standard output\n");
  75. for (Mode=0; Mode < ConOut->Mode->MaxMode; Mode++) {
  76. Status = ConOut->QueryMode(ConOut, Mode, &Col, &Row);
  77. if (EFI_ERROR(Status)) {
  78. Print (L"%Emode: failed to query mode: %r\n", Status);
  79. goto Done;
  80. }
  81. Print (L" col %3d row %3d %c\n", Col, Row, Mode == ConOut->Mode->Mode ? '*' : ' ');
  82. }
  83. } else {
  84. for (Mode=0; Mode < ConOut->Mode->MaxMode; Mode++) {
  85. Status = ConOut->QueryMode(ConOut, Mode, &Col, &Row);
  86. if (EFI_ERROR(Status)) {
  87. Print (L"%Emode: failed to query mode: %r\n", Status);
  88. goto Done;
  89. }
  90. if (Row == NewRow && Col == NewCol) {
  91. ConOut->SetMode (ConOut, Mode);
  92. ConOut->ClearScreen (ConOut);
  93. goto Done;
  94. }
  95. }
  96. Print (L"%Emode: not found (%d,%d)\n", NewCol, NewRow);
  97. }
  98. Done:
  99. return EFI_SUCCESS;
  100. }