\r
**/\r
\r
-#include <Library/BaseMemoryLib.h>\r
#include <Library/DevicePathLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
#include <Library/PrintLib.h>\r
\r
#include "VirtioGpu.h"\r
\r
-//\r
-// Dummy Graphics Output Protocol GUID: a temporary placeholder for the EFI\r
-// counterpart. It will be replaced with the real thing as soon as we implement\r
-// the EFI GOP. Refer to VGPU_GOP.Gop.\r
-//\r
-STATIC EFI_GUID mDummyGraphicsOutputProtocolGuid = {\r
- 0x4983f8dc, 0x2782, 0x415b,\r
- { 0x91, 0xf5, 0x2c, 0xeb, 0x48, 0x4a, 0x0f, 0xe9 }\r
-};\r
-\r
//\r
// The device path node that describes the Video Output Device Attributes for\r
// the single head (UEFI child handle) that we support.\r
//\r
// Initialize our Graphics Output Protocol.\r
//\r
- // This means "nothing" for now.\r
+ // Fill in the function members of VgpuGop->Gop from the template, then set\r
+ // up the rest of the GOP infrastructure by calling SetMode() right now.\r
//\r
- Status = EFI_SUCCESS;\r
+ CopyMem (&VgpuGop->Gop, &mGopTemplate, sizeof mGopTemplate);\r
+ Status = VgpuGop->Gop.SetMode (&VgpuGop->Gop, 0);\r
if (EFI_ERROR (Status)) {\r
goto CloseVirtIoByChild;\r
}\r
// Install the Graphics Output Protocol on the child handle.\r
//\r
Status = gBS->InstallProtocolInterface (&VgpuGop->GopHandle,\r
- &mDummyGraphicsOutputProtocolGuid, EFI_NATIVE_INTERFACE,\r
+ &gEfiGraphicsOutputProtocolGuid, EFI_NATIVE_INTERFACE,\r
&VgpuGop->Gop);\r
if (EFI_ERROR (Status)) {\r
goto UninitGop;\r
return EFI_SUCCESS;\r
\r
UninitGop:\r
- //\r
- // Nothing, for now.\r
- //\r
+ ReleaseGopResources (VgpuGop, TRUE /* DisableHead */);\r
\r
CloseVirtIoByChild:\r
gBS->CloseProtocol (ParentBusController, &gVirtioDeviceProtocolGuid,\r
\r
VgpuGop = ParentBus->Child;\r
Status = gBS->UninstallProtocolInterface (VgpuGop->GopHandle,\r
- &mDummyGraphicsOutputProtocolGuid, &VgpuGop->Gop);\r
+ &gEfiGraphicsOutputProtocolGuid, &VgpuGop->Gop);\r
ASSERT_EFI_ERROR (Status);\r
\r
//\r
// Uninitialize VgpuGop->Gop.\r
//\r
- // Nothing, for now.\r
- //\r
- Status = EFI_SUCCESS;\r
- ASSERT_EFI_ERROR (Status);\r
+ ReleaseGopResources (VgpuGop, TRUE /* DisableHead */);\r
\r
Status = gBS->CloseProtocol (ParentBusController, &gVirtioDeviceProtocolGuid,\r
DriverBindingHandle, VgpuGop->GopHandle);\r
goto FreeVgpuDev;\r
}\r
\r
+ Status = VirtioGpuInit (VgpuDev);\r
+ if (EFI_ERROR (Status)) {\r
+ goto FreeVgpuDevBusName;\r
+ }\r
+\r
+ Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK,\r
+ VirtioGpuExitBoot, VgpuDev /* NotifyContext */,\r
+ &VgpuDev->ExitBoot);\r
+ if (EFI_ERROR (Status)) {\r
+ goto UninitGpu;\r
+ }\r
+\r
//\r
// Install the VGPU_DEV "protocol interface" on ControllerHandle.\r
//\r
Status = gBS->InstallProtocolInterface (&ControllerHandle,\r
&gEfiCallerIdGuid, EFI_NATIVE_INTERFACE, VgpuDev);\r
if (EFI_ERROR (Status)) {\r
- goto FreeVgpuDevBusName;\r
+ goto CloseExitBoot;\r
}\r
\r
if (RemainingDevicePath != NULL && IsDevicePathEnd (RemainingDevicePath)) {\r
VgpuDev);\r
}\r
\r
+CloseExitBoot:\r
+ if (VirtIoBoundJustNow) {\r
+ gBS->CloseEvent (VgpuDev->ExitBoot);\r
+ }\r
+\r
+UninitGpu:\r
+ if (VirtIoBoundJustNow) {\r
+ VirtioGpuUninit (VgpuDev);\r
+ }\r
+\r
FreeVgpuDevBusName:\r
if (VirtIoBoundJustNow) {\r
FreeUnicodeStringTable (VgpuDev->BusName);\r
&gEfiCallerIdGuid, VgpuDev);\r
ASSERT_EFI_ERROR (Status);\r
\r
+ Status = gBS->CloseEvent (VgpuDev->ExitBoot);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ VirtioGpuUninit (VgpuDev);\r
FreeUnicodeStringTable (VgpuDev->BusName);\r
FreePool (VgpuDev);\r
\r