Пример #1
0
EFI_STATUS
StslWriteLogFileName (
  IN STANDARD_TEST_PRIVATE_DATA   *Private
  )
{
  EFI_STATUS                        Status;
  EFI_TEST_OUTPUT_LIBRARY_PROTOCOL  *Output;
  EFI_FILE_HANDLE                   FileHandle;
  EFI_SIMPLE_TEXT_OUT_PROTOCOL      *ConOut;
  CHAR16                            String[EFI_MAX_PRINT_BUFFER];

  Output = Private->OutputProtocol;
  ConOut = gST->ConOut;

  Status = EFI_SUCCESS;

  //
  // System log file
  //
  SPrint (String, EFI_MAX_PRINT_BUFFER, L"Logfile: \"%s\"\n",
          Private->SystemLogFile.FileName);
  if (Private->SystemLogFile.EnableScreenOutput) {
    Status = ConOut->OutputString (ConOut, String);
    if ( EFI_ERROR (Status) ) {
      return Status;
    }
  }

  FileHandle = Private->SystemLogFile.FileHandle;
  if (FileHandle != NULL) {
    Status = Output->Write (Output, FileHandle, String);
    if ( EFI_ERROR (Status) ) {
      return Status;
    }
  }

  //
  // Case log file
  //
  SPrint (String, EFI_MAX_PRINT_BUFFER, L"Logfile: \"%s\"\n",
          Private->CaseLogFile.FileName);
  if (Private->CaseLogFile.EnableScreenOutput) {
    Status = ConOut->OutputString (ConOut, String);
    if ( EFI_ERROR (Status) ) {
      return Status;
    }
  }

  FileHandle = Private->CaseLogFile.FileHandle;
  if (FileHandle != NULL) {
    Status = Output->Write (Output, FileHandle, String);
  }

  return Status;
}
Пример #2
0
void
remove_password_box (EFI_SYSTEM_TABLE *systab)
{
	EFI_SIMPLE_TEXT_OUT_PROTOCOL *conout = systab->ConOut;

	conout->SetAttribute (conout, EFI_WHITE | EFI_BACKGROUND_BLACK);

	conout->ClearScreen(conout);

	conout->EnableCursor(conout, 1);
}
Пример #3
0
VOID
EFIAPI
SEnvTextOut (
  IN EFI_HANDLE   h,
  IN VOID         *Interface
  )
/*++

Routine Description:

Arguments:

  h         - An EFI handle
  Interface - The interface

Returns:

--*/
{
  EFI_SIMPLE_TEXT_OUT_PROTOCOL  *Dev;
  INTN                          Index;
  UINTN                         Col;
  UINTN                         Row;
  EFI_STATUS                    Status;

  Dev = Interface;

  PrintToken (
    STRING_TOKEN (STR_SHELLENV_DPROT_ATTRIB_X),
    HiiEnvHandle,
    Dev->Mode->Attribute
    );

  //
  // Dump TextOut Info
  //
  for (Index = 0; Index < Dev->Mode->MaxMode; Index++) {
    Status = Dev->QueryMode (Dev, Index, &Col, &Row);
    PrintToken (
      STRING_TOKEN (STR_SHELLENV_DPROT_MODE),
      HiiEnvHandle,
      Index == Dev->Mode->Mode ? '*' : ' ',
      Index
      );

    if (EFI_ERROR (Status)) {
      PrintToken (STRING_TOKEN (STR_SHELLENV_DPROT_ERROR), HiiEnvHandle, Status);
    } else {
      PrintToken (STRING_TOKEN (STR_SHELLENV_DPROT_COL_ROW), HiiEnvHandle, Col, Row);
    }
  }
}
Пример #4
0
EFI_STATUS
StslWriteKeyFile (
  IN STANDARD_TEST_PRIVATE_DATA   *Private,
  IN CHAR16                       *String
  )
{
  EFI_STATUS                        Status;
  EFI_TEST_OUTPUT_LIBRARY_PROTOCOL  *Output;
  EFI_FILE_HANDLE                   FileHandle;
  EFI_SIMPLE_TEXT_OUT_PROTOCOL      *ConOut;

  Output = Private->OutputProtocol;
  ConOut = gST->ConOut;

  Status = EFI_SUCCESS;

  //
  // System key file
  //
  if (Private->SystemKeyFile.EnableScreenOutput) {
    Status = ConOut->OutputString (ConOut, String);
    if ( EFI_ERROR (Status) ) {
      return Status;
    }
  }

  FileHandle = Private->SystemKeyFile.FileHandle;
  if (FileHandle != NULL) {
    Status = Output->Write (Output, FileHandle, String);
    if ( EFI_ERROR (Status) ) {
      return Status;
    }
  }

  //
  // Case key file
  //
  if (Private->CaseKeyFile.EnableScreenOutput) {
    Status = ConOut->OutputString (ConOut, String);
    if ( EFI_ERROR (Status) ) {
      return Status;
    }
  }

  FileHandle = Private->CaseKeyFile.FileHandle;
  if (FileHandle != NULL) {
    Status = Output->Write (Output, FileHandle, String);
  }

  return Status;
}
Пример #5
0
VOID
GetConsoleOutMode (
    IN  BMM_CALLBACK_DATA    *CallbackData
)
/*++

Routine Description:
  Get mode number according to column and row

Arguments:
  CallbackData  -  BMM_CALLBACK_DATA

Returns:
  None.

--*/
{
    UINTN                         Col;
    UINTN                         Row;
    UINTN                         CurrentCol;
    UINTN                         CurrentRow;
    UINTN                         Mode;
    UINTN                         MaxMode;
    EFI_STATUS                    Status;
    CONSOLE_OUT_MODE              *ModeInfo;
    EFI_SIMPLE_TEXT_OUT_PROTOCOL  *ConOut;

    ConOut   = gST->ConOut;
    MaxMode  = (UINTN) (ConOut->Mode->MaxMode);
    ModeInfo = EfiLibGetVariable (VarConOutMode, &gEfiGenericVariableGuid);

    if (ModeInfo != NULL) {
        CurrentCol = ModeInfo->Column;
        CurrentRow = ModeInfo->Row;
        for (Mode = 0; Mode < MaxMode; Mode++) {
            Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);
            if (!EFI_ERROR(Status)) {
                if (CurrentCol == Col && CurrentRow == Row) {
                    CallbackData->BmmFakeNvData.ConsoleOutMode = (UINT16) Mode;
                    break;
                }
            }
        }
    }
    SafeFreePool (ModeInfo);
}
Пример #6
0
void
init_password_box (EFI_SYSTEM_TABLE *systab, struct password_box *pwd_box)
{
	EFI_SIMPLE_TEXT_OUT_PROTOCOL *conout = systab->ConOut;
	EFI_SIMPLE_TEXT_IN_PROTOCOL  *conin  = systab->ConIn;

	UINTN max_mode = systab->ConOut->Mode->MaxMode;

	EFI_STATUS error;
	UINTN cols = 0, rows = 0;

	UINTN max_cols = 0;
	UINTN max_rows = 0;
	UINTN best_mode = 0;

	int i;
	for (i = 0; i < max_mode; i++) {
		error = conout->QueryMode(systab->ConOut, i, &cols, &rows);

		if (!error	&&
		    cols != 0	&&
		    cols <= 512	&&
		    rows != 0	&&
		    rows <= 512) {
			if (max_cols < cols) {
				max_cols = cols;
				max_rows = rows;
				best_mode = i;
			} else if (max_cols == cols &&
				   max_rows < rows) {
				max_rows = rows;
				best_mode = i;
			}
		}
	}

	conout->SetMode (conout, best_mode);

	conout->SetAttribute (conout, BACKGROUND);

	conout->ClearScreen(conout);

	conout->EnableCursor(conout, 0);

	UINTN col_offset = (max_cols - PASS_BOX_COLS) / 2;
	UINTN row_offset = (max_rows - PASS_BOX_ROWS) / 2;

	pwd_box->cols = PASS_BOX_COLS;
	pwd_box->rows =	PASS_BOX_ROWS;
	pwd_box->col_offset = col_offset;
	pwd_box->row_offset = row_offset;
}
Пример #7
0
static void
draw_password_box (EFI_SYSTEM_TABLE *systab, struct password_box *pwd_box,
		   CHAR16 *hint_txt)
{
	EFI_SIMPLE_TEXT_OUT_PROTOCOL *conout = systab->ConOut;

	int i;
	for (i = 0; i < pwd_box->cols; i++) {
		line[i] = ' ';
	}

	for (i = 0; i < PASS_FIELD_COLS; i++) {
		input_line[i] = ' ';
	}

	/* Draw box */
	conout->SetCursorPosition (conout,
				   pwd_box->col_offset,
				   pwd_box->row_offset);

	conout->SetAttribute (conout, BOX_BACKGROUND);

	UINTN row;
	for (row = 0; row < pwd_box->rows; row++) {
		conout->OutputString (conout, line);

		UINTN new_row = pwd_box->row_offset + row;
		conout->SetCursorPosition (conout,
					   pwd_box->col_offset,
					   new_row);
	}

	/* Print box title */
	conout->SetAttribute (conout, BOX_TEXT);

	conout->SetCursorPosition (conout,
				   pwd_box->col_offset,
				   pwd_box->row_offset + 1);

	conout->OutputString (conout, TXT_HEAD);

	/* Print hint */
	conout->SetCursorPosition (conout,
				   pwd_box->col_offset,
				   pwd_box->row_offset + 5);

	conout->OutputString (conout, hint_txt);

	/* Print input field */
	conout->SetAttribute (conout, BOX_INPUT);

	conout->SetCursorPosition (conout,
				   pwd_box->col_offset + 2,
				   pwd_box->row_offset + 3);

	conout->OutputString (conout, input_line);

	/* Move cursor to the first input position */
	conout->SetAttribute (conout, BOX_INPUT_TEXT);

	conout->SetCursorPosition (conout,
				   pwd_box->col_offset + 2,
				   pwd_box->row_offset + 3);

	conout->EnableCursor(conout, 1);
}
Пример #8
0
void
get_password (EFI_SYSTEM_TABLE *systab, struct password_box *pwd_box,
	      uint8_t *pass_buf, UINTN buf_nbytes, UINTN *n_chars)
{
	*n_chars = 0;

	EFI_SIMPLE_TEXT_OUT_PROTOCOL *conout = systab->ConOut;
	EFI_SIMPLE_TEXT_IN_PROTOCOL  *conin  = systab->ConIn;

	EFI_INPUT_KEY input_key;
	UINTN event_idx;

	UINTN count = 0;
	EFI_STATUS error;

get_input:
	conout->EnableCursor(conout, count < PASS_FIELD_COLS);

	systab->BootServices->WaitForEvent (1, &conin->WaitForKey, &event_idx);

	error = conin->ReadKeyStroke (conin, &input_key);
	randseed_event (systab);

	if (error) {
		goto get_input;
	}

	switch (input_key.UnicodeChar) {
	case 0x0000:
	case 0x0009:
		goto get_input;
	case 0x0008: /* BS */
		pass_buf[count] = 0x00;
		if (count > 0) {
			count--;
			if (count < PASS_FIELD_COLS) {
				conout->SetAttribute (conout, BOX_INPUT);
				conout->OutputString (conout, CHAR_REMOVE);
				conout->SetAttribute (conout, BOX_INPUT_TEXT);
				/* Make sure that the cursor appears */
				conout->OutputString (conout, L"");
			}
		}

		goto get_input;
	default:
		if (count < (PASS_N_CHARS - 1)) {
			pass_buf[count] = input_key.UnicodeChar;
			if (count < PASS_FIELD_COLS) {
				conout->OutputString (conout, L"*");
			}
			count++;
		}

		if (count + 1 != buf_nbytes) {
			goto get_input;
		}
		/* Fallthrough */
	case 0x000A:
	case 0x000D:
		pass_buf[count + 1] = '\0';
		*n_chars = count;
		break;
	}
}
//
// TDS 4.2.3
//
EFI_STATUS
BBTestQueryModeConformanceAutoTest (
  IN EFI_BB_TEST_PROTOCOL       *This,
  IN VOID                       *ClientInterface,
  IN EFI_TEST_LEVEL             TestLevel,
  IN EFI_HANDLE                 SupportHandle
  )
{
  EFI_STANDARD_TEST_LIBRARY_PROTOCOL   *StandardLib;
  EFI_STATUS                           Status;
  EFI_SIMPLE_TEXT_OUT_PROTOCOL         *SimpleOut;
  EFI_TEST_ASSERTION                   AssertionType;

  EFI_SIMPLE_TEXT_OUTPUT_MODE          ModeExpected;
  UINTN                                ModeNumber[5];
  UINTN                                Column, Row;
  UINTN                                Index;

  EFI_GRAPHICS_OUTPUT_PROTOCOL                *GraphicsOutput;
  EFI_DEVICE_PATH_PROTOCOL             *DevicePath;
  CHAR16                               *DevicePathStr;
  //
  // Get the Standard Library Interface
  //
  Status = gtBS->HandleProtocol (
                   SupportHandle,
                   &gEfiStandardTestLibraryGuid,
                   &StandardLib
                   );

  if (EFI_ERROR(Status)) {
    StandardLib->RecordAssertion (
                   StandardLib,
                   EFI_TEST_ASSERTION_FAILED,
                   gTestGenericFailureGuid,
                   L"BS.HandleProtocol - Handle standard test library",
                   L"%a:%d:Status - %r",
                   __FILE__,
                   (UINTN)__LINE__,
                   Status
                   );
    return Status;
  }
   
  SimpleOut = (EFI_SIMPLE_TEXT_OUT_PROTOCOL *)ClientInterface;

  //
  // Get Device Path of current Simple_Text_Output_Protocol
  // And out put device path or device name
  //
  Status = LocateDevicePathFromSimpleTextOut (SimpleOut, &DevicePath, StandardLib);
  if (Status == EFI_SUCCESS) {
    DevicePathStr = DevicePathToStr (DevicePath);
    if (DevicePathStr != NULL) {
      StandardLib->RecordMessage (
                     StandardLib,
                     EFI_VERBOSE_LEVEL_DEFAULT,
                     L"\r\nCurrent Device: %s",
                     DevicePathStr
                     );
      Status = gtBS->FreePool (DevicePathStr);
      if (EFI_ERROR(Status)) {
        StandardLib->RecordAssertion (
                       StandardLib,
                       EFI_TEST_ASSERTION_FAILED,
                       gTestGenericFailureGuid,
                       L"BS.FreePool - Free pool",
                       L"%a:%d:Status - %r",
                       __FILE__,
                       (UINTN)__LINE__,
                       Status
                       );
        return Status;
      }
      DevicePathStr = NULL;
    }
  } else {
    Status = LocateGopFromSimpleTextOut (SimpleOut, &GraphicsOutput, StandardLib);
    if (EFI_ERROR(Status)) {
      //
      // Console Splitter/StdErr
      //
      StandardLib->RecordMessage (
                     StandardLib,
                     EFI_VERBOSE_LEVEL_DEFAULT,
                     L"\r\nCurrent Device: ConsoleSplitter/StdErr"
                     );
    } else {
      //
      // Console Splitter/ConOut
      //
      StandardLib->RecordMessage (
                     StandardLib,
                     EFI_VERBOSE_LEVEL_DEFAULT,
                     L"\r\nCurrent Device: ConsoleSplitter/ConOut"
                     );
    }
  }

  //
  // Prepare test data
  //
  ModeNumber[0] = SimpleOut->Mode->MaxMode;
  ModeNumber[1] = SimpleOut->Mode->MaxMode + 1;
  ModeNumber[2] = SimpleOut->Mode->MaxMode + 2;
  ModeNumber[3] = SimpleOut->Mode->MaxMode + 100;

  Column = 0;
  Row = 0;
  for (Index = 0; Index <= 3; Index++) {
    //
    // Clear Screen
    //
    SimpleOut->ClearScreen (SimpleOut);

    //
    // Prepare expected Mode after call Reset.
    //
    BackupMode (SimpleOut, &ModeExpected);

    //
    // Call QueryMode with invalid ModeNumber
    //
    Status = SimpleOut->QueryMode (SimpleOut, ModeNumber[Index], &Column, &Row);
    //
    // Mode itegrity test
    //
    if (CheckModeIntegrity (&ModeExpected, SimpleOut->Mode) == FALSE) {
      AssertionType = EFI_TEST_ASSERTION_FAILED;
    } else {
      AssertionType = EFI_TEST_ASSERTION_PASSED;
    }
    StandardLib->RecordAssertion (
                   StandardLib,
                   AssertionType,
                   gSimpleTextOutputConformanceTestAssertionGuid001,
                   L"EFI_SIMPLE_TEXT_OUT_PROTOCOL.QueryMode - QueryMode() with invalid ModeNumber, mode position integrity",
                   L"%a:%d: ModeNumber=%d Current: Cursor Position(%d x %d), Mode=%d, MaxMode=%d, Attribute=%d, CursorVisible=%d. "\
                   L" Expected:Cursor Position(%d x %d), Mode=%d, MaxMode=%d, Attribute=%d, CursorVisible=%d.",
                   __FILE__,
                   (UINTN)__LINE__,
                   ModeNumber[Index],
                   SimpleOut->Mode->CursorColumn,
                   SimpleOut->Mode->CursorRow,
                   SimpleOut->Mode->Mode,
                   SimpleOut->Mode->Attribute,
                   SimpleOut->Mode->MaxMode,
                   SimpleOut->Mode->CursorVisible,
                   ModeExpected.CursorColumn,
                   ModeExpected.CursorRow,
                   ModeExpected.Mode,
                   ModeExpected.MaxMode,
                   ModeExpected.Attribute,
                   ModeExpected.CursorVisible
                   );
    //
    // Status check
    //
    if (Status!=EFI_UNSUPPORTED) {
      AssertionType = EFI_TEST_ASSERTION_FAILED;
    } else {
      AssertionType = EFI_TEST_ASSERTION_PASSED;
    }
    StandardLib->RecordAssertion (
                   StandardLib,
                   AssertionType,
                   gSimpleTextOutputConformanceTestAssertionGuid002,
                   L"EFI_SIMPLE_TEXT_OUT_PROTOCOL.QueryMode - QueryMode() with invalid ModeNumber",
                   L"%a:%d: Status = %r, ModeNumber = %d, MaxModeNumber=%d, Column=%d, Row=%d",
                   __FILE__,
                   (UINTN)__LINE__,
                   Status,
                   ModeNumber[Index],
                   SimpleOut->Mode->MaxMode,
                   Column,
                   Row
                   );
  }

  return EFI_SUCCESS;
}
//
// TDS 4.2.6
//
EFI_STATUS
BBTestSetCursorPositionConformanceAutoTest (
    IN EFI_BB_TEST_PROTOCOL       *This,
    IN VOID                       *ClientInterface,
    IN EFI_TEST_LEVEL             TestLevel,
    IN EFI_HANDLE                 SupportHandle
  )
{
  EFI_STANDARD_TEST_LIBRARY_PROTOCOL   *StandardLib;
  EFI_STATUS                           Status;
  EFI_SIMPLE_TEXT_OUT_PROTOCOL         *SimpleOut;
  EFI_TEST_ASSERTION                   AssertionType;

  EFI_SIMPLE_TEXT_OUTPUT_MODE          ModeOrg, ModeExpected;
  INT32                                Mode;
  UINTN                                ColumnTest[10], RowTest[10];
  UINTN                                Column, Row;

  UINTN                                Index;

  EFI_GRAPHICS_OUTPUT_PROTOCOL                *GraphicsOutput;
  EFI_DEVICE_PATH_PROTOCOL             *DevicePath;
  CHAR16                               *DevicePathStr;

  //
  // Get the Standard Library Interface
  //
  Status = gtBS->HandleProtocol (
                   SupportHandle,
                   &gEfiStandardTestLibraryGuid,
                   &StandardLib
                   );

  if (EFI_ERROR(Status)) {
    StandardLib->RecordAssertion (
                   StandardLib,
                   EFI_TEST_ASSERTION_FAILED,
                   gTestGenericFailureGuid,
                   L"BS.HandleProtocol - Handle standard test library",
                   L"%a:%d:Status - %r",
                   __FILE__,
                   (UINTN)__LINE__,
                   Status
                   );
    return Status;
  }

  SimpleOut = (EFI_SIMPLE_TEXT_OUT_PROTOCOL *)ClientInterface;

  //
  // Get Device Path of current Simple_Text_Output_Protocol
  // And out put device path or device name
  //
  Status = LocateDevicePathFromSimpleTextOut (SimpleOut, &DevicePath, StandardLib);
  if (Status == EFI_SUCCESS) {
    DevicePathStr = DevicePathToStr (DevicePath);
    if (DevicePathStr != NULL) {
      StandardLib->RecordMessage (
                     StandardLib,
                     EFI_VERBOSE_LEVEL_DEFAULT,
                     L"\r\nCurrent Device: %s",
                     DevicePathStr
                     );
      Status = gtBS->FreePool (DevicePathStr);
      if (EFI_ERROR(Status)) {
        StandardLib->RecordAssertion (
                       StandardLib,
                       EFI_TEST_ASSERTION_FAILED,
                       gTestGenericFailureGuid,
                       L"BS.FreePool - Free pool",
                       L"%a:%d:Status - %r",
                       __FILE__,
                       (UINTN)__LINE__,
                       Status
                       );
        return Status;
      }
      DevicePathStr = NULL;
    }
  } else {
    Status = LocateGopFromSimpleTextOut (SimpleOut, &GraphicsOutput, StandardLib);
    if (EFI_ERROR(Status)) {
      //
      // Console Splitter/StdErr
      //
      StandardLib->RecordMessage (
                     StandardLib,
                     EFI_VERBOSE_LEVEL_DEFAULT,
                     L"\r\nCurrent Device: ConsoleSplitter/StdErr"
                     );
    } else {
      //
      // Console Splitter/ConOut
      //
      StandardLib->RecordMessage (
                     StandardLib,
                     EFI_VERBOSE_LEVEL_DEFAULT,
                     L"\r\nCurrent Device: ConsoleSplitter/ConOut"
                     );
    }
  }

  //
  // Backup Mode
  //
  BackupMode (SimpleOut, &ModeOrg);

  //
  // For each mode supported!
  //
  for (Mode = 0; Mode < SimpleOut->Mode->MaxMode; Mode++) {
    //
    // Change mode
    //
    Status = SimpleOut->SetMode (SimpleOut, Mode);
    if (EFI_ERROR(Status)) {
      AssertionType = EFI_TEST_ASSERTION_FAILED;
      StandardLib->RecordAssertion (
                     StandardLib,
                     AssertionType,
                     gTestGenericFailureGuid,
                     L"EFI_SIMPLE_TEXT_OUT_PROTOCOL.SetMode - SetMode() with valid mode",
                     L"%a:%d: Status = %r, Mode = %d",
                     __FILE__,
                     (UINTN)__LINE__,
                     Status,
                     Mode
                     );
      continue;
    }

    //
    // Get Mode's screen boundary
    //
    Status = SimpleOut->QueryMode (SimpleOut, Mode, &Column, &Row);
    if (EFI_ERROR(Status)) {
      AssertionType = EFI_TEST_ASSERTION_FAILED;
      StandardLib->RecordAssertion (
                     StandardLib,
                     AssertionType,
                     gTestGenericFailureGuid,
                     L"EFI_SIMPLE_TEXT_OUT_PROTOCOL.QueryMode - QueryMode() with valid mode",
                     L"%a:%d: Status = %r, Mode = %d",
                     __FILE__,
                     (UINTN)__LINE__,
                     Status,
                     Mode
                     );
      continue;
    }

    //
    // Prepare test data
    //
    ColumnTest[0] = Column;
    RowTest[0]    = Row - 1;
    ColumnTest[1] = Column;
    RowTest[1]    = 0;
    ColumnTest[2] = Column + 1;
    RowTest[2]    = Row - 1;
    ColumnTest[3] = Column + 1;
    RowTest[3]    = 0;
    ColumnTest[4] = 0;
    RowTest[4]    = Row;
    ColumnTest[5] = Column - 1;
    RowTest[5]    = Row;
    ColumnTest[6] = Column - 1;
    RowTest[6]    = Row + 1;
    ColumnTest[7] = 0;
    RowTest[7]    = Row + 1;

    for (Index = 0; Index < 8; Index++) {
      //
      // Prepare expected Mode after call Reset.
      //
      BackupMode (SimpleOut, &ModeExpected);

      //
      // Call SetAttribute with invalid Attribute
      //
      Status = SimpleOut->SetCursorPosition (SimpleOut, ColumnTest[Index], RowTest[Index]);

      //
      // Mode itegrity test
      //
      if (CheckModeIntegrity (&ModeExpected, SimpleOut->Mode) == FALSE) {
        AssertionType = EFI_TEST_ASSERTION_FAILED;
      } else {
        AssertionType = EFI_TEST_ASSERTION_PASSED;
      }
      StandardLib->RecordAssertion (
                     StandardLib,
                     AssertionType,
                     gSimpleTextOutputConformanceTestAssertionGuid009,
                     L"EFI_SIMPLE_TEXT_OUT_PROTOCOL.SetCursorPosition - SetCursorPosition() with invalid position, mode position integrity",
                     L"%a:%d: Mode=%d, Positoin=(%d x %d) Current: Cursor Position(%d x %d), Mode=%d, MaxMode=%d, Attribute=%d, CursorVisible=%d. "\
                     L" Expected:Cursor Position(%d x %d), Mode=%d, MaxMode=%d, Attribute=%d, CursorVisible=%d.",
                     __FILE__,
                     (UINTN)__LINE__,
                     Mode,
                     ColumnTest[Index],
                     RowTest[Index],
                     SimpleOut->Mode->CursorColumn,
                     SimpleOut->Mode->CursorRow,
                     SimpleOut->Mode->Mode,
                     SimpleOut->Mode->MaxMode,
                     SimpleOut->Mode->Attribute,
                     SimpleOut->Mode->CursorVisible,
                     ModeExpected.CursorColumn,
                     ModeExpected.CursorRow,
                     ModeExpected.Mode,
                     ModeExpected.MaxMode,
                     ModeExpected.Attribute,
                     ModeExpected.CursorVisible
                     );

      //
      // Status check
      //
      if (Status!=EFI_UNSUPPORTED) {
        AssertionType = EFI_TEST_ASSERTION_FAILED;
      } else {
        AssertionType = EFI_TEST_ASSERTION_PASSED;
      }
      StandardLib->RecordAssertion (
                     StandardLib,
                     AssertionType,
                     gSimpleTextOutputConformanceTestAssertionGuid010,
                     L"EFI_SIMPLE_TEXT_OUT_PROTOCOL.SetCursorPosition - SetCursorPositoin() with invalid Position",
                     L"%a:%d: Status = %r, Mode = %d, Position = (%d x %d)",
                     __FILE__,
                     (UINTN)__LINE__,
                     Status,
                     Mode,
                     ColumnTest[Index],
                     RowTest[Index]
                     );
    }
  }
  return RestoreMode (SimpleOut, &ModeOrg, StandardLib);
}
//
// TDS 4.2.5
//
EFI_STATUS
BBTestSetAttributeConformanceAutoTest (
    IN EFI_BB_TEST_PROTOCOL       *This,
    IN VOID                       *ClientInterface,
    IN EFI_TEST_LEVEL             TestLevel,
    IN EFI_HANDLE                 SupportHandle
  )
{
  //
  // This test case should be obsolete according to Spec changed.
  //

  EFI_STANDARD_TEST_LIBRARY_PROTOCOL   *StandardLib;
  EFI_STATUS                           Status;
  EFI_SIMPLE_TEXT_OUT_PROTOCOL         *SimpleOut;
  EFI_TEST_ASSERTION                   AssertionType;

  EFI_SIMPLE_TEXT_OUTPUT_MODE          ModeOrg, ModeExpected;
  UINTN                                Attribute[10];

  UINTN                                Index;

  EFI_GRAPHICS_OUTPUT_PROTOCOL                *GraphicsOutput;
  EFI_DEVICE_PATH_PROTOCOL             *DevicePath;
  CHAR16                               *DevicePathStr;



  //
  // Get the Standard Library Interface
  //
  Status = gtBS->HandleProtocol (
                   SupportHandle,
                   &gEfiStandardTestLibraryGuid,
                   &StandardLib
                   );

  if (EFI_ERROR(Status)) {
    StandardLib->RecordAssertion (
                   StandardLib,
                   EFI_TEST_ASSERTION_FAILED,
                   gTestGenericFailureGuid,
                   L"BS.HandleProtocol - Handle standard test library",
                   L"%a:%d:Status - %r",
                   __FILE__,
                   (UINTN)__LINE__,
                   Status
                   );
    return Status;
  }

  SimpleOut = (EFI_SIMPLE_TEXT_OUT_PROTOCOL *)ClientInterface;

  //
  // Get Device Path of current Simple_Text_Output_Protocol
  // And out put device path or device name
  //
  Status = LocateDevicePathFromSimpleTextOut (SimpleOut, &DevicePath, StandardLib);
  if (Status == EFI_SUCCESS) {
    DevicePathStr = DevicePathToStr (DevicePath);
    if (DevicePathStr != NULL) {
      StandardLib->RecordMessage (
                     StandardLib,
                     EFI_VERBOSE_LEVEL_DEFAULT,
                     L"\r\nCurrent Device: %s",
                     DevicePathStr
                     );
      Status = gtBS->FreePool (DevicePathStr);
      if (EFI_ERROR(Status)) {
        StandardLib->RecordAssertion (
                       StandardLib,
                       EFI_TEST_ASSERTION_FAILED,
                       gTestGenericFailureGuid,
                       L"BS.FreePool - Free pool",
                       L"%a:%d:Status - %r",
                       __FILE__,
                       (UINTN)__LINE__,
                       Status
                       );
        return Status;
      }
      DevicePathStr = NULL;
    }
  } else {
    Status = LocateGopFromSimpleTextOut (SimpleOut, &GraphicsOutput, StandardLib);
    if (EFI_ERROR(Status)) {
      //
      // Console Splitter/StdErr
      //
      StandardLib->RecordMessage (
                     StandardLib,
                     EFI_VERBOSE_LEVEL_DEFAULT,
                     L"\r\nCurrent Device: ConsoleSplitter/StdErr"
                     );
    } else {
      //
      // Console Splitter/ConOut
      //
      StandardLib->RecordMessage (
                     StandardLib,
                     EFI_VERBOSE_LEVEL_DEFAULT,
                     L"\r\nCurrent Device: ConsoleSplitter/ConOut"
                     );
    }
  }

  //
  // Prepare test data
  //

  Attribute[0] = 0xB3;
  Attribute[1] = 0x80;
  Attribute[2] = 0x91;
  Attribute[3] = 0xA2;
  Attribute[4] = 65538;

  //
  // Backup Mode
  //
  BackupMode (SimpleOut, &ModeOrg);

  for (Index = 0; Index < 5; Index++) {
    //
    // Prepare expected Mode after call Reset.
    //
    BackupMode (SimpleOut, &ModeExpected);

    //
    // Call SetAttribute with invalid Attribute
    //
    Status = SimpleOut->SetAttribute (SimpleOut, Attribute[Index]);

    //
    // Mode itegrity test
    //
    ModeExpected.CursorColumn = SimpleOut->Mode->CursorColumn;
    ModeExpected.CursorRow = SimpleOut->Mode->CursorRow;
    if (CheckModeIntegrity (&ModeExpected, SimpleOut->Mode) == FALSE) {
      AssertionType = EFI_TEST_ASSERTION_FAILED;
    } else {
      AssertionType = EFI_TEST_ASSERTION_PASSED;
    }
    StandardLib->RecordAssertion (
                   StandardLib,
                   AssertionType,
                   gSimpleTextOutputConformanceTestAssertionGuid005,
                   L"EFI_SIMPLE_TEXT_OUT_PROTOCOL.SetAttribute - SetAttribute() with invalid Attribute, mode position integrity",
                   L"%a:%d: Attribute=%x Current: Cursor Position(%d x %d), Mode=%d, MaxMode=%d, Attribute=%d, CursorVisible=%d. "\
                   L" Expected:Cursor Position(%d x %d), Mode=%d, MaxMode=%d, Attribute=%d, CursorVisible=%d.",
                   __FILE__,
                   (UINTN)__LINE__,
                   Attribute[Index],
                   SimpleOut->Mode->CursorColumn,
                   SimpleOut->Mode->CursorRow,
                   SimpleOut->Mode->Mode,
                   SimpleOut->Mode->MaxMode,
                   SimpleOut->Mode->Attribute,
                   SimpleOut->Mode->CursorVisible,
                   ModeExpected.CursorColumn,
                   ModeExpected.CursorRow,
                   ModeExpected.Mode,
                   ModeExpected.MaxMode,
                   ModeExpected.Attribute,
                   ModeExpected.CursorVisible
                   );

    //
    // Status check
    //
    if (Status!=EFI_UNSUPPORTED) {
      AssertionType = EFI_TEST_ASSERTION_FAILED;
    } else {
      AssertionType = EFI_TEST_ASSERTION_PASSED;
    }
    StandardLib->RecordAssertion (
                   StandardLib,
                   AssertionType,
                   gSimpleTextOutputConformanceTestAssertionGuid006,
                   L"EFI_SIMPLE_TEXT_OUT_PROTOCOL.SetAttribute - SetAttribute() with invalid Attribute",
                   L"%a:%d: Status = %r, Attribute = %x",
                   __FILE__,
                   (UINTN)__LINE__,
                   Status,
                   Attribute[Index]
                   );
  }

  return RestoreMode (SimpleOut, &ModeOrg, StandardLib);
}
Пример #12
0
VOID
UpdateConModePage (
  IN BMM_CALLBACK_DATA                *CallbackData
  )
/*++

Routine Description:
  Refresh the text mode page

Arguments:
  CallbackData      - BMM_CALLBACK_DATA

Returns:
  None.

--*/
{
  UINTN                         Mode;
  UINTN                         Index;
  UINTN                         Col;
  UINTN                         Row;
  CHAR16                        RowString[50];
  CHAR16                        ModeString[50];
  UINTN                         MaxMode;
  UINTN                         ValidMode;
  EFI_STRING_ID                 *ModeToken;
  IFR_OPTION                    *IfrOptionList;
  EFI_STATUS                    Status;
  EFI_SIMPLE_TEXT_OUT_PROTOCOL  *ConOut;

  ConOut    = gST->ConOut;
  Index     = 0;
  ValidMode = 0;
  MaxMode   = (UINTN) (ConOut->Mode->MaxMode);

  CallbackData->BmmAskSaveOrNot = TRUE;

  UpdatePageStart (CallbackData);

  //
  // Check valid mode
  //
  for (Mode = 0; Mode < MaxMode; Mode++) {
    Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);
    if (EFI_ERROR (Status)) {
      continue;
    }
    ValidMode++;
  }

  if (ValidMode == 0) {
    return;
  }

  IfrOptionList       = EfiAllocateZeroPool (sizeof (IFR_OPTION) * ValidMode);
  ASSERT(IfrOptionList != NULL);

  ModeToken           = EfiAllocateZeroPool (sizeof (EFI_STRING_ID) * ValidMode);
  ASSERT(ModeToken != NULL);

  //
  // Determin which mode should be the first entry in menu
  //
  GetConsoleOutMode (CallbackData);

  //
  // Build text mode options
  //
  for (Mode = 0; Mode < MaxMode; Mode++) {
    Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);
    if (EFI_ERROR (Status)) {
      continue;
    }
    //
    // Build mode string Column x Row
    //
    EfiValueToString (ModeString, Col, 0, 0);
    EfiStrCat (ModeString, L" x ");
    EfiValueToString (RowString, Row, 0, 0);
    EfiStrCat (ModeString, RowString);

    IfrLibNewString (CallbackData->BmmHiiHandle, &ModeToken[Index], ModeString);

    IfrOptionList[Index].StringToken  = ModeToken[Index];
    IfrOptionList[Index].Value.u16    = (UINT16) Mode;
    if (Mode == CallbackData->BmmFakeNvData.ConsoleOutMode) {
      IfrOptionList[Index].Flags      = EFI_IFR_OPTION_DEFAULT;
    } else {
      IfrOptionList[Index].Flags      = 0;
    }
    Index++;
  }

  CreateOneOfOpCode (
    CON_MODE_QUESTION_ID,
    VARSTORE_ID_BOOT_MAINT,
    CON_MODE_VAR_OFFSET,
    STRING_TOKEN (STR_CON_MODE_SETUP),
    STRING_TOKEN (STR_CON_MODE_SETUP),
    EFI_IFR_FLAG_RESET_REQUIRED,
    EFI_IFR_NUMERIC_SIZE_2,
    IfrOptionList,
    ValidMode,
    &gUpdateData
    );
  SafeFreePool (IfrOptionList);
  SafeFreePool (ModeToken);

  UpdatePageEnd (CallbackData);
}