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