]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseIoLibIntrinsic/IoLibArm.c
c21053464074e4a4e54ca2188d548e8c82a121ad
[mirror_edk2.git] / MdePkg / Library / BaseIoLibIntrinsic / IoLibArm.c
1 /** @file
2 I/O Library for ARM.
3
4 Copyright (c) 2006 - 2009, Intel Corporation<BR>
5 Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.<BR>
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16
17 //
18 // Include common header file for this module.
19 //
20 #include "BaseIoLibIntrinsicInternal.h"
21
22 /**
23 Reads an 8-bit I/O port.
24
25 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
26 This function must guarantee that all I/O read and write operations are
27 serialized.
28
29 If 8-bit I/O port operations are not supported, then ASSERT().
30
31 @param Port The I/O port to read.
32
33 @return The value read.
34
35 **/
36 UINT8
37 EFIAPI
38 IoRead8 (
39 IN UINTN Port
40 )
41 {
42 ASSERT (FALSE);
43 return 0;
44 }
45
46 /**
47 Writes an 8-bit I/O port.
48
49 Writes the 8-bit I/O port specified by Port with the value specified by Value
50 and returns Value. This function must guarantee that all I/O read and write
51 operations are serialized.
52
53 If 8-bit I/O port operations are not supported, then ASSERT().
54
55 @param Port The I/O port to write.
56 @param Value The value to write to the I/O port.
57
58 @return The value written the I/O port.
59
60 **/
61 UINT8
62 EFIAPI
63 IoWrite8 (
64 IN UINTN Port,
65 IN UINT8 Value
66 )
67 {
68 ASSERT (FALSE);
69 return Value;
70 }
71
72 /**
73 Reads a 16-bit I/O port.
74
75 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
76 This function must guarantee that all I/O read and write operations are
77 serialized.
78
79 If 16-bit I/O port operations are not supported, then ASSERT().
80
81 @param Port The I/O port to read.
82
83 @return The value read.
84
85 **/
86 UINT16
87 EFIAPI
88 IoRead16 (
89 IN UINTN Port
90 )
91 {
92 ASSERT (FALSE);
93 return 0;
94 }
95
96 /**
97 Writes a 16-bit I/O port.
98
99 Writes the 16-bit I/O port specified by Port with the value specified by Value
100 and returns Value. This function must guarantee that all I/O read and write
101 operations are serialized.
102
103 If 16-bit I/O port operations are not supported, then ASSERT().
104
105 @param Port The I/O port to write.
106 @param Value The value to write to the I/O port.
107
108 @return The value written the I/O port.
109
110 **/
111 UINT16
112 EFIAPI
113 IoWrite16 (
114 IN UINTN Port,
115 IN UINT16 Value
116 )
117 {
118 ASSERT (FALSE);
119 return Value;
120 }
121
122 /**
123 Reads a 32-bit I/O port.
124
125 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
126 This function must guarantee that all I/O read and write operations are
127 serialized.
128
129 If 32-bit I/O port operations are not supported, then ASSERT().
130
131 @param Port The I/O port to read.
132
133 @return The value read.
134
135 **/
136 UINT32
137 EFIAPI
138 IoRead32 (
139 IN UINTN Port
140 )
141 {
142 ASSERT (FALSE);
143 return 0;
144 }
145
146 /**
147 Writes a 32-bit I/O port.
148
149 Writes the 32-bit I/O port specified by Port with the value specified by Value
150 and returns Value. This function must guarantee that all I/O read and write
151 operations are serialized.
152
153 If 32-bit I/O port operations are not supported, then ASSERT().
154
155 @param Port The I/O port to write.
156 @param Value The value to write to the I/O port.
157
158 @return The value written the I/O port.
159
160 **/
161 UINT32
162 EFIAPI
163 IoWrite32 (
164 IN UINTN Port,
165 IN UINT32 Value
166 )
167 {
168 ASSERT (FALSE);
169 return Value;
170 }
171
172 /**
173 Reads a 64-bit I/O port.
174
175 Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
176 This function must guarantee that all I/O read and write operations are
177 serialized.
178
179 If 64-bit I/O port operations are not supported, then ASSERT().
180 If Port is not aligned on a 64-bit boundary, then ASSERT().
181
182 @param Port The I/O port to read.
183
184 @return The value read.
185
186 **/
187 UINT64
188 EFIAPI
189 IoRead64 (
190 IN UINTN Port
191 )
192 {
193 ASSERT (FALSE);
194 return 0;
195 }
196
197 /**
198 Writes a 64-bit I/O port.
199
200 Writes the 64-bit I/O port specified by Port with the value specified by Value
201 and returns Value. This function must guarantee that all I/O read and write
202 operations are serialized.
203
204 If 64-bit I/O port operations are not supported, then ASSERT().
205 If Port is not aligned on a 64-bit boundary, then ASSERT().
206
207 @param Port The I/O port to write.
208 @param Value The value to write to the I/O port.
209
210 @return The value written the I/O port.
211
212 **/
213 UINT64
214 EFIAPI
215 IoWrite64 (
216 IN UINTN Port,
217 IN UINT64 Value
218 )
219 {
220 ASSERT (FALSE);
221 return 0;
222 }
223
224
225 /**
226 Reads an 8-bit MMIO register.
227
228 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
229 returned. This function must guarantee that all MMIO read and write
230 operations are serialized.
231
232 If 8-bit MMIO register operations are not supported, then ASSERT().
233
234 @param Address The MMIO register to read.
235
236 @return The value read.
237
238 **/
239 UINT8
240 EFIAPI
241 MmioRead8 (
242 IN UINTN Address
243 )
244 {
245 UINT8 Value;
246
247 Value = *(volatile UINT8*)Address;
248 return Value;
249 }
250
251 /**
252 Writes an 8-bit MMIO register.
253
254 Writes the 8-bit MMIO register specified by Address with the value specified
255 by Value and returns Value. This function must guarantee that all MMIO read
256 and write operations are serialized.
257
258 If 8-bit MMIO register operations are not supported, then ASSERT().
259
260 @param Address The MMIO register to write.
261 @param Value The value to write to the MMIO register.
262
263 **/
264 UINT8
265 EFIAPI
266 MmioWrite8 (
267 IN UINTN Address,
268 IN UINT8 Value
269 )
270 {
271 *(volatile UINT8*)Address = Value;
272 return Value;
273 }
274
275 /**
276 Reads a 16-bit MMIO register.
277
278 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
279 returned. This function must guarantee that all MMIO read and write
280 operations are serialized.
281
282 If 16-bit MMIO register operations are not supported, then ASSERT().
283
284 @param Address The MMIO register to read.
285
286 @return The value read.
287
288 **/
289 UINT16
290 EFIAPI
291 MmioRead16 (
292 IN UINTN Address
293 )
294 {
295 UINT16 Value;
296
297 ASSERT ((Address & 1) == 0);
298 Value = *(volatile UINT16*)Address;
299 return Value;
300 }
301
302 /**
303 Writes a 16-bit MMIO register.
304
305 Writes the 16-bit MMIO register specified by Address with the value specified
306 by Value and returns Value. This function must guarantee that all MMIO read
307 and write operations are serialized.
308
309 If 16-bit MMIO register operations are not supported, then ASSERT().
310
311 @param Address The MMIO register to write.
312 @param Value The value to write to the MMIO register.
313
314 **/
315 UINT16
316 EFIAPI
317 MmioWrite16 (
318 IN UINTN Address,
319 IN UINT16 Value
320 )
321 {
322 ASSERT ((Address & 1) == 0);
323 *(volatile UINT16*)Address = Value;
324 return Value;
325 }
326
327 /**
328 Reads a 32-bit MMIO register.
329
330 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
331 returned. This function must guarantee that all MMIO read and write
332 operations are serialized.
333
334 If 32-bit MMIO register operations are not supported, then ASSERT().
335
336 @param Address The MMIO register to read.
337
338 @return The value read.
339
340 **/
341 UINT32
342 EFIAPI
343 MmioRead32 (
344 IN UINTN Address
345 )
346 {
347 UINT32 Value;
348
349 ASSERT ((Address & 3) == 0);
350 Value = *(volatile UINT32*)Address;
351 return Value;
352 }
353
354 /**
355 Writes a 32-bit MMIO register.
356
357 Writes the 32-bit MMIO register specified by Address with the value specified
358 by Value and returns Value. This function must guarantee that all MMIO read
359 and write operations are serialized.
360
361 If 32-bit MMIO register operations are not supported, then ASSERT().
362
363 @param Address The MMIO register to write.
364 @param Value The value to write to the MMIO register.
365
366 **/
367 UINT32
368 EFIAPI
369 MmioWrite32 (
370 IN UINTN Address,
371 IN UINT32 Value
372 )
373 {
374 ASSERT ((Address & 3) == 0);
375 *(volatile UINT32*)Address = Value;
376 return Value;
377 }
378
379 /**
380 Reads a 64-bit MMIO register.
381
382 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
383 returned. This function must guarantee that all MMIO read and write
384 operations are serialized.
385
386 If 64-bit MMIO register operations are not supported, then ASSERT().
387
388 @param Address The MMIO register to read.
389
390 @return The value read.
391
392 **/
393 UINT64
394 EFIAPI
395 MmioRead64 (
396 IN UINTN Address
397 )
398 {
399 UINT64 Value;
400
401 ASSERT ((Address & 7) == 0);
402 Value = *(volatile UINT64*)Address;
403 return Value;
404 }
405
406 /**
407 Writes a 64-bit MMIO register.
408
409 Writes the 64-bit MMIO register specified by Address with the value specified
410 by Value and returns Value. This function must guarantee that all MMIO read
411 and write operations are serialized.
412
413 If 64-bit MMIO register operations are not supported, then ASSERT().
414
415 @param Address The MMIO register to write.
416 @param Value The value to write to the MMIO register.
417
418 **/
419 UINT64
420 EFIAPI
421 MmioWrite64 (
422 IN UINTN Address,
423 IN UINT64 Value
424 )
425 {
426 ASSERT ((Address & 7) == 0);
427 *(volatile UINT64*)Address = Value;
428 return Value;
429 }
430