Skip to content

Commit

Permalink
MdeModulePkg: TerminalDxe: Added a PCD to set the timer interval
Browse files Browse the repository at this point in the history
This change added a PCD to set the timer interval for terminal devices to
periodically query the serial port.
  • Loading branch information
kuqin12 authored and kenlautner committed May 9, 2023
1 parent 69909c3 commit f8ea858
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions MdeModulePkg/MdeModulePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -2314,6 +2314,11 @@
# @Prompt The shared bit mask when Intel Tdx is enabled.
gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0|UINT64|0x10000025

## MU_CHANGE - Configuring timer interval in terminal DXE driver
## This PCD determines the timer interval to be set when using serial console.
# @Prompt Sets the serial console timer interval, in the unit of 100ns.
gEfiMdeModulePkgTokenSpaceGuid.PcdTerminalKeyboardTimerInterval|0x00000000|UINT32|0x00030025

[PcdsPatchableInModule]
## Specify memory size with page number for PEI code when
# Loading Module at Fixed Address feature is enabled.
Expand Down
14 changes: 13 additions & 1 deletion MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ StartTerminalStateMachine (
)
{
EFI_STATUS Status;
UINT64 TimerInterval; // MU_CHANGE: Override the timer interval if the PCD is set

Status = gBS->CreateEvent (
EVT_TIMER | EVT_NOTIFY_SIGNAL,
Expand All @@ -385,10 +386,21 @@ StartTerminalStateMachine (
);
ASSERT_EFI_ERROR (Status);

// MU_CHANGE Starts: Override the timer interval if the PCD is set
if (PcdGet32 (PcdTerminalKeyboardTimerInterval) != 0) {
TimerInterval = PcdGet32 (PcdTerminalKeyboardTimerInterval);
} else if (TerminalDevice->SerialInTimeOut == 0) {
TimerInterval = KEYBOARD_TIMER_INTERVAL;
} else {
// We should check back when filled in half of the FIFO, the number is the unit of 100ns.
TimerInterval = TerminalDevice->SerialInTimeOut * FIFO_MAX_NUMBER / 2 * 10;
}

// MU_CHANGE Ends
Status = gBS->SetTimer (
TerminalDevice->TimerEvent,
TimerPeriodic,
KEYBOARD_TIMER_INTERVAL
TimerInterval // MU_CHANGE
);
ASSERT_EFI_ERROR (Status);

Expand Down
2 changes: 2 additions & 0 deletions MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## CONSUMES

gEfiMdeModulePkgTokenSpaceGuid.PcdTerminalKeyboardTimerInterval ## CONSUMES MU_CHANGE

# [Event]
# # Relative timer event set by UnicodeToEfiKey(), used to be one 2 seconds input timeout.
# EVENT_TYPE_RELATIVE_TIMER ## CONSUMES
Expand Down

0 comments on commit f8ea858

Please sign in to comment.