Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement api to convert pci address to host address #117

Closed
wants to merge 1 commit into from

Conversation

pankajbansalnxp
Copy link

The PCI device address may not be same as host address (CPU view address)
To read/write directly to PCI device's BARs (without using
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Mem.Read() and
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Mem.Write()) we need to convert PCI
device address to host address.

The UEFI specifications 2.7 provide a method to translate the PCI device
address to host address and vice versa.

device address = host address + translation offset

EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Configuration() method can provide us with
the translation offset and host address range.

Using this we can convert the PCI device address to host address.

Signed-off-by: Pankaj Bansal pankaj.bansal@nxp.com

The PCI device address may not be same as host address (CPU view address)
To read/write directly to PCI device's BARs (without using
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Mem.Read() and
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Mem.Write()) we need to convert PCI
device address to host address.

The UEFI specifications 2.7 provide a method to translate the PCI device
address to host address and vice versa.

device address = host address + translation offset

EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Configuration() method can provide us with
the translation offset and host address range.

Using this we can convert the PCI device address to host address.

Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
@mcb30
Copy link
Member

mcb30 commented Aug 3, 2020

So, this looks like a generally good idea to have. However:

  • there would also need to be implementations for each of the other PCI APIs (pcibios and pcidirect)
  • something would need to actually use the API; at the moment it's purely unused code

@pankajbansalnxp
Copy link
Author

@mcb30 : i have used this patch to create an intel e1000 PCIE NIC efi driver. like this:

commit c32de21f035e57c56824fef5dac036a22a2f3e2a (HEAD -> github/master)
Author: Pankaj Bansal pankaj.bansal@nxp.com
Date: Fri Jul 3 12:00:45 2020 -0500

use pci_ioremap

Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>

diff --git a/src/drivers/net/intel.c b/src/drivers/net/intel.c
index d9b8b46b..17be5f63 100644
--- a/src/drivers/net/intel.c
+++ b/src/drivers/net/intel.c
@@ -959,7 +959,8 @@ static int intel_probe ( struct pci_device *pci ) {
adjust_pci_device ( pci );

    /* Map registers */
  •   intel->regs = ioremap ( pci->membase, INTEL_BAR_SIZE );
    
  •   intel->regs = ioremap ( pci_ioremap ( pci, pci->membase, INTEL_BAR_SIZE ),
    
  •                           INTEL_BAR_SIZE );
      if ( ! intel->regs ) {
              rc = -ENODEV;
              goto err_ioremap;
    

I did not submit this patch because i did not know if this would cause any issues with any existing functionality or not?
I am fairly new to ipxe code and still not familiar with many of it's features and functions.

@mcb30 mcb30 self-assigned this Sep 24, 2020
@mcb30 mcb30 mentioned this pull request Sep 25, 2020
@mcb30 mcb30 closed this in #146 Sep 25, 2020
@mcb30
Copy link
Member

mcb30 commented Sep 25, 2020

@pankajbansalnxp Thank you for contributing this. I have implemented equivalent functionality in #146 and updated all PCI drivers to use it. Please let me know if this does not work for you.

@zube zube bot removed the [zube]: Done label Dec 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants