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