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