]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Unaligned.c
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.
16 // Include common header file for this module.
18 #include <BaseLibInternals.h>
22 Reads a 16-bit value from memory that may be unaligned.
24 This function returns the 16-bit value pointed to by Buffer. The function
25 guarantees that the read operation does not produce an alignment fault.
27 If the Buffer is NULL, then ASSERT().
29 @param Buffer Pointer to a 16-bit value that may be unaligned.
37 IN CONST UINT16
*Buffer
40 ASSERT (Buffer
!= NULL
);
46 Writes a 16-bit value to memory that may be unaligned.
48 This function writes the 16-bit value specified by Value to Buffer. Value is
49 returned. The function guarantees that the write operation does not produce
52 If the Buffer is NULL, then ASSERT().
54 @param Buffer Pointer to a 16-bit value that may be unaligned.
55 @param Value 16-bit value to write to Buffer.
67 ASSERT (Buffer
!= NULL
);
69 return *Buffer
= Value
;
73 Reads a 24-bit value from memory that may be unaligned.
75 This function returns the 24-bit value pointed to by Buffer. The function
76 guarantees that the read operation does not produce an alignment fault.
78 If the Buffer is NULL, then ASSERT().
80 @param Buffer Pointer to a 24-bit value that may be unaligned.
82 @return The value read.
88 IN CONST UINT32
*Buffer
91 ASSERT (Buffer
!= NULL
);
93 return *Buffer
& 0xffffff;
97 Writes a 24-bit value to memory that may be unaligned.
99 This function writes the 24-bit value specified by Value to Buffer. Value is
100 returned. The function guarantees that the write operation does not produce
103 If the Buffer is NULL, then ASSERT().
105 @param Buffer Pointer to a 24-bit value that may be unaligned.
106 @param Value 24-bit value to write to Buffer.
108 @return The value written.
118 ASSERT (Buffer
!= NULL
);
120 *Buffer
= BitFieldWrite32 (*Buffer
, 0, 23, Value
);
125 Reads a 32-bit value from memory that may be unaligned.
127 This function returns the 32-bit value pointed to by Buffer. The function
128 guarantees that the read operation does not produce an alignment fault.
130 If the Buffer is NULL, then ASSERT().
132 @param Buffer Pointer to a 32-bit value that may be unaligned.
140 IN CONST UINT32
*Buffer
143 ASSERT (Buffer
!= NULL
);
149 Writes a 32-bit value to memory that may be unaligned.
151 This function writes the 32-bit value specified by Value to Buffer. Value is
152 returned. The function guarantees that the write operation does not produce
155 If the Buffer is NULL, then ASSERT().
157 @param Buffer Pointer to a 32-bit value that may be unaligned.
158 @param Value 32-bit value to write to Buffer.
170 ASSERT (Buffer
!= NULL
);
172 return *Buffer
= Value
;
176 Reads a 64-bit value from memory that may be unaligned.
178 This function returns the 64-bit value pointed to by Buffer. The function
179 guarantees that the read operation does not produce an alignment fault.
181 If the Buffer is NULL, then ASSERT().
183 @param Buffer Pointer to a 64-bit value that may be unaligned.
191 IN CONST UINT64
*Buffer
194 ASSERT (Buffer
!= NULL
);
200 Writes a 64-bit value to memory that may be unaligned.
202 This function writes the 64-bit value specified by Value to Buffer. Value is
203 returned. The function guarantees that the write operation does not produce
206 If the Buffer is NULL, then ASSERT().
208 @param Buffer Pointer to a 64-bit value that may be unaligned.
209 @param Value 64-bit value to write to Buffer.
221 ASSERT (Buffer
!= NULL
);
223 return *Buffer
= Value
;