]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Unaligned.c
2 Unaligned access functions of BaseLib.
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "BaseLibInternals.h"
12 Reads a 16-bit value from memory that may be unaligned.
14 This function returns the 16-bit value pointed to by Buffer. The function
15 guarantees that the read operation does not produce an alignment fault.
17 If the Buffer is NULL, then ASSERT().
19 @param Buffer A pointer to a 16-bit value that may be unaligned.
21 @return The 16-bit value read from Buffer.
27 IN CONST UINT16
*Buffer
30 ASSERT (Buffer
!= NULL
);
36 Writes a 16-bit value to memory that may be unaligned.
38 This function writes the 16-bit value specified by Value to Buffer. Value is
39 returned. The function guarantees that the write operation does not produce
42 If the Buffer is NULL, then ASSERT().
44 @param Buffer A pointer to a 16-bit value that may be unaligned.
45 @param Value 16-bit value to write to Buffer.
47 @return The 16-bit value to write to Buffer.
57 ASSERT (Buffer
!= NULL
);
59 return *Buffer
= Value
;
63 Reads a 24-bit value from memory that may be unaligned.
65 This function returns the 24-bit value pointed to by Buffer. The function
66 guarantees that the read operation does not produce an alignment fault.
68 If the Buffer is NULL, then ASSERT().
70 @param Buffer A pointer to a 24-bit value that may be unaligned.
72 @return The 24-bit value read from Buffer.
78 IN CONST UINT32
*Buffer
81 ASSERT (Buffer
!= NULL
);
83 return *Buffer
& 0xffffff;
87 Writes a 24-bit value to memory that may be unaligned.
89 This function writes the 24-bit value specified by Value to Buffer. Value is
90 returned. The function guarantees that the write operation does not produce
93 If the Buffer is NULL, then ASSERT().
95 @param Buffer A pointer to a 24-bit value that may be unaligned.
96 @param Value 24-bit value to write to Buffer.
98 @return The 24-bit value to write to Buffer.
108 ASSERT (Buffer
!= NULL
);
110 *Buffer
= BitFieldWrite32 (*Buffer
, 0, 23, Value
);
115 Reads a 32-bit value from memory that may be unaligned.
117 This function returns the 32-bit value pointed to by Buffer. The function
118 guarantees that the read operation does not produce an alignment fault.
120 If the Buffer is NULL, then ASSERT().
122 @param Buffer A pointer to a 32-bit value that may be unaligned.
124 @return The 32-bit value read from Buffer.
130 IN CONST UINT32
*Buffer
133 ASSERT (Buffer
!= NULL
);
139 Writes a 32-bit value to memory that may be unaligned.
141 This function writes the 32-bit value specified by Value to Buffer. Value is
142 returned. The function guarantees that the write operation does not produce
145 If the Buffer is NULL, then ASSERT().
147 @param Buffer A pointer to a 32-bit value that may be unaligned.
148 @param Value The 32-bit value to write to Buffer.
150 @return The 32-bit value to write to Buffer.
160 ASSERT (Buffer
!= NULL
);
162 return *Buffer
= Value
;
166 Reads a 64-bit value from memory that may be unaligned.
168 This function returns the 64-bit value pointed to by Buffer. The function
169 guarantees that the read operation does not produce an alignment fault.
171 If the Buffer is NULL, then ASSERT().
173 @param Buffer A pointer to a 64-bit value that may be unaligned.
175 @return The 64-bit value read from Buffer.
181 IN CONST UINT64
*Buffer
184 ASSERT (Buffer
!= NULL
);
190 Writes a 64-bit value to memory that may be unaligned.
192 This function writes the 64-bit value specified by Value to Buffer. Value is
193 returned. The function guarantees that the write operation does not produce
196 If the Buffer is NULL, then ASSERT().
198 @param Buffer A pointer to a 64-bit value that may be unaligned.
199 @param Value The 64-bit value to write to Buffer.
201 @return The 64-bit value to write to Buffer.
211 ASSERT (Buffer
!= NULL
);
213 return *Buffer
= Value
;