EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDriver.c

Go to the documentation of this file.
00001 
00016 #include "VlanConfigImpl.h"
00017 
00018 EFI_DRIVER_BINDING_PROTOCOL gVlanConfigDriverBinding = {
00019   VlanConfigDriverBindingSupported,
00020   VlanConfigDriverBindingStart,
00021   VlanConfigDriverBindingStop,
00022   0xa,
00023   NULL,
00024   NULL
00025 };
00026 
00038 EFI_STATUS
00039 EFIAPI
00040 VlanConfigDriverEntryPoint (
00041   IN EFI_HANDLE          ImageHandle,
00042   IN EFI_SYSTEM_TABLE    *SystemTable
00043   )
00044 {
00045   return EfiLibInstallDriverBindingComponentName2 (
00046            ImageHandle,
00047            SystemTable,
00048            &gVlanConfigDriverBinding,
00049            ImageHandle,
00050            &gVlanConfigComponentName,
00051            &gVlanConfigComponentName2
00052            );
00053 }
00054 
00055 
00069 EFI_STATUS
00070 EFIAPI
00071 VlanConfigDriverBindingSupported (
00072   IN EFI_DRIVER_BINDING_PROTOCOL     *This,
00073   IN EFI_HANDLE                      ControllerHandle,
00074   IN EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath OPTIONAL
00075   )
00076 {
00077   EFI_STATUS                Status;
00078   EFI_VLAN_CONFIG_PROTOCOL  *VlanConfig;
00079 
00080   Status = gBS->OpenProtocol (
00081                   ControllerHandle,
00082                   &gEfiVlanConfigProtocolGuid,
00083                   (VOID **) &VlanConfig,
00084                   This->DriverBindingHandle,
00085                   ControllerHandle,
00086                   EFI_OPEN_PROTOCOL_BY_DRIVER
00087                   );
00088   if (EFI_ERROR (Status)) {
00089     return Status;
00090   }
00091 
00092   //
00093   // Close the VlanConfig protocol opened for supported test
00094   //
00095   gBS->CloseProtocol (
00096          ControllerHandle,
00097          &gEfiVlanConfigProtocolGuid,
00098          This->DriverBindingHandle,
00099          ControllerHandle
00100          );
00101 
00102   return Status;
00103 }
00104 
00105 
00119 EFI_STATUS
00120 EFIAPI
00121 VlanConfigDriverBindingStart (
00122   IN EFI_DRIVER_BINDING_PROTOCOL     *This,
00123   IN EFI_HANDLE                      ControllerHandle,
00124   IN EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath OPTIONAL
00125   )
00126 {
00127   EFI_STATUS                Status;
00128   EFI_VLAN_CONFIG_PROTOCOL  *VlanConfig;
00129   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
00130   VLAN_CONFIG_PRIVATE_DATA  *PrivateData;
00131 
00132   //
00133   // Check for multiple start
00134   //
00135   Status = gBS->OpenProtocol (
00136                   ControllerHandle,
00137                   &gEfiCallerIdGuid,
00138                   (VOID **) &PrivateData,
00139                   This->DriverBindingHandle,
00140                   ControllerHandle,
00141                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
00142                   );
00143   if (!EFI_ERROR (Status)) {
00144     return EFI_ALREADY_STARTED;
00145   }
00146 
00147   //
00148   // Open VlanConfig protocol by driver
00149   //
00150   Status = gBS->OpenProtocol (
00151                   ControllerHandle,
00152                   &gEfiVlanConfigProtocolGuid,
00153                   (VOID **) &VlanConfig,
00154                   This->DriverBindingHandle,
00155                   ControllerHandle,
00156                   EFI_OPEN_PROTOCOL_BY_DRIVER
00157                   );
00158   if (EFI_ERROR (Status)) {
00159     return Status;
00160   }
00161 
00162   //
00163   // Get parent device path
00164   //
00165   Status = gBS->OpenProtocol (
00166                   ControllerHandle,
00167                   &gEfiDevicePathProtocolGuid,
00168                   (VOID **) &DevicePath,
00169                   This->DriverBindingHandle,
00170                   ControllerHandle,
00171                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
00172                   );
00173   if (EFI_ERROR (Status)) {
00174     goto ErrorExit;
00175   }
00176 
00177   //
00178   // Create a private data for this network device
00179   //
00180   PrivateData = AllocateCopyPool (sizeof (VLAN_CONFIG_PRIVATE_DATA), &mVlanConfigPrivateDateTemplate);
00181   if (PrivateData == NULL) {
00182     Status = EFI_OUT_OF_RESOURCES;
00183     goto ErrorExit;
00184   }
00185 
00186   PrivateData->ImageHandle = This->DriverBindingHandle;
00187   PrivateData->ControllerHandle = ControllerHandle;
00188   PrivateData->VlanConfig = VlanConfig;
00189   PrivateData->ParentDevicePath = DevicePath;
00190 
00191   //
00192   // Install VLAN configuration form
00193   //
00194   Status = InstallVlanConfigForm (PrivateData);
00195   if (EFI_ERROR (Status)) {
00196     goto ErrorExit;
00197   }
00198 
00199   //
00200   // Install private GUID
00201   //
00202   Status = gBS->InstallMultipleProtocolInterfaces (
00203                   &ControllerHandle,
00204                   &gEfiCallerIdGuid,
00205                   PrivateData,
00206                   NULL
00207                   );
00208   if (EFI_ERROR (Status)) {
00209     goto ErrorExit;
00210   }
00211   return Status;
00212 
00213 ErrorExit:
00214   gBS->CloseProtocol (
00215          ControllerHandle,
00216          &gEfiVlanConfigProtocolGuid,
00217          This->DriverBindingHandle,
00218          ControllerHandle
00219          );
00220 
00221   gBS->CloseProtocol (
00222          ControllerHandle,
00223          &gEfiDevicePathProtocolGuid,
00224          This->DriverBindingHandle,
00225          ControllerHandle
00226          );
00227 
00228   if (PrivateData != NULL) {
00229     UninstallVlanConfigForm (PrivateData);
00230     FreePool (PrivateData);
00231   }
00232 
00233   return Status;
00234 }
00235 
00236 
00250 EFI_STATUS
00251 EFIAPI
00252 VlanConfigDriverBindingStop (
00253   IN EFI_DRIVER_BINDING_PROTOCOL     *This,
00254   IN EFI_HANDLE                      ControllerHandle,
00255   IN UINTN                           NumberOfChildren,
00256   IN EFI_HANDLE                      *ChildHandleBuffer
00257   )
00258 {
00259   EFI_STATUS                Status;
00260   VLAN_CONFIG_PRIVATE_DATA  *PrivateData;
00261 
00262   //
00263   // Retrieve the PrivateData from ControllerHandle
00264   //
00265   Status = gBS->OpenProtocol (
00266                   ControllerHandle,
00267                   &gEfiCallerIdGuid,
00268                   (VOID **) &PrivateData,
00269                   This->DriverBindingHandle,
00270                   ControllerHandle,
00271                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
00272                   );
00273   if (EFI_ERROR (Status)) {
00274     return Status;
00275   }
00276   ASSERT (PrivateData->Signature == VLAN_CONFIG_PRIVATE_DATA_SIGNATURE);
00277 
00278   //
00279   // Uninstall VLAN configuration Form
00280   //
00281   UninstallVlanConfigForm (PrivateData);
00282 
00283   //
00284   // Uninstall the private GUID
00285   //
00286   Status = gBS->UninstallMultipleProtocolInterfaces (
00287                   ControllerHandle,
00288                   &gEfiCallerIdGuid,
00289                   PrivateData,
00290                   NULL
00291                   );
00292   if (EFI_ERROR (Status)) {
00293     return Status;
00294   }
00295 
00296   Status = gBS->CloseProtocol (
00297                   ControllerHandle,
00298                   &gEfiVlanConfigProtocolGuid,
00299                   This->DriverBindingHandle,
00300                   ControllerHandle
00301                   );
00302   return Status;
00303 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines