]>
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.
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
36 ASSERT (Buffer
!= NULL
);
42 Writes a 16-bit value to memory that may be unaligned.
44 This function writes the 16-bit value specified by Value to Buffer. Value is
45 returned. The function guarantees that the write operation does not produce
48 If the Buffer is NULL, then ASSERT().
50 @param Buffer Pointer to a 16-bit value that may be unaligned.
51 @param Value 16-bit value to write to Buffer.
63 ASSERT (Buffer
!= NULL
);
65 return *Buffer
= Value
;
69 Reads a 24-bit value from memory that may be unaligned.
71 This function returns the 24-bit value pointed to by Buffer. The function
72 guarantees that the read operation does not produce an alignment fault.
74 If the Buffer is NULL, then ASSERT().
76 @param Buffer Pointer to a 24-bit value that may be unaligned.
78 @return The value read.
84 IN CONST UINT32
*Buffer
87 ASSERT (Buffer
!= NULL
);
89 return *Buffer
& 0xffffff;
93 Writes a 24-bit value to memory that may be unaligned.
95 This function writes the 24-bit value specified by Value to Buffer. Value is
96 returned. The function guarantees that the write operation does not produce
99 If the Buffer is NULL, then ASSERT().
101 @param Buffer Pointer to a 24-bit value that may be unaligned.
102 @param Value 24-bit value to write to Buffer.
104 @return The value written.
114 ASSERT (Buffer
!= NULL
);
116 *Buffer
= BitFieldWrite32 (*Buffer
, 0, 23, Value
);
121 Reads a 32-bit value from memory that may be unaligned.
123 This function returns the 32-bit value pointed to by Buffer. The function
124 guarantees that the read operation does not produce an alignment fault.
126 If the Buffer is NULL, then ASSERT().
128 @param Buffer Pointer to a 32-bit value that may be unaligned.
136 IN CONST UINT32
*Buffer
139 ASSERT (Buffer
!= NULL
);
145 Writes a 32-bit value to memory that may be unaligned.
147 This function writes the 32-bit value specified by Value to Buffer. Value is
148 returned. The function guarantees that the write operation does not produce
151 If the Buffer is NULL, then ASSERT().
153 @param Buffer Pointer to a 32-bit value that may be unaligned.
154 @param Value 32-bit value to write to Buffer.
166 ASSERT (Buffer
!= NULL
);
168 return *Buffer
= Value
;
172 Reads a 64-bit value from memory that may be unaligned.
174 This function returns the 64-bit value pointed to by Buffer. The function
175 guarantees that the read operation does not produce an alignment fault.
177 If the Buffer is NULL, then ASSERT().
179 @param Buffer Pointer to a 64-bit value that may be unaligned.
187 IN CONST UINT64
*Buffer
190 ASSERT (Buffer
!= NULL
);
196 Writes a 64-bit value to memory that may be unaligned.
198 This function writes the 64-bit value specified by Value to Buffer. Value is
199 returned. The function guarantees that the write operation does not produce
202 If the Buffer is NULL, then ASSERT().
204 @param Buffer Pointer to a 64-bit value that may be unaligned.
205 @param Value 64-bit value to write to Buffer.
217 ASSERT (Buffer
!= NULL
);
219 return *Buffer
= Value
;