Windows mapping

Does anybody know if there's a system call or something that allows a chunk of physical memory (I'm thinking a block of dpm located on a PCI board) to be mapped into the addressing space of a user program, so it's directly addressable?

I suppose the alternative would be to have a device driver or a dll copy blocks of stuff between the PCI bus and the user space, but that's clumsy.

John

Reply to
John Larkin
Loading thread data ...

Which OS? The non-clumsy safe way to do it is to use a driver.

Reply to
The Real Andy

""" NAME mmap, munmap - map or unmap files or devices into memory ^^^^^ SYNOPSIS #include

void * mmap(void *start, size_t length, int prot , int flags, int fd, off_t offset);

int munmap(void *start, size_t length);

DESCRIPTION The mmap function asks to map length bytes starting at offset offset from the file (or other object) specified by the file descriptor fd into memory, preferably at address start. This latter address is a hint only, and is usually specified as 0. The actual place where the object is mapped is returned by mmap, and is never 0.

"""

Some kind of driver is needed to perform an open() on the device so it can be mapped in the first place. On Linux one can skip all that and (relatively) trivially map the device to pseudo-files under /sysfs - from there it's all user side.

Who knows what 'doze does; is it supposed to be Posix compliant as NT was?

Reply to
Frithiof Andreas Jensen

Its eons since I did this and it was on NT3.5, I think you have to do the memory locking and mapping in a device driver, but I think you can then share that memory with the user level program.

Colin =^.^=

Reply to
colin

Hi John,

Assuming Windows here, the function call you're after is MmMapIoSpace. This is a kernel function, though, so you'll need a proper device driver to perform the task for you (or you can use one of those "generic" device drivers that lets a user mode program poke around anywhere it wants -- I used WinRT for this pushing a decade ago, and they're long since dead, but I expect there are current alternatives available).

---Joel

Reply to
Joel Kolstad

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.