Re: Shared memory between kernel driver and multiple processes

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




In case you are talking about CE 6.0 (otherwise I can't explain
what VM routines like VirtualAllocCopyEx() do in your solutions
1 and 2), you don't have too much choice here. Either allocate
physically contiguous region in your kmode driver and map it to
the process, or use file mapping to map physically discontinuous
virtual memory.


Olivier M wrote:
Hi all,

I would like to allocate memory from a kernel driver (not necessarily
at driver load time) and arbitrarily map the memory to client
application processes. The memory must be readable and writable from
all processes that it's mapped to as well being accessible within the
kernel driver.

I have an idea about possible solutions but would like to understand
better what's best practice / possible etc.

- Solution 1: for kernel driver:
AllocPhysMem() gives a CPU relative physical address + Kernel CPU
virtual
VirtualAllocEx/VirtualCopyEx reserves arbitrary space in client process
and maps the physical address range to it.

-> This solution seems workable but relies on physically contiguous
memory - issues beyond boot time.

- Solution 2: for kernel driver:
HeapCreate()/HeapAlloc() create a kernel heap and allocate kernel CPU
virtual addresses from it
Use VirtualAllocCopyEx() to re-map memory to processes.

-> This solution doesn't depend on physically contiguous memory but I
doubt it's valid for VirtualAllocCopyEx to operate on kernel heap
allocations?

- Solution 3: File Mapping:
CreateFileMapping() / MapViewOfFile - kernel driver manages
allocations in a File mapping
User application processes can access kernel allocations in the file
mapping and have read/write access
-> Doesn't rely on physically contiguous memory although is not an
'orthogonal' solution compared to the way this is achieved in other
OSs (e.g. Linux). To give some background, WinCE is one of many OS
supported in a generic Driver Porting Software framework.

Any Feedback or advice is welcome

Thanks,
Olivier

.



Relevant Pages

  • Re: Shared memory between kernel driver and multiple processes
    ... VirtualAllocCopyEx() doesn't have to be used with physical ... memory addresses. ... I would like to allocate memory from a kernel driver (not necessarily ...
    (microsoft.public.windowsce.platbuilder)
  • Re: [2.4 patch] Port of adutux driver from 2.6 kernel to 2.4.
    ... I suspect you allocate 256 times more memory than necessary. ... Solution: Use minor_table_mutex to lock ... It's a problem with 2.6 kernel driver. ...
    (Linux-Kernel)
  • Shared memory between kernel driver and multiple processes
    ... I would like to allocate memory from a kernel driver (not necessarily ... Use VirtualAllocCopyEx() to re-map memory to processes. ... allocations in a File mapping ...
    (microsoft.public.windowsce.platbuilder)
  • AllocPhysMem Doubt
    ... memory into application for read/write. ... am using AllocPhysMem to allocate virtual and physical memory. ... VirtAddressToUsrSpace = VirtualAllocCopyEx( ... Application read/write access). ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Shared memory between kernel driver and multiple processes
    ... region in your kmode driver and map it to the process, or use file mapping to map ... physically discontinuous virtual memory. ... Is there an inherent overhead in creating Memory mapped files? ... And VirtualAllocCopyEx will take care ...
    (microsoft.public.windowsce.platbuilder)