Howto return a pointer from io_read-function ?


I’m rather new to QNX programming and i’m writing a resource manager for a framegrabber board. I have problems with returning a picture to the client.
In the endless while-loop of the main-function of my resource manager, i read from a buffer, which contains the actual picture :


bitmap is declared in the header-file as unsigned char * bitmap;

In the io_read - function, i do the following :

[code]// write data to the client
if (nbytes) {

   retVal.width = width;
   retVal.height = height;
   retVal.bpp = bpp;
   MsgReply(ctp->rcvid, nbytes, &retVal + off, nbytes);
   // Settup POSIX start atime data
   // advance the lseek index vy the number of bytes read if not _IO_XTYPE_OFFSET
   if (xtype == _IO_XTYPE_NONE) {
        ocb->offset += nbytes;
   // If we have returned all Data reset offset to 0
   if ( nbytes >= sizeof(picCtrlStruct) ) {
        ocb->offset = 0;

} else {
} // io_read

Where retVal is of the following struct :

typedef struct { unsigned char * bitmap; /*!< das Bild */ int height; /*!< Hoehe des Bildes */ int width; /*!< Breite des Bildes */ int bpp; } picCtrlStruct;

My problem is, that the values of height, width and bpp are returned correctly, but bitmap doesn’t points to the picture. How can i return the picture ?

I hope someone can help me,


answered in the newsgroup

Ok, thanks, i understand. If i want to use solution 2, how can i setup a dma memory region ?
I think i must do something like

unsigned char *dmabuff;

and send the physical address of dmabuff to the server, but how can i get this physical address ?
And how can i map the physical address, into the virtual memory of the server. I read something about mmap_device_memory() and mmap(). Which one is the right way to do this ?