]>
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
10 #include "BaseLibInternals.h"
14 Reads a 16-bit value from memory that may be unaligned.
16 This function returns the 16-bit value pointed to by Buffer. The function
17 guarantees that the read operation does not produce an alignment fault.
19 If the Buffer is NULL, then ASSERT().
21 @param Buffer A pointer to a 16-bit value that may be unaligned.
23 @return The 16-bit value read from Buffer.
29 IN CONST UINT16
*Buffer
32 ASSERT (Buffer
!= NULL
);
38 Writes a 16-bit value to memory that may be unaligned.
40 This function writes the 16-bit value specified by Value to Buffer. Value is
41 returned. The function guarantees that the write operation does not produce
44 If the Buffer is NULL, then ASSERT().
46 @param Buffer A pointer to a 16-bit value that may be unaligned.
47 @param Value 16-bit value to write to Buffer.
49 @return The 16-bit value to write to Buffer.
59 ASSERT (Buffer
!= NULL
);
61 return *Buffer
= Value
;
65 Reads a 24-bit value from memory that may be unaligned.
67 This function returns the 24-bit value pointed to by Buffer. The function
68 guarantees that the read operation does not produce an alignment fault.
70 If the Buffer is NULL, then ASSERT().
72 @param Buffer A pointer to a 24-bit value that may be unaligned.
74 @return The 24-bit value read from Buffer.
80 IN CONST UINT32
*Buffer
83 ASSERT (Buffer
!= NULL
);
85 return *Buffer
& 0xffffff;
89 Writes a 24-bit value to memory that may be unaligned.
91 This function writes the 24-bit value specified by Value to Buffer. Value is
92 returned. The function guarantees that the write operation does not produce
95 If the Buffer is NULL, then ASSERT().
97 @param Buffer A pointer to a 24-bit value that may be unaligned.
98 @param Value 24-bit value to write to Buffer.
100 @return The 24-bit value to write to Buffer.
110 ASSERT (Buffer
!= NULL
);
112 *Buffer
= BitFieldWrite32 (*Buffer
, 0, 23, Value
);
117 Reads a 32-bit value from memory that may be unaligned.
119 This function returns the 32-bit value pointed to by Buffer. The function
120 guarantees that the read operation does not produce an alignment fault.
122 If the Buffer is NULL, then ASSERT().
124 @param Buffer A pointer to a 32-bit value that may be unaligned.
126 @return The 32-bit value read from Buffer.
132 IN CONST UINT32
*Buffer
135 ASSERT (Buffer
!= NULL
);
141 Writes a 32-bit value to memory that may be unaligned.
143 This function writes the 32-bit value specified by Value to Buffer. Value is
144 returned. The function guarantees that the write operation does not produce
147 If the Buffer is NULL, then ASSERT().
149 @param Buffer A pointer to a 32-bit value that may be unaligned.
150 @param Value The 32-bit value to write to Buffer.
152 @return The 32-bit value to write to Buffer.
162 ASSERT (Buffer
!= NULL
);
164 return *Buffer
= Value
;
168 Reads a 64-bit value from memory that may be unaligned.
170 This function returns the 64-bit value pointed to by Buffer. The function
171 guarantees that the read operation does not produce an alignment fault.
173 If the Buffer is NULL, then ASSERT().
175 @param Buffer A pointer to a 64-bit value that may be unaligned.
177 @return The 64-bit value read from Buffer.
183 IN CONST UINT64
*Buffer
186 ASSERT (Buffer
!= NULL
);
192 Writes a 64-bit value to memory that may be unaligned.
194 This function writes the 64-bit value specified by Value to Buffer. Value is
195 returned. The function guarantees that the write operation does not produce
198 If the Buffer is NULL, then ASSERT().
200 @param Buffer A pointer to a 64-bit value that may be unaligned.
201 @param Value The 64-bit value to write to Buffer.
203 @return The 64-bit value to write to Buffer.
213 ASSERT (Buffer
!= NULL
);
215 return *Buffer
= Value
;