public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Accessing memory above 0xFFFFFFFF limit.
@ 2017-11-27 12:20 Amit kumar
  2017-11-27 15:34 ` Laszlo Ersek
  0 siblings, 1 reply; 2+ messages in thread
From: Amit kumar @ 2017-11-27 12:20 UTC (permalink / raw)
  To: edk2-devel@lists.01.org


Hi.
I am trying to allocate a mem buffer above 4Gb address but the allocation
since i am unable to locate EdkiiIoMmuProtocol.

Status = gBS->LocateProtocol (&gEdkiiIoMmuProtocolGuid, NULL, (VOID **)&mIoMmuProtocol);
      Status = mIoMmuProtocol->AllocateBuffer (
                   mIoMmuProtocol,
                   MaxAllocateType,
                   EfiBootServicesData,
                   1,
                  HostAddress,
                  EDKII_IOMMU_ATTRIBUTE_DUAL_ADDRESS_CYCLE
                  );

Best Regards
Amit Kumar



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

* Re: Accessing memory above 0xFFFFFFFF limit.
  2017-11-27 12:20 Accessing memory above 0xFFFFFFFF limit Amit kumar
@ 2017-11-27 15:34 ` Laszlo Ersek
  0 siblings, 0 replies; 2+ messages in thread
From: Laszlo Ersek @ 2017-11-27 15:34 UTC (permalink / raw)
  To: Amit kumar, edk2-devel@lists.01.org

On 11/27/17 13:20, Amit kumar wrote:
> 
> Hi.
> I am trying to allocate a mem buffer above 4Gb address but the allocation
> since i am unable to locate EdkiiIoMmuProtocol.
> 
> Status = gBS->LocateProtocol (&gEdkiiIoMmuProtocolGuid, NULL, (VOID **)&mIoMmuProtocol);
>       Status = mIoMmuProtocol->AllocateBuffer (
>                    mIoMmuProtocol,
>                    MaxAllocateType,
>                    EfiBootServicesData,
>                    1,
>                   HostAddress,
>                   EDKII_IOMMU_ATTRIBUTE_DUAL_ADDRESS_CYCLE
>                   );

PciHostBridgeDxe can perfectly well allocate >4GB memory for DMA
purposes even in the absence of the IOMMU protocol. For that, your PCI
device driver has to advertize the PCI device as 64-bit capable. In your
Driver Binding Start() function, call PciIo->Attributes() with the
EfiPciIoAttributeOperationEnable operation, and set
EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE. From the v2.7 UEFI spec (14.4
EFI PCI I/O Protocol):

    If this bit is set, then the PCI controller is capable of producing
    PCI Dual Address Cycles, so it is able to access a 64-bit address
    space. If this bit is not set, then the PCI controller is not
    capable of producing PCI Dual Address Cycles, so it is only able to
    access a 32-bit address space.

PciHostBridgeDxe will ignore the bit if the root bridge that the device
belongs to is generally uncapable of 64-bit access. Please see
"DmaAbove4G" in the PciHostBridgeLib interface:

  MdeModulePkg/Include/Library/PciHostBridgeLib.h

(You might notice that the PciHostBridgeDxe source code uses
EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE, but above I wrote
EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE. The PciBusDxe driver maps the
latter to the former, in the PciIoAllocateBuffer() function.)

Laszlo


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

end of thread, other threads:[~2017-11-27 15:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-27 12:20 Accessing memory above 0xFFFFFFFF limit Amit kumar
2017-11-27 15:34 ` Laszlo Ersek

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