From c7916981cc01e37d189e1802463fa68d10a17bf2 Mon Sep 17 00:00:00 2001 From: xgu3 Date: Fri, 26 Jan 2007 08:35:57 +0000 Subject: [PATCH] To fix, cd ...... works unnormally in shell USB CBI1 driver has no component name protocol git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2328 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Bus/Usb/UsbCbi/Dxe/Cbi1/ComponentName.c | 204 ++++++++++++++++++ .../Bus/Usb/UsbCbi/Dxe/Cbi1/UsbCbi1.msa | 6 +- EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/cbi1.c | 12 +- .../SimpleFileSystem/WinNtSimpleFileSystem.c | 35 ++- 4 files changed, 252 insertions(+), 5 deletions(-) create mode 100644 EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/ComponentName.c diff --git a/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/ComponentName.c b/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/ComponentName.c new file mode 100644 index 0000000000..f8485dd734 --- /dev/null +++ b/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/ComponentName.c @@ -0,0 +1,204 @@ +/*++ + +Copyright (c) 2006, 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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ComponentName.c + +Abstract: + +--*/ + +#include "cbi.h" + +extern EFI_DRIVER_BINDING_PROTOCOL gUsbCbi1DriverBinding; + +// +// EFI Component Name Functions +// +EFI_STATUS +EFIAPI +UsbCbi1ComponentNameGetDriverName ( + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName + ); + +EFI_STATUS +EFIAPI +UsbCbi1ComponentNameGetControllerName ( + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName + ); + +// +// EFI Component Name Protocol +// +EFI_COMPONENT_NAME_PROTOCOL gUsbCbi1ComponentName = { + UsbCbi1ComponentNameGetDriverName, + UsbCbi1ComponentNameGetControllerName, + "eng" +}; + +STATIC EFI_UNICODE_STRING_TABLE mUsbCbi1DriverNameTable[] = { + { "eng", (CHAR16 *) L"Usb Cbi1 Mass Storage Driver" }, + { NULL , NULL } +}; + + +EFI_STATUS +EFIAPI +UsbCbi1ComponentNameGetDriverName ( + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName + ) +/*++ + + Routine Description: + Retrieves a Unicode string that is the user readable name of the EFI Driver. + + Arguments: + This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. + Language - A pointer to a three character ISO 639-2 language identifier. + This is the language of the driver name that that the caller + is requesting, and it must match one of the languages specified + in SupportedLanguages. The number of languages supported by a + driver is up to the driver writer. + DriverName - A pointer to the Unicode string to return. This Unicode string + is the name of the driver specified by This in the language + specified by Language. + + Returns: + EFI_SUCCESS - The Unicode string for the Driver specified by This + and the language specified by Language was returned + in DriverName. + EFI_INVALID_PARAMETER - Language is NULL. + EFI_INVALID_PARAMETER - DriverName is NULL. + EFI_UNSUPPORTED - The driver specified by This does not support the + language specified by Language. + +--*/ +{ + return LookupUnicodeString ( + Language, + gUsbCbi1ComponentName.SupportedLanguages, + mUsbCbi1DriverNameTable, + DriverName + ); +} + +EFI_STATUS +EFIAPI +UsbCbi1ComponentNameGetControllerName ( + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName + ) +/*++ + + Routine Description: + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by an EFI Driver. + + Arguments: + This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. + ControllerHandle - The handle of a controller that the driver specified by + This is managing. This handle specifies the controller + whose name is to be returned. + ChildHandle - The handle of the child controller to retrieve the name + of. This is an optional parameter that may be NULL. It + will be NULL for device drivers. It will also be NULL + for a bus drivers that wish to retrieve the name of the + bus controller. It will not be NULL for a bus driver + that wishes to retrieve the name of a child controller. + Language - A pointer to a three character ISO 639-2 language + identifier. This is the language of the controller name + that that the caller is requesting, and it must match one + of the languages specified in SupportedLanguages. The + number of languages supported by a driver is up to the + driver writer. + ControllerName - A pointer to the Unicode string to return. This Unicode + string is the name of the controller specified by + ControllerHandle and ChildHandle in the language specified + by Language from the point of view of the driver specified + by This. + + Returns: + EFI_SUCCESS - The Unicode string for the user readable name in the + language specified by Language for the driver + specified by This was returned in DriverName. + EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. + EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE. + EFI_INVALID_PARAMETER - Language is NULL. + EFI_INVALID_PARAMETER - ControllerName is NULL. + EFI_UNSUPPORTED - The driver specified by This is not currently managing + the controller specified by ControllerHandle and + ChildHandle. + EFI_UNSUPPORTED - The driver specified by This does not support the + language specified by Language. + +--*/ +{ + EFI_STATUS Status; + USB_CBI_DEVICE *UsbCbiDev; + EFI_USB_ATAPI_PROTOCOL *UsbAtapi; + + // + // This is a device driver, so ChildHandle must be NULL. + // + if (ChildHandle != NULL) { + return EFI_UNSUPPORTED; + } + + // + // Make sure this driver is currently managing ControllerHandle + // + Status = EfiTestManagedDevice ( + ControllerHandle, + gUsbCbi1DriverBinding.DriverBindingHandle, + &gEfiUsbIoProtocolGuid + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Get the device context + // + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiUsbAtapiProtocolGuid, + (VOID **) &UsbAtapi, + gUsbCbi1DriverBinding.DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + UsbCbiDev = USB_CBI_DEVICE_FROM_THIS (UsbAtapi); + + return LookupUnicodeString ( + Language, + gUsbCbi1ComponentName.SupportedLanguages, + UsbCbiDev->ControllerNameTable, + ControllerName + ); + +} diff --git a/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/UsbCbi1.msa b/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/UsbCbi1.msa index d21cb776a4..2a0a86b8ae 100644 --- a/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/UsbCbi1.msa +++ b/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/UsbCbi1.msa @@ -1,4 +1,4 @@ - + UsbCbi1 @@ -56,6 +56,7 @@ cbi.h cbi1.c + ComponentName.c @@ -76,7 +77,8 @@ EFI_SPECIFICATION_VERSION 0x00020000 EDK_RELEASE_VERSION 0x00020000 - gCBI1DriverBinding + gUsbCbi1DriverBinding + gUsbCbi1ComponentName diff --git a/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/cbi1.c b/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/cbi1.c index 008627b9dd..d8ef374c9f 100644 --- a/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/cbi1.c +++ b/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/cbi1.c @@ -20,6 +20,8 @@ Abstract: #include "cbi.h" +extern EFI_COMPONENT_NAME_PROTOCOL gUsbCbi1ComponentName; + EFI_STATUS EFIAPI UsbCBI1DriverEntryPoint ( @@ -113,7 +115,7 @@ Cbi1ReportStatusCode ( ); -EFI_DRIVER_BINDING_PROTOCOL gCBI1DriverBinding = { +EFI_DRIVER_BINDING_PROTOCOL gUsbCbi1DriverBinding = { CBI1DriverBindingSupported, CBI1DriverBindingStart, CBI1DriverBindingStop, @@ -352,6 +354,14 @@ CBI1DriverBindingStart ( goto ErrorExit; } + UsbCbiDev->ControllerNameTable = NULL; + AddUnicodeString ( + "eng", + gUsbCbi1ComponentName.SupportedLanguages, + &UsbCbiDev->ControllerNameTable, + (CHAR16 *) L"Usb Cbi1 Mass Storage" + ); + return EFI_SUCCESS; ErrorExit: diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c index bea7de40f8..30f5476d5a 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c @@ -688,6 +688,32 @@ OpenRoot: FileName[StrLen (FileName) - 1] = 0; } + // + // If file name does not equal to "." or "..", + // then we trim the leading/trailing blanks and trailing dots + // + if (StrCmp (FileName, L".") != 0 && StrCmp (FileName, L"..") != 0) { + // + // Trim leading blanks + // + Count = 0; + for (TempFileName = FileName; + *TempFileName != 0 && *TempFileName == L' '; + TempFileName++) { + Count++; + } + CutPrefix (FileName, Count); + // + // Trim trailing dots and blanks + // + for (TempFileName = FileName + StrLen (FileName) - 1; + TempFileName >= FileName && (*TempFileName == L' ' || *TempFileName == L'.'); + TempFileName--) { + ; + } + *(TempFileName + 1) = 0; + } + // // Attempt to open the file // @@ -738,8 +764,13 @@ OpenRoot: StrCat (NewPrivateFile->FileName, FileName + 1); } else { StrCpy (NewPrivateFile->FileName, NewPrivateFile->FilePath); - StrCat (NewPrivateFile->FileName, L"\\"); - StrCat (NewPrivateFile->FileName, FileName); + if (StrCmp (FileName, L"") != 0) { + // + // In case the filename becomes empty, especially after trimming dots and blanks + // + StrCat (NewPrivateFile->FileName, L"\\"); + StrCat (NewPrivateFile->FileName, FileName); + } } // -- 2.39.2