2 Unaligned access functions of BaseLib.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 Module Name: Unaligned.c
18 Reads a 16-bit value from memory that may be unaligned.
20 This function returns the 16-bit value pointed to by Buffer. The function
21 guarantees that the read operation does not produce an alignment fault.
23 If the Buffer is NULL, then ASSERT().
25 @param Buffer Pointer to a 16-bit value that may be unaligned.
33 IN CONST UINT16
*Buffer
40 Writes a 16-bit value to memory that may be unaligned.
42 This function writes the 16-bit value specified by Value to Buffer. Value is
43 returned. The function guarantees that the write operation does not produce
46 If the Buffer is NULL, then ASSERT().
48 @param Buffer Pointer to a 16-bit value that may be unaligned.
49 @param Value 16-bit value to write to Buffer.
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 Pointer to a 24-bit value that may be unaligned.
74 @return The value read.
80 IN CONST UINT32
*Buffer
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 Pointer to a 24-bit value that may be unaligned.
96 @param Value 24-bit value to write to Buffer.
98 @return The value written.
108 return *Buffer
= BitFieldWrite32 (*Buffer
, 0, 23, Value
);
112 Reads a 32-bit value from memory that may be unaligned.
114 This function returns the 32-bit value pointed to by Buffer. The function
115 guarantees that the read operation does not produce an alignment fault.
117 If the Buffer is NULL, then ASSERT().
119 @param Buffer Pointer to a 32-bit value that may be unaligned.
127 IN CONST UINT32
*Buffer
134 Writes a 32-bit value to memory that may be unaligned.
136 This function writes the 32-bit value specified by Value to Buffer. Value is
137 returned. The function guarantees that the write operation does not produce
140 If the Buffer is NULL, then ASSERT().
142 @param Buffer Pointer to a 32-bit value that may be unaligned.
143 @param Value 32-bit value to write to Buffer.
155 return *Buffer
= Value
;
159 Reads a 64-bit value from memory that may be unaligned.
161 This function returns the 64-bit value pointed to by Buffer. The function
162 guarantees that the read operation does not produce an alignment fault.
164 If the Buffer is NULL, then ASSERT().
166 @param Buffer Pointer to a 64-bit value that may be unaligned.
174 IN CONST UINT64
*Buffer
181 Writes a 64-bit value to memory that may be unaligned.
183 This function writes the 64-bit value specified by Value to Buffer. Value is
184 returned. The function guarantees that the write operation does not produce
187 If the Buffer is NULL, then ASSERT().
189 @param Buffer Pointer to a 64-bit value that may be unaligned.
190 @param Value 64-bit value to write to Buffer.
202 return *Buffer
= Value
;