diff options
author | Laszlo Ersek <lersek@redhat.com> | 2016-08-18 01:31:27 +0200 |
---|---|---|
committer | Laszlo Ersek <lersek@redhat.com> | 2016-09-01 22:55:53 +0200 |
commit | c5f235bbf2ac6ecf9acec023a1840b03cbfb5efd (patch) | |
tree | 3180e93cbec050e1cd4dd48968a5e4bc1c582f4f /OvmfPkg/VirtioGpuDxe/DriverBinding.c | |
parent | 92f200c2d63c5d27dffbf8d85087028a3fd62ef6 (diff) | |
download | edk2-c5f235bbf2ac6ecf9acec023a1840b03cbfb5efd.tar.gz edk2-c5f235bbf2ac6ecf9acec023a1840b03cbfb5efd.tar.bz2 edk2-c5f235bbf2ac6ecf9acec023a1840b03cbfb5efd.zip |
OvmfPkg/VirtioGpuDxe: initialize and tear down VirtIo GPU device
This patch implements the steps listed in section "3.1.1 Driver
Requirements: Device Initialization" of the Virtio V1.0 Committee Spec 04.
The VirtIo GPU is brought up in VirtioGpuDriverBindingStart(), and down in
VirtioGpuDriverBindingStop().
We also add an ExitBootServices() callback that resets the device. This
ensures that the device model abandons any guest memory areas when we
transfer control to the guest OS.
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Ref: https://tianocore.acgmultimedia.com/show_bug.cgi?id=66
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Diffstat (limited to 'OvmfPkg/VirtioGpuDxe/DriverBinding.c')
-rw-r--r-- | OvmfPkg/VirtioGpuDxe/DriverBinding.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/OvmfPkg/VirtioGpuDxe/DriverBinding.c b/OvmfPkg/VirtioGpuDxe/DriverBinding.c index b902a07871..bdea55ef7d 100644 --- a/OvmfPkg/VirtioGpuDxe/DriverBinding.c +++ b/OvmfPkg/VirtioGpuDxe/DriverBinding.c @@ -646,13 +646,25 @@ VirtioGpuDriverBindingStart ( goto FreeVgpuDev;
}
+ Status = VirtioGpuInit (VgpuDev);
+ if (EFI_ERROR (Status)) {
+ goto FreeVgpuDevBusName;
+ }
+
+ Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK,
+ VirtioGpuExitBoot, VgpuDev /* NotifyContext */,
+ &VgpuDev->ExitBoot);
+ if (EFI_ERROR (Status)) {
+ goto UninitGpu;
+ }
+
//
// Install the VGPU_DEV "protocol interface" on ControllerHandle.
//
Status = gBS->InstallProtocolInterface (&ControllerHandle,
&gEfiCallerIdGuid, EFI_NATIVE_INTERFACE, VgpuDev);
if (EFI_ERROR (Status)) {
- goto FreeVgpuDevBusName;
+ goto CloseExitBoot;
}
if (RemainingDevicePath != NULL && IsDevicePathEnd (RemainingDevicePath)) {
@@ -693,6 +705,16 @@ UninstallVgpuDev: VgpuDev);
}
+CloseExitBoot:
+ if (VirtIoBoundJustNow) {
+ gBS->CloseEvent (VgpuDev->ExitBoot);
+ }
+
+UninitGpu:
+ if (VirtIoBoundJustNow) {
+ VirtioGpuUninit (VgpuDev);
+ }
+
FreeVgpuDevBusName:
if (VirtIoBoundJustNow) {
FreeUnicodeStringTable (VgpuDev->BusName);
@@ -761,6 +783,10 @@ VirtioGpuDriverBindingStop ( &gEfiCallerIdGuid, VgpuDev);
ASSERT_EFI_ERROR (Status);
+ Status = gBS->CloseEvent (VgpuDev->ExitBoot);
+ ASSERT_EFI_ERROR (Status);
+
+ VirtioGpuUninit (VgpuDev);
FreeUnicodeStringTable (VgpuDev->BusName);
FreePool (VgpuDev);
|