]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/ComponentName.c
bfe500f6f5b5a9acbf9e179445c936514a3f6067
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2MouseDxe / 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 //
22 // Include common header file for this module.
23 //
24 #include "CommonHeader.h"
25
26 #include "Ps2Mouse.h"
27
28 //
29 // EFI Component Name Protocol
30 //
31 EFI_COMPONENT_NAME_PROTOCOL gPs2MouseComponentName = {
32 Ps2MouseComponentNameGetDriverName,
33 Ps2MouseComponentNameGetControllerName,
34 "eng"
35 };
36
37 static EFI_UNICODE_STRING_TABLE mPs2MouseDriverNameTable[] = {
38 {
39 "eng",
40 L"PS/2 Mouse Driver"
41 },
42 {
43 NULL,
44 NULL
45 }
46 };
47
48 EFI_STATUS
49 EFIAPI
50 Ps2MouseComponentNameGetDriverName (
51 IN EFI_COMPONENT_NAME_PROTOCOL *This,
52 IN CHAR8 *Language,
53 OUT CHAR16 **DriverName
54 )
55 /*++
56
57 Routine Description:
58
59 Retrieves a Unicode string that is the user readable name of the EFI Driver.
60
61 Arguments:
62
63 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
64 Language - A pointer to a three character ISO 639-2 language identifier.
65 This is the language of the driver name that that the caller
66 is requesting, and it must match one of the languages specified
67 in SupportedLanguages. The number of languages supported by a
68 driver is up to the driver writer.
69 DriverName - A pointer to the Unicode string to return. This Unicode string
70 is the name of the driver specified by This in the language
71 specified by Language.
72
73 Returns:
74
75 EFI_SUCCESS - The Unicode string for the Driver specified by This
76 and the language specified by Language was returned
77 in DriverName.
78 EFI_INVALID_PARAMETER - Language is NULL.
79 EFI_INVALID_PARAMETER - DriverName is NULL.
80 EFI_UNSUPPORTED - The driver specified by This does not support the
81 language specified by Language.
82
83 --*/
84 {
85 return LookupUnicodeString (
86 Language,
87 gPs2MouseComponentName.SupportedLanguages,
88 mPs2MouseDriverNameTable,
89 DriverName
90 );
91 }
92
93 EFI_STATUS
94 EFIAPI
95 Ps2MouseComponentNameGetControllerName (
96 IN EFI_COMPONENT_NAME_PROTOCOL *This,
97 IN EFI_HANDLE ControllerHandle,
98 IN EFI_HANDLE ChildHandle OPTIONAL,
99 IN CHAR8 *Language,
100 OUT CHAR16 **ControllerName
101 )
102 /*++
103
104 Routine Description:
105
106 Retrieves a Unicode string that is the user readable name of the controller
107 that is being managed by an EFI Driver.
108
109 Arguments:
110
111 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
112 ControllerHandle - The handle of a controller that the driver specified by
113 This is managing. This handle specifies the controller
114 whose name is to be returned.
115 ChildHandle - The handle of the child controller to retrieve the name
116 of. This is an optional parameter that may be NULL. It
117 will be NULL for device drivers. It will also be NULL
118 for a bus drivers that wish to retrieve the name of the
119 bus controller. It will not be NULL for a bus driver
120 that wishes to retrieve the name of a child controller.
121 Language - A pointer to a three character ISO 639-2 language
122 identifier. This is the language of the controller name
123 that that the caller is requesting, and it must match one
124 of the languages specified in SupportedLanguages. The
125 number of languages supported by a driver is up to the
126 driver writer.
127 ControllerName - A pointer to the Unicode string to return. This Unicode
128 string is the name of the controller specified by
129 ControllerHandle and ChildHandle in the language specified
130 by Language from the point of view of the driver specified
131 by This.
132
133 Returns:
134
135 EFI_SUCCESS - The Unicode string for the user readable name in the
136 language specified by Language for the driver
137 specified by This was returned in DriverName.
138 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
139 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
140 EFI_INVALID_PARAMETER - Language is NULL.
141 EFI_INVALID_PARAMETER - ControllerName is NULL.
142 EFI_UNSUPPORTED - The driver specified by This is not currently managing
143 the controller specified by ControllerHandle and
144 ChildHandle.
145 EFI_UNSUPPORTED - The driver specified by This does not support the
146 language specified by Language.
147
148 --*/
149 {
150 EFI_STATUS Status;
151 EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
152 PS2_MOUSE_DEV *MouseDev;
153 EFI_ISA_IO_PROTOCOL *IsaIoProtocol;
154
155 //
156 // This is a device driver, so ChildHandle must be NULL.
157 //
158 if (ChildHandle != NULL) {
159 return EFI_UNSUPPORTED;
160 }
161 //
162 // Check Controller's handle
163 //
164 Status = gBS->OpenProtocol (
165 ControllerHandle,
166 &gEfiIsaIoProtocolGuid,
167 (VOID **) &IsaIoProtocol,
168 gPS2MouseDriver.DriverBindingHandle,
169 ControllerHandle,
170 EFI_OPEN_PROTOCOL_BY_DRIVER
171 );
172 if (!EFI_ERROR (Status)) {
173 gBS->CloseProtocol (
174 ControllerHandle,
175 &gEfiIsaIoProtocolGuid,
176 gPS2MouseDriver.DriverBindingHandle,
177 ControllerHandle
178 );
179
180 return EFI_UNSUPPORTED;
181 }
182
183 if (Status != EFI_ALREADY_STARTED) {
184 return EFI_UNSUPPORTED;
185 }
186 //
187 // Get the device context
188 //
189 Status = gBS->OpenProtocol (
190 ControllerHandle,
191 &gEfiSimplePointerProtocolGuid,
192 (VOID **) &SimplePointerProtocol,
193 gPS2MouseDriver.DriverBindingHandle,
194 ControllerHandle,
195 EFI_OPEN_PROTOCOL_GET_PROTOCOL
196 );
197 if (EFI_ERROR (Status)) {
198 return Status;
199 }
200
201 MouseDev = PS2_MOUSE_DEV_FROM_THIS (SimplePointerProtocol);
202
203 return LookupUnicodeString (
204 Language,
205 gPs2MouseComponentName.SupportedLanguages,
206 MouseDev->ControllerNameTable,
207 ControllerName
208 );
209 }