TRUE // CursorVisible\r
},\r
0, // SerialInTimeOut\r
- { // RawFiFo\r
- 0,\r
- 0,\r
- { 0 }\r
- },\r
- { // UnicodeFiFo\r
- 0,\r
- 0,\r
- { 0 }\r
- },\r
- { // EfiKeyFiFo\r
- 0,\r
- 0,\r
- { {0} }\r
- },\r
+\r
+ NULL, // RawFifo\r
+ NULL, // UnicodeFiFo\r
+ NULL, // EfiKeyFiFo\r
+\r
NULL, // ControllerNameTable\r
NULL, // TwoSecondTimeOut\r
INPUT_STATE_DEFAULT,\r
};\r
\r
/**\r
- Test to see if this driver supports Controller. \r
+ Test to see if this driver supports Controller.\r
\r
@param This Protocol instance pointer.\r
@param Controller Handle of device to test\r
UINTN EntryCount;\r
UINTN Index;\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;\r
\r
TerminalDevice = NULL;\r
DefaultNode = NULL;\r
if (EFI_ERROR (Status)) {\r
goto Error;\r
}\r
- //\r
- // if the serial device is a hot plug device, do not update the\r
- // ConInDev, ConOutDev, and StdErrDev variables.\r
- //\r
- Status = gBS->OpenProtocol (\r
- Controller,\r
- &gEfiHotPlugDeviceGuid,\r
- NULL,\r
- This->DriverBindingHandle,\r
- Controller,\r
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
- );\r
- if (EFI_ERROR (Status)) {\r
+\r
+ if (!IsHotPlugDevice (ParentDevicePath)) {\r
+ //\r
+ // if the serial device is a hot plug device, do not update the\r
+ // ConInDev, ConOutDev, and StdErrDev variables.\r
+ //\r
TerminalUpdateConsoleDevVariable (L"ConInDev", ParentDevicePath);\r
TerminalUpdateConsoleDevVariable (L"ConOutDev", ParentDevicePath);\r
TerminalUpdateConsoleDevVariable (L"ErrOutDev", ParentDevicePath);\r
if (!EFI_ERROR (Status)) {\r
Status = EFI_SUCCESS;\r
for (Index = 0; Index < EntryCount; Index++) {\r
- if (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) {\r
+ if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
Status = EFI_ALREADY_STARTED;\r
}\r
}\r
goto Error;\r
}\r
//\r
- // initialize the FIFO buffer used for accommodating\r
- // the pre-read pending characters\r
+ // Allocates and initializes the FIFO buffer to be zero, used for accommodating\r
+ // the pre-read pending characters.\r
//\r
- InitializeRawFiFo (TerminalDevice);\r
- InitializeUnicodeFiFo (TerminalDevice);\r
- InitializeEfiKeyFiFo (TerminalDevice);\r
+ TerminalDevice->RawFiFo = AllocateZeroPool (sizeof (RAW_DATA_FIFO));\r
+ if (TerminalDevice->RawFiFo == NULL) {\r
+ goto Error;\r
+ }\r
+ TerminalDevice->UnicodeFiFo = AllocateZeroPool (sizeof (UNICODE_FIFO));\r
+ if (TerminalDevice->UnicodeFiFo == NULL) {\r
+ goto Error;\r
+ }\r
+ TerminalDevice->EfiKeyFiFo = AllocateZeroPool (sizeof (EFI_KEY_FIFO));\r
+ if (TerminalDevice->EfiKeyFiFo == NULL) {\r
+ goto Error;\r
+ }\r
\r
//\r
// Set the timeout value of serial buffer for\r
goto ReportError;\r
}\r
//\r
- // Simple Text Output Protocol\r
+ // Set Simple Text Output Protocol from template.\r
//\r
- SimpleTextOutput = TerminalDevice->SimpleTextOutput;\r
- \r
- SimpleTextOutput.Reset = TerminalConOutReset;\r
- SimpleTextOutput.OutputString = TerminalConOutOutputString;\r
- SimpleTextOutput.TestString = TerminalConOutTestString;\r
- SimpleTextOutput.QueryMode = TerminalConOutQueryMode;\r
- SimpleTextOutput.SetMode = TerminalConOutSetMode;\r
- SimpleTextOutput.SetAttribute = TerminalConOutSetAttribute;\r
- SimpleTextOutput.ClearScreen = TerminalConOutClearScreen;\r
- SimpleTextOutput.SetCursorPosition = TerminalConOutSetCursorPosition;\r
- SimpleTextOutput.EnableCursor = TerminalConOutEnableCursor;\r
- SimpleTextOutput.Mode = &TerminalDevice->SimpleTextOutputMode;\r
+ SimpleTextOutput = CopyMem (\r
+ &TerminalDevice->SimpleTextOutput,\r
+ &mTerminalDevTemplate.SimpleTextOutput,\r
+ sizeof (mTerminalDevTemplate.SimpleTextOutput)\r
+ );\r
+ SimpleTextOutput->Mode = &TerminalDevice->SimpleTextOutputMode;\r
\r
TerminalDevice->SimpleTextOutputMode.MaxMode = 3;\r
//\r
// For terminal devices, cursor is always visible\r
//\r
TerminalDevice->SimpleTextOutputMode.CursorVisible = TRUE;\r
- Status = SimpleTextOutput.SetAttribute (\r
- &TerminalDevice->SimpleTextOutput,\r
- EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)\r
- );\r
+ Status = TerminalConOutSetAttribute (\r
+ SimpleTextOutput,\r
+ EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)\r
+ );\r
if (EFI_ERROR (Status)) {\r
goto ReportError;\r
}\r
\r
- Status = SimpleTextOutput.Reset (\r
- &TerminalDevice->SimpleTextOutput,\r
- FALSE\r
- );\r
+ Status = TerminalConOutReset (SimpleTextOutput, FALSE);\r
if (EFI_ERROR (Status)) {\r
goto ReportError;\r
}\r
\r
- Status = SimpleTextOutput.SetMode (\r
- &TerminalDevice->SimpleTextOutput,\r
- 0\r
- );\r
+ Status = TerminalConOutSetMode (SimpleTextOutput, 0);\r
if (EFI_ERROR (Status)) {\r
goto ReportError;\r
}\r
\r
- Status = SimpleTextOutput.EnableCursor (\r
- &TerminalDevice->SimpleTextOutput,\r
- TRUE\r
- );\r
+ Status = TerminalConOutEnableCursor (SimpleTextOutput, TRUE);\r
if (EFI_ERROR (Status)) {\r
goto ReportError;\r
}\r
if (EFI_ERROR (Status)) {\r
goto Error;\r
}\r
- //\r
- // if the serial device is a hot plug device, attaches the HotPlugGuid\r
- // onto the terminal device handle.\r
- //\r
- Status = gBS->OpenProtocol (\r
- Controller,\r
- &gEfiHotPlugDeviceGuid,\r
- NULL,\r
- This->DriverBindingHandle,\r
- Controller,\r
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &TerminalDevice->Handle,\r
- &gEfiHotPlugDeviceGuid,\r
- NULL,\r
- NULL\r
- );\r
- }\r
+\r
//\r
// Register the Parent-Child relationship via\r
// EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
\r
TerminalFreeNotifyList (&TerminalDevice->NotifyList);\r
\r
+ if (TerminalDevice->RawFiFo != NULL) {\r
+ FreePool (TerminalDevice->RawFiFo);\r
+ }\r
+ if (TerminalDevice->UnicodeFiFo != NULL) {\r
+ FreePool (TerminalDevice->UnicodeFiFo);\r
+ }\r
+ if (TerminalDevice->EfiKeyFiFo != NULL) {\r
+ FreePool (TerminalDevice->EfiKeyFiFo);\r
+ }\r
+\r
if (TerminalDevice->ControllerNameTable != NULL) {\r
FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);\r
}\r
/**\r
Stop this driver on Controller by closing Simple Text In, Simple Text\r
In Ex, Simple Text Out protocol, and removing parent device path from\r
- Console Device Environment Variables. \r
+ Console Device Environment Variables.\r
\r
@param This Protocol instance pointer.\r
@param Controller Handle of device to stop driver on\r
FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);\r
}\r
\r
- Status = gBS->OpenProtocol (\r
- ChildHandleBuffer[Index],\r
- &gEfiHotPlugDeviceGuid,\r
- NULL,\r
- This->DriverBindingHandle,\r
- Controller,\r
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- Status = gBS->UninstallMultipleProtocolInterfaces (\r
- ChildHandleBuffer[Index],\r
- &gEfiHotPlugDeviceGuid,\r
- NULL,\r
- NULL\r
- );\r
- } else {\r
- Status = EFI_SUCCESS;\r
- }\r
-\r
gBS->CloseEvent (TerminalDevice->TwoSecondTimeOut);\r
gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);\r
gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx);\r
@param VariableName The Console Device Environment Variable.\r
@param ParentDevicePath The terminal device path to be updated.\r
\r
- @return None.\r
-\r
**/\r
VOID\r
TerminalUpdateConsoleDevVariable (\r
@param VariableName Console Device Environment Variables.\r
@param ParentDevicePath The terminal device path to be updated.\r
\r
- @return None.\r
-\r
**/\r
VOID\r
TerminalRemoveConsoleDevVariable (\r
@param VariableSize Returns the size of the EFI variable that was read\r
\r
@return Dynamically allocated memory that contains a copy of the EFI variable.\r
- Caller is responsible freeing the buffer. If variable was not read, \r
+ Caller is responsible freeing the buffer. If variable was not read,\r
NULL returned.\r
\r
**/\r
return EFI_SUCCESS;\r
}\r
\r
-/**\r
- Initialize the Raw Data FIFO.\r
-\r
- @param TerminalDevice The terminal device.\r
-\r
- @return None.\r
-\r
-**/\r
-VOID\r
-InitializeRawFiFo (\r
- IN TERMINAL_DEV *TerminalDevice\r
- )\r
-{\r
- //\r
- // Make the raw FIFO empty.\r
- //\r
- TerminalDevice->RawFiFo.Head = TerminalDevice->RawFiFo.Tail;\r
-}\r
-\r
-/**\r
- Initialize the Unicode FIFO.\r
-\r
- @param TerminalDevice The terminal device.\r
-\r
- @return None.\r
-\r
-**/\r
-VOID\r
-InitializeUnicodeFiFo (\r
- IN TERMINAL_DEV *TerminalDevice\r
- )\r
-{\r
- //\r
- // Make the unicode FIFO empty\r
- //\r
- TerminalDevice->UnicodeFiFo.Head = TerminalDevice->UnicodeFiFo.Tail;\r
-}\r
-\r
-/**\r
- Initialize the EFI Key FIFO.\r
-\r
- @param TerminalDevice The terminal device.\r
-\r
- @return None.\r
-\r
-**/\r
-VOID\r
-InitializeEfiKeyFiFo (\r
- IN TERMINAL_DEV *TerminalDevice\r
- )\r
-{\r
- //\r
- // Make the efi key FIFO empty\r
- //\r
- TerminalDevice->EfiKeyFiFo.Head = TerminalDevice->EfiKeyFiFo.Tail;\r
-}\r
-\r
-\r
/**\r
The user Entry Point for module Terminal. The user code starts with this function.\r
\r
\r
return Status;\r
}\r
+\r
+/**\r
+ Check if the device supports hot-plug through its device path.\r
+\r
+ This function could be updated to check more types of Hot Plug devices.\r
+ Currently, it checks USB and PCCard device.\r
+\r
+ @param DevicePath Pointer to device's device path.\r
+\r
+ @retval TRUE The devcie is a hot-plug device\r
+ @retval FALSE The devcie is not a hot-plug device.\r
+\r
+**/\r
+BOOLEAN\r
+IsHotPlugDevice (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ )\r
+{\r
+ EFI_DEVICE_PATH_PROTOCOL *CheckDevicePath;\r
+\r
+ CheckDevicePath = DevicePath;\r
+ while (!IsDevicePathEnd (CheckDevicePath)) {\r
+ //\r
+ // Check device whether is hot plug device or not throught Device Path\r
+ // \r
+ if ((DevicePathType (CheckDevicePath) == MESSAGING_DEVICE_PATH) &&\r
+ (DevicePathSubType (CheckDevicePath) == MSG_USB_DP ||\r
+ DevicePathSubType (CheckDevicePath) == MSG_USB_CLASS_DP ||\r
+ DevicePathSubType (CheckDevicePath) == MSG_USB_WWID_DP)) {\r
+ //\r
+ // If Device is USB device\r
+ //\r
+ return TRUE;\r
+ }\r
+ if ((DevicePathType (CheckDevicePath) == HARDWARE_DEVICE_PATH) &&\r
+ (DevicePathSubType (CheckDevicePath) == HW_PCCARD_DP)) {\r
+ //\r
+ // If Device is PCCard\r
+ //\r
+ return TRUE;\r
+ }\r
+ \r
+ CheckDevicePath = NextDevicePathNode (CheckDevicePath);\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r