637ff819 |
1 | /*++\r |
2 | \r |
366565e0 |
3 | Copyright (c) 2006 - 2007, Intel Corporation<BR>\r |
4 | All rights reserved. This program and the accompanying materials\r |
5 | are licensed and made available under the terms and conditions of the BSD License\r |
6 | which accompanies this distribution. The full text of the license may be found at\r |
7 | http://opensource.org/licenses/bsd-license.php\r |
8 | \r |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
637ff819 |
11 | \r |
12 | Module Name:\r |
13 | \r |
14 | ComponentName.c\r |
15 | \r |
16 | Abstract:\r |
17 | \r |
18 | --*/\r |
19 | \r |
20 | #include "Serial.h"\r |
21 | \r |
22 | //\r |
23 | // EFI Component Name Protocol\r |
24 | //\r |
25 | EFI_COMPONENT_NAME_PROTOCOL gIsaSerialComponentName = {\r |
26 | IsaSerialComponentNameGetDriverName,\r |
27 | IsaSerialComponentNameGetControllerName,\r |
28 | "eng"\r |
29 | };\r |
30 | \r |
31 | STATIC EFI_UNICODE_STRING_TABLE mIsaSerialDriverNameTable[] = {\r |
32 | {\r |
33 | "eng",\r |
34 | L"ISA Serial Driver"\r |
35 | },\r |
36 | {\r |
37 | NULL,\r |
38 | NULL\r |
39 | }\r |
40 | };\r |
41 | \r |
42 | EFI_STATUS\r |
43 | EFIAPI\r |
44 | IsaSerialComponentNameGetDriverName (\r |
45 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
46 | IN CHAR8 *Language,\r |
47 | OUT CHAR16 **DriverName\r |
48 | )\r |
49 | /*++\r |
50 | \r |
51 | Routine Description:\r |
52 | \r |
53 | Retrieves a Unicode string that is the user readable name of the EFI Driver.\r |
54 | \r |
55 | Arguments:\r |
56 | \r |
57 | This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r |
58 | Language - A pointer to a three character ISO 639-2 language identifier.\r |
59 | This is the language of the driver name that that the caller \r |
60 | is requesting, and it must match one of the languages specified\r |
61 | in SupportedLanguages. The number of languages supported by a \r |
62 | driver is up to the driver writer.\r |
63 | DriverName - A pointer to the Unicode string to return. This Unicode string\r |
64 | is the name of the driver specified by This in the language \r |
65 | specified by Language.\r |
66 | \r |
67 | Returns:\r |
68 | \r |
69 | EFI_SUCCESS - The Unicode string for the Driver specified by This\r |
70 | and the language specified by Language was returned \r |
71 | in DriverName.\r |
72 | EFI_INVALID_PARAMETER - Language is NULL.\r |
73 | EFI_INVALID_PARAMETER - DriverName is NULL.\r |
74 | EFI_UNSUPPORTED - The driver specified by This does not support the \r |
75 | language specified by Language.\r |
76 | \r |
77 | --*/\r |
78 | {\r |
79 | return LookupUnicodeString (\r |
80 | Language,\r |
81 | gIsaSerialComponentName.SupportedLanguages,\r |
82 | mIsaSerialDriverNameTable,\r |
83 | DriverName\r |
84 | );\r |
85 | }\r |
86 | \r |
87 | EFI_STATUS\r |
88 | EFIAPI\r |
89 | IsaSerialComponentNameGetControllerName (\r |
90 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
91 | IN EFI_HANDLE ControllerHandle,\r |
92 | IN EFI_HANDLE ChildHandle OPTIONAL,\r |
93 | IN CHAR8 *Language,\r |
94 | OUT CHAR16 **ControllerName\r |
95 | )\r |
96 | /*++\r |
97 | \r |
98 | Routine Description:\r |
99 | \r |
100 | Retrieves a Unicode string that is the user readable name of the controller\r |
101 | that is being managed by an EFI Driver.\r |
102 | \r |
103 | Arguments:\r |
104 | \r |
105 | This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r |
106 | ControllerHandle - The handle of a controller that the driver specified by \r |
107 | This is managing. This handle specifies the controller \r |
108 | whose name is to be returned.\r |
109 | ChildHandle - The handle of the child controller to retrieve the name \r |
110 | of. This is an optional parameter that may be NULL. It \r |
111 | will be NULL for device drivers. It will also be NULL \r |
112 | for a bus drivers that wish to retrieve the name of the \r |
113 | bus controller. It will not be NULL for a bus driver \r |
114 | that wishes to retrieve the name of a child controller.\r |
115 | Language - A pointer to a three character ISO 639-2 language \r |
116 | identifier. This is the language of the controller name \r |
117 | that that the caller is requesting, and it must match one\r |
118 | of the languages specified in SupportedLanguages. The \r |
119 | number of languages supported by a driver is up to the \r |
120 | driver writer.\r |
121 | ControllerName - A pointer to the Unicode string to return. This Unicode\r |
122 | string is the name of the controller specified by \r |
123 | ControllerHandle and ChildHandle in the language \r |
124 | specified by Language from the point of view of the \r |
125 | driver specified by This. \r |
126 | \r |
127 | Returns:\r |
128 | \r |
129 | EFI_SUCCESS - The Unicode string for the user readable name in the \r |
130 | language specified by Language for the driver \r |
131 | specified by This was returned in DriverName.\r |
132 | EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r |
133 | EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r |
134 | EFI_HANDLE.\r |
135 | EFI_INVALID_PARAMETER - Language is NULL.\r |
136 | EFI_INVALID_PARAMETER - ControllerName is NULL.\r |
137 | EFI_UNSUPPORTED - The driver specified by This is not currently \r |
138 | managing the controller specified by \r |
139 | ControllerHandle and ChildHandle.\r |
140 | EFI_UNSUPPORTED - The driver specified by This does not support the \r |
141 | language specified by Language.\r |
142 | \r |
143 | --*/\r |
144 | {\r |
145 | EFI_STATUS Status;\r |
146 | EFI_SERIAL_IO_PROTOCOL *SerialIo;\r |
147 | SERIAL_DEV *SerialDevice;\r |
148 | \r |
149 | //\r |
150 | // This is a device driver, so ChildHandle must be NULL.\r |
151 | //\r |
152 | if (ChildHandle != NULL) {\r |
153 | return EFI_UNSUPPORTED;\r |
154 | }\r |
155 | //\r |
156 | // Make sure this driver is currently managing ControllerHandle\r |
157 | //\r |
158 | Status = EfiTestManagedDevice (\r |
159 | ControllerHandle,\r |
160 | gSerialControllerDriver.DriverBindingHandle,\r |
161 | &gEfiIsaIoProtocolGuid\r |
162 | );\r |
163 | if (EFI_ERROR (Status)) {\r |
164 | return Status;\r |
165 | }\r |
166 | //\r |
167 | // Get the Block I/O Protocol on Controller\r |
168 | //\r |
169 | Status = gBS->OpenProtocol (\r |
170 | ControllerHandle,\r |
171 | &gEfiSerialIoProtocolGuid,\r |
172 | (VOID **) &SerialIo,\r |
173 | gSerialControllerDriver.DriverBindingHandle,\r |
174 | ControllerHandle,\r |
175 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r |
176 | );\r |
177 | if (EFI_ERROR (Status)) {\r |
178 | return Status;\r |
179 | }\r |
180 | //\r |
181 | // Get the Serial Controller's Device structure\r |
182 | //\r |
183 | SerialDevice = SERIAL_DEV_FROM_THIS (SerialIo);\r |
184 | \r |
185 | return LookupUnicodeString (\r |
186 | Language,\r |
187 | gIsaSerialComponentName.SupportedLanguages,\r |
188 | SerialDevice->ControllerNameTable,\r |
189 | ControllerName\r |
190 | );\r |
191 | }\r |
192 | \r |
193 | VOID\r |
194 | AddName (\r |
195 | IN SERIAL_DEV *SerialDevice,\r |
196 | IN EFI_ISA_IO_PROTOCOL *IsaIo\r |
197 | )\r |
198 | /*++\r |
199 | \r |
200 | Routine Description:\r |
201 | \r |
202 | Add the component name for the serial io device\r |
203 | \r |
204 | Arguments:\r |
205 | \r |
206 | SerialDevice - A pointer to the SERIAL_DEV instance.\r |
207 | IsaIo - A pointer to the EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL instance.\r |
208 | \r |
209 | Returns:\r |
210 | \r |
211 | None\r |
212 | \r |
213 | --*/\r |
214 | {\r |
215 | CHAR16 SerialPortName[sizeof (SERIAL_PORT_NAME)];\r |
216 | \r |
217 | StrCpy (SerialPortName, L"ISA Serial Port # ");\r |
218 | SerialPortName[sizeof (SERIAL_PORT_NAME) - 2] = (CHAR16) (L'0' + (UINT8) IsaIo->ResourceList->Device.UID);\r |
219 | AddUnicodeString (\r |
220 | "eng",\r |
221 | gIsaSerialComponentName.SupportedLanguages,\r |
222 | &SerialDevice->ControllerNameTable,\r |
223 | (CHAR16 *) SerialPortName\r |
224 | );\r |
225 | }\r |