the code i'm referring to is here
when i create a memory mapping for a pcidevice, i am always getting the same value for getPhysicalAddress and getVirtualAddress:e.g.
pciDevice = OSDynamicCast(IOPCIDevice, provider);deviceMap = pciDevice->mapDeviceMemoryWithRegister(kIOPCIConfigBaseAddress0);deviceRegisters = (struct oxygen *) deviceMap->getVirtualAddress();pciDevice->setMemoryEnable(true);pciDevice->setBusMasterEnable(true);deviceMap->getPhysicalAddress();
now, actually, i’m not too surprised by this because i think this is the point of “DMA”.
- if we have some kind of mapping in the driver, then one is all we need.
- that is, the physicaladdress is the virtual address as it’s the sole spot we need to do the “memory to memory” (cpu datastore to PCI sound card)
is this understanding correct?
now for the main issue: i am experiencing kernel panics that are caused caused by any access or assignment of deviceRegisters’ members, such as:
kprintf("Xonar Vendor ID:0x%04x, Device ID:0x%04x, SubDevice ID:0x%04x, Physical Address:%lu\n", vendor_id, dev_id, subdev_id, deviceRegisters->addr);
now that tells me something i am doing something wrong in terms of allocation since accessing members of this structure should not cause a panic.
however if you look at listing 3-2 here: https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/WritingAudioDrivers/ImplementDriver/ImplementDriver.html#//apple_ref/doc/uid/TP30000732-DontLinkElementID_15
this is exactly how it is supposed to be done.
a wise man (pmj) suggested i must use ioRead/Write functions to assign/access these values, but this does not really jive with the (admittedly old) skeleton code provided by apple. what could cause access issues to this memory mapping? surely having to do pointer arithmetic to assign/read values, while probably correct, is not the purpose of this design?