Microsoft
Software
Hardware
Network
Question : Exporting kernel memory to user space using devmap_umem_setup
Hi,
I have a simple pseudo driver pretty much copied off the "Writing Device Drivers" tutorial. What i was trying to achieve was allocating and exporting kernel memory from this driver to the user space app. I'm not interested in exporting device memory hence i only used devmap_umem_setup in the devmap() entry point. I have a user space app that calls mmap to invoke the devmap routine. Based on the return values of all the routines involved both in the driver such as ddi_umem_alloc, devmap_setup, devmap_umem_setup and the mmap call in the user app it appears the mapping is successful. However when i set something in the user app at that memory address returned by mmap, i am not able to read it back from the driver using the ddi_umem_cookie_t. The value read back in the driver pointed to by the cookie is different than the one set by the user space app. I'm not using any offsets both in mmap and devmap_umem_setup (passing 0) and the length being passed is 4096. My question is does the ddi_umem_cookie_t set by ddi_umem_alloc point to the same memory location (after whatever address translations that need to happen) that mmap call will return given that the offsets are 0 and length is 1 page size (4096) and the addr in mmap is 0.
user app:
fd=open("/devices/pseudo/d
ummy@0:0",
O_RDWR);
mapadd = mmap64(0, len, (PROT_READ|PROT_WRITE),
MAP_SHARED, fd, 0);
driver:
xsp->umem = ddi_umem_alloc(8192,
DDI_UMEM_SLEEP | DDI_UMEM_PAGEABLE, &(xsp->ucookie));
error = devmap_setup(dev, 0, asp, addrp, 4096,
prot, maxprot, flags, credp);
error = devmap_umem_setup(handle, xsp->dip, NULL, xsp->ucookie,
0, 4096, PROT_ALL, DEVMAP_DEFAULTS, NULL);
My understanding was that i would be able to access the memory pointed to xsp->ucookie (kernel space) as well as from the mapadd (user space) but that does not seem to be the case
Any help would be much appreciated.
Thanks
Answer : Exporting kernel memory to user space using devmap_umem_setup
I think from the kernel side, you want to access the memory locations pointed to by xsp->umem. If that doesn't work, could you post the whole driver?
Random Solutions
How do I write data to separate excel worksheets in coldfusion?
Crystal report 2008, draw graph with huge of data.
Using multiple routers - BEFVP41 VPN Router, Netgear WDR3700
Cisco VPN client for Windows, use both RSA SecurID soft token and hard token
Assigning a GPO to specific users and one Server only ?
Is there a tool to check to see who has enabled auto-forward in outlook
How to improve the email performance in C#
How do I setup my domain controller to keep the correct time on my domain?
MS Access SQL Divide by Zero workaround needed
Proxy? Do I have to?