I'm trying to prepare a buffer for DMA, but PrepareForDMA always fails with error 0xe00002c2 - kIOReturnBadArgument.
I've watched the WWDC20 session, but I'm not sure what I'm doing wrong - any help much appreciated!
constexpr auto bufferSize = 1024u;
struct DMABufferInfo {
IOBufferMemoryDescriptor* descriptor;
IODMACommand* command;
uint32_t segmentsCount;
IOAddressSegment segments[32];
uint64_t flags;
};
struct Driver_IVars
{
IOPCIDevice* device;
DMABufferInfo bufferInfo;
}
...
kern_return_t
IMPL(Driver, Start)
{
		/*
		 * Successfully opens device
		 * Writes to PCIDevice command register
		 */
		...
		os_log(OS_LOG_DEFAULT, "Allocating buffer...");
ret = IOBufferMemoryDescriptor::Create(
		 kIOMemoryDirectionOut,
		 bufferSize,
0,
&ivars->bufferInfo.descriptor
);
\__Require(ret == kIOReturnSuccess, Exit);
		ret = ivars->bufferInfo.descriptor->SetLength(bufferSize);
		\__Require(ret == kIOReturnSuccess, Exit);
		os_log(OS_LOG_DEFAULT, "Creating IODMACommand...");
		IODMACommandSpecification dmaSpecification;
		bzero(&dmaSpecification, sizeof(dmaSpecification));
		dmaSpecification.options = kIODMACommandSpecificationNoOptions;
		dmaSpecification.maxAddressBits = 64;
IODMACommand::Create(
				ivars->device,
				kIODMACommandCreateNoOptions,
				&dmaSpecification,
				&ivars->bufferInfo.command
		);
\__Require(ret == kIOReturnSuccess, Exit);
os_log(OS_LOG_DEFAULT, "Preparing For DMA...");
ret = ivars->bufferInfo.command->PrepareForDMA(
				kIODMACommandPrepareForDMANoOptions,
				ivars->bufferInfo.descriptor,
				0,
				0,
				&ivars->bufferInfo.flags,
				&ivars->bufferInfo.segmentsCount,
				ivars->bufferInfo.segments
		);
		\__Require(ret == kIOReturnSuccess, Exit);
		os_log(OS_LOG_DEFAULT, "Prepared buffer for DMA");
Exit:
		os_log(OS_LOG_DEFAULT, "Exiting: %s, ret = %#010x",\__FUNCTION\__, ret);
		return ret;
}
Log output:
Allocating playback buffer...
Creating IODMACommand...
Preparing For DMA...
Exiting: Start_Impl, ret = 0xe00002c2
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I've been trying to create a Provisioning Profile through the developer "Certificates, Identifiers & Profiles" webpage. The Profile will provide our DriverKit development entitlements.
I am able to select the Type, the App ID, Certificates and Entitlements without problems.
However, when I go to click the final "Generate" button it spins for a couple of seconds and then stops. No error message is presented, and it never proceeds to the "Download" step.
Any ideas what could cause this and how to resolve it?