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