2010-02-24 00:58:38 +01:00
|
|
|
## @file
|
2014-08-28 07:09:12 +02:00
|
|
|
# Produces the CPU I/O 2 Protocol by using the services of the I/O Library.
|
2009-12-07 04:09:04 +01:00
|
|
|
#
|
2018-06-27 15:14:20 +02:00
|
|
|
# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
|
2017-01-13 21:09:52 +01:00
|
|
|
# Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
|
|
|
|
#
|
2010-04-24 14:25:26 +02:00
|
|
|
# This program and the accompanying materials
|
2009-12-07 04:09:04 +01:00
|
|
|
# are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
# which accompanies this distribution. The full text of the license may be found at
|
|
|
|
# http://opensource.org/licenses/bsd-license.php
|
2010-01-14 23:14:50 +01:00
|
|
|
#
|
2009-12-07 04:09:04 +01:00
|
|
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
#
|
2010-02-24 00:58:38 +01:00
|
|
|
##
|
2009-12-07 04:09:04 +01:00
|
|
|
|
|
|
|
[Defines]
|
|
|
|
INF_VERSION = 0x00010005
|
|
|
|
BASE_NAME = CpuIo2Dxe
|
2014-08-28 07:09:12 +02:00
|
|
|
MODULE_UNI_FILE = CpuIo2Dxe.uni
|
2009-12-07 04:09:04 +01:00
|
|
|
FILE_GUID = A19B1FE7-C1BC-49F8-875F-54A5D542443F
|
|
|
|
MODULE_TYPE = DXE_DRIVER
|
2018-06-27 15:14:20 +02:00
|
|
|
VERSION_STRING = 1.0
|
2009-12-07 04:09:04 +01:00
|
|
|
ENTRY_POINT = CpuIo2Initialize
|
|
|
|
|
|
|
|
#
|
|
|
|
# The following information is for reference only and not required by the build tools.
|
|
|
|
#
|
2018-06-29 05:38:37 +02:00
|
|
|
# VALID_ARCHITECTURES = IA32 X64 EBC
|
2009-12-07 04:09:04 +01:00
|
|
|
#
|
|
|
|
|
2010-01-14 23:14:50 +01:00
|
|
|
[Sources]
|
2009-12-07 04:09:04 +01:00
|
|
|
CpuIo2Dxe.c
|
2010-07-13 05:08:54 +02:00
|
|
|
CpuIo2Dxe.h
|
UefiCpuPkg: CpuIo2Dxe: optimize FIFO reads and writes of IO ports
* Short description:
The CpuIoServiceRead() and CpuIoServiceWrite() functions transfer data
between memory and IO ports with individual Io(Read|Write)(8|16|32)
function calls, each in an appropriately set up loop.
On the Ia32 and X64 platforms however, FIFO reads and writes can be
optimized, by coding them in assembly, and delegating the loop to the
CPU, with the REP prefix.
On KVM virtualization hosts, this difference has a huge performance
impact: if the loop is open-coded, then the virtual machine traps to the
hypervisor on every single UINT8 / UINT16 / UINT32 transfer, whereas
with the REP prefix, KVM can transfer up to a page of data per VM trap.
This is especially noticeable with IDE PIO transfers, where all the data
are squeezed through IO ports.
* Long description:
The RootBridgeIoIoRW() function in
PcAtChipsetPkg/PciHostBridgeDxe/PciRootBridgeIo.c
used to have the exact same IO port acces optimization, dating back
verbatim to commit 1fd376d9792:
PcAtChipsetPkg/PciHostBridgeDxe: Improve KVM FIFO I/O read/write
performance
OvmfPkg cloned the "PcAtChipsetPkg/PciHostBridgeDxe" driver (for
unrelated reasons), and inherited the optimization from PcAtChipsetPkg.
The "PcAtChipsetPkg/PciHostBridgeDxe" driver was ultimately removed in
commit 111d79db47:
PcAtChipsetPkg/PciHostBridge: Remove PciHostBridge driver
and OvmfPkg too was rebased to the new core Pci Host Bridge Driver, in
commit 4014885ffd:
OvmfPkg: switch to MdeModulePkg/Bus/Pci/PciHostBridgeDxe
This caused the optimization to go lost. Namely, the
RootBridgeIoIoRead() and RootBridgeIoIoWrite() functions in the new core
Pci Host Bridge Driver delegate IO port accesses to
EFI_CPU_IO2_PROTOCOL. And, in OvmfPkg (and likely most other Ia32 / X64
edk2 platforms), this protocol is provided by "UefiCpuPkg/CpuIo2Dxe",
which lacks the optimization.
Therefore, this patch ports the C source code logic from commit
1fd376d9792 (see above) to "UefiCpuPkg/CpuIo2Dxe", plus it ports the
NASM-converted assembly helper functions from OvmfPkg commits
6026bf460037 and ace1d0517b65:
OvmfPkg PciHostBridgeDxe: Convert Ia32/IoFifo.asm to NASM
OvmfPkg PciHostBridgeDxe: Convert X64/IoFifo.asm to NASM
In order to support the MSFT and INTEL toolchains as well, the *.asm
files are ported from OvmfPkg as well, immediately from before the above
conversion (that is, at 6026bf460037^).
* Notes about the port:
- The write and read branches from commit 1fd376d9792 are split to the
separate functions CpuIoServiceWrite() and CpuIoServiceRead().
- The EfiPciWidthUintXX constants are replaced with EfiCpuIoWidthUintXX.
- The cast expression "(UINTN) Address" is replaced with
"(UINTN)Address" (i.e., no space), because that's how the receiving
functions spell it as well.
- The labels in the switch statements are unindented by one level, to
match the edk2 coding style (and the rest of UefiCpuPkg) better.
* The first signoff belongs to Jordan, because he authored all of
1fd376d9792, 6026bf460037 and ace1d0517b65.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Ref: https://www.redhat.com/archives/vfio-users/2016-April/msg00029.html
Reported-by: Mark <kram321@gmail.com>
Ref: http://thread.gmane.org/gmane.comp.bios.edk2.devel/10424/focus=10432
Reported-by: Jordan Justen <jordan.l.justen@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Mark <kram321@gmail.com>
Tested-by: Mark <kram321@gmail.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
2016-04-07 22:28:38 +02:00
|
|
|
|
2009-12-07 04:09:04 +01:00
|
|
|
[Packages]
|
|
|
|
MdePkg/MdePkg.dec
|
|
|
|
|
|
|
|
[LibraryClasses]
|
|
|
|
UefiDriverEntryPoint
|
2010-01-14 23:14:50 +01:00
|
|
|
BaseLib
|
2009-12-07 04:09:04 +01:00
|
|
|
DebugLib
|
2010-01-14 23:14:50 +01:00
|
|
|
IoLib
|
|
|
|
UefiBootServicesTableLib
|
2009-12-07 04:09:04 +01:00
|
|
|
|
|
|
|
[Protocols]
|
|
|
|
gEfiCpuIo2ProtocolGuid ## PRODUCES
|
|
|
|
|
|
|
|
[Depex]
|
|
|
|
TRUE
|
2014-08-28 07:09:12 +02:00
|
|
|
|
|
|
|
[UserExtensions.TianoCore."ExtraFiles"]
|
|
|
|
CpuIo2DxeExtra.uni
|