HalAllocateCommonBuffer & MmMapIoSpace problem



Hello to you,

I need help with a problem in ce 5.0 + pxa270

I wrote a driver which uses dma, so it calls HalAllocateCommonBuffer
to get a suitable address.

An application that opens the driver calls a DeviceIoControl to get
the physical address of the buffer and then MmMapIoSpace to read the
data.

When the application calls MmUnmapIoSpace, I get the message:
..... NK Kernel: DEBUGCHK failed in file d:\macallan\private\winceos
\coreos\nk\kernel\physmem.c at line 907

VirtualAlloc / VirtualCopy shows the same error

If I add MmMapIoSpace in the driver, the problem moves to the time
when the application closes the driver and it calls MmUnmapIoSpace,
that is, the first invocation of MmUnmapIoSpace (made by the
application) succeeds but the second fails (the driver calls
MmUnmapIoSpace before calling HalFreeCommonBuffer, to reverse the
ordering the calls).


Can you give me an advice about this?
Thank you very much
.