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