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

@@ -1,7 +1,7 @@
/** @file
I/O Library for ARM.
Copyright (c) 2006 - 2009, 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) 2018, Linaro, Ltd. All rights reserved.<BR>
@@ -546,7 +546,16 @@ MmioRead8 (
IN UINTN Address
)
{
return MmioRead8Internal (Address);
UINT8 Value;
BOOLEAN Flag;
Flag = FilterBeforeMmIoRead (FilterWidth8, Address, &Value);
if (Flag) {
Value = MmioRead8Internal (Address);
}
FilterAfterMmIoRead (FilterWidth8, Address, &Value);
return Value;
}
/**
@@ -569,7 +578,14 @@ MmioWrite8 (
IN UINT8 Value
)
{
MmioWrite8Internal (Address, Value);
BOOLEAN Flag;
Flag = FilterBeforeMmIoWrite (FilterWidth8, Address, &Value);
if (Flag) {
MmioWrite8Internal (Address, Value);
}
FilterAfterMmIoWrite (FilterWidth8, Address, &Value);
return Value;
}
@@ -593,9 +609,18 @@ MmioRead16 (
IN UINTN Address
)
{
BOOLEAN Flag;
UINT16 Value;
ASSERT ((Address & 1) == 0);
return MmioRead16Internal (Address);
Flag = FilterBeforeMmIoRead (FilterWidth16, Address, &Value);
if (Flag) {
Value = MmioRead16Internal (Address);
}
FilterAfterMmIoRead (FilterWidth16, Address, &Value);
return Value;
}
/**
@@ -618,9 +643,16 @@ MmioWrite16 (
IN UINT16 Value
)
{
BOOLEAN Flag;
ASSERT ((Address & 1) == 0);
MmioWrite16Internal (Address, Value);
Flag = FilterBeforeMmIoWrite (FilterWidth16, Address, &Value);
if (Flag) {
MmioWrite16Internal (Address, Value);
}
FilterAfterMmIoWrite (FilterWidth16, Address, &Value);
return Value;
}
@@ -644,9 +676,18 @@ MmioRead32 (
IN UINTN Address
)
{
BOOLEAN Flag;
UINT32 Value;
ASSERT ((Address & 3) == 0);
return MmioRead32Internal (Address);
Flag = FilterBeforeMmIoRead (FilterWidth32, Address, &Value);
if (Flag) {
Value = MmioRead32Internal (Address);
}
FilterAfterMmIoRead (FilterWidth32, Address, &Value);
return Value;
}
/**
@@ -669,9 +710,16 @@ MmioWrite32 (
IN UINT32 Value
)
{
BOOLEAN Flag;
ASSERT ((Address & 3) == 0);
MmioWrite32Internal (Address, Value);
Flag = FilterBeforeMmIoWrite (FilterWidth32, Address, &Value);
if (Flag) {
MmioWrite32Internal (Address, Value);
}
FilterAfterMmIoWrite (FilterWidth32, Address, &Value);
return Value;
}
@@ -695,9 +743,18 @@ MmioRead64 (
IN UINTN Address
)
{
BOOLEAN Flag;
UINT64 Value;
ASSERT ((Address & 7) == 0);
return MmioRead64Internal (Address);
Flag = FilterBeforeMmIoRead (FilterWidth64, Address, &Value);
if (Flag) {
Value = MmioRead64Internal (Address);
}
FilterAfterMmIoRead (FilterWidth64, Address, &Value);
return Value;
}
/**
@@ -720,8 +777,15 @@ MmioWrite64 (
IN UINT64 Value
)
{
BOOLEAN Flag;
ASSERT ((Address & 7) == 0);
MmioWrite64Internal (Address, Value);
Flag = FilterBeforeMmIoWrite (FilterWidth64, Address, &Value);
if (Flag) {
MmioWrite64Internal (Address, Value);
}
FilterAfterMmIoWrite (FilterWidth64, Address, &Value);
return Value;
}