mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
b4667b1105
commit
c7916981cc
|
@ -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
|
||||
);
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
|
||||
<MsaHeader>
|
||||
<ModuleName>UsbCbi1</ModuleName>
|
||||
|
@ -56,6 +56,7 @@
|
|||
<SourceFiles>
|
||||
<Filename>cbi.h</Filename>
|
||||
<Filename>cbi1.c</Filename>
|
||||
<Filename>ComponentName.c</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
|
@ -76,7 +77,8 @@
|
|||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
<Extern>
|
||||
<DriverBinding>gCBI1DriverBinding</DriverBinding>
|
||||
<DriverBinding>gUsbCbi1DriverBinding</DriverBinding>
|
||||
<ComponentName>gUsbCbi1ComponentName</ComponentName>
|
||||
</Extern>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,9 +764,14 @@ OpenRoot:
|
|||
StrCat (NewPrivateFile->FileName, FileName + 1);
|
||||
} else {
|
||||
StrCpy (NewPrivateFile->FileName, NewPrivateFile->FilePath);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Get rid of . and .., except leading . or ..
|
||||
|
|
Loading…
Reference in New Issue