]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Refine the comments for BiosVideo thunk driver.
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 1 Mar 2009 07:12:53 +0000 (07:12 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 1 Mar 2009 07:12:53 +0000 (07:12 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7738 6f19259b-4bc3-4df7-8a09-765794883524

DuetPkg/BiosVideoThunkDxe/BiosVideo.c
DuetPkg/BiosVideoThunkDxe/BiosVideo.h
DuetPkg/BiosVideoThunkDxe/LegacyBiosThunk.c

index 0d8b0c65d12b3bd44efc18164267865c64027796..1b471d9efc3942fb5be0834099041309ff81c917 100644 (file)
@@ -1,4 +1,6 @@
-/*++\r
+/** @file\r
+\r
+  BiosVideo driver produce EFI_GRAPHIC_OUTPUT_PROTOCOL via LegacyBios Video rom.\r
 \r
 Copyright (c) 2006 - 2008, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
@@ -9,17 +11,7 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
-Module Name:\r
-\r
-  BiosVideo.c\r
-\r
-Abstract:\r
-\r
-  ConsoleOut Routines that speak VGA.\r
-\r
-Revision History\r
-\r
---*/\r
+**/\r
 \r
 #include "BiosVideo.h"\r
 \r
@@ -38,109 +30,35 @@ EFI_DRIVER_BINDING_PROTOCOL gBiosVideoDriverBinding = {
 //\r
 // Global lookup tables for VGA graphics modes\r
 //\r
-UINT8                       mVgaLeftMaskTable[]   = { 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };\r
+UINT8 mVgaLeftMaskTable[]   = { 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };\r
+\r
+UINT8 mVgaRightMaskTable[]  = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };\r
 \r
-UINT8                       mVgaRightMaskTable[]  = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };\r
+UINT8 mVgaBitMaskTable[]    = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };\r
 \r
-UINT8                       mVgaBitMaskTable[]    = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };\r
+EFI_LEGACY_8259_PROTOCOL   *mLegacy8259 = NULL;\r
+THUNK_CONTEXT              mThunkContext;\r
 \r
 EFI_GRAPHICS_OUTPUT_BLT_PIXEL  mVgaColorToGraphicsOutputColor[] = {\r
-  {\r
-    0x00,\r
-    0x00,\r
-    0x00,\r
-    0x00\r
-  },\r
-  {\r
-    0x98,\r
-    0x00,\r
-    0x00,\r
-    0x00\r
-  },\r
-  {\r
-    0x00,\r
-    0x98,\r
-    0x00,\r
-    0x00\r
-  },\r
-  {\r
-    0x98,\r
-    0x98,\r
-    0x00,\r
-    0x00\r
-  },\r
-  {\r
-    0x00,\r
-    0x00,\r
-    0x98,\r
-    0x00\r
-  },\r
-  {\r
-    0x98,\r
-    0x00,\r
-    0x98,\r
-    0x00\r
-  },\r
-  {\r
-    0x00,\r
-    0x98,\r
-    0x98,\r
-    0x00\r
-  },\r
-  {\r
-    0x98,\r
-    0x98,\r
-    0x98,\r
-    0x00\r
-  },\r
-  {\r
-    0x10,\r
-    0x10,\r
-    0x10,\r
-    0x00\r
-  },\r
-  {\r
-    0xff,\r
-    0x10,\r
-    0x10,\r
-    0x00\r
-  },\r
-  {\r
-    0x10,\r
-    0xff,\r
-    0x10,\r
-    0x00\r
-  },\r
-  {\r
-    0xff,\r
-    0xff,\r
-    0x10,\r
-    0x00\r
-  },\r
-  {\r
-    0x10,\r
-    0x10,\r
-    0xff,\r
-    0x00\r
-  },\r
-  {\r
-    0xf0,\r
-    0x10,\r
-    0xff,\r
-    0x00\r
-  },\r
-  {\r
-    0x10,\r
-    0xff,\r
-    0xff,\r
-    0x00\r
-  },\r
-  {\r
-    0xff,\r
-    0xff,\r
-    0xff,\r
-    0x00\r
-  }\r
+  //\r
+  // {B, G, R, reserved}\r
+  //  \r
+  {0x00, 0x00, 0x00, 0x00}, // BLACK\r
+  {0x98, 0x00, 0x00, 0x00}, // LIGHTBLUE\r
+  {0x00, 0x98, 0x00, 0x00}, // LIGHGREEN\r
+  {0x98, 0x98, 0x00, 0x00}, // LIGHCYAN\r
+  {0x00, 0x00, 0x98, 0x00}, // LIGHRED\r
+  {0x98, 0x00, 0x98, 0x00}, // MAGENTA\r
+  {0x00, 0x98, 0x98, 0x00}, // BROWN\r
+  {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY\r
+  {0x10, 0x10, 0x10, 0x00},\r
+  {0xff, 0x10, 0x10, 0x00}, // BLUE\r
+  {0x10, 0xff, 0x10, 0x00}, // LIME\r
+  {0xff, 0xff, 0x10, 0x00}, // CYAN\r
+  {0x10, 0x10, 0xff, 0x00}, // RED\r
+  {0xf0, 0x10, 0xff, 0x00}, // FUCHSIA\r
+  {0x10, 0xff, 0xff, 0x00}, // YELLOW\r
+  {0xff, 0xff, 0xff, 0x00}  // WHITE  \r
 };\r
 \r
 //\r
@@ -175,17 +93,44 @@ VESA_BIOS_EXTENSIONS_EDID_TIMING mEstablishedEdidTiming[] = {
   {1152, 870, 75}\r
 };\r
 \r
+/**\r
+  Install child hanlde for a detect BiosVideo device and install related protocol\r
+  into this handle, such as EFI_GRAPHIC_OUTPUT_PROTOCOL.\r
+\r
+  @param This                Instance pointer of EFI_DRIVER_BINDING_PROTOCOL\r
+  @param ParentHandle        Parent's controller handle\r
+  @param ParentPciIo         Parent's EFI_PCI_IO_PROTOCOL instance pointer\r
+  @param ParentLegacy8259    Parent's EFI_LEGACY_8259_PROTOCOL instance pointer \r
+  @param ParentDevicePath    Parent's BIOS Video controller device path\r
+  @param RemainingDevicePath Remaining device path node instance for children.\r
+\r
+  @return whether success to create children handle for a VGA device and install \r
+          related protocol into new children handle.\r
+\r
+**/\r
 EFI_STATUS\r
 BiosVideoChildHandleInstall (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
   IN  EFI_HANDLE                     ParentHandle,\r
   IN  EFI_PCI_IO_PROTOCOL            *ParentPciIo,\r
   IN  EFI_LEGACY_8259_PROTOCOL       *ParentLegacy8259,\r
+  IN  THUNK_CONTEXT                  *ThunkContext,\r
   IN  EFI_DEVICE_PATH_PROTOCOL       *ParentDevicePath,\r
   IN  EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
   )\r
 ;\r
 \r
+/**\r
+  Deregister an video child handle and free resources\r
+\r
+  @param This            Protocol instance pointer.\r
+  @param Controller      Video controller handle\r
+  @param Handle          Video child handle\r
+\r
+  @return EFI_STATUS\r
+\r
+**/\r
+\r
 EFI_STATUS\r
 BiosVideoChildHandleUninstall (\r
   EFI_DRIVER_BINDING_PROTOCOL    *This,\r
@@ -194,34 +139,32 @@ BiosVideoChildHandleUninstall (
   )\r
 ;\r
 \r
+/**\r
+  Collect the resource from destroyed bios video device.\r
+\r
+  @param BiosVideoPrivate   Video child device private data structure\r
+**/\r
+\r
 VOID\r
 BiosVideoDeviceReleaseResource (\r
   BIOS_VIDEO_DEV  *BiosVideoPrivate\r
   )\r
 ;\r
 \r
+/**\r
+  Driver Entry Point.\r
+\r
+  @param ImageHandle      Handle of driver image.\r
+  @param SystemTable      Pointer to system table.\r
+\r
+  @return EFI_STATUS\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoDriverEntryPoint (\r
   IN EFI_HANDLE         ImageHandle,\r
   IN EFI_SYSTEM_TABLE   *SystemTable\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Driver Entry Point.\r
-\r
-  Arguments:\r
-\r
-  ImageHandle - Handle of driver image.\r
-  SystemTable - Pointer to system table.\r
-\r
-  Returns:\r
-\r
-    EFI_STATUS\r
-\r
---*/\r
 {\r
   EFI_STATUS  Status;\r
 \r
@@ -237,52 +180,17 @@ BiosVideoDriverEntryPoint (
   return Status;\r
 }\r
 \r
-VOID\r
-EFIAPI\r
-BiosVideoExitBootServices (\r
-  EFI_EVENT  Event,\r
-  VOID       *Context\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Callback function for exit boot service event\r
-\r
-Arguments:\r
-\r
-  Event   - EFI_EVENT structure\r
-  Context - Event context\r
+/**\r
+  Test to see if Bios Video could be supported on the Controller.\r
 \r
-Returns:\r
+  @param This                  Pointer to driver binding protocol\r
+  @param Controller            Controller handle to connect\r
+  @param RemainingDevicePath   A pointer to the remaining portion of a device path\r
 \r
-  None\r
-\r
---*/\r
-{\r
-/*\r
-  BIOS_VIDEO_DEV        *BiosVideoPrivate;\r
-  EFI_IA32_REGISTER_SET Regs;\r
-\r
-  //\r
-  // Get our context\r
-  //\r
-  BiosVideoPrivate = (BIOS_VIDEO_DEV *) Context;\r
-\r
-  //\r
-  // Set the 80x25 Text VGA Mode\r
-  //\r
-  Regs.H.AH = 0x00;\r
-  Regs.H.AL = 0x83;\r
-  BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-\r
-  Regs.H.AH = 0x11;\r
-  Regs.H.AL = 0x14;\r
-  Regs.H.BL = 0;\r
-  BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-*/\r
-}\r
+  @retval EFI_SUCCESS         This driver supports this device.\r
+  @retval other               This driver does not support this device.\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoDriverBindingSupported (\r
@@ -290,25 +198,6 @@ BiosVideoDriverBindingSupported (
   IN EFI_HANDLE                   Controller,\r
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Supported.\r
-\r
-  Arguments:\r
-\r
-  This - Pointer to driver binding protocol\r
-  Controller - Controller handle to connect\r
-  RemainingDevicePath - A pointer to the remaining portion of a device path\r
-\r
-\r
-  Returns:\r
-\r
-  EFI_STATUS - EFI_SUCCESS:This controller can be managed by this driver,\r
-               Otherwise, this controller cannot be managed by this driver\r
-\r
---*/\r
 {\r
   EFI_STATUS                Status;\r
   EFI_LEGACY_8259_PROTOCOL  *LegacyBios;\r
@@ -351,6 +240,16 @@ BiosVideoDriverBindingSupported (
   return Status;\r
 }\r
 \r
+/**\r
+  Install Graphics Output Protocol onto VGA device handles\r
+\r
+  @param This                   Pointer to driver binding protocol\r
+  @param Controller             Controller handle to connect\r
+  @param RemainingDevicePath    A pointer to the remaining portion of a device path\r
+\r
+  @return EFI_STATUS\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoDriverBindingStart (\r
@@ -358,28 +257,10 @@ BiosVideoDriverBindingStart (
   IN EFI_HANDLE                   Controller,\r
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Install Graphics Output Protocol onto VGA device handles\r
-\r
-  Arguments:\r
-\r
-  This - Pointer to driver binding protocol\r
-  Controller - Controller handle to connect\r
-  RemainingDevicePath - A pointer to the remaining portion of a device path\r
-\r
-  Returns:\r
-\r
-    EFI_STATUS\r
-\r
---*/\r
 {\r
   EFI_STATUS                      Status;\r
   EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
   EFI_PCI_IO_PROTOCOL             *PciIo;\r
-  EFI_LEGACY_8259_PROTOCOL        *Legacy8259;\r
 \r
   PciIo = NULL;\r
   //\r
@@ -410,14 +291,18 @@ BiosVideoDriverBindingStart (
   }\r
 \r
   //\r
-  // See if the Legacy BIOS Protocol is available\r
+  // Establish legacy environment for thunk call for all children handle.\r
   //\r
-  Status = gBS->LocateProtocol (&gEfiLegacy8259ProtocolGuid, NULL, (VOID **) &Legacy8259);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
+  if (mLegacy8259 == NULL) {\r
+    Status = gBS->LocateProtocol (&gEfiLegacy8259ProtocolGuid, NULL, (VOID **) &mLegacy8259);\r
+    if (EFI_ERROR (Status)) {\r
+        goto Done;\r
+    }\r
+    \r
+    InitializeBiosIntCaller(&mThunkContext);\r
+    InitializeInterruptRedirection(mLegacy8259);\r
   }\r
 \r
-\r
   //\r
   // Create child handle and install GraphicsOutputProtocol on it\r
   //\r
@@ -425,7 +310,8 @@ BiosVideoDriverBindingStart (
              This,\r
              Controller,\r
              PciIo,\r
-             Legacy8259,\r
+             mLegacy8259,\r
+             &mThunkContext,\r
              ParentDevicePath,\r
              RemainingDevicePath\r
              );\r
@@ -448,6 +334,19 @@ Done:
   return Status;\r
 }\r
 \r
+/**\r
+  Stop this driver on Controller \r
+\r
+  @param  This              Protocol instance pointer.\r
+  @param  Controller        Handle of device to stop driver on\r
+  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
+                            children is zero stop the entire bus driver.\r
+  @param  ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+  @retval EFI_SUCCESS       This driver is removed Controller.\r
+  @retval other             This driver was not removed from this device.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoDriverBindingStop (\r
@@ -456,33 +355,11 @@ BiosVideoDriverBindingStop (
   IN  UINTN                           NumberOfChildren,\r
   IN  EFI_HANDLE                      *ChildHandleBuffer\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Stop.\r
-\r
-  Arguments:\r
-\r
-  This - Pointer to driver binding protocol\r
-  Controller - Controller handle to connect\r
-  NumberOfChilren - Number of children handle created by this driver\r
-  ChildHandleBuffer - Buffer containing child handle created\r
-\r
-  Returns:\r
-\r
-  EFI_SUCCESS - Driver disconnected successfully from controller\r
-  EFI_UNSUPPORTED - Cannot find BIOS_VIDEO_DEV structure\r
-\r
---*/\r
 {\r
   EFI_STATUS                   Status;\r
-  BIOS_VIDEO_DEV               *BiosVideoPrivate;\r
   BOOLEAN                      AllChildrenStopped;\r
   UINTN                        Index;\r
 \r
-  BiosVideoPrivate = NULL;\r
-\r
   if (NumberOfChildren == 0) {\r
     //\r
     // Close PCI I/O protocol on the controller handle\r
@@ -513,32 +390,31 @@ BiosVideoDriverBindingStop (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Install child hanlde for a detect BiosVideo device and install related protocol\r
+  into this handle, such as EFI_GRAPHIC_OUTPUT_PROTOCOL.\r
+\r
+  @param This                Instance pointer of EFI_DRIVER_BINDING_PROTOCOL\r
+  @param ParentHandle        Parent's controller handle\r
+  @param ParentPciIo         Parent's EFI_PCI_IO_PROTOCOL instance pointer\r
+  @param ParentLegacy8259    Parent's EFI_LEGACY_8259_PROTOCOL instance pointer \r
+  @param ParentDevicePath    Parent's BIOS Video controller device path\r
+  @param RemainingDevicePath Remaining device path node instance for children.\r
+\r
+  @return whether success to create children handle for a VGA device and install \r
+          related protocol into new children handle.\r
+\r
+**/\r
 EFI_STATUS\r
 BiosVideoChildHandleInstall (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
   IN  EFI_HANDLE                     ParentHandle,\r
   IN  EFI_PCI_IO_PROTOCOL            *ParentPciIo,\r
   IN  EFI_LEGACY_8259_PROTOCOL       *ParentLegacy8259,\r
+  IN  THUNK_CONTEXT                  *ParentThunkContext,\r
   IN  EFI_DEVICE_PATH_PROTOCOL       *ParentDevicePath,\r
   IN  EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Install child handles if the Handle supports MBR format.\r
-\r
-Arguments:       \r
-  This       - Calling context.\r
-  Handle     - Parent Handle \r
-  PciIo      - Parent PciIo interface\r
-  LegacyBios  - Parent LegacyBios interface\r
-  DevicePath - Parent Device Path\r
-\r
-Returns:\r
-  EFI_SUCCESS - If a child handle was added\r
-  other       - A child handle was not added\r
-\r
---*/\r
 {\r
   EFI_STATUS               Status;\r
   BIOS_VIDEO_DEV           *BiosVideoPrivate;\r
@@ -569,21 +445,8 @@ Returns:
   // Initialize the child private structure\r
   //\r
   BiosVideoPrivate->Signature = BIOS_VIDEO_DEV_SIGNATURE;\r
-  BiosVideoPrivate->Handle = NULL;\r
-\r
-  /**\r
-  Status = gBS->CreateEvent (\r
-                  EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,\r
-                  EFI_TPL_NOTIFY,\r
-                  BiosVideoExitBootServices,\r
-                  BiosVideoPrivate,\r
-                  &BiosVideoPrivate->ExitBootServicesEvent\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  **/\r
-  \r
+  BiosVideoPrivate->Handle    = NULL;\r
+\r
   //\r
   // Fill in Graphics Output specific mode structures\r
   //\r
@@ -612,16 +475,14 @@ Returns:
   //\r
   // Child handle need to consume the Legacy Bios protocol\r
   //\r
-  BiosVideoPrivate->Legacy8259 = ParentLegacy8259;\r
-\r
+  BiosVideoPrivate->Legacy8259   = ParentLegacy8259;\r
+  BiosVideoPrivate->ThunkContext = ParentThunkContext;\r
+  \r
   //\r
   // When check for VBE, PCI I/O protocol is needed, so use parent's protocol interface temporally\r
   //\r
   BiosVideoPrivate->PciIo = ParentPciIo;\r
 \r
-  InitializeBiosIntCaller(BiosVideoPrivate);\r
-  InitializeInterruptRedirection(BiosVideoPrivate);\r
-\r
   //\r
   // Check for VESA BIOS Extensions for modes that are compatible with Graphics Output\r
   //\r
@@ -652,9 +513,9 @@ Returns:
   if (BiosVideoPrivate->ProduceGraphicsOutput) {\r
     if (RemainingDevicePath == NULL) {\r
       ZeroMem (&AcpiDeviceNode, sizeof (ACPI_ADR_DEVICE_PATH));\r
-      AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH;\r
+      AcpiDeviceNode.Header.Type    = ACPI_DEVICE_PATH;\r
       AcpiDeviceNode.Header.SubType = ACPI_ADR_DP;\r
-      AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0);\r
+      AcpiDeviceNode.ADR            = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0);\r
       SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof (ACPI_ADR_DEVICE_PATH));\r
 \r
       BiosVideoPrivate->DevicePath = AppendDevicePathNode (\r
@@ -720,29 +581,22 @@ Done:
   return Status;\r
 }\r
 \r
+/**\r
+  Deregister an video child handle and free resources\r
+\r
+  @param This            Protocol instance pointer.\r
+  @param Controller      Video controller handle\r
+  @param Handle          Video child handle\r
+\r
+  @return EFI_STATUS\r
+\r
+**/\r
 EFI_STATUS\r
 BiosVideoChildHandleUninstall (\r
   EFI_DRIVER_BINDING_PROTOCOL    *This,\r
   EFI_HANDLE                     Controller,\r
   EFI_HANDLE                     Handle\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Deregister an video child handle and free resources\r
-\r
-Arguments:\r
-\r
-  This            - Protocol instance pointer.\r
-  Controller      - Video controller handle\r
-  Handle          - Video child handle\r
-\r
-Returns:\r
-\r
-  EFI_STATUS\r
-\r
---*/\r
 {\r
   EFI_STATUS                   Status;\r
   EFI_IA32_REGISTER_SET        Regs;\r
@@ -853,24 +707,16 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Collect the resource from destroyed bios video device.\r
+\r
+  @param BiosVideoPrivate   Video child device private data structure\r
+\r
+**/\r
 VOID\r
 BiosVideoDeviceReleaseResource (\r
   BIOS_VIDEO_DEV  *BiosVideoPrivate\r
   )\r
-/*++\r
-Routing Description:\r
-\r
-  Release resources of an video child device before stopping it.\r
-\r
-Arguments:\r
-\r
-  BiosVideoPrivate  -  Video child device private data structure\r
-\r
-Returns:\r
-\r
-    NONE\r
-    \r
----*/\r
 {\r
   if (BiosVideoPrivate == NULL) {\r
     return ;\r
@@ -940,37 +786,26 @@ Returns:
     gBS->FreePool (BiosVideoPrivate->DevicePath);\r
   }\r
 \r
-  //\r
-  // Close the ExitBootServices event\r
-  //\r
-  if (BiosVideoPrivate->ExitBootServicesEvent != NULL) {\r
-    gBS->CloseEvent (BiosVideoPrivate->ExitBootServicesEvent);\r
-  }\r
-\r
   gBS->FreePool (BiosVideoPrivate);\r
 \r
   return ;\r
 }\r
 \r
-STATIC\r
-UINT32\r
-CalculateEdidKey (\r
-  VESA_BIOS_EXTENSIONS_EDID_TIMING       *EdidTiming\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
+/**\r
 \r
   Generate a search key for a specified timing data.\r
 \r
-  Arguments:\r
 \r
-  EdidTiming       - Pointer to EDID timing\r
+  @param EdidTiming      - Pointer to EDID timing\r
 \r
-  Returns:\r
-  The 32 bit unique key for search.\r
+  @return The 32 bit unique key for search.\r
 \r
---*/\r
+**/\r
+STATIC\r
+UINT32\r
+CalculateEdidKey (\r
+  VESA_BIOS_EXTENSIONS_EDID_TIMING       *EdidTiming\r
+  )\r
 {\r
   UINT32 Key;\r
 \r
@@ -981,28 +816,24 @@ CalculateEdidKey (
   return Key;\r
 }\r
 \r
-STATIC\r
-BOOLEAN\r
-ParseEdidData (\r
-  UINT8                                      *EdidBuffer,\r
-  VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING *ValidEdidTiming\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
+/**\r
 \r
   Parse the Established Timing and Standard Timing in EDID data block.\r
 \r
-  Arguments:\r
 \r
-  EdidBuffer       - Pointer to EDID data block\r
-  ValidEdidTiming  - Valid EDID timing information\r
+  @param EdidBuffer      - Pointer to EDID data block\r
+  @param ValidEdidTiming - Valid EDID timing information\r
 \r
-  Returns:\r
-  TRUE              - The EDID data is valid.\r
-  FALSE             - The EDID data is invalid.\r
+  @return TRUE              - The EDID data is valid.\r
+          FALSE             - The EDID data is invalid.\r
 \r
---*/\r
+**/\r
+STATIC\r
+BOOLEAN\r
+ParseEdidData (\r
+  UINT8                                      *EdidBuffer,\r
+  VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING *ValidEdidTiming\r
+  )\r
 {\r
   UINT8  CheckSum;\r
   UINT32 Index;\r
@@ -1093,29 +924,24 @@ ParseEdidData (
   return TRUE;\r
 }\r
 \r
-STATIC\r
-BOOLEAN\r
-SearchEdidTiming (\r
-  VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING *ValidEdidTiming,\r
-  VESA_BIOS_EXTENSIONS_EDID_TIMING       *EdidTiming\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
+/**\r
 \r
   Search a specified Timing in all the valid EDID timings.\r
 \r
-  Arguments:\r
 \r
-  ValidEdidTiming  - All valid EDID timing information.\r
-  EdidTiming       - The Timing to search for.\r
+  @param ValidEdidTiming - All valid EDID timing information.\r
+  @param EdidTiming      - The Timing to search for.\r
 \r
-  Returns:\r
+  @return TRUE  - Found.\r
+          FALSE - Not found.\r
 \r
-  TRUE  - Found.\r
-  FALSE - Not found.\r
-\r
---*/\r
+**/\r
+STATIC\r
+BOOLEAN\r
+SearchEdidTiming (\r
+  VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING *ValidEdidTiming,\r
+  VESA_BIOS_EXTENSIONS_EDID_TIMING       *EdidTiming\r
+  )\r
 {\r
   UINT32 Index;\r
   UINT32 Key;\r
@@ -1134,6 +960,14 @@ SearchEdidTiming (
 #define PCI_DEVICE_ENABLED  (EFI_PCI_COMMAND_IO_SPACE | EFI_PCI_COMMAND_MEMORY_SPACE)\r
 \r
 \r
+/**\r
+  Judge whether this device is VGA device.\r
+\r
+  @param PciIo      Parent PciIo protocol instance pointer\r
+\r
+  @retval TRUE  Is vga device\r
+  @retval FALSE Is no vga device\r
+**/\r
 BOOLEAN\r
 BiosVideoIsVga (\r
   IN  EFI_PCI_IO_PROTOCOL       *PciIo\r
@@ -1182,26 +1016,19 @@ BiosVideoIsVga (
 }\r
 \r
 \r
+/**\r
+  Check for VBE device\r
+\r
+  @param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
+\r
+  @retval EFI_SUCCESS VBE device found\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoCheckForVbe (\r
   IN OUT BIOS_VIDEO_DEV  *BiosVideoPrivate\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-  Check for VBE device\r
-\r
-  Arguments:\r
-\r
-  BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
-\r
-  Returns:\r
-\r
-  EFI_SUCCESS - VBE device found\r
-\r
---*/\r
 {\r
   EFI_STATUS                             Status;\r
   EFI_IA32_REGISTER_SET                  Regs;\r
@@ -1617,26 +1444,18 @@ Done:
   return Status;\r
 }\r
 \r
+/**\r
+  Check for VGA device\r
+\r
+  @param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
+\r
+  @retval EFI_SUCCESS  Standard VGA device found\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoCheckForVga (\r
   IN OUT BIOS_VIDEO_DEV  *BiosVideoPrivate\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Check for VGA device\r
-\r
-  Arguments:\r
-\r
-    BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
-\r
-  Returns:\r
-\r
-    EFI_SUCCESS - Standard VGA device found\r
-\r
---*/\r
 {\r
   EFI_STATUS            Status;\r
   BIOS_VIDEO_MODE_DATA  *ModeBuffer;\r
@@ -1719,6 +1538,22 @@ Done:
 //\r
 // Graphics Output Protocol Member Functions for VESA BIOS Extensions\r
 //\r
+/**\r
+\r
+  Graphics Output protocol interface to get video mode\r
+\r
+\r
+  @param This            - Protocol instance pointer.\r
+  @param ModeNumber      - The mode number to return information on.\r
+  @param SizeOfInfo      - A pointer to the size, in bytes, of the Info buffer.\r
+  @param Info            - Caller allocated buffer that returns information about ModeNumber.\r
+\r
+  @return EFI_SUCCESS           - Mode information returned.\r
+          EFI_DEVICE_ERROR      - A hardware error occurred trying to retrieve the video mode.\r
+          EFI_NOT_STARTED       - Video display is not initialized. Call SetMode ()\r
+          EFI_INVALID_PARAMETER - One of the input args was NULL.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoGraphicsOutputQueryMode (\r
@@ -1727,25 +1562,6 @@ BiosVideoGraphicsOutputQueryMode (
   OUT UINTN                                 *SizeOfInfo,\r
   OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  **Info\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Graphics Output protocol interface to get video mode\r
-\r
-  Arguments:\r
-    This                  - Protocol instance pointer.\r
-    ModeNumber            - The mode number to return information on.\r
-    Info                  - Caller allocated buffer that returns information about ModeNumber.\r
-    SizeOfInfo            - A pointer to the size, in bytes, of the Info buffer.\r
-\r
-  Returns:\r
-    EFI_SUCCESS           - Mode information returned.\r
-    EFI_DEVICE_ERROR      - A hardware error occurred trying to retrieve the video mode.\r
-    EFI_NOT_STARTED       - Video display is not initialized. Call SetMode ()\r
-    EFI_INVALID_PARAMETER - One of the input args was NULL.\r
-\r
---*/\r
 {\r
   BIOS_VIDEO_DEV        *BiosVideoPrivate;\r
   EFI_STATUS            Status;\r
@@ -1784,28 +1600,25 @@ Routine Description:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+\r
+  Graphics Output protocol interface to set video mode\r
+\r
+\r
+  @param This            - Protocol instance pointer.\r
+  @param ModeNumber      - The mode number to be set.\r
+\r
+  @return EFI_SUCCESS      - Graphics mode was changed.\r
+          EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
+          EFI_UNSUPPORTED  - ModeNumber is not supported by this device.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoGraphicsOutputSetMode (\r
   IN  EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
   IN  UINT32                       ModeNumber\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Graphics Output protocol interface to set video mode\r
-\r
-  Arguments:\r
-    This             - Protocol instance pointer.\r
-    ModeNumber       - The mode number to be set.\r
-\r
-  Returns:\r
-    EFI_SUCCESS      - Graphics mode was changed.\r
-    EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
-    EFI_UNSUPPORTED  - ModeNumber is not supported by this device.\r
-\r
---*/\r
 {\r
   EFI_STATUS              Status;\r
   BIOS_VIDEO_DEV          *BiosVideoPrivate;\r
@@ -1938,6 +1751,23 @@ Routine Description:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+\r
+  Update physical frame buffer, copy 4 bytes block, then copy remaining bytes.\r
+\r
+\r
+  @param PciIo           - The pointer of EFI_PCI_IO_PROTOCOL\r
+  @param VbeBuffer       - The data to transfer to screen\r
+  @param MemAddress      - Physical frame buffer base address\r
+  @param DestinationX    - The X coordinate of the destination for BltOperation\r
+  @param DestinationY    - The Y coordinate of the destination for BltOperation\r
+  @param TotalBytes      - The total bytes of copy\r
+  @param VbePixelWidth   - Bytes per pixel\r
+  @param BytesPerScanLine - Bytes per scan line\r
+\r
+  @return None.\r
+\r
+**/\r
 VOID\r
 CopyVideoBuffer (\r
   IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
@@ -1949,28 +1779,6 @@ CopyVideoBuffer (
   IN  UINT32                VbePixelWidth,\r
   IN  UINTN                 BytesPerScanLine\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Update physical frame buffer, copy 4 bytes block, then copy remaining bytes.\r
-\r
-Arguments:\r
-\r
-  PciIo             - The pointer of EFI_PCI_IO_PROTOCOL\r
-  VbeBuffer         - The data to transfer to screen\r
-  MemAddress        - Physical frame buffer base address\r
-  DestinationX      - The X coordinate of the destination for BltOperation\r
-  DestinationY      - The Y coordinate of the destination for BltOperation\r
-  TotalBytes        - The total bytes of copy\r
-  VbePixelWidth     - Bytes per pixel\r
-  BytesPerScanLine  - Bytes per scan line\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   UINTN                 FrameBufferAddr;\r
   UINTN                 CopyBlockNum;\r
@@ -2054,6 +1862,29 @@ Returns:
 //\r
 // BUGBUG : Add Blt for 16 bit color, 15 bit color, and 8 bit color modes\r
 //\r
+/**\r
+\r
+  Graphics Output protocol instance to block transfer for VBE device\r
+\r
+\r
+  @param This            - Pointer to Graphics Output protocol instance\r
+  @param BltBuffer       - The data to transfer to screen\r
+  @param BltOperation    - The operation to perform\r
+  @param SourceX         - The X coordinate of the source for BltOperation\r
+  @param SourceY         - The Y coordinate of the source for BltOperation\r
+  @param DestinationX    - The X coordinate of the destination for BltOperation\r
+  @param DestinationY    - The Y coordinate of the destination for BltOperation\r
+  @param Width           - The width of a rectangle in the blt rectangle in pixels\r
+  @param Height          - The height of a rectangle in the blt rectangle in pixels\r
+  @param Delta           - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
+                         If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
+                         If a subrectangle of the BltBuffer is used, then Delta represents\r
+                         the number of bytes in a row of the BltBuffer.\r
+\r
+  @return EFI_INVALID_PARAMETER - Invalid parameter passed in\r
+          EFI_SUCCESS - Blt operation success\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoGraphicsOutputVbeBlt (\r
@@ -2068,34 +1899,6 @@ BiosVideoGraphicsOutputVbeBlt (
   IN  UINTN                              Height,\r
   IN  UINTN                              Delta\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Graphics Output protocol instance to block transfer for VBE device\r
-\r
-Arguments:\r
-\r
-  This          - Pointer to Graphics Output protocol instance\r
-  BltBuffer     - The data to transfer to screen\r
-  BltOperation  - The operation to perform\r
-  SourceX       - The X coordinate of the source for BltOperation\r
-  SourceY       - The Y coordinate of the source for BltOperation\r
-  DestinationX  - The X coordinate of the destination for BltOperation\r
-  DestinationY  - The Y coordinate of the destination for BltOperation\r
-  Width         - The width of a rectangle in the blt rectangle in pixels\r
-  Height        - The height of a rectangle in the blt rectangle in pixels\r
-  Delta         - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
-                  If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
-                  If a subrectangle of the BltBuffer is used, then Delta represents\r
-                  the number of bytes in a row of the BltBuffer.\r
-\r
-Returns:\r
-\r
-  EFI_INVALID_PARAMETER - Invalid parameter passed in\r
-  EFI_SUCCESS - Blt operation success\r
-\r
---*/\r
 {\r
   BIOS_VIDEO_DEV                 *BiosVideoPrivate;\r
   BIOS_VIDEO_MODE_DATA           *Mode;\r
@@ -2324,6 +2127,18 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+\r
+  Write graphics controller registers\r
+\r
+\r
+  @param PciIo           - Pointer to PciIo protocol instance of the controller\r
+  @param Address         - Register address\r
+  @param Data            - Data to be written to register\r
+\r
+  @return None\r
+\r
+**/\r
 STATIC\r
 VOID\r
 WriteGraphicsController (\r
@@ -2331,23 +2146,6 @@ WriteGraphicsController (
   IN  UINTN                Address,\r
   IN  UINTN                Data\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Write graphics controller registers\r
-\r
-Arguments:\r
-\r
-  PciIo   - Pointer to PciIo protocol instance of the controller\r
-  Address - Register address\r
-  Data    - Data to be written to register\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
 {\r
   Address = Address | (Data << 8);\r
   PciIo->Io.Write (\r
@@ -2360,6 +2158,20 @@ Returns:
               );\r
 }\r
 \r
+/**\r
+\r
+  Read the four bit plane of VGA frame buffer\r
+\r
+\r
+  @param PciIo           - Pointer to PciIo protocol instance of the controller\r
+  @param HardwareBuffer  - Hardware VGA frame buffer address\r
+  @param MemoryBuffer    - Memory buffer address\r
+  @param WidthInBytes    - Number of bytes in a line to read\r
+  @param Height          - Height of the area to read\r
+\r
+  @return None\r
+\r
+**/\r
 VOID\r
 VgaReadBitPlanes (\r
   EFI_PCI_IO_PROTOCOL  *PciIo,\r
@@ -2368,25 +2180,6 @@ VgaReadBitPlanes (
   UINTN                WidthInBytes,\r
   UINTN                Height\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Read the four bit plane of VGA frame buffer\r
-\r
-Arguments:\r
-\r
-  PciIo           - Pointer to PciIo protocol instance of the controller\r
-  HardwareBuffer  - Hardware VGA frame buffer address\r
-  MemoryBuffer    - Memory buffer address\r
-  WidthInBytes    - Number of bytes in a line to read\r
-  Height          - Height of the area to read\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
 {\r
   UINTN BitPlane;\r
   UINTN Rows;\r
@@ -2432,6 +2225,19 @@ Returns:
   }\r
 }\r
 \r
+/**\r
+\r
+  Internal routine to convert VGA color to Grahpics Output color\r
+\r
+\r
+  @param MemoryBuffer    - Buffer containing VGA color\r
+  @param X               - The X coordinate of pixel on screen\r
+  @param Y               - The Y coordinate of pixel on screen\r
+  @param BltBuffer       - Buffer to contain converted Grahpics Output color\r
+\r
+  @return None\r
+\r
+**/\r
 VOID\r
 VgaConvertToGraphicsOutputColor (\r
   UINT8                          *MemoryBuffer,\r
@@ -2439,24 +2245,6 @@ VgaConvertToGraphicsOutputColor (
   UINTN                          Y,\r
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *BltBuffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Internal routine to convert VGA color to Grahpics Output color\r
-\r
-Arguments:\r
-\r
-  MemoryBuffer  - Buffer containing VGA color\r
-  X             - The X coordinate of pixel on screen\r
-  Y             - The Y coordinate of pixel on screen\r
-  BltBuffer     - Buffer to contain converted Grahpics Output color\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
 {\r
   UINTN Mask;\r
   UINTN Bit;\r
@@ -2473,25 +2261,20 @@ Returns:
   *BltBuffer = mVgaColorToGraphicsOutputColor[Color];\r
 }\r
 \r
-UINT8\r
-VgaConvertColor (\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL          *BltBuffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Internal routine to convert Grahpics Output color to VGA color\r
 \r
-Arguments:\r
-\r
-  BltBuffer - buffer containing Grahpics Output color\r
 \r
-Returns:\r
+  @param BltBuffer       - buffer containing Grahpics Output color\r
 \r
-  Converted VGA color\r
+  @return Converted VGA color\r
 \r
---*/\r
+**/\r
+UINT8\r
+VgaConvertColor (\r
+  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL          *BltBuffer\r
+  )\r
 {\r
   UINT8 Color;\r
 \r
@@ -2503,6 +2286,27 @@ Returns:
   return Color;\r
 }\r
 \r
+/**\r
+  Grahpics Output protocol instance to block transfer for VGA device\r
+\r
+  @param This            Pointer to Grahpics Output protocol instance\r
+  @param BltBuffer       The data to transfer to screen\r
+  @param BltOperation    The operation to perform\r
+  @param SourceX         The X coordinate of the source for BltOperation\r
+  @param SourceY         The Y coordinate of the source for BltOperation\r
+  @param DestinationX    The X coordinate of the destination for BltOperation\r
+  @param DestinationY    The Y coordinate of the destination for BltOperation\r
+  @param Width           The width of a rectangle in the blt rectangle in pixels\r
+  @param Height          The height of a rectangle in the blt rectangle in pixels\r
+  @param Delta           Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
+                         If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
+                         If a subrectangle of the BltBuffer is used, then Delta represents\r
+                         the number of bytes in a row of the BltBuffer.\r
+\r
+  @retval EFI_INVALID_PARAMETER Invalid parameter passed in\r
+  @retval EFI_SUCCESS           Blt operation success\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoGraphicsOutputVgaBlt (\r
@@ -2517,34 +2321,6 @@ BiosVideoGraphicsOutputVgaBlt (
   IN  UINTN                              Height,\r
   IN  UINTN                              Delta\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Grahpics Output protocol instance to block transfer for VGA device\r
-\r
-Arguments:\r
-\r
-  This          - Pointer to Grahpics Output protocol instance\r
-  BltBuffer     - The data to transfer to screen\r
-  BltOperation  - The operation to perform\r
-  SourceX       - The X coordinate of the source for BltOperation\r
-  SourceY       - The Y coordinate of the source for BltOperation\r
-  DestinationX  - The X coordinate of the destination for BltOperation\r
-  DestinationY  - The Y coordinate of the destination for BltOperation\r
-  Width         - The width of a rectangle in the blt rectangle in pixels\r
-  Height        - The height of a rectangle in the blt rectangle in pixels\r
-  Delta         - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
-                  If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
-                  If a subrectangle of the BltBuffer is used, then Delta represents\r
-                  the number of bytes in a row of the BltBuffer.\r
-\r
-Returns:\r
-\r
-  EFI_INVALID_PARAMETER - Invalid parameter passed in\r
-  EFI_SUCCESS - Blt operation success\r
-\r
---*/\r
 {\r
   BIOS_VIDEO_DEV      *BiosVideoPrivate;\r
   EFI_TPL             OriginalTPL;\r
@@ -2930,29 +2706,22 @@ Returns:
 //\r
 // VGA Mini Port Protocol Functions\r
 //\r
+/**\r
+  VgaMiniPort protocol interface to set mode\r
+\r
+  @param This             Pointer to VgaMiniPort protocol instance\r
+  @param ModeNumber       The index of the mode\r
+\r
+  @retval EFI_UNSUPPORTED The requested mode is not supported\r
+  @retval EFI_SUCCESS     The requested mode is set successfully\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoVgaMiniPortSetMode (\r
   IN  EFI_VGA_MINI_PORT_PROTOCOL  *This,\r
   IN  UINTN                       ModeNumber\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  VgaMiniPort protocol interface to set mode\r
-\r
-Arguments:\r
-\r
-  This        - Pointer to VgaMiniPort protocol instance\r
-  ModeNumber  - The index of the mode\r
-\r
-Returns:\r
-\r
-  EFI_UNSUPPORTED - The requested mode is not supported\r
-  EFI_SUCCESS - The requested mode is set successfully\r
-\r
---*/\r
 {\r
   BIOS_VIDEO_DEV        *BiosVideoPrivate;\r
   EFI_IA32_REGISTER_SET Regs;\r
index c8a3f3c92d55bc32bf5157eb93829ab2045ee957..08053478f850215b4c95deb32e41fabd58f03b7f 100644 (file)
@@ -1,4 +1,4 @@
-/*++\r
+/** @file\r
 \r
 Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
@@ -9,14 +9,7 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
-Module Name:\r
-\r
-  UefiBiosVideo.h\r
-    \r
-Abstract: \r
-\r
-Revision History\r
---*/\r
+**/\r
 \r
 #ifndef _BIOS_GRAPHICS_OUTPUT_H\r
 #define _BIOS_GRAPHICS_OUTPUT_H\r
@@ -88,11 +81,12 @@ typedef struct {
   EFI_HANDLE                                  Handle;\r
 \r
   //\r
-  // Consumed Protocols\r
+  // Consumed Protocols inherited from parent controller.\r
   //\r
   EFI_PCI_IO_PROTOCOL                         *PciIo;\r
   EFI_LEGACY_8259_PROTOCOL                    *Legacy8259;\r
-\r
+  THUNK_CONTEXT                               *ThunkContext;\r
+  \r
   //\r
   // Produced Protocols\r
   //\r
@@ -106,7 +100,6 @@ typedef struct {
   //\r
   BOOLEAN                                     VgaCompatible;\r
   BOOLEAN                                     ProduceGraphicsOutput;\r
-  EFI_EVENT                                   ExitBootServicesEvent;\r
 \r
   //\r
   // Graphics Output Protocol related fields\r
@@ -150,6 +143,17 @@ extern EFI_COMPONENT_NAME2_PROTOCOL  gBiosVideoComponentName2;
 //\r
 // Driver Binding Protocol functions\r
 //\r
+/**\r
+  Test to see if Bios Video could be supported on the Controller.\r
+\r
+  @param This                  Pointer to driver binding protocol\r
+  @param Controller            Controller handle to connect\r
+  @param RemainingDevicePath   A pointer to the remaining portion of a device path\r
+\r
+  @retval EFI_SUCCESS         This driver supports this device.\r
+  @retval other               This driver does not support this device.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoDriverBindingSupported (\r
@@ -157,25 +161,18 @@ BiosVideoDriverBindingSupported (
   IN EFI_HANDLE                   Controller,\r
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This                - GC_TODO: add argument description\r
-  Controller          - GC_TODO: add argument description\r
-  RemainingDevicePath - GC_TODO: add argument description\r
+;\r
 \r
-Returns:\r
+/**\r
+  Install Graphics Output Protocol onto VGA device handles\r
 \r
-  GC_TODO: add return values\r
+  @param This                   Pointer to driver binding protocol\r
+  @param Controller             Controller handle to connect\r
+  @param RemainingDevicePath    A pointer to the remaining portion of a device path\r
 \r
---*/\r
-;\r
+  @return EFI_STATUS\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoDriverBindingStart (\r
@@ -183,25 +180,21 @@ BiosVideoDriverBindingStart (
   IN EFI_HANDLE                   Controller,\r
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This                - GC_TODO: add argument description\r
-  Controller          - GC_TODO: add argument description\r
-  RemainingDevicePath - GC_TODO: add argument description\r
+;\r
 \r
-Returns:\r
+/**\r
+  Stop this driver on Controller \r
 \r
-  GC_TODO: add return values\r
+  @param  This              Protocol instance pointer.\r
+  @param  Controller        Handle of device to stop driver on\r
+  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
+                            children is zero stop the entire bus driver.\r
+  @param  ChildHandleBuffer List of Child Handles to Stop.\r
 \r
---*/\r
-;\r
+  @retval EFI_SUCCESS       This driver is removed Controller.\r
+  @retval other             This driver was not removed from this device.\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoDriverBindingStop (\r
@@ -210,120 +203,70 @@ BiosVideoDriverBindingStop (
   IN  UINTN                        NumberOfChildren,\r
   IN  EFI_HANDLE                   *ChildHandleBuffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This              - GC_TODO: add argument description\r
-  Controller        - GC_TODO: add argument description\r
-  NumberOfChildren  - GC_TODO: add argument description\r
-  ChildHandleBuffer - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
 ;\r
 \r
 //\r
 // Private worker functions\r
 //\r
+/**\r
+  Check for VBE device\r
+\r
+  @param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
+\r
+  @retval EFI_SUCCESS VBE device found\r
+\r
+**/\r
 EFI_STATUS\r
 BiosVideoCheckForVbe (\r
   BIOS_VIDEO_DEV  *BiosVideoPrivate\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  BiosVideoPrivate  - GC_TODO: add argument description\r
+;\r
 \r
-Returns:\r
+/**\r
+  Check for VGA device\r
 \r
-  GC_TODO: add return values\r
+  @param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
 \r
---*/\r
-;\r
+  @retval EFI_SUCCESS  Standard VGA device found\r
+**/\r
 \r
 EFI_STATUS\r
 BiosVideoCheckForVga (\r
   BIOS_VIDEO_DEV  *BiosVideoPrivate\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  BiosVideoPrivate  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
 ;\r
 \r
-STATIC\r
-EFI_STATUS\r
-DeRegisterVideoChildHandle (\r
-  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  EFI_HANDLE                     Controller,\r
-  EFI_HANDLE                     Handle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Deregister an video child handle and free resources\r
+/**\r
+  Collect the resource from destroyed bios video device.\r
 \r
-Arguments:\r
-\r
-  This            - Protocol instance pointer.\r
-  Controller      - Video controller handle\r
-  Handle          - Video child handle\r
-\r
-Returns:\r
-\r
-  EFI_STATUS\r
-\r
---*/\r
-;\r
+  @param BiosVideoPrivate   Video child device private data structure\r
 \r
+**/\r
 VOID\r
 BiosVideoDeviceReleaseResource (\r
   BIOS_VIDEO_DEV  *BiosVideoChildPrivate\r
   )\r
-/*++\r
-Routing Description:\r
+;\r
 \r
-  Release resources of a video child device before stopping it.\r
+//\r
+// BIOS Graphics Output Protocol functions\r
+//\r
+/**\r
 \r
-Arguments:\r
+  Graphics Output protocol interface to get video mode\r
 \r
-  BiosVideoChildPrivate  -  Video child device private data structure\r
 \r
-Returns:\r
+  @param This            - Protocol instance pointer.\r
+  @param ModeNumber      - The mode number to return information on.\r
+  @param SizeOfInfo      - A pointer to the size, in bytes, of the Info buffer.\r
+  @param Info            - Caller allocated buffer that returns information about ModeNumber.\r
 \r
-    NONE\r
-    \r
----*/\r
-;\r
+  @return EFI_SUCCESS           - Mode information returned.\r
+          EFI_DEVICE_ERROR      - A hardware error occurred trying to retrieve the video mode.\r
+          EFI_NOT_STARTED       - Video display is not initialized. Call SetMode ()\r
+          EFI_INVALID_PARAMETER - One of the input args was NULL.\r
 \r
-//\r
-// BIOS Graphics Output Protocol functions\r
-//\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoGraphicsOutputQueryMode (\r
@@ -332,52 +275,52 @@ BiosVideoGraphicsOutputQueryMode (
   OUT UINTN                                 *SizeOfInfo,\r
   OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  **Info\r
   )\r
-/*++\r
+;\r
 \r
-Routine Description:\r
+/**\r
 \r
-  Graphics Output protocol interface to get video mode\r
+  Graphics Output protocol interface to set video mode\r
 \r
-  Arguments:\r
-    This                  - Protocol instance pointer.\r
-    ModeNumber            - The mode number to return information on.\r
-    Info                  - Caller allocated buffer that returns information about ModeNumber.\r
-    SizeOfInfo            - A pointer to the size, in bytes, of the Info buffer.\r
 \r
-  Returns:\r
-    EFI_SUCCESS           - Mode information returned.\r
-    EFI_BUFFER_TOO_SMALL  - The Info buffer was too small.\r
-    EFI_DEVICE_ERROR      - A hardware error occurred trying to retrieve the video mode.\r
-    EFI_NOT_STARTED       - Video display is not initialized. Call SetMode ()\r
-    EFI_INVALID_PARAMETER - One of the input args was NULL.\r
+  @param This            - Protocol instance pointer.\r
+  @param ModeNumber      - The mode number to be set.\r
 \r
---*/\r
-;\r
+  @return EFI_SUCCESS      - Graphics mode was changed.\r
+          EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
+          EFI_UNSUPPORTED  - ModeNumber is not supported by this device.\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoGraphicsOutputSetMode (\r
   IN  EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
   IN  UINT32                       ModeNumber\r
   )\r
-/*++\r
-\r
-Routine Description:\r
+;\r
 \r
-  Graphics Output protocol interface to set video mode\r
+/**\r
 \r
-  Arguments:\r
-    This             - Protocol instance pointer.\r
-    ModeNumber       - The mode number to be set.\r
+  Graphics Output protocol instance to block transfer for VBE device\r
 \r
-  Returns:\r
-    EFI_SUCCESS      - Graphics mode was changed.\r
-    EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
-    EFI_UNSUPPORTED  - ModeNumber is not supported by this device.\r
-\r
---*/\r
-;\r
 \r
+  @param This            - Pointer to Graphics Output protocol instance\r
+  @param BltBuffer       - The data to transfer to screen\r
+  @param BltOperation    - The operation to perform\r
+  @param SourceX         - The X coordinate of the source for BltOperation\r
+  @param SourceY         - The Y coordinate of the source for BltOperation\r
+  @param DestinationX    - The X coordinate of the destination for BltOperation\r
+  @param DestinationY    - The Y coordinate of the destination for BltOperation\r
+  @param Width           - The width of a rectangle in the blt rectangle in pixels\r
+  @param Height          - The height of a rectangle in the blt rectangle in pixels\r
+  @param Delta           - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
+                         If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
+                         If a subrectangle of the BltBuffer is used, then Delta represents\r
+                         the number of bytes in a row of the BltBuffer.\r
+\r
+  @return EFI_INVALID_PARAMETER - Invalid parameter passed in\r
+          EFI_SUCCESS - Blt operation success\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoGraphicsOutputVbeBlt (\r
@@ -392,36 +335,29 @@ BiosVideoGraphicsOutputVbeBlt (
   IN  UINTN                              Height,\r
   IN  UINTN                              Delta\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Graphics Output protocol instance to block transfer for VBE device\r
-\r
-Arguments:\r
-\r
-  This          - Pointer to Graphics Output protocol instance\r
-  BltBuffer     - The data to transfer to screen\r
-  BltOperation  - The operation to perform\r
-  SourceX       - The X coordinate of the source for BltOperation\r
-  SourceY       - The Y coordinate of the source for BltOperation\r
-  DestinationX  - The X coordinate of the destination for BltOperation\r
-  DestinationY  - The Y coordinate of the destination for BltOperation\r
-  Width         - The width of a rectangle in the blt rectangle in pixels\r
-  Height        - The height of a rectangle in the blt rectangle in pixels\r
-  Delta         - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
-                  If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
-                  If a subrectangle of the BltBuffer is used, then Delta represents\r
-                  the number of bytes in a row of the BltBuffer.\r
-\r
-Returns:\r
-\r
-  EFI_INVALID_PARAMETER - Invalid parameter passed in\r
-  EFI_SUCCESS - Blt operation success\r
-\r
---*/\r
 ;\r
 \r
+/**\r
+  Grahpics Output protocol instance to block transfer for VGA device\r
+\r
+  @param This            Pointer to Grahpics Output protocol instance\r
+  @param BltBuffer       The data to transfer to screen\r
+  @param BltOperation    The operation to perform\r
+  @param SourceX         The X coordinate of the source for BltOperation\r
+  @param SourceY         The Y coordinate of the source for BltOperation\r
+  @param DestinationX    The X coordinate of the destination for BltOperation\r
+  @param DestinationY    The Y coordinate of the destination for BltOperation\r
+  @param Width           The width of a rectangle in the blt rectangle in pixels\r
+  @param Height          The height of a rectangle in the blt rectangle in pixels\r
+  @param Delta           Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
+                         If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
+                         If a subrectangle of the BltBuffer is used, then Delta represents\r
+                         the number of bytes in a row of the BltBuffer.\r
+\r
+  @retval EFI_INVALID_PARAMETER Invalid parameter passed in\r
+  @retval EFI_SUCCESS           Blt operation success\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoGraphicsOutputVgaBlt (\r
@@ -436,65 +372,37 @@ BiosVideoGraphicsOutputVgaBlt (
   IN  UINTN                              Height,\r
   IN  UINTN                              Delta\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Grahpics Output protocol instance to block transfer for VGA device\r
-\r
-Arguments:\r
-\r
-  This          - Pointer to Grahpics Output protocol instance\r
-  BltBuffer     - The data to transfer to screen\r
-  BltOperation  - The operation to perform\r
-  SourceX       - The X coordinate of the source for BltOperation\r
-  SourceY       - The Y coordinate of the source for BltOperation\r
-  DestinationX  - The X coordinate of the destination for BltOperation\r
-  DestinationY  - The Y coordinate of the destination for BltOperation\r
-  Width         - The width of a rectangle in the blt rectangle in pixels\r
-  Height        - The height of a rectangle in the blt rectangle in pixels\r
-  Delta         - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
-                  If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
-                  If a subrectangle of the BltBuffer is used, then Delta represents\r
-                  the number of bytes in a row of the BltBuffer.\r
-\r
-Returns:\r
-\r
-  EFI_INVALID_PARAMETER - Invalid parameter passed in\r
-  EFI_SUCCESS - Blt operation success\r
-\r
---*/\r
 ;\r
 \r
 //\r
 // BIOS VGA Mini Port Protocol functions\r
 //\r
+/**\r
+  VgaMiniPort protocol interface to set mode\r
+\r
+  @param This             Pointer to VgaMiniPort protocol instance\r
+  @param ModeNumber       The index of the mode\r
+\r
+  @retval EFI_UNSUPPORTED The requested mode is not supported\r
+  @retval EFI_SUCCESS     The requested mode is set successfully\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 BiosVideoVgaMiniPortSetMode (\r
   IN  EFI_VGA_MINI_PORT_PROTOCOL  *This,\r
   IN  UINTN                       ModeNumber\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  VgaMiniPort protocol interface to set mode\r
-\r
-Arguments:\r
-\r
-  This        - Pointer to VgaMiniPort protocol instance\r
-  ModeNumber  - The index of the mode\r
-\r
-Returns:\r
-\r
-  EFI_UNSUPPORTED - The requested mode is not supported\r
-  EFI_SUCCESS - The requested mode is set successfully\r
-\r
---*/\r
 ;\r
 \r
+/**\r
+  Judge whether this device is VGA device.\r
+\r
+  @param PciIo      Parent PciIo protocol instance pointer\r
 \r
+  @retval TRUE  Is vga device\r
+  @retval FALSE Is no vga device\r
+**/\r
 BOOLEAN\r
 BiosVideoIsVga (\r
   IN  EFI_PCI_IO_PROTOCOL       *PciIo\r
@@ -543,16 +451,44 @@ BiosVideoIsVga (
 \r
 #define VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER         0x08\r
 \r
+/**\r
+  Initialize legacy environment for BIOS INI caller.\r
+  \r
+  @param ThunkContext   the instance pointer of THUNK_CONTEXT\r
+**/\r
 VOID\r
 InitializeBiosIntCaller (\r
-  IN  BIOS_VIDEO_DEV                 *BiosDev\r
+  THUNK_CONTEXT     *ThunkContext\r
   );\r
   \r
+/**\r
+   Initialize interrupt redirection code and entries, because\r
+   IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.\r
+   Or the interrupt will lost when we do thunk.\r
+   NOTE: We do not reset 8259 vector base, because it will cause pending\r
+   interrupt lost.\r
+   \r
+   @param Legacy8259  Instance pointer for EFI_LEGACY_8259_PROTOCOL.\r
+   \r
+**/  \r
 VOID\r
 InitializeInterruptRedirection (\r
-  IN  BIOS_VIDEO_DEV                 *BiosDev\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *Legacy8259\r
   );\r
   \r
+/**\r
+  Thunk to 16-bit real mode and execute a software interrupt with a vector \r
+  of BiosInt. Regs will contain the 16-bit register context on entry and \r
+  exit.\r
+  \r
+  @param  This    Protocol instance pointer.\r
+  @param  BiosInt Processor interrupt vector to invoke\r
+  @param  Reg     Register contexted passed into (and returned) from thunk to 16-bit mode\r
+  \r
+  @retval TRUE   Thunk completed, and there were no BIOS errors in the target code.\r
+                 See Regs for status.\r
+  @retval FALSE  There was a BIOS erro in the target code.  \r
+**/  \r
 BOOLEAN\r
 EFIAPI\r
 LegacyBiosInt86 (\r
index 1f39066b2e20d08c533392dcea1dd1964fadc269..b8603426c666d1c89bce33467ca6e2940a8aed0a 100644 (file)
@@ -1,13 +1,29 @@
+/** @file\r
+  Provide legacy thunk interface for accessing Bios Video Rom.\r
+  \r
+Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
 \r
 #include "BiosVideo.h"\r
 \r
 #define EFI_CPU_EFLAGS_IF 0x200\r
 \r
-THUNK_CONTEXT               mThunkContext;\r
-\r
+/**\r
+  Initialize legacy environment for BIOS INI caller.\r
+  \r
+  @param ThunkContext   the instance pointer of THUNK_CONTEXT\r
+**/\r
 VOID\r
 InitializeBiosIntCaller (\r
-  IN  BIOS_VIDEO_DEV                 *BiosDev\r
+  THUNK_CONTEXT     *ThunkContext\r
   )\r
 {\r
   EFI_STATUS            Status;\r
@@ -29,32 +45,27 @@ InitializeBiosIntCaller (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
   \r
-  mThunkContext.RealModeBuffer     = (VOID*)(UINTN)LegacyRegionBase;\r
-  mThunkContext.RealModeBufferSize = EFI_PAGES_TO_SIZE (RealModeBufferSize);\r
-  mThunkContext.ThunkAttributes    = 3;\r
-  AsmPrepareThunk16(&mThunkContext);\r
+  ThunkContext->RealModeBuffer     = (VOID*)(UINTN)LegacyRegionBase;\r
+  ThunkContext->RealModeBufferSize = EFI_PAGES_TO_SIZE (RealModeBufferSize);\r
+  ThunkContext->ThunkAttributes    = 3;\r
+  AsmPrepareThunk16(ThunkContext);\r
   \r
 }\r
 \r
+/**\r
+   Initialize interrupt redirection code and entries, because\r
+   IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.\r
+   Or the interrupt will lost when we do thunk.\r
+   NOTE: We do not reset 8259 vector base, because it will cause pending\r
+   interrupt lost.\r
+   \r
+   @param Legacy8259  Instance pointer for EFI_LEGACY_8259_PROTOCOL.\r
+   \r
+**/\r
 VOID\r
 InitializeInterruptRedirection (\r
-  IN  BIOS_VIDEO_DEV                 *BiosDev\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *Legacy8259\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-    Initialize interrupt redirection code and entries, because\r
-    IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.\r
-    Or the interrupt will lost when we do thunk.\r
-    NOTE: We do not reset 8259 vector base, because it will cause pending\r
-    interrupt lost.\r
-\r
-  Arguments:\r
-    NONE\r
-\r
-  Returns:\r
-    NONE\r
---*/\r
 {\r
   EFI_STATUS            Status;\r
   EFI_PHYSICAL_ADDRESS  LegacyRegionBase;\r
@@ -94,7 +105,7 @@ InitializeInterruptRedirection (
   //\r
   // Get VectorBase, it should be 0x68\r
   //\r
-  Status = BiosDev->Legacy8259->GetVector (BiosDev->Legacy8259, Efi8259Irq0, &ProtectedModeBaseVector);\r
+  Status = Legacy8259->GetVector (Legacy8259, Efi8259Irq0, &ProtectedModeBaseVector);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
@@ -108,6 +119,19 @@ InitializeInterruptRedirection (
   return ;\r
 }\r
 \r
+/**\r
+  Thunk to 16-bit real mode and execute a software interrupt with a vector \r
+  of BiosInt. Regs will contain the 16-bit register context on entry and \r
+  exit.\r
+  \r
+  @param  This    Protocol instance pointer.\r
+  @param  BiosInt Processor interrupt vector to invoke\r
+  @param  Reg     Register contexted passed into (and returned) from thunk to 16-bit mode\r
+  \r
+  @retval TRUE   Thunk completed, and there were no BIOS errors in the target code.\r
+                 See Regs for status.\r
+  @retval FALSE  There was a BIOS erro in the target code.  \r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 LegacyBiosInt86 (\r
@@ -115,25 +139,6 @@ LegacyBiosInt86 (
   IN  UINT8                           BiosInt,\r
   IN  EFI_IA32_REGISTER_SET           *Regs\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-    Thunk to 16-bit real mode and execute a software interrupt with a vector \r
-    of BiosInt. Regs will contain the 16-bit register context on entry and \r
-    exit.\r
-\r
-  Arguments:\r
-    This    - Protocol instance pointer.\r
-    BiosInt - Processor interrupt vector to invoke\r
-    Reg     - Register contexted passed into (and returned) from thunk to \r
-              16-bit mode\r
-\r
-  Returns:\r
-    FALSE   - Thunk completed, and there were no BIOS errors in the target code.\r
-              See Regs for status.\r
-    TRUE    - There was a BIOS erro in the target code.\r
-\r
---*/\r
 {\r
   UINTN                 Status;\r
   UINTN                 Eflags;\r
@@ -178,7 +183,7 @@ LegacyBiosInt86 (
   Status = BiosDev->Legacy8259->SetMode (BiosDev->Legacy8259, Efi8259LegacyMode, NULL, NULL);\r
   ASSERT_EFI_ERROR (Status);\r
   \r
-  Stack16 = (UINT16 *)((UINT8 *) mThunkContext.RealModeBuffer + mThunkContext.RealModeBufferSize - sizeof (UINT16));\r
+  Stack16 = (UINT16 *)((UINT8 *) BiosDev->ThunkContext->RealModeBuffer + BiosDev->ThunkContext->RealModeBufferSize - sizeof (UINT16));\r
   Stack16 -= sizeof (ThunkRegSet.E.EFLAGS) / sizeof (UINT16);\r
   CopyMem (Stack16, &ThunkRegSet.E.EFLAGS, sizeof (ThunkRegSet.E.EFLAGS));\r
 \r
@@ -186,8 +191,8 @@ LegacyBiosInt86 (
   ThunkRegSet.E.ESP  = (UINT16) (UINTN) Stack16;\r
   ThunkRegSet.E.Eip  = (UINT16)((UINT32 *)NULL)[BiosInt];\r
   ThunkRegSet.E.CS   = (UINT16)(((UINT32 *)NULL)[BiosInt] >> 16);\r
-  mThunkContext.RealModeState = &ThunkRegSet;\r
-  AsmThunk16 (&mThunkContext);\r
+  BiosDev->ThunkContext->RealModeState = &ThunkRegSet;\r
+  AsmThunk16 (BiosDev->ThunkContext);\r
 \r
   //\r
   // Restore protected mode interrupt state\r