diff options
author | Eric Dong <eric.dong@intel.com> | 2014-07-28 07:10:22 +0000 |
---|---|---|
committer | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-07-28 07:10:22 +0000 |
commit | 40578d09d1f9e8864e6d1eff95b9eeabee4b9947 (patch) | |
tree | 90222cde6a235ce9698683b92fe3264d17bcb018 /MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c | |
parent | f449affebd12c64e5ae2338caa7993e0daa10712 (diff) | |
download | edk2-platforms-40578d09d1f9e8864e6d1eff95b9eeabee4b9947.tar.xz |
Update the code to follow UEFI spec, process date/time/ref value type as buffer type when in an expression.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15690 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c')
-rw-r--r-- | MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c | 164 |
1 files changed, 129 insertions, 35 deletions
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c b/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c index 1ab38b1df2..65d2a74995 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c +++ b/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c @@ -2,7 +2,7 @@ Implementation for handling the User Interface option processing.
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -99,6 +99,107 @@ HiiValueToUINT64 ( }
/**
+ Check whether this value type can be transfer to EFI_IFR_TYPE_BUFFER type.
+
+ EFI_IFR_TYPE_REF, EFI_IFR_TYPE_DATE and EFI_IFR_TYPE_TIME are converted to
+ EFI_IFR_TYPE_BUFFER when do the value compare.
+
+ @param Value Expression value to compare on.
+
+ @retval TRUE This value type can be transter to EFI_IFR_TYPE_BUFFER type.
+ @retval FALSE This value type can't be transter to EFI_IFR_TYPE_BUFFER type.
+
+**/
+BOOLEAN
+IsTypeInBuffer (
+ IN EFI_HII_VALUE *Value
+ )
+{
+ switch (Value->Type) {
+ case EFI_IFR_TYPE_BUFFER:
+ case EFI_IFR_TYPE_DATE:
+ case EFI_IFR_TYPE_TIME:
+ case EFI_IFR_TYPE_REF:
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+}
+
+/**
+ Check whether this value type can be transfer to EFI_IFR_TYPE_UINT64
+
+ @param Value Expression value to compare on.
+
+ @retval TRUE This value type can be transter to EFI_IFR_TYPE_BUFFER type.
+ @retval FALSE This value type can't be transter to EFI_IFR_TYPE_BUFFER type.
+
+**/
+BOOLEAN
+IsTypeInUINT64 (
+ IN EFI_HII_VALUE *Value
+ )
+{
+ switch (Value->Type) {
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ case EFI_IFR_TYPE_BOOLEAN:
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+}
+
+/**
+ Return the buffer length and buffer pointer for this value.
+
+ EFI_IFR_TYPE_REF, EFI_IFR_TYPE_DATE and EFI_IFR_TYPE_TIME are converted to
+ EFI_IFR_TYPE_BUFFER when do the value compare.
+
+ @param Value Expression value to compare on.
+ @param Buf Return the buffer pointer.
+ @param BufLen Return the buffer length.
+
+**/
+VOID
+GetBufAndLenForValue (
+ IN EFI_HII_VALUE *Value,
+ OUT UINT8 **Buf,
+ OUT UINT16 *BufLen
+ )
+{
+ switch (Value->Type) {
+ case EFI_IFR_TYPE_BUFFER:
+ *Buf = Value->Buffer;
+ *BufLen = Value->BufferLen;
+ break;
+
+ case EFI_IFR_TYPE_DATE:
+ *Buf = (UINT8 *) (&Value->Value.date);
+ *BufLen = (UINT16) sizeof (EFI_HII_DATE);
+ break;
+
+ case EFI_IFR_TYPE_TIME:
+ *Buf = (UINT8 *) (&Value->Value.time);
+ *BufLen = (UINT16) sizeof (EFI_HII_TIME);
+ break;
+
+ case EFI_IFR_TYPE_REF:
+ *Buf = (UINT8 *) (&Value->Value.ref);
+ *BufLen = (UINT16) sizeof (EFI_HII_REF);
+ break;
+
+ default:
+ *Buf = NULL;
+ *BufLen = 0;
+ }
+}
+
+/**
Compare two Hii value.
@param Value1 Expression value to compare on left-hand.
@@ -125,21 +226,12 @@ CompareHiiValue ( CHAR16 *Str1;
CHAR16 *Str2;
UINTN Len;
+ UINT8 *Buf1;
+ UINT16 Buf1Len;
+ UINT8 *Buf2;
+ UINT16 Buf2Len;
- if (Value1->Type >= EFI_IFR_TYPE_OTHER || Value2->Type >= EFI_IFR_TYPE_OTHER ) {
- if (Value1->Type != EFI_IFR_TYPE_BUFFER && Value2->Type != EFI_IFR_TYPE_BUFFER) {
- return EFI_UNSUPPORTED;
- }
- }
-
- if (Value1->Type == EFI_IFR_TYPE_STRING || Value2->Type == EFI_IFR_TYPE_STRING ) {
- if (Value1->Type != Value2->Type) {
- //
- // Both Operator should be type of String
- //
- return EFI_UNSUPPORTED;
- }
-
+ if (Value1->Type == EFI_IFR_TYPE_STRING && Value2->Type == EFI_IFR_TYPE_STRING) {
if (Value1->Value.string == 0 || Value2->Value.string == 0) {
//
// StringId 0 is reserved
@@ -174,22 +266,21 @@ CompareHiiValue ( return EFI_SUCCESS;
}
- if (Value1->Type == EFI_IFR_TYPE_BUFFER || Value2->Type == EFI_IFR_TYPE_BUFFER ) {
- if (Value1->Type != Value2->Type) {
- //
- // Both Operator should be type of Buffer.
- //
- return EFI_UNSUPPORTED;
- }
- Len = Value1->BufferLen > Value2->BufferLen ? Value2->BufferLen : Value1->BufferLen;
- *Result = CompareMem (Value1->Buffer, Value2->Buffer, Len);
- if ((*Result == 0) && (Value1->BufferLen != Value2->BufferLen))
- {
+ //
+ // Take types(date, time, ref, buffer) as buffer
+ //
+ if (IsTypeInBuffer(Value1) && IsTypeInBuffer(Value2)) {
+ GetBufAndLenForValue(Value1, &Buf1, &Buf1Len);
+ GetBufAndLenForValue(Value2, &Buf2, &Buf2Len);
+
+ Len = Buf1Len > Buf2Len ? Buf2Len : Buf1Len;
+ *Result = CompareMem (Buf1, Buf2, Len);
+ if ((*Result == 0) && (Buf1Len != Buf2Len)) {
//
// In this case, means base on samll number buffer, the data is same
// So which value has more data, which value is bigger.
//
- *Result = Value1->BufferLen > Value2->BufferLen ? 1 : -1;
+ *Result = Buf1Len > Buf2Len ? 1 : -1;
}
return EFI_SUCCESS;
}
@@ -197,16 +288,19 @@ CompareHiiValue ( //
// Take remain types(integer, boolean, date/time) as integer
//
- Temp64 = HiiValueToUINT64(Value1) - HiiValueToUINT64(Value2);
- if (Temp64 > 0) {
- *Result = 1;
- } else if (Temp64 < 0) {
- *Result = -1;
- } else {
- *Result = 0;
+ if (IsTypeInUINT64(Value1) && IsTypeInUINT64(Value2)) {
+ Temp64 = HiiValueToUINT64(Value1) - HiiValueToUINT64(Value2);
+ if (Temp64 > 0) {
+ *Result = 1;
+ } else if (Temp64 < 0) {
+ *Result = -1;
+ } else {
+ *Result = 0;
+ }
+ return EFI_SUCCESS;
}
- return EFI_SUCCESS;
+ return EFI_UNSUPPORTED;
}
/**
|