};\r
\r
\r
-EFI_GUID *gTerminalType[] = {\r
+EFI_GUID *mTerminalType[] = {\r
&gEfiPcAnsiGuid,\r
&gEfiVT100Guid,\r
&gEfiVT100PlusGuid,\r
//\r
};\r
\r
+/**\r
+ Convert the GUID representation of terminal type to enum type.\r
+\r
+ @param Guid The GUID representation of terminal type.\r
+\r
+ @return The terminal type in enum type.\r
+**/\r
+TERMINAL_TYPE\r
+TerminalTypeFromGuid (\r
+ IN EFI_GUID *Guid\r
+)\r
+{\r
+ TERMINAL_TYPE Type;\r
+\r
+ for (Type = 0; Type < ARRAY_SIZE (mTerminalType); Type++) {\r
+ if (CompareGuid (Guid, mTerminalType[Type])) {\r
+ break;\r
+ }\r
+ }\r
+ return Type;\r
+}\r
+\r
/**\r
Test to see if this driver supports Controller.\r
\r
//\r
// only supports PC ANSI, VT100, VT100+, VT-UTF8, and TtyTerm terminal types\r
//\r
- if (!CompareGuid (&Node->Guid, &gEfiPcAnsiGuid) &&\r
- !CompareGuid (&Node->Guid, &gEfiVT100Guid) &&\r
- !CompareGuid (&Node->Guid, &gEfiVT100PlusGuid) &&\r
- !CompareGuid (&Node->Guid, &gEfiVTUTF8Guid) &&\r
- !CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) {\r
-\r
+ if (TerminalTypeFromGuid (&Node->Guid) == ARRAY_SIZE (mTerminalType)) {\r
return EFI_UNSUPPORTED;\r
}\r
}\r
//\r
if (RemainingDevicePath == NULL) {\r
TerminalType = PcdGet8 (PcdDefaultTerminalType);\r
- //\r
- // Must be between TerminalTypePcAnsi (0) and TerminalTypeTtyTerm (4)\r
- //\r
- ASSERT (TerminalType <= TerminalTypeTtyTerm);\r
} else if (!IsDevicePathEnd (RemainingDevicePath)) {\r
//\r
// If RemainingDevicePath isn't the End of Device Path Node,\r
// Use the RemainingDevicePath to determine the terminal type\r
//\r
Node = (VENDOR_DEVICE_PATH *)RemainingDevicePath;\r
- if (CompareGuid (&Node->Guid, &gEfiPcAnsiGuid)) {\r
- TerminalType = TerminalTypePcAnsi;\r
- } else if (CompareGuid (&Node->Guid, &gEfiVT100Guid)) {\r
- TerminalType = TerminalTypeVt100;\r
- } else if (CompareGuid (&Node->Guid, &gEfiVT100PlusGuid)) {\r
- TerminalType = TerminalTypeVt100Plus;\r
- } else if (CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {\r
- TerminalType = TerminalTypeVtUtf8;\r
- } else if (CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) {\r
- TerminalType = TerminalTypeTtyTerm;\r
- } else {\r
- goto Error;\r
- }\r
+ TerminalType = TerminalTypeFromGuid (&Node->Guid);\r
} else {\r
//\r
// If RemainingDevicePath is the End of Device Path Node,\r
return EFI_SUCCESS;\r
}\r
\r
+ ASSERT (TerminalType < ARRAY_SIZE (mTerminalType));\r
+\r
//\r
// Initialize the Terminal Dev\r
//\r
//\r
// Append terminal device path onto the variable.\r
//\r
- for (TerminalType = TerminalTypePcAnsi; TerminalType <= TerminalTypeTtyTerm; TerminalType++) {\r
+ for (TerminalType = 0; TerminalType < ARRAY_SIZE (mTerminalType); TerminalType++) {\r
SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);\r
NewVariable = AppendDevicePathInstance (Variable, TempDevicePath);\r
ASSERT (NewVariable != NULL);\r
// Loop through all the terminal types that this driver supports\r
//\r
Match = FALSE;\r
- for (TerminalType = TerminalTypePcAnsi; TerminalType <= TerminalTypeTtyTerm; TerminalType++) {\r
+ for (TerminalType = 0; TerminalType < ARRAY_SIZE (mTerminalType); TerminalType++) {\r
\r
SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);\r
\r