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