handling devctl message , returning , help!!!

//cmd
#define mycmd(c) __DIOTF(_DCMD_ALL , c , struct _ADMXRC_IOCTL_PARAMS )
//-----------------------------------------------
typedef struct _ADMXRC_IOCTL_PARAMS { 
  struct { 
    void*         lpBuffer; 
    unsigned long nSize; 
  } in; 
  struct { 
    unsigned long nSize; 
    void*         lpBuffer; 
  } out; 
  struct { 
    void*         lpBuffer; 
    unsigned long nSize; 
  } mass; 
} ADMXRC_IOCTL_PARAMS; 

//---------------------------------------------------------
typedef union _ADMXRC_IOCTLS_GETVERSIONINFO { 
  struct { 
    unsigned char major; 
    unsigned char minor; 
  } out; 
} ADMXRC_IOCTLS_GETVERSIONINFO; 

//------------------------------------------------------------------
int 
_ADMXRC2_IoCtlNoWait( 
  ADMXRC2_HANDLE  hDevice,        /* device handle (file pointer)             */ 
  unsigned long   IoControlCode,  /* IOCTL code                               */ 
  void*	          lpInBuffer,     /* pointer to buffer to supply input data   */ 
  unsigned long	  nInBufferSize,  /* size of input buffer                     */ 
  void*           lpOutBuffer,    /* pointer to buffer to receive output data */ 
  unsigned long	  nOutBufferSize, /* size of output buffer                    */ 
  ADMXRC2_STATUS* status) 
{ 
  ADMXRC_IOCTL_PARAMS ibp; 
  ADMXRC2_STATUS      st; 
  int                 err; 

 
  ibp.in.lpBuffer = lpInBuffer; 
  ibp.in.nSize = nInBufferSize; 
  ibp.out.lpBuffer = lpOutBuffer; 
  ibp.out.nSize = nOutBufferSize; 
  ibp.mass.nSize = 0; 
 

 printf("message %x\n",IoControlCode);  

//  err = ioctl(hDevice, IoControlCode, (unsigned int) &ibp); 

  printf(" inbuffer %p outbuffer %p ",ibp.in.lpBuffer,ibp.out.lpBuffer); 
 
  err  = devctl (hDevice, mycmd(IoControlCode)  , &ibp , sizeof(ibp)  , NULL );
  
  if (err) { 
    if (err < 0) { 
      st = map_error(err); 
    } else { 
      st = (ADMXRC2_STATUS) err; 
    } 
  } else { 
    st = ADMXRC_SUCCESS; 
  } 
 
  *status = st; 
 
  return (st == ADMXRC2_SUCCESS); 
} 
 
//--------------------------------------------------------------
// handling iodevctl
int io_devctl(resmgr_context_t *ctp, io_devctl_t *msg, RESMGR_OCB_T *ocb )
{
ADMXRC_IOCTLS_GETVERSIONINFO *t2  ;
int status, nbytes;
unsigned long IoControlCode = 0;
ADMXRC_IOCTL_PARAMS *iop;
  
 status = nbytes = 0 ;

 //decode command
  IoControlCode = msg->i.dcmd - _POSIX_DEVDIR_TOFROM - ( sizeof(struct _ADMXRC_IOCTL_PARAMS)<<16  ) - (_DCMD_ALL<<8);
  
  os_dbgprint(0,("Resource Manager: devctl message %x  %x\n",msg->i.dcmd, IoControlCode));  

  status = iofunc_devctl_default( ctp, msg, ocb );    
  
  if (status != _RESMGR_DEFAULT)
     return (status);
     
  iop = _DEVCTL_DATA(msg->i);

  os_dbgprint(0,("Resource Manager: in.b %p size %d\n",iop->in.lpBuffer, iop->in.nSize )  );  
  os_dbgprint(0,("Resource Manager: out.b %p size %d\n",iop->out.lpBuffer, iop->out.nSize )  );    
  
  status = fops_ioctl(devObj, IoControlCode, iop, &nbytes );   // do work.

   memset ( &msg->o , 0 , sizeof (msg->o) );   
   msg->o.ret_val = status;
   msg->o.nbytes = nbytes ;
   
   [b]if (IoControlCode == 0x88)    // command   GetVersionInfo
     {
       t2 = (ADMXRC_IOCTLS_GETVERSIONINFO *) iop->out.lpBuffer ;      //checking the info returned by fops_ioctl <--- function
       os_dbgprint(0, ("GetVersionInfo %d.%d\n", t2->major, t2->minor) ); 
// all is correct :)   print  3.6
     }  
  [/b]
 
  SETIOV (ctp -> iov, &msg -> o, sizeof (msg->o) + nbytes);
  return (_RESMGR_NPARTS (1));
//return ( _RESMGR_PTR(ctp, &msg->o, sizeof(msg->o)+nbytes) );
}

//--------------------------------------------------------------
//--------------------------------------------------------------
{
 ADMXRC2_HANDLE               handle; 
  ADMXRC2_STATUS               status; 
  ADMXRC_IOCTLS_GETVERSIONINFO ioctl; 
 

 _ADMXRC2_IoCtlNoWait(handle,  
		       (unsigned long) ADMXRC_IOCTL_GETVERSIONINFO, 
		       NULL, 
		       0, 
		       &ioctl.out, 
		       sizeof(ioctl.out), 
		       &status); 
  if (status != ADMXRC2_SUCCESS || 
      (ioctl.out.major < ADMXRC_DVR_MAJORVER) || 
      (ioctl.out.major == ADMXRC_DVR_MAJORVER && ioctl.out.minor < ADMXRC_DVR_MINORVER)) { 
      
       printf(" %p .. %d.%d  \n", &ioctl , ioctl.out.major, ioctl.out.minor); 
        // bad  :(  print ----  0.0   Why?


   fprintf(stderr,"The ADM-XRC device driver in this sytem is not correctly installed.\n\n" 
	    "Please reinstall the ADM-XRC device driver version %d.%d or later.\n", 
	    ADMXRC_DVR_MAJORVER, ADMXRC_DVR_MINORVER); 
    _ADMXRC2_Close(handle); 
    status = ADMXRC2_BAD_DRIVER; 
    goto done; 
  } 
[/b] 
 
 done: 
  if (status != ADMXRC2_SUCCESS) { 
    if (_ADMXRC2_errorHandler != NULL) { 
      return _ADMXRC2_handleError(fn, status); 
    } else { 
      return status; 
    } 
  } else { 
    return status; 
  } 
}

help!

when I call to io_devctl , just before leaving function check the data and I see that they are correct and when return of the function the data are not such, :frowning:

//in io_devctl …
if (IoControlCode == 0x88) // command GetCardVersion
{
t2 = (ADMXRC_IOCTLS_GETVERSIONINFO *) iop->out.lpBuffer ; //checking the info returned by fops_ioctl <— function
os_dbgprint(0, (“GetVersionInfo %d.%d\n”, t2->major, t2->minor) );
// all is correct :slight_smile: print 3.6
}

//----------calling to devctl with command GetVersionInfo

[b]_ADMXRC2_IoCtlNoWait(handle,
(unsigned long) ADMXRC_IOCTL_GETVERSIONINFO,
NULL,
0,
&ioctl.out,
sizeof(ioctl.out),
&status);
if (status != ADMXRC2_SUCCESS ||
(ioctl.out.major < ADMXRC_DVR_MAJORVER) ||
(ioctl.out.major == ADMXRC_DVR_MAJORVER && ioctl.out.minor < ADMXRC_DVR_MINORVER)) {

   printf(" %p .. %d.%d  \n", &ioctl , ioctl.out.major, ioctl.out.minor);
    // bad  :frowning:  print ----  0.0   Why?

fprintf(stderr,“The ADM-XRC device driver in this sytem is not correctly installed.\n\n”
“Please reinstall the ADM-XRC device driver version %d.%d or later.\n”,
ADMXRC_DVR_MAJORVER, ADMXRC_DVR_MINORVER);
_ADMXRC2_Close(handle);
status = ADMXRC2_BAD_DRIVER;
goto done;
}

[/b]

the problem may be are in

SETIOV (ctp -> iov, &msg -> o, sizeof (msg->o) + nbytes); return (_RESMGR_NPARTS (1)); //return ( _RESMGR_PTR(ctp, &msg->o, sizeof(msg->o)+nbytes) );

please tell me why no return with tha data correctly.

help!!!