]>
git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c
47eb80d26abf85b81af85fc3d165b3116b7ee322
3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 Unaligned access functions of BaseLib.
23 #include "BaseLibInternals.h"
26 Reads a 16-bit value from memory that may be unaligned.
28 This function returns the 16-bit value pointed to by Buffer. The function
29 guarantees that the read operation does not produce an alignment fault.
31 If the Buffer is NULL, then ASSERT().
33 @param Buffer Pointer to a 16-bit value that may be unaligned.
41 IN CONST UINT16
*Buffer
44 ASSERT (Buffer
!= NULL
);
50 Writes a 16-bit value to memory that may be unaligned.
52 This function writes the 16-bit value specified by Value to Buffer. Value is
53 returned. The function guarantees that the write operation does not produce
56 If the Buffer is NULL, then ASSERT().
58 @param Buffer Pointer to a 16-bit value that may be unaligned.
59 @param Value 16-bit value to write to Buffer.
71 ASSERT (Buffer
!= NULL
);
73 return *Buffer
= Value
;
77 Reads a 24-bit value from memory that may be unaligned.
79 This function returns the 24-bit value pointed to by Buffer. The function
80 guarantees that the read operation does not produce an alignment fault.
82 If the Buffer is NULL, then ASSERT().
84 @param Buffer Pointer to a 24-bit value that may be unaligned.
86 @return The value read.
92 IN CONST UINT32
*Buffer
95 ASSERT (Buffer
!= NULL
);
97 return *Buffer
& 0xffffff;
101 Writes a 24-bit value to memory that may be unaligned.
103 This function writes the 24-bit value specified by Value to Buffer. Value is
104 returned. The function guarantees that the write operation does not produce
107 If the Buffer is NULL, then ASSERT().
109 @param Buffer Pointer to a 24-bit value that may be unaligned.
110 @param Value 24-bit value to write to Buffer.
112 @return The value written.
122 ASSERT (Buffer
!= NULL
);
124 *Buffer
= BitFieldWrite32 (*Buffer
, 0, 23, Value
);
129 Reads a 32-bit value from memory that may be unaligned.
131 This function returns the 32-bit value pointed to by Buffer. The function
132 guarantees that the read operation does not produce an alignment fault.
134 If the Buffer is NULL, then ASSERT().
136 @param Buffer Pointer to a 32-bit value that may be unaligned.
144 IN CONST UINT32
*Buffer
147 ASSERT (Buffer
!= NULL
);
153 Writes a 32-bit value to memory that may be unaligned.
155 This function writes the 32-bit value specified by Value to Buffer. Value is
156 returned. The function guarantees that the write operation does not produce
159 If the Buffer is NULL, then ASSERT().
161 @param Buffer Pointer to a 32-bit value that may be unaligned.
162 @param Value 32-bit value to write to Buffer.
174 ASSERT (Buffer
!= NULL
);
176 return *Buffer
= Value
;
180 Reads a 64-bit value from memory that may be unaligned.
182 This function returns the 64-bit value pointed to by Buffer. The function
183 guarantees that the read operation does not produce an alignment fault.
185 If the Buffer is NULL, then ASSERT().
187 @param Buffer Pointer to a 64-bit value that may be unaligned.
195 IN CONST UINT64
*Buffer
198 ASSERT (Buffer
!= NULL
);
204 Writes a 64-bit value to memory that may be unaligned.
206 This function writes the 64-bit value specified by Value to Buffer. Value is
207 returned. The function guarantees that the write operation does not produce
210 If the Buffer is NULL, then ASSERT().
212 @param Buffer Pointer to a 64-bit value that may be unaligned.
213 @param Value 64-bit value to write to Buffer.
225 ASSERT (Buffer
!= NULL
);
227 return *Buffer
= Value
;