git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4447
6f19259b-4bc3-4df7-8a09-
765794883524
\r
#include <Base.h>\r
\r
\r
#include <Base.h>\r
\r
+#include <Library/BaseLib.h>\r
#include <Library/PciCf8Lib.h>\r
#include <Library/IoLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/PciCf8Lib.h>\r
#include <Library/IoLib.h>\r
#include <Library/DebugLib.h>\r
OUT VOID *Buffer\r
)\r
{\r
OUT VOID *Buffer\r
)\r
{\r
+ UINTN ReturnValue;\r
+ UINTN Value;\r
\r
ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);\r
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100);\r
\r
ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);\r
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100);\r
//\r
// Read a word if StartAddress is word aligned\r
//\r
//\r
// Read a word if StartAddress is word aligned\r
//\r
- *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress);\r
+ Value = (UINTN) PciCf8Read16 (StartAddress);\r
+ WriteUnaligned16 ((UINT16 *)Buffer, (UINT16) Value);\r
+\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
//\r
// Read as many double words as possible\r
//\r
//\r
// Read as many double words as possible\r
//\r
- *(volatile UINT32 *)Buffer = PciCf8Read32 (StartAddress);\r
+ Value = (UINTN) PciCf8Read32 (StartAddress);\r
+ WriteUnaligned32 ((UINT32 *)Buffer, (UINT32) Value);\r
StartAddress += sizeof (UINT32);\r
Size -= sizeof (UINT32);\r
Buffer = (UINT32*)Buffer + 1;\r
StartAddress += sizeof (UINT32);\r
Size -= sizeof (UINT32);\r
Buffer = (UINT32*)Buffer + 1;\r
//\r
// Read the last remaining word if exist\r
//\r
//\r
// Read the last remaining word if exist\r
//\r
- *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress);\r
+ Value = (UINTN) PciCf8Read16 (StartAddress);\r
+ WriteUnaligned16 ((UINT16 *)Buffer, (UINT16) Value);\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
IN VOID *Buffer\r
)\r
{\r
IN VOID *Buffer\r
)\r
{\r
\r
ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);\r
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100);\r
\r
ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);\r
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100);\r
//\r
// Write a word if StartAddress is word aligned\r
//\r
//\r
// Write a word if StartAddress is word aligned\r
//\r
- PciCf8Write16 (StartAddress, *(UINT16*)Buffer);\r
+ PciCf8Write16 (StartAddress, ReadUnaligned16 ((UINT16*)Buffer));\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
//\r
// Write as many double words as possible\r
//\r
//\r
// Write as many double words as possible\r
//\r
- PciCf8Write32 (StartAddress, *(UINT32*)Buffer);\r
+ PciCf8Write32 (StartAddress, ReadUnaligned32 ((UINT32*)Buffer));\r
StartAddress += sizeof (UINT32);\r
Size -= sizeof (UINT32);\r
Buffer = (UINT32*)Buffer + 1;\r
StartAddress += sizeof (UINT32);\r
Size -= sizeof (UINT32);\r
Buffer = (UINT32*)Buffer + 1;\r
//\r
// Write the last remaining word if exist\r
//\r
//\r
// Write the last remaining word if exist\r
//\r
- PciCf8Write16 (StartAddress, *(UINT16*)Buffer);\r
+ PciCf8Write16 (StartAddress, ReadUnaligned16 ((UINT16*)Buffer));\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
\r
#include <Base.h>\r
\r
\r
#include <Base.h>\r
\r
+#include <Library/BaseLib.h>\r
#include <Library/PciExpressLib.h>\r
#include <Library/IoLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/PciExpressLib.h>\r
#include <Library/IoLib.h>\r
#include <Library/DebugLib.h>\r
OUT VOID *Buffer\r
)\r
{\r
OUT VOID *Buffer\r
)\r
{\r
+ UINTN ReturnValue;\r
+ UINTN Value;\r
\r
ASSERT_INVALID_PCI_ADDRESS (StartAddress);\r
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
\r
ASSERT_INVALID_PCI_ADDRESS (StartAddress);\r
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
//\r
// Read a word if StartAddress is word aligned\r
//\r
//\r
// Read a word if StartAddress is word aligned\r
//\r
- *(volatile UINT16 *)Buffer = PciExpressRead16 (StartAddress);\r
+ Value = (UINTN) PciExpressRead16 (StartAddress);\r
+ WriteUnaligned16 ((UINT16 *) Buffer, (UINT16) Value);\r
+\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
//\r
// Read as many double words as possible\r
//\r
//\r
// Read as many double words as possible\r
//\r
- *(volatile UINT32 *)Buffer = PciExpressRead32 (StartAddress);\r
+ Value = (UINTN) PciExpressRead32 (StartAddress);\r
+ WriteUnaligned32 ((UINT32 *) Buffer, (UINT32) Value);\r
+\r
StartAddress += sizeof (UINT32);\r
Size -= sizeof (UINT32);\r
Buffer = (UINT32*)Buffer + 1;\r
StartAddress += sizeof (UINT32);\r
Size -= sizeof (UINT32);\r
Buffer = (UINT32*)Buffer + 1;\r
//\r
// Read the last remaining word if exist\r
//\r
//\r
// Read the last remaining word if exist\r
//\r
- *(volatile UINT16 *)Buffer = PciExpressRead16 (StartAddress);\r
+ Value = (UINTN) PciExpressRead16 (StartAddress);\r
+ WriteUnaligned16 ((UINT16 *) Buffer, (UINT16) Value);\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
//\r
// Write a word if StartAddress is word aligned\r
//\r
//\r
// Write a word if StartAddress is word aligned\r
//\r
- PciExpressWrite16 (StartAddress, *(UINT16*)Buffer);\r
+ PciExpressWrite16 (StartAddress, ReadUnaligned16 ((UINT16*)Buffer));\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
//\r
// Write as many double words as possible\r
//\r
//\r
// Write as many double words as possible\r
//\r
- PciExpressWrite32 (StartAddress, *(UINT32*)Buffer);\r
+ PciExpressWrite32 (StartAddress, ReadUnaligned32 ((UINT32*)Buffer));\r
StartAddress += sizeof (UINT32);\r
Size -= sizeof (UINT32);\r
Buffer = (UINT32*)Buffer + 1;\r
StartAddress += sizeof (UINT32);\r
Size -= sizeof (UINT32);\r
Buffer = (UINT32*)Buffer + 1;\r
//\r
// Write the last remaining word if exist\r
//\r
//\r
// Write the last remaining word if exist\r
//\r
- PciExpressWrite16 (StartAddress, *(UINT16*)Buffer);\r
+ PciExpressWrite16 (StartAddress, ReadUnaligned16 ((UINT16*)Buffer));\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r
StartAddress += sizeof (UINT16);\r
Size -= sizeof (UINT16);\r
Buffer = (UINT16*)Buffer + 1;\r