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