2 Common I/O Library routines.
4 Copyright (c) 2006, 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 BIT63 0x8000000000000000ULL
19 #define MAP_PORT_BASE_TO_MEM(_Port) \
20 ((((_Port) & 0xfffc) << 10) | ((_Port) & 0x0fff))
23 Reads a 8-bit I/O port.
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
29 @param Port The I/O port to read.
31 @return The value read.
43 // Add the 64MB aligned IO Port space to the IO address
45 Address
= MAP_PORT_BASE_TO_MEM (Port
);
46 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
48 return MmioRead8 (Address
);
52 Reads a 16-bit I/O port.
54 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
55 This function must guarantee that all I/O read and write operations are
58 @param Port The I/O port to read.
60 @return The value read.
72 // Add the 64MB aligned IO Port space to the IO address
74 Address
= MAP_PORT_BASE_TO_MEM (Port
);
75 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
77 return MmioRead16 (Address
);
81 Reads a 32-bit I/O port.
83 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
84 This function must guarantee that all I/O read and write operations are
87 @param Port The I/O port to read.
89 @return The value read.
101 // Add the 64MB aligned IO Port space to the IO address
103 Address
= MAP_PORT_BASE_TO_MEM (Port
);
104 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
106 return MmioRead32 (Address
);
110 Writes a 8-bit I/O port.
112 Writes the 8-bit I/O port specified by Port with the value specified by Value
113 and returns Value. This function must guarantee that all I/O read and write
114 operations are serialized.
116 @param Port The I/O port to write.
117 @param Value The value to write to the I/O port.
119 @return The value written the I/O port.
132 // Add the 64MB aligned IO Port space to the IO address
134 Address
= MAP_PORT_BASE_TO_MEM (Port
);
135 Address
+= PcdGet64(PcdIoBlockBaseAddressForIpf
);
137 return MmioWrite8 (Address
, Data
);
141 Writes a 16-bit I/O port.
143 Writes the 16-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 MmioWrite16 (Address
, Data
);
172 Writes a 32-bit I/O port.
174 Writes the 32-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 MmioWrite32 (Address
, Data
);
203 Reads a 8-bit MMIO register.
205 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
206 returned. This function must guarantee that all MMIO read and write
207 operations are serialized.
209 @param Address The MMIO register to read.
211 @return The value read.
225 Data
= *((volatile UINT8
*) Address
);
232 Reads a 16-bit MMIO register.
234 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
235 returned. This function must guarantee that all MMIO read and write
236 operations are serialized.
238 @param Address The MMIO register to read.
240 @return The value read.
254 Data
= *((volatile UINT16
*) Address
);
261 Reads a 32-bit MMIO register.
263 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
264 returned. This function must guarantee that all MMIO read and write
265 operations are serialized.
267 @param Address The MMIO register to read.
269 @return The value read.
283 Data
= *((volatile UINT32
*) Address
);
290 Reads a 64-bit MMIO register.
292 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
293 returned. This function must guarantee that all MMIO read and write
294 operations are serialized.
296 @param Address The MMIO register to read.
298 @return The value read.
312 Data
= *((volatile UINT64
*) Address
);
320 Writes a 8-bit MMIO register.
322 Writes the 8-bit MMIO register specified by Address with the value specified
323 by Value and returns Value. This function must guarantee that all MMIO read
324 and write operations are serialized.
326 @param Address The MMIO register to write.
327 @param Data The value to write to the MMIO register.
329 @return The value written the memory address.
342 *((volatile UINT8
*) Address
) = Data
;
349 Writes a 16-bit MMIO register.
351 Writes the 16-bit MMIO register specified by Address with the value specified
352 by Value and returns Value. This function must guarantee that all MMIO read
353 and write operations are serialized.
355 @param Address The MMIO register to write.
356 @param Data The value to write to the MMIO register.
358 @return The value written the memory address.
371 *((volatile UINT16
*) Address
) = Data
;
378 Writes a 32-bit MMIO register.
380 Writes the 32-bit MMIO register specified by Address with the value specified
381 by Value and returns Value. This function must guarantee that all MMIO read
382 and write operations are serialized.
384 @param Address The MMIO register to write.
385 @param Data The value to write to the MMIO register.
387 @return The value written the memory address.
400 *((volatile UINT32
*) Address
) = Data
;
407 Writes a 64-bit MMIO register.
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.
413 @param Address The MMIO register to write.
414 @param Data The value to write to the MMIO register.
416 @return The value written the memory address.
429 *((volatile UINT64
*) Address
) = Data
;