]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
2 | Bit field functions of BaseLib.\r | |
3 | \r | |
499ceb8e | 4 | Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r |
bb817c56 | 5 | This program and the accompanying materials\r |
e1f414b6 | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
127010dd | 8 | http://opensource.org/licenses/bsd-license.php.\r |
e1f414b6 | 9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
e1f414b6 | 13 | **/\r |
14 | \r | |
e1f414b6 | 15 | #include "BaseLibInternals.h"\r |
16 | \r | |
17 | /**\r | |
2fc60b70 | 18 | Worker function that returns a bit field from Operand.\r |
e1f414b6 | 19 | \r |
20 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
21 | \r | |
22 | @param Operand Operand on which to perform the bitfield operation.\r | |
23 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
24 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
25 | \r | |
26 | @return The bit field read.\r | |
27 | \r | |
28 | **/\r | |
28ca72bc | 29 | UINTN\r |
38bbd3d9 | 30 | EFIAPI\r |
80151e53 | 31 | InternalBaseLibBitFieldReadUint (\r |
28ca72bc | 32 | IN UINTN Operand,\r |
e1f414b6 | 33 | IN UINTN StartBit,\r |
34 | IN UINTN EndBit\r | |
35 | )\r | |
36 | {\r | |
37 | //\r | |
28ca72bc | 38 | // ~((UINTN)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]\r |
e1f414b6 | 39 | // are 1's while bit[EndBit + 1] thru the most significant bit are 0's.\r |
40 | //\r | |
28ca72bc | 41 | return (Operand & ~((UINTN)-2 << EndBit)) >> StartBit;\r |
e1f414b6 | 42 | }\r |
43 | \r | |
44 | /**\r | |
2fc60b70 | 45 | Worker function that reads a bit field from Operand, performs a bitwise OR,\r |
e1f414b6 | 46 | and returns the result.\r |
47 | \r | |
48 | Performs a bitwise OR between the bit field specified by StartBit and EndBit\r | |
49 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
50 | preserved. The new value is returned.\r | |
51 | \r | |
94952554 LG |
52 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
53 | \r | |
e1f414b6 | 54 | @param Operand Operand on which to perform the bitfield operation.\r |
55 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
56 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
127010dd | 57 | @param OrData The value to OR with the read value from the value.\r |
e1f414b6 | 58 | \r |
59 | @return The new value.\r | |
60 | \r | |
61 | **/\r | |
28ca72bc | 62 | UINTN\r |
38bbd3d9 | 63 | EFIAPI\r |
80151e53 | 64 | InternalBaseLibBitFieldOrUint (\r |
28ca72bc | 65 | IN UINTN Operand,\r |
e1f414b6 | 66 | IN UINTN StartBit,\r |
67 | IN UINTN EndBit,\r | |
28ca72bc | 68 | IN UINTN OrData\r |
e1f414b6 | 69 | )\r |
70 | {\r | |
94952554 LG |
71 | //\r |
72 | // Higher bits in OrData those are not used must be zero. \r | |
73 | //\r | |
499ceb8e LG |
74 |