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