]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c
Maintainers.txt: Remove EdkCompatibilityPkg information
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / RuntimeDxe / EfiRuntimeLib / Io.c
1 /*++
2
3 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
4 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
8
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.
11
12 Module Name:
13
14 Io.c
15
16 Abstract:
17
18 Light weight lib functions that wrape IoRead (), IoWrite, MemRead (),
19 and MemWrite ().
20
21 --*/
22
23 #include "Tiano.h"
24 #include "EfiRuntimeLib.h"
25
26 UINT8
27 IoRead8 (
28 IN UINT64 Address
29 )
30 /*++
31
32 Routine Description:
33 Do a one byte IO read
34
35 Arguments:
36 Address - IO address to read
37
38 Returns:
39 Data read
40
41 --*/
42 {
43 UINT8 Buffer;
44
45 Buffer = 0;
46 EfiIoRead (EfiCpuIoWidthUint8, Address, 1, &Buffer);
47 return Buffer;
48 }
49
50 UINT16
51 IoRead16 (
52 IN UINT64 Address
53 )
54 /*++
55
56 Routine Description:
57 Do a two byte IO read
58
59 Arguments:
60 Address - IO address to read
61
62 Returns:
63 Data read
64
65 --*/
66 {
67 UINT16 Buffer;
68
69 Buffer = 0;
70 EfiIoRead (EfiCpuIoWidthUint16, Address, 1, &Buffer);
71 return Buffer;
72 }
73
74 UINT32
75 IoRead32 (
76 IN UINT64 Address
77 )
78 /*++
79
80 Routine Description:
81 Do a four byte IO read
82
83 Arguments:
84 Address - IO address to read
85
86 Returns:
87 Data read
88
89 --*/
90 {
91 UINT32 Buffer;
92
93 Buffer = 0;
94 EfiIoRead (EfiCpuIoWidthUint32, Address, 1, &Buffer);
95 return Buffer;
96 }
97
98 VOID
99 IoWrite8 (
100 IN UINT64 Address,
101 IN UINT8 Data
102 )
103 /*++
104
105 Routine Description:
106 Do a one byte IO write
107
108 Arguments:
109 Address - IO address to write
110 Data - Data to write to Address
111
112 Returns:
113 NONE
114
115 --*/
116 {
117 EfiIoWrite (EfiCpuIoWidthUint8, Address, 1, &Data);
118 }
119
120 VOID
121 IoWrite16 (
122 IN UINT64 Address,
123 IN UINT16 Data
124 )
125 /*++
126
127 Routine Description:
128 Do a two byte IO write
129
130 Arguments:
131 Address - IO address to write
132 Data - Data to write to Address
133
134 Returns:
135 NONE
136
137 --*/
138 {
139 EfiIoWrite (EfiCpuIoWidthUint16, Address, 1, &Data);
140 }
141
142 VOID
143 IoWrite32 (
144 IN UINT64 Address,
145 IN UINT32 Data
146 )
147 /*++
148
149 Routine Description:
150 Do a four byte IO write
151
152 Arguments:
153 Address - IO address to write
154 Data - Data to write to Address
155
156 Returns:
157 NONE
158
159 --*/
160 {
161 EfiIoWrite (EfiCpuIoWidthUint32, Address, 1, &Data);
162 }
163
164 UINT8
165 MemRead8 (
166 IN UINT64 Address
167 )
168 /*++
169
170 Routine Description:
171 Do a one byte Memory mapped IO read
172
173 Arguments:
174 Address - Memory mapped IO address to read
175
176 Returns:
177 Data read
178
179 --*/
180 {
181 UINT8 Buffer;
182
183 Buffer = 0;
184 EfiMemRead (EfiCpuIoWidthUint8, Address, 1, &Buffer);
185 return Buffer;
186 }
187
188 UINT16
189 MemRead16 (
190 IN UINT64 Address
191 )
192 /*++
193
194 Routine Description:
195 Do a two byte Memory mapped IO read
196
197 Arguments:
198 Address - Memory mapped IO address to read
199
200 Returns:
201 Data read
202
203 --*/
204 {
205 UINT16 Buffer;
206
207 Buffer = 0;
208 EfiMemRead (EfiCpuIoWidthUint16, Address, 1, &Buffer);
209 return Buffer;
210 }
211
212 UINT32
213 MemRead32 (
214 IN UINT64 Address
215 )
216 /*++
217
218 Routine Description:
219 Do a four byte Memory mapped IO read
220
221 Arguments:
222 Address - Memory mapped IO address to read
223
224 Returns:
225 Data read
226
227 --*/
228 {
229 UINT32 Buffer;
230
231 Buffer = 0;
232 EfiMemRead (EfiCpuIoWidthUint32, Address, 1, &Buffer);
233 return Buffer;
234 }
235
236 UINT64
237 MemRead64 (
238 IN UINT64 Address
239 )
240 /*++
241
242 Routine Description:
243 Do a eight byte Memory mapped IO read
244
245 Arguments:
246 Address - Memory mapped IO address to read
247
248 Returns:
249 Data read
250
251 --*/
252 {
253 UINT64 Buffer;
254
255 Buffer = 0;
256 EfiMemRead (EfiCpuIoWidthUint64, Address, 1, &Buffer);
257 return Buffer;
258 }
259
260 VOID
261 MemWrite8 (
262 IN UINT64 Address,
263 IN UINT8 Data
264 )
265 /*++
266
267 Routine Description:
268 Do a one byte Memory mapped IO write
269
270 Arguments:
271 Address - Memory mapped IO address to write
272 Data - Data to write to Address
273
274 Returns:
275 NONE
276
277 --*/
278 {
279 EfiMemWrite (EfiCpuIoWidthUint8, Address, 1, &Data);
280 }
281
282 VOID
283 MemWrite16 (
284 IN UINT64 Address,
285 IN UINT16 Data
286 )
287 /*++
288
289 Routine Description:
290 Do a two byte Memory mapped IO write
291
292 Arguments:
293 Address - Memory mapped IO address to write
294 Data - Data to write to Address
295
296 Returns:
297 NONE
298
299 --*/
300 {
301 EfiMemWrite (EfiCpuIoWidthUint16, Address, 1, &Data);
302 }
303
304 VOID
305 MemWrite32 (
306 IN UINT64 Address,
307 IN UINT32 Data
308 )
309 /*++
310
311 Routine Description:
312 Do a four byte Memory mapped IO write
313
314 Arguments:
315 Address - Memory mapped IO address to write
316 Data - Data to write to Address
317
318 Returns:
319 NONE
320
321 --*/
322 {
323 EfiMemWrite (EfiCpuIoWidthUint32, Address, 1, &Data);
324 }
325
326 VOID
327 MemWrite64 (
328 IN UINT64 Address,
329 IN UINT64 Data
330 )
331 /*++
332
333 Routine Description:
334 Do a eight byte Memory mapped IO write
335
336 Arguments:
337 Address - Memory mapped IO address to write
338 Data - Data to write to Address
339
340 Returns:
341 NONE
342
343 --*/
344 {
345 EfiMemWrite (EfiCpuIoWidthUint64, Address, 1, &Data);
346 }