示例#1
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.3.1
//
EFI_STATUS
BBTestReadKeyStrokeManualTest (
  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_IN_PROTOCOL          *SimpleIn;

  EFI_TEST_ASSERTION                   AssertionType;
  EFI_INPUT_KEY                        Key;
  CHAR16                               KeyBuffer[MAX_KEY_BUFFER_SIZE];

  EFI_DEVICE_PATH_PROTOCOL             *DevicePath;
  CHAR16                               *DevicePathStr;
  UINTN                                Index;

  //
  // 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__,
                   __LINE__,
                   Status
                   );
    return Status;
  }

  SimpleIn = (EFI_SIMPLE_TEXT_IN_PROTOCOL *)ClientInterface;

  //
  // Get Device Path of current Simple_Text_In_Protocol
  // And out put device path or device name
  //
  Status = LocateDevicePathFromSimpleTextIn (SimpleIn, &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__,
                       __LINE__,
                       Status
                       );
        return Status;
      }
      DevicePathStr=NULL;
    }
  } else {
    //
    // Console Splitter/StdErr
    //
    StandardLib->RecordMessage (
                   StandardLib,
                   EFI_VERBOSE_LEVEL_DEFAULT,
                   L"\r\nCurrent Device: ConsoleSplitter/TxtIn"
                   );
  }

  //
  // wait for times
  //
  Print (L"\r\nReadKeyStroke Stress Test Start!\r\n");
  WaitTimeOrKey (5);

  //
  // Assertion Point 4.1.3.2.1
  // ReadKeyStroke()
  //
    Status = SimpleIn->Reset (SimpleIn,TRUE);
  if (EFI_ERROR(Status)) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
    StandardLib->RecordAssertion (
                   StandardLib,
                   AssertionType,
                   gTestGenericFailureGuid,
                   L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset with ExtendedVeirification as TRUE",
                   L"%a:%d, Status = %r",
                   __FILE__,
                   __LINE__,
                   Status
                   );
  }
  Print (L"\r\nPlease input some displayabed characters in 5 seconds\r\n");

  gtBS->Stall (5000000);

  //
  // Assume user has input some key, go on verification
  // Read all key
  //
  Index=0;
  do {
    Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
    if (Status == EFI_SUCCESS) {
      KeyBuffer[Index++] = Key.UnicodeChar;
    }

  } while (Status == EFI_SUCCESS && Index < MAX_KEY_BUFFER_SIZE);

  //
  // Echo the input keys
  //
  if (Status != EFI_NOT_READY) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
    StandardLib->RecordAssertion (
                   StandardLib,
                   AssertionType,
                   gSimpleTextInExtensiveTestAssertionGuid001,
                   L"EFI_SIMPLE_TEXT_IN_PROTOCOL.ReadKeyStroke - ReadKeyStroke() when no key input",
                   L"%a:%d, Status = %r, Expected = %r",
                   __FILE__,
                   __LINE__,
                   Status,
                   EFI_NOT_READY
                   );
  }

  KeyBuffer[Index] = 0;

  Print (L"The keys input are:%s", KeyBuffer);

  //
  // Prompt for user judge
  //
  if (AutoJudge (5,TRUE,L"\r\nEcho correct?\r\n") == TRUE) {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  }
  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInExtensiveTestAssertionGuid002,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.ReadKeyStroke - ReadKeyStroke() with key input, user's view",
                 L"%a:%d",
                 __FILE__,
                 __LINE__
                 );

  return EFI_SUCCESS;
}
//
// TDS 4.1.4
//
EFI_STATUS
BBTestWaitForKeyFunctionManualTest (
  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_IN_PROTOCOL          *SimpleIn;


  EFI_TEST_ASSERTION                   AssertionType;
  EFI_INPUT_KEY                        Key;


  EFI_DEVICE_PATH_PROTOCOL             *DevicePath;
  CHAR16                               *DevicePathStr;

 // BOOLEAN                              KeyPressed=FALSE, EscPressed=FALSE;
    UINTN                                WaitIndex;


  //
  // Verify whether it is one of IHV interfaces
  //
  if (! IsIhvInterface (ClientInterface, SupportHandle)) {
    return EFI_UNSUPPORTED;
  }

  //
  // 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__,
                   __LINE__,
                   Status
                   );
    return Status;
  }

  SimpleIn = (EFI_SIMPLE_TEXT_IN_PROTOCOL *)ClientInterface;

  //
  // Get Device Path of current Simple_Text_In_Protocol
  // And out put device path or device name
  //
  Status = LocateDevicePathFromSimpleTextIn (SimpleIn, &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__,
                       __LINE__,
                       Status
                       );
        return Status;
      }
      DevicePathStr=NULL;
    }
  } else {
    //
    // Console Splitter/StdErr
    //
    StandardLib->RecordMessage (
                   StandardLib,
                   EFI_VERBOSE_LEVEL_DEFAULT,
                   L"\r\nCurrent Device: ConsoleSplitter/TxtIn"
                   );
  }

  //
  // wait for times
  //
  Print (L"\r\nWaitForKey Function Test Start!\r\n");
  WaitTimeOrKey (5);

  Status = SimpleIn->Reset (SimpleIn, TRUE);
  if (EFI_ERROR(Status)) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
    StandardLib->RecordAssertion (
                   StandardLib,
                   AssertionType,
                   gTestGenericFailureGuid,
                   L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset with ExtendedVeirification as TRUE",
                   L"%a:%d, Status = %r",
                   __FILE__,
                   __LINE__,
                   Status
                   );
  }
  //
  // Assertion Point 4.1.4.2.1
  // WaitForKey()
  //
  Print (L"Press ONE displayable key! and NO More!");

  //
  // WaitForKey event
  //
  Status = gtBS->WaitForEvent (1, &(SimpleIn->WaitForKey), &WaitIndex);
  if (EFI_ERROR(Status)) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  }

  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInInterfaceTestAssertionGuid011,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.WaitForKey - Wait for event with key input",
                 L"%a:%d, Status = %r, Expected = %r",
                 __FILE__,
                 __LINE__,
                 Status,
                 EFI_SUCCESS
                 );


  //
  // Call ReadKeyStroke repeatedly to receive the character.
  //
  Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
  if (EFI_ERROR(Status)) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  }

  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInInterfaceTestAssertionGuid014,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.ReadKeyStroke - ReadKeyStroke() with key input",
                 L"%a:%d, Status = %r",
                 __FILE__,
                 __LINE__,
                 Status
                 );

  return EFI_SUCCESS;
}
//
// TDS 4.1.3
//
EFI_STATUS
BBTestReadKeyStrokeFunctionManualTest (
  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_IN_PROTOCOL          *SimpleIn;


  EFI_TEST_ASSERTION                   AssertionType;
  EFI_INPUT_KEY                        Key;


  EFI_DEVICE_PATH_PROTOCOL             *DevicePath;
  CHAR16                               *DevicePathStr;

  BOOLEAN                              KeyPressed=FALSE, EscPressed=FALSE;

  //
  // Verify whether it is one of IHV interfaces
  //
  if (! IsIhvInterface (ClientInterface, SupportHandle)) {
    return EFI_UNSUPPORTED;
  }

  //
  // 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__,
                   __LINE__,
                   Status
                   );
    return Status;
  }

  SimpleIn = (EFI_SIMPLE_TEXT_IN_PROTOCOL *)ClientInterface;

  //
  // Get Device Path of current Simple_Text_In_Protocol
  // And out put device path or device name
  //
  Status = LocateDevicePathFromSimpleTextIn (SimpleIn, &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__,
                       __LINE__,
                       Status
                       );
        return Status;
      }
      DevicePathStr=NULL;
    }
  } else {
    //
    // Console Splitter/StdErr
    //
    StandardLib->RecordMessage (
                   StandardLib,
                   EFI_VERBOSE_LEVEL_DEFAULT,
                   L"\r\nCurrent Device: ConsoleSplitter/TxtIn"
                   );
  }

  //
  // wait for times
  //
  Print (L"\r\nReadKeyStroke Function Test Start!\r\n");
  WaitTimeOrKey (5);

  //
  // Assertion Point 4.1.3.2.1
  // ReadKeyStroke()
  //

  Print (L"\r\nPress any key and wait for echo. Two ESC keys to quit");
  while (TRUE) {
    KeyPressed = WaitTimeOrKeySimpleIn (SimpleIn, 1);
    if (KeyPressed==TRUE) {
      Print (L"\r\nKey Pressed--");
      //
      // Key Pressed!
      //

      //
      // Call ReadKeyStroke to retrieve the key
      //
      Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
      if (EFI_ERROR(Status)) {
        AssertionType = EFI_TEST_ASSERTION_FAILED;
        StandardLib->RecordAssertion (
                       StandardLib,
                       AssertionType,
                       gSimpleTextInInterfaceTestAssertionGuid009,
                       L"EFI_SIMPLE_TEXT_IN_PROTOCOL.ReadKeyStroke - ReadKeyStroke() with key input",
                       L"%a:%d, Status = %r",
                       __FILE__,
                       __LINE__,
                       Status
                       );
      }

      //
      // Output what user input
      //
      if (Key.ScanCode==0) {
        //
        // Unicode character
        //
        APrint ((char*)(&Key.UnicodeChar));
      } else {
        //
        // Scan code character
        //
        Print (ScanCodeDesc (Key.ScanCode));
      }
      if (Key.ScanCode==SCAN_ESC) {
        if (EscPressed==TRUE) {
          break;
        }
        EscPressed = TRUE;
      } else {
        EscPressed=FALSE;
      }
    }

  }


  if (AutoJudge (5, TRUE, L"\r\nEcho correct?\r\n")==TRUE) {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  }
  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInInterfaceTestAssertionGuid010,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.ReadKeyStroke - ReadKeyStroke() with key input, user's view",
                 L"%a:%d",
                 __FILE__,
                 __LINE__
                 );
  return EFI_SUCCESS;
}
//
// TDS 4.1.1
//
EFI_STATUS
BBTestResetFunctionAutoTest (
  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_IN_PROTOCOL          *SimpleIn;


  EFI_TEST_ASSERTION                   AssertionType;

  EFI_DEVICE_PATH_PROTOCOL             *DevicePath;
  CHAR16                               *DevicePathStr;

  UINTN                                Index;
  EFI_INPUT_KEY                        Key;

  //
  // Verify whether it is one of IHV interfaces
  //
  if (! IsIhvInterface (ClientInterface, SupportHandle)) {
    return EFI_UNSUPPORTED;
  }

  //
  // 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__,
                   __LINE__,
                   Status
                   );
    return Status;
  }

  SimpleIn = (EFI_SIMPLE_TEXT_IN_PROTOCOL *)ClientInterface;

  //
  // Get Device Path of current Simple_Text_In_Protocol
  // And out put device path or device name
  //
  Status = LocateDevicePathFromSimpleTextIn (SimpleIn, &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__,
                       __LINE__,
                       Status
                       );
        return Status;
      }
      DevicePathStr=NULL;
    }
  } else {
    //
    // Console Splitter/StdErr
    //
    StandardLib->RecordMessage (
                   StandardLib,
                   EFI_VERBOSE_LEVEL_DEFAULT,
                   L"\r\nCurrent Device: ConsoleSplitter/TxtIn"
                   );
  }


  //
  // Assertion Point 4.1.1.2.1
  // Reset without Extended Verification & Reset with Extended Verification
  //

  for (Index=0;Index<REPEAT_EXECUTE_OF_TEST;Index++) {
    //
    // Call SimpleTextIn.Reset() with ExtendedVerification as FALSE
    //
    Status = SimpleIn->Reset (SimpleIn, FALSE);
    if (EFI_ERROR(Status)) {
      AssertionType = EFI_TEST_ASSERTION_FAILED;
    } else {
      AssertionType = EFI_TEST_ASSERTION_PASSED;
    }
    StandardLib->RecordAssertion (
                   StandardLib,
                   AssertionType,
                   gSimpleTextInInterfaceTestAssertionGuid001,
                   L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE",
                   L"%a:%d: Status = %r",
                   __FILE__,
                   __LINE__,
                   Status
                   );
   //
   //Auto test, after reset(), no key input, ReadKeyStroke() should return EFI_NOT_READY
   //
   Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);

   if (Status != EFI_NOT_READY) {
      AssertionType = EFI_TEST_ASSERTION_FAILED;
   } else {
      AssertionType = EFI_TEST_ASSERTION_PASSED;
   }
   StandardLib->RecordAssertion (
                  StandardLib,
                  AssertionType,
                  gSimpleTextInInterfaceTestAssertionGuid012,
                  L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE, ReadKeyStroke() verification with no key input",
                  L"%a:%d: Status = %r, Expected = %r",
                  __FILE__,
                  __LINE__,
                  Status,
                  EFI_NOT_READY
                  );
    //
    // Call SimpleTextIn.Reset() with ExtendedVerification as TRUE
    //
    Status = SimpleIn->Reset (SimpleIn, TRUE);
    if (EFI_ERROR(Status)) {
      AssertionType = EFI_TEST_ASSERTION_FAILED;
    } else {
      AssertionType = EFI_TEST_ASSERTION_PASSED;
    }
    StandardLib->RecordAssertion (
                   StandardLib,
                   AssertionType,
                   gSimpleTextInInterfaceTestAssertionGuid002,
                   L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE",
                   L"%a:%d: Status = %r",
                   __FILE__,
                   __LINE__,
                   Status
                   );
   //
   //Auto test, after reset(), no key input, ReadKeyStroke() should return EFI_NOT_READY
   //
    Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);

   if (Status!=EFI_NOT_READY) {
      AssertionType = EFI_TEST_ASSERTION_FAILED;
   } else {
      AssertionType = EFI_TEST_ASSERTION_PASSED;
   }
   StandardLib->RecordAssertion (
                  StandardLib,
                  AssertionType,
                  gSimpleTextInInterfaceTestAssertionGuid013,
                  L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE, ReadKeyStroke() verification with no key input",
                  L"%a:%d: Status = %r, Expected = %r",
                  __FILE__,
                  __LINE__,
                  Status,
                  EFI_NOT_READY
                  );
  }

  return EFI_SUCCESS;
}
//
// TDS 4.1.2
//
EFI_STATUS
BBTestResetFunctionManualTest (
  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_IN_PROTOCOL          *SimpleIn;


  EFI_TEST_ASSERTION                   AssertionType;

  EFI_DEVICE_PATH_PROTOCOL             *DevicePath;
  CHAR16                               *DevicePathStr;

  EFI_INPUT_KEY                        Key;


  //
  // Verify whether it is one of IHV interfaces
  //
  if (! IsIhvInterface (ClientInterface, SupportHandle)) {
    return EFI_UNSUPPORTED;
  }

  //
  // 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__,
                   __LINE__,
                   Status
                   );
    return Status;
  }

  SimpleIn = (EFI_SIMPLE_TEXT_IN_PROTOCOL *)ClientInterface;

  //
  // Get Device Path of current Simple_Text_In_Protocol
  // And out put device path or device name
  //
  Status = LocateDevicePathFromSimpleTextIn (SimpleIn, &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__,
                       __LINE__,
                       Status
                       );
        return Status;
      }
      DevicePathStr=NULL;
    }
  } else {
    //
    // Console Splitter/StdErr
    //
    StandardLib->RecordMessage (
                   StandardLib,
                   EFI_VERBOSE_LEVEL_DEFAULT,
                   L"\r\nCurrent Device: ConsoleSplitter/TxtIn"
                   );
  }

  Print (L"\r\nReset Function Test Start!\r\n");
  WaitTimeOrKey (5);

  //
  // Assertion Point 4.1.2.2.1
  // Reset without Extended Verification & Reset with Extended Verification
  //


  //
  // Call SimpleTextIn.Reset() with ExtendedVerification as FALSE
  //
  Status = SimpleIn->Reset (SimpleIn, FALSE);
  if (EFI_ERROR(Status)) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  }
  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInInterfaceTestAssertionGuid003,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE",
                 L"%a:%d, Status = %r",
                 __FILE__,
                 __LINE__,
                 Status
                 );

  //
  // Prompt tester to input some characters
  //
  Print (L"Press some displayble keys in 5 second!");

  //
  // Wait 5 seconds
  //
  gtBS->Stall (5000000);

  //
  // Call SimpleTextIn.Reset with ExtendedVerification as FALSE again
  //
  Status = SimpleIn->Reset (SimpleIn, FALSE);
  if (EFI_ERROR(Status)) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  }
  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInInterfaceTestAssertionGuid004,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE",
                 L"%a:%d, Status = %r",
                 __FILE__,
                 __LINE__,
                 Status
                 );

  //
  // Call SimpleTextIn.ReadKeyStroke() to check key buffer
  //
  Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);

  if (Status!=EFI_NOT_READY) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  }
  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInInterfaceTestAssertionGuid005,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE, ReadKeyStroke() verification",
                 L"%a:%d, Status = %r, Expected=%r",
                 __FILE__,
                 __LINE__,
                 Status,
                 EFI_NOT_READY
                 );

  //
  // Assertion Point 4.1.2.2.2
  //

  //
  // Call SimpleTextIn.Reset() with ExtendedVerification as TRUE
  //
  Status = SimpleIn->Reset (SimpleIn, TRUE);
  if (EFI_ERROR(Status)) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  }
  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInInterfaceTestAssertionGuid006,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE",
                 L"%a:%d, Status = %r",
                 __FILE__,
                 __LINE__,
                 Status
                 );

  //
  // Prompt tester to input some characters
  //
  Print (L"Press some displayble keys in 5 second AGAIN!");

  //
  // Wait 5 seconds
  //
  gtBS->Stall (5000000);

  //
  // Call SimpleTextIn.Reset with ExtendedVerification as TRUE again
  //
  Status = SimpleIn->Reset (SimpleIn, TRUE);
  if (EFI_ERROR(Status)) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  }
  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInInterfaceTestAssertionGuid007,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE",
                 L"%a:%d, Status = %r",
                 __FILE__,
                 __LINE__,
                 Status
                 );

  //
  // Call SimpleTextIn.ReadKeyStroke() to check key buffer
  //
  Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);

  if (Status!=EFI_NOT_READY) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  }
  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInInterfaceTestAssertionGuid008,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE, ReadKeyStroke() verification",
                 L"%a:%d, Status = %r, Expected=%r",
                 __FILE__,
                 __LINE__,
                 Status,
                 EFI_NOT_READY
                 );

  return EFI_SUCCESS;
}
//
// TDS 4.2.2
//
EFI_STATUS
BBTestWaitForKeyConformanceManualTest (
  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_IN_PROTOCOL          *SimpleIn;

  EFI_TEST_ASSERTION                   AssertionType;
  EFI_INPUT_KEY                        Key;

  EFI_DEVICE_PATH_PROTOCOL             *DevicePath;
  CHAR16                               *DevicePathStr;

  UINTN                                WaitIndex;


  //
  // 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__,
                   __LINE__,
                   Status
                   );
    return Status;
  }

  SimpleIn = (EFI_SIMPLE_TEXT_IN_PROTOCOL *)ClientInterface;

  //
  // Get Device Path of current Simple_Text_In_Protocol
  // And out put device path or device name
  //
  Status = LocateDevicePathFromSimpleTextIn (SimpleIn, &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__,
                       __LINE__,
                       Status
                       );
        return Status;
      }
      DevicePathStr=NULL;
    }
  } else {
    //
    // Console Splitter/StdErr
    //
    StandardLib->RecordMessage (
                   StandardLib,
                   EFI_VERBOSE_LEVEL_DEFAULT,
                   L"\r\nCurrent Device: ConsoleSplitter/TxtIn"
                   );
  }

  //
  // wait for times
  //
  Print (L"\r\nWaitForKey Conformance Test Start!\r\n");
  WaitTimeOrKey (5);

  //
  // Assertion Point 4.2.2.2.1
  // ReadKeyStroke()
  //

  //
  // Call Reset with ExtendedVerification as TRUE
  //
  Status = SimpleIn->Reset (SimpleIn, TRUE);
  if (EFI_ERROR(Status)) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
    StandardLib->RecordAssertion (
                   StandardLib,
                   AssertionType,
                   gTestGenericFailureGuid,
                   L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset with ExtendedVeirification as TRUE",
                   L"%a:%d, Status = %r",
                   __FILE__,
                   __LINE__,
                   Status
                   );
  }

  //
  // Call CheckEvent() on the WaitForKey event
  //
  Status = gtBS->CheckEvent (SimpleIn->WaitForKey);
  if (Status!=EFI_NOT_READY) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  }
  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInConformanceTestAssertionGuid007,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.WaitForKey - Event check before key input",
                 L"%a:%d, Status = %r, Expected = %r",
                 __FILE__,
                 __LINE__,
                 Status,
                 EFI_NOT_READY
                 );

  //
  // Prompt tester to input some character
  //
  Print (L"Press ONE displayable key! and NO More!");

  //
  // WaitForKey event
  //
  Status = gtBS->WaitForEvent (1, &(SimpleIn->WaitForKey), &WaitIndex);
  if (EFI_ERROR(Status)) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  }

  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInConformanceTestAssertionGuid008,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.WaitForKey - Wait for event with key input",
                 L"%a:%d, Status = %r, Expected = %r",
                 __FILE__,
                 __LINE__,
                 Status,
                 EFI_SUCCESS
                 );


  Print (L"\r\nThe key(s) input:");
  //
  // Call ReadKeyStroke repeatedly to receive the character.
  //
  while (TRUE) {
    //
    // Call ReadKeyStroke to retrieve the key
    //
    Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
    if (EFI_ERROR(Status)) {
      break;
    }

    //
    // Output what user input
    //
    if (Key.ScanCode==0) {
      //
      // Unicode character
      //
      APrint ((char*)(&Key.UnicodeChar));
    } else {
      //
      // Scan code character
      //
      Print (ScanCodeDesc (Key.ScanCode));
    }
  }

  //
  // Wait 2 second for user to check the key echoed.
  //
  gtBS->Stall (2000000);

  //
  // Call CheckEvent() on the WaitForKey event
  //
  Status = gtBS->CheckEvent (SimpleIn->WaitForKey);
  if (Status!=EFI_NOT_READY) {
    AssertionType = EFI_TEST_ASSERTION_FAILED;
  } else {
    AssertionType = EFI_TEST_ASSERTION_PASSED;
  }
  StandardLib->RecordAssertion (
                 StandardLib,
                 AssertionType,
                 gSimpleTextInConformanceTestAssertionGuid010,
                 L"EFI_SIMPLE_TEXT_IN_PROTOCOL.WaitForKey - Event check after key read stroken",
                 L"%a:%d, Status = %r, Expected = %r",
                 __FILE__,
                 __LINE__,
                 Status,
                 EFI_NOT_READY
                 );

  return EFI_SUCCESS;
}