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