]>
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 return *Buffer
= BitFieldWrite32 (*Buffer
, 0, 23, Value
);
120 Reads a 32-bit value from memory that may be unaligned.
122 This function returns the 32-bit value pointed to by Buffer. The function
123 guarantees that the read operation does not produce an alignment fault.
125 If the Buffer is NULL, then ASSERT().
127 @param Buffer Pointer to a 32-bit value that may be unaligned.
135 IN CONST UINT32
*Buffer
138 ASSERT (Buffer
!= NULL
);
144 Writes a 32-bit value to memory that may be unaligned.
146 This function writes the 32-bit value specified by Value to Buffer. Value is
147 returned. The function guarantees that the write operation does not produce
150 If the Buffer is NULL, then ASSERT().
152 @param Buffer Pointer to a 32-bit value that may be unaligned.
153 @param Value 32-bit value to write to Buffer.
165 ASSERT (Buffer
!= NULL
);
167 return *Buffer
= Value
;
171 Reads a 64-bit value from memory that may be unaligned.
173 This function returns the 64-bit value pointed to by Buffer. The function
174 guarantees that the read operation does not produce an alignment fault.
176 If the Buffer is NULL, then ASSERT().
178 @param Buffer Pointer to a 64-bit value that may be unaligned.
186 IN CONST UINT64
*Buffer
189 ASSERT (Buffer
!= NULL
);
195 Writes a 64-bit value to memory that may be unaligned.
197 This function writes the 64-bit value specified by Value to Buffer. Value is
198 returned. The function guarantees that the write operation does not produce
201 If the Buffer is NULL, then ASSERT().
203 @param Buffer Pointer to a 64-bit value that may be unaligned.
204 @param Value 64-bit value to write to Buffer.
216 ASSERT (Buffer
!= NULL
);
218 return *Buffer
= Value
;