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 Oct 20, 2023
1 parent 6a4c863 commit 79c0a60
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 @@ -2358,6 +2358,11 @@
## The value of rate limiter event for timeout check. Default value is 100(unit 1ms).
# @Prompt The value is use for Usb Network rate limiting supported.
gEfiMdeModulePkgTokenSpaceGuid.PcdUsbNetworkRateLimitingFactor|100|UINT32|0x10000028

## 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
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 79c0a60

Please sign in to comment.