]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.c
IntelFrameworkModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaFloppyDxe / ComponentName.c
... / ...
CommitLineData
1/** @file\r
2 UEFI Component Name(2) protocol implementation for Isa Floppy driver.\r
3\r
4Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
5SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9#include "IsaFloppy.h"\r
10\r
11//\r
12// EFI Component Name Protocol\r
13//\r
14GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIsaFloppyComponentName = {\r
15 IsaFloppyComponentNameGetDriverName,\r
16 IsaFloppyComponentNameGetControllerName,\r
17 "eng"\r
18};\r
19\r
20//\r
21// EFI Component Name 2 Protocol\r
22//\r
23GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIsaFloppyComponentName2 = {\r
24 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IsaFloppyComponentNameGetDriverName,\r
25 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IsaFloppyComponentNameGetControllerName,\r
26 "en"\r
27};\r
28\r
29\r
30GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaFloppyDriverNameTable[] = {\r
31 {\r
32 "eng;en",\r
33 L"ISA Floppy Driver"\r
34 },\r
35 {\r
36 NULL,\r
37 NULL\r
38 }\r
39};\r
40\r
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
51 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
52 EFI_COMPONENT_NAME_PROTOCOL instance.\r
53 @param[in] Language A pointer to a Null-terminated ASCII string\r
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
60 in RFC 4646 or ISO 639-2 language code format.\r
61 @param[out] DriverName A pointer to the Unicode string to return.\r
62 This Unicode string is the name of the\r
63 driver specified by This in the language\r
64 specified by Language.\r
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
70 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
71 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
72 the language specified by Language.\r
73**/\r
74EFI_STATUS\r
75EFIAPI\r
76IsaFloppyComponentNameGetDriverName (\r
77 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
78 IN CHAR8 *Language,\r
79 OUT CHAR16 **DriverName\r
80 )\r
81{\r
82 return LookupUnicodeString2 (\r
83 Language,\r
84 This->SupportedLanguages,\r
85 mIsaFloppyDriverNameTable,\r
86 DriverName,\r
87 (BOOLEAN)(This == &gIsaFloppyComponentName)\r
88 );\r
89}\r
90\r
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
104 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
105 EFI_COMPONENT_NAME_PROTOCOL instance.\r
106 @param[in] ControllerHandle The handle of a controller that the driver\r
107 specified by This is managing. This handle\r
108 specifies the controller whose name is to be\r
109 returned.\r
110 @param[in] ChildHandle The handle of the child controller to retrieve\r
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
118 @param[in] Language A pointer to a Null-terminated ASCII string\r
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
125 RFC 4646 or ISO 639-2 language code format.\r
126 @param[out] ControllerName A pointer to the Unicode string to return.\r
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
137 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
138 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
139 EFI_HANDLE.\r
140 @retval EFI_INVALID_PARAMETER Language is NULL.\r
141 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
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
145 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
146 the language specified by Language.\r
147**/\r
148EFI_STATUS\r
149EFIAPI\r
150IsaFloppyComponentNameGetControllerName (\r
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
156 )\r
157{\r
158 EFI_STATUS Status;\r
159 EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
160 FDC_BLK_IO_DEV *FdcDev;\r
161\r
162 if (Language == NULL || ControllerName == NULL) {\r
163 return EFI_INVALID_PARAMETER;\r
164 }\r
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
171\r
172 //\r
173 // Check if this driver is currently managing ControllerHandle\r
174 //\r
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
182 }\r
183\r
184 //\r
185 // Get the device context\r
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
198\r
199 FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);\r
200\r
201 return LookupUnicodeString2 (\r
202 Language,\r
203 This->SupportedLanguages,\r
204 FdcDev->ControllerNameTable,\r
205 ControllerName,\r
206 (BOOLEAN)(This == &gIsaFloppyComponentName)\r
207 );\r
208}\r
209\r
210/**\r
211 Add the component name for the floppy device\r
212\r
213 @param[in] FdcDev A pointer to the FDC_BLK_IO_DEV instance.\r
214\r
215**/\r
216VOID\r
217AddName (\r
218 IN FDC_BLK_IO_DEV *FdcDev\r
219 )\r
220{\r
221 CHAR16 FloppyDriveName[FLOPPY_DRIVE_NAME_LEN + 1];\r
222\r
223 if (!(FeaturePcdGet(PcdComponentNameDisable) && FeaturePcdGet(PcdComponentName2Disable))) {\r
224 StrCpyS (FloppyDriveName, FLOPPY_DRIVE_NAME_LEN + 1, FLOPPY_DRIVE_NAME);\r
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
242}\r
243\r