Hello,
I write a resource manager. I handle _IO_READ messages with the
io_read() function (as in the documentation “writing a Resource
Manager”).
I have a problem with the macro SETIOV.When the client program does a
read(), an error returns : “Server fault on msg pass” (errno=312).
Here is the code :
#define LEN 65535
…
int io_read (resmgr_context_t *ctp, io_read_t *msg, RESMGR_OCB_T *ocb)
{
off64_t offset;
static char *addr;
…
if( (addr = (char*)mmap_device_memory(0, LEN,
PROT_NOCACHE|PROT_READ|PROT_WRITE,
MAP_PHYS|MAP_SHARED,
offset)) == MAP_FAILED ) {
perror(“mmap_device_memory”);
return -1;
}
SETIOV (ctp->iov, addr, nbytes);
munmap(addr, LEN);
…
return (_RESMGR_NPARTS (nparts));
}
offset is the physical address of my 64K buffer, and mmap convert it
into a virtual address.
When I do a printf of addr, I can display the text I have wrote in the
buffer and the address is 0x40380000.
But, when the client does a read(), there is the error “Server fault
on msg pass”.
If I declare
char *buf = “hello world\n”;
in the io_read() function and if I do
SETIOV (ctp->iov, buf, nbytes);
I have no error. The address of buf is 0x804c3b6 and printf displays
the good text.
My questions are :
Why SETIOV does not work with mmap() while it works whith “char *buf”
as in my example ?
Is there an error in my code ?
Thank you in advance for your answer.
– Phil.