]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Unaligned.c
2 Unaligned access functions of BaseLib.
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
5 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 "BaseLibInternals.h"
20 Reads a 16-bit value from memory that may be unaligned.
22 This function returns the 16-bit value pointed to by Buffer. The function
23 guarantees that the read operation does not produce an alignment fault.
25 If the Buffer is NULL, then ASSERT().
27 @param Buffer Pointer to a 16-bit value that may be unaligned.
29 @return The 16-bit value read from Buffer.
35 IN CONST UINT16
*Buffer
38 ASSERT (Buffer
!= NULL
);
44 Writes a 16-bit value to memory that may be unaligned.
46 This function writes the 16-bit value specified by Value to Buffer. Value is
47 returned. The function guarantees that the write operation does not produce
50 If the Buffer is NULL, then ASSERT().
52 @param Buffer Pointer to a 16-bit value that may be unaligned.
53 @param Value 16-bit value to write to Buffer.
55 @return The 16-bit value to write to Buffer.
65 ASSERT (Buffer
!= NULL
);
67 return *Buffer
= Value
;
71 Reads a 24-bit value from memory that may be unaligned.
73 This function returns the 24-bit value pointed to by Buffer. The function
74 guarantees that the read operation does not produce an alignment fault.
76 If the Buffer is NULL, then ASSERT().
78 @param Buffer Pointer to a 24-bit value that may be unaligned.
80 @return The 24-bit value read from Buffer.
86 IN CONST UINT32
*Buffer
89 ASSERT (Buffer
!= NULL
);
91 return *Buffer
& 0xffffff;
95 Writes a 24-bit value to memory that may be unaligned.
97 This function writes the 24-bit value specified by Value to Buffer. Value is
98 returned. The function guarantees that the write operation does not produce
101 If the Buffer is NULL, then ASSERT().
103 @param Buffer Pointer to a 24-bit value that may be unaligned.
104 @param Value 24-bit value to write to Buffer.
106 @return The 24-bit value to write to Buffer.
116 ASSERT (Buffer
!= NULL
);
118 *Buffer
= BitFieldWrite32 (*Buffer
, 0, 23, Value
);
123 Reads a 32-bit value from memory that may be unaligned.
125 This function returns the 32-bit value pointed to by Buffer. The function
126 guarantees that the read operation does not produce an alignment fault.
128 If the Buffer is NULL, then ASSERT().
130 @param Buffer Pointer to a 32-bit value that may be unaligned.
132 @return The 32-bit value read from Buffer.
138 IN CONST UINT32
*Buffer
141 ASSERT (Buffer
!= NULL
);
147 Writes a 32-bit value to memory that may be unaligned.
149 This function writes the 32-bit value specified by Value to Buffer. Value is
150 returned. The function guarantees that the write operation does not produce
153 If the Buffer is NULL, then ASSERT().
155 @param Buffer Pointer to a 32-bit value that may be unaligned.
156 @param Value 32-bit value to write to Buffer.
158 @return The 32-bit value to write to Buffer.
168 ASSERT (Buffer
!= NULL
);
170 return *Buffer
= Value
;
174 Reads a 64-bit value from memory that may be unaligned.
176 This function returns the 64-bit value pointed to by Buffer. The function
177 guarantees that the read operation does not produce an alignment fault.
179 If the Buffer is NULL, then ASSERT().
181 @param Buffer Pointer to a 64-bit value that may be unaligned.
183 @return The 64-bit value read from Buffer.
189 IN CONST UINT64
*Buffer
192 ASSERT (Buffer
!= NULL
);
198 Writes a 64-bit value to memory that may be unaligned.
200 This function writes the 64-bit value specified by Value to Buffer. Value is
201 returned. The function guarantees that the write operation does not produce
204 If the Buffer is NULL, then ASSERT().
206 @param Buffer Pointer to a 64-bit value that may be unaligned.
207 @param Value 64-bit value to write to Buffer.
209 @return The 64-bit value to write to Buffer.
219 ASSERT (Buffer
!= NULL
);
221 return *Buffer
= Value
;