diff options
author | niruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-05-24 08:29:09 +0000 |
---|---|---|
committer | niruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-05-24 08:29:09 +0000 |
commit | a974619978dff4528e810f74fb736cb474db65c1 (patch) | |
tree | 346eb9fb98ae33335292cb42543abecc6b551b85 /MdeModulePkg/Universal/Console/ConSplitterDxe | |
parent | 04a894204b48e8655d919197aa0a8a0d035d6abc (diff) | |
download | edk2-a974619978dff4528e810f74fb736cb474db65c1.zip edk2-a974619978dff4528e810f74fb736cb474db65c1.tar.gz edk2-a974619978dff4528e810f74fb736cb474db65c1.tar.bz2 |
Remove the check of signature because the code which looks for the input NotifyHandle in the internal linked list is enough.
Enhance ConSplitter to register hot keys for new connected consoles.
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hot Tian <hot.tian@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13358 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/Console/ConSplitterDxe')
-rw-r--r-- | MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c | 105 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h | 17 |
2 files changed, 73 insertions, 49 deletions
diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c index ab42b92..38004bb 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c @@ -1708,12 +1708,12 @@ ConSplitterStdErrDriverBindingStop ( /**
- Take the passed in Buffer of size SizeOfCount and grow the buffer
- by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
- bytes. Copy the current data in Buffer to the new version of Buffer
- and free the old version of buffer.
+ Take the passed in Buffer of size ElementSize and grow the buffer
+ by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes.
+ Copy the current data in Buffer to the new version of Buffer and
+ free the old version of buffer.
- @param SizeOfCount Size of element in array.
+ @param ElementSize Size of element in array.
@param Count Current number of elements in array.
@param Buffer Bigger version of passed in Buffer with all the
data.
@@ -1724,7 +1724,7 @@ ConSplitterStdErrDriverBindingStop ( **/
EFI_STATUS
ConSplitterGrowBuffer (
- IN UINTN SizeOfCount,
+ IN UINTN ElementSize,
IN OUT UINTN *Count,
IN OUT VOID **Buffer
)
@@ -1736,15 +1736,15 @@ ConSplitterGrowBuffer ( // copy the old buffer's content to the new-size buffer,
// then free the old buffer.
//
- *Count += CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT;
Ptr = ReallocatePool (
- SizeOfCount * ((*Count) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT),
- SizeOfCount * (*Count),
+ ElementSize * (*Count),
+ ElementSize * ((*Count) + CONSOLE_SPLITTER_ALLOC_UNIT),
*Buffer
);
if (Ptr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+ *Count += CONSOLE_SPLITTER_ALLOC_UNIT;
*Buffer = Ptr;
return EFI_SUCCESS;
}
@@ -1847,12 +1847,28 @@ ConSplitterTextInExAddDevice ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ LIST_ENTRY *Link;
+ TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify;
+ UINTN TextInExListCount;
//
- // If the Text Input Ex List is full, enlarge it by calling ConSplitterGrowBuffer().
+ // Enlarge the NotifyHandleList and the TextInExList
//
if (Private->CurrentNumberOfExConsoles >= Private->TextInExListCount) {
+ for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
+ CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);
+ TextInExListCount = Private->TextInExListCount;
+
+ Status = ConSplitterGrowBuffer (
+ sizeof (EFI_HANDLE),
+ &TextInExListCount,
+ (VOID **) &CurrentNotify->NotifyHandleList
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ }
Status = ConSplitterGrowBuffer (
sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *),
&Private->TextInExListCount,
@@ -1862,6 +1878,30 @@ ConSplitterTextInExAddDevice ( return EFI_OUT_OF_RESOURCES;
}
}
+
+ //
+ // Register the key notify in the new text-in device
+ //
+ for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
+ CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);
+ Status = TextInEx->RegisterKeyNotify (
+ TextInEx,
+ &CurrentNotify->KeyData,
+ CurrentNotify->KeyNotificationFn,
+ &CurrentNotify->NotifyHandleList[Private->CurrentNumberOfExConsoles]
+ );
+ if (EFI_ERROR (Status)) {
+ for (Link = Link->BackLink; Link != &Private->NotifyList; Link = Link->BackLink) {
+ CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);
+ TextInEx->UnregisterKeyNotify (
+ TextInEx,
+ CurrentNotify->NotifyHandleList[Private->CurrentNumberOfExConsoles]
+ );
+ }
+ return Status;
+ }
+ }
+
//
// Add the new text-in device data structure into the Text Input Ex List.
//
@@ -3584,14 +3624,6 @@ ConSplitterTextInRegisterKeyNotify ( Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
//
- // If no physical console input device exists,
- // return EFI_SUCCESS directly.
- //
- if (Private->CurrentNumberOfExConsoles <= 0) {
- return EFI_SUCCESS;
- }
-
- //
// Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
//
for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
@@ -3611,7 +3643,7 @@ ConSplitterTextInRegisterKeyNotify ( if (NewNotify == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- NewNotify->NotifyHandleList = (EFI_HANDLE *) AllocateZeroPool (sizeof (EFI_HANDLE) * Private->CurrentNumberOfExConsoles);
+ NewNotify->NotifyHandleList = (EFI_HANDLE *) AllocateZeroPool (sizeof (EFI_HANDLE) * Private->TextInExListCount);
if (NewNotify->NotifyHandleList == NULL) {
gBS->FreePool (NewNotify);
return EFI_OUT_OF_RESOURCES;
@@ -3633,6 +3665,15 @@ ConSplitterTextInRegisterKeyNotify ( &NewNotify->NotifyHandleList[Index]
);
if (EFI_ERROR (Status)) {
+ //
+ // Un-register the key notify on all physical console input devices
+ //
+ while (Index-- != 0) {
+ Private->TextInExList[Index]->UnregisterKeyNotify (
+ Private->TextInExList[Index],
+ NewNotify->NotifyHandleList[Index]
+ );
+ }
gBS->FreePool (NewNotify->NotifyHandleList);
gBS->FreePool (NewNotify);
return Status;
@@ -3668,7 +3709,6 @@ ConSplitterTextInUnregisterKeyNotify ( )
{
TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
- EFI_STATUS Status;
UINTN Index;
TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify;
LIST_ENTRY *Link;
@@ -3677,31 +3717,16 @@ ConSplitterTextInUnregisterKeyNotify ( return EFI_INVALID_PARAMETER;
}
- if (((TEXT_IN_EX_SPLITTER_NOTIFY *) NotificationHandle)->Signature != TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE) {
- return EFI_INVALID_PARAMETER;
- }
-
Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
- //
- // if no physical console input device exists,
- // return EFI_SUCCESS directly.
- //
- if (Private->CurrentNumberOfExConsoles <= 0) {
- return EFI_SUCCESS;
- }
-
for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);
if (CurrentNotify->NotifyHandle == NotificationHandle) {
for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {
- Status = Private->TextInExList[Index]->UnregisterKeyNotify (
- Private->TextInExList[Index],
- CurrentNotify->NotifyHandleList[Index]
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ Private->TextInExList[Index]->UnregisterKeyNotify (
+ Private->TextInExList[Index],
+ CurrentNotify->NotifyHandleList[Index]
+ );
}
RemoveEntryList (&CurrentNotify->NotifyEntry);
diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h index c22f0f6..0a9fe7d 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h @@ -1,7 +1,7 @@ /** @file
Private data structures for the Console Splitter driver
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, 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
@@ -74,8 +74,7 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gConSplitterStdErrComponentName2; //
// Private Data Structures
//
-#define CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT 32
-#define CONSOLE_SPLITTER_MODES_ALLOC_UNIT 32
+#define CONSOLE_SPLITTER_ALLOC_UNIT 32
typedef struct {
@@ -1732,12 +1731,12 @@ ConSplitterTextOutEnableCursor ( );
/**
- Take the passed in Buffer of size SizeOfCount and grow the buffer
- by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
- bytes. Copy the current data in Buffer to the new version of Buffer
- and free the old version of buffer.
+ Take the passed in Buffer of size ElementSize and grow the buffer
+ by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes.
+ Copy the current data in Buffer to the new version of Buffer and
+ free the old version of buffer.
- @param SizeOfCount Size of element in array.
+ @param ElementSize Size of element in array.
@param Count Current number of elements in array.
@param Buffer Bigger version of passed in Buffer with all the
data.
@@ -1748,7 +1747,7 @@ ConSplitterTextOutEnableCursor ( **/
EFI_STATUS
ConSplitterGrowBuffer (
- IN UINTN SizeOfCount,
+ IN UINTN ElementSize,
IN OUT UINTN *Count,
IN OUT VOID **Buffer
);
|