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