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
ORACLE SQL similarity with SQL Server
ADmodify.exe "mailbox rights modification disabled" ??
Repeater Enable/Disable RequiredFieldValidator depending a textbox
"outlook.ost cannot be accessed because it has been configured for usw with a different mailbox"
How to reset the sametime password for a single user
Password recovery on Juniper SA2500
How do I change the default Domain extension for SBS 2008 in Exchange for all users?
Windows Service crashing on one machine, not on the other
"microsoft exchange offline address book" creates synchronization error log
unable to scan with my HP Photosmart All-in-one printer