Equivalent API to MmGetPhysicalAddress in WEC7

209 views Asked by At

I am porting Windows 7 Network driver code to WEC7. I got stuck with the API MmGetPhysicalAddress. I didn't find equivalent API to this in WEC7. Can anyone help to proceed further..

Thanks.

2

There are 2 answers

2
Carsten Hansen On

MmGetPhysicalAddress is not available in Windows CE, but you probably don't need it anyway.

Somewhere in the InitializeHandlerEx callback, the driver should be calling NdisMAllocateSharedMemory to allocate RX/TX buffers.

NdisMAllocateSharedMemory returns both the virtual and physical address of the allocated buffer, so you can keep the physical address around, and then there won't be any need to request it from the OS.

Normally the physical address would be kept in a driver-specific, per-buffer structure along with the virtual buffer address.

You can find a sample implementation of this in C:\WINCE700\public\COMMON\oak\drivers\netcard\e100bex\60. In mp_init.c, notice how NICAllocAdapterMemory calls NdisMAllocateSharedMemory and stores the physical address of each buffer in pMpTxbuf->BufferPa.

2
Valter Minute On

You may have a look at LockPages: https://msdn.microsoft.com/en-us/library/ee482989.aspx But if the buffer was not allocated using NDIS functions it may not be fully contiguous in physical memory, so you may need to check that.