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