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