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