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