2 Common I/O Library routines.
4 Copyright (c) 2006 - 2007, Intel Corporation<BR>
5 All rights reserved. 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
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.
13 Module Name: IoLibIpf.c
17 #define MAP_PORT_BASE_TO_MEM(_Port) \
18 ((((_Port) & 0xfffc) << 10) | ((_Port) & 0x0fff))
21 Reads a 8-bit I/O port.
23 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
24 This function must guarantee that all I/O read and write operations are
27 @param Port The I/O port to read.
29 @return The value read.
41 // Add the 64MB aligned IO Port space to the IO address
43 Address
= MAP_PORT_BASE_TO_MEM (Port
);
44 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
46 return MmioRead8 (Address
);
50 Reads a 16-bit I/O port.
52 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
53 This function must guarantee that all I/O read and write operations are
56 @param Port The I/O port to read.
58 @return The value read.
70 // Add the 64MB aligned IO Port space to the IO address
72 Address
= MAP_PORT_BASE_TO_MEM (Port
);
73 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
75 return MmioRead16 (Address
);
79 Reads a 32-bit I/O port.
81 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
82 This function must guarantee that all I/O read and write operations are
85 @param Port The I/O port to read.
87 @return The value read.
99 // Add the 64MB aligned IO Port space to the IO address
101 Address
= MAP_PORT_BASE_TO_MEM (Port
);
102 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
104 return MmioRead32 (Address
);
108 Reads a 64-bit I/O port.
110 Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
111 This function must guarantee that all I/O read and write operations are
114 If 64-bit I/O port operations are not supported, then ASSERT().
116 @param Port The I/O port to read.
118 @return The value read.
132 Writes a 8-bit I/O port.
134 Writes the 8-bit I/O port specified by Port with the value specified by Value
135 and returns Value. This function must guarantee that all I/O read and write
136 operations are serialized.
138 @param Port The I/O port to write.
139 @param Value The value to write to the I/O port.
141 @return The value written the I/O port.
154 // Add the 64MB aligned IO Port space to the IO address
156 Address
= MAP_PORT_BASE_TO_MEM (Port
);
157 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
159 return MmioWrite8 (Address
, Data
);
163 Writes a 16-bit I/O port.
165 Writes the 16-bit I/O port specified by Port with the value specified by Value
166 and returns Value. This function must guarantee that all I/O read and write
167 operations are serialized.
169 @param Port The I/O port to write.
170 @param Value The value to write to the I/O port.
172 @return The value written the I/O port.
185 // Add the 64MB aligned IO Port space to the IO address
187 Address
= MAP_PORT_BASE_TO_MEM (Port
);
188 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
190 return MmioWrite16 (Address
, Data
);
194 Writes a 32-bit I/O port.
196 Writes the 32-bit I/O port specified by Port with the value specified by Value
197 and returns Value. This function must guarantee that all I/O read and write
198 operations are serialized.
200 @param Port The I/O port to write.
201 @param Value The value to write to the I/O port.
203 @return The value written the I/O port.
216 // Add the 64MB aligned IO Port space to the IO address
218 Address
= MAP_PORT_BASE_TO_MEM (Port
);
219 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
221 return MmioWrite32 (Address
, Data
);
225 Writes a 64-bit I/O port.
227 Writes the 64-bit I/O port specified by Port with the value specified by Value
228 and returns Value. This function must guarantee that all I/O read and write
229 operations are serialized.
231 If 64-bit I/O port operations are not supported, then ASSERT().
233 @param Port The I/O port to write.
234 @param Value The value to write to the I/O port.
236 @return The value written the I/O port.
251 Reads a 8-bit MMIO register.
253 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
254 returned. This function must guarantee that all MMIO read and write
255 operations are serialized.
257 @param Address The MMIO register to read.
259 @return The value read.
273 Data
= *((volatile UINT8
*) Address
);
280 Reads a 16-bit MMIO register.
282 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
283 returned. This function must guarantee that all MMIO read and write
284 operations are serialized.
286 @param Address The MMIO register to read.
288 @return The value read.
302 Data
= *((volatile UINT16
*) Address
);
309 Reads a 32-bit MMIO register.
311 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
312 returned. This function must guarantee that all MMIO read and write
313 operations are serialized.
315 @param Address The MMIO register to read.
317 @return The value read.
331 Data
= *((volatile UINT32
*) Address
);
338 Reads a 64-bit MMIO register.
340 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
341 returned. This function must guarantee that all MMIO read and write
342 operations are serialized.
344 @param Address The MMIO register to read.
346 @return The value read.
360 Data
= *((volatile UINT64
*) Address
);
368 Writes a 8-bit MMIO register.
370 Writes the 8-bit MMIO register specified by Address with the value specified
371 by Value and returns Value. This function must guarantee that all MMIO read
372 and write operations are serialized.
374 @param Address The MMIO register to write.
375 @param Data The value to write to the MMIO register.
377 @return The value written the memory address.
390 *((volatile UINT8
*) Address
) = Data
;
397 Writes a 16-bit MMIO register.
399 Writes the 16-bit MMIO register specified by Address with the value specified
400 by Value and returns Value. This function must guarantee that all MMIO read
401 and write operations are serialized.
403 @param Address The MMIO register to write.
404 @param Data The value to write to the MMIO register.
406 @return The value written the memory address.
419 *((volatile UINT16
*) Address
) = Data
;
426 Writes a 32-bit MMIO register.
428 Writes the 32-bit MMIO register specified by Address with the value specified
429 by Value and returns Value. This function must guarantee that all MMIO read
430 and write operations are serialized.
432 @param Address The MMIO register to write.
433 @param Data The value to write to the MMIO register.
435 @return The value written the memory address.
448 *((volatile UINT32
*) Address
) = Data
;
455 Writes a 64-bit MMIO register.
457 Writes the 64-bit MMIO register specified by Address with the value specified
458 by Value and returns Value. This function must guarantee that all MMIO read
459 and write operations are serialized.
461 @param Address The MMIO register to write.
462 @param Data The value to write to the MMIO register.
464 @return The value written the memory address.
477 *((volatile UINT64
*) Address
) = Data
;