summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c')
-rw-r--r--MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c147
1 files changed, 146 insertions, 1 deletions
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c b/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c
index aca043a8c2..cf9f6836b3 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c
@@ -15,6 +15,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "FormDisplay.h"
+typedef struct {
+ EFI_EVENT SyncEvent;
+ UINT8 *TimeOut;
+ CHAR16 *ErrorInfo;
+} WARNING_IF_CONTEXT;
+
+#define MAX_TIME_OUT_LEN 0x10
+
/**
Concatenate a narrow string to another string.
@@ -561,6 +569,136 @@ CreateMultiStringPopUp (
}
/**
+ Process nothing.
+
+ @param Event The Event need to be process
+ @param Context The context of the event.
+
+**/
+VOID
+EFIAPI
+EmptyEventProcess (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+}
+
+/**
+ Process for the refresh interval statement.
+
+ @param Event The Event need to be process
+ @param Context The context of the event.
+
+**/
+VOID
+EFIAPI
+RefreshTimeOutProcess (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ WARNING_IF_CONTEXT *EventInfo;
+ CHAR16 TimeOutString[MAX_TIME_OUT_LEN];
+
+ EventInfo = (WARNING_IF_CONTEXT *) Context;
+
+ if (*(EventInfo->TimeOut) == 0) {
+ gBS->CloseEvent (Event);
+
+ gBS->SignalEvent (EventInfo->SyncEvent);
+ return;
+ }
+
+ UnicodeSPrint(TimeOutString, MAX_TIME_OUT_LEN, L"%d", *(EventInfo->TimeOut));
+
+ CreateDialog (NULL, gEmptyString, EventInfo->ErrorInfo, gPressEnter, gEmptyString, TimeOutString, NULL);
+
+ *(EventInfo->TimeOut) -= 1;
+}
+
+/**
+ Show the warning message.
+
+ @param RetInfo The input warning string and timeout info.
+
+**/
+VOID
+WarningIfCheck (
+ IN STATEMENT_ERROR_INFO *RetInfo
+ )
+{
+ CHAR16 *ErrorInfo;
+ EFI_EVENT WaitList[2];
+ EFI_EVENT RefreshIntervalEvent;
+ EFI_EVENT TimeOutEvent;
+ UINT8 TimeOut;
+ EFI_STATUS Status;
+ UINTN Index;
+ WARNING_IF_CONTEXT EventContext;
+ EFI_INPUT_KEY Key;
+
+ TimeOutEvent = NULL;
+ RefreshIntervalEvent = NULL;
+
+ ASSERT (RetInfo->StringId != 0);
+ ErrorInfo = GetToken (RetInfo->StringId, gFormData->HiiHandle);
+ TimeOut = RetInfo->TimeOut;
+ if (RetInfo->TimeOut == 0) {
+ do {
+ CreateDialog (&Key, gEmptyString, ErrorInfo, gPressEnter, gEmptyString, NULL);
+ } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
+ } else {
+ Status = gBS->CreateEvent (EVT_NOTIFY_WAIT, TPL_CALLBACK, EmptyEventProcess, NULL, &TimeOutEvent);
+ ASSERT_EFI_ERROR (Status);
+
+ EventContext.SyncEvent = TimeOutEvent;
+ EventContext.TimeOut = &TimeOut;
+ EventContext.ErrorInfo = ErrorInfo;
+
+ Status = gBS->CreateEvent (EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, RefreshTimeOutProcess, &EventContext, &RefreshIntervalEvent);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Show the dialog first to avoid long time not reaction.
+ //
+ gBS->SignalEvent (RefreshIntervalEvent);
+
+ Status = gBS->SetTimer (RefreshIntervalEvent, TimerPeriodic, ONE_SECOND);
+ ASSERT_EFI_ERROR (Status);
+
+ while (TRUE) {
+ Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
+ if (!EFI_ERROR (Status) && Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
+ break;
+ }
+
+ if (Status != EFI_NOT_READY) {
+ continue;
+ }
+
+ WaitList[0] = TimeOutEvent;
+ WaitList[1] = gST->ConIn->WaitForKey;
+
+ Status = gBS->WaitForEvent (2, WaitList, &Index);
+ ASSERT_EFI_ERROR (Status);
+
+ if (Index == 0) {
+ //
+ // Timeout occur, close the hoot time out event.
+ //
+ break;
+ }
+ }
+ }
+
+ gBS->CloseEvent (TimeOutEvent);
+ gBS->CloseEvent (RefreshIntervalEvent);
+
+ FreePool (ErrorInfo);
+}
+
+/**
Process validate for one question.
@param Question The question need to be validate.
@@ -600,7 +738,14 @@ ValidateQuestion (
FreePool (ErrorInfo);
Status = EFI_INVALID_PARAMETER;
- break;
+ break;
+
+ case WARNING_IF_TRUE:
+ //
+ // Condition meet, show up warning message
+ //
+ WarningIfCheck (&RetInfo);
+ break;
default:
break;