summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2012-05-24 08:29:09 +0000
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2012-05-24 08:29:09 +0000
commita974619978dff4528e810f74fb736cb474db65c1 (patch)
tree346eb9fb98ae33335292cb42543abecc6b551b85
parent04a894204b48e8655d919197aa0a8a0d035d6abc (diff)
downloadedk2-platforms-a974619978dff4528e810f74fb736cb474db65c1.tar.xz
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
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c6
-rw-r--r--MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c6
-rw-r--r--MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c105
-rw-r--r--MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h17
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c6
-rw-r--r--Nt32Pkg/WinNtGopDxe/WinNtGopInput.c6
6 files changed, 77 insertions, 69 deletions
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
index 352aabade8..201ef0ac5c 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
+++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
@@ -2,7 +2,7 @@
Routines implements SIMPLE_TEXT_IN protocol's interfaces based on 8042 interfaces
provided by Ps2KbdCtrller.c.
-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
@@ -644,10 +644,6 @@ KeyboardUnregisterKeyNotify (
return EFI_INVALID_PARAMETER;
}
- if (((KEYBOARD_CONSOLE_IN_EX_NOTIFY *) NotificationHandle)->Signature != KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE) {
- return EFI_INVALID_PARAMETER;
- }
-
ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
//
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
index e4491401e8..001158018f 100644
--- a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
+++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
@@ -2,7 +2,7 @@
USB Keyboard Driver that manages USB keyboard and produces Simple Text Input
Protocol and Simple Text Input Ex Protocol.
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 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
@@ -1126,10 +1126,6 @@ USBKeyboardUnregisterKeyNotify (
return EFI_INVALID_PARAMETER;
}
- if (((KEYBOARD_CONSOLE_IN_EX_NOTIFY *) NotificationHandle)->Signature != USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE) {
- return EFI_INVALID_PARAMETER;
- }
-
UsbKeyboardDevice = TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS (This);
//
diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
index ab42b924dd..38004bb31c 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 c22f0f659f..0a9fe7dfc6 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
);
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 90bac164bc..547ef832f6 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -1,7 +1,7 @@
/** @file
Implementation for EFI_SIMPLE_TEXT_INPUT_PROTOCOL protocol.
-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
@@ -406,10 +406,6 @@ TerminalConInUnregisterKeyNotify (
return EFI_INVALID_PARAMETER;
}
- if (((TERMINAL_CONSOLE_IN_EX_NOTIFY *) NotificationHandle)->Signature != TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE) {
- return EFI_INVALID_PARAMETER;
- }
-
TerminalDevice = TERMINAL_CON_IN_EX_DEV_FROM_THIS (This);
NotifyList = &TerminalDevice->NotifyList;
diff --git a/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c b/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c
index ee1a98cdeb..812b02e2da 100644
--- a/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c
+++ b/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c
@@ -1,6 +1,6 @@
/** @file
-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
@@ -922,10 +922,6 @@ WinNtGopSimpleTextInExUnregisterKeyNotify (
return EFI_INVALID_PARAMETER;
}
- if (((WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY *) NotificationHandle)->Signature != WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE) {
- return EFI_INVALID_PARAMETER;
- }
-
Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This);
for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {