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.
17 static EFI_CPU_IO_PROTOCOL
*gCpuIo
;
21 IN EFI_HANDLE ImageHandle
,
22 IN EFI_SYSTEM_TABLE
*SystemTable
27 Status
= SystemTable
->BootServices
->LocateProtocol (
28 &gEfiCpuIoProtocolGuid
,
32 ASSERT_EFI_ERROR (Status
);
40 IN EFI_CPU_IO_PROTOCOL_WIDTH Width
45 gCpuIo
->Io
.Read (gCpuIo
, Width
, Port
, 1, &Data
);
53 IN EFI_CPU_IO_PROTOCOL_WIDTH Width
,
57 gCpuIo
->Io
.Write (gCpuIo
, Width
, Port
, 1, &Data
);
65 IN EFI_CPU_IO_PROTOCOL_WIDTH Width
70 gCpuIo
->Mem
.Read (gCpuIo
, Width
, Address
, 1, &Data
);
78 IN EFI_CPU_IO_PROTOCOL_WIDTH Width
,
82 gCpuIo
->Mem
.Write (gCpuIo
, Width
, Address
, 1, &Data
);
87 Reads an 8-bit I/O port.
89 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
90 This function must guarantee that all I/O read and write operations are
93 If 8-bit I/O port operations are not supported, then ASSERT().
95 @param Port The I/O port to read.
97 @return The value read.
106 return (UINT8
)IoReadWorker (Port
, EfiCpuIoWidthUint8
);
110 Writes an 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 If 8-bit I/O port operations are not supported, then ASSERT().
118 @param Port The I/O port to write.
119 @param Value The value to write to the I/O port.
121 @return The value written the I/O port.
131 return (UINT8
)IoWriteWorker (Port
, EfiCpuIoWidthUint8
, Value
);
135 Reads a 16-bit I/O port.
137 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
138 This function must guarantee that all I/O read and write operations are
141 If 16-bit I/O port operations are not supported, then ASSERT().
143 @param Port The I/O port to read.
145 @return The value read.
154 return (UINT16
)IoReadWorker (Port
, EfiCpuIoWidthUint16
);
158 Writes a 16-bit I/O port.
160 Writes the 16-bit I/O port specified by Port with the value specified by Value
161 and returns Value. This function must guarantee that all I/O read and write
162 operations are serialized.
164 If 16-bit I/O port operations are not supported, then ASSERT().
166 @param Port The I/O port to write.
167 @param Value The value to write to the I/O port.
169 @return The value written the I/O port.
179 return (UINT16
)IoWriteWorker (Port
, EfiCpuIoWidthUint16
, Value
);
183 Reads a 32-bit I/O port.
185 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
186 This function must guarantee that all I/O read and write operations are
189 If 32-bit I/O port operations are not supported, then ASSERT().
191 @param Port The I/O port to read.
193 @return The value read.
202 return (UINT32
)IoReadWorker (Port
, EfiCpuIoWidthUint32
);
206 Writes a 32-bit I/O port.
208 Writes the 32-bit I/O port specified by Port with the value specified by Value
209 and returns Value. This function must guarantee that all I/O read and write
210 operations are serialized.
212 If 32-bit I/O port operations are not supported, then ASSERT().
214 @param Port The I/O port to write.
215 @param Value The value to write to the I/O port.
217 @return The value written the I/O port.
227 return (UINT32
)IoWriteWorker (Port
, EfiCpuIoWidthUint32
, Value
);
231 Reads a 64-bit I/O port.
233 Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
234 This function must guarantee that all I/O read and write operations are
237 If 64-bit I/O port operations are not supported, then ASSERT().
239 @param Port The I/O port to read.
241 @return The value read.
250 return IoReadWorker (Port
, EfiCpuIoWidthUint64
);
254 Writes a 64-bit I/O port.
256 Writes the 64-bit I/O port specified by Port with the value specified by Value
257 and returns Value. This function must guarantee that all I/O read and write
258 operations are serialized.
260 If 64-bit I/O port operations are not supported, then ASSERT().
262 @param Port The I/O port to write.
263 @param Value The value to write to the I/O port.
265 @return The value written the I/O port.
275 return IoWriteWorker (Port
, EfiCpuIoWidthUint64
, Value
);
279 Reads an 8-bit MMIO register.
281 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
282 returned. This function must guarantee that all MMIO read and write
283 operations are serialized.
285 If 8-bit MMIO register operations are not supported, then ASSERT().
287 @param Address The MMIO register to read.
289 @return The value read.
298 return (UINT8
)MmioReadWorker (Address
, EfiCpuIoWidthUint8
);
302 Writes an 8-bit MMIO register.
304 Writes the 8-bit MMIO register specified by Address with the value specified
305 by Value and returns Value. This function must guarantee that all MMIO read
306 and write operations are serialized.
308 If 8-bit MMIO register operations are not supported, then ASSERT().
310 @param Address The MMIO register to write.
311 @param Value The value to write to the MMIO register.
321 return (UINT8
)MmioWriteWorker (Address
, EfiCpuIoWidthUint8
, Value
);
325 Reads a 16-bit MMIO register.
327 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
328 returned. This function must guarantee that all MMIO read and write
329 operations are serialized.
331 If 16-bit MMIO register operations are not supported, then ASSERT().
333 @param Address The MMIO register to read.
335 @return The value read.
344 return (UINT16
)MmioReadWorker (Address
, EfiCpuIoWidthUint16
);
348 Writes a 16-bit MMIO register.
350 Writes the 16-bit MMIO register specified by Address with the value specified
351 by Value and returns Value. This function must guarantee that all MMIO read
352 and write operations are serialized.
354 If 16-bit MMIO register operations are not supported, then ASSERT().
356 @param Address The MMIO register to write.
357 @param Value The value to write to the MMIO register.
367 return (UINT16
)MmioWriteWorker (Address
, EfiCpuIoWidthUint16
, Value
);
371 Reads a 32-bit MMIO register.
373 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
374 returned. This function must guarantee that all MMIO read and write
375 operations are serialized.
377 If 32-bit MMIO register operations are not supported, then ASSERT().
379 @param Address The MMIO register to read.
381 @return The value read.
390 return (UINT32
)MmioReadWorker (Address
, EfiCpuIoWidthUint32
);
394 Writes a 32-bit MMIO register.
396 Writes the 32-bit MMIO register specified by Address with the value specified
397 by Value and returns Value. This function must guarantee that all MMIO read
398 and write operations are serialized.
400 If 32-bit MMIO register operations are not supported, then ASSERT().
402 @param Address The MMIO register to write.
403 @param Value The value to write to the MMIO register.
413 return (UINT32
)MmioWriteWorker (Address
, EfiCpuIoWidthUint32
, Value
);
417 Reads a 64-bit MMIO register.
419 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
420 returned. This function must guarantee that all MMIO read and write
421 operations are serialized.
423 If 64-bit MMIO register operations are not supported, then ASSERT().
425 @param Address The MMIO register to read.
427 @return The value read.
436 return (UINT64
)MmioReadWorker (Address
, EfiCpuIoWidthUint64
);
440 Writes a 64-bit MMIO register.
442 Writes the 64-bit MMIO register specified by Address with the value specified
443 by Value and returns Value. This function must guarantee that all MMIO read
444 and write operations are serialized.
446 If 64-bit MMIO register operations are not supported, then ASSERT().
448 @param Address The MMIO register to write.
449 @param Value The value to write to the MMIO register.
459 return (UINT64
)MmioWriteWorker (Address
, EfiCpuIoWidthUint64
, Value
);