I am trying to read data using a physical address on Apple Silicon MacOS. I think the best way is to convert the physical address to a virtual address and access it, or access it directly with the physical address.
I guess I could achieve this with IOKit (or kext). However, I couldn't find any documentation about the API or Syscall related to this. Could I please get some advice on this?
Thanks in advance.
From a kext, you can use
IOMemoryDescriptor::withPhysicalAddress()to create anIOMemoryDescriptor, which you can then map into any address space you want, either viamap()for the kernel's address space, orcreateMappingInTask()for userland processes.Example:
I wrote a kext not long ago that does exactly this, and exposes this functionality to userland via IOKit external methods, along with some convenience wrappers.