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