]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.c
Code scrub for VgaMiniPortDxe.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / VgaMiniPortDxe / VgaMiniPort.c
index b0963a45f8134e53a45d2c52cfdae6c797ffed41..ef39d2a7eedacb53539c415636ef98945c19d578 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
+  Implements EFI Driver Binding Protocol and VGA Mini Port Protocol for VGA Mini Port Driver.\r
 \r
-Copyright (c) 2006 Intel Corporation. All rights reserved\r
+Copyright (c) 2006 - 2009 Intel Corporation. All rights reserved\r
 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
@@ -34,12 +35,16 @@ EFI_DRIVER_BINDING_PROTOCOL gPciVgaMiniPortDriverBinding = {
 };\r
 \r
 /**\r
-  Driver entry point for VgaMiniPort driver.\r
-  \r
-  @param ImageHandle  Driver image handle.\r
-  @param SystemTable  Point to EFI_SYSTEM_TABLE.\r
-  \r
-  @retval Status of install driver binding protocol.\r
+  Entrypoint of VGA Mini Port Driver.\r
+\r
+  This function is the entrypoint of UVGA Mini Port Driver. It installs Driver Binding\r
+  Protocols together with Component Name Protocols.\r
+\r
+  @param  ImageHandle       The firmware allocated handle for the EFI image.\r
+  @param  SystemTable       A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -48,21 +53,24 @@ PciVgaMiniPortDriverEntryPoint (
   IN EFI_SYSTEM_TABLE   *SystemTable\r
   )\r
 {\r
-  return EfiLibInstallDriverBindingComponentName2 (\r
-           ImageHandle,\r
-           SystemTable,\r
-           &gPciVgaMiniPortDriverBinding,\r
-           ImageHandle,\r
-           &gPciVgaMiniPortComponentName,\r
-           &gPciVgaMiniPortComponentName2\r
-           );\r
+  EFI_STATUS              Status;\r
+\r
+  Status = EfiLibInstallDriverBindingComponentName2 (\r
+             ImageHandle,\r
+             SystemTable,\r
+             &gPciVgaMiniPortDriverBinding,\r
+             ImageHandle,\r
+             &gPciVgaMiniPortComponentName,\r
+             &gPciVgaMiniPortComponentName2\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 \r
 /**\r
-  Supported.\r
-\r
-  (Standard DriverBinding Protocol Supported() function)\r
+  Check whether VGA Mini Port driver supports this device.\r
 \r
   @param  This                   The driver binding protocol.\r
   @param  Controller             The controller handle to check.\r
@@ -124,20 +132,21 @@ PciVgaMiniPortDriverBindingSupported (
 \r
 Done:\r
   gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiPciIoProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
+         Controller,\r
+         &gEfiPciIoProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         Controller\r
+         );\r
 \r
   return Status;\r
 }\r
 \r
 \r
 /**\r
-  Install VGA Mini Port Protocol onto VGA device handles\r
+  Starts the VGA device with this driver.\r
 \r
-  (Standard DriverBinding Protocol Start() function)\r
+  This function consumes PCI I/O Protocol, and installs VGA Mini Port Protocol\r
+  onto the VGA device handle.\r
 \r
   @param  This                   The driver binding instance.\r
   @param  Controller             The controller to check.\r
@@ -179,16 +188,8 @@ PciVgaMiniPortDriverBindingStart (
   //\r
   // Allocate the private device structure\r
   //\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  sizeof (PCI_VGA_MINI_PORT_DEV),\r
-                  (VOID **) &PciVgaMiniPortPrivate\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  ZeroMem (PciVgaMiniPortPrivate, sizeof (PCI_VGA_MINI_PORT_DEV));\r
+  PciVgaMiniPortPrivate = AllocateZeroPool (sizeof (PCI_VGA_MINI_PORT_DEV));\r
+  ASSERT (PciVgaMiniPortPrivate != NULL);\r
 \r
   //\r
   // Initialize the private device structure\r
@@ -207,7 +208,7 @@ PciVgaMiniPortDriverBindingStart (
   PciVgaMiniPortPrivate->VgaMiniPort.MaxMode = 1;\r
 \r
   //\r
-  // Install Vga Mini Port Protocol\r
+  // Install VGA Mini Port Protocol\r
   //\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
                   &Controller,\r
@@ -218,13 +219,13 @@ PciVgaMiniPortDriverBindingStart (
 Done:\r
   if (EFI_ERROR (Status)) {\r
     gBS->CloseProtocol (\r
-          Controller,\r
-          &gEfiPciIoProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          Controller\r
-          );\r
+           Controller,\r
+           &gEfiPciIoProtocolGuid,\r
+           This->DriverBindingHandle,\r
+           Controller\r
+           );\r
     if (PciVgaMiniPortPrivate != NULL) {\r
-      gBS->FreePool (PciVgaMiniPortPrivate);\r
+      FreePool (PciVgaMiniPortPrivate);\r
     }\r
   }\r
 \r
@@ -233,9 +234,10 @@ Done:
 \r
 \r
 /**\r
-  Stop.\r
+  Stop the VGA device with this driver.\r
 \r
-  (Standard DriverBinding Protocol Stop() function)\r
+  This function uninstalls VGA Mini Port Protocol from the VGA device handle,\r
+  and closes PCI I/O Protocol.\r
 \r
   @param  This                   The driver binding protocol.\r
   @param  Controller             The controller to release.\r
@@ -284,13 +286,13 @@ PciVgaMiniPortDriverBindingStop (
   }\r
 \r
   gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiPciIoProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
+         Controller,\r
+         &gEfiPciIoProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         Controller\r
+         );\r
 \r
-  gBS->FreePool (PciVgaMiniPortPrivate);\r
+  FreePool (PciVgaMiniPortPrivate);\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -299,14 +301,19 @@ PciVgaMiniPortDriverBindingStop (
 //\r
 \r
 /**\r
-  Thunk function of EFI_VGA_MINI_PORT_SET_MODE.\r
-\r
-  @param  This             Point to instance of EFI_VGA_MINI_PORT_PROTOCOL.\r
-  @param  ModeNumber       Mode number.\r
+  Sets the text display mode of a VGA controller.\r
 \r
-  @retval EFI_UNSUPPORTED  Invalid mode number.\r
-  @retval EFI_SUCCESS      Success.\r
+  This function implements EFI_VGA_MINI_PORT_PROTOCOL.SetMode().\r
+  If ModeNumber exceeds the valid range, then EFI_UNSUPPORTED is returned.\r
+  Otherwise, EFI_SUCCESS is directly returned without real operation.\r
+  \r
+  @param This                 Protocol instance pointer.\r
+  @param ModeNumber           Mode number.  0 - 80x25   1-80x50\r
 \r
+  @retval EFI_SUCCESS         The mode was set\r
+  @retval EFI_UNSUPPORTED     ModeNumber is not supported.\r
+  @retval EFI_DEVICE_ERROR    The device is not functioning properly.\r
+  \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r