In Linux there is used file_operations structure holding pointers to functions operating on device files. If you then in user space call fread(/dev/…), OS thereafter calls appropriate function from file_operations structure, to return some output from the device to the user.
What I know in QNX there is resmgr_io_funcs_t structure, which have to be filled with almost the same operations, i.e. to handle _IO_READ message I just need to point member read from resmgr_io_funcs_t structure to appropriate function (this is also described here http://www.qnx.com/developers/docs/6.3.0/neutrino/prog/resmgr.html#HANDLING_READ_MSG).
From linux device drivers chapter 13 http://www.xml.com/ldd/chapter/book/ch13.html…
…in Linux the mmap method is part of the file_operations structure and is invoked when the mmap system call is issued. With mmap, the kernel performs a good deal of work before the actual method is invoked, and therefore the prototype of the method is quite different from that of the system call. This is unlike calls such as ioctl and poll, where the kernel does not do much before calling the method.
The system call is declared as follows (as described in the mmap(2) manual page):
mmap (caddr_t addr, size_t len, int prot, int flags, int fd,
off_t offset)
On the other hand, the file operation is declared as
int (*mmap) (struct file *filp, struct vm_area_struct *vma);
In the original Linux driver (which I am porting), is on response on mmap system call executed the code I have posted before ( int xx_control_mmap(struct file *filp, struct vm_area_struct *vma) {… ). This code is used to map hardware memory into kernels memory via remap_page_range function.
Shouldn’t I use _IO_MMAP() callouts to do this in QNX??? And if so, how to get number of bytes to be mapped???
Thanks a lot.
Michal