We have a custom platform with a lot of special-purpose hardware on it.
Under
CE 6.0, all of the hardware access must be done by a device driver. I wrote
one to wrap our hardware, but it sure would be better for us if our
application
could access the hardware directly.

Is there a way to do this in WinCE 6.0? Could I write a device driver that
would map the physical addresses to a calling process's virtual address
space? (if so, what API would do that for me?)

Or, could I somehow trick the User Mode Driver Framework into thinking
that my application is a driver?

thanks.

Re: Hardware Access from Application by Steve

Steve
Wed Oct 31 10:23:33 PDT 2007

I found the answer from a microsoft chat.

AllocPhysicalMem() then VirtualCopyEx().



Re: Hardware Access from Application by Silver

Silver
Wed Oct 31 12:40:31 PDT 2007

AllocPhysicalMem is not what you want, it will actually allocate memory
space in RAM.

Try using MmMapIoSpace, this uses VirtualAlloc/VirtualCopy to give a
virtual pointer to the address region desired.
You may need to translate the bus address first, HalTranslateBusAddress.

Geoff
--


Re: Hardware Access from Application by Steve

Steve
Wed Oct 31 12:56:36 PDT 2007

If I specify the physical address of my hardware on my platform, then won't
AllocPhysMem() just map the range regardless of if it is truly RAM or
something else? My hardware is connected directly to the system bus on a
PXA270.

Am I confused?


"Silver" <moc.liamtoh@gnirrevliseht> wrote in message
news:eO38rX$GIHA.3916@TK2MSFTNGP02.phx.gbl...
> AllocPhysicalMem is not what you want, it will actually allocate memory
> space in RAM.
>
> Try using MmMapIoSpace, this uses VirtualAlloc/VirtualCopy to give a
> virtual pointer to the address region desired.
> You may need to translate the bus address first, HalTranslateBusAddress.
>
> Geoff
> --
>



Re: Hardware Access from Application by voidcoder

voidcoder
Wed Oct 31 16:34:12 PDT 2007


AllocPhysMem() does exactly what the name implies,
it allocates a physically contiguous memory region
at some address (simply picks the first unused
contiguous chunk of pages) in system RAM and
returns the physical address of the memory location.
It is definitely not what you want.

I believe the only way to get direct access to the
hardware from the user mode app in 6.0 is to reserve
a range of pages in user mode (VirtualAlloc) and then
pass the address to kernel mode where you can commit
the region of physical pages representing your hardware
memory (VirtualAllocCopyEx) to the reserved region.


--
Oleg


Steve Araiza wrote:
> If I specify the physical address of my hardware on my platform, then won't
> AllocPhysMem() just map the range regardless of if it is truly RAM or
> something else? My hardware is connected directly to the system bus on a
> PXA270.
>
> Am I confused?
>
>
> "Silver" <moc.liamtoh@gnirrevliseht> wrote in message
> news:eO38rX$GIHA.3916@TK2MSFTNGP02.phx.gbl...
>> AllocPhysicalMem is not what you want, it will actually allocate memory
>> space in RAM.
>>
>> Try using MmMapIoSpace, this uses VirtualAlloc/VirtualCopy to give a
>> virtual pointer to the address region desired.
>> You may need to translate the bus address first, HalTranslateBusAddress.
>>
>> Geoff
>> --
>>
>
>

Re: Hardware Access from Application by Steve

Steve
Thu Nov 01 05:12:41 PDT 2007

You were right, I was confused. The pPhysicalAddress parameter to
AllocPhysMem() is an output, not an input. So I need to use something else.