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