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