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
\r
PeiServices = GetPeiServicesTablePointer ();\r
CpuIo = (*PeiServices)->CpuIo;\r
-\r
ASSERT (CpuIo != NULL);\r
\r
return CpuIo->IoRead8 (PeiServices, CpuIo, (UINT64) Port);\r
\r
PeiServices = GetPeiServicesTablePointer ();\r
CpuIo = (*PeiServices)->CpuIo;\r
-\r
ASSERT (CpuIo != NULL);\r
\r
CpuIo->IoWrite8 (PeiServices, CpuIo, (UINT64) Port, Value);\r
\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
\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
\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
\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
\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
\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
\r
PeiServices = GetPeiServicesTablePointer ();\r
CpuIo = (*PeiServices)->CpuIo;\r
-\r
ASSERT (CpuIo != NULL);\r
\r
return CpuIo->MemRead8 (PeiServices, CpuIo, (UINT64) Address);\r
\r
PeiServices = GetPeiServicesTablePointer ();\r
CpuIo = (*PeiServices)->CpuIo;\r
-\r
ASSERT (CpuIo != NULL);\r
\r
CpuIo->MemWrite8 (PeiServices, CpuIo, (UINT64) Address, Value);\r
\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
\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
\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
\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
\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
\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