Skip to content

Commit

Permalink
Reset ConIn on ConfApp entrypoint (#317)
Browse files Browse the repository at this point in the history
## Description

This change added a reset call to reset the simple text input protocol
installed on the gST->ConInHandle. This is needed to offset any
potential dangling voltage on the serial lines after a reset, etc.

- [x] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [ ] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [ ] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

## How This Was Tested

This was tested on a proprietary hardware platform.

## Integration Instructions

N/A
  • Loading branch information
kuqin12 authored Feb 21, 2024
1 parent b673c31 commit cca9d2d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions SetupDataPkg/ConfApp/ConfApp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
30 changes: 30 additions & 0 deletions SetupDataPkg/ConfApp/UnitTest/ConInConOut.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ MockReadKey (
OUT EFI_KEY_DATA *KeyData
);

EFI_STATUS
EFIAPI
MockReset (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
);

EFI_SIMPLE_TEXT_OUTPUT_MODE MockMode = {
.CursorColumn = 5,
.CursorRow = 5,
Expand Down Expand Up @@ -120,6 +127,7 @@ EFI_SYSTEM_TABLE MockSys = {
};

EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL MockSimpleInput = {
.Reset = MockReset,
.ReadKeyStrokeEx = MockReadKey,
.WaitForKeyEx = (EFI_EVENT)(UINTN)0xDEADBEEF,
};
Expand All @@ -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_EX_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
{
assert_ptr_equal (This, &MockSimpleInput);

return EFI_SUCCESS;
}

0 comments on commit cca9d2d

Please sign in to comment.