]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BasePciCf8Lib/PciLib.c
Update the PciXXXReadBuffer() for better coding style.
[mirror_edk2.git] / MdePkg / Library / BasePciCf8Lib / PciLib.c
index bbd1e01d915e7712d6abe21a07cfb76cae3a0c2d..64bd1557fc5d86ca5c0ea47cdd90993c3175c1e7 100644 (file)
 \r
 **/\r
 \r
-//\r
-// The package level header files this module uses\r
-//\r
+\r
 #include <Base.h>\r
-//\r
-// The protocols, PPI and GUID defintions for this module\r
-//\r
-//\r
-// The Library classes this module consumes\r
-//\r
+\r
+#include <Library/BaseLib.h>\r
 #include <Library/PciCf8Lib.h>\r
 #include <Library/IoLib.h>\r
 #include <Library/DebugLib.h>\r
@@ -1307,7 +1301,7 @@ PciCf8ReadBuffer (
   OUT     VOID                      *Buffer\r
   )\r
 {\r
-  UINTN                             ReturnValue;\r
+  UINTN   ReturnValue;\r
 \r
   ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);\r
   ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100);\r
@@ -1337,7 +1331,8 @@ PciCf8ReadBuffer (
     //\r
     // Read a word if StartAddress is word aligned\r
     //\r
-    *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress);\r
+    WriteUnaligned16 ((UINT16 *)Buffer, (UINT16) PciCf8Read16 (StartAddress));\r
+\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1347,7 +1342,7 @@ PciCf8ReadBuffer (
     //\r
     // Read as many double words as possible\r
     //\r
-    *(volatile UINT32 *)Buffer = PciCf8Read32 (StartAddress);\r
+    WriteUnaligned32 ((UINT32 *)Buffer, (UINT32) PciCf8Read32 (StartAddress));\r
     StartAddress += sizeof (UINT32);\r
     Size -= sizeof (UINT32);\r
     Buffer = (UINT32*)Buffer + 1;\r
@@ -1357,7 +1352,7 @@ PciCf8ReadBuffer (
     //\r
     // Read the last remaining word if exist\r
     //\r
-    *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress);\r
+    WriteUnaligned16 ((UINT16 *)Buffer, (UINT16) PciCf8Read16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1406,7 +1401,7 @@ PciCf8WriteBuffer (
   IN      VOID                      *Buffer\r
   )\r
 {\r
-  UINTN                             ReturnValue;\r
+  UINTN   ReturnValue;\r
 \r
   ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);\r
   ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100);\r
@@ -1436,7 +1431,7 @@ PciCf8WriteBuffer (
     //\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
@@ -1446,7 +1441,7 @@ PciCf8WriteBuffer (
     //\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
@@ -1456,7 +1451,7 @@ PciCf8WriteBuffer (
     //\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