]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/Unaligned.c
Minor grammatical work--mostly adding periods. Items with ONLY period added did...
[mirror_edk2.git] / MdePkg / Library / BaseLib / Unaligned.c
CommitLineData
e1f414b6 1/** @file\r
2 Unaligned access functions of BaseLib.\r
3\r
127010dd 4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
bb817c56 5 This program and the accompanying materials\r
e1f414b6 6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
127010dd 8 http://opensource.org/licenses/bsd-license.php.\r
e1f414b6 9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
e1f414b6 13**/\r
14\r
1efcc4ae 15\r
47fc17d8 16#include "BaseLibInternals.h"\r
f734a10a 17\r
e1f414b6 18\r
19/**\r
20 Reads a 16-bit value from memory that may be unaligned.\r
21\r
22 This function returns the 16-bit value pointed to by Buffer. The function\r
23 guarantees that the read operation does not produce an alignment fault.\r
24\r
25 If the Buffer is NULL, then ASSERT().\r
26\r
127010dd 27 @param Buffer A pointer to a 16-bit value that may be unaligned.\r
e1f414b6 28\r
5385a579 29 @return The 16-bit value read from Buffer.\r
e1f414b6 30\r
31**/\r
32UINT16\r
33EFIAPI\r
34ReadUnaligned16 (\r
5385a579 35 IN CONST UINT16 *Buffer\r
e1f414b6 36 )\r
37{\r
38 ASSERT (Buffer != NULL);\r
39\r
40 return *Buffer;\r
41}\r
42\r
43/**\r
44 Writes a 16-bit value to memory that may be unaligned.\r
45\r
46 This function writes the 16-bit value specified by Value to Buffer. Value is\r
47 returned. The function guarantees that the write operation does not produce\r
48 an alignment fault.\r
49\r
50 If the Buffer is NULL, then ASSERT().\r
51\r
127010dd 52 @param Buffer A pointer to a 16-bit value that may be unaligned.\r
e1f414b6 53 @param Value 16-bit value to write to Buffer.\r
54\r
5385a579 55 @return The 16-bit value to write to Buffer.\r
e1f414b6 56\r
57**/\r
58UINT16\r
59EFIAPI\r
60WriteUnaligned16 (\r
5385a579 61 OUT UINT16 *Buffer,\r
62 IN UINT16 Value\r
e1f414b6 63 )\r
64{\r
65 ASSERT (Buffer != NULL);\r
66\r
67 return *Buffer = Value;\r
68}\r
69\r
70/**\r
71 Reads a 24-bit value from memory that may be unaligned.\r
72\r
73 This function returns the 24-bit value pointed to by Buffer. The function\r
74 guarantees that the read operation does not produce an alignment fault.\r
75\r
76 If the Buffer is NULL, then ASSERT().\r
77\r
127010dd 78 @param Buffer A pointer to a 24-bit value that may be unaligned.\r
e1f414b6 79\r
5385a579 80 @return The 24-bit value read from Buffer.\r
e1f414b6 81\r
82**/\r
83UINT32\r
84EFIAPI\r
85ReadUnaligned24 (\r
5385a579 86 IN CONST UINT32 *Buffer\r
e1f414b6 87 )\r
88{\r
89 ASSERT (Buffer != NULL);\r
90\r
91 return *Buffer & 0xffffff;\r
92}\r
93\r
94/**\r
95 Writes a 24-bit value to memory that may be unaligned.\r
96\r
97 This function writes the 24-bit value specified by Value to Buffer. Value is\r
98 returned. The function guarantees that the write operation does not produce\r
99 an alignment fault.\r
100\r
101 If the Buffer is NULL, then ASSERT().\r
102\r
127010dd 103 @param Buffer A pointer to a 24-bit value that may be unaligned.\r
e1f414b6 104 @param Value 24-bit value to write to Buffer.\r
105\r
5385a579 106 @return The 24-bit value to write to Buffer.\r
e1f414b6 107\r
108**/\r
109UINT32\r
110EFIAPI\r
111WriteUnaligned24 (\r
5385a579 112 OUT UINT32 *Buffer,\r
113 IN UINT32 Value\r
e1f414b6 114 )\r
115{\r
116 ASSERT (Buffer != NULL);\r
117\r
118 *Buffer = BitFieldWrite32 (*Buffer, 0, 23, Value);\r
119 return Value;\r
120}\r
121\r
122/**\r
123 Reads a 32-bit value from memory that may be unaligned.\r
124\r
125 This function returns the 32-bit value pointed to by Buffer. The function\r
126 guarantees that the read operation does not produce an alignment fault.\r
127\r
128 If the Buffer is NULL, then ASSERT().\r
129\r
127010dd 130 @param Buffer A pointer to a 32-bit value that may be unaligned.\r
e1f414b6 131\r
5385a579 132 @return The 32-bit value read from Buffer.\r
e1f414b6 133\r
134**/\r
135UINT32\r
136EFIAPI\r
137ReadUnaligned32 (\r
5385a579 138 IN CONST UINT32 *Buffer\r
e1f414b6 139 )\r
140{\r
141 ASSERT (Buffer != NULL);\r
142\r
143 return *Buffer;\r
144}\r
145\r
146/**\r
147 Writes a 32-bit value to memory that may be unaligned.\r
148\r
149 This function writes the 32-bit value specified by Value to Buffer. Value is\r
150 returned. The function guarantees that the write operation does not produce\r
151 an alignment fault.\r
152\r
153 If the Buffer is NULL, then ASSERT().\r
154\r
127010dd 155 @param Buffer A pointer to a 32-bit value that may be unaligned.\r
156 @param Value The 32-bit value to write to Buffer.\r
e1f414b6 157\r
5385a579 158 @return The 32-bit value to write to Buffer.\r
e1f414b6 159\r
160**/\r
161UINT32\r
162EFIAPI\r
163WriteUnaligned32 (\r
5385a579 164 OUT UINT32 *Buffer,\r
165 IN UINT32 Value\r
e1f414b6 166 )\r
167{\r
168 ASSERT (Buffer != NULL);\r
169\r
170 return *Buffer = Value;\r
171}\r
172\r
173/**\r
174 Reads a 64-bit value from memory that may be unaligned.\r
175\r
176 This function returns the 64-bit value pointed to by Buffer. The function\r
177 guarantees that the read operation does not produce an alignment fault.\r
178\r
179 If the Buffer is NULL, then ASSERT().\r
180\r
127010dd 181 @param Buffer A pointer to a 64-bit value that may be unaligned.\r
e1f414b6 182\r
5385a579 183 @return The 64-bit value read from Buffer.\r
e1f414b6 184\r
185**/\r
186UINT64\r
187EFIAPI\r
188ReadUnaligned64 (\r
5385a579 189 IN CONST UINT64 *Buffer\r
e1f414b6 190 )\r
191{\r
192 ASSERT (Buffer != NULL);\r
193\r
194 return *Buffer;\r
195}\r
196\r
197/**\r
198 Writes a 64-bit value to memory that may be unaligned.\r
199\r
200 This function writes the 64-bit value specified by Value to Buffer. Value is\r
201 returned. The function guarantees that the write operation does not produce\r
202 an alignment fault.\r
203\r
204 If the Buffer is NULL, then ASSERT().\r
205\r
127010dd 206 @param Buffer A pointer to a 64-bit value that may be unaligned.\r
207 @param Value The 64-bit value to write to Buffer.\r
e1f414b6 208\r
5385a579 209 @return The 64-bit value to write to Buffer.\r
e1f414b6 210\r
211**/\r
212UINT64\r
213EFIAPI\r
214WriteUnaligned64 (\r
5385a579 215 OUT UINT64 *Buffer,\r
216 IN UINT64 Value\r
e1f414b6 217 )\r
218{\r
219 ASSERT (Buffer != NULL);\r
220\r
221 return *Buffer = Value;\r
222}\r