Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/Libefi/IoLib.c

  • Property svn:executable set to *
1/** @file
2 Common I/O Library routines.
3
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
5 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.
9
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.
12
13**/
14
15#include <efi.h>
16
17/**
18 Reads a 64-bit I/O port.
19
20 Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
21 This function must guarantee that all I/O read and write operations are
22 serialized.
23
24 If 64-bit I/O port operations are not supported, then ASSERT().
25 If Port is not aligned on a 64-bit boundary, then ASSERT().
26
27 @param Port The I/O port to read.
28
29 @return The value read.
30
31**/
32UINT64
33IoRead64 (
34 IN UINTN Port
35 )
36{
37 ASSERT (FALSE);
38 return 0;
39}
40
41/**
42 Writes a 64-bit I/O port.
43
44 Writes the 64-bit I/O port specified by Port with the value specified by Value
45 and returns Value. This function must guarantee that all I/O read and write
46 operations are serialized.
47
48 If 64-bit I/O port operations are not supported, then ASSERT().
49 If Port is not aligned on a 64-bit boundary, then ASSERT().
50
51 @param Port The I/O port to write.
52 @param Value The value to write to the I/O port.
53
54 @return The value written the I/O port.
55
56**/
57UINT64
58IoWrite64 (
59 IN UINTN Port,
60 IN UINT64 Value
61 )
62{
63 ASSERT (FALSE);
64 return 0;
65}
66
67
68/**
69 Reads an 8-bit MMIO register.
70
71 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
72 returned. This function must guarantee that all MMIO read and write
73 operations are serialized.
74
75 If 8-bit MMIO register operations are not supported, then ASSERT().
76
77 @param Address The MMIO register to read.
78
79 @return The value read.
80
81**/
82UINT8
83MmioRead8 (
84 IN UINTN Address
85 )
86{
87 UINT8 Value;
88
89 Value = *(volatile UINT8*)Address;
90
91 return Value;
92}
93
94/**
95 Writes an 8-bit MMIO register.
96
97 Writes the 8-bit MMIO register specified by Address with the value specified
98 by Value and returns Value. This function must guarantee that all MMIO read
99 and write operations are serialized.
100
101 If 8-bit MMIO register operations are not supported, then ASSERT().
102
103 @param Address The MMIO register to write.
104 @param Value The value to write to the MMIO register.
105
106 @return Value.
107
108**/
109UINT8
110MmioWrite8 (
111 IN UINTN Address,
112 IN UINT8 Value
113 )
114{
115 *(volatile UINT8*)Address = Value;
116
117 return Value;
118}
119
120/**
121 Reads a 16-bit MMIO register.
122
123 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
124 returned. This function must guarantee that all MMIO read and write
125 operations are serialized.
126
127 If 16-bit MMIO register operations are not supported, then ASSERT().
128 If Address is not aligned on a 16-bit boundary, then ASSERT().
129
130 @param Address The MMIO register to read.
131
132 @return The value read.
133
134**/
135UINT16
136MmioRead16 (
137 IN UINTN Address
138 )
139{
140 UINT16 Value;
141
142 ASSERT ((Address & 1) == 0);
143
144 Value = *(volatile UINT16*)Address;
145
146 return Value;
147}
148
149/**
150 Writes a 16-bit MMIO register.
151
152 Writes the 16-bit MMIO register specified by Address with the value specified
153 by Value and returns Value. This function must guarantee that all MMIO read
154 and write operations are serialized.
155
156 If 16-bit MMIO register operations are not supported, then ASSERT().
157 If Address is not aligned on a 16-bit boundary, then ASSERT().
158
159 @param Address The MMIO register to write.
160 @param Value The value to write to the MMIO register.
161
162 @return Value.
163
164**/
165UINT16
166MmioWrite16 (
167 IN UINTN Address,
168 IN UINT16 Value
169 )
170{
171 ASSERT ((Address & 1) == 0);
172
173 *(volatile UINT16*)Address = Value;
174
175 return Value;
176}
177
178/**
179 Reads a 32-bit MMIO register.
180
181 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
182 returned. This function must guarantee that all MMIO read and write
183 operations are serialized.
184
185 If 32-bit MMIO register operations are not supported, then ASSERT().
186 If Address is not aligned on a 32-bit boundary, then ASSERT().
187
188 @param Address The MMIO register to read.
189
190 @return The value read.
191
192**/
193UINT32
194MmioRead32 (
195 IN UINTN Address
196 )
197{
198 UINT32 Value;
199
200 ASSERT ((Address & 3) == 0);
201
202 Value = *(volatile UINT32*)Address;
203
204 return Value;
205}
206
207/**
208 Writes a 32-bit MMIO register.
209
210 Writes the 32-bit MMIO register specified by Address with the value specified
211 by Value and returns Value. This function must guarantee that all MMIO read
212 and write operations are serialized.
213
214 If 32-bit MMIO register operations are not supported, then ASSERT().
215 If Address is not aligned on a 32-bit boundary, then ASSERT().
216
217 @param Address The MMIO register to write.
218 @param Value The value to write to the MMIO register.
219
220 @return Value.
221
222**/
223UINT32
224MmioWrite32 (
225 IN UINTN Address,
226 IN UINT32 Value
227 )
228{
229 ASSERT ((Address & 3) == 0);
230
231 *(volatile UINT32*)Address = Value;
232
233 return Value;
234}
235
236/**
237 Reads a 64-bit MMIO register.
238
239 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
240 returned. This function must guarantee that all MMIO read and write
241 operations are serialized.
242
243 If 64-bit MMIO register operations are not supported, then ASSERT().
244 If Address is not aligned on a 64-bit boundary, then ASSERT().
245
246 @param Address The MMIO register to read.
247
248 @return The value read.
249
250**/
251UINT64
252MmioRead64 (
253 IN UINTN Address
254 )
255{
256 UINT64 Value;
257
258 ASSERT ((Address & 7) == 0);
259
260 Value = *(volatile UINT64*)Address;
261
262 return Value;
263}
264
265/**
266 Writes a 64-bit MMIO register.
267
268 Writes the 64-bit MMIO register specified by Address with the value specified
269 by Value and returns Value. This function must guarantee that all MMIO read
270 and write operations are serialized.
271
272 If 64-bit MMIO register operations are not supported, then ASSERT().
273 If Address is not aligned on a 64-bit boundary, then ASSERT().
274
275 @param Address The MMIO register to write.
276 @param Value The value to write to the MMIO register.
277
278**/
279UINT64
280MmioWrite64 (
281 IN UINTN Address,
282 IN UINT64 Value
283 )
284{
285 ASSERT ((Address & 7) == 0);
286
287 *(volatile UINT64*)Address = Value;
288
289 return Value;
290}
291
292

Archive Download this file

Revision: 2182