3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. 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
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.
22 #include "EdkIIGlueBase.h"
24 #define BIT63 0x8000000000000000UL
26 #define MAP_PORT_BASE_TO_MEM(_Port) \
27 ((((_Port) & 0xfffc) << 10) | ((_Port) & 0x0fff))
30 Reads a 8-bit I/O port.
32 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
33 This function must guarantee that all I/O read and write operations are
36 @param Port The I/O port to read.
38 @return The value read.
50 // Add the 64MB aligned IO Port space to the IO address
52 Address
= MAP_PORT_BASE_TO_MEM (Port
);
53 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
55 return MmioRead8 (Address
);
59 Reads a 16-bit I/O port.
61 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
62 This function must guarantee that all I/O read and write operations are
65 @param Port The I/O port to read.
67 @return The value read.
79 // Add the 64MB aligned IO Port space to the IO address
81 Address
= MAP_PORT_BASE_TO_MEM (Port
);
82 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
84 return MmioRead16 (Address
);
88 Reads a 32-bit I/O port.
90 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
91 This function must guarantee that all I/O read and write operations are
94 @param Port The I/O port to read.
96 @return The value read.
108 // Add the 64MB aligned IO Port space to the IO address
110 Address
= MAP_PORT_BASE_TO_MEM (Port
);
111 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
113 return MmioRead32 (Address
);
117 Reads a 64-bit I/O port.
119 Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
120 This function must guarantee that all I/O read and write operations are
123 If 64-bit I/O port operations are not supported, then ASSERT().
125 @param Port The I/O port to read.
127 @return The value read.
141 Writes a 8-bit I/O port.
143 Writes the 8-bit I/O port specified by Port with the value specified by Value
144 and returns Value. This function must guarantee that all I/O read and write
145 operations are serialized.
147 @param Port The I/O port to write.
148 @param Value The value to write to the I/O port.
150 @return The value written the I/O port.
163 // Add the 64MB aligned IO Port space to the IO address
165 Address
= MAP_PORT_BASE_TO_MEM (Port
);
166 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
168 return MmioWrite8 (Address
, Data
);
172 Writes a 16-bit I/O port.
174 Writes the 16-bit I/O port specified by Port with the value specified by Value
175 and returns Value. This function must guarantee that all I/O read and write
176 operations are serialized.
178 @param Port The I/O port to write.
179 @param Value The value to write to the I/O port.
181 @return The value written the I/O port.
194 // Add the 64MB aligned IO Port space to the IO address
196 Address
= MAP_PORT_BASE_TO_MEM (Port
);
197 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
199 return MmioWrite16 (Address
, Data
);
203 Writes a 32-bit I/O port.
205 Writes the 32-bit I/O port specified by Port with the value specified by Value
206 and returns Value. This function must guarantee that all I/O read and write
207 operations are serialized.
209 @param Port The I/O port to write.
210 @param Value The value to write to the I/O port.
212 @return The value written the I/O port.
225 // Add the 64MB aligned IO Port space to the IO address
227 Address
= MAP_PORT_BASE_TO_MEM (Port
);
228 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
230 return MmioWrite32 (Address
, Data
);
234 Writes a 64-bit I/O port.
236 Writes the 64-bit I/O port specified by Port with the value specified by Value
237 and returns Value. This function must guarantee that all I/O read and write
238 operations are serialized.
240 If 64-bit I/O port operations are not supported, then ASSERT().
242 @param Port The I/O port to write.
243 @param Value The value to write to the I/O port.
245 @return The value written the I/O port.
260 Reads a 8-bit MMIO register.
262 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
263 returned. This function must guarantee that all MMIO read and write
264 operations are serialized.
266 @param Address The MMIO register to read.
268 @return The value read.
282 Data
= *((volatile UINT8
*) Address
);
289 Reads a 16-bit MMIO register.
291 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
292 returned. This function must guarantee that all MMIO read and write
293 operations are serialized.
295 @param Address The MMIO register to read.
297 @return The value read.
311 Data
= *((volatile UINT16
*) Address
);
318 Reads a 32-bit MMIO register.
320 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
321 returned. This function must guarantee that all MMIO read and write
322 operations are serialized.
324 @param Address The MMIO register to read.
326 @return The value read.
340 Data
= *((volatile UINT32
*) Address
);
347 Reads a 64-bit MMIO register.
349 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
350 returned. This function must guarantee that all MMIO read and write
351 operations are serialized.
353 @param Address The MMIO register to read.
355 @return The value read.
369 Data
= *((volatile UINT64
*) Address
);
377 Writes a 8-bit MMIO register.
379 Writes the 8-bit MMIO register specified by Address with the value specified
380 by Value and returns Value. This function must guarantee that all MMIO read
381 and write operations are serialized.
383 @param Address The MMIO register to write.
384 @param Data The value to write to the MMIO register.
386 @return The value written the memory address.
399 *((volatile UINT8
*) Address
) = Data
;
406 Writes a 16-bit MMIO register.
408 Writes the 16-bit MMIO register specified by Address with the value specified
409 by Value and returns Value. This function must guarantee that all MMIO read
410 and write operations are serialized.
412 @param Address The MMIO register to write.
413 @param Data The value to write to the MMIO register.
415 @return The value written the memory address.
428 *((volatile UINT16
*) Address
) = Data
;
435 Writes a 32-bit MMIO register.
437 Writes the 32-bit MMIO register specified by Address with the value specified
438 by Value and returns Value. This function must guarantee that all MMIO read
439 and write operations are serialized.
441 @param Address The MMIO register to write.
442 @param Data The value to write to the MMIO register.
444 @return The value written the memory address.
457 *((volatile UINT32
*) Address
) = Data
;
464 Writes a 64-bit MMIO register.
466 Writes the 64-bit MMIO register specified by Address with the value specified
467 by Value and returns Value. This function must guarantee that all MMIO read
468 and write operations are serialized.
470 @param Address The MMIO register to write.
471 @param Data The value to write to the MMIO register.
473 @return The value written the memory address.
486 *((volatile UINT64
*) Address
) = Data
;