]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c
Contributed-under: TianoCore Contribution Agreement 1.0
[mirror_edk2.git] / OptionRomPkg / Bus / Usb / UsbNetworking / Ax88772b / DriverBinding.c
diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c
new file mode 100644 (file)
index 0000000..076b639
--- /dev/null
@@ -0,0 +1,672 @@
+/** @file\r
+  Implement the driver binding protocol for Asix AX88772 Ethernet driver.\r
+                     \r
+  Copyright (c) 2011, 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 "Ax88772.h"\r
+\r
+/**\r
+  Verify the controller type\r
+\r
+  @param [in] pThis                Protocol instance pointer.\r
+  @param [in] Controller           Handle of device to test.\r
+  @param [in] pRemainingDevicePath Not used.\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
+DriverSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL * pThis,\r
+  IN EFI_HANDLE Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL * pRemainingDevicePath\r
+  )\r
+{\r
+  EFI_USB_DEVICE_DESCRIPTOR Device;\r
+  EFI_USB_IO_PROTOCOL * pUsbIo;\r
+  EFI_STATUS Status;\r
+  //\r
+  //  Connect to the USB stack\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiUsbIoProtocolGuid,\r
+                  (VOID **) &pUsbIo,\r
+                  pThis->DriverBindingHandle,         \r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (!EFI_ERROR ( Status )) {\r
+\r
+    //\r
+    //  Get the interface descriptor to check the USB class and find a transport\r
+    //  protocol handler.\r
+    //\r
+    Status = pUsbIo->UsbGetDeviceDescriptor ( pUsbIo, &Device );\r
+    if (EFI_ERROR ( Status )) {\r
+       Status = EFI_UNSUPPORTED;\r
+    }\r
+    else {\r
+      //\r
+      //  Validate the adapter\r
+      //   \r
+      if ( VENDOR_ID == Device.IdVendor ) {\r
+\r
+        if (PRODUCT_ID == Device.IdProduct) {\r
+            DEBUG ((EFI_D_INFO, "Found the AX88772B\r\n"));\r
+        }\r
+                   else  {\r
+                            Status = EFI_UNSUPPORTED;\r
+                   }\r
+      }\r
+           else {\r
+                     Status = EFI_UNSUPPORTED;\r
+       }   \r
+    }\r
+   \r
+    //\r
+    //  Done with the USB stack\r
+    //\r
+    gBS->CloseProtocol (\r
+           Controller,\r
+           &gEfiUsbIoProtocolGuid,\r
+           pThis->DriverBindingHandle,\r
+           Controller\r
+           );\r
+  }\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Start this driver on Controller by opening UsbIo and DevicePath protocols.\r
+  Initialize PXE structures, create a copy of the Controller Device Path with the\r
+  NIC's MAC address appended to it, install the NetworkInterfaceIdentifier protocol\r
+  on the newly created Device Path.\r
+\r
+  @param [in] pThis                Protocol instance pointer.\r
+  @param [in] Controller           Handle of device to work with.\r
+  @param [in] pRemainingDevicePath Not used, always produce all possible children.\r
+\r
+  @retval EFI_SUCCESS          This driver is added to Controller.\r
+  @retval other                This driver does not support this device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DriverStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL * pThis,\r
+  IN EFI_HANDLE Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL * pRemainingDevicePath\r
+  )\r
+{\r
+\r
+       EFI_STATUS                                              Status;\r
+       NIC_DEVICE                                              *pNicDevice;\r
+       UINTN                                                   LengthInBytes;\r
+       EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath = NULL;\r
+       MAC_ADDR_DEVICE_PATH            MacDeviceNode;\r
+\r
+  //\r
+       //  Allocate the device structure\r
+       //\r
+       LengthInBytes = sizeof ( *pNicDevice );\r
+       Status = gBS->AllocatePool (\r
+                  EfiRuntimeServicesData,\r
+                  LengthInBytes,\r
+                  (VOID **) &pNicDevice\r
+                  );\r
+\r
+       if (EFI_ERROR (Status)) {\r
+               DEBUG ((EFI_D_ERROR, "gBS->AllocatePool:pNicDevice ERROR Status = %r\n", Status));\r
+               goto EXIT;\r
+       }\r
+       \r
+       //\r
+  //  Set the structure signature\r
+  //\r
+  ZeroMem ( pNicDevice, LengthInBytes );\r
+  pNicDevice->Signature = DEV_SIGNATURE;\r
+\r
+       Status = gBS->OpenProtocol (\r
+                    Controller,\r
+                    &gEfiUsbIoProtocolGuid,\r
+                    (VOID **) &pNicDevice->pUsbIo,\r
+                    pThis->DriverBindingHandle,\r
+                    Controller,\r
+                    EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                    );\r
+\r
+       if (EFI_ERROR (Status)) {\r
+               DEBUG ((EFI_D_ERROR, "gBS->OpenProtocol:EFI_USB_IO_PROTOCOL ERROR Status = %r\n", Status));\r
+               gBS->FreePool ( pNicDevice );\r
+               goto EXIT;\r
+       }\r
+\r
+       //\r
+  //  Initialize the simple network protocol\r
+  //\r
+       Status = SN_Setup ( pNicDevice );\r
+\r
+       if (EFI_ERROR(Status)){\r
+          DEBUG ((EFI_D_ERROR, "SN_Setup ERROR Status = %r\n", Status));\r
+          gBS->CloseProtocol (\r
+                                       Controller,\r
+                                       &gEfiUsbIoProtocolGuid,\r
+                                       pThis->DriverBindingHandle,\r
+                                       Controller\r
+                                       );\r
+                 gBS->FreePool ( pNicDevice );\r
+                 goto EXIT;\r
+  }\r
+\r
+       //\r
+  // Set Device Path\r
+  //                   \r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
+                                         pThis->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+       if (EFI_ERROR(Status)) {\r
+        DEBUG ((EFI_D_ERROR, "gBS->OpenProtocol:EFI_DEVICE_PATH_PROTOCOL error. Status = %r\n",\r
+            Status));        \r
+                   gBS->CloseProtocol (\r
+                                       Controller,\r
+                                       &gEfiUsbIoProtocolGuid,\r
+                                       pThis->DriverBindingHandle,\r
+                                       Controller\r
+                                       );\r
+                 gBS->FreePool ( pNicDevice );\r
+                 goto EXIT;\r
+       }\r
+\r
+  ZeroMem (&MacDeviceNode, sizeof (MAC_ADDR_DEVICE_PATH));\r
+  MacDeviceNode.Header.Type = MESSAGING_DEVICE_PATH;\r
+  MacDeviceNode.Header.SubType = MSG_MAC_ADDR_DP;\r
+\r
+  SetDevicePathNodeLength (&MacDeviceNode.Header, sizeof (MAC_ADDR_DEVICE_PATH));\r
+                       \r
+  CopyMem (&MacDeviceNode.MacAddress,\r
+                                                               &pNicDevice->SimpleNetworkData.CurrentAddress,\r
+                                                               PXE_HWADDR_LEN_ETHER);\r
+                                                               \r
+  MacDeviceNode.IfType = pNicDevice->SimpleNetworkData.IfType;\r
+\r
+  pNicDevice->MyDevPath = AppendDevicePathNode (\r
+                                          ParentDevicePath,\r
+                                          (EFI_DEVICE_PATH_PROTOCOL *) &MacDeviceNode\r
+                                          );\r
+\r
+       pNicDevice->Controller = NULL;\r
+\r
+       //\r
+  //  Install both the simple network and device path protocols.\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &pNicDevice->Controller,\r
+                          &gEfiCallerIdGuid,\r
+                          pNicDevice,\r
+                          &gEfiSimpleNetworkProtocolGuid,            \r
+                          &pNicDevice->SimpleNetwork,\r
+                                                             &gEfiDevicePathProtocolGuid,\r
+                                                             pNicDevice->MyDevPath,\r
+                          NULL\r
+                          );\r
+\r
+       if (EFI_ERROR(Status)){\r
+               DEBUG ((EFI_D_ERROR, "gBS->InstallMultipleProtocolInterfaces error. Status = %r\n",\r
+            Status)); \r
+               gBS->CloseProtocol (\r
+                                                      Controller,\r
+                                                      &gEfiDevicePathProtocolGuid,\r
+                                                      pThis->DriverBindingHandle,\r
+                                                      Controller);\r
+          gBS->CloseProtocol (\r
+                                       Controller,\r
+                                       &gEfiUsbIoProtocolGuid,\r
+                                       pThis->DriverBindingHandle,\r
+                                       Controller\r
+                                       );\r
+                 gBS->FreePool ( pNicDevice );\r
+                 goto EXIT;\r
+       }\r
+\r
+       //\r
+       // Open For Child Device\r
+       //\r
+       Status = gBS->OpenProtocol (                                                                         \r
+                  Controller,\r
+                  &gEfiUsbIoProtocolGuid,\r
+                  (VOID **) &pNicDevice->pUsbIo,\r
+                  pThis->DriverBindingHandle,\r
+                  pNicDevice->Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+                  );\r
+\r
+       if (EFI_ERROR(Status)){\r
+          gBS->UninstallMultipleProtocolInterfaces (\r
+              &pNicDevice->Controller,\r
+                          &gEfiCallerIdGuid,\r
+                          pNicDevice,\r
+                          &gEfiSimpleNetworkProtocolGuid,            \r
+                          &pNicDevice->SimpleNetwork,\r
+                                                             &gEfiDevicePathProtocolGuid,\r
+                                                             pNicDevice->MyDevPath,\r
+                          NULL\r
+                          );\r
+               gBS->CloseProtocol (\r
+                                                      Controller,\r
+                                                      &gEfiDevicePathProtocolGuid,\r
+                                                      pThis->DriverBindingHandle,\r
+                                                      Controller);\r
+          gBS->CloseProtocol (\r
+                                       Controller,\r
+                                       &gEfiUsbIoProtocolGuid,\r
+                                       pThis->DriverBindingHandle,\r
+                                       Controller\r
+                                       );\r
+                 gBS->FreePool ( pNicDevice );\r
+       }\r
+\r
+EXIT:\r
+       return Status;\r
+\r
+}\r
+\r
+/**\r
+  Stop this driver on Controller by removing NetworkInterfaceIdentifier protocol and\r
+  closing the DevicePath and PciIo protocols on Controller.\r
+\r
+  @param [in] pThis                Protocol instance pointer.\r
+  @param [in] Controller           Handle of device to stop driver on.\r
+  @param [in] NumberOfChildren     How many children need to be stopped.\r
+  @param [in] pChildHandleBuffer   Not used.\r
+\r
+  @retval EFI_SUCCESS          This driver is removed Controller.\r
+  @retval EFI_DEVICE_ERROR     The device could not be stopped due to a device error.\r
+  @retval other                This driver was not removed from this device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DriverStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL * pThis,\r
+  IN  EFI_HANDLE Controller,\r
+  IN  UINTN NumberOfChildren,\r
+  IN  EFI_HANDLE * ChildHandleBuffer\r
+  )\r
+{\r
+               BOOLEAN                                   AllChildrenStopped;\r
+               UINTN                                     Index;\r
+               EFI_SIMPLE_NETWORK_PROTOCOL                               *SimpleNetwork;\r
+               EFI_STATUS                                Status = EFI_SUCCESS;\r
+               NIC_DEVICE                                                                *pNicDevice;\r
+               \r
+               //\r
+               // Complete all outstanding transactions to Controller.\r
+               // Don't allow any new transaction to Controller to be started.\r
+               //\r
+               if (NumberOfChildren == 0) {\r
+               \r
+                 Status = gBS->OpenProtocol (\r
+                                               Controller,\r
+                                               &gEfiSimpleNetworkProtocolGuid,\r
+                                               (VOID **) &SimpleNetwork,\r
+                                               pThis->DriverBindingHandle,\r
+                                               Controller,\r
+                                               EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                                               );\r
+                                               \r
+                       if (EFI_ERROR(Status)) {\r
+        //\r
+        // This is a 2nd type handle(multi-lun root), it needs to close devicepath\r
+        // and usbio protocol.\r
+        //\r
+        gBS->CloseProtocol (\r
+            Controller,\r
+            &gEfiDevicePathProtocolGuid,\r
+            pThis->DriverBindingHandle,\r
+            Controller\r
+            );\r
+        gBS->CloseProtocol (\r
+            Controller,\r
+            &gEfiUsbIoProtocolGuid,\r
+            pThis->DriverBindingHandle,\r
+            Controller\r
+            );\r
+        return EFI_SUCCESS;\r
+      }\r
+      \r
+      pNicDevice = DEV_FROM_SIMPLE_NETWORK ( SimpleNetwork );\r
+      \r
+      Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                                                 Controller,                                             \r
+                                                 &gEfiCallerIdGuid,\r
+                          pNicDevice,\r
+                          &gEfiSimpleNetworkProtocolGuid,            \r
+                          &pNicDevice->SimpleNetwork,\r
+                                                             &gEfiDevicePathProtocolGuid,\r
+                                                             pNicDevice->MyDevPath,\r
+                          NULL\r
+                          );\r
+                          \r
+      if (EFI_ERROR (Status)) {\r
+        return Status;\r
+      }\r
+                 //\r
+                 // Close the bus driver\r
+                 //\r
+                 Status = gBS->CloseProtocol (\r
+                                 Controller,\r
+                                 &gEfiDevicePathProtocolGuid,\r
+                                 pThis->DriverBindingHandle,\r
+                                 Controller\r
+                                 );\r
+\r
+                 if (EFI_ERROR(Status)){\r
+          DEBUG ((EFI_D_ERROR, "driver stop: gBS->CloseProtocol:EfiDevicePathProtocol error. Status %r\n", Status));\r
+                 }\r
+\r
+                 Status = gBS->CloseProtocol (\r
+                                 Controller,\r
+                                 &gEfiUsbIoProtocolGuid,\r
+                                 pThis->DriverBindingHandle,\r
+                                 Controller\r
+                                 );\r
+\r
+                 if (EFI_ERROR(Status)){\r
+          DEBUG ((EFI_D_ERROR, "driver stop: gBS->CloseProtocol:EfiUsbIoProtocol error. Status %r\n", Status));\r
+                 }\r
+      return EFI_SUCCESS;\r
+               } \r
+               AllChildrenStopped = TRUE;\r
+\r
+               for (Index = 0; Index < NumberOfChildren; Index++) {\r
+\r
+                               Status = gBS->OpenProtocol (\r
+                                               ChildHandleBuffer[Index],\r
+                                               &gEfiSimpleNetworkProtocolGuid,\r
+                                               (VOID **) &SimpleNetwork,\r
+                                               pThis->DriverBindingHandle,\r
+                                               Controller,\r
+                                               EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                                               );\r
+                                               \r
+                               if (EFI_ERROR (Status)) {\r
+          AllChildrenStopped = FALSE;\r
+          DEBUG ((EFI_D_ERROR, "Fail to stop No.%d multi-lun child handle when opening SimpleNetwork\n", (UINT32)Index));\r
+          continue;\r
+        } \r
+        \r
+        pNicDevice = DEV_FROM_SIMPLE_NETWORK ( SimpleNetwork );\r
+        \r
+        gBS->CloseProtocol (\r
+                                                   Controller,\r
+                                                   &gEfiUsbIoProtocolGuid,\r
+                                                   pThis->DriverBindingHandle,\r
+                                                   ChildHandleBuffer[Index]\r
+                                                   ); \r
+                                                   \r
+                               Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                                                 ChildHandleBuffer[Index],                                               \r
+                                                 &gEfiCallerIdGuid,\r
+                          pNicDevice,\r
+                          &gEfiSimpleNetworkProtocolGuid,            \r
+                          &pNicDevice->SimpleNetwork,\r
+                                                             &gEfiDevicePathProtocolGuid,\r
+                                                             pNicDevice->MyDevPath,\r
+                          NULL\r
+                          );\r
+                          \r
+        if (EFI_ERROR (Status)) {\r
+            Status = gBS->OpenProtocol (                                                                         \r
+                  Controller,\r
+                  &gEfiUsbIoProtocolGuid,\r
+                  (VOID **) &pNicDevice->pUsbIo,\r
+                  pThis->DriverBindingHandle,\r
+                  ChildHandleBuffer[Index],\r
+                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+                  );\r
+        }\r
+        else {\r
+            int i;\r
+            RX_PKT * pCurr = pNicDevice->QueueHead;\r
+            RX_PKT * pFree;\r
+            \r
+            for ( i = 0 ; i < MAX_QUEUE_SIZE ; i++) {\r
+                 if ( NULL != pCurr ) {\r
+                    pFree = pCurr;\r
+                    pCurr = pCurr->pNext;\r
+                    gBS->FreePool (pFree);\r
+                 }\r
+            }\r
+            \r
+            if ( NULL != pNicDevice->pRxTest)\r
+                                                   gBS->FreePool (pNicDevice->pRxTest);\r
+\r
+                                        if ( NULL != pNicDevice->pTxTest)\r
+                                                   gBS->FreePool (pNicDevice->pTxTest);\r
+\r
+           if ( NULL != pNicDevice->MyDevPath)\r
+                                              gBS->FreePool (pNicDevice->MyDevPath);\r
+                 \r
+                                   if ( NULL != pNicDevice)\r
+                  gBS->FreePool (pNicDevice);\r
+        }\r
+    }\r
+        \r
+        if (!AllChildrenStopped) {\r
+                return EFI_DEVICE_ERROR;\r
+        }\r
+        return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Driver binding protocol declaration\r
+**/\r
+EFI_DRIVER_BINDING_PROTOCOL  gDriverBinding = {\r
+  DriverSupported,\r
+  DriverStart,\r
+  DriverStop,\r
+  0xa,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+\r
+/**\r
+  Ax88772 driver unload routine.\r
+\r
+  @param [in] ImageHandle       Handle for the image.\r
+\r
+  @retval EFI_SUCCESS           Image may be unloaded\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DriverUnload (\r
+  IN EFI_HANDLE ImageHandle\r
+  )\r
+{\r
+  UINTN BufferSize;\r
+  UINTN Index;\r
+  UINTN Max;\r
+  EFI_HANDLE * pHandle;\r
+  EFI_STATUS Status;\r
+\r
+  //\r
+  //  Determine which devices are using this driver\r
+  //\r
+  BufferSize = 0;\r
+  pHandle = NULL;\r
+  Status = gBS->LocateHandle (\r
+                  ByProtocol,\r
+                  &gEfiCallerIdGuid,\r
+                  NULL,\r
+                  &BufferSize,\r
+                  NULL );\r
+  if ( EFI_BUFFER_TOO_SMALL == Status ) {\r
+    for ( ; ; ) {\r
+      //\r
+      //  One or more block IO devices are present\r
+      //\r
+      Status = gBS->AllocatePool (\r
+                      EfiRuntimeServicesData,\r
+                      BufferSize,\r
+                      (VOID **) &pHandle\r
+                      );\r
+      if ( EFI_ERROR ( Status )) {\r
+        DEBUG ((EFI_D_ERROR, "Insufficient memory, failed handle buffer allocation\r\n"));\r
+        break;\r
+      }\r
+\r
+      //\r
+      //  Locate the block IO devices\r
+      //\r
+      Status = gBS->LocateHandle (\r
+                      ByProtocol,\r
+                      &gEfiCallerIdGuid,\r
+                      NULL,\r
+                      &BufferSize,\r
+                      pHandle );\r
+      if ( EFI_ERROR ( Status )) {\r
+        //\r
+        //  Error getting handles\r
+        //\r
+        break;\r
+      }\r
+      \r
+      //\r
+      //  Remove any use of the driver\r
+      //\r
+      Max = BufferSize / sizeof ( pHandle[ 0 ]);\r
+      for ( Index = 0; Max > Index; Index++ ) {\r
+        Status = DriverStop ( &gDriverBinding,\r
+                              pHandle[ Index ],\r
+                              0,\r
+                              NULL );\r
+        if ( EFI_ERROR ( Status )) {\r
+          DEBUG ((EFI_D_ERROR, "WARNING - Failed to shutdown the driver on handle %08x\r\n", pHandle[ Index ]));\r
+          break;\r
+        }\r
+      }\r
+      break;\r
+    }\r
+  }\r
+  else {\r
+    if ( EFI_NOT_FOUND == Status ) {\r
+      //\r
+      //  No devices were found\r
+      //\r
+      Status = EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  //\r
+  //  Free the handle array          \r
+  //\r
+  if ( NULL != pHandle ) {\r
+    gBS->FreePool ( pHandle );\r
+  }\r
+\r
+  //\r
+  //  Remove the protocols installed by the EntryPoint routine.\r
+  //\r
+  if ( !EFI_ERROR ( Status )) {\r
+    gBS->UninstallMultipleProtocolInterfaces (\r
+            ImageHandle,\r
+            &gEfiDriverBindingProtocolGuid,\r
+            &gDriverBinding,                              \r
+            &gEfiComponentNameProtocolGuid,\r
+            &gComponentName,\r
+            &gEfiComponentName2ProtocolGuid,\r
+            &gComponentName2,\r
+            NULL\r
+            );\r
+\r
+    DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
+            "Removed:   gEfiComponentName2ProtocolGuid from 0x%08x\r\n",\r
+            ImageHandle ));\r
+    DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
+              "Removed:   gEfiComponentNameProtocolGuid from 0x%08x\r\n",\r
+              ImageHandle ));\r
+    DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
+              "Removed:   gEfiDriverBindingProtocolGuid from 0x%08x\r\n",\r
+              ImageHandle ));\r
+\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+Ax88772 driver entry point.\r
+\r
+@param [in] ImageHandle       Handle for the image.\r
+@param [in] pSystemTable      Address of the system table.\r
+\r
+@retval EFI_SUCCESS           Image successfully loaded.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EntryPoint (\r
+  IN EFI_HANDLE ImageHandle,\r
+  IN EFI_SYSTEM_TABLE * pSystemTable\r
+  )\r
+{\r
+  EFI_LOADED_IMAGE_PROTOCOL * pLoadedImage;\r
+  EFI_STATUS    Status;\r
+\r
+  //\r
+  //  Enable unload support\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  gImageHandle,\r
+                  &gEfiLoadedImageProtocolGuid,\r
+                  (VOID **)&pLoadedImage\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    pLoadedImage->Unload = DriverUnload;\r
+  }\r
+\r
+  //\r
+  //  Add the driver to the list of drivers\r
+  //\r
+  Status = EfiLibInstallDriverBindingComponentName2 (\r
+             ImageHandle,\r
+             pSystemTable,\r
+             &gDriverBinding,\r
+             ImageHandle,\r
+             &gComponentName,\r
+             &gComponentName2\r
+             );\r
+  if ( !EFI_ERROR ( Status )) {\r
+\r
+    AsciiPrint ("Installed: gEfiDriverBindingProtocolGuid on   0x%08x\r\n",\r
+              ImageHandle );\r
+    AsciiPrint("Installed: gEfiComponentNameProtocolGuid on   0x%08x\r\n",\r
+              ImageHandle );\r
+    AsciiPrint("Installed: gEfiComponentName2ProtocolGuid on   0x%08x\r\n",\r
+              ImageHandle );\r
+\r
+  }\r
+  return Status;\r
+}\r