Hi,
I have used the memory mapped code like below while mapping the device resources during the start of device,
FdoData->IoBaseAddress = MmMapIoSpace(resourceTrans->u.Memory.Start,resourceTrans->u.Memory.Length,MmNonCached);
Now i want to write one byte data into this mapped memory location,
How can i invoke from the user application, so that it can write one byte data into the above mapped memory location?
Can any body provide the code snippet from user side for this memory mapped writing from user application?
I would use a device I/O control request to send your driver a request to
write a value into the board memory.
From user mode, you open the device with CreateFile, and then you use
DeviceIoControl to send a I/O control request to the driver.
I would follow these samples from the WDK
(if you have a WDM driver)
src\general\ioctl
src\general\pcidrv
(if you have a KMDF driver)
src\kmdf\pcidrv
Hope it helps
GV
–
Gianluca Varenni, Windows DDK MVP
CACE Technologies
http://www.cacetech.com
----- Original Message -----
From:
To: “Windows System Software Devs Interest List”
Sent: Thursday, December 13, 2007 9:29 AM
Subject: [ntdev] How can i invoke from the user application, to write into
the memory mapped location
> Hi,
>
> I have used the memory mapped code like below while mapping the device
> resources during the start of device,
>
> FdoData->IoBaseAddress =
> MmMapIoSpace(resourceTrans->u.Memory.Start,resourceTrans->u.Memory.Length,MmNonCached);
>
>
> Now i want to write one byte data into this mapped memory location,
>
> How can i invoke from the user application, so that it can write one byte
> data into the above mapped memory location?
>
> Can any body provide the code snippet from user side for this memory
> mapped writing from user application?
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
Is it right way to perform read/write from/to the memory mapped region as
FdoData->IoBaseAddress = MmMapIoSpace();
and its corresponding read/write rouitnes respectively as below,
RtlCopyMemory(Buf, (PVOID)p_DVCEXT->IoBaseAddress, BufLen);
RtlCopyMemory( (PVOID)p_DVCEXT->IoBaseAddress, Buf, BufLen);
WRITE_REGISTER_BUFFER_U*() and READ_REGISTER_BUFFER_U*() are the appropriate
kernel interfaces for drivers to write or read device memory. Your user
application can use a custom IOCTL or standard ReadFile WriteFile operations
to the deviceobject created by your driver to cause your driver to initiate
the IO operation on behalf of your application. If your device has DMA
support, you should consider using DMA rather than copying tyhe data using
the system CPU.
On Dec 19, 2007 5:06 AM, wrote:
> Is it right way to perform read/write from/to the memory mapped region as
> FdoData->IoBaseAddress = MmMapIoSpace();
>
> and its corresponding read/write rouitnes respectively as below,
>
> RtlCopyMemory(Buf, (PVOID)p_DVCEXT->IoBaseAddress, BufLen);
>
> RtlCopyMemory( (PVOID)p_DVCEXT->IoBaseAddress, Buf, BufLen);
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
–
Mark Roddy
Use WRITE_REGISTER_BUFFER_xxx instead of RtlCopyMemory, it will do the
proper memory barriers.
–
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
wrote in message news:xxxxx@ntdev…
> Is it right way to perform read/write from/to the memory mapped region as
> FdoData->IoBaseAddress = MmMapIoSpace();
>
> and its corresponding read/write rouitnes respectively as below,
>
> RtlCopyMemory(Buf, (PVOID)p_DVCEXT->IoBaseAddress, BufLen);
>
> RtlCopyMemory( (PVOID)p_DVCEXT->IoBaseAddress, Buf, BufLen);
>
I have tried to open the device corresponding to the driver in the following way and then i tried to perform the read and write as below to the device, but i am unable to open my device itself, what could be the reason in the below code snippet?
HANDLE hdevice = CreateFile(“\\.\PSDODIRDVC”, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hdevice == INVALID_HANDLE_VALUE)
{
printf(“Unable to open PSEUDODEVICE device - error %s\n”, GetLastError());
return 1;
}
WriteFile(hdevice, buffer, strlen(buffer), &junk, NULL);
ReadFile(hdevice, buffer2, 15, &junk, NULL);
My target is i want to perform the write and read to the memory mapped region to my driver as below:
FdoData->IoBaseAddress = MmMapIoSpace();
xxxxx@phoenix.com wrote:
I have tried to open the device corresponding to the driver in the following way and then i tried to perform the read and write as below to the device, but i am unable to open my device itself, what could be the reason in the below code snippet?
And you expect us to tell you that when you won’t even tell us the error
code you received? Come on, we aren’t mind readers.
There is nothing wrong with the code segment you posted. Therefore, the
problem must be somewhere else.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.