]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the unaligned issue of PCI read/write buffer.
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 19 May 2009 07:09:45 +0000 (07:09 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 19 May 2009 07:09:45 +0000 (07:09 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8333 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/PeiPciLibPciCfg2/PciLib.c
MdePkg/Library/PeiPciSegmentLibPciCfg2/PciSegmentLib.c
MdePkg/Library/UefiPciLibPciRootBridgeIo/PciLib.c
MdePkg/Library/UefiPciSegmentLibPciRootBridgeIo/PciSegmentLib.c

index 01306b7b926a1856f9395a2397e5808c0de12c55..65de76046b1021d617bae7431d0a631bf359aef3 100644 (file)
@@ -1272,7 +1272,7 @@ PciReadBuffer (
     //\r
     // Read a word if StartAddress is word aligned\r
     //\r
-    *(volatile UINT16 *)Buffer = PciRead16 (StartAddress);\r
+    WriteUnaligned16 (Buffer, PciRead16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1282,7 +1282,7 @@ PciReadBuffer (
     //\r
     // Read as many double words as possible\r
     //\r
-    *(volatile UINT32 *)Buffer = PciRead32 (StartAddress);\r
+    WriteUnaligned32 (Buffer, PciRead32 (StartAddress));\r
     StartAddress += sizeof (UINT32);\r
     Size -= sizeof (UINT32);\r
     Buffer = (UINT32*)Buffer + 1;\r
@@ -1292,7 +1292,7 @@ PciReadBuffer (
     //\r
     // Read the last remaining word if exist\r
     //\r
-    *(volatile UINT16 *)Buffer = PciRead16 (StartAddress);\r
+    WriteUnaligned16 (Buffer, PciRead16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1370,7 +1370,7 @@ PciWriteBuffer (
     //\r
     // Write a word if StartAddress is word aligned\r
     //\r
-    PciWrite16 (StartAddress, *(UINT16*)Buffer);\r
+    PciWrite16 (StartAddress, ReadUnaligned16 (Buffer));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1380,7 +1380,7 @@ PciWriteBuffer (
     //\r
     // Write as many double words as possible\r
     //\r
-    PciWrite32 (StartAddress, *(UINT32*)Buffer);\r
+    PciWrite32 (StartAddress, ReadUnaligned32 (Buffer));\r
     StartAddress += sizeof (UINT32);\r
     Size -= sizeof (UINT32);\r
     Buffer = (UINT32*)Buffer + 1;\r
@@ -1390,7 +1390,7 @@ PciWriteBuffer (
     //\r
     // Write the last remaining word if exist\r
     //\r
-    PciWrite16 (StartAddress, *(UINT16*)Buffer);\r
+    PciWrite16 (StartAddress, ReadUnaligned16 (Buffer));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
index 332d2a9b45e7eb3d6eabf034806f5d6005e3cc58..a08298aaa24f51f2ee687b11167bcd47e395d03a 100644 (file)
@@ -1259,7 +1259,7 @@ PciSegmentReadBuffer (
     //\r
     // Read a word if StartAddress is word aligned\r
     //\r
-    *(volatile UINT16 *)Buffer = PciSegmentRead16 (StartAddress);\r
+    WriteUnaligned16 (Buffer, PciSegmentRead16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1269,7 +1269,7 @@ PciSegmentReadBuffer (
     //\r
     // Read as many double words as possible\r
     //\r
-    *(volatile UINT32 *)Buffer = PciSegmentRead32 (StartAddress);\r
+    WriteUnaligned32 (Buffer, PciSegmentRead32 (StartAddress));\r
     StartAddress += sizeof (UINT32);\r
     Size -= sizeof (UINT32);\r
     Buffer = (UINT32*)Buffer + 1;\r
@@ -1279,7 +1279,7 @@ PciSegmentReadBuffer (
     //\r
     // Read the last remaining word if exist\r
     //\r
-    *(volatile UINT16 *)Buffer = PciSegmentRead16 (StartAddress);\r
+    WriteUnaligned16 (Buffer, PciSegmentRead16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1358,7 +1358,7 @@ PciSegmentWriteBuffer (
     //\r
     // Write a word if StartAddress is word aligned\r
     //\r
-    PciSegmentWrite16 (StartAddress, *(UINT16*)Buffer);\r
+    PciSegmentWrite16 (StartAddress, ReadUnaligned16 (Buffer));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1368,7 +1368,7 @@ PciSegmentWriteBuffer (
     //\r
     // Write as many double words as possible\r
     //\r
-    PciSegmentWrite32 (StartAddress, *(UINT32*)Buffer);\r
+    PciSegmentWrite32 (StartAddress, ReadUnaligned32 (Buffer));\r
     StartAddress += sizeof (UINT32);\r
     Size -= sizeof (UINT32);\r
     Buffer = (UINT32*)Buffer + 1;\r
@@ -1378,7 +1378,7 @@ PciSegmentWriteBuffer (
     //\r
     // Write the last remaining word if exist\r
     //\r
-    PciSegmentWrite16 (StartAddress, *(UINT16*)Buffer);\r
+    PciSegmentWrite16 (StartAddress, ReadUnaligned16 (Buffer));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
index 1f236753649b09d0b64165f32802ee3472a1d144..913b97cc1af9cc93fea3f7dfe1baae32ee4ddb57 100644 (file)
@@ -1286,7 +1286,7 @@ PciReadBuffer (
     //\r
     // Read a word if StartAddress is word aligned\r
     //\r
-    *(volatile UINT16 *)Buffer = PciRead16 (StartAddress);\r
+    WriteUnaligned16 (Buffer, PciRead16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1296,7 +1296,7 @@ PciReadBuffer (
     //\r
     // Read as many double words as possible\r
     //\r
-    *(volatile UINT32 *)Buffer = PciRead32 (StartAddress);\r
+    WriteUnaligned32 (Buffer, PciRead32 (StartAddress));\r
     StartAddress += sizeof (UINT32);\r
     Size -= sizeof (UINT32);\r
     Buffer = (UINT32*)Buffer + 1;\r
@@ -1306,7 +1306,7 @@ PciReadBuffer (
     //\r
     // Read the last remaining word if exist\r
     //\r
-    *(volatile UINT16 *)Buffer = PciRead16 (StartAddress);\r
+    WriteUnaligned16 (Buffer, PciRead16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1384,7 +1384,7 @@ PciWriteBuffer (
     //\r
     // Write a word if StartAddress is word aligned\r
     //\r
-    PciWrite16 (StartAddress, *(UINT16*)Buffer);\r
+    PciWrite16 (StartAddress, ReadUnaligned16 (Buffer));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1394,7 +1394,7 @@ PciWriteBuffer (
     //\r
     // Write as many double words as possible\r
     //\r
-    PciWrite32 (StartAddress, *(UINT32*)Buffer);\r
+    PciWrite32 (StartAddress, ReadUnaligned32 (Buffer));\r
     StartAddress += sizeof (UINT32);\r
     Size -= sizeof (UINT32);\r
     Buffer = (UINT32*)Buffer + 1;\r
@@ -1404,7 +1404,7 @@ PciWriteBuffer (
     //\r
     // Write the last remaining word if exist\r
     //\r
-    PciWrite16 (StartAddress, *(UINT16*)Buffer);\r
+    PciWrite16 (StartAddress, ReadUnaligned16 (Buffer));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
index 97fd240a0e8658042f8bfad416e72d64785d5d97..da153f994a09b3eec2c936b129dab6c67a524490 100644 (file)
@@ -1338,7 +1338,7 @@ PciSegmentReadBuffer (
     //\r
     // Read a word if StartAddress is word aligned\r
     //\r
-    *(volatile UINT16 *)Buffer = PciSegmentRead16 (StartAddress);\r
+    WriteUnaligned16 (Buffer, PciSegmentRead16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1348,7 +1348,7 @@ PciSegmentReadBuffer (
     //\r
     // Read as many double words as possible\r
     //\r
-    *(volatile UINT32 *)Buffer = PciSegmentRead32 (StartAddress);\r
+    WriteUnaligned32 (Buffer, PciSegmentRead32 (StartAddress));\r
     StartAddress += sizeof (UINT32);\r
     Size -= sizeof (UINT32);\r
     Buffer = (UINT32*)Buffer + 1;\r
@@ -1358,7 +1358,7 @@ PciSegmentReadBuffer (
     //\r
     // Read the last remaining word if exist\r
     //\r
-    *(volatile UINT16 *)Buffer = PciSegmentRead16 (StartAddress);\r
+    WriteUnaligned16 (Buffer, PciSegmentRead16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1436,7 +1436,7 @@ PciSegmentWriteBuffer (
     //\r
     // Write a word if StartAddress is word aligned\r
     //\r
-    PciSegmentWrite16 (StartAddress, *(UINT16*)Buffer);\r
+    PciSegmentWrite16 (StartAddress, ReadUnaligned16 (Buffer));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1446,7 +1446,7 @@ PciSegmentWriteBuffer (
     //\r
     // Write as many double words as possible\r
     //\r
-    PciSegmentWrite32 (StartAddress, *(UINT32*)Buffer);\r
+    PciSegmentWrite32 (StartAddress, ReadUnaligned32 (Buffer));\r
     StartAddress += sizeof (UINT32);\r
     Size -= sizeof (UINT32);\r
     Buffer = (UINT32*)Buffer + 1;\r
@@ -1456,7 +1456,7 @@ PciSegmentWriteBuffer (
     //\r
     // Write the last remaining word if exist\r
     //\r
-    PciSegmentWrite16 (StartAddress, *(UINT16*)Buffer);\r
+    PciSegmentWrite16 (StartAddress, ReadUnaligned16 (Buffer));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r