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
Can I use the SendKeys command in Excel VBA to interact with other applications other that Microsoft Office?
Request for the permission of type 'System.Net.Mail.SmtpPermi
ssion, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c56193
4e089' failed
dlookup error in access
Delete shortcut from all users desktop via script
Ho to customize flash paper interface
How do I read Metastock data using C#?
Some email bypassing spam filter
Replacing Keyboard on Toshiba Portege A600
Post data back to jquery
SQL Statement. Copy and paste characters from cell into another in same record