]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PeiIoLibCpuIo/IoLib.c
UefiLib:
[mirror_edk2.git] / MdePkg / Library / PeiIoLibCpuIo / IoLib.c
index 2156f6b480f27de6dbc599c129785d8f70fd5ce9..1da0203b5c936c3d0cb09004448dd640599d917a 100644 (file)
@@ -39,7 +39,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 +71,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 +102,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 +137,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 +171,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 +206,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 +240,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 +275,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 +309,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 +339,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 +370,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 +404,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 +438,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 +472,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 +506,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 +540,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