]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Bus/Usb/UsbKb/Dxe/ComponentName.c
1) Initialize gBS, gST, gImageHandle in UefiBootServicesTableLib.c to NULL
[mirror_edk2.git] / EdkModulePkg / Bus / Usb / UsbKb / 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 "keyboard.h"
21
22 //
23 // EFI Component Name Protocol
24 //
25 EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName = {
26 UsbKeyboardComponentNameGetDriverName,
27 UsbKeyboardComponentNameGetControllerName,
28 "eng"
29 };
30
31 STATIC EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTable[] = {
32 { "eng", (CHAR16 *) L"Usb Keyboard Driver" },
33 { NULL , NULL }
34 };
35
36
37 EFI_STATUS
38 EFIAPI
39 UsbKeyboardComponentNameGetDriverName (
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 gUsbKeyboardComponentName.SupportedLanguages,
74 mUsbKeyboardDriverNameTable,
75 DriverName
76 );
77 }
78
79 EFI_STATUS
80 EFIAPI
81 UsbKeyboardComponentNameGetControllerName (
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_KB_DEV *UsbKbDev;
135 EFI_SIMPLE_TEXT_IN_PROTOCOL *SimpleTxtIn;
136 EFI_USB_IO_PROTOCOL *UsbIoProtocol;
137 //
138 // This is a device driver, so ChildHandle must be NULL.
139 //
140 if (ChildHandle != NULL) {
141 return EFI_UNSUPPORTED;
142 }
143
144 //
145 // Check Controller's handle
146 //
147 Status = gBS->OpenProtocol (
148 ControllerHandle,
149 &gEfiUsbIoProtocolGuid,
150 (VOID **) &UsbIoProtocol,
151 gUsbKeyboardDriverBinding.DriverBindingHandle,
152 ControllerHandle,
153 EFI_OPEN_PROTOCOL_BY_DRIVER
154 );
155 if (!EFI_ERROR (Status)) {
156 gBS->CloseProtocol (
157 ControllerHandle,
158 &gEfiUsbIoProtocolGuid,
159 gUsbKeyboardDriverBinding.DriverBindingHandle,
160 ControllerHandle
161 );
162
163 return EFI_UNSUPPORTED;
164 }
165
166 if (Status != EFI_ALREADY_STARTED) {
167 return EFI_UNSUPPORTED;
168 }
169 //
170 // Get the device context
171 //
172 Status = gBS->OpenProtocol (
173 ControllerHandle,
174 &gEfiSimpleTextInProtocolGuid,
175 (VOID **) &SimpleTxtIn,
176 gUsbKeyboardDriverBinding.DriverBindingHandle,
177 ControllerHandle,
178 EFI_OPEN_PROTOCOL_GET_PROTOCOL
179 );
180
181 if (EFI_ERROR (Status)) {
182 return Status;
183 }
184
185 UsbKbDev = USB_KB_DEV_FROM_THIS (SimpleTxtIn);
186
187 return LookupUnicodeString (
188 Language,
189 gUsbKeyboardComponentName.SupportedLanguages,
190 UsbKbDev->ControllerNameTable,
191 ControllerName
192 );
193
194 }