eric_tian | 804405e | 2008-06-30 05:08:49 +0000 | [diff] [blame] | 1 | /*++
|
| 2 |
|
hhtian | f9b8ab5 | 2010-04-28 12:31:45 +0000 | [diff] [blame] | 3 | Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
| 4 | This program and the accompanying materials
|
eric_tian | 804405e | 2008-06-30 05:08:49 +0000 | [diff] [blame] | 5 | are licensed and made available under the terms and conditions of the BSD License
|
| 6 | which accompanies this distribution. The full text of the license may be found at
|
| 7 | http://opensource.org/licenses/bsd-license.php
|
| 8 |
|
| 9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
| 10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
| 11 |
|
| 12 | Module Name:
|
| 13 |
|
| 14 | ComponentName.c
|
| 15 |
|
| 16 | Abstract:
|
| 17 |
|
| 18 | --*/
|
| 19 |
|
| 20 | #include "UnixBlockIo.h"
|
| 21 |
|
| 22 | //
|
| 23 | // EFI Component Name Functions
|
| 24 | //
|
| 25 | EFI_STATUS
|
| 26 | EFIAPI
|
| 27 | UnixBlockIoComponentNameGetDriverName (
|
| 28 | IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
| 29 | IN CHAR8 *Language,
|
| 30 | OUT CHAR16 **DriverName
|
| 31 | );
|
| 32 |
|
| 33 | EFI_STATUS
|
| 34 | EFIAPI
|
| 35 | UnixBlockIoComponentNameGetControllerName (
|
| 36 | IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
| 37 | IN EFI_HANDLE ControllerHandle,
|
| 38 | IN EFI_HANDLE ChildHandle OPTIONAL,
|
| 39 | IN CHAR8 *Language,
|
| 40 | OUT CHAR16 **ControllerName
|
| 41 | );
|
| 42 |
|
| 43 | //
|
| 44 | // EFI Component Name Protocol
|
| 45 | //
|
| 46 | EFI_COMPONENT_NAME_PROTOCOL gUnixBlockIoComponentName = {
|
| 47 | UnixBlockIoComponentNameGetDriverName,
|
| 48 | UnixBlockIoComponentNameGetControllerName,
|
| 49 | "eng"
|
| 50 | };
|
| 51 |
|
jji4 | 7492c63 | 2008-10-30 06:14:35 +0000 | [diff] [blame] | 52 | EFI_UNICODE_STRING_TABLE mUnixBlockIoDriverNameTable[] = {
|
eric_tian | 804405e | 2008-06-30 05:08:49 +0000 | [diff] [blame] | 53 | { "eng", L"Unix Block I/O Driver" },
|
| 54 | { NULL , NULL }
|
| 55 | };
|
| 56 |
|
| 57 | EFI_STATUS
|
| 58 | EFIAPI
|
| 59 | UnixBlockIoComponentNameGetDriverName (
|
| 60 | IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
| 61 | IN CHAR8 *Language,
|
| 62 | OUT CHAR16 **DriverName
|
| 63 | )
|
| 64 | /*++
|
| 65 |
|
| 66 | Routine Description:
|
| 67 | Retrieves a Unicode string that is the user readable name of the EFI Driver.
|
| 68 |
|
| 69 | Arguments:
|
| 70 | This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
|
| 71 | Language - A pointer to a three character ISO 639-2 language identifier.
|
| 72 | This is the language of the driver name that that the caller
|
| 73 | is requesting, and it must match one of the languages specified
|
| 74 | in SupportedLanguages. The number of languages supported by a
|
| 75 | driver is up to the driver writer.
|
| 76 | DriverName - A pointer to the Unicode string to return. This Unicode string
|
| 77 | is the name of the driver specified by This in the language
|
| 78 | specified by Language.
|
| 79 |
|
| 80 | Returns:
|
| 81 | EFI_SUCCESS - The Unicode string for the Driver specified by This
|
| 82 | and the language specified by Language was returned
|
| 83 | in DriverName.
|
| 84 | EFI_INVALID_PARAMETER - Language is NULL.
|
| 85 | EFI_INVALID_PARAMETER - DriverName is NULL.
|
| 86 | EFI_UNSUPPORTED - The driver specified by This does not support the
|
| 87 | language specified by Language.
|
| 88 |
|
| 89 | --*/
|
| 90 | {
|
| 91 | return LookupUnicodeString (
|
| 92 | Language,
|
| 93 | gUnixBlockIoComponentName.SupportedLanguages,
|
| 94 | mUnixBlockIoDriverNameTable,
|
| 95 | DriverName
|
| 96 | );
|
| 97 | }
|
| 98 |
|
| 99 | EFI_STATUS
|
| 100 | EFIAPI
|
| 101 | UnixBlockIoComponentNameGetControllerName (
|
| 102 | IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
| 103 | IN EFI_HANDLE ControllerHandle,
|
| 104 | IN EFI_HANDLE ChildHandle OPTIONAL,
|
| 105 | IN CHAR8 *Language,
|
| 106 | OUT CHAR16 **ControllerName
|
| 107 | )
|
| 108 | /*++
|
| 109 |
|
| 110 | Routine Description:
|
| 111 | Retrieves a Unicode string that is the user readable name of the controller
|
| 112 | that is being managed by an EFI Driver.
|
| 113 |
|
| 114 | Arguments:
|
| 115 | This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
|
| 116 | ControllerHandle - The handle of a controller that the driver specified by
|
| 117 | This is managing. This handle specifies the controller
|
| 118 | whose name is to be returned.
|
| 119 | ChildHandle - The handle of the child controller to retrieve the name
|
| 120 | of. This is an optional parameter that may be NULL. It
|
| 121 | will be NULL for device drivers. It will also be NULL
|
| 122 | for a bus drivers that wish to retrieve the name of the
|
| 123 | bus controller. It will not be NULL for a bus driver
|
| 124 | that wishes to retrieve the name of a child controller.
|
| 125 | Language - A pointer to a three character ISO 639-2 language
|
| 126 | identifier. This is the language of the controller name
|
| 127 | that that the caller is requesting, and it must match one
|
| 128 | of the languages specified in SupportedLanguages. The
|
| 129 | number of languages supported by a driver is up to the
|
| 130 | driver writer.
|
| 131 | ControllerName - A pointer to the Unicode string to return. This Unicode
|
| 132 | string is the name of the controller specified by
|
| 133 | ControllerHandle and ChildHandle in the language specified
|
| 134 | by Language from the point of view of the driver specified
|
| 135 | by This.
|
| 136 |
|
| 137 | Returns:
|
| 138 | EFI_SUCCESS - The Unicode string for the user readable name in the
|
| 139 | language specified by Language for the driver
|
| 140 | specified by This was returned in DriverName.
|
| 141 | EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
|
| 142 | EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
|
| 143 | EFI_INVALID_PARAMETER - Language is NULL.
|
| 144 | EFI_INVALID_PARAMETER - ControllerName is NULL.
|
| 145 | EFI_UNSUPPORTED - The driver specified by This is not currently managing
|
| 146 | the controller specified by ControllerHandle and
|
| 147 | ChildHandle.
|
| 148 | EFI_UNSUPPORTED - The driver specified by This does not support the
|
| 149 | language specified by Language.
|
| 150 |
|
| 151 | --*/
|
| 152 | {
|
| 153 | EFI_STATUS Status;
|
| 154 | EFI_BLOCK_IO_PROTOCOL *BlockIo;
|
| 155 | UNIX_BLOCK_IO_PRIVATE *Private;
|
| 156 |
|
| 157 | //
|
| 158 | // This is a device driver, so ChildHandle must be NULL.
|
| 159 | //
|
| 160 | if (ChildHandle != NULL) {
|
| 161 | return EFI_UNSUPPORTED;
|
| 162 | }
|
| 163 | //
|
| 164 | // Make sure this driver is currently managing ControllerHandle
|
| 165 | //
|
| 166 | Status = EfiTestManagedDevice (
|
| 167 | ControllerHandle,
|
| 168 | gUnixBlockIoDriverBinding.DriverBindingHandle,
|
| 169 | &gEfiUnixIoProtocolGuid
|
| 170 | );
|
| 171 | if (EFI_ERROR (Status)) {
|
| 172 | return EFI_UNSUPPORTED;
|
| 173 | }
|
| 174 | //
|
| 175 | // Get our context back
|
| 176 | //
|
| 177 | Status = gBS->OpenProtocol (
|
| 178 | ControllerHandle,
|
| 179 | &gEfiBlockIoProtocolGuid,
|
| 180 | (void *)&BlockIo,
|
| 181 | gUnixBlockIoDriverBinding.DriverBindingHandle,
|
| 182 | ControllerHandle,
|
| 183 | EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
| 184 | );
|
| 185 | if (EFI_ERROR (Status)) {
|
| 186 | return EFI_UNSUPPORTED;
|
| 187 | }
|
| 188 |
|
| 189 | Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo);
|
| 190 |
|
| 191 | return LookupUnicodeString (
|
| 192 | Language,
|
| 193 | gUnixBlockIoComponentName.SupportedLanguages,
|
| 194 | Private->ControllerNameTable,
|
| 195 | ControllerName
|
| 196 | );
|
| 197 | }
|