\r
\r
/**\r
- Take the passed in Buffer of size SizeOfCount and grow the buffer\r
- by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount\r
- bytes. Copy the current data in Buffer to the new version of Buffer\r
- and free the old version of buffer.\r
+ Take the passed in Buffer of size ElementSize and grow the buffer\r
+ by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes.\r
+ Copy the current data in Buffer to the new version of Buffer and\r
+ free the old version of buffer.\r
\r
- @param SizeOfCount Size of element in array.\r
+ @param ElementSize Size of element in array.\r
@param Count Current number of elements in array.\r
@param Buffer Bigger version of passed in Buffer with all the\r
data.\r
**/\r
EFI_STATUS\r
ConSplitterGrowBuffer (\r
- IN UINTN SizeOfCount,\r
+ IN UINTN ElementSize,\r
IN OUT UINTN *Count,\r
IN OUT VOID **Buffer\r
)\r
// copy the old buffer's content to the new-size buffer,\r
// then free the old buffer.\r
//\r
- *Count += CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT;\r
Ptr = ReallocatePool (\r
- SizeOfCount * ((*Count) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT),\r
- SizeOfCount * (*Count),\r
+ ElementSize * (*Count),\r
+ ElementSize * ((*Count) + CONSOLE_SPLITTER_ALLOC_UNIT),\r
*Buffer\r
);\r
if (Ptr == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
+ *Count += CONSOLE_SPLITTER_ALLOC_UNIT;\r
*Buffer = Ptr;\r
return EFI_SUCCESS;\r
}\r
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
+ LIST_ENTRY *Link;\r
+ TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify;\r
+ UINTN TextInExListCount;\r
\r
//\r
- // If the Text Input Ex List is full, enlarge it by calling ConSplitterGrowBuffer().\r
+ // Enlarge the NotifyHandleList and the TextInExList\r
//\r
if (Private->CurrentNumberOfExConsoles >= Private->TextInExListCount) {\r
+ for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {\r
+ CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);\r
+ TextInExListCount = Private->TextInExListCount;\r
+\r
+ Status = ConSplitterGrowBuffer (\r
+ sizeof (EFI_HANDLE),\r
+ &TextInExListCount,\r
+ (VOID **) &CurrentNotify->NotifyHandleList\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ }\r
Status = ConSplitterGrowBuffer (\r
sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *),\r
&Private->TextInExListCount,\r
return EFI_OUT_OF_RESOURCES;\r
}\r
}\r
+\r
+ //\r
+ // Register the key notify in the new text-in device\r
+ //\r
+ for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {\r
+ CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);\r
+ Status = TextInEx->RegisterKeyNotify (\r
+ TextInEx,\r
+ &CurrentNotify->KeyData,\r
+ CurrentNotify->KeyNotificationFn,\r
+ &CurrentNotify->NotifyHandleList[Private->CurrentNumberOfExConsoles]\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ for (Link = Link->BackLink; Link != &Private->NotifyList; Link = Link->BackLink) {\r
+ CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);\r
+ TextInEx->UnregisterKeyNotify (\r
+ TextInEx,\r
+ CurrentNotify->NotifyHandleList[Private->CurrentNumberOfExConsoles]\r
+ );\r
+ }\r
+ return Status;\r
+ }\r
+ }\r
+\r
//\r
// Add the new text-in device data structure into the Text Input Ex List.\r
//\r
\r
Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
\r
- //\r
- // If no physical console input device exists,\r
- // return EFI_SUCCESS directly.\r
- //\r
- if (Private->CurrentNumberOfExConsoles <= 0) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
//\r
// Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.\r
//\r
if (NewNotify == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- NewNotify->NotifyHandleList = (EFI_HANDLE *) AllocateZeroPool (sizeof (EFI_HANDLE) * Private->CurrentNumberOfExConsoles);\r
+ NewNotify->NotifyHandleList = (EFI_HANDLE *) AllocateZeroPool (sizeof (EFI_HANDLE) * Private->TextInExListCount);\r
if (NewNotify->NotifyHandleList == NULL) {\r
gBS->FreePool (NewNotify);\r
return EFI_OUT_OF_RESOURCES;\r
&NewNotify->NotifyHandleList[Index]\r
);\r
if (EFI_ERROR (Status)) {\r
+ //\r
+ // Un-register the key notify on all physical console input devices\r
+ //\r
+ while (Index-- != 0) {\r
+ Private->TextInExList[Index]->UnregisterKeyNotify (\r
+ Private->TextInExList[Index],\r
+ NewNotify->NotifyHandleList[Index]\r
+ );\r
+ }\r
gBS->FreePool (NewNotify->NotifyHandleList);\r
gBS->FreePool (NewNotify);\r
return Status;\r
)\r
{\r
TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r
- EFI_STATUS Status;\r
UINTN Index;\r
TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify;\r
LIST_ENTRY *Link;\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- if (((TEXT_IN_EX_SPLITTER_NOTIFY *) NotificationHandle)->Signature != TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
\r
- //\r
- // if no physical console input device exists,\r
- // return EFI_SUCCESS directly.\r
- //\r
- if (Private->CurrentNumberOfExConsoles <= 0) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {\r
CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);\r
if (CurrentNotify->NotifyHandle == NotificationHandle) {\r
for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {\r
- Status = Private->TextInExList[Index]->UnregisterKeyNotify (\r
- Private->TextInExList[Index],\r
- CurrentNotify->NotifyHandleList[Index]\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
+ Private->TextInExList[Index]->UnregisterKeyNotify (\r
+ Private->TextInExList[Index],\r
+ CurrentNotify->NotifyHandleList[Index]\r
+ );\r
}\r
RemoveEntryList (&CurrentNotify->NotifyEntry);\r
\r