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