]>
Commit | Line | Data |
---|---|---|
91c68197 LG |
1 | /** @file\r |
2 | UEFI Component Name and Name2 protocol for Isa serial driver.\r | |
637ff819 | 3 | \r |
180a5a35 HT |
4 | Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials\r | |
f8cd287b | 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 | |
366565e0 | 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 | |
637ff819 | 12 | \r |
f8cd287b | 13 | **/\r |
637ff819 | 14 | \r |
15 | #include "Serial.h"\r | |
16 | \r | |
91c68197 | 17 | #define SERIAL_PORT_NAME "ISA Serial Port # "\r |
637ff819 | 18 | //\r |
19 | // EFI Component Name Protocol\r | |
20 | //\r | |
1307dcd7 | 21 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIsaSerialComponentName = {\r |
637ff819 | 22 | IsaSerialComponentNameGetDriverName,\r |
23 | IsaSerialComponentNameGetControllerName,\r | |
24 | "eng"\r | |
1307dcd7 | 25 | };\r |
f3d08ccf | 26 | \r |
27 | //\r | |
28 | // EFI Component Name 2 Protocol\r | |
29 | //\r | |
1307dcd7 | 30 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIsaSerialComponentName2 = {\r |
f3d08ccf | 31 | (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IsaSerialComponentNameGetDriverName,\r |
32 | (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IsaSerialComponentNameGetControllerName,\r | |
33 | "en"\r | |
1307dcd7 | 34 | };\r |
f3d08ccf | 35 | \r |
637ff819 | 36 | \r |
d1aeb0bd | 37 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaSerialDriverNameTable[] = {\r |
637ff819 | 38 | {\r |
f3d08ccf | 39 | "eng;en",\r |
637ff819 | 40 | L"ISA Serial Driver"\r |
41 | },\r | |
42 | {\r | |
43 | NULL,\r | |
44 | NULL\r | |
45 | }\r | |
46 | };\r | |
47 | \r | |
f3d08ccf | 48 | /**\r |
49 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
50 | \r | |
51 | This function retrieves the user readable name of a driver in the form of a\r | |
52 | Unicode string. If the driver specified by This has a user readable name in\r | |
53 | the language specified by Language, then a pointer to the driver name is\r | |
54 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
55 | by This does not support the language specified by Language,\r | |
56 | then EFI_UNSUPPORTED is returned.\r | |
57 | \r | |
58 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
59 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
60 | \r | |
61 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
62 | array indicating the language. This is the\r | |
63 | language of the driver name that the caller is\r | |
64 | requesting, and it must match one of the\r | |
65 | languages specified in SupportedLanguages. The\r | |
66 | number of languages supported by a driver is up\r | |
67 | to the driver writer. Language is specified\r | |
4bca47e1 | 68 | in RFC 4646 or ISO 639-2 language code format.\r |
f3d08ccf | 69 | \r |
70 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
71 | This Unicode string is the name of the\r | |
72 | driver specified by This in the language\r | |
73 | specified by Language.\r | |
74 | \r | |
75 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
76 | This and the language specified by Language was\r | |
77 | returned in DriverName.\r | |
78 | \r | |
79 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
80 | \r | |
81 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
82 | \r | |
83 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
84 | the language specified by Language.\r | |
85 | \r | |
86 | **/\r | |
637ff819 | 87 | EFI_STATUS\r |
88 | EFIAPI\r | |
89 | IsaSerialComponentNameGetDriverName (\r | |
90 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
91 | IN CHAR8 *Language,\r | |
92 | OUT CHAR16 **DriverName\r | |
93 | )\r | |
637ff819 | 94 | {\r |
f3d08ccf | 95 | return LookupUnicodeString2 (\r |
637ff819 | 96 | Language,\r |
f3d08ccf | 97 | This->SupportedLanguages,\r |
637ff819 | 98 | mIsaSerialDriverNameTable,\r |
f3d08ccf | 99 | DriverName,\r |
100 | (BOOLEAN)(This == &gIsaSerialComponentName)\r | |
637ff819 | 101 | );\r |
102 | }\r | |
103 | \r | |
f3d08ccf | 104 | /**\r |
105 | Retrieves a Unicode string that is the user readable name of the controller\r | |
106 | that is being managed by a driver.\r | |
107 | \r | |
108 | This function retrieves the user readable name of the controller specified by\r | |
109 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
110 | driver specified by This has a user readable name in the language specified by\r | |
111 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
112 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
113 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
114 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
115 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
116 | \r | |
117 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
118 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
119 | \r | |
120 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
121 | specified by This is managing. This handle\r | |
122 | specifies the controller whose name is to be\r | |
123 | returned.\r | |
124 | \r | |
125 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
126 | the name of. This is an optional parameter that\r | |
127 | may be NULL. It will be NULL for device\r | |
128 | drivers. It will also be NULL for a bus drivers\r | |
129 | that wish to retrieve the name of the bus\r | |
130 | controller. It will not be NULL for a bus\r | |
131 | driver that wishes to retrieve the name of a\r | |
132 | child controller.\r | |
133 | \r | |
134 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
135 | array indicating the language. This is the\r | |
136 | language of the driver name that the caller is\r | |
137 | requesting, and it must match one of the\r | |
138 | languages specified in SupportedLanguages. The\r | |
139 | number of languages supported by a driver is up\r | |
140 | to the driver writer. Language is specified in\r | |
4bca47e1 | 141 | RFC 4646 or ISO 639-2 language code format.\r |
f3d08ccf | 142 | \r |
143 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
144 | This Unicode string is the name of the\r | |
145 | controller specified by ControllerHandle and\r | |
146 | ChildHandle in the language specified by\r | |
147 | Language from the point of view of the driver\r | |
148 | specified by This.\r | |
149 | \r | |
150 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
151 | the language specified by Language for the\r | |
152 | driver specified by This was returned in\r | |
153 | DriverName.\r | |
154 | \r | |
155 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
156 | \r | |
157 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
158 | EFI_HANDLE.\r | |
159 | \r | |
160 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
161 | \r | |
162 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
163 | \r | |
164 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
165 | managing the controller specified by\r | |
166 | ControllerHandle and ChildHandle.\r | |
167 | \r | |
168 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
169 | the language specified by Language.\r | |
170 | \r | |
171 | **/\r | |
637ff819 | 172 | EFI_STATUS\r |
173 | EFIAPI\r | |
174 | IsaSerialComponentNameGetControllerName (\r | |
175 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
176 | IN EFI_HANDLE ControllerHandle,\r | |
177 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
178 | IN CHAR8 *Language,\r | |
179 | OUT CHAR16 **ControllerName\r | |
180 | )\r | |
637ff819 | 181 | {\r |
182 | EFI_STATUS Status;\r | |
183 | EFI_SERIAL_IO_PROTOCOL *SerialIo;\r | |
184 | SERIAL_DEV *SerialDevice;\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 | // Make sure this driver is currently managing ControllerHandle\r | |
194 | //\r | |
195 | Status = EfiTestManagedDevice (\r | |
196 | ControllerHandle,\r | |
197 | gSerialControllerDriver.DriverBindingHandle,\r | |
198 | &gEfiIsaIoProtocolGuid\r | |
199 | );\r | |
200 | if (EFI_ERROR (Status)) {\r | |
201 | return Status;\r | |
202 | }\r | |
203 | //\r | |
204 | // Get the Block I/O Protocol on Controller\r | |
205 | //\r | |
206 | Status = gBS->OpenProtocol (\r | |
207 | ControllerHandle,\r | |
208 | &gEfiSerialIoProtocolGuid,\r | |
209 | (VOID **) &SerialIo,\r | |
210 | gSerialControllerDriver.DriverBindingHandle,\r | |
211 | ControllerHandle,\r | |
212 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
213 | );\r | |
214 | if (EFI_ERROR (Status)) {\r | |
215 | return Status;\r | |
216 | }\r | |
217 | //\r | |
218 | // Get the Serial Controller's Device structure\r | |
219 | //\r | |
220 | SerialDevice = SERIAL_DEV_FROM_THIS (SerialIo);\r | |
221 | \r | |
f3d08ccf | 222 | return LookupUnicodeString2 (\r |
637ff819 | 223 | Language,\r |
f3d08ccf | 224 | This->SupportedLanguages,\r |
637ff819 | 225 | SerialDevice->ControllerNameTable,\r |
f3d08ccf | 226 | ControllerName,\r |
227 | (BOOLEAN)(This == &gIsaSerialComponentName)\r | |
637ff819 | 228 | );\r |
229 | }\r | |
230 | \r | |
bcd70414 | 231 | /**\r |
91c68197 | 232 | Add the ISO639-2 and RFC4646 component name both for the Serial IO device\r |
637ff819 | 233 | \r |
91c68197 | 234 | @param SerialDevice A pointer to the SERIAL_DEV instance.\r |
637ff819 | 235 | \r |
91c68197 | 236 | @param IsaIo A pointer to the EFI_ISA_IO_PROTOCOL instance.\r |
637ff819 | 237 | \r |
bcd70414 | 238 | **/\r |
91c68197 LG |
239 | VOID\r |
240 | AddName (\r | |
241 | IN SERIAL_DEV *SerialDevice,\r | |
242 | IN EFI_ISA_IO_PROTOCOL *IsaIo\r | |
243 | )\r | |
637ff819 | 244 | {\r |
245 | CHAR16 SerialPortName[sizeof (SERIAL_PORT_NAME)];\r | |
246 | \r | |
247 | StrCpy (SerialPortName, L"ISA Serial Port # ");\r | |
248 | SerialPortName[sizeof (SERIAL_PORT_NAME) - 2] = (CHAR16) (L'0' + (UINT8) IsaIo->ResourceList->Device.UID);\r | |
f3d08ccf | 249 | AddUnicodeString2 (\r |
637ff819 | 250 | "eng",\r |
251 | gIsaSerialComponentName.SupportedLanguages,\r | |
252 | &SerialDevice->ControllerNameTable,\r | |
f3d08ccf | 253 | (CHAR16 *) SerialPortName,\r |
254 | TRUE\r | |
637ff819 | 255 | );\r |
f3d08ccf | 256 | AddUnicodeString2 (\r |
257 | "en",\r | |
258 | gIsaSerialComponentName2.SupportedLanguages,\r | |
259 | &SerialDevice->ControllerNameTable,\r | |
260 | (CHAR16 *) SerialPortName,\r | |
261 | FALSE\r | |
262 | );\r | |
263 | \r | |
637ff819 | 264 | }\r |