]>
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 // Include common header file for this module.
20 #include "CommonHeader.h"
23 Reads a 16-bit value from memory that may be unaligned.
25 This function returns the 16-bit value pointed to by Buffer. The function
26 guarantees that the read operation does not produce an alignment fault.
28 If the Buffer is NULL, then ASSERT().
30 @param Buffer Pointer to a 16-bit value that may be unaligned.
38 IN CONST UINT16
*Buffer
41 ASSERT (Buffer
!= NULL
);
47 Writes a 16-bit value to memory that may be unaligned.
49 This function writes the 16-bit value specified by Value to Buffer. Value is
50 returned. The function guarantees that the write operation does not produce
53 If the Buffer is NULL, then ASSERT().
55 @param Buffer Pointer to a 16-bit value that may be unaligned.
56 @param Value 16-bit value to write to Buffer.
68 ASSERT (Buffer
!= NULL
);
70 return *Buffer
= Value
;
74 Reads a 24-bit value from memory that may be unaligned.
76 This function returns the 24-bit value pointed to by Buffer. The function
77 guarantees that the read operation does not produce an alignment fault.
79 If the Buffer is NULL, then ASSERT().
81 @param Buffer Pointer to a 24-bit value that may be unaligned.
83 @return The value read.
89 IN CONST UINT32
*Buffer
92 ASSERT (Buffer
!= NULL
);
94 return *Buffer
& 0xffffff;
98 Writes a 24-bit value to memory that may be unaligned.
100 This function writes the 24-bit value specified by Value to Buffer. Value is
101 returned. The function guarantees that the write operation does not produce
104 If the Buffer is NULL, then ASSERT().
106 @param Buffer Pointer to a 24-bit value that may be unaligned.
107 @param Value 24-bit value to write to Buffer.
109 @return The value written.
119 ASSERT (Buffer
!= NULL
);
121 *Buffer
= BitFieldWrite32 (*Buffer
, 0, 23, Value
);
126 Reads a 32-bit value from memory that may be unaligned.
128 This function returns the 32-bit value pointed to by Buffer. The function
129 guarantees that the read operation does not produce an alignment fault.
131 If the Buffer is NULL, then ASSERT().
133 @param Buffer Pointer to a 32-bit value that may be unaligned.
141 IN CONST UINT32
*Buffer
144 ASSERT (Buffer
!= NULL
);
150 Writes a 32-bit value to memory that may be unaligned.
152 This function writes the 32-bit value specified by Value to Buffer. Value is
153 returned. The function guarantees that the write operation does not produce
156 If the Buffer is NULL, then ASSERT().
158 @param Buffer Pointer to a 32-bit value that may be unaligned.
159 @param Value 32-bit value to write to Buffer.
171 ASSERT (Buffer
!= NULL
);
173 return *Buffer
= Value
;
177 Reads a 64-bit value from memory that may be unaligned.
179 This function returns the 64-bit value pointed to by Buffer. The function
180 guarantees that the read operation does not produce an alignment fault.
182 If the Buffer is NULL, then ASSERT().
184 @param Buffer Pointer to a 64-bit value that may be unaligned.
192 IN CONST UINT64
*Buffer
195 ASSERT (Buffer
!= NULL
);
201 Writes a 64-bit value to memory that may be unaligned.
203 This function writes the 64-bit value specified by Value to Buffer. Value is
204 returned. The function guarantees that the write operation does not produce
207 If the Buffer is NULL, then ASSERT().
209 @param Buffer Pointer to a 64-bit value that may be unaligned.
210 @param Value 64-bit value to write to Buffer.
222 ASSERT (Buffer
!= NULL
);
224 return *Buffer
= Value
;