]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/BaseLib.h
MdePkg/BaseLib: Add bit field population calculating methods
[mirror_edk2.git] / MdePkg / Include / Library / BaseLib.h
index 1db3a0475d9366f63f749b65f88913857a73297b..123ae19dc263dc98e73174e877b37473b7d28a2a 100644 (file)
@@ -4609,6 +4609,62 @@ BitFieldAndThenOr64 (
   IN      UINT64                    OrData\r
   );\r
 \r
+/**\r
+  Reads a bit field from a 32-bit value, counts and returns\r
+  the number of set bits.\r
+\r
+  Counts the number of set bits in the  bit field specified by\r
+  StartBit and EndBit in Operand. The count is returned.\r
+\r
+  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
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The number of bits set between StartBit and EndBit.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BitFieldCountOnes32 (\r
+  IN       UINT32                   Operand,\r
+  IN       UINTN                    StartBit,\r
+  IN       UINTN                    EndBit\r
+  );\r
+\r
+/**\r
+   Reads a bit field from a 64-bit value, counts and returns\r
+   the number of set bits.\r
+\r
+   Counts the number of set bits in the  bit field specified by\r
+   StartBit and EndBit in Operand. The count is returned.\r
+\r
+   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
+\r
+   @param  Operand   Operand on which to perform the bitfield operation.\r
+   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+   Range 0..63.\r
+   @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+   Range 0..63.\r
+\r
+   @return The number of bits set between StartBit and EndBit.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BitFieldCountOnes64 (\r
+  IN       UINT64                   Operand,\r
+  IN       UINTN                    StartBit,\r
+  IN       UINTN                    EndBit\r
+  );\r
+\r
 //\r
 // Base Library Checksum Functions\r
 //\r