]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseS3IoLib/S3IoLib.c
Add ASSERT() for BitField operations to make sure the input value is valid.
[mirror_edk2.git] / MdePkg / Library / BaseS3IoLib / S3IoLib.c
index 2ff3fff21a883e8a748746da154915daf3836995..017bcbb9cd37c6a287d465f54c917a486e401cd5 100644 (file)
@@ -2,7 +2,7 @@
   I/O and MMIO Library Services that do I/O and also enable the I/O operatation\r
   to be replayed during an S3 resume.\r
   \r
-  Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 -2012, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions\r
@@ -264,6 +264,7 @@ S3IoBitFieldRead8 (
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -302,6 +303,7 @@ S3IoBitFieldWrite8 (
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -340,6 +342,7 @@ S3IoBitFieldOr8 (
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -379,6 +382,8 @@ S3IoBitFieldAnd8 (
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -614,6 +619,7 @@ S3IoBitFieldRead16 (
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -652,6 +658,7 @@ S3IoBitFieldWrite16 (
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -690,6 +697,7 @@ S3IoBitFieldOr16 (
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -730,6 +738,8 @@ S3IoBitFieldAnd16 (
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -965,6 +975,7 @@ S3IoBitFieldRead32 (
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -1003,6 +1014,7 @@ S3IoBitFieldWrite32 (
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -1041,6 +1053,7 @@ S3IoBitFieldOr32 (
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -1081,6 +1094,8 @@ S3IoBitFieldAnd32 (
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -1316,6 +1331,7 @@ S3IoBitFieldRead64 (
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -1354,6 +1370,7 @@ S3IoBitFieldWrite64 (
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -1392,6 +1409,7 @@ S3IoBitFieldOr64 (
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -1432,6 +1450,8 @@ S3IoBitFieldAnd64 (
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Port          The I/O port to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -1697,6 +1717,7 @@ S3MmioBitFieldRead8 (
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -1736,6 +1757,7 @@ S3MmioBitFieldWrite8 (
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -1775,6 +1797,7 @@ S3MmioBitFieldOr8 (
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -1815,6 +1838,8 @@ S3MmioBitFieldAnd8 (
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -2050,6 +2075,7 @@ S3MmioBitFieldRead16 (
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -2089,6 +2115,7 @@ S3MmioBitFieldWrite16 (
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -2128,6 +2155,7 @@ S3MmioBitFieldOr16 (
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -2168,6 +2196,8 @@ S3MmioBitFieldAnd16 (
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -2402,6 +2432,7 @@ S3MmioBitFieldRead32 (
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -2441,6 +2472,7 @@ S3MmioBitFieldWrite32 (
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -2480,6 +2512,7 @@ S3MmioBitFieldOr32 (
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -2520,6 +2553,8 @@ S3MmioBitFieldAnd32 (
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -2754,6 +2789,7 @@ S3MmioBitFieldRead64 (
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -2793,6 +2829,7 @@ S3MmioBitFieldWrite64 (
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -2832,6 +2869,7 @@ S3MmioBitFieldOr64 (
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r
@@ -2872,6 +2910,8 @@ S3MmioBitFieldAnd64 (
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address       The MMIO register to write.\r
   @param  StartBit      The ordinal of the least significant bit in the bit field.\r