MdePkg/IoLib: Filter/trace port IO/MMIO access

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3246

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
Dandan Bi
2021-03-12 10:26:10 +08:00
committed by mergify[bot]
parent 9c08b3e7d5
commit 38c8be123a
9 changed files with 329 additions and 73 deletions

View File

@@ -2,7 +2,7 @@
I/O library for non I/O read and write access (memory map I/O read and
write only) architecture, such as ARM and RISC-V processor.
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
@@ -408,8 +408,14 @@ MmioRead8 (
)
{
UINT8 Value;
BOOLEAN Flag;
Flag = FilterBeforeMmIoRead (FilterWidth8, Address, &Value);
if (Flag) {
Value = *(volatile UINT8*)Address;
}
FilterAfterMmIoRead (FilterWidth8, Address, &Value);
Value = *(volatile UINT8*)Address;
return Value;
}
@@ -433,7 +439,14 @@ MmioWrite8 (
IN UINT8 Value
)
{
*(volatile UINT8*)Address = Value;
BOOLEAN Flag;
Flag = FilterBeforeMmIoWrite (FilterWidth8, Address, &Value);
if (Flag) {
*(volatile UINT8*)Address = Value;
}
FilterAfterMmIoWrite (FilterWidth8, Address, &Value);
return Value;
}
@@ -458,9 +471,16 @@ MmioRead16 (
)
{
UINT16 Value;
BOOLEAN Flag;
ASSERT ((Address & 1) == 0);
Value = *(volatile UINT16*)Address;
Flag = FilterBeforeMmIoRead (FilterWidth16, Address, &Value);
if (Flag) {
Value = *(volatile UINT16*)Address;
}
FilterAfterMmIoRead (FilterWidth16, Address, &Value);
return Value;
}
@@ -484,8 +504,16 @@ MmioWrite16 (
IN UINT16 Value
)
{
BOOLEAN Flag;
ASSERT ((Address & 1) == 0);
*(volatile UINT16*)Address = Value;
Flag = FilterBeforeMmIoWrite (FilterWidth16, Address, &Value);
if (Flag) {
*(volatile UINT16*)Address = Value;
}
FilterAfterMmIoWrite (FilterWidth16, Address, &Value);
return Value;
}
@@ -510,9 +538,16 @@ MmioRead32 (
)
{
UINT32 Value;
BOOLEAN Flag;
ASSERT ((Address & 3) == 0);
Value = *(volatile UINT32*)Address;
Flag = FilterBeforeMmIoRead (FilterWidth32, Address, &Value);
if (Flag) {
Value = *(volatile UINT32*)Address;
}
FilterAfterMmIoRead (FilterWidth32, Address, &Value);
return Value;
}
@@ -536,8 +571,16 @@ MmioWrite32 (
IN UINT32 Value
)
{
BOOLEAN Flag;
ASSERT ((Address & 3) == 0);
Flag = FilterBeforeMmIoWrite (FilterWidth32, Address, &Value);
if (Flag) {
*(volatile UINT32*)Address = Value;
}
FilterAfterMmIoWrite (FilterWidth32, Address, &Value);
return Value;
}
@@ -562,9 +605,16 @@ MmioRead64 (
)
{
UINT64 Value;
BOOLEAN Flag;
ASSERT ((Address & 7) == 0);
Value = *(volatile UINT64*)Address;
Flag = FilterBeforeMmIoRead (FilterWidth64, Address, &Value);
if (Flag) {
Value = *(volatile UINT64*)Address;
}
FilterAfterMmIoRead (FilterWidth64, Address, &Value);
return Value;
}
@@ -588,8 +638,16 @@ MmioWrite64 (
IN UINT64 Value
)
{
BOOLEAN Flag;
ASSERT ((Address & 7) == 0);
*(volatile UINT64*)Address = Value;
Flag = FilterBeforeMmIoWrite (FilterWidth64, Address, &Value);
if (Flag) {
*(volatile UINT64*)Address = Value;
}
FilterAfterMmIoWrite (FilterWidth64, Address, &Value);
return Value;
}