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