1 | /* $Id: ComponentName.c 53335 2014-11-14 17:20:13Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * ComponentName.c
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2010 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | /*
|
---|
28 | This code is based on:
|
---|
29 |
|
---|
30 | Copyright (c) 2006, Intel Corporation
|
---|
31 | All rights reserved. This program and the accompanying materials
|
---|
32 | are licensed and made available under the terms and conditions of the BSD License
|
---|
33 | which accompanies this distribution. The full text of the license may be found at
|
---|
34 | http://opensource.org/licenses/bsd-license.php
|
---|
35 |
|
---|
36 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
37 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
38 |
|
---|
39 | */
|
---|
40 |
|
---|
41 | #include "VBoxVga.h"
|
---|
42 |
|
---|
43 | //
|
---|
44 | // EFI Component Name Protocol
|
---|
45 | //
|
---|
46 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gVBoxVgaComponentName = {
|
---|
47 | VBoxVgaComponentNameGetDriverName,
|
---|
48 | VBoxVgaComponentNameGetControllerName,
|
---|
49 | "eng"
|
---|
50 | };
|
---|
51 |
|
---|
52 | //
|
---|
53 | // EFI Component Name 2 Protocol
|
---|
54 | //
|
---|
55 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gVBoxVgaComponentName2 = {
|
---|
56 | (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) VBoxVgaComponentNameGetDriverName,
|
---|
57 | (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) VBoxVgaComponentNameGetControllerName,
|
---|
58 | "en"
|
---|
59 | };
|
---|
60 |
|
---|
61 |
|
---|
62 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mVBoxVgaDriverNameTable[] = {
|
---|
63 | { "eng;en", L"VirtualBox SVGA Driver" },
|
---|
64 | { NULL , NULL }
|
---|
65 | };
|
---|
66 |
|
---|
67 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mVBoxVgaControllerNameTable[] = {
|
---|
68 | { "eng;en", L"VirtualBox SVGA PCI Adapter" },
|
---|
69 | { NULL , NULL }
|
---|
70 | };
|
---|
71 |
|
---|
72 | /**
|
---|
73 | Retrieves a Unicode string that is the user readable name of the driver.
|
---|
74 |
|
---|
75 | This function retrieves the user readable name of a driver in the form of a
|
---|
76 | Unicode string. If the driver specified by This has a user readable name in
|
---|
77 | the language specified by Language, then a pointer to the driver name is
|
---|
78 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
|
---|
79 | by This does not support the language specified by Language,
|
---|
80 | then EFI_UNSUPPORTED is returned.
|
---|
81 |
|
---|
82 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
---|
83 | EFI_COMPONENT_NAME_PROTOCOL instance.
|
---|
84 |
|
---|
85 | @param Language[in] A pointer to a Null-terminated ASCII string
|
---|
86 | array indicating the language. This is the
|
---|
87 | language of the driver name that the caller is
|
---|
88 | requesting, and it must match one of the
|
---|
89 | languages specified in SupportedLanguages. The
|
---|
90 | number of languages supported by a driver is up
|
---|
91 | to the driver writer. Language is specified
|
---|
92 | in RFC 4646 or ISO 639-2 language code format.
|
---|
93 |
|
---|
94 | @param DriverName[out] A pointer to the Unicode string to return.
|
---|
95 | This Unicode string is the name of the
|
---|
96 | driver specified by This in the language
|
---|
97 | specified by Language.
|
---|
98 |
|
---|
99 | @retval EFI_SUCCESS The Unicode string for the Driver specified by
|
---|
100 | This and the language specified by Language was
|
---|
101 | returned in DriverName.
|
---|
102 |
|
---|
103 | @retval EFI_INVALID_PARAMETER Language is NULL.
|
---|
104 |
|
---|
105 | @retval EFI_INVALID_PARAMETER DriverName is NULL.
|
---|
106 |
|
---|
107 | @retval EFI_UNSUPPORTED The driver specified by This does not support
|
---|
108 | the language specified by Language.
|
---|
109 |
|
---|
110 | **/
|
---|
111 | EFI_STATUS
|
---|
112 | EFIAPI
|
---|
113 | VBoxVgaComponentNameGetDriverName (
|
---|
114 | IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
---|
115 | IN CHAR8 *Language,
|
---|
116 | OUT CHAR16 **DriverName
|
---|
117 | )
|
---|
118 | {
|
---|
119 | return LookupUnicodeString2 (
|
---|
120 | Language,
|
---|
121 | This->SupportedLanguages,
|
---|
122 | mVBoxVgaDriverNameTable,
|
---|
123 | DriverName,
|
---|
124 | (BOOLEAN)(This == &gVBoxVgaComponentName)
|
---|
125 | );
|
---|
126 | }
|
---|
127 |
|
---|
128 | /**
|
---|
129 | Retrieves a Unicode string that is the user readable name of the controller
|
---|
130 | that is being managed by a driver.
|
---|
131 |
|
---|
132 | This function retrieves the user readable name of the controller specified by
|
---|
133 | ControllerHandle and ChildHandle in the form of a Unicode string. If the
|
---|
134 | driver specified by This has a user readable name in the language specified by
|
---|
135 | Language, then a pointer to the controller name is returned in ControllerName,
|
---|
136 | and EFI_SUCCESS is returned. If the driver specified by This is not currently
|
---|
137 | managing the controller specified by ControllerHandle and ChildHandle,
|
---|
138 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
---|
139 | support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
---|
140 |
|
---|
141 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
---|
142 | EFI_COMPONENT_NAME_PROTOCOL instance.
|
---|
143 |
|
---|
144 | @param ControllerHandle[in] The handle of a controller that the driver
|
---|
145 | specified by This is managing. This handle
|
---|
146 | specifies the controller whose name is to be
|
---|
147 | returned.
|
---|
148 |
|
---|
149 | @param ChildHandle[in] The handle of the child controller to retrieve
|
---|
150 | the name of. This is an optional parameter that
|
---|
151 | may be NULL. It will be NULL for device
|
---|
152 | drivers. It will also be NULL for a bus drivers
|
---|
153 | that wish to retrieve the name of the bus
|
---|
154 | controller. It will not be NULL for a bus
|
---|
155 | driver that wishes to retrieve the name of a
|
---|
156 | child controller.
|
---|
157 |
|
---|
158 | @param Language[in] A pointer to a Null-terminated ASCII string
|
---|
159 | array indicating the language. This is the
|
---|
160 | language of the driver name that the caller is
|
---|
161 | requesting, and it must match one of the
|
---|
162 | languages specified in SupportedLanguages. The
|
---|
163 | number of languages supported by a driver is up
|
---|
164 | to the driver writer. Language is specified in
|
---|
165 | RFC 4646 or ISO 639-2 language code format.
|
---|
166 |
|
---|
167 | @param ControllerName[out] A pointer to the Unicode string to return.
|
---|
168 | This Unicode string is the name of the
|
---|
169 | controller specified by ControllerHandle and
|
---|
170 | ChildHandle in the language specified by
|
---|
171 | Language from the point of view of the driver
|
---|
172 | specified by This.
|
---|
173 |
|
---|
174 | @retval EFI_SUCCESS The Unicode string for the user readable name in
|
---|
175 | the language specified by Language for the
|
---|
176 | driver specified by This was returned in
|
---|
177 | DriverName.
|
---|
178 |
|
---|
179 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
|
---|
180 |
|
---|
181 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
|
---|
182 | EFI_HANDLE.
|
---|
183 |
|
---|
184 | @retval EFI_INVALID_PARAMETER Language is NULL.
|
---|
185 |
|
---|
186 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
---|
187 |
|
---|
188 | @retval EFI_UNSUPPORTED The driver specified by This is not currently
|
---|
189 | managing the controller specified by
|
---|
190 | ControllerHandle and ChildHandle.
|
---|
191 |
|
---|
192 | @retval EFI_UNSUPPORTED The driver specified by This does not support
|
---|
193 | the language specified by Language.
|
---|
194 |
|
---|
195 | **/
|
---|
196 | EFI_STATUS
|
---|
197 | EFIAPI
|
---|
198 | VBoxVgaComponentNameGetControllerName (
|
---|
199 | IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
---|
200 | IN EFI_HANDLE ControllerHandle,
|
---|
201 | IN EFI_HANDLE ChildHandle OPTIONAL,
|
---|
202 | IN CHAR8 *Language,
|
---|
203 | OUT CHAR16 **ControllerName
|
---|
204 | )
|
---|
205 | {
|
---|
206 | EFI_STATUS Status;
|
---|
207 |
|
---|
208 | //
|
---|
209 | // This is a device driver, so ChildHandle must be NULL.
|
---|
210 | //
|
---|
211 | if (ChildHandle != NULL) {
|
---|
212 | return EFI_UNSUPPORTED;
|
---|
213 | }
|
---|
214 |
|
---|
215 | //
|
---|
216 | // Make sure this driver is currently managing ControllHandle
|
---|
217 | //
|
---|
218 | Status = EfiTestManagedDevice (
|
---|
219 | ControllerHandle,
|
---|
220 | gVBoxVgaDriverBinding.DriverBindingHandle,
|
---|
221 | &gEfiPciIoProtocolGuid
|
---|
222 | );
|
---|
223 | if (EFI_ERROR (Status)) {
|
---|
224 | return Status;
|
---|
225 | }
|
---|
226 |
|
---|
227 | //
|
---|
228 | // Get the Cirrus Logic 5430's Device structure
|
---|
229 | //
|
---|
230 | return LookupUnicodeString2 (
|
---|
231 | Language,
|
---|
232 | This->SupportedLanguages,
|
---|
233 | mVBoxVgaControllerNameTable,
|
---|
234 | ControllerName,
|
---|
235 | (BOOLEAN)(This == &gVBoxVgaComponentName)
|
---|
236 | );
|
---|
237 | }
|
---|