X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FBasePciCf8Lib%2FPciLib.c;h=64bd1557fc5d86ca5c0ea47cdd90993c3175c1e7;hp=272d641ff32af609ab574073f951a8a0ae23b643;hb=af2bb549adeefd4e4ae266b8574270218dd5da7c;hpb=2ce311322c72857f73138c45358e722607a1e80c diff --git a/MdePkg/Library/BasePciCf8Lib/PciLib.c b/MdePkg/Library/BasePciCf8Lib/PciLib.c index 272d641ff3..64bd1557fc 100644 --- a/MdePkg/Library/BasePciCf8Lib/PciLib.c +++ b/MdePkg/Library/BasePciCf8Lib/PciLib.c @@ -10,10 +10,16 @@ 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: PciLib.c - **/ + +#include + +#include +#include +#include +#include + // // Declare I/O Ports used to perform PCI Confguration Cycles // @@ -1295,7 +1301,7 @@ PciCf8ReadBuffer ( OUT VOID *Buffer ) { - UINTN ReturnValue; + UINTN ReturnValue; ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0); ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100); @@ -1325,7 +1331,8 @@ PciCf8ReadBuffer ( // // Read a word if StartAddress is word aligned // - *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress); + WriteUnaligned16 ((UINT16 *)Buffer, (UINT16) PciCf8Read16 (StartAddress)); + StartAddress += sizeof (UINT16); Size -= sizeof (UINT16); Buffer = (UINT16*)Buffer + 1; @@ -1335,7 +1342,7 @@ PciCf8ReadBuffer ( // // Read as many double words as possible // - *(volatile UINT32 *)Buffer = PciCf8Read32 (StartAddress); + WriteUnaligned32 ((UINT32 *)Buffer, (UINT32) PciCf8Read32 (StartAddress)); StartAddress += sizeof (UINT32); Size -= sizeof (UINT32); Buffer = (UINT32*)Buffer + 1; @@ -1345,7 +1352,7 @@ PciCf8ReadBuffer ( // // Read the last remaining word if exist // - *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress); + WriteUnaligned16 ((UINT16 *)Buffer, (UINT16) PciCf8Read16 (StartAddress)); StartAddress += sizeof (UINT16); Size -= sizeof (UINT16); Buffer = (UINT16*)Buffer + 1; @@ -1394,7 +1401,7 @@ PciCf8WriteBuffer ( IN VOID *Buffer ) { - UINTN ReturnValue; + UINTN ReturnValue; ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0); ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100); @@ -1424,7 +1431,7 @@ PciCf8WriteBuffer ( // // Write a word if StartAddress is word aligned // - PciCf8Write16 (StartAddress, *(UINT16*)Buffer); + PciCf8Write16 (StartAddress, ReadUnaligned16 ((UINT16*)Buffer)); StartAddress += sizeof (UINT16); Size -= sizeof (UINT16); Buffer = (UINT16*)Buffer + 1; @@ -1434,7 +1441,7 @@ PciCf8WriteBuffer ( // // Write as many double words as possible // - PciCf8Write32 (StartAddress, *(UINT32*)Buffer); + PciCf8Write32 (StartAddress, ReadUnaligned32 ((UINT32*)Buffer)); StartAddress += sizeof (UINT32); Size -= sizeof (UINT32); Buffer = (UINT32*)Buffer + 1; @@ -1444,7 +1451,7 @@ PciCf8WriteBuffer ( // // Write the last remaining word if exist // - PciCf8Write16 (StartAddress, *(UINT16*)Buffer); + PciCf8Write16 (StartAddress, ReadUnaligned16 ((UINT16*)Buffer)); StartAddress += sizeof (UINT16); Size -= sizeof (UINT16); Buffer = (UINT16*)Buffer + 1;