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
Reverse DNS does not match SMTP Banner
Scheduled Tasks to perform daily export of W2K3 server Event Viewer Logs.......
Intermittent internet connectivity for PCs in small remote office
Strip out ’s in mySQL query | XML Parsing Error: undefined entity
Net Use returns "System error 64 has occurred. The specified network name is no longer available."
Deploying SharePoint project to Production Server
WRT54G2 Linksys router - reset password saving actual configuration
How to run db2 script from control center windows
Cannot pull Data from Oracle using SSIS
OS X Server 10.5 and OS X Laptops Joining accounts to Open Directory?