PCI dext: scatter-gather DMA to application buffer

Hello,

I am porting a PCI driver written with IOKit to the new PCIDriverKit framework.

I am able to perform DMA with a contiguous buffer allocated inside the dext (with IOBufferMemoryDescriptor::Create).

But I would also like to perform DMA to and from a buffer allocated by an application.

What I exactly want to do is:

  • Allocate an aligned buffer in the app (with e.g. posix_memalign)
  • Send the pointer to this buffer to the dext
  • In the dext, retrieve the list of pages descriptors to be able to perform DMA without copy into (or from) this buffer.

In IOKit, we can use methods such IOMemoryDescriptor::withAddressRange and IODMACommand::gen64IOVMSegments to map and retrieve the scatter gather list but I cannot find any information on how to do this in a dext with the PCIDriverKit framework.

Can anybody help me on how to do that?