edkiigluesmmdriverentrypoint.c
来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· C语言 代码 · 共 474 行 · 第 1/2 页
C
474 行
/*++
Copyright (c) 2004 - 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
EdkIIGlueSmmDriverEntryPoint.c
Abstract:
Smm Driver entry point template file
--*/
#include "EdkIIGlueDxe.h"
#include "Common/EdkIIGlueDependencies.h"
//
// Module Unload Handler
//
#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__
EFI_STATUS
EFIAPI
__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (
EFI_HANDLE ImageHandle
);
#endif
EFI_STATUS
EFIAPI
ProcessModuleUnloadList (
EFI_HANDLE ImageHandle
)
{
#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__
return (__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (ImageHandle));
#else
return EFI_SUCCESS;
#endif
}
#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__
GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__;
#endif
//
// Library constructors
//
VOID
ProcessLibraryConstructorList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
//
// Declare "Status" if any of the following libraries are used
//
#if defined(__EDKII_GLUE_DXE_HOB_LIB__) \
|| defined(__EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__) \
|| defined(__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__) \
|| defined(__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__) \
|| defined(__EDKII_GLUE_DXE_SERVICES_TABLE_LIB__) \
|| defined(__EDKII_GLUE_DXE_SMBUS_LIB__) \
|| defined(__EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__)
EFI_STATUS Status;
#endif
//
// EdkII Glue Library Constructors:
// NOTE: the constructors must be called according to dependency order
//
// UefiBootServicesTableLib UefiBootServicesTableLibConstructor()
// EdkDxeRuntimeDriverLib RuntimeDriverLibConstruct()
// DxeHobLib HobLibConstructor()
// UefiDriverModelLib UefiDriverModelLibConstructor()
// DxeSmbusLib SmbusLibConstructor()
// DxeServicesTableLib DxeServicesTableLibConstructor()
// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor()
// check here: check lib usage
#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
#endif
#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__
Status = RuntimeDriverLibConstruct (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
#endif
#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
#endif
#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__
Status = UefiDriverModelLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
#endif
#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
#endif
#ifdef __EDKII_GLUE_DXE_HOB_LIB__
Status = HobLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
#endif
#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__
Status = SmbusLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
#endif
}
//
// Library destructors
//
VOID
ProcessLibraryDestructorList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
}
EFI_BOOT_SERVICES *mBS;
/**
This function returns the size, in bytes,
of the device path data structure specified by DevicePath.
If DevicePath is NULL, then 0 is returned.
@param DevicePath A pointer to a device path data structure.
@return The size of a device path in bytes.
**/
STATIC
UINTN
EFIAPI
SmmGetDevicePathSize (
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
CONST EFI_DEVICE_PATH_PROTOCOL *Start;
if (DevicePath == NULL) {
return 0;
}
//
// Search for the end of the device path structure
//
Start = DevicePath;
while (!EfiIsDevicePathEnd (DevicePath)) {
DevicePath = EfiNextDevicePathNode (DevicePath);
}
//
// Compute the size and add back in the size of the end device path structure
//
return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
}
/**
This function appends the device path SecondDevicePath
to every device path instance in FirstDevicePath.
@param FirstDevicePath A pointer to a device path data structure.
@param SecondDevicePath A pointer to a device path data structure.
@return A pointer to the new device path is returned.
NULL is returned if space for the new device path could not be allocated from pool.
It is up to the caller to free the memory used by FirstDevicePath and SecondDevicePath
if they are no longer needed.
**/
EFI_DEVICE_PATH_PROTOCOL *
EFIAPI
SmmAppendDevicePath (
IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,
IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath
)
{
EFI_STATUS Status;
UINTN Size;
UINTN Size1;
UINTN Size2;
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePath2;
ASSERT (FirstDevicePath != NULL && SecondDevicePath != NULL);
//
// Allocate space for the combined device path. It only has one end node of
// length EFI_DEVICE_PATH_PROTOCOL
//
Size1 = SmmGetDevicePathSize (FirstDevicePath);
Size2 = SmmGetDevicePathSize (SecondDevicePath);
Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL);
Status = (mBS->AllocatePool) (EfiBootServicesData, Size, (VOID **) &NewDevicePath);
if (EFI_SUCCESS == Status) {
(mBS->CopyMem) ((VOID *) NewDevicePath, (VOID *) FirstDevicePath, Size1);
//
// Over write Src1 EndNode and do the copy
//
DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL)));
(mBS->CopyMem) ((VOID *) DevicePath2, (VOID *) SecondDevicePath, Size2);
}
return NewDevicePath;
}
/**
Unload function that is registered in the LoadImage protocol. It un-installs
protocols produced and deallocates pool used by the driver. Called by the core
when unloading the driver.
@param ImageHandle ImageHandle of the unloaded driver
@return Status of the ProcessModuleUnloadList.
**/
EFI_STATUS
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?