Skip navigation.
Home
The QNX Community Portal

View topic - How to retrieve pathname space from handler functions in RM?

How to retrieve pathname space from handler functions in RM?

Discussion about the general applications that run on QNX6

How to retrieve pathname space from handler functions in RM?

Postby newbie_learner » Tue May 07, 2013 4:05 pm

Hi,

Is there anyway of retrieving the pathname space from within resource manager functions like io_read/io_write/io_devctl() ?

I want to register 2 pathname space in the resource manager and it will have the same handler function. But in the handler function, I want to know the client request that is destined to (whether the request is destined to /dev1 or /dev2) and then call appropriate driver function from within the handler.

If I am right, I need to use the ID I get from resmgr_attach(). But how do I retrieve it from within io_devctl() ?
Also is it possible to retrieve the pathname space in string format from any of the resource mgr attributes ?

======================
int io_devctl(resmgr_context_t *ctp, io_devctl_t *msg, RESMGR_OCB_T *ocb)
{
int nbytes, status, previous;
void *rx_Data;


if ((status = iofunc_devctl_default(ctp, msg, ocb)) != _RESMGR_DEFAULT) {
return(status);
}
status = nbytes = 0;
printf("\r\n%s Entered Recv. ID %d...", __FUNCTION__, ctp->rcvid);

//if the request is destined to dev1
if(dev1)
driver1 -> doJobA(paramA)

else if(dev2)
driver1 -> doJobA(paramB)

.......
}


Thanks in advance.
newbie_learner
Active Member
 
Posts: 18
Joined: Wed Mar 27, 2013 10:12 pm

Re: How to retrieve pathname space from handler functions in

Postby maschoen » Wed May 08, 2013 1:49 am

The OCB structure:
typedef struct _iofunc_ocb {
IOFUNC_ATTR_T *attr;
int32_t ioflag;
off_t offset;
uint16_t sflag;
uint16_t flags;
} iofunc_ocb_t;

Has a pointer to the Attribute structure "attr".

Each name space device, eg /dev/dev1 is associated with a particular attribute structure.

Is that enough to get you going?
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: How to retrieve pathname space from handler functions in

Postby newbie_learner » Wed May 08, 2013 2:30 pm

Thanks Mashoen for your response.

I had investigated that ocb structure for my requirement before posting. But it doesn't serve my purpose or at least I don't know how to retrieve the info I wanted.

Basically I wanted to know which device the request is destined to within the handler functions in RM.

I did achieve what I wanted using resmgr_context_t structure as below.

=============================
/* attach our device name */
mdm1DevId = resmgr_attach(
dppMdm, /* dispatch handle */
&resmgr_attrMdm, /* resource manager attrs */
FPGA_MDM1_DEVICE, /* device name */
_FTYPE_ANY, /* open type */
0, /* flags */
&mdmConnect_funcs, /* connect routines */
&mdmio_funcs, /* I/O routines */
&mdmAttr); /* handle */

/* attach our 2nd device */
mdm2DevId = resmgr_attach(
dppMdm, /* dispatch handle */
&resmgr_attrMdm, /* resource manager attrs */
FPGA_MDM2_DEVICE, /* device name */
_FTYPE_ANY, /* open type */
0, /* flags */
&mdmConnect_funcs, /* connect routines */
&mdmio_funcs, /* I/O routines */
&mdm2Attr); /* handle */

----------------------------------------------------------------------------------
int mdmRm_io_devctl(resmgr_context_t *ctp, io_devctl_t *msg, RESMGR_OCB_T *ocb)
{
int nbytes, status, previous;
void *rx_Data;

if ((status = iofunc_devctl_default(ctp, msg, ocb)) != _RESMGR_DEFAULT) {
return(status);
}
status = nbytes = 0;
printf("\r\n%s Entered Rec ID %d...", __FUNCTION__, ctp->rcvid);

if(mdm2DevId == ctp->id) {
printf("\r\nMsg is meant for Mdm2: ID -> %d ", ctp->id);
}
else if(mdm1DevId == ctp->id) {
printf("\r\nMsg is meant for Mdm1: ID -> %d ", ctp->id);
}
else {
printf("\r\nInvalid device");

}
newbie_learner
Active Member
 
Posts: 18
Joined: Wed Mar 27, 2013 10:12 pm


Return to QNX6 - Applications

Who is online

Users browsing this forum: No registered users and 2 guests