RE: Mapping physical memory into Application space





This code runs in a device driver (as part of device.exe), i have tried to
make the code more understandable below:

pout is a ptr to a struct that has an embedded pointer called buffer.

ioctl(instance, pin, size, pout, size, unused)
{
paddr = MmapIoSpace(physical_address)
// trying to map paddr from device.exe to the calling application
pnewaddr = MapPtrProcess(paddr, GetCallerProcess())
pout->buffer = pnewaddr

}

In the application:

buffer_struct some_buf;

ioctl(fd, IOCTL, NULL, 0, &some_buf, sizeof(some_buf))

memcpy(some_buf.buffer, my_buf, some_length);

"viddec" wrote:

> Hi,
>
> I want to return to the user application a mapping to a physical buffer.
>
> Suppose the virtual address in the address space of device.exe is paddr
> does
>
> ioctl(instance, pin, size, pout, size, unused)
> {
> pnewaddr = MapPtrProcess(paddr, GetCallerProcess())
> pout = pnewaddr //should this be *pout = pnewaddr
> }
>
> return the new mapping in pout ?
>
>
.