]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Unaligned.c
935e1693002660de31e464892f99a07650dbccc4
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 // Include common header file for this module.
20 #include <BaseLibInternals.h>
24 Reads a 16-bit value from memory that may be unaligned.
26 This function returns the 16-bit value pointed to by Buffer. The function
27 guarantees that the read operation does not produce an alignment fault.
29 If the Buffer is NULL, then ASSERT().
31 @param Buffer Pointer to a 16-bit value that may be unaligned.
39 IN CONST UINT16
*Buffer
42 ASSERT (Buffer
!= NULL
);
48 Writes a 16-bit value to memory that may be unaligned.
50 This function writes the 16-bit value specified by Value to Buffer. Value is
51 returned. The function guarantees that the write operation does not produce
54 If the Buffer is NULL, then ASSERT().
56 @param Buffer Pointer to a 16-bit value that may be unaligned.
57 @param Value 16-bit value to write to Buffer.
69 ASSERT (Buffer
!= NULL
);
71 return *Buffer
= Value
;
75 Reads a 24-bit value from memory that may be unaligned.
77 This function returns the 24-bit value pointed to by Buffer. The function
78 guarantees that the read operation does not produce an alignment fault.
80 If the Buffer is NULL, then ASSERT().
82 @param Buffer Pointer to a 24-bit value that may be unaligned.
84 @return The value read.
90 IN CONST UINT32
*Buffer
93 ASSERT (Buffer
!= NULL
);
95 return *Buffer
& 0xffffff;
99 Writes a 24-bit value to memory that may be unaligned.
101 This function writes the 24-bit value specified by Value to Buffer. Value is
102 returned. The function guarantees that the write operation does not produce
105 If the Buffer is NULL, then ASSERT().
107 @param Buffer Pointer to a 24-bit value that may be unaligned.
108 @param Value 24-bit value to write to Buffer.
110 @return The value written.
120 ASSERT (Buffer
!= NULL
);
122 *Buffer
= BitFieldWrite32 (*Buffer
, 0, 23, Value
);
127 Reads a 32-bit value from memory that may be unaligned.
129 This function returns the 32-bit value pointed to by Buffer. The function
130 guarantees that the read operation does not produce an alignment fault.
132 If the Buffer is NULL, then ASSERT().
134 @param Buffer Pointer to a 32-bit value that may be unaligned.
142 IN CONST UINT32
*Buffer
145 ASSERT (Buffer
!= NULL
);
151 Writes a 32-bit value to memory that may be unaligned.
153 This function writes the 32-bit value specified by Value to Buffer. Value is
154 returned. The function guarantees that the write operation does not produce
157 If the Buffer is NULL, then ASSERT().
159 @param Buffer Pointer to a 32-bit value that may be unaligned.
160 @param Value 32-bit value to write to Buffer.
172 ASSERT (Buffer
!= NULL
);
174 return *Buffer
= Value
;
178 Reads a 64-bit value from memory that may be unaligned.
180 This function returns the 64-bit value pointed to by Buffer. The function
181 guarantees that the read operation does not produce an alignment fault.
183 If the Buffer is NULL, then ASSERT().
185 @param Buffer Pointer to a 64-bit value that may be unaligned.
193 IN CONST UINT64
*Buffer
196 ASSERT (Buffer
!= NULL
);
202 Writes a 64-bit value to memory that may be unaligned.
204 This function writes the 64-bit value specified by Value to Buffer. Value is
205 returned. The function guarantees that the write operation does not produce
208 If the Buffer is NULL, then ASSERT().
210 @param Buffer Pointer to a 64-bit value that may be unaligned.
211 @param Value 64-bit value to write to Buffer.
223 ASSERT (Buffer
!= NULL
);
225 return *Buffer
= Value
;