public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* How do I access Prefetchable Memory region through EFI_PCI_IO_PROTOCOL
@ 2018-09-14 18:24 Kirkendall, Garrett
  2018-09-16 10:19 ` Laszlo Ersek
  0 siblings, 1 reply; 4+ messages in thread
From: Kirkendall, Garrett @ 2018-09-14 18:24 UTC (permalink / raw)
  To: edk2-devel@lists.01.org

Hopefully someone can help me understand.

I assume I should be able to access MMIO pointed to by a PCI devices Prefetchable Memory BAR.  I would think I would use EFI_PCI_IO_PROTOCOL.Mem.Read or Write.  This in turn will send the request up to EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Mem.Read or Write.  

MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c: RootBridgeIoMemRead (Write) calls RootBridgeIoCheckParameter() to verify that the request falls within the confines of the PCI root bridge.  The below code verifies the address against non-prefetchable MMIO regions and skips the prefetchable memory regions.  Is this correct, and if so what is the method to read/write prefetchable memory regions?  If I force EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM, then I can access prefetchable memory regions because they are forced within Mem.* and MemAbove4G.*



EFI_STATUS
RootBridgeIoCheckParameter (
  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,
  IN OPERATION_TYPE                         OperationType,
  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,
  IN UINT64                                 Address,
  IN UINTN                                  Count,
  IN VOID                                   *Buffer
  )
{
...
  } else if (OperationType == MemOperation) {
    //
    // Allow Legacy MMIO access
    //
    if ((Address >= 0xA0000) && (Address + MultU64x32 (Count, Size)) <= 0xC0000) {
      if ((RootBridge->Attributes & EFI_PCI_ATTRIBUTE_VGA_MEMORY) != 0) {
        return EFI_SUCCESS;
      }
    }
    //
    // By comparing the Address against Limit we know which range to be used
    // for checking
    //
    if (Address + MultU64x32 (Count, Size) <= RootBridge->Mem.Limit + 1) {
      Base = RootBridge->Mem.Base;
      Limit = RootBridge->Mem.Limit;
    } else {
      Base = RootBridge->MemAbove4G.Base;
      Limit = RootBridge->MemAbove4G.Limit;
    }
  } else {
...

GARRETT KIRKENDALL
SMTS Firmware Engineer | CTE
7171 Southwest Parkway, Austin, TX 78735 USA 
AMD   facebook  |  amd.com



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-21  7:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-14 18:24 How do I access Prefetchable Memory region through EFI_PCI_IO_PROTOCOL Kirkendall, Garrett
2018-09-16 10:19 ` Laszlo Ersek
2018-09-19  1:53   ` Kirkendall, Garrett
2018-09-21  7:25     ` Ni, Ruiyu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox