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