X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdePkg%2FLibrary%2FBaseIoLibIntrinsic%2FIoLib.c;fp=MdePkg%2FLibrary%2FBaseIoLibIntrinsic%2FIoLib.c;h=d0d7044f0901fd95e30a7b2e766d371f437dc1ab;hb=38c8be123aced4cc8ad5c7e0da9121a181b94251;hp=a6bbc925462b2c1c1172d0cc702af4484e442aef;hpb=9c08b3e7d5ac177a1ecb3678004fd94164865814;p=mirror_edk2.git diff --git a/MdePkg/Library/BaseIoLibIntrinsic/IoLib.c b/MdePkg/Library/BaseIoLibIntrinsic/IoLib.c index a6bbc92546..d0d7044f09 100644 --- a/MdePkg/Library/BaseIoLibIntrinsic/IoLib.c +++ b/MdePkg/Library/BaseIoLibIntrinsic/IoLib.c @@ -1,7 +1,7 @@ /** @file Common I/O Library routines. - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -82,10 +82,15 @@ MmioRead8 ( ) { UINT8 Value; + BOOLEAN Flag; - MemoryFence (); - Value = *(volatile UINT8*)Address; - MemoryFence (); + Flag = FilterBeforeMmIoRead (FilterWidth8, Address, &Value); + if (Flag) { + MemoryFence (); + Value = *(volatile UINT8*)Address; + MemoryFence (); + } + FilterAfterMmIoRead (FilterWidth8, Address, &Value); return Value; } @@ -112,9 +117,15 @@ MmioWrite8 ( IN UINT8 Value ) { - MemoryFence (); - *(volatile UINT8*)Address = Value; - MemoryFence (); + BOOLEAN Flag; + + Flag = FilterBeforeMmIoWrite (FilterWidth8, Address, &Value); + if (Flag) { + MemoryFence (); + *(volatile UINT8*)Address = Value; + MemoryFence (); + } + FilterAfterMmIoWrite (FilterWidth8, Address, &Value); return Value; } @@ -141,12 +152,16 @@ MmioRead16 ( ) { UINT16 Value; + BOOLEAN Flag; ASSERT ((Address & 1) == 0); - - MemoryFence (); - Value = *(volatile UINT16*)Address; - MemoryFence (); + Flag = FilterBeforeMmIoRead (FilterWidth16, Address, &Value); + if (Flag) { + MemoryFence (); + Value = *(volatile UINT16*)Address; + MemoryFence (); + } + FilterAfterMmIoRead (FilterWidth16, Address, &Value); return Value; } @@ -174,11 +189,17 @@ MmioWrite16 ( IN UINT16 Value ) { + BOOLEAN Flag; + ASSERT ((Address & 1) == 0); - MemoryFence (); - *(volatile UINT16*)Address = Value; - MemoryFence (); + Flag = FilterBeforeMmIoWrite (FilterWidth16, Address, &Value); + if (Flag) { + MemoryFence (); + *(volatile UINT16*)Address = Value; + MemoryFence (); + } + FilterAfterMmIoWrite (FilterWidth16, Address, &Value); return Value; } @@ -205,12 +226,17 @@ MmioRead32 ( ) { UINT32 Value; + BOOLEAN Flag; ASSERT ((Address & 3) == 0); - MemoryFence (); - Value = *(volatile UINT32*)Address; - MemoryFence (); + Flag = FilterBeforeMmIoRead (FilterWidth32, Address, &Value); + if (Flag) { + MemoryFence (); + Value = *(volatile UINT32*)Address; + MemoryFence (); + } + FilterAfterMmIoRead (FilterWidth32, Address, &Value); return Value; } @@ -238,11 +264,17 @@ MmioWrite32 ( IN UINT32 Value ) { + BOOLEAN Flag; + ASSERT ((Address & 3) == 0); - MemoryFence (); - *(volatile UINT32*)Address = Value; - MemoryFence (); + Flag = FilterBeforeMmIoWrite (FilterWidth32, Address, &Value); + if (Flag) { + MemoryFence (); + *(volatile UINT32*)Address = Value; + MemoryFence (); + } + FilterAfterMmIoWrite (FilterWidth32, Address, &Value); return Value; } @@ -269,12 +301,17 @@ MmioRead64 ( ) { UINT64 Value; + BOOLEAN Flag; ASSERT ((Address & 7) == 0); - MemoryFence (); - Value = *(volatile UINT64*)Address; - MemoryFence (); + Flag = FilterBeforeMmIoRead (FilterWidth64, Address, &Value); + if (Flag) { + MemoryFence (); + Value = *(volatile UINT64*)Address; + MemoryFence (); + } + FilterAfterMmIoRead (FilterWidth64, Address, &Value); return Value; } @@ -300,11 +337,17 @@ MmioWrite64 ( IN UINT64 Value ) { + BOOLEAN Flag; + ASSERT ((Address & 7) == 0); - MemoryFence (); - *(volatile UINT64*)Address = Value; - MemoryFence (); + Flag = FilterBeforeMmIoWrite (FilterWidth64, Address, &Value); + if (Flag) { + MemoryFence (); + *(volatile UINT64*)Address = Value; + MemoryFence (); + } + FilterAfterMmIoWrite (FilterWidth64, Address, &Value); return Value; }