4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This file implement EfiMain() for library class DxeSmmDriverEntryPoint.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EfiMain() is common driver entry point for all SMM driver who uses DxeSmmDriverEntryPoint
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync library class.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncCopyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncThis program and the accompanying materials
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncare licensed and made available under the terms and conditions of the BSD License
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncwhich accompanies this distribution. The full text of the license may be found at
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This function returns the size, in bytes,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync of the device path data structure specified by DevicePath.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If DevicePath is NULL, then 0 is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param DevicePath A pointer to a device path data structure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The size of a device path in bytes.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Search for the end of the device path structure
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Compute the size and add back in the size of the end device path structure
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This function appends the device path SecondDevicePath
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync to every device path instance in FirstDevicePath.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param FirstDevicePath A pointer to a device path data structure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param SecondDevicePath A pointer to a device path data structure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return A pointer to the new device path is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync NULL is returned if space for the new device path could not be allocated from pool.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync It is up to the caller to free the memory used by FirstDevicePath and SecondDevicePath
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if they are no longer needed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ASSERT (FirstDevicePath != NULL && SecondDevicePath != NULL);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Allocate space for the combined device path. It only has one end node of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // length EFI_DEVICE_PATH_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = gBS->AllocatePool (EfiBootServicesData, Size, (VOID **) &NewDevicePath);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // CopyMem in gBS is used as this service should always be ready. We didn't choose
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // to use a BaseMemoryLib function as such library instance may have constructor.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync gBS->CopyMem ((VOID *) NewDevicePath, (VOID *) FirstDevicePath, Size1);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Over write Src1 EndNode and do the copy
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL)));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync gBS->CopyMem ((VOID *) DevicePath2, (VOID *) SecondDevicePath, Size2);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Unload function that is registered in the LoadImage protocol. It un-installs
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync protocols produced and deallocates pool used by the driver. Called by the core
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync when unloading the driver.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ImageHandle ImageHandle of the unloaded driver
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return Status of the ProcessModuleUnloadList.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Call the unload handlers for all the modules.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Note: All libraries were constructed in SMM space,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // therefore we can not destruct them in Unload
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // handler.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Enrty point to DXE SMM Driver.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ImageHandle ImageHandle of the loaded driver.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param SystemTable Pointer to the EFI System Table.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS One or more of the drivers returned a success code.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval !EFI_SUCESS The return status from the last driver entry point in the list.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Cache a pointer to the Boot Services Table
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Retrieve SMM Base Protocol
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Check to see if we are already in SMM
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Retrieve the Loaded Image Protocol
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Retrieve the Device Path Protocol from the DeviceHandle from which this driver was loaded
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Build the full device path to the currently execuing image
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CompleteFilePath = SmmAppendDevicePath (ImageDevicePath, LoadedImage->FilePath);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Load the image in memory to SMRAM; it will automatically generate the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = SmmBase->Register (SmmBase, CompleteFilePath, LoadedImage->ImageBase, 0, &Handle, FALSE);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Optionally install the unload handler
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Call constructor for all libraries
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ProcessLibraryConstructorList (ImageHandle, SystemTable);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Call the list of driver entry points
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ProcessLibraryDestructorList (ImageHandle, SystemTable);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Enrty point wrapper of DXE SMM Driver.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ImageHandle ImageHandle of the loaded driver.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param SystemTable Pointer to the EFI System Table.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS One or more of the drivers returned a success code.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval !EFI_SUCESS The return status from the last driver entry point in the list.