fixed one bug when "reconnect -r"

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8116 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff 2009-04-17 05:40:21 +00:00
parent 75bf9d0ecc
commit e672aebac6

View File

@ -168,65 +168,65 @@ Index: edit/libEditor.c
--- edit/libEditor.c (revision 30) --- edit/libEditor.c (revision 30)
+++ edit/libEditor.c (working copy) +++ edit/libEditor.c (working copy)
@@ -88,8 +88,6 @@ @@ -88,8 +88,6 @@
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer; - EFI_HANDLE *HandleBuffer;
- UINTN HandleCount; - UINTN HandleCount;
// //
// basic initialization // basic initialization
@@ -117,38 +115,22 @@ @@ -117,38 +115,22 @@
); );
// //
- // Find mouse - // Find mouse
+ // Find mouse in System Table ConsoleInHandle + // Find mouse in System Table ConsoleInHandle
// //
- HandleBuffer = NULL; - HandleBuffer = NULL;
- Status = LibLocateHandle ( - Status = LibLocateHandle (
- ByProtocol, - ByProtocol,
- &gEfiPrimaryConsoleInDeviceGuid, - &gEfiPrimaryConsoleInDeviceGuid,
- NULL, - NULL,
- &HandleCount, - &HandleCount,
- &HandleBuffer - &HandleBuffer
- ); - );
+ Status = BS->HandleProtocol ( + Status = BS->HandleProtocol (
+ In, + In,
+ &gEfiSimplePointerProtocolGuid, + &gEfiSimplePointerProtocolGuid,
+ &MainEditor.MouseInterface + &MainEditor.MouseInterface
+ ); + );
- if (!EFI_ERROR (Status)) { - if (!EFI_ERROR (Status)) {
- if (HandleCount > 0) { - if (HandleCount > 0) {
- Status = BS->HandleProtocol ( - Status = BS->HandleProtocol (
- HandleBuffer[0], - HandleBuffer[0],
- &gEfiSimplePointerProtocolGuid, - &gEfiSimplePointerProtocolGuid,
- &MainEditor.MouseInterface - &MainEditor.MouseInterface
- ); - );
- -
- if (EFI_ERROR (Status)) { - if (EFI_ERROR (Status)) {
- MainEditor.MouseInterface = NULL; - MainEditor.MouseInterface = NULL;
- } else { - } else {
- MainEditor.MouseAccumulatorX = 0; - MainEditor.MouseAccumulatorX = 0;
- MainEditor.MouseAccumulatorY = 0; - MainEditor.MouseAccumulatorY = 0;
- MainEditor.MouseSupported = TRUE; - MainEditor.MouseSupported = TRUE;
- } - }
- } - }
+ if (EFI_ERROR (Status)) { + if (EFI_ERROR (Status)) {
+ MainEditor.MouseInterface = NULL; + MainEditor.MouseInterface = NULL;
+ } else { + } else {
+ MainEditor.MouseAccumulatorX = 0; + MainEditor.MouseAccumulatorX = 0;
+ MainEditor.MouseAccumulatorY = 0; + MainEditor.MouseAccumulatorY = 0;
+ MainEditor.MouseSupported = TRUE; + MainEditor.MouseSupported = TRUE;
} }
- if (HandleBuffer) { - if (HandleBuffer) {
- FreePool (HandleBuffer); - FreePool (HandleBuffer);
- } - }
// //
// below will call the five components' init function // below will call the five components' init function
// //
Index: edit/libFileBuffer.c Index: edit/libFileBuffer.c
=================================================================== ===================================================================
--- edit/libFileBuffer.c (revision 30) --- edit/libFileBuffer.c (revision 30)
@ -248,67 +248,67 @@ Index: edit/libFileBuffer.c
+ if ((FileSize >= 2) && (*((UINT16 *) Buffer) == EFI_UNICODE_BYTE_ORDER_MARK)) { + if ((FileSize >= 2) && (*((UINT16 *) Buffer) == EFI_UNICODE_BYTE_ORDER_MARK)) {
// //
// Unicode file's size should be even // Unicode file's size should be even
// //
Index: hexedit/libEditor.c Index: hexedit/libEditor.c
=================================================================== ===================================================================
--- hexedit/libEditor.c (revision 30) --- hexedit/libEditor.c (revision 30)
+++ hexedit/libEditor.c (working copy) +++ hexedit/libEditor.c (working copy)
@@ -100,8 +100,6 @@ @@ -100,8 +100,6 @@
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer; - EFI_HANDLE *HandleBuffer;
- UINTN HandleCount; - UINTN HandleCount;
// //
// basic initialization // basic initialization
@@ -129,36 +127,19 @@ @@ -129,36 +127,19 @@
&(HMainEditor.ScreenSize.Row) &(HMainEditor.ScreenSize.Row)
); );
- HandleBuffer = NULL; - HandleBuffer = NULL;
- Status = LibLocateHandle ( - Status = LibLocateHandle (
- ByProtocol, - ByProtocol,
- &gEfiPrimaryConsoleInDeviceGuid, - &gEfiPrimaryConsoleInDeviceGuid,
- NULL, - NULL,
- &HandleCount, - &HandleCount,
- &HandleBuffer - &HandleBuffer
- ); - );
- -
- if (!EFI_ERROR (Status)) { - if (!EFI_ERROR (Status)) {
- -
- if (HandleCount > 0) { - if (HandleCount > 0) {
- Status = BS->HandleProtocol ( - Status = BS->HandleProtocol (
- HandleBuffer[0], - HandleBuffer[0],
- &gEfiSimplePointerProtocolGuid, - &gEfiSimplePointerProtocolGuid,
- &HMainEditor.MouseInterface - &HMainEditor.MouseInterface
- ); - );
- if (EFI_ERROR (Status)) { - if (EFI_ERROR (Status)) {
- HMainEditor.MouseInterface = NULL; - HMainEditor.MouseInterface = NULL;
- } else { - } else {
- HMainEditor.MouseAccumulatorX = 0; - HMainEditor.MouseAccumulatorX = 0;
- HMainEditor.MouseAccumulatorY = 0; - HMainEditor.MouseAccumulatorY = 0;
- HMainEditor.MouseSupported = TRUE; - HMainEditor.MouseSupported = TRUE;
- } - }
- } - }
+ Status = BS->HandleProtocol ( + Status = BS->HandleProtocol (
+ In, + In,
+ &gEfiSimplePointerProtocolGuid, + &gEfiSimplePointerProtocolGuid,
+ &HMainEditor.MouseInterface + &HMainEditor.MouseInterface
+ ); + );
+ if (EFI_ERROR (Status)) { + if (EFI_ERROR (Status)) {
+ HMainEditor.MouseInterface = NULL; + HMainEditor.MouseInterface = NULL;
+ } else { + } else {
+ HMainEditor.MouseAccumulatorX = 0; + HMainEditor.MouseAccumulatorX = 0;
+ HMainEditor.MouseAccumulatorY = 0; + HMainEditor.MouseAccumulatorY = 0;
+ HMainEditor.MouseSupported = TRUE; + HMainEditor.MouseSupported = TRUE;
} }
- if (HandleBuffer != NULL) { - if (HandleBuffer != NULL) {
- FreePool (HandleBuffer); - FreePool (HandleBuffer);
- } - }
// //
// below will call the five components' init function // below will call the five components' init function
// //
Index: Library/EfiShellLib.h Index: Library/EfiShellLib.h
=================================================================== ===================================================================
@ -504,171 +504,182 @@ Index: shellenv/Connect.c
--- shellenv/Connect.c (revision 30) --- shellenv/Connect.c (revision 30)
+++ shellenv/Connect.c (working copy) +++ shellenv/Connect.c (working copy)
@@ -831,6 +831,16 @@ @@ -831,6 +831,16 @@
return Status; return Status;
} }
+ // + //
+ // Close proxy console before disconnect all devices. + // Close proxy console before disconnect all devices.
+ // + //
+ SEnvCloseConsoleProxy ( + SEnvCloseConsoleProxy (
+ ST->ConsoleInHandle, + ST->ConsoleInHandle,
+ &ST->ConIn, + &ST->ConIn,
+ ST->ConsoleOutHandle, + ST->ConsoleOutHandle,
+ &ST->ConOut + &ST->ConOut
+ ); + );
+ +
for (Index = 0; Index < AllHandleCount; Index++) { for (Index = 0; Index < AllHandleCount; Index++) {
// //
// Check whether the handle is still in handle database // Check whether the handle is still in handle database
@@ -1004,7 +1014,6 @@ @@ -1004,7 +1014,6 @@
VOID VOID
SEnvConnectConsole ( SEnvConnectConsole (
CHAR16 *VariableName, CHAR16 *VariableName,
- EFI_GUID *PrimaryGuid, - EFI_GUID *PrimaryGuid,
EFI_GUID *ConsoleGuid, EFI_GUID *ConsoleGuid,
EFI_HANDLE *ConsoleHandle, EFI_HANDLE *ConsoleHandle,
VOID **ConsoleInterface VOID **ConsoleInterface
@@ -1018,9 +1027,8 @@ @@ -1018,27 +1027,36 @@
EFI_HANDLE *AllHandleBuffer; EFI_HANDLE *AllHandleBuffer;
VOID *Interface; VOID *Interface;
- *ConsoleHandle = NULL; - *ConsoleHandle = NULL;
- *ConsoleInterface = NULL; - *ConsoleInterface = NULL;
ConsoleIndex = 0; ConsoleIndex = 0;
+ AllHandleBuffer = NULL; + AllHandleBuffer = NULL;
DevicePath = LibGetVariable (VariableName, &gEfiGlobalVariableGuid); DevicePath = LibGetVariable (VariableName, &gEfiGlobalVariableGuid);
if (DevicePath != NULL) { - if (DevicePath != NULL) {
@@ -1028,17 +1036,19 @@ - SEnvConnectDevicePath (DevicePath);
FreePool (DevicePath); - FreePool (DevicePath);
} + if (DevicePath == NULL) {
+ //
- AllHandleBuffer = NULL; + // If no any device defined in EFI variable, do nothing
- Status = BS->LocateHandleBuffer ( + //
- ByProtocol, + return;
- PrimaryGuid, }
- NULL,
- &AllHandleCount, - AllHandleBuffer = NULL;
- &AllHandleBuffer - Status = BS->LocateHandleBuffer (
- ); - ByProtocol,
- if (!EFI_ERROR (Status) && AllHandleCount > 0) { - PrimaryGuid,
- *ConsoleHandle = AllHandleBuffer[0]; - NULL,
- } else if (*ConsoleHandle == NULL) { - &AllHandleCount,
+ Status = EFI_NOT_FOUND; - &AllHandleBuffer
+ // - );
+ // Check ConsoleHandle validation whatever it was updated or not. - if (!EFI_ERROR (Status) && AllHandleCount > 0) {
+ // - *ConsoleHandle = AllHandleBuffer[0];
+ if (*ConsoleHandle != NULL) { - } else if (*ConsoleHandle == NULL) {
+ Status = BS->HandleProtocol ( + //
+ *ConsoleHandle, + // Connect all console devices
+ ConsoleGuid, + //
+ &Interface + SEnvConnectDevicePath (DevicePath);
+ ); + FreePool (DevicePath);
+ } +
+ + Status = EFI_NOT_FOUND;
+ if (EFI_ERROR (Status)) { + //
AllHandleBuffer = NULL; + // Check ConsoleHandle validation whatever it was updated or not.
Status = BS->LocateHandleBuffer ( + //
ByProtocol, + if (*ConsoleHandle != NULL) {
@@ -1063,16 +1073,16 @@ + Status = BS->HandleProtocol (
&gEfiDevicePathProtocolGuid, + *ConsoleHandle,
&Interface + ConsoleGuid,
); + &Interface
- if (EFI_ERROR (Status)) { + );
+ if (!EFI_ERROR (Status)) { + }
ConsoleIndex = Index; +
break; + if (EFI_ERROR (Status)) {
} AllHandleBuffer = NULL;
} Status = BS->LocateHandleBuffer (
+ ByProtocol,
+ *ConsoleHandle = AllHandleBuffer[ConsoleIndex]; @@ -1063,16 +1081,16 @@
} &gEfiDevicePathProtocolGuid,
} &Interface
);
- *ConsoleHandle = AllHandleBuffer[ConsoleIndex]; - if (EFI_ERROR (Status)) {
- + if (!EFI_ERROR (Status)) {
if (*ConsoleHandle != NULL) { ConsoleIndex = Index;
BS->HandleProtocol ( break;
*ConsoleHandle, }
@@ -1081,7 +1091,7 @@ }
); +
} + *ConsoleHandle = AllHandleBuffer[ConsoleIndex];
}
- if (AllHandleBuffer) { }
+ if (AllHandleBuffer != NULL) {
FreePool (AllHandleBuffer); - *ConsoleHandle = AllHandleBuffer[ConsoleIndex];
} -
} if (*ConsoleHandle != NULL) {
@@ -1189,8 +1199,7 @@ BS->HandleProtocol (
EFI_STATUS Status; *ConsoleHandle,
@@ -1081,7 +1099,7 @@
// );
- // Check current ConIn and ConOut to ensure it is the ConsoleProxy }
- // Otherwise, the Console should not be close
+ // Check current ConIn and ConOut to judge it is the ConsoleProxy - if (AllHandleBuffer) {
// + if (AllHandleBuffer != NULL) {
Status = SEnvCheckConsoleProxy ( FreePool (AllHandleBuffer);
ST->ConsoleInHandle, }
@@ -1203,23 +1212,21 @@ }
// Indicate the Console is replaced by redirection operation @@ -1189,8 +1207,7 @@
// It is not safe to connect Console here EFI_STATUS Status;
//
- if (EFI_ERROR (Status)) { //
- return ; - // Check current ConIn and ConOut to ensure it is the ConsoleProxy
+ if (!EFI_ERROR (Status)) { - // Otherwise, the Console should not be close
+ // + // Check current ConIn and ConOut to judge it is the ConsoleProxy
+ // It is proxy console, to prevent the proxy console form being restored to original console, //
+ // close it temporary before connect all console Status = SEnvCheckConsoleProxy (
+ // ST->ConsoleInHandle,
+ SEnvCloseConsoleProxy ( @@ -1203,23 +1220,21 @@
+ ST->ConsoleInHandle, // Indicate the Console is replaced by redirection operation
+ &ST->ConIn, // It is not safe to connect Console here
+ ST->ConsoleOutHandle, //
+ &ST->ConOut - if (EFI_ERROR (Status)) {
+ ); - return ;
} + if (!EFI_ERROR (Status)) {
- // + //
- // To prevent the proxy console form being restored to original console, + // It is proxy console, to prevent the proxy console form being restored to original console,
- // close it temporary before connect all console + // close it temporary before connect all console
- // + //
- SEnvCloseConsoleProxy ( + SEnvCloseConsoleProxy (
- ST->ConsoleInHandle, + ST->ConsoleInHandle,
- &ST->ConIn, + &ST->ConIn,
- ST->ConsoleOutHandle, + ST->ConsoleOutHandle,
- &ST->ConOut + &ST->ConOut
- ); + );
}
SEnvConnectConsole ( - //
VarErrorOut, - // To prevent the proxy console form being restored to original console,
- &gEfiPrimaryStandardErrorDeviceGuid, - // close it temporary before connect all console
&gEfiSimpleTextOutProtocolGuid, - //
&ST->StandardErrorHandle, - SEnvCloseConsoleProxy (
(VOID **) &ST->StdErr - ST->ConsoleInHandle,
@@ -1227,7 +1234,6 @@ - &ST->ConIn,
- ST->ConsoleOutHandle,
SEnvConnectConsole ( - &ST->ConOut
VarConsoleOut, - );
- &gEfiPrimaryConsoleOutDeviceGuid,
&gEfiSimpleTextOutProtocolGuid, SEnvConnectConsole (
&ST->ConsoleOutHandle, VarErrorOut,
(VOID **) &ST->ConOut - &gEfiPrimaryStandardErrorDeviceGuid,
@@ -1235,7 +1241,6 @@ &gEfiSimpleTextOutProtocolGuid,
&ST->StandardErrorHandle,
SEnvConnectConsole ( (VOID **) &ST->StdErr
VarConsoleIn, @@ -1227,7 +1242,6 @@
- &gEfiPrimaryConsoleInDeviceGuid,
&gEfiSimpleTextInProtocolGuid, SEnvConnectConsole (
&ST->ConsoleInHandle, VarConsoleOut,
(VOID **) &ST->ConIn - &gEfiPrimaryConsoleOutDeviceGuid,
@@ -1254,6 +1259,8 @@ &gEfiSimpleTextOutProtocolGuid,
SetCrc (&ST->Hdr); &ST->ConsoleOutHandle,
} (VOID **) &ST->ConOut
@@ -1235,7 +1249,6 @@
+
+ SEnvConnectConsole (
EFI_STATUS VarConsoleIn,
EFIAPI - &gEfiPrimaryConsoleInDeviceGuid,
SEnvCmdReconnect ( &gEfiSimpleTextInProtocolGuid,
&ST->ConsoleInHandle,
(VOID **) &ST->ConIn
@@ -1254,6 +1267,8 @@
SetCrc (&ST->Hdr);
}
+
+
EFI_STATUS
EFIAPI
SEnvCmdReconnect (
Index: SmbiosView/PrintInfo.c Index: SmbiosView/PrintInfo.c
=================================================================== ===================================================================
--- SmbiosView/PrintInfo.c (revision 30) --- SmbiosView/PrintInfo.c (revision 30)