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