]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PeiIoLibCpuIo/IoLib.c
Make GuidedSection library instance to follow the value of GuidedSectionExtraction...
[mirror_edk2.git] / MdePkg / Library / PeiIoLibCpuIo / IoLib.c
index 2156f6b480f27de6dbc599c129785d8f70fd5ce9..bc8319eb290ef0cbc0c71e5e21143032912caaa0 100644 (file)
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-  Module Name:  IoLib.c\r
-\r
 **/\r
 \r
+\r
+#include <PiPei.h>\r
+\r
+#include <Library/IoLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+\r
 /**\r
   Reads an 8-bit I/O port.\r
 \r
@@ -39,7 +45,6 @@ IoRead8 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
 \r
   return CpuIo->IoRead8 (PeiServices, CpuIo, (UINT64) Port);\r
@@ -72,7 +77,6 @@ IoWrite8 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
 \r
   CpuIo->IoWrite8 (PeiServices, CpuIo, (UINT64) Port, Value);\r
@@ -104,9 +108,11 @@ IoRead16 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Port is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Port & 1) == 0);\r
   return CpuIo->IoRead16 (PeiServices, CpuIo, (UINT64) Port);\r
 }\r
 \r
@@ -137,9 +143,11 @@ IoWrite16 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Port is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Port & 1) == 0);\r
   CpuIo->IoWrite16 (PeiServices, CpuIo, (UINT64) Port, Value);\r
   return Value;\r
 }\r
@@ -169,9 +177,11 @@ IoRead32 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Port is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Port & 3) == 0);\r
   return CpuIo->IoRead32 (PeiServices, CpuIo, (UINT64) Port);\r
 }\r
 \r
@@ -202,9 +212,11 @@ IoWrite32 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Port is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Port & 3) == 0);\r
   CpuIo->IoWrite32 (PeiServices, CpuIo, (UINT64) Port, Value);\r
   return Value;\r
 }\r
@@ -234,9 +246,11 @@ IoRead64 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Port is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Port & 7) == 0);\r
   return CpuIo->IoRead64 (PeiServices, CpuIo, (UINT64) Port);\r
 }\r
 \r
@@ -267,9 +281,11 @@ IoWrite64 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Port is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Port & 7) == 0);\r
   CpuIo->IoWrite64 (PeiServices, CpuIo, (UINT64) Port, Value);\r
   return Value;;\r
 }\r
@@ -299,7 +315,6 @@ MmioRead8 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
 \r
   return CpuIo->MemRead8 (PeiServices, CpuIo, (UINT64) Address);\r
@@ -330,7 +345,6 @@ MmioWrite8 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
 \r
   CpuIo->MemWrite8 (PeiServices, CpuIo, (UINT64) Address, Value);\r
@@ -362,9 +376,11 @@ MmioRead16 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Address is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Address & 1) == 0);\r
   return CpuIo->MemRead16 (PeiServices, CpuIo, (UINT64) Address);\r
 \r
 }\r
@@ -394,9 +410,11 @@ MmioWrite16 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Address is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Address & 1) == 0);\r
   CpuIo->MemWrite16 (PeiServices, CpuIo, (UINT64) Address, Value);\r
   return Value;\r
 }\r
@@ -426,9 +444,11 @@ MmioRead32 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Address is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Address & 3) == 0);\r
   return CpuIo->MemRead32 (PeiServices, CpuIo, (UINT64) Address);\r
 \r
 }\r
@@ -458,9 +478,11 @@ MmioWrite32 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Address is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Address & 3) == 0);\r
   CpuIo->MemWrite32 (PeiServices, CpuIo, (UINT64) Address, Value);\r
   return Value;\r
 }\r
@@ -490,9 +512,11 @@ MmioRead64 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Address is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Address & 7) == 0);\r
   return CpuIo->MemRead64 (PeiServices, CpuIo, (UINT64) Address);\r
 \r
 }\r
@@ -522,9 +546,11 @@ MmioWrite64 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Address is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Address & 7) == 0);\r
   CpuIo->MemWrite64 (PeiServices, CpuIo, (UINT64) Address, Value);\r
   return Value;\r
 }\r