X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ShellPkg%2FApplication%2FShell%2FShellProtocol.c;h=e1aadb845d4eb7c49a971d9ba1919efced0c84f7;hp=19759cbb2bbbf5194a887f782b759818d9d7768d;hb=e3df6949e7e2a4578660d4079988487a147c91b7;hpb=c154b9970849127546f50481b586d61d78c9bbec diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index 19759cbb2b..e1aadb845d 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -2,7 +2,7 @@ Member functions of EFI_SHELL_PROTOCOL and functions for creation, manipulation, and initialization of EFI_SHELL_PROTOCOL. - Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
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 @@ -14,7 +14,6 @@ **/ #include "Shell.h" -#include /** Close an open file handle. @@ -37,6 +36,36 @@ EfiShellClose ( return (FileHandleClose(ConvertShellHandleToEfiFileProtocol(FileHandle))); } +/** + Internal worker to determine whether there is a BlockIo somewhere + upon the device path specified. + + @param[in] DevicePath The device path to test. + + @retval TRUE gEfiBlockIoProtocolGuid was installed on a handle with this device path + @retval FALSE gEfiBlockIoProtocolGuid was not found. +**/ +BOOLEAN +EFIAPI +InternalShellProtocolIsBlockIoPresent( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePathCopy; + EFI_STATUS Status; + EFI_HANDLE Handle; + + Handle = NULL; + + DevicePathCopy = (EFI_DEVICE_PATH_PROTOCOL*)DevicePath; + Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &DevicePathCopy, &Handle); + + if ((Handle != NULL) && (!EFI_ERROR(Status))) { + return (TRUE); + } + return (FALSE); +} + /** Internal worker to determine whether there is a file system somewhere upon the device path specified. @@ -86,27 +115,19 @@ InternalShellProtocolDebugPrintMessage ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { - EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevicePathToText; EFI_STATUS Status; CHAR16 *Temp; Status = EFI_SUCCESS; DEBUG_CODE_BEGIN(); - DevicePathToText = NULL; - Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, - NULL, - (VOID**)&DevicePathToText); if (Mapping != NULL) { DEBUG((EFI_D_INFO, "Added new map item:\"%S\"\r\n", Mapping)); } - if (!EFI_ERROR(Status)) { - if (DevicePath != NULL) { - Temp = DevicePathToText->ConvertDevicePathToText(DevicePath, TRUE, TRUE); - DEBUG((EFI_D_INFO, "DevicePath: %S\r\n", Temp)); - FreePool(Temp); - } - } + Temp = ConvertDevicePathToText(DevicePath, TRUE, TRUE); + DEBUG((EFI_D_INFO, "DevicePath: %S\r\n", Temp)); + FreePool(Temp); + DEBUG_CODE_END(); return (Status); } @@ -176,7 +197,8 @@ EfiShellSetMap( // make sure this is a valid to add device path // ///@todo add BlockIo to this test... - if (!InternalShellProtocolIsSimpleFileSystemPresent(DevicePath)) { + if (!InternalShellProtocolIsSimpleFileSystemPresent(DevicePath) + && !InternalShellProtocolIsBlockIoPresent(DevicePath)) { return (EFI_INVALID_PARAMETER); } @@ -457,10 +479,12 @@ EfiShellGetFilePathFromDevicePath( This function converts a file system style name to a device path, by replacing any mapping references to the associated device path. - @param Path the pointer to the path + @param[in] Path The pointer to the path. - @return all The pointer of the file path. The file path is callee + @return The pointer of the file path. The file path is callee allocated and should be freed by the caller. + @retval NULL The path could not be found. + @retval NULL There was not enough available memory. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI @@ -494,12 +518,13 @@ EfiShellGetDevicePathFromFilePath( Size = StrSize(Cwd); Size += StrSize(Path); NewPath = AllocateZeroPool(Size); - ASSERT(NewPath != NULL); + if (NewPath == NULL) { + return (NULL); + } StrCpy(NewPath, Cwd); - if ((Path[0] == (CHAR16)L'\\') && - (NewPath[StrLen(NewPath)-1] == (CHAR16)L'\\') - ) { - ((CHAR16*)NewPath)[StrLen(NewPath)-1] = CHAR_NULL; + if (*Path == L'\\') { + Path++; + while (PathRemoveLastItem(NewPath)) ; } StrCat(NewPath, Path); DevicePathForReturn = EfiShellGetDevicePathFromFilePath(NewPath); @@ -513,8 +538,7 @@ EfiShellGetDevicePathFromFilePath( // ASSERT((MapName == NULL && Size == 0) || (MapName != NULL)); MapName = StrnCatGrow(&MapName, &Size, Path, (StrStr(Path, L":")-Path+1)); - if (MapName[StrLen(MapName)-1] != L':') { - ASSERT(FALSE); + if (MapName == NULL || MapName[StrLen(MapName)-1] != L':') { return (NULL); } @@ -534,7 +558,6 @@ EfiShellGetDevicePathFromFilePath( // DevicePathCopyForFree = DevicePathCopy = DuplicateDevicePath(DevicePath); if (DevicePathCopy == NULL) { - ASSERT(FALSE); FreePool(MapName); return (NULL); } @@ -555,7 +578,11 @@ EfiShellGetDevicePathFromFilePath( // // build the full device path // - DevicePathForReturn = FileDevicePath(Handle, Path+StrLen(MapName)+1); + if (*(Path+StrLen(MapName)+1) == CHAR_NULL) { + DevicePathForReturn = FileDevicePath(Handle, L"\\"); + } else { + DevicePathForReturn = FileDevicePath(Handle, Path+StrLen(MapName)); + } FreePool(MapName); if (DevicePathCopyForFree != NULL) { @@ -612,7 +639,6 @@ EfiShellGetDeviceName( { EFI_STATUS Status; EFI_COMPONENT_NAME2_PROTOCOL *CompName2; - EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevicePathToText; EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_HANDLE *HandleList; UINTN HandleCount; @@ -621,6 +647,11 @@ EfiShellGetDeviceName( CHAR8 *Lang; CHAR8 *TempChar; + UINTN ParentControllerCount; + EFI_HANDLE *ParentControllerBuffer; + UINTN ParentDriverCount; + EFI_HANDLE *ParentDriverBuffer; + if (BestDeviceName == NULL || DeviceHandle == NULL ){ @@ -673,7 +704,7 @@ EfiShellGetDeviceName( continue; } if (Language == NULL) { - Lang = AllocatePool(AsciiStrSize(CompName2->SupportedLanguages)); + Lang = AllocateZeroPool(AsciiStrSize(CompName2->SupportedLanguages)); if (Lang == NULL) { return (EFI_OUT_OF_RESOURCES); } @@ -683,7 +714,7 @@ EfiShellGetDeviceName( *TempChar = CHAR_NULL; } } else { - Lang = AllocatePool(AsciiStrSize(Language)); + Lang = AllocateZeroPool(AsciiStrSize(Language)); if (Lang == NULL) { return (EFI_OUT_OF_RESOURCES); } @@ -699,38 +730,95 @@ EfiShellGetDeviceName( if (HandleList != NULL) { FreePool(HandleList); } + + // + // Now check the parent controller using this as the child. + // + if (DeviceNameToReturn == NULL){ + PARSE_HANDLE_DATABASE_PARENTS(DeviceHandle, &ParentControllerCount, &ParentControllerBuffer); + for (LoopVar = 0 ; LoopVar < ParentControllerCount ; LoopVar++) { + PARSE_HANDLE_DATABASE_UEFI_DRIVERS(ParentControllerBuffer[LoopVar], &ParentDriverCount, &ParentDriverBuffer); + for (HandleCount = 0 ; HandleCount < ParentDriverCount ; HandleCount++) { + // + // try using that driver's component name with controller and our driver as the child. + // + Status = gBS->OpenProtocol( + ParentDriverBuffer[HandleCount], + &gEfiComponentName2ProtocolGuid, + (VOID**)&CompName2, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (EFI_ERROR(Status)) { + Status = gBS->OpenProtocol( + ParentDriverBuffer[HandleCount], + &gEfiComponentNameProtocolGuid, + (VOID**)&CompName2, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + } + + if (EFI_ERROR(Status)) { + continue; + } + if (Language == NULL) { + Lang = AllocateZeroPool(AsciiStrSize(CompName2->SupportedLanguages)); + if (Lang == NULL) { + return (EFI_OUT_OF_RESOURCES); + } + AsciiStrCpy(Lang, CompName2->SupportedLanguages); + TempChar = AsciiStrStr(Lang, ";"); + if (TempChar != NULL){ + *TempChar = CHAR_NULL; + } + } else { + Lang = AllocateZeroPool(AsciiStrSize(Language)); + if (Lang == NULL) { + return (EFI_OUT_OF_RESOURCES); + } + AsciiStrCpy(Lang, Language); + } + Status = CompName2->GetControllerName(CompName2, ParentControllerBuffer[LoopVar], DeviceHandle, Lang, &DeviceNameToReturn); + FreePool(Lang); + Lang = NULL; + if (!EFI_ERROR(Status) && DeviceNameToReturn != NULL) { + break; + } + + + + } + SHELL_FREE_NON_NULL(ParentDriverBuffer); + if (!EFI_ERROR(Status) && DeviceNameToReturn != NULL) { + break; + } + } + SHELL_FREE_NON_NULL(ParentControllerBuffer); + } + // + // dont return on fail since we will try device path if that bit is on + // if (DeviceNameToReturn != NULL){ ASSERT(BestDeviceName != NULL); StrnCatGrow(BestDeviceName, NULL, DeviceNameToReturn, 0); return (EFI_SUCCESS); } - // - // dont return on fail since we will try device path if that bit is on - // } if ((Flags & EFI_DEVICE_NAME_USE_DEVICE_PATH) != 0) { - Status = gBS->LocateProtocol( - &gEfiDevicePathToTextProtocolGuid, + Status = gBS->OpenProtocol( + DeviceHandle, + &gEfiDevicePathProtocolGuid, + (VOID**)&DevicePath, + gImageHandle, NULL, - (VOID**)&DevicePathToText); - // - // we now have the device path to text protocol - // + EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (!EFI_ERROR(Status)) { - Status = gBS->OpenProtocol( - DeviceHandle, - &gEfiDevicePathProtocolGuid, - (VOID**)&DevicePath, - gImageHandle, - NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (!EFI_ERROR(Status)) { - // - // use device path to text on the device path - // - *BestDeviceName = DevicePathToText->ConvertDevicePathToText(DevicePath, TRUE, TRUE); - return (EFI_SUCCESS); - } + // + // use device path to text on the device path + // + *BestDeviceName = ConvertDevicePathToText(DevicePath, TRUE, TRUE); + return (EFI_SUCCESS); } } // @@ -888,7 +976,6 @@ InternalOpenFileDevicePath( SHELL_FILE_HANDLE ShellHandle; EFI_FILE_PROTOCOL *Handle1; EFI_FILE_PROTOCOL *Handle2; - EFI_DEVICE_PATH_PROTOCOL *DpCopy; FILEPATH_DEVICE_PATH *AlignedNode; if (FileHandle == NULL) { @@ -898,7 +985,6 @@ InternalOpenFileDevicePath( Handle1 = NULL; Handle2 = NULL; Handle = NULL; - DpCopy = DevicePath; ShellHandle = NULL; FilePathNode = NULL; AlignedNode = NULL; @@ -1479,18 +1565,18 @@ EfiShellExecute( DevPath = AppendDevicePath (ShellInfoObject.ImageDevPath, ShellInfoObject.FileDevPath); DEBUG_CODE_BEGIN(); - Temp = gDevPathToText->ConvertDevicePathToText(ShellInfoObject.FileDevPath, TRUE, TRUE); + Temp = ConvertDevicePathToText(ShellInfoObject.FileDevPath, TRUE, TRUE); FreePool(Temp); - Temp = gDevPathToText->ConvertDevicePathToText(ShellInfoObject.ImageDevPath, TRUE, TRUE); + Temp = ConvertDevicePathToText(ShellInfoObject.ImageDevPath, TRUE, TRUE); FreePool(Temp); - Temp = gDevPathToText->ConvertDevicePathToText(DevPath, TRUE, TRUE); + Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE); FreePool(Temp); DEBUG_CODE_END(); Temp = NULL; Size = 0; ASSERT((Temp == NULL && Size == 0) || (Temp != NULL)); - StrnCatGrow(&Temp, &Size, L"Shell.efi ", 0); + StrnCatGrow(&Temp, &Size, L"Shell.efi -_exit ", 0); StrnCatGrow(&Temp, &Size, CommandLine, 0); Status = InternalShellExecuteDevicePath( @@ -1630,14 +1716,14 @@ InternalDuplicateShellFileInfo( { EFI_SHELL_FILE_INFO *NewNode; - NewNode = AllocatePool(sizeof(EFI_SHELL_FILE_INFO)); + NewNode = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO)); if (NewNode == NULL) { return (NULL); } NewNode->FullName = AllocateZeroPool(StrSize(Node->FullName)); NewNode->FileName = AllocateZeroPool(StrSize(Node->FileName)); - NewNode->Info = AllocatePool((UINTN)Node->Info->Size); + NewNode->Info = AllocateZeroPool((UINTN)Node->Info->Size); if ( NewNode->FullName == NULL || NewNode->FileName == NULL || NewNode->Info == NULL @@ -1692,7 +1778,7 @@ CreateAndPopulateShellFileInfo( if (ShellFileListItem == NULL) { return (NULL); } - if (Info != NULL) { + if (Info != NULL && Info->Size != 0) { ShellFileListItem->Info = AllocateZeroPool((UINTN)Info->Size); if (ShellFileListItem->Info == NULL) { FreePool(ShellFileListItem); @@ -1783,6 +1869,9 @@ EfiShellFindFilesInDir( TempString = NULL; Size = 0; TempString = StrnCatGrow(&TempString, &Size, ShellFileHandleGetPath(FileDirHandle), 0); + if (TempString == NULL) { + return (EFI_OUT_OF_RESOURCES); + } TempSpot = StrStr(TempString, L";"); if (TempSpot != NULL) { @@ -1790,6 +1879,9 @@ EfiShellFindFilesInDir( } TempString = StrnCatGrow(&TempString, &Size, BasePath, 0); + if (TempString == NULL) { + return (EFI_OUT_OF_RESOURCES); + } BasePath = TempString; } @@ -1840,8 +1932,8 @@ EfiShellFindFilesInDir( /** Updates a file name to be preceeded by the mapped drive name - @param[in] BasePath the Mapped drive name to prepend - @param[in,out] Path pointer to pointer to the file name to update. + @param[in] BasePath the Mapped drive name to prepend + @param[in, out] Path pointer to pointer to the file name to update. @retval EFI_SUCCESS @retval EFI_OUT_OF_RESOURCES @@ -1896,12 +1988,12 @@ UpdateFileName( Upon a EFI_SUCCESS return fromt he function any the caller is responsible to call FreeFileList with FileList. - @param[in] FilePattern The FilePattern to check against. - @param[in] UnicodeCollation The pointer to EFI_UNICODE_COLLATION_PROTOCOL structure - @param[in] FileHandle The FileHandle to start with - @param[in,out] FileList pointer to pointer to list of found files. - @param[in] ParentNode The node for the parent. Same file as identified by HANDLE. - @param[in] MapName The file system name this file is on. + @param[in] FilePattern The FilePattern to check against. + @param[in] UnicodeCollation The pointer to EFI_UNICODE_COLLATION_PROTOCOL structure + @param[in] FileHandle The FileHandle to start with + @param[in, out] FileList pointer to pointer to list of found files. + @param[in] ParentNode The node for the parent. Same file as identified by HANDLE. + @param[in] MapName The file system name this file is on. @retval EFI_SUCCESS all files were found and the FileList contains a list. @retval EFI_NOT_FOUND no files were found @@ -1964,7 +2056,7 @@ ShellSearchHandle( } else { NewShellNode->Handle = NULL; if (*FileList == NULL) { - *FileList = AllocatePool(sizeof(EFI_SHELL_FILE_INFO)); + *FileList = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO)); InitializeListHead(&((*FileList)->Link)); } @@ -2044,7 +2136,7 @@ ShellSearchHandle( Status = EFI_OUT_OF_RESOURCES; } if (*FileList == NULL) { - *FileList = AllocatePool(sizeof(EFI_SHELL_FILE_INFO)); + *FileList = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO)); InitializeListHead(&((*FileList)->Link)); } @@ -2121,21 +2213,22 @@ EfiShellFindFiles( RootDevicePath = NULL; RootFileHandle = NULL; MapName = NULL; - PatternCopy = AllocatePool(StrSize(FilePattern)); + PatternCopy = AllocateZeroPool(StrSize(FilePattern)); if (PatternCopy == NULL) { return (EFI_OUT_OF_RESOURCES); } StrCpy(PatternCopy, FilePattern); - PatternCopy = CleanPath(PatternCopy); + PatternCopy = PathCleanUpDirectories(PatternCopy); Count = StrStr(PatternCopy, L":") - PatternCopy; Count += 2; ASSERT(MapName == NULL); MapName = StrnCatGrow(&MapName, NULL, PatternCopy, Count); - - if (!EFI_ERROR(Status)) { + if (MapName == NULL) { + Status = EFI_OUT_OF_RESOURCES; + } else { RootDevicePath = EfiShellGetDevicePathFromFilePath(PatternCopy); if (RootDevicePath == NULL) { Status = EFI_INVALID_PARAMETER; @@ -2186,17 +2279,19 @@ EfiShellOpenFileList( CHAR16 *Path2; UINTN Path2Size; CONST CHAR16 *CurDir; + BOOLEAN Found; - ShellCommandCleanPath(Path); + PathCleanUpDirectories(Path); Path2Size = 0; Path2 = NULL; - ASSERT(FileList != NULL); - ASSERT(*FileList != NULL); + if (FileList == NULL || *FileList == NULL) { + return (EFI_INVALID_PARAMETER); + } if (*Path == L'.' && *(Path+1) == L'\\') { - Path++; + Path+=2; } // @@ -2208,6 +2303,7 @@ EfiShellOpenFileList( StrnCatGrow(&Path2, &Path2Size, CurDir, 0); if (*Path == L'\\') { Path++; + while (PathRemoveLastItem(Path2)) ; } ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL)); StrnCatGrow(&Path2, &Path2Size, Path, 0); @@ -2216,7 +2312,7 @@ EfiShellOpenFileList( StrnCatGrow(&Path2, NULL, Path, 0); } - CleanPath (Path2); + PathCleanUpDirectories (Path2); // // do the search @@ -2229,6 +2325,7 @@ EfiShellOpenFileList( return (Status); } + Found = FALSE; // // We had no errors so open all the files (that are not already opened...) // @@ -2238,9 +2335,13 @@ EfiShellOpenFileList( ){ if (ShellFileListItem->Status == 0 && ShellFileListItem->Handle == NULL) { ShellFileListItem->Status = EfiShellOpenFileByName (ShellFileListItem->FullName, &ShellFileListItem->Handle, OpenMode); + Found = TRUE; } } + if (!Found) { + return (EFI_NOT_FOUND); + } return(EFI_SUCCESS); } @@ -2564,7 +2665,7 @@ EfiShellSetCurDir( DirectoryName = StrnCatGrow(&DirectoryName, NULL, Dir, 0); ASSERT(DirectoryName != NULL); - CleanPath(DirectoryName); + PathCleanUpDirectories(DirectoryName); if (FileSystem == NULL) { // @@ -2646,7 +2747,7 @@ EfiShellSetCurDir( MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0); ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL)); MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0); - if (MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') { + if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') { ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL)); MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0); } @@ -2771,7 +2872,6 @@ InternalEfiShellGetListAlias( UINTN NameSize; CHAR16 *RetVal; UINTN RetSize; - CHAR16 *Alias; Status = gRT->QueryVariableInfo(EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, &MaxStorSize, &RemStorSize, &MaxVarSize); ASSERT_EFI_ERROR(Status); @@ -2797,7 +2897,6 @@ InternalEfiShellGetListAlias( break; } if (CompareGuid(&Guid, &gShellAliasGuid)){ - Alias = GetVariable(VariableName, &gShellAliasGuid); ASSERT((RetVal == NULL && RetSize == 0) || (RetVal != NULL)); RetVal = StrnCatGrow(&RetVal, &RetSize, VariableName, 0); RetVal = StrnCatGrow(&RetVal, &RetSize, L";", 0); @@ -3011,7 +3110,7 @@ EFI_SHELL_PROTOCOL mShellProtocol = { This must be removed via calling CleanUpShellProtocol(). - @param[in,out] NewShell The pointer to the pointer to the structure + @param[in, out] NewShell The pointer to the pointer to the structure to install. @retval EFI_SUCCESS The operation was successful. @@ -3140,7 +3239,7 @@ CreatePopulateInstallShellProtocol ( Free all memory and restore the system to the state it was in before calling CreatePopulateInstallShellProtocol. - @param[in,out] NewShell The pointer to the new shell protocol structure. + @param[in, out] NewShell The pointer to the new shell protocol structure. @retval EFI_SUCCESS The operation was successful. **/ @@ -3188,9 +3287,16 @@ CleanUpShellProtocol ( NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle1); - Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle2); - + if (!EFI_ERROR (Status)) { + Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle1); + Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle2); + Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle3); + Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle4); + Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlSNotifyHandle1); + Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlSNotifyHandle2); + Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlSNotifyHandle3); + Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlSNotifyHandle4); + } return (Status); } @@ -3207,10 +3313,27 @@ NotificationFunction( IN EFI_KEY_DATA *KeyData ) { - if (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak == NULL) { - return (EFI_UNSUPPORTED); + EFI_INPUT_KEY Key; + if ( ((KeyData->Key.UnicodeChar == L'c') && + (KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED))) || + (KeyData->Key.UnicodeChar == 3) + ){ + if (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak == NULL) { + return (EFI_UNSUPPORTED); + } + return (gBS->SignalEvent(ShellInfoObject.NewEfiShellProtocol->ExecutionBreak)); + } else if ((KeyData->Key.UnicodeChar == L's') && + (KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED)) + ){ + ShellInfoObject.HaltOutput = TRUE; + + // + // Make sure that there are no pending keystrokes to pervent the pause. + // + gST->ConIn->Reset(gST->ConIn, FALSE); + while (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key)==EFI_SUCCESS); } - return (gBS->SignalEvent(ShellInfoObject.NewEfiShellProtocol->ExecutionBreak)); + return (EFI_SUCCESS); } /**