]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Ata/AtaBusDxe/ComponentName.c
7ffa5380e08c52fc765f130d995e3f9660ffe73e
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaBusDxe / ComponentName.c
1 /** @file
2 UEFI Component Name(2) protocol implementation for ConPlatform driver.
3
4 Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "AtaBus.h"
16
17 //
18 // Driver name table
19 //
20 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusDriverNameTable[] = {
21 { "eng;en", L"ATA Bus Driver" },
22 { NULL , NULL }
23 };
24
25 //
26 // Controller name table
27 //
28 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusControllerNameTable[] = {
29 { "eng;en", L"ATA Controller" },
30 { NULL , NULL }
31 };
32
33
34 //
35 // EFI Component Name Protocol
36 //
37 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gAtaBusComponentName = {
38 AtaBusComponentNameGetDriverName,
39 AtaBusComponentNameGetControllerName,
40 "eng"
41 };
42
43 //
44 // EFI Component Name 2 Protocol
45 //
46 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gAtaBusComponentName2 = {
47 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) AtaBusComponentNameGetDriverName,
48 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) AtaBusComponentNameGetControllerName,
49 "en"
50 };
51
52 /**
53 Retrieves a Unicode string that is the user readable name of the driver.
54
55 This function retrieves the user readable name of a driver in the form of a
56 Unicode string. If the driver specified by This has a user readable name in
57 the language specified by Language, then a pointer to the driver name is
58 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
59 by This does not support the language specified by Language,
60 then EFI_UNSUPPORTED is returned.
61
62 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
63 EFI_COMPONENT_NAME_PROTOCOL instance.
64
65 @param Language[in] A pointer to a Null-terminated ASCII string
66 array indicating the language. This is the
67 language of the driver name that the caller is
68 requesting, and it must match one of the
69 languages specified in SupportedLanguages. The
70 number of languages supported by a driver is up
71 to the driver writer. Language is specified
72 in RFC 4646 or ISO 639-2 language code format.
73
74 @param DriverName[out] A pointer to the Unicode string to return.
75 This Unicode string is the name of the
76 driver specified by This in the language
77 specified by Language.
78
79 @retval EFI_SUCCESS The Unicode string for the Driver specified by
80 This and the language specified by Language was
81 returned in DriverName.
82
83 @retval EFI_INVALID_PARAMETER Language is NULL.
84
85 @retval EFI_INVALID_PARAMETER DriverName is NULL.
86
87 @retval EFI_UNSUPPORTED The driver specified by This does not support
88 the language specified by Language.
89
90 **/
91 EFI_STATUS
92 EFIAPI
93 AtaBusComponentNameGetDriverName (
94 IN EFI_COMPONENT_NAME_PROTOCOL *This,
95 IN CHAR8 *Language,
96 OUT CHAR16 **DriverName
97 )
98 {
99 return LookupUnicodeString2 (
100 Language,
101 This->SupportedLanguages,
102 mAtaBusDriverNameTable,
103 DriverName,
104 (BOOLEAN)(This == &gAtaBusComponentName)
105 );
106 }
107
108
109 /**
110 Retrieves a Unicode string that is the user readable name of the controller
111 that is being managed by a driver.
112
113 This function retrieves the user readable name of the controller specified by
114 ControllerHandle and ChildHandle in the form of a Unicode string. If the
115 driver specified by This has a user readable name in the language specified by
116 Language, then a pointer to the controller name is returned in ControllerName,
117 and EFI_SUCCESS is returned. If the driver specified by This is not currently
118 managing the controller specified by ControllerHandle and ChildHandle,
119 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
120 support the language specified by Language, then EFI_UNSUPPORTED is returned.
121
122 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
123 EFI_COMPONENT_NAME_PROTOCOL instance.
124
125 @param ControllerHandle[in] The handle of a controller that the driver
126 specified by This is managing. This handle
127 specifies the controller whose name is to be
128 returned.
129
130 @param ChildHandle[in] The handle of the child controller to retrieve
131 the name of. This is an optional parameter that
132 may be NULL. It will be NULL for device
133 drivers. It will also be NULL for a bus drivers
134 that wish to retrieve the name of the bus
135 controller. It will not be NULL for a bus
136 driver that wishes to retrieve the name of a
137 child controller.
138
139 @param Language[in] A pointer to a Null-terminated ASCII string
140 array indicating the language. This is the
141 language of the driver name that the caller is
142 requesting, and it must match one of the
143 languages specified in SupportedLanguages. The
144 number of languages supported by a driver is up
145 to the driver writer. Language is specified in
146 RFC 4646 or ISO 639-2 language code format.
147
148 @param ControllerName[out] A pointer to the Unicode string to return.
149 This Unicode string is the name of the
150 controller specified by ControllerHandle and
151 ChildHandle in the language specified by
152 Language from the point of view of the driver
153 specified by This.
154
155 @retval EFI_SUCCESS The Unicode string for the user readable name in
156 the language specified by Language for the
157 driver specified by This was returned in
158 DriverName.
159
160 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
161
162 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
163 EFI_HANDLE.
164
165 @retval EFI_INVALID_PARAMETER Language is NULL.
166
167 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
168
169 @retval EFI_UNSUPPORTED The driver specified by This is not currently
170 managing the controller specified by
171 ControllerHandle and ChildHandle.
172
173 @retval EFI_UNSUPPORTED The driver specified by This does not support
174 the language specified by Language.
175
176 **/
177 EFI_STATUS
178 EFIAPI
179 AtaBusComponentNameGetControllerName (
180 IN EFI_COMPONENT_NAME_PROTOCOL *This,
181 IN EFI_HANDLE ControllerHandle,
182 IN EFI_HANDLE ChildHandle OPTIONAL,
183 IN CHAR8 *Language,
184 OUT CHAR16 **ControllerName
185 )
186 {
187 EFI_STATUS Status;
188 EFI_BLOCK_IO_PROTOCOL *BlockIo;
189 ATA_DEVICE *AtaDevice;
190 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
191
192 //
193 // Make sure this driver is currently managing ControllHandle
194 //
195 Status = EfiTestManagedDevice (
196 ControllerHandle,
197 gAtaBusDriverBinding.DriverBindingHandle,
198 &gEfiAtaPassThruProtocolGuid
199 );
200 if (EFI_ERROR (Status)) {
201 return Status;
202 }
203
204 ControllerNameTable = mAtaBusControllerNameTable;
205 if (ChildHandle != NULL) {
206 Status = EfiTestChildHandle (
207 ControllerHandle,
208 ChildHandle,
209 &gEfiAtaPassThruProtocolGuid
210 );
211 if (EFI_ERROR (Status)) {
212 return Status;
213 }
214 //
215 // Get the child context
216 //
217 Status = gBS->OpenProtocol (
218 ChildHandle,
219 &gEfiBlockIoProtocolGuid,
220 (VOID **) &BlockIo,
221 gAtaBusDriverBinding.DriverBindingHandle,
222 ChildHandle,
223 EFI_OPEN_PROTOCOL_GET_PROTOCOL
224 );
225 if (EFI_ERROR (Status)) {
226 return EFI_UNSUPPORTED;
227 }
228 AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);
229 ControllerNameTable =AtaDevice->ControllerNameTable;
230 }
231 return LookupUnicodeString2 (
232 Language,
233 This->SupportedLanguages,
234 ControllerNameTable,
235 ControllerName,
236 (BOOLEAN)(This == &gAtaBusComponentName)
237 );
238 }