coco3431
coco3431

Reputation: 1

How do I use DMA in a macOS Kext?

I've been working on making a kext to access data on PCI BAR memory. Currently I am able to map the data and access it but its very slow. I'd like to use DMA to increase the speed at which I can communicate with the device, however I've been unable to find many good examples. I was looking at this page (https://opensource.apple.com/source/IOPCIFamily/IOPCIFamily-106/AppleSamplePCI/AppleSamplePCI.cpp.auto.html) but I'm unsure what should be placed where it says "if we had a DMA controller, kick off the DMA here." Does anyone have any good resources they would be willing to share?

Upvotes: 0

Views: 463

Answers (1)

pmdj
pmdj

Reputation: 23428

It's not entirely clear what you're asking here. DMA is generally triggered in a device-specific fashion. So, you memory-map a BAR (mapDeviceMemoryWithRegister() and friends); this "memory" will correspond to device registers, and you will typically bit-bang on these device registers to make the device do something, including performing DMA transfers. The layout and semantics of these registers are entirely device specific.

Incidentally, your question is tagged with the kernel-extension tag, but I should point out that PCI driver kernel extensions are now deprecated and it's possible to write PCI drivers using DriverKit. (Though not necessarily all kinds of PCI device drivers, the vast majority can now be done in user space.)

Upvotes: 1

Related Questions