From 7c1b19fd7811b5e08e041c7b287ae76a1074462b Mon Sep 17 00:00:00 2001 From: Kun Qin Date: Tue, 20 Feb 2024 16:45:49 -0800 Subject: [PATCH 1/4] reset conin on entry --- SetupDataPkg/ConfApp/ConfApp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SetupDataPkg/ConfApp/ConfApp.c b/SetupDataPkg/ConfApp/ConfApp.c index 9039fcdf..4b6e6340 100644 --- a/SetupDataPkg/ConfApp/ConfApp.c +++ b/SetupDataPkg/ConfApp/ConfApp.c @@ -357,6 +357,12 @@ ConfAppEntry ( goto Exit; } + // This will be the serial ConIn, which could have some potential noise on the line, reset it before reading + Status = mSimpleTextInEx->Reset (mSimpleTextInEx, FALSE); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Unable to reset SimpleTextIn on ConIn. Code = %r.\n", Status)); + } + Status = GetPlatformKeyStore (&mSecureBootKeys, &mSecureBootKeysCount); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "Failed to get platform secure boot keys. Code = %r.\n", Status)); From ffa4d81544df10fea7a120d0d8e884de2c29ed93 Mon Sep 17 00:00:00 2001 From: Kun Qin Date: Tue, 20 Feb 2024 17:14:37 -0800 Subject: [PATCH 2/4] Adding unit test --- SetupDataPkg/ConfApp/UnitTest/ConInConOut.c | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/SetupDataPkg/ConfApp/UnitTest/ConInConOut.c b/SetupDataPkg/ConfApp/UnitTest/ConInConOut.c index 67e19131..424a7af3 100644 --- a/SetupDataPkg/ConfApp/UnitTest/ConInConOut.c +++ b/SetupDataPkg/ConfApp/UnitTest/ConInConOut.c @@ -52,6 +52,13 @@ MockReadKey ( OUT EFI_KEY_DATA *KeyData ); +EFI_STATUS +EFIAPI +MockReset ( + IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + OUT EFI_KEY_DATA *KeyData + ); + EFI_SIMPLE_TEXT_OUTPUT_MODE MockMode = { .CursorColumn = 5, .CursorRow = 5, @@ -120,6 +127,7 @@ EFI_SYSTEM_TABLE MockSys = { }; EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL MockSimpleInput = { + .Reset = MockReset, .ReadKeyStrokeEx = MockReadKey, .WaitForKeyEx = (EFI_EVENT)(UINTN)0xDEADBEEF, }; @@ -144,3 +152,25 @@ MockReadKey ( CopyMem (KeyData, MockKey, sizeof (EFI_KEY_DATA)); return EFI_SUCCESS; } + +/** + Mock instance of Reset function. + + @param This Protocol instance pointer. + @param ExtendedVerification Driver may perform diagnostics on reset. + + @retval EFI_SUCCESS The device was reset. + @retval EFI_DEVICE_ERROR The device is not functioning properly and could not be reset. + +**/ +EFI_STATUS +EFIAPI +MockReset ( + IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, + IN BOOLEAN ExtendedVerification + ) +{ + assert_ptr_equal (This, &MockSimpleInput); + + return EFI_SUCCESS; +} From ae487678c13297f1610e82e7ee277211b18349f1 Mon Sep 17 00:00:00 2001 From: Kun Qin Date: Tue, 20 Feb 2024 17:23:32 -0800 Subject: [PATCH 3/4] uncrustify --- SetupDataPkg/ConfApp/ConfApp.c | 2 +- SetupDataPkg/ConfApp/UnitTest/ConInConOut.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SetupDataPkg/ConfApp/ConfApp.c b/SetupDataPkg/ConfApp/ConfApp.c index 4b6e6340..50c25480 100644 --- a/SetupDataPkg/ConfApp/ConfApp.c +++ b/SetupDataPkg/ConfApp/ConfApp.c @@ -357,7 +357,7 @@ ConfAppEntry ( goto Exit; } - // This will be the serial ConIn, which could have some potential noise on the line, reset it before reading + // This will be the serial ConIn, which could have some potential noise on the line, reset it before reading Status = mSimpleTextInEx->Reset (mSimpleTextInEx, FALSE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "Unable to reset SimpleTextIn on ConIn. Code = %r.\n", Status)); diff --git a/SetupDataPkg/ConfApp/UnitTest/ConInConOut.c b/SetupDataPkg/ConfApp/UnitTest/ConInConOut.c index 424a7af3..ee8216f6 100644 --- a/SetupDataPkg/ConfApp/UnitTest/ConInConOut.c +++ b/SetupDataPkg/ConfApp/UnitTest/ConInConOut.c @@ -166,8 +166,8 @@ MockReadKey ( EFI_STATUS EFIAPI MockReset ( - IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, - IN BOOLEAN ExtendedVerification + IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, + IN BOOLEAN ExtendedVerification ) { assert_ptr_equal (This, &MockSimpleInput); From e2d0674b33d6dc77d925f82f7e854609ac59fc23 Mon Sep 17 00:00:00 2001 From: Kun Qin Date: Tue, 20 Feb 2024 17:34:00 -0800 Subject: [PATCH 4/4] uncrustify 2 --- SetupDataPkg/ConfApp/UnitTest/ConInConOut.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SetupDataPkg/ConfApp/UnitTest/ConInConOut.c b/SetupDataPkg/ConfApp/UnitTest/ConInConOut.c index ee8216f6..378aaca0 100644 --- a/SetupDataPkg/ConfApp/UnitTest/ConInConOut.c +++ b/SetupDataPkg/ConfApp/UnitTest/ConInConOut.c @@ -55,8 +55,8 @@ MockReadKey ( EFI_STATUS EFIAPI MockReset ( - IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, - OUT EFI_KEY_DATA *KeyData + IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + IN BOOLEAN ExtendedVerification ); EFI_SIMPLE_TEXT_OUTPUT_MODE MockMode = { @@ -166,8 +166,8 @@ MockReadKey ( EFI_STATUS EFIAPI MockReset ( - IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, - IN BOOLEAN ExtendedVerification + IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + IN BOOLEAN ExtendedVerification ) { assert_ptr_equal (This, &MockSimpleInput);