mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-30 00:54:06 +02:00
PI 1.1 SMM Feature Check-in
1. Add SmmServicesTableLib library class/instance. 2. Add SmmIoLibCpuIo/SmmPciLibPciRootBridgeIo library instance. 3. Update some library INF to support SMM_CORE module type. 4. Update dec/dsc to include new modules. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9590 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
2983a79df5
commit
b7c5912af1
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
GUIDs for gBS->CreateEventEx Event Groups. Defined in UEFI spec 2.0.
|
GUIDs for gBS->CreateEventEx Event Groups. Defined in UEFI spec 2.0 and PI 1.2.
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006 - 2009, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -39,5 +39,9 @@ extern EFI_GUID gEfiEventMemoryMapChangeGuid;
|
|||||||
|
|
||||||
extern EFI_GUID gEfiEventReadyToBootGuid;
|
extern EFI_GUID gEfiEventReadyToBootGuid;
|
||||||
|
|
||||||
|
#define EFI_EVENT_GROUP_DXE_DISPATCH \
|
||||||
|
{ 0x7081e22f, 0xcac6, 0x4053, { 0x94, 0x68, 0x67, 0x57, 0x82, 0xcf, 0x88, 0xe5 }}
|
||||||
|
|
||||||
|
extern EFI_GUID gEfiEventDxeDispatchGuid;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
43
MdePkg/Include/Library/SmmServicesTableLib.h
Normal file
43
MdePkg/Include/Library/SmmServicesTableLib.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/** @file
|
||||||
|
Provides a service to retrieve a pointer to the SMM Services Table.
|
||||||
|
Only available to SMM module types.
|
||||||
|
|
||||||
|
Copyright (c) 2009, 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.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef __SMM_SERVICES_TABLE_LIB_H__
|
||||||
|
#define __SMM_SERVICES_TABLE_LIB_H__
|
||||||
|
|
||||||
|
#include <PiSmm.h>
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Cache pointer to the SMM Services Table
|
||||||
|
///
|
||||||
|
extern EFI_SMM_SYSTEM_TABLE2 *gSmst;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function allows the caller to determine if the driver is executing in
|
||||||
|
System Management Mode(SMM).
|
||||||
|
|
||||||
|
This function returns TRUE if the driver is executing in SMM and FALSE if the
|
||||||
|
driver is not executing in SMM.
|
||||||
|
|
||||||
|
@retval TRUE The driver is executing in System Management Mode (SMM).
|
||||||
|
@retval FALSE The driver is not executing in System Management Mode (SMM).
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
EFIAPI
|
||||||
|
InSmm (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif
|
25
MdePkg/Include/PiSmm.h
Normal file
25
MdePkg/Include/PiSmm.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/** @file
|
||||||
|
|
||||||
|
Root include file for Mde Package SMM modules.
|
||||||
|
|
||||||
|
Copyright (c) 2009, 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.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef __PI_SMM_H__
|
||||||
|
#define __PI_SMM_H__
|
||||||
|
|
||||||
|
#include <Uefi/UefiBaseType.h>
|
||||||
|
#include <Uefi/UefiSpec.h>
|
||||||
|
|
||||||
|
#include <Pi/PiSmmCis.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -31,7 +31,7 @@
|
|||||||
FILE_GUID = af97eb89-4cc6-45f8-a514-ca025b346480
|
FILE_GUID = af97eb89-4cc6-45f8-a514-ca025b346480
|
||||||
MODULE_TYPE = DXE_DRIVER
|
MODULE_TYPE = DXE_DRIVER
|
||||||
VERSION_STRING = 1.0
|
VERSION_STRING = 1.0
|
||||||
LIBRARY_CLASS = PcdLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
LIBRARY_CLASS = PcdLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVER
|
||||||
CONSTRUCTOR = PcdLibConstructor
|
CONSTRUCTOR = PcdLibConstructor
|
||||||
|
|
||||||
#
|
#
|
||||||
|
2275
MdePkg/Library/SmmIoLibCpuIo/IoHighLevel.c
Normal file
2275
MdePkg/Library/SmmIoLibCpuIo/IoHighLevel.c
Normal file
File diff suppressed because it is too large
Load Diff
642
MdePkg/Library/SmmIoLibCpuIo/IoLib.c
Normal file
642
MdePkg/Library/SmmIoLibCpuIo/IoLib.c
Normal file
@ -0,0 +1,642 @@
|
|||||||
|
/** @file
|
||||||
|
I/O Library.
|
||||||
|
The implementation of I/O operation for this library instance
|
||||||
|
are based on EFI_CPU_IO_PROTOCOL.
|
||||||
|
|
||||||
|
Copyright (c) 2009, Intel Corporation<BR>
|
||||||
|
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: IoLib.c
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
#include "SmmCpuIoLibInternal.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Globle varible to cache pointer to CpuIo protocol.
|
||||||
|
//
|
||||||
|
EFI_SMM_CPU_IO_PROTOCOL *mCpuIo = NULL;
|
||||||
|
EFI_SMM_PCI_ROOT_BRIDGE_IO_PROTOCOL *mPciRootBridgeIo = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The constructor function caches the pointer to CpuIo protocol.
|
||||||
|
|
||||||
|
The constructor function locates CpuIo protocol from protocol database.
|
||||||
|
It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
|
||||||
|
|
||||||
|
@param ImageHandle The firmware allocated handle for the EFI image.
|
||||||
|
@param SystemTable A pointer to the EFI System Table.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
IoLibConstructor (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Status = gSmst->SmmLocateProtocol (&gEfiSmmPciRootBridgeIoProtocolGuid, NULL, (VOID **) &mPciRootBridgeIo);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
Status = gSmst->SmmLocateProtocol (&gEfiSmmCpuIoProtocolGuid, NULL, (VOID **) &mCpuIo);
|
||||||
|
}
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads registers in the EFI CPU I/O space.
|
||||||
|
|
||||||
|
Reads the I/O port specified by Port with registers width specified by Width.
|
||||||
|
The read value is returned. If such operations are not supported, then ASSERT().
|
||||||
|
This function must guarantee that all I/O read and write operations are serialized.
|
||||||
|
|
||||||
|
@param Port The base address of the I/O operation.
|
||||||
|
The caller is responsible for aligning the Address if required.
|
||||||
|
@param Width The width of the I/O operation.
|
||||||
|
|
||||||
|
@return Data read from registers in the EFI CPU I/O space.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
IoReadWorker (
|
||||||
|
IN UINTN Port,
|
||||||
|
IN EFI_SMM_IO_WIDTH Width
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINT64 Data;
|
||||||
|
|
||||||
|
if (mPciRootBridgeIo != NULL) {
|
||||||
|
Status = mPciRootBridgeIo->Io.Read (mPciRootBridgeIo, (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width, Port, 1, &Data);
|
||||||
|
} else {
|
||||||
|
Status = mCpuIo->Io.Read (mCpuIo, Width, Port, 1, &Data);
|
||||||
|
}
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
return Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Writes registers in the EFI CPU I/O space.
|
||||||
|
|
||||||
|
Writes the I/O port specified by Port with registers width and value specified by Width
|
||||||
|
and Data respectively. Data is returned. If such operations are not supported, then ASSERT().
|
||||||
|
This function must guarantee that all I/O read and write operations are serialized.
|
||||||
|
|
||||||
|
@param Port The base address of the I/O operation.
|
||||||
|
The caller is responsible for aligning the Address if required.
|
||||||
|
@param Width The width of the I/O operation.
|
||||||
|
@param Data The value to write to the I/O port.
|
||||||
|
|
||||||
|
@return The paramter of Data.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
IoWriteWorker (
|
||||||
|
IN UINTN Port,
|
||||||
|
IN EFI_SMM_IO_WIDTH Width,
|
||||||
|
IN UINT64 Data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
if (mPciRootBridgeIo != NULL) {
|
||||||
|
Status = mPciRootBridgeIo->Io.Write (mPciRootBridgeIo, (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width, Port, 1, &Data);
|
||||||
|
} else {
|
||||||
|
Status = mCpuIo->Io.Write (mCpuIo, Width, Port, 1, &Data);
|
||||||
|
}
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
return Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads memory-mapped registers in the EFI system memory space.
|
||||||
|
|
||||||
|
Reads the MMIO registers specified by Address with registers width specified by Width.
|
||||||
|
The read value is returned. If such operations are not supported, then ASSERT().
|
||||||
|
This function must guarantee that all MMIO read and write operations are serialized.
|
||||||
|
|
||||||
|
@param Address The MMIO register to read.
|
||||||
|
The caller is responsible for aligning the Address if required.
|
||||||
|
@param Width The width of the I/O operation.
|
||||||
|
|
||||||
|
@return Data read from registers in the EFI system memory space.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
MmioReadWorker (
|
||||||
|
IN UINTN Address,
|
||||||
|
IN EFI_SMM_IO_WIDTH Width
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINT64 Data;
|
||||||
|
|
||||||
|
if (mPciRootBridgeIo != NULL) {
|
||||||
|
Status = mPciRootBridgeIo->Mem.Read (mPciRootBridgeIo, (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width, Address, 1, &Data);
|
||||||
|
} else {
|
||||||
|
Status = mCpuIo->Mem.Read (mCpuIo, Width, Address, 1, &Data);
|
||||||
|
}
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
return Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Writes memory-mapped registers in the EFI system memory space.
|
||||||
|
|
||||||
|
Writes the MMIO registers specified by Address with registers width and value specified by Width
|
||||||
|
and Data respectively. Data is returned. If such operations are not supported, then ASSERT().
|
||||||
|
This function must guarantee that all MMIO read and write operations are serialized.
|
||||||
|
|
||||||
|
@param Address The MMIO register to read.
|
||||||
|
The caller is responsible for aligning the Address if required.
|
||||||
|
@param Width The width of the I/O operation.
|
||||||
|
@param Data The value to write to the I/O port.
|
||||||
|
|
||||||
|
@return Data read from registers in the EFI system memory space.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
MmioWriteWorker (
|
||||||
|
IN UINTN Address,
|
||||||
|
IN EFI_SMM_IO_WIDTH Width,
|
||||||
|
IN UINT64 Data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
if (mPciRootBridgeIo != NULL) {
|
||||||
|
Status = mPciRootBridgeIo->Mem.Write (mPciRootBridgeIo, (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width, Address, 1, &Data);
|
||||||
|
} else {
|
||||||
|
Status = mCpuIo->Mem.Write (mCpuIo, Width, Address, 1, &Data);
|
||||||
|
}
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
return Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads an 8-bit I/O port.
|
||||||
|
|
||||||
|
Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
|
||||||
|
This function must guarantee that all I/O read and write operations are
|
||||||
|
serialized.
|
||||||
|
|
||||||
|
If 8-bit I/O port operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Port The I/O port to read.
|
||||||
|
|
||||||
|
@return The value read.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT8
|
||||||
|
EFIAPI
|
||||||
|
IoRead8 (
|
||||||
|
IN UINTN Port
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return (UINT8)IoReadWorker (Port, SMM_IO_UINT8);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Writes an 8-bit I/O port.
|
||||||
|
|
||||||
|
Writes the 8-bit I/O port specified by Port with the value specified by Value
|
||||||
|
and returns Value. This function must guarantee that all I/O read and write
|
||||||
|
operations are serialized.
|
||||||
|
|
||||||
|
If 8-bit I/O port operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Port The I/O port to write.
|
||||||
|
@param Value The value to write to the I/O port.
|
||||||
|
|
||||||
|
@return The value written the I/O port.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT8
|
||||||
|
EFIAPI
|
||||||
|
IoWrite8 (
|
||||||
|
IN UINTN Port,
|
||||||
|
IN UINT8 Value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return (UINT8)IoWriteWorker (Port, SMM_IO_UINT8, Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads a 16-bit I/O port.
|
||||||
|
|
||||||
|
Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
|
||||||
|
This function must guarantee that all I/O read and write operations are
|
||||||
|
serialized.
|
||||||
|
|
||||||
|
If Port is not aligned on a 16-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If 16-bit I/O port operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Port The I/O port to read.
|
||||||
|
|
||||||
|
@return The value read.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT16
|
||||||
|
EFIAPI
|
||||||
|
IoRead16 (
|
||||||
|
IN UINTN Port
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make sure Port is aligned on a 16-bit boundary.
|
||||||
|
//
|
||||||
|
ASSERT ((Port & 1) == 0);
|
||||||
|
return (UINT16)IoReadWorker (Port, SMM_IO_UINT16);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Writes a 16-bit I/O port.
|
||||||
|
|
||||||
|
Writes the 16-bit I/O port specified by Port with the value specified by Value
|
||||||
|
and returns Value. This function must guarantee that all I/O read and write
|
||||||
|
operations are serialized.
|
||||||
|
|
||||||
|
If Port is not aligned on a 16-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If 16-bit I/O port operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Port The I/O port to write.
|
||||||
|
@param Value The value to write to the I/O port.
|
||||||
|
|
||||||
|
@return The value written the I/O port.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT16
|
||||||
|
EFIAPI
|
||||||
|
IoWrite16 (
|
||||||
|
IN UINTN Port,
|
||||||
|
IN UINT16 Value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make sure Port is aligned on a 16-bit boundary.
|
||||||
|
//
|
||||||
|
ASSERT ((Port & 1) == 0);
|
||||||
|
return (UINT16)IoWriteWorker (Port, SMM_IO_UINT16, Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads a 32-bit I/O port.
|
||||||
|
|
||||||
|
Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
|
||||||
|
This function must guarantee that all I/O read and write operations are
|
||||||
|
serialized.
|
||||||
|
|
||||||
|
If Port is not aligned on a 32-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If 32-bit I/O port operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Port The I/O port to read.
|
||||||
|
|
||||||
|
@return The value read.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
IoRead32 (
|
||||||
|
IN UINTN Port
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make sure Port is aligned on a 32-bit boundary.
|
||||||
|
//
|
||||||
|
ASSERT ((Port & 3) == 0);
|
||||||
|
return (UINT32)IoReadWorker (Port, SMM_IO_UINT32);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Writes a 32-bit I/O port.
|
||||||
|
|
||||||
|
Writes the 32-bit I/O port specified by Port with the value specified by Value
|
||||||
|
and returns Value. This function must guarantee that all I/O read and write
|
||||||
|
operations are serialized.
|
||||||
|
|
||||||
|
If Port is not aligned on a 32-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If 32-bit I/O port operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Port The I/O port to write.
|
||||||
|
@param Value The value to write to the I/O port.
|
||||||
|
|
||||||
|
@return The value written the I/O port.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
IoWrite32 (
|
||||||
|
IN UINTN Port,
|
||||||
|
IN UINT32 Value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make sure Port is aligned on a 32-bit boundary.
|
||||||
|
//
|
||||||
|
ASSERT ((Port & 3) == 0);
|
||||||
|
return (UINT32)IoWriteWorker (Port, SMM_IO_UINT32, Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads a 64-bit I/O port.
|
||||||
|
|
||||||
|
Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
|
||||||
|
This function must guarantee that all I/O read and write operations are
|
||||||
|
serialized.
|
||||||
|
|
||||||
|
If Port is not aligned on a 64-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If 64-bit I/O port operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Port The I/O port to read.
|
||||||
|
|
||||||
|
@return The value read.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
IoRead64 (
|
||||||
|
IN UINTN Port
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make sure Port is aligned on a 64-bit boundary.
|
||||||
|
//
|
||||||
|
ASSERT ((Port & 7) == 0);
|
||||||
|
return IoReadWorker (Port, SMM_IO_UINT64);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Writes a 64-bit I/O port.
|
||||||
|
|
||||||
|
Writes the 64-bit I/O port specified by Port with the value specified by Value
|
||||||
|
and returns Value. This function must guarantee that all I/O read and write
|
||||||
|
operations are serialized.
|
||||||
|
|
||||||
|
If Port is not aligned on a 64-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If 64-bit I/O port operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Port The I/O port to write.
|
||||||
|
@param Value The value to write to the I/O port.
|
||||||
|
|
||||||
|
@return The value written the I/O port.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
IoWrite64 (
|
||||||
|
IN UINTN Port,
|
||||||
|
IN UINT64 Value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make sure Port is aligned on a 64-bit boundary.
|
||||||
|
//
|
||||||
|
ASSERT ((Port & 7) == 0);
|
||||||
|
return IoWriteWorker (Port, SMM_IO_UINT64, Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads an 8-bit MMIO register.
|
||||||
|
|
||||||
|
Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
|
||||||
|
returned. This function must guarantee that all MMIO read and write
|
||||||
|
operations are serialized.
|
||||||
|
|
||||||
|
If 8-bit MMIO register operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Address The MMIO register to read.
|
||||||
|
|
||||||
|
@return The value read.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT8
|
||||||
|
EFIAPI
|
||||||
|
MmioRead8 (
|
||||||
|
IN UINTN Address
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return (UINT8)MmioReadWorker (Address, SMM_IO_UINT8);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Writes an 8-bit MMIO register.
|
||||||
|
|
||||||
|
Writes the 8-bit MMIO register specified by Address with the value specified
|
||||||
|
by Value and returns Value. This function must guarantee that all MMIO read
|
||||||
|
and write operations are serialized.
|
||||||
|
|
||||||
|
If 8-bit MMIO register operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Address The MMIO register to write.
|
||||||
|
@param Value The value to write to the MMIO register.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT8
|
||||||
|
EFIAPI
|
||||||
|
MmioWrite8 (
|
||||||
|
IN UINTN Address,
|
||||||
|
IN UINT8 Value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return (UINT8)MmioWriteWorker (Address, SMM_IO_UINT8, Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads a 16-bit MMIO register.
|
||||||
|
|
||||||
|
Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
|
||||||
|
returned. This function must guarantee that all MMIO read and write
|
||||||
|
operations are serialized.
|
||||||
|
|
||||||
|
If Address is not aligned on a 16-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If 16-bit MMIO register operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Address The MMIO register to read.
|
||||||
|
|
||||||
|
@return The value read.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT16
|
||||||
|
EFIAPI
|
||||||
|
MmioRead16 (
|
||||||
|
IN UINTN Address
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make sure Address is aligned on a 16-bit boundary.
|
||||||
|
//
|
||||||
|
ASSERT ((Address & 1) == 0);
|
||||||
|
return (UINT16)MmioReadWorker (Address, SMM_IO_UINT16);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Writes a 16-bit MMIO register.
|
||||||
|
|
||||||
|
Writes the 16-bit MMIO register specified by Address with the value specified
|
||||||
|
by Value and returns Value. This function must guarantee that all MMIO read
|
||||||
|
and write operations are serialized.
|
||||||
|
|
||||||
|
If Address is not aligned on a 16-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If 16-bit MMIO register operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Address The MMIO register to write.
|
||||||
|
@param Value The value to write to the MMIO register.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT16
|
||||||
|
EFIAPI
|
||||||
|
MmioWrite16 (
|
||||||
|
IN UINTN Address,
|
||||||
|
IN UINT16 Value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make sure Address is aligned on a 16-bit boundary.
|
||||||
|
//
|
||||||
|
ASSERT ((Address & 1) == 0);
|
||||||
|
return (UINT16)MmioWriteWorker (Address, SMM_IO_UINT16, Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads a 32-bit MMIO register.
|
||||||
|
|
||||||
|
Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
|
||||||
|
returned. This function must guarantee that all MMIO read and write
|
||||||
|
operations are serialized.
|
||||||
|
|
||||||
|
If Address is not aligned on a 32-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If 32-bit MMIO register operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Address The MMIO register to read.
|
||||||
|
|
||||||
|
@return The value read.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
MmioRead32 (
|
||||||
|
IN UINTN Address
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make sure Address is aligned on a 32-bit boundary.
|
||||||
|
//
|
||||||
|
ASSERT ((Address & 3) == 0);
|
||||||
|
return (UINT32)MmioReadWorker (Address, SMM_IO_UINT32);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Writes a 32-bit MMIO register.
|
||||||
|
|
||||||
|
Writes the 32-bit MMIO register specified by Address with the value specified
|
||||||
|
by Value and returns Value. This function must guarantee that all MMIO read
|
||||||
|
and write operations are serialized.
|
||||||
|
|
||||||
|
If Address is not aligned on a 32-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If 32-bit MMIO register operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Address The MMIO register to write.
|
||||||
|
@param Value The value to write to the MMIO register.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
MmioWrite32 (
|
||||||
|
IN UINTN Address,
|
||||||
|
IN UINT32 Value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make sure Address is aligned on a 32-bit boundary.
|
||||||
|
//
|
||||||
|
ASSERT ((Address & 3) == 0);
|
||||||
|
return (UINT32)MmioWriteWorker (Address, SMM_IO_UINT32, Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads a 64-bit MMIO register.
|
||||||
|
|
||||||
|
Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
|
||||||
|
returned. This function must guarantee that all MMIO read and write
|
||||||
|
operations are serialized.
|
||||||
|
|
||||||
|
If Address is not aligned on a 64-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If 64-bit MMIO register operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Address The MMIO register to read.
|
||||||
|
|
||||||
|
@return The value read.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
MmioRead64 (
|
||||||
|
IN UINTN Address
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make sure Address is aligned on a 64-bit boundary.
|
||||||
|
//
|
||||||
|
ASSERT ((Address & 7) == 0);
|
||||||
|
return (UINT64)MmioReadWorker (Address, SMM_IO_UINT64);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Writes a 64-bit MMIO register.
|
||||||
|
|
||||||
|
Writes the 64-bit MMIO register specified by Address with the value specified
|
||||||
|
by Value and returns Value. This function must guarantee that all MMIO read
|
||||||
|
and write operations are serialized.
|
||||||
|
|
||||||
|
If Address is not aligned on a 64-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If 64-bit MMIO register operations are not supported, then ASSERT().
|
||||||
|
|
||||||
|
@param Address The MMIO register to write.
|
||||||
|
@param Value The value to write to the MMIO register.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
MmioWrite64 (
|
||||||
|
IN UINTN Address,
|
||||||
|
IN UINT64 Value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make sure Address is aligned on a 64-bit boundary.
|
||||||
|
//
|
||||||
|
ASSERT ((Address & 7) == 0);
|
||||||
|
return (UINT64)MmioWriteWorker (Address, SMM_IO_UINT64, Value);
|
||||||
|
}
|
416
MdePkg/Library/SmmIoLibCpuIo/IoLibMmioBuffer.c
Normal file
416
MdePkg/Library/SmmIoLibCpuIo/IoLibMmioBuffer.c
Normal file
@ -0,0 +1,416 @@
|
|||||||
|
/** @file
|
||||||
|
I/O Library MMIO Buffer Functions.
|
||||||
|
|
||||||
|
Copyright (c) 2009, Intel Corporation<BR>
|
||||||
|
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: IoLibMmioBuffer.c
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
#include "SmmCpuIoLibInternal.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copy data from MMIO region to system memory by using 8-bit access.
|
||||||
|
|
||||||
|
Copy data from MMIO region specified by starting address StartAddress
|
||||||
|
to system memory specified by Buffer by using 8-bit access. The total
|
||||||
|
number of byte to be copied is specified by Length. Buffer is returned.
|
||||||
|
|
||||||
|
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||||
|
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||||
|
|
||||||
|
|
||||||
|
@param StartAddress Starting address for the MMIO region to be copied from.
|
||||||
|
@param Length Size in bytes of the copy.
|
||||||
|
@param Buffer Pointer to a system memory buffer receiving the data read.
|
||||||
|
|
||||||
|
@return Buffer
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT8 *
|
||||||
|
EFIAPI
|
||||||
|
MmioReadBuffer8 (
|
||||||
|
IN UINTN StartAddress,
|
||||||
|
IN UINTN Length,
|
||||||
|
OUT UINT8 *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT8 *ReturnBuffer;
|
||||||
|
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||||
|
|
||||||
|
ReturnBuffer = Buffer;
|
||||||
|
|
||||||
|
while (Length-- > 0) {
|
||||||
|
*(Buffer++) = MmioRead8 (StartAddress++);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copy data from MMIO region to system memory by using 16-bit access.
|
||||||
|
|
||||||
|
Copy data from MMIO region specified by starting address StartAddress
|
||||||
|
to system memory specified by Buffer by using 16-bit access. The total
|
||||||
|
number of byte to be copied is specified by Length. Buffer is returned.
|
||||||
|
|
||||||
|
If StartAddress is not aligned on a 16-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||||
|
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||||
|
|
||||||
|
If Length is not aligned on a 16-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If Buffer is not aligned on a 16-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
@param StartAddress Starting address for the MMIO region to be copied from.
|
||||||
|
@param Length Size in bytes of the copy.
|
||||||
|
@param Buffer Pointer to a system memory buffer receiving the data read.
|
||||||
|
|
||||||
|
@return Buffer
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT16 *
|
||||||
|
EFIAPI
|
||||||
|
MmioReadBuffer16 (
|
||||||
|
IN UINTN StartAddress,
|
||||||
|
IN UINTN Length,
|
||||||
|
OUT UINT16 *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT16 *ReturnBuffer;
|
||||||
|
|
||||||
|
ASSERT ((StartAddress & (sizeof (UINT16) - 1)) == 0);
|
||||||
|
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||||
|
|
||||||
|
ASSERT ((Length & (sizeof (UINT16) - 1)) == 0);
|
||||||
|
ASSERT (((UINTN) Buffer & (sizeof (UINT16) - 1)) == 0);
|
||||||
|
|
||||||
|
ReturnBuffer = Buffer;
|
||||||
|
|
||||||
|
while (Length > 0) {
|
||||||
|
*(Buffer++) = MmioRead16 (StartAddress);
|
||||||
|
StartAddress += sizeof (UINT16);
|
||||||
|
Length -= sizeof (UINT16);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copy data from MMIO region to system memory by using 32-bit access.
|
||||||
|
|
||||||
|
Copy data from MMIO region specified by starting address StartAddress
|
||||||
|
to system memory specified by Buffer by using 32-bit access. The total
|
||||||
|
number of byte to be copied is specified by Length. Buffer is returned.
|
||||||
|
|
||||||
|
If StartAddress is not aligned on a 32-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||||
|
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||||
|
|
||||||
|
If Length is not aligned on a 32-bit boundary, then ASSERT().
|
||||||
|
If Buffer is not aligned on a 32-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
@param StartAddress Starting address for the MMIO region to be copied from.
|
||||||
|
@param Length Size in bytes of the copy.
|
||||||
|
@param Buffer Pointer to a system memory buffer receiving the data read.
|
||||||
|
|
||||||
|
@return Buffer
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32 *
|
||||||
|
EFIAPI
|
||||||
|
MmioReadBuffer32 (
|
||||||
|
IN UINTN StartAddress,
|
||||||
|
IN UINTN Length,
|
||||||
|
OUT UINT32 *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT32 *ReturnBuffer;
|
||||||
|
|
||||||
|
ASSERT ((StartAddress & (sizeof (UINT32) - 1)) == 0);
|
||||||
|
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||||
|
|
||||||
|
ASSERT ((Length & (sizeof (UINT32) - 1)) == 0);
|
||||||
|
ASSERT (((UINTN) Buffer & (sizeof (UINT32) - 1)) == 0);
|
||||||
|
|
||||||
|
ReturnBuffer = Buffer;
|
||||||
|
|
||||||
|
while (Length > 0) {
|
||||||
|
*(Buffer++) = MmioRead32 (StartAddress);
|
||||||
|
StartAddress += sizeof (UINT32);
|
||||||
|
Length -= sizeof (UINT32);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copy data from MMIO region to system memory by using 64-bit access.
|
||||||
|
|
||||||
|
Copy data from MMIO region specified by starting address StartAddress
|
||||||
|
to system memory specified by Buffer by using 64-bit access. The total
|
||||||
|
number of byte to be copied is specified by Length. Buffer is returned.
|
||||||
|
|
||||||
|
If StartAddress is not aligned on a 64-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||||
|
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||||
|
|
||||||
|
If Length is not aligned on a 64-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If Buffer is not aligned on a 64-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
@param StartAddress Starting address for the MMIO region to be copied from.
|
||||||
|
@param Length Size in bytes of the copy.
|
||||||
|
@param Buffer Pointer to a system memory buffer receiving the data read.
|
||||||
|
|
||||||
|
@return Buffer
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64 *
|
||||||
|
EFIAPI
|
||||||
|
MmioReadBuffer64 (
|
||||||
|
IN UINTN StartAddress,
|
||||||
|
IN UINTN Length,
|
||||||
|
OUT UINT64 *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT64 *ReturnBuffer;
|
||||||
|
|
||||||
|
ASSERT ((StartAddress & (sizeof (UINT64) - 1)) == 0);
|
||||||
|
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||||
|
|
||||||
|
ASSERT ((Length & (sizeof (UINT64) - 1)) == 0);
|
||||||
|
ASSERT (((UINTN) Buffer & (sizeof (UINT64) - 1)) == 0);
|
||||||
|
|
||||||
|
ReturnBuffer = Buffer;
|
||||||
|
|
||||||
|
while (Length > 0) {
|
||||||
|
*(Buffer++) = MmioRead64 (StartAddress);
|
||||||
|
StartAddress += sizeof (UINT64);
|
||||||
|
Length -= sizeof (UINT64);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copy data from system memory to MMIO region by using 8-bit access.
|
||||||
|
|
||||||
|
Copy data from system memory specified by Buffer to MMIO region specified
|
||||||
|
by starting address StartAddress by using 8-bit access. The total number
|
||||||
|
of byte to be copied is specified by Length. Buffer is returned.
|
||||||
|
|
||||||
|
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||||
|
If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
|
||||||
|
|
||||||
|
|
||||||
|
@param StartAddress Starting address for the MMIO region to be copied to.
|
||||||
|
@param Length Size in bytes of the copy.
|
||||||
|
@param Buffer Pointer to a system memory buffer containing the data to write.
|
||||||
|
|
||||||
|
@return Buffer
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT8 *
|
||||||
|
EFIAPI
|
||||||
|
MmioWriteBuffer8 (
|
||||||
|
IN UINTN StartAddress,
|
||||||
|
IN UINTN Length,
|
||||||
|
IN CONST UINT8 *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
VOID* ReturnBuffer;
|
||||||
|
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||||
|
|
||||||
|
ReturnBuffer = (UINT8 *) Buffer;
|
||||||
|
|
||||||
|
while (Length-- > 0) {
|
||||||
|
MmioWrite8 (StartAddress++, *(Buffer++));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnBuffer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copy data from system memory to MMIO region by using 16-bit access.
|
||||||
|
|
||||||
|
Copy data from system memory specified by Buffer to MMIO region specified
|
||||||
|
by starting address StartAddress by using 16-bit access. The total number
|
||||||
|
of byte to be copied is specified by Length. Buffer is returned.
|
||||||
|
|
||||||
|
If StartAddress is not aligned on a 16-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||||
|
If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
|
||||||
|
|
||||||
|
If Length is not aligned on a 16-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If Buffer is not aligned on a 16-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
@param StartAddress Starting address for the MMIO region to be copied to.
|
||||||
|
@param Length Size in bytes of the copy.
|
||||||
|
@param Buffer Pointer to a system memory buffer containing the data to write.
|
||||||
|
|
||||||
|
@return Buffer
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT16 *
|
||||||
|
EFIAPI
|
||||||
|
MmioWriteBuffer16 (
|
||||||
|
IN UINTN StartAddress,
|
||||||
|
IN UINTN Length,
|
||||||
|
IN CONST UINT16 *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT16 *ReturnBuffer;
|
||||||
|
|
||||||
|
ASSERT ((StartAddress & (sizeof (UINT16) - 1)) == 0);
|
||||||
|
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||||
|
|
||||||
|
ASSERT ((Length & (sizeof (UINT16) - 1)) == 0);
|
||||||
|
ASSERT (((UINTN) Buffer & (sizeof (UINT16) - 1)) == 0);
|
||||||
|
|
||||||
|
ReturnBuffer = (UINT16 *) Buffer;
|
||||||
|
|
||||||
|
while (Length > 0) {
|
||||||
|
MmioWrite16 (StartAddress, *(Buffer++));
|
||||||
|
|
||||||
|
StartAddress += sizeof (UINT16);
|
||||||
|
Length -= sizeof (UINT16);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copy data from system memory to MMIO region by using 32-bit access.
|
||||||
|
|
||||||
|
Copy data from system memory specified by Buffer to MMIO region specified
|
||||||
|
by starting address StartAddress by using 32-bit access. The total number
|
||||||
|
of byte to be copied is specified by Length. Buffer is returned.
|
||||||
|
|
||||||
|
If StartAddress is not aligned on a 32-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||||
|
If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
|
||||||
|
|
||||||
|
If Length is not aligned on a 32-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If Buffer is not aligned on a 32-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
@param StartAddress Starting address for the MMIO region to be copied to.
|
||||||
|
@param Length Size in bytes of the copy.
|
||||||
|
@param Buffer Pointer to a system memory buffer containing the data to write.
|
||||||
|
|
||||||
|
@return Buffer
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32 *
|
||||||
|
EFIAPI
|
||||||
|
MmioWriteBuffer32 (
|
||||||
|
IN UINTN StartAddress,
|
||||||
|
IN UINTN Length,
|
||||||
|
IN CONST UINT32 *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT32 *ReturnBuffer;
|
||||||
|
|
||||||
|
ASSERT ((StartAddress & (sizeof (UINT32) - 1)) == 0);
|
||||||
|
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||||
|
|
||||||
|
ASSERT ((Length & (sizeof (UINT32) - 1)) == 0);
|
||||||
|
ASSERT (((UINTN) Buffer & (sizeof (UINT32) - 1)) == 0);
|
||||||
|
|
||||||
|
ReturnBuffer = (UINT32 *) Buffer;
|
||||||
|
|
||||||
|
while (Length > 0) {
|
||||||
|
MmioWrite32 (StartAddress, *(Buffer++));
|
||||||
|
|
||||||
|
StartAddress += sizeof (UINT32);
|
||||||
|
Length -= sizeof (UINT32);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copy data from system memory to MMIO region by using 64-bit access.
|
||||||
|
|
||||||
|
Copy data from system memory specified by Buffer to MMIO region specified
|
||||||
|
by starting address StartAddress by using 64-bit access. The total number
|
||||||
|
of byte to be copied is specified by Length. Buffer is returned.
|
||||||
|
|
||||||
|
If StartAddress is not aligned on a 64-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||||
|
If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
|
||||||
|
|
||||||
|
If Length is not aligned on a 64-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
If Buffer is not aligned on a 64-bit boundary, then ASSERT().
|
||||||
|
|
||||||
|
@param StartAddress Starting address for the MMIO region to be copied to.
|
||||||
|
@param Length Size in bytes of the copy.
|
||||||
|
@param Buffer Pointer to a system memory buffer containing the data to write.
|
||||||
|
|
||||||
|
@return Buffer
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64 *
|
||||||
|
EFIAPI
|
||||||
|
MmioWriteBuffer64 (
|
||||||
|
IN UINTN StartAddress,
|
||||||
|
IN UINTN Length,
|
||||||
|
IN CONST UINT64 *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT64 *ReturnBuffer;
|
||||||
|
|
||||||
|
ASSERT ((StartAddress & (sizeof (UINT64) - 1)) == 0);
|
||||||
|
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||||
|
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||||
|
|
||||||
|
ASSERT ((Length & (sizeof (UINT64) - 1)) == 0);
|
||||||
|
ASSERT (((UINTN) Buffer & (sizeof (UINT64) - 1)) == 0);
|
||||||
|
|
||||||
|
ReturnBuffer = (UINT64 *) Buffer;
|
||||||
|
|
||||||
|
while (Length > 0) {
|
||||||
|
MmioWrite64 (StartAddress, *(Buffer++));
|
||||||
|
|
||||||
|
StartAddress += sizeof (UINT64);
|
||||||
|
Length -= sizeof (UINT64);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnBuffer;
|
||||||
|
}
|
||||||
|
|
121
MdePkg/Library/SmmIoLibCpuIo/SmmCpuIoLibInternal.h
Normal file
121
MdePkg/Library/SmmIoLibCpuIo/SmmCpuIoLibInternal.h
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
/** @file
|
||||||
|
Internal include file of SMM CPU IO Library.
|
||||||
|
It includes all necessary protocol/library class's header file
|
||||||
|
for implementation of IoLib library instance. It is included
|
||||||
|
all source code of this library instance.
|
||||||
|
|
||||||
|
Copyright (c) 2009, 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: DxeCpuIoLibInternal.h
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _SMM_CPUIO_LIB_INTERNAL_H_
|
||||||
|
#define _SMM_CPUIO_LIB_INTERNAL_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include <PiSmm.h>
|
||||||
|
#include <Protocol/SmmCpuIo.h>
|
||||||
|
#include <Protocol/SmmPciRootBridgeIo.h>
|
||||||
|
#include <Library/IoLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/SmmServicesTableLib.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads registers in the EFI CPU I/O space.
|
||||||
|
|
||||||
|
Reads the I/O port specified by Port with registers width specified by Width.
|
||||||
|
The read value is returned. If such operations are not supported, then ASSERT().
|
||||||
|
This function must guarantee that all I/O read and write operations are serialized.
|
||||||
|
|
||||||
|
@param Port The base address of the I/O operation.
|
||||||
|
The caller is responsible for aligning the Address if required.
|
||||||
|
@param Width The width of the I/O operation.
|
||||||
|
|
||||||
|
@return Data read from registers in the EFI CPU I/O space.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
IoReadWorker (
|
||||||
|
IN UINTN Port,
|
||||||
|
IN EFI_SMM_IO_WIDTH Width
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Writes registers in the EFI CPU I/O space.
|
||||||
|
|
||||||
|
Writes the I/O port specified by Port with registers width and value specified by Width
|
||||||
|
and Data respectively. Data is returned. If such operations are not supported, then ASSERT().
|
||||||
|
This function must guarantee that all I/O read and write operations are serialized.
|
||||||
|
|
||||||
|
@param Port The base address of the I/O operation.
|
||||||
|
The caller is responsible for aligning the Address if required.
|
||||||
|
@param Width The width of the I/O operation.
|
||||||
|
@param Data The value to write to the I/O port.
|
||||||
|
|
||||||
|
@return The paramter of Data.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
IoWriteWorker (
|
||||||
|
IN UINTN Port,
|
||||||
|
IN EFI_SMM_IO_WIDTH Width,
|
||||||
|
IN UINT64 Data
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads memory-mapped registers in the EFI system memory space.
|
||||||
|
|
||||||
|
Reads the MMIO registers specified by Address with registers width specified by Width.
|
||||||
|
The read value is returned. If such operations are not supported, then ASSERT().
|
||||||
|
This function must guarantee that all MMIO read and write operations are serialized.
|
||||||
|
|
||||||
|
@param Address The MMIO register to read.
|
||||||
|
The caller is responsible for aligning the Address if required.
|
||||||
|
@param Width The width of the I/O operation.
|
||||||
|
|
||||||
|
@return Data read from registers in the EFI system memory space.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
MmioReadWorker (
|
||||||
|
IN UINTN Address,
|
||||||
|
IN EFI_SMM_IO_WIDTH Width
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Writes memory-mapped registers in the EFI system memory space.
|
||||||
|
|
||||||
|
Writes the MMIO registers specified by Address with registers width and value specified by Width
|
||||||
|
and Data respectively. Data is returned. If such operations are not supported, then ASSERT().
|
||||||
|
This function must guarantee that all MMIO read and write operations are serialized.
|
||||||
|
|
||||||
|
@param Address The MMIO register to read.
|
||||||
|
The caller is responsible for aligning the Address if required.
|
||||||
|
@param Width The width of the I/O operation.
|
||||||
|
@param Data The value to write to the I/O port.
|
||||||
|
|
||||||
|
@return Data read from registers in the EFI system memory space.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
MmioWriteWorker (
|
||||||
|
IN UINTN Address,
|
||||||
|
IN EFI_SMM_IO_WIDTH Width,
|
||||||
|
IN UINT64 Data
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif
|
56
MdePkg/Library/SmmIoLibCpuIo/SmmIoLibCpuIo.inf
Normal file
56
MdePkg/Library/SmmIoLibCpuIo/SmmIoLibCpuIo.inf
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#/** @file
|
||||||
|
# Component description file for Cpu Io SMM Io Library.
|
||||||
|
#
|
||||||
|
# I/O Library implementation that uses the CPU I/O Protocol for I/O
|
||||||
|
# and MMIO operations.
|
||||||
|
# Copyright (c) 2009, 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.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#**/
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = SmmIoLibCpuIo
|
||||||
|
FILE_GUID = DEEEA15E-4A77-4513-BA75-71D26FEF78A1
|
||||||
|
MODULE_TYPE = DXE_SMM_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
LIBRARY_CLASS = IoLib|DXE_SMM_DRIVER SMM_CORE
|
||||||
|
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||||
|
PI_SPECIFICATION_VERSION = 0x0001000A
|
||||||
|
|
||||||
|
CONSTRUCTOR = IoLibConstructor
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources.common]
|
||||||
|
IoLibMmioBuffer.c
|
||||||
|
SmmCpuIoLibInternal.h
|
||||||
|
IoHighLevel.c
|
||||||
|
IoLib.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseLib
|
||||||
|
DebugLib
|
||||||
|
SmmServicesTableLib
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiSmmCpuIoProtocolGuid ## CONSUMES
|
||||||
|
gEfiSmmPciRootBridgeIoProtocolGuid ## CONSUMES
|
||||||
|
|
||||||
|
[Depex]
|
||||||
|
gEfiSmmCpuIoProtocolGuid OR gEfiSmmPciRootBridgeIoProtocolGuid
|
1420
MdePkg/Library/SmmPciLibPciRootBridgeIo/PciLib.c
Normal file
1420
MdePkg/Library/SmmPciLibPciRootBridgeIo/PciLib.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,54 @@
|
|||||||
|
# @file
|
||||||
|
# PCI Library that layers on top of the SMM PCI Root Bridge I/O Protocol.
|
||||||
|
#
|
||||||
|
# This library produces the APIs from the PCI Library and implements these APIs
|
||||||
|
# by calling into the PCI Root Bridge I/O Protocol. The PCI Root Bridge I/O Protocol is
|
||||||
|
# typically produced by a chipset specific DXE driver.
|
||||||
|
# This library binds to the first PCI Root Bridge I/O Protocol in the platform. As a result,
|
||||||
|
# it should only be used on platforms that contain a single PCI root bridge.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009, 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.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = SmmPciLibPciRootBridgeIo
|
||||||
|
FILE_GUID = F6994CBA-2351-4ebc-A2DA-20BAC2FE2CF3
|
||||||
|
MODULE_TYPE = DXE_SMM_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
LIBRARY_CLASS = PciLib|DXE_SMM_DRIVER SMM_CORE
|
||||||
|
PI_SPECIFICATION_VERSION = 0x0001000A
|
||||||
|
|
||||||
|
CONSTRUCTOR = PciLibConstructor
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources.common]
|
||||||
|
PciLib.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseLib
|
||||||
|
SmmServicesTableLib
|
||||||
|
DebugLib
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiSmmPciRootBridgeIoProtocolGuid ## CONSUMES
|
||||||
|
|
104
MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c
Normal file
104
MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/** @file
|
||||||
|
SMM Services Table Library.
|
||||||
|
|
||||||
|
Copyright (c) 2009, Intel Corporation<BR>
|
||||||
|
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.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <PiDxe.h>
|
||||||
|
#include <PiSmm.h>
|
||||||
|
#include <Protocol/SmmBase2.h>
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/SmmServicesTableLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
|
||||||
|
EFI_SMM_SYSTEM_TABLE2 *gSmst = NULL;
|
||||||
|
EFI_SMM_BASE2_PROTOCOL *mInternalSmmBase2 = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
The constructor function caches the pointer of Smm Services Table.
|
||||||
|
|
||||||
|
@param ImageHandle The firmware allocated handle for the EFI image.
|
||||||
|
@param SystemTable A pointer to the EFI System Table.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
SmmServicesTableLibConstructor (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
BOOLEAN InSmm;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve SMM Base2 Protocol
|
||||||
|
//
|
||||||
|
Status = gBS->LocateProtocol (
|
||||||
|
&gEfiSmmBase2ProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID **) &mInternalSmmBase2
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
ASSERT (mInternalSmmBase2 != NULL);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check to see if we are already in SMM
|
||||||
|
//
|
||||||
|
mInternalSmmBase2->InSmm (mInternalSmmBase2, &InSmm);
|
||||||
|
|
||||||
|
if (!InSmm) {
|
||||||
|
//
|
||||||
|
// We are not in SMM, so SMST is not needed
|
||||||
|
//
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// We are in SMM, retrieve the pointer to SMM System Table
|
||||||
|
//
|
||||||
|
mInternalSmmBase2->GetSmstLocation (mInternalSmmBase2, &gSmst);
|
||||||
|
|
||||||
|
ASSERT (gSmst != NULL);
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function allows the caller to determine if the driver is executing in
|
||||||
|
System Management Mode(SMM).
|
||||||
|
|
||||||
|
This function returns TRUE if the driver is executing in SMM and FALSE if the
|
||||||
|
driver is not executing in SMM.
|
||||||
|
|
||||||
|
@retval TRUE The driver is executing in System Management Mode (SMM).
|
||||||
|
@retval FALSE The driver is not executing in System Management Mode (SMM).
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
EFIAPI
|
||||||
|
InSmm (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOLEAN InSmm;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check to see if we are already in SMM
|
||||||
|
//
|
||||||
|
mInternalSmmBase2->InSmm (mInternalSmmBase2, &InSmm);
|
||||||
|
|
||||||
|
return InSmm;
|
||||||
|
}
|
47
MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
Normal file
47
MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#/** @file
|
||||||
|
# SMM Services Table Library.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009, 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.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#**/
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = SmmServicesTableLib
|
||||||
|
FILE_GUID = 064B4C5B-C5EF-4eff-85DF-65518EF1314D
|
||||||
|
MODULE_TYPE = DXE_SMM_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
LIBRARY_CLASS = SmmServicesTableLib|SMM_CORE DXE_SMM_DRIVER
|
||||||
|
EDK_RELEASE_VERSION = 0x00020000
|
||||||
|
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||||
|
PI_SPECIFICATION_VERSION = 0x0001000A
|
||||||
|
|
||||||
|
CONSTRUCTOR = SmmServicesTableLibConstructor
|
||||||
|
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources.common]
|
||||||
|
SmmServicesTableLib.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
DebugLib
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiSmmBase2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
|
|
||||||
|
[Depex.common.DXE_DRIVER]
|
||||||
|
gEfiSmmBase2ProtocolGuid
|
@ -1,7 +1,7 @@
|
|||||||
#/** @file
|
#/** @file
|
||||||
# UEFI Boot Services Table Library implementation.
|
# UEFI Boot Services Table Library implementation.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2007 - 2008, Intel Corporation.
|
# Copyright (c) 2007 - 2009, Intel Corporation.
|
||||||
#
|
#
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -19,7 +19,7 @@
|
|||||||
FILE_GUID = ff5c7a2c-ab7a-4366-8616-11c6e53247b6
|
FILE_GUID = ff5c7a2c-ab7a-4366-8616-11c6e53247b6
|
||||||
MODULE_TYPE = UEFI_DRIVER
|
MODULE_TYPE = UEFI_DRIVER
|
||||||
VERSION_STRING = 1.0
|
VERSION_STRING = 1.0
|
||||||
LIBRARY_CLASS = UefiBootServicesTableLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
LIBRARY_CLASS = UefiBootServicesTableLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
|
||||||
|
|
||||||
CONSTRUCTOR = UefiBootServicesTableLibConstructor
|
CONSTRUCTOR = UefiBootServicesTableLibConstructor
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Device Path Library that layers on top of the Memory Allocation Library.
|
# Device Path Library that layers on top of the Memory Allocation Library.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2007 - 2008, Intel Corporation
|
# Copyright (c) 2007 - 2009, Intel Corporation
|
||||||
#
|
#
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -21,7 +21,7 @@
|
|||||||
FILE_GUID = 91c1677a-e57f-4191-8b8e-eb7711a716e0
|
FILE_GUID = 91c1677a-e57f-4191-8b8e-eb7711a716e0
|
||||||
MODULE_TYPE = UEFI_DRIVER
|
MODULE_TYPE = UEFI_DRIVER
|
||||||
VERSION_STRING = 1.0
|
VERSION_STRING = 1.0
|
||||||
LIBRARY_CLASS = DevicePathLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
LIBRARY_CLASS = DevicePathLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#/** @file
|
#/** @file
|
||||||
# Module entry point library for UEFI driver.
|
# Module entry point library for UEFI driver.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2007 - 2008, Intel Corporation.
|
# Copyright (c) 2007 - 2009, Intel Corporation.
|
||||||
#
|
#
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -19,7 +19,7 @@
|
|||||||
FILE_GUID = 331deb15-454b-48d8-9b74-70d01f3f3556
|
FILE_GUID = 331deb15-454b-48d8-9b74-70d01f3f3556
|
||||||
MODULE_TYPE = UEFI_DRIVER
|
MODULE_TYPE = UEFI_DRIVER
|
||||||
VERSION_STRING = 1.0
|
VERSION_STRING = 1.0
|
||||||
LIBRARY_CLASS = UefiDriverEntryPoint|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER UEFI_DRIVER
|
LIBRARY_CLASS = UefiDriverEntryPoint|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER UEFI_DRIVER SMM_CORE DXE_SMM_DRIVER
|
||||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
# EFI Driver Model related protocols, manage Unicode string tables for UEFI Drivers,
|
# EFI Driver Model related protocols, manage Unicode string tables for UEFI Drivers,
|
||||||
# and print messages on the console output and standard error devices.
|
# and print messages on the console output and standard error devices.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2007 - 2008, Intel Corporation
|
# Copyright (c) 2007 - 2009, Intel Corporation
|
||||||
#
|
#
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -25,7 +25,7 @@
|
|||||||
FILE_GUID = 3a004ba5-efe0-4a61-9f1a-267a46ae5ba9
|
FILE_GUID = 3a004ba5-efe0-4a61-9f1a-267a46ae5ba9
|
||||||
MODULE_TYPE = UEFI_DRIVER
|
MODULE_TYPE = UEFI_DRIVER
|
||||||
VERSION_STRING = 1.0
|
VERSION_STRING = 1.0
|
||||||
LIBRARY_CLASS = UefiLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
LIBRARY_CLASS = UefiLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# Memory Allocation Library that uses EFI Boot Services to allocate
|
# Memory Allocation Library that uses EFI Boot Services to allocate
|
||||||
# and free memory.
|
# and free memory.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2007 - 2008, Intel Corporation
|
# Copyright (c) 2007 - 2009, Intel Corporation
|
||||||
#
|
#
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -22,7 +22,7 @@
|
|||||||
FILE_GUID = 4674739d-3195-4fb2-8094-ac1d22d00194
|
FILE_GUID = 4674739d-3195-4fb2-8094-ac1d22d00194
|
||||||
MODULE_TYPE = UEFI_DRIVER
|
MODULE_TYPE = UEFI_DRIVER
|
||||||
VERSION_STRING = 1.0
|
VERSION_STRING = 1.0
|
||||||
LIBRARY_CLASS = MemoryAllocationLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
LIBRARY_CLASS = MemoryAllocationLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#/** @file
|
#/** @file
|
||||||
# UEFI Runtime Services Table Library implementation.
|
# UEFI Runtime Services Table Library implementation.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2007 - 2008, Intel Corporation.
|
# Copyright (c) 2007 - 2009, Intel Corporation.
|
||||||
#
|
#
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -19,7 +19,7 @@
|
|||||||
FILE_GUID = 19cbbb97-ff61-45ff-8c3f-dfa66dd118c8
|
FILE_GUID = 19cbbb97-ff61-45ff-8c3f-dfa66dd118c8
|
||||||
MODULE_TYPE = UEFI_DRIVER
|
MODULE_TYPE = UEFI_DRIVER
|
||||||
VERSION_STRING = 1.0
|
VERSION_STRING = 1.0
|
||||||
LIBRARY_CLASS = UefiRuntimeServicesTableLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
LIBRARY_CLASS = UefiRuntimeServicesTableLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
|
||||||
|
|
||||||
CONSTRUCTOR = UefiRuntimeServicesTableLibConstructor
|
CONSTRUCTOR = UefiRuntimeServicesTableLibConstructor
|
||||||
|
|
||||||
|
@ -74,6 +74,10 @@
|
|||||||
# Only available to DXE and UEFI module types.
|
# Only available to DXE and UEFI module types.
|
||||||
UefiBootServicesTableLib|Include/Library/UefiBootServicesTableLib.h
|
UefiBootServicesTableLib|Include/Library/UefiBootServicesTableLib.h
|
||||||
|
|
||||||
|
## @libraryclass Provides a service to retrieve a pointer to the SMM Services Table.
|
||||||
|
# Only available to SMM/DXE Combined and SMM module types.
|
||||||
|
SmmServicesTableLib|Include/Library/SmmServicesTableLib.h
|
||||||
|
|
||||||
## @libraryclass Module entry point library for UEFI Applications.
|
## @libraryclass Module entry point library for UEFI Applications.
|
||||||
UefiApplicationEntryPoint|Include/Library/UefiApplicationEntryPoint.h
|
UefiApplicationEntryPoint|Include/Library/UefiApplicationEntryPoint.h
|
||||||
|
|
||||||
@ -429,6 +433,8 @@
|
|||||||
#
|
#
|
||||||
# GUID defined in PI1.2
|
# GUID defined in PI1.2
|
||||||
#
|
#
|
||||||
|
## Include/Guid/EventGroup.h
|
||||||
|
gEfiEventDxeDispatchGuid = { 0x7081E22F, 0xCAC6, 0x4053, { 0x94, 0x68, 0x67, 0x57, 0x82, 0xCF, 0x88, 0xE5 }}
|
||||||
|
|
||||||
## Guid for EFI_DISK_INFO_PROTOCOL.Interface to specify Ide interface.
|
## Guid for EFI_DISK_INFO_PROTOCOL.Interface to specify Ide interface.
|
||||||
## Include/Protocol/DiskInfo.h
|
## Include/Protocol/DiskInfo.h
|
||||||
|
@ -148,7 +148,9 @@
|
|||||||
MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
|
MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
|
||||||
MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
|
MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
|
||||||
MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
|
MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
|
||||||
|
MdePkg/Library/SmmIoLibCpuIo/SmmIoLibCpuIo.inf
|
||||||
|
MdePkg/Library/SmmPciLibPciRootBridgeIo/SmmPciLibPciRootBridgeIo.inf
|
||||||
|
MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
|
||||||
|
|
||||||
[Components.IPF]
|
[Components.IPF]
|
||||||
MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
|
MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user