]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Isa/Ps2MouseDxe/ComponentName.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Bus / Isa / Ps2MouseDxe / ComponentName.c
1 /** @file
2 UEFI Component Name(2) protocol implementation for Ps2MouseDxe driver.
3
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "Ps2Mouse.h"
10
11 //
12 // EFI Component Name Protocol
13 //
14 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPs2MouseComponentName = {
15 Ps2MouseComponentNameGetDriverName,
16 Ps2MouseComponentNameGetControllerName,
17 "eng"
18 };
19
20 //
21 // EFI Component Name 2 Protocol
22 //
23 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseComponentName2 = {
24 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ps2MouseComponentNameGetDriverName,
25 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ps2MouseComponentNameGetControllerName,
26 "en"
27 };
28
29
30 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2MouseDriverNameTable[] = {
31 {
32 "eng;en",
33 L"PS/2 Mouse Driver"
34 },
35 {
36 NULL,
37 NULL
38 }
39 };
40
41 /**
42 Retrieves a Unicode string that is the user readable name of the driver.
43
44 This function retrieves the user readable name of a driver in the form of a
45 Unicode string. If the driver specified by This has a user readable name in
46 the language specified by Language, then a pointer to the driver name is
47 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
48 by This does not support the language specified by Language,
49 then EFI_UNSUPPORTED is returned.
50
51 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
52 EFI_COMPONENT_NAME_PROTOCOL instance.
53
54 @param Language[in] A pointer to a Null-terminated ASCII string
55 array indicating the language. This is the
56 language of the driver name that the caller is
57 requesting, and it must match one of the
58 languages specified in SupportedLanguages. The
59 number of languages supported by a driver is up
60 to the driver writer. Language is specified
61 in RFC 4646 or ISO 639-2 language code format.
62
63 @param DriverName[out] A pointer to the Unicode string to return.
64 This Unicode string is the name of the
65 driver specified by This in the language
66 specified by Language.
67
68 @retval EFI_SUCCESS The Unicode string for the Driver specified by
69 This and the language specified by Language was
70 returned in DriverName.
71
72 @retval EFI_INVALID_PARAMETER Language is NULL.
73
74 @retval EFI_INVALID_PARAMETER DriverName is NULL.
75
76 @retval EFI_UNSUPPORTED The driver specified by This does not support
77 the language specified by Language.
78
79 **/
80 EFI_STATUS
81 EFIAPI
82 Ps2MouseComponentNameGetDriverName (
83 IN EFI_COMPONENT_NAME_PROTOCOL *This,
84 IN CHAR8 *Language,
85 OUT CHAR16 **DriverName
86 )
87 {
88 return LookupUnicodeString2 (
89 Language,
90 This->SupportedLanguages,
91 mPs2MouseDriverNameTable,
92 DriverName,
93 (BOOLEAN)(This == &gPs2MouseComponentName)
94 );
95 }
96
97 /**
98 Retrieves a Unicode string that is the user readable name of the controller
99 that is being managed by a driver.
100
101 This function retrieves the user readable name of the controller specified by
102 ControllerHandle and ChildHandle in the form of a Unicode string. If the
103 driver specified by This has a user readable name in the language specified by
104 Language, then a pointer to the controller name is returned in ControllerName,
105 and EFI_SUCCESS is returned. If the driver specified by This is not currently
106 managing the controller specified by ControllerHandle and ChildHandle,
107 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
108 support the language specified by Language, then EFI_UNSUPPORTED is returned.
109
110 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
111 EFI_COMPONENT_NAME_PROTOCOL instance.
112
113 @param ControllerHandle[in] The handle of a controller that the driver
114 specified by This is managing. This handle
115 specifies the controller whose name is to be
116 returned.
117
118 @param ChildHandle[in] The handle of the child controller to retrieve
119 the name of. This is an optional parameter that
120 may be NULL. It will be NULL for device
121 drivers. It will also be NULL for a bus drivers
122 that wish to retrieve the name of the bus
123 controller. It will not be NULL for a bus
124 driver that wishes to retrieve the name of a
125 child controller.
126
127 @param Language[in] A pointer to a Null-terminated ASCII string
128 array indicating the language. This is the
129 language of the driver name that the caller is
130 requesting, and it must match one of the
131 languages specified in SupportedLanguages. The
132 number of languages supported by a driver is up
133 to the driver writer. Language is specified in
134 RFC 4646 or ISO 639-2 language code format.
135
136 @param ControllerName[out] A pointer to the Unicode string to return.
137 This Unicode string is the name of the
138 controller specified by ControllerHandle and
139 ChildHandle in the language specified by
140 Language from the point of view of the driver
141 specified by This.
142
143 @retval EFI_SUCCESS The Unicode string for the user readable name in
144 the language specified by Language for the
145 driver specified by This was returned in
146 DriverName.
147
148 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
149
150 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
151 EFI_HANDLE.
152
153 @retval EFI_INVALID_PARAMETER Language is NULL.
154
155 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
156
157 @retval EFI_UNSUPPORTED The driver specified by This is not currently
158 managing the controller specified by
159 ControllerHandle and ChildHandle.
160
161 @retval EFI_UNSUPPORTED The driver specified by This does not support
162 the language specified by Language.
163
164 **/
165 EFI_STATUS
166 EFIAPI
167 Ps2MouseComponentNameGetControllerName (
168 IN EFI_COMPONENT_NAME_PROTOCOL *This,
169 IN EFI_HANDLE ControllerHandle,
170 IN EFI_HANDLE ChildHandle OPTIONAL,
171 IN CHAR8 *Language,
172 OUT CHAR16 **ControllerName
173 )
174 {
175 EFI_STATUS Status;
176 EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
177 PS2_MOUSE_DEV *MouseDev;
178
179 //
180 // This is a device driver, so ChildHandle must be NULL.
181 //
182 if (ChildHandle != NULL) {
183 return EFI_UNSUPPORTED;
184 }
185 //
186 // Check Controller's handle
187 //
188 Status = EfiTestManagedDevice (ControllerHandle, gPS2MouseDriver.DriverBindingHandle, &gEfiSioProtocolGuid);
189
190 if (EFI_ERROR (Status)) {
191 return Status;
192 }
193 //
194 // Get the device context
195 //
196 Status = gBS->OpenProtocol (
197 ControllerHandle,
198 &gEfiSimplePointerProtocolGuid,
199 (VOID **) &SimplePointerProtocol,
200 gPS2MouseDriver.DriverBindingHandle,
201 ControllerHandle,
202 EFI_OPEN_PROTOCOL_GET_PROTOCOL
203 );
204 if (EFI_ERROR (Status)) {
205 return Status;
206 }
207
208 MouseDev = PS2_MOUSE_DEV_FROM_THIS (SimplePointerProtocol);
209
210 return LookupUnicodeString2 (
211 Language,
212 This->SupportedLanguages,
213 MouseDev->ControllerNameTable,
214 ControllerName,
215 (BOOLEAN)(This == &gPs2MouseComponentName)
216 );
217 }