1 | /* $Id: VBoxFsDxe.c 69500 2017-10-28 15:14:05Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxFsDxe.c - VirtualBox FS wrapper
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2017 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 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #include <Protocol/ComponentName.h>
|
---|
32 | #include <Protocol/ComponentName2.h>
|
---|
33 | #include <Protocol/DriverBinding.h>
|
---|
34 | #include <Protocol/PciIo.h>
|
---|
35 | #include <Library/BaseMemoryLib.h>
|
---|
36 | #include <Library/DebugLib.h>
|
---|
37 | #include <Library/UefiBootServicesTableLib.h>
|
---|
38 | #include <Library/UefiLib.h>
|
---|
39 | #include <IndustryStandard/Pci22.h>
|
---|
40 |
|
---|
41 |
|
---|
42 | /*********************************************************************************************************************************
|
---|
43 | * Internal Functions *
|
---|
44 | *********************************************************************************************************************************/
|
---|
45 | static EFI_STATUS EFIAPI
|
---|
46 | VBoxFsDB_Supported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle,
|
---|
47 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL);
|
---|
48 | static EFI_STATUS EFIAPI
|
---|
49 | VBoxFsDB_Start(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle,
|
---|
50 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL);
|
---|
51 | static EFI_STATUS EFIAPI
|
---|
52 | VBoxFsDB_Stop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle,
|
---|
53 | IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL);
|
---|
54 |
|
---|
55 | static EFI_STATUS EFIAPI
|
---|
56 | VBoxFsCN_GetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
---|
57 | IN CHAR8 *Language, OUT CHAR16 **DriverName);
|
---|
58 | static EFI_STATUS EFIAPI
|
---|
59 | VBoxFsCN_GetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
---|
60 | IN EFI_HANDLE ControllerHandle,
|
---|
61 | IN EFI_HANDLE ChildHandle OPTIONAL,
|
---|
62 | IN CHAR8 *Language, OUT CHAR16 **ControllerName);
|
---|
63 |
|
---|
64 | static EFI_STATUS EFIAPI
|
---|
65 | VBoxFsCN2_GetDriverName(IN EFI_COMPONENT_NAME2_PROTOCOL *This,
|
---|
66 | IN CHAR8 *Language, OUT CHAR16 **DriverName);
|
---|
67 | static EFI_STATUS EFIAPI
|
---|
68 | VBoxFsCN2_GetControllerName(IN EFI_COMPONENT_NAME2_PROTOCOL *This,
|
---|
69 | IN EFI_HANDLE ControllerHandle,
|
---|
70 | IN EFI_HANDLE ChildHandle OPTIONAL,
|
---|
71 | IN CHAR8 *Language, OUT CHAR16 **ControllerName);
|
---|
72 |
|
---|
73 |
|
---|
74 | /** EFI Driver Binding Protocol. */
|
---|
75 | static EFI_DRIVER_BINDING_PROTOCOL g_VBoxFsDB =
|
---|
76 | {
|
---|
77 | VBoxFsDB_Supported,
|
---|
78 | VBoxFsDB_Start,
|
---|
79 | VBoxFsDB_Stop,
|
---|
80 | /* .Version = */ 1,
|
---|
81 | /* .ImageHandle = */ NULL,
|
---|
82 | /* .DriverBindingHandle = */ NULL
|
---|
83 | };
|
---|
84 |
|
---|
85 | /** EFI Component Name Protocol. */
|
---|
86 | static const EFI_COMPONENT_NAME_PROTOCOL g_VBoxFsCN =
|
---|
87 | {
|
---|
88 | VBoxFsCN_GetDriverName,
|
---|
89 | VBoxFsCN_GetControllerName,
|
---|
90 | "eng"
|
---|
91 | };
|
---|
92 |
|
---|
93 | /** EFI Component Name 2 Protocol. */
|
---|
94 | static const EFI_COMPONENT_NAME2_PROTOCOL g_VBoxFsCN2 =
|
---|
95 | {
|
---|
96 | VBoxFsCN2_GetDriverName,
|
---|
97 | VBoxFsCN2_GetControllerName,
|
---|
98 | "en"
|
---|
99 | };
|
---|
100 |
|
---|
101 | /** Driver name translation table. */
|
---|
102 | static CONST EFI_UNICODE_STRING_TABLE g_aVBoxFsDriverLangAndNames[] =
|
---|
103 | {
|
---|
104 | { "eng;en", L"VBox Universal FS Wrapper Driver" },
|
---|
105 | { NULL, NULL }
|
---|
106 | };
|
---|
107 |
|
---|
108 |
|
---|
109 |
|
---|
110 | /**
|
---|
111 | * VBoxFsDxe entry point.
|
---|
112 | *
|
---|
113 | * @returns EFI status code.
|
---|
114 | *
|
---|
115 | * @param ImageHandle The image handle.
|
---|
116 | * @param SystemTable The system table pointer.
|
---|
117 | */
|
---|
118 | EFI_STATUS EFIAPI
|
---|
119 | DxeInitializeVBoxFs(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
---|
120 | {
|
---|
121 | EFI_STATUS rc;
|
---|
122 | DEBUG((DEBUG_INFO, "DxeInitializeVBoxFsDxe\n"));
|
---|
123 |
|
---|
124 | rc = EfiLibInstallDriverBindingComponentName2(ImageHandle, SystemTable,
|
---|
125 | &g_VBoxFsDB, ImageHandle,
|
---|
126 | &g_VBoxFsCN, &g_VBoxFsCN2);
|
---|
127 | ASSERT_EFI_ERROR(rc);
|
---|
128 | return rc;
|
---|
129 | }
|
---|
130 |
|
---|
131 | EFI_STATUS EFIAPI
|
---|
132 | DxeUninitializeVBoxFs(IN EFI_HANDLE ImageHandle)
|
---|
133 | {
|
---|
134 | return EFI_SUCCESS;
|
---|
135 | }
|
---|
136 |
|
---|
137 |
|
---|
138 | /**
|
---|
139 | * @copydoc EFI_DRIVER_BINDING_SUPPORTED
|
---|
140 | */
|
---|
141 | static EFI_STATUS EFIAPI
|
---|
142 | VBoxFsDB_Supported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle,
|
---|
143 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
|
---|
144 | {
|
---|
145 | EFI_STATUS rcRet = EFI_UNSUPPORTED;
|
---|
146 | /* EFI_STATUS rc; */
|
---|
147 |
|
---|
148 | return rcRet;
|
---|
149 | }
|
---|
150 |
|
---|
151 |
|
---|
152 | /**
|
---|
153 | * @copydoc EFI_DRIVER_BINDING_START
|
---|
154 | */
|
---|
155 | static EFI_STATUS EFIAPI
|
---|
156 | VBoxFsDB_Start(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle,
|
---|
157 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
|
---|
158 | {
|
---|
159 | /* EFI_STATUS rc; */
|
---|
160 |
|
---|
161 | return EFI_UNSUPPORTED;
|
---|
162 | }
|
---|
163 |
|
---|
164 |
|
---|
165 | /**
|
---|
166 | * @copydoc EFI_DRIVER_BINDING_STOP
|
---|
167 | */
|
---|
168 | static EFI_STATUS EFIAPI
|
---|
169 | VBoxFsDB_Stop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle,
|
---|
170 | IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL)
|
---|
171 | {
|
---|
172 | /* EFI_STATUS rc; */
|
---|
173 |
|
---|
174 | return EFI_UNSUPPORTED;
|
---|
175 | }
|
---|
176 |
|
---|
177 |
|
---|
178 | /** @copydoc EFI_COMPONENT_NAME_GET_DRIVER_NAME */
|
---|
179 | static EFI_STATUS EFIAPI
|
---|
180 | VBoxFsCN_GetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
---|
181 | IN CHAR8 *Language, OUT CHAR16 **DriverName)
|
---|
182 | {
|
---|
183 | return LookupUnicodeString2(Language,
|
---|
184 | This->SupportedLanguages,
|
---|
185 | &g_aVBoxFsDriverLangAndNames[0],
|
---|
186 | DriverName,
|
---|
187 | TRUE);
|
---|
188 | }
|
---|
189 |
|
---|
190 | /** @copydoc EFI_COMPONENT_NAME_GET_CONTROLLER_NAME */
|
---|
191 | static EFI_STATUS EFIAPI
|
---|
192 | VBoxFsCN_GetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
---|
193 | IN EFI_HANDLE ControllerHandle,
|
---|
194 | IN EFI_HANDLE ChildHandle OPTIONAL,
|
---|
195 | IN CHAR8 *Language, OUT CHAR16 **ControllerName)
|
---|
196 | {
|
---|
197 | /** @todo try query the protocol from the controller and forward the query. */
|
---|
198 | return EFI_UNSUPPORTED;
|
---|
199 | }
|
---|
200 |
|
---|
201 | /** @copydoc EFI_COMPONENT_NAME2_GET_DRIVER_NAME */
|
---|
202 | static EFI_STATUS EFIAPI
|
---|
203 | VBoxFsCN2_GetDriverName(IN EFI_COMPONENT_NAME2_PROTOCOL *This,
|
---|
204 | IN CHAR8 *Language, OUT CHAR16 **DriverName)
|
---|
205 | {
|
---|
206 | return LookupUnicodeString2(Language,
|
---|
207 | This->SupportedLanguages,
|
---|
208 | &g_aVBoxFsDriverLangAndNames[0],
|
---|
209 | DriverName,
|
---|
210 | FALSE);
|
---|
211 | }
|
---|
212 |
|
---|
213 | /** @copydoc EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME */
|
---|
214 | static EFI_STATUS EFIAPI
|
---|
215 | VBoxFsCN2_GetControllerName(IN EFI_COMPONENT_NAME2_PROTOCOL *This,
|
---|
216 | IN EFI_HANDLE ControllerHandle,
|
---|
217 | IN EFI_HANDLE ChildHandle OPTIONAL,
|
---|
218 | IN CHAR8 *Language, OUT CHAR16 **ControllerName)
|
---|
219 | {
|
---|
220 | /** @todo try query the protocol from the controller and forward the query. */
|
---|
221 | return EFI_UNSUPPORTED;
|
---|
222 | }
|
---|