Exemple #1
0
//----------------------------------------------------------------------------------------------
static int ata_pass_thru(int fd,struct cam_pass_thru *pcpt)
{
int    icnt;
int    status;
iov_t  iov[3];
struct cam_pass_thru	cpt;
  cpt=*pcpt;
  icnt=1;
  SETIOV(&iov[0],&cpt,sizeof(cpt));
  cpt.cam_timeout=cpt.cam_timeout?cpt.cam_timeout:CAM_TIME_DEFAULT;
  if(cpt.cam_sense_len)
   {
    SETIOV(&iov[1],(void *)cpt.cam_sense_ptr,cpt.cam_sense_len);
    cpt.cam_sense_ptr=sizeof(cpt);
    icnt++;
   }
  if(cpt.cam_dxfer_len)
   {
    SETIOV(&iov[2],(void *)cpt.cam_data_ptr,cpt.cam_dxfer_len);
    cpt.cam_data_ptr=(paddr_t)sizeof(cpt)+cpt.cam_sense_len;
    icnt++;
   }
  if((status=devctlv(fd,DCMD_CAM_PASS_THRU,icnt,icnt,iov,iov,NULL)))
    pout("ata_pass_thru devctl:  %s\n",strerror(status));
  pcpt->cam_status=cpt.cam_status;
  pcpt->cam_scsi_status=cpt.cam_scsi_status;
  return(status);
}
static int
ds3232_i2c_write(unsigned char reg, unsigned char val[], unsigned char num)
{
    iov_t           siov[3];
    i2c_send_t      hdr;

    hdr.slave.addr = DS3232_I2C_ADDRESS;
    hdr.slave.fmt = I2C_ADDRFMT_7BIT;
    hdr.len = num + 1;
    hdr.stop = 1;

    SETIOV(&siov[0], &hdr, sizeof(hdr));
    SETIOV(&siov[1], &reg, sizeof(reg));
    SETIOV(&siov[2], val, num);

    return devctlv(fd, DCMD_I2C_SEND, 3, 0, siov, NULL, NULL);
}
Exemple #3
0
static int
mc9s08dz60_i2c_write(uint8_t reg, uint8_t *val, int num)
{
    iov_t           siov[3];
    i2c_send_t      hdr;

    hdr.slave.addr = MC9S08DZ60_I2C_ADDRESS;
    hdr.slave.fmt = I2C_ADDRFMT_7BIT;
    hdr.len = num + 1;
    hdr.stop = 1;

    SETIOV(&siov[0], &hdr, sizeof(hdr));
    SETIOV(&siov[1], &reg, 1);
    SETIOV(&siov[2], val, num);

    return devctlv(fd, DCMD_I2C_SEND, 3, 0, siov, NULL, NULL);
}
static int
ds3232_i2c_read(unsigned char reg, unsigned char val[], unsigned char num)
{
    iov_t           siov[2], riov[2];
    i2c_sendrecv_t  hdr;

    hdr.slave.addr = DS3232_I2C_ADDRESS;
    hdr.slave.fmt = I2C_ADDRFMT_7BIT;
    hdr.send_len = 1;
    hdr.recv_len = num;
    hdr.stop = 1;

    SETIOV(&siov[0], &hdr, sizeof(hdr));
    SETIOV(&siov[1], &reg, sizeof(reg));

    SETIOV(&riov[0], &hdr, sizeof(hdr));
    SETIOV(&riov[1], val, num);

    return devctlv(fd, DCMD_I2C_SENDRECV, 2, 2, siov, riov, NULL);
}
Exemple #5
0
static int
mc9s08dz60_i2c_read(uint8_t reg, uint8_t *val, int num)
{
    iov_t           siov[2], riov[2];
    i2c_sendrecv_t  hdr;

    hdr.slave.addr = MC9S08DZ60_I2C_ADDRESS;
    hdr.slave.fmt = I2C_ADDRFMT_7BIT;
    hdr.send_len = 1;
    hdr.recv_len = num;
    hdr.stop = 1;

    SETIOV(&siov[0], &hdr, sizeof(hdr));
    SETIOV(&siov[1], &reg, 1);

    SETIOV(&riov[0], &hdr, sizeof(hdr));
    SETIOV(&riov[1], val, num);

    return devctlv(fd, DCMD_I2C_SENDRECV, 2, 2, siov, riov, NULL);
}
Exemple #6
0
 /*
 * TWL4030 function definitions
 */
static int
twl4030_i2c_write (disp_adapter_t *adapter, uint8_t addr, uint8_t reg, uint8_t val)
{
    iov_t           siov[3];
    i2c_send_t      hdr;

    hdr.slave.addr = addr;
    hdr.slave.fmt = I2C_ADDRFMT_7BIT;
    hdr.len = 2;
    hdr.stop = 1;

    SETIOV(&siov[0], &hdr, sizeof(hdr));
    SETIOV(&siov[1], &reg, sizeof(reg));
    SETIOV(&siov[2], &val, 1);

    if (devctlv(fd, DCMD_I2C_SEND, 3, 0, siov, NULL, NULL) != EOK) {
		disp_printf(adapter, "twl4030_i2c_write fail");
		return -1;
    }
	return 0;
}
Exemple #7
0
static int twl4030_i2c_write(int fd, uint8_t addr, uint8_t reg, uint8_t val)
{
    iov_t siov[3];
    i2c_send_t hdr;

    hdr.slave.addr = addr;
    hdr.slave.fmt = I2C_ADDRFMT_7BIT;
    hdr.len = 2;
    hdr.stop = 1;

    SETIOV(&siov[0], &hdr, sizeof(hdr));
    SETIOV(&siov[1], &reg, sizeof(reg));
    SETIOV(&siov[2], &val, 1);

    if (devctlv(fd, DCMD_I2C_SEND, 3, 0, siov, NULL, NULL) != EOK)
    {
        slogf(_SLOGC_SIM_MMC, _SLOG_ERROR, "BEAGLE MMCSD: twl4030_i2c_write fail");
        return -1;
    }

    return 0;
}
Exemple #8
0
/*!
 *  @brief  Function to invoke the APIs through ioctl.
 *
 *  @param  cmd     Command for driver ioctl
 *  @param  args    Arguments for the ioctl command
 *
 *  @sa
 */
Int
IpcDrv_ioctl (UInt32 cmd, Ptr args)
{
    Int status      = Ipc_S_SUCCESS;
    int osStatus    = -1;

    GT_2trace (curTrace, GT_ENTER, "IpcDrv_ioctl", cmd, args);

    GT_assert (curTrace, (IpcDrv_refCount > 0));

	switch (cmd) {

		  case CMD_IPC_CONTROL:
		  {
			  osStatus = devctl( IpcDrv_handle, DCMD_IPC_CONTROL, args, sizeof(IpcDrv_CmdArgs), NULL);
		  }
		  break;

		  case CMD_IPC_READCONFIG:
		  {
			  IpcDrv_CmdArgs *cargs = (IpcDrv_CmdArgs *)args;
			  iov_t read_iov[2];

			  SETIOV( &read_iov[0], cargs, sizeof(IpcDrv_CmdArgs) );
			  SETIOV( &read_iov[1], cargs->args.readConfig.cfg, cargs->args.readConfig.size );
			  osStatus = devctlv( IpcDrv_handle, DCMD_IPC_READCONFIG, 2, 2, read_iov, read_iov, NULL);
		  }
		  break;


		  case CMD_IPC_WRITECONFIG:
		  {
			  IpcDrv_CmdArgs *cargs = (IpcDrv_CmdArgs *)args;
			  iov_t write_iov[2];

			  SETIOV( &write_iov[0], cargs, sizeof(IpcDrv_CmdArgs) );
			  SETIOV( &write_iov[1], cargs->args.writeConfig.cfg, cargs->args.writeConfig.size );
			  osStatus = devctlv( IpcDrv_handle, DCMD_IPC_WRITECONFIG, 2, 1, write_iov, write_iov, NULL);
		  }
		  break;

		  default:
		  {
			  /* This does not impact return status of this function, so retVal
			   * comment is not used.
			   */
			  status = Ipc_E_INVALIDARG;
			   GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "IpcDrv_ioctl",
                             status,
                             "Driver ioctl failed!");
		  }
		  break;
	  }

    if (osStatus != 0) {
        /*! @retval Ipc_E_OSFAILURE Driver ioctl failed */
        status = Ipc_E_OSFAILURE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "IpcDrv_ioctl",
                             status,
                             "Driver ioctl failed!");
    }
    else {
        /* First field in the structure is the API status. */
        status = ((IpcDrv_CmdArgs *) args)->apiStatus;
    }

    GT_1trace(curTrace, GT_LEAVE, "IpcDrv_ioctl", status);

    return (status);
}
/*!
 *  @brief  Function to invoke the APIs through ioctl.
 *
 *  @param  cmd     Command for driver ioctl
 *  @param  args    Arguments for the ioctl command
 *
 *  @sa
 */
Int
NotifyDrvUsr_ioctl (UInt32 cmd, Ptr args)
{
    Int status      = Notify_S_SUCCESS;
    int osStatus    = -1;

    GT_2trace (curTrace, GT_ENTER, "NotifyDrvUsr_ioctl", cmd, args);

    GT_assert (curTrace, (NotifyDrvUsr_refCount > 0));

	 switch (cmd) {

			case CMD_NOTIFY_SENDEVENT:
			{
				 osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_SENDEVENT, args, sizeof(Notify_CmdArgsSendEvent), NULL);
			}
			break;

			case CMD_NOTIFY_DISABLE:
			{
				 osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_DISABLE, args, sizeof(Notify_CmdArgsDisable), NULL);
			}
			break;

			case CMD_NOTIFY_RESTORE:
			{
				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_RESTORE, args, sizeof(Notify_CmdArgsRestore), NULL);
			}
			break;

			case CMD_NOTIFY_DISABLEEVENT:
			{
				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_DISABLEEVENT, args, sizeof(Notify_CmdArgsDisableEvent), NULL);
			}
			break;

			case CMD_NOTIFY_ENABLEEVENT:
			{
				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_ENABLEEVENT, args, sizeof(Notify_CmdArgsEnableEvent), NULL);
			}
			break;

			case CMD_NOTIFY_REGISTEREVENTSINGLE:
			{
				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_REGISTEREVENTSINGLE, args, sizeof(Notify_CmdArgsRegisterEvent), NULL);
			}
			break;

			case CMD_NOTIFY_REGISTEREVENT:
			{

				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_REGISTEREVENT, args, sizeof(Notify_CmdArgsRegisterEvent), NULL);
			}
			break;

			case CMD_NOTIFY_UNREGISTEREVENTSINGLE:
			{
				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_UNREGISTEREVENTSINGLE, args, sizeof(Notify_CmdArgsUnregisterEvent), NULL);
			}
			break;

			case CMD_NOTIFY_UNREGISTEREVENT:
			{
				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_UNREGISTEREVENT, args, sizeof(Notify_CmdArgsUnregisterEvent), NULL);
			}
			break;

			case CMD_NOTIFY_GETCONFIG:
			{
				Notify_CmdArgsGetConfig *cargs = (Notify_CmdArgsGetConfig *)args;

				iov_t notify_getconfig_iov[2];

				SETIOV( &notify_getconfig_iov[0], cargs, sizeof(Notify_CmdArgsGetConfig) );
				SETIOV( &notify_getconfig_iov[1], cargs->cfg, sizeof(Notify_Config) );

				/* the osal_drv handle is used instead of ipcdrv_handle as the ipcdrc_handle is not yet initialized */
				osStatus = devctlv( OsalDrv_handle, DCMD_NOTIFY_GETCONFIG, 2, 2, notify_getconfig_iov, notify_getconfig_iov, NULL);
			}
			break;

			case CMD_NOTIFY_SETUP:
			{

				Notify_CmdArgsSetup *cargs = (Notify_CmdArgsSetup *)args;

				iov_t notify_setup_iov[2];

				SETIOV( &notify_setup_iov[0], cargs, sizeof(Notify_CmdArgsSetup) );
				SETIOV( &notify_setup_iov[1], cargs->cfg, sizeof(Notify_Config) );

				osStatus = devctlv( IpcDrv_handle, DCMD_NOTIFY_SETUP, 2, 2, notify_setup_iov, notify_setup_iov, NULL);
			}
			break;

			case CMD_NOTIFY_DESTROY:
			{
				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_DESTROY, args, sizeof(Notify_CmdArgsDestroy), NULL);
			}
			break;
			case CMD_NOTIFY_ATTACH:
			{
				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_ATTACH, args, sizeof(Notify_CmdArgsAttach), NULL);
			}
			break;
			case CMD_NOTIFY_DETACH:
			{
				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_DETACH, args, sizeof(Notify_CmdArgsDetach), NULL);
			}
			break;
			case CMD_NOTIFY_SHAREDMEMREQ:
			{
				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_SHAREDMEMREQ, args, sizeof(Notify_CmdArgsSharedMemReq), NULL);
			}
			break;

			case CMD_NOTIFY_INTLINEREGISTERED:
			{

				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_INTLINEREGISTERED, args, sizeof(Notify_CmdArgsIntLineRegistered), NULL);
			}
			break;

			case CMD_NOTIFY_EVENTAVAILABLE:
			{

				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_EVENTAVAILABLE, args, sizeof(Notify_CmdArgsEventAvailable), NULL);
			}
			break;

			case CMD_NOTIFY_THREADATTACH:
			{
				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_THREADATTACH, args, sizeof(Notify_CmdArgsThreadAttach), NULL);
			}
			break;

			case CMD_NOTIFY_THREADDETACH:
			{

				osStatus = devctl( IpcDrv_handle, DCMD_NOTIFY_THREADDETACH, args, sizeof(Notify_CmdArgsThreadDetach), NULL);
			}
			break;

			default:
			{
				/* This does not impact return status of this function, so retVal
				 * comment is not used.
				 */
				status = Notify_E_INVALIDARG;
				GT_setFailureReason (curTrace,
									 GT_4CLASS,
									 "NotifyDrv_ioctl",
									 status,
									 "Unsupported ioctl command specified");
			}
			break;
		}


    if (osStatus != 0) {
        /*! @retval Notify_E_OSFAILURE Driver ioctl failed */
        status = Notify_E_OSFAILURE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "NotifyDrvUsr_ioctl",
                             status,
                             "Driver ioctl failed!");
    }
    else {
        /* First field in the structure is the API status. */
        status = ((Notify_CmdArgs *) args)->apiStatus; // TODO: THIS WILL NEED TO BE MODIFIED FOR IOCTL THAT DO NOT USE COMMOM CMD ARGS
    }

    GT_1trace(curTrace, GT_LEAVE, "NotifyDrvUsr_ioctl", status);

    return status;
}
/*!
 *  @brief  Function to invoke the APIs through ioctl.
 *
 *  @param  cmd     Command for driver ioctl
 *  @param  args    Arguments for the ioctl command
 *
 *  @sa
 */
Int
SharedRegionDrv_ioctl (UInt32 cmd, Ptr args)
{
    Int                       status   = SharedRegion_S_SUCCESS;
    int                       osStatus = -1;
    SharedRegionDrv_CmdArgs * cargs    = (SharedRegionDrv_CmdArgs *) args;
    SharedRegion_Region    *  regions  = NULL;
    SharedRegion_Config *     config;
    Memory_MapInfo            mapInfo;
    UInt16                    i;

    GT_2trace (curTrace, GT_ENTER, "SharedRegionDrv_ioctl", cmd, args);

/*  TODO: SharedRegionDrv_refCount not defined in QNX build
 *  GT_assert (curTrace, (SharedRegionDrv_refCount > 0));
 */

    switch (cmd) {

        case CMD_SHAREDREGION_GETCONFIG:
        {
			SharedRegionDrv_CmdArgs *cargs = (SharedRegionDrv_CmdArgs *)args;
			iov_t sharedregion_getconfig_iov[2];
			SharedRegion_Config * shreg_config = cargs->args.getConfig.config;

			SETIOV( &sharedregion_getconfig_iov[0], cargs, sizeof(SharedRegionDrv_CmdArgs) );
			SETIOV( &sharedregion_getconfig_iov[1], cargs->args.getConfig.config, sizeof(SharedRegion_Config) );

			/* the osal_drv handle is used instead of ipcdrv_handle as the ipcdrc_handle is not yet initialized */
			osStatus = devctlv( OsalDrv_handle, DCMD_SHAREDREGION_GETCONFIG, 1, 2, sharedregion_getconfig_iov, sharedregion_getconfig_iov, NULL);

			if ( osStatus == 0 ){
				cargs->args.getConfig.config = shreg_config;
			}
        }
        break;

        case CMD_SHAREDREGION_SETUP:
        {
			SharedRegionDrv_CmdArgs *cargs = (SharedRegionDrv_CmdArgs *)args;
			iov_t sharedregion_setup_iov[3];

			SETIOV( &sharedregion_setup_iov[0], cargs, sizeof(SharedRegionDrv_CmdArgs) );
			SETIOV( &sharedregion_setup_iov[1], cargs->args.setup.config, sizeof(SharedRegion_Config) );
			SETIOV( &sharedregion_setup_iov[2], cargs->args.setup.regions, cargs->args.setup.config->numEntries * sizeof(SharedRegion_Region) );

			osStatus = devctlv( IpcDrv_handle, DCMD_SHAREDREGION_SETUP, 2, 3, sharedregion_setup_iov, sharedregion_setup_iov, NULL);
        }
        break;


        case CMD_SHAREDREGION_GETREGIONINFO:
        {
			SharedRegionDrv_CmdArgs *cargs = (SharedRegionDrv_CmdArgs *)args;
			iov_t sharedregion_getregconfig_iov[2];	/* no of max shared region entries + 1 */
            //UInt16              i=0;
            SharedRegion_Config   config;

            SharedRegion_getConfig (&config);
			SETIOV( &sharedregion_getregconfig_iov[0], cargs, sizeof(SharedRegionDrv_CmdArgs) );
			SETIOV( &sharedregion_getregconfig_iov[1], cargs->args.getRegionInfo.regions, (sizeof(SharedRegion_Region) * config.numEntries));

			//for (i = 1; i< cargs->args.getConfig.config->numEntries+1;i++) {
			//	SETIOV( &sharedregion_getregconfig_iov[i], &cargs->args.setup.regions[i-1], sizeof(SharedRegion_Region) );
			//}

//			SETIOV( &sharedregion_getregconfig_iov[1], cargs->args.setup.regions, (sizeof(SharedRegion_Region) * cargs->args.getConfig.config->numEntries));

			//osStatus = devctlv( IpcDrv_handle, DCMD_SHAREDREGION_GETREGIONINFO, 1, cargs->args.getConfig.config->numEntries + 1, sharedregion_getregconfig_iov, sharedregion_getregconfig_iov, NULL);
			osStatus = devctlv( IpcDrv_handle, DCMD_SHAREDREGION_GETREGIONINFO, 2, 2, sharedregion_getregconfig_iov, sharedregion_getregconfig_iov, NULL);
        }
        break;

        case CMD_SHAREDREGION_DESTROY:
        {
			osStatus = devctl( IpcDrv_handle, DCMD_SHAREDREGION_DESTROY, cargs, sizeof(SharedRegionDrv_CmdArgs), NULL);
        }
        break;

        case CMD_SHAREDREGION_START:
        {
			osStatus = devctl( IpcDrv_handle, DCMD_SHAREDREGION_START, cargs, sizeof(SharedRegionDrv_CmdArgs), NULL);
        }
        break;

        case CMD_SHAREDREGION_STOP:
        {
			osStatus = devctl( IpcDrv_handle, DCMD_SHAREDREGION_STOP, cargs, sizeof(SharedRegionDrv_CmdArgs), NULL);
        }
        break;

        case CMD_SHAREDREGION_ATTACH:
        {
			osStatus = devctl( IpcDrv_handle, DCMD_SHAREDREGION_ATTACH, cargs, sizeof(SharedRegionDrv_CmdArgs), NULL);
        }
        break;

        case CMD_SHAREDREGION_DETACH:
        {
			osStatus = devctl( IpcDrv_handle, DCMD_SHAREDREGION_DETACH, cargs, sizeof(SharedRegionDrv_CmdArgs), NULL);
        }
        break;

        case CMD_SHAREDREGION_SETENTRY:
        {

			SharedRegionDrv_CmdArgs *cargs = (SharedRegionDrv_CmdArgs *)args;

			iov_t sharedregion_getregsetentry_iov[2];

			SETIOV( &sharedregion_getregsetentry_iov[0], cargs, sizeof(SharedRegionDrv_CmdArgs) );
			SETIOV( &sharedregion_getregsetentry_iov[1], &cargs->args.setEntry.entry, sizeof(SharedRegion_Entry) );

			osStatus = devctlv( IpcDrv_handle, DCMD_SHAREDREGION_SETENTRY, 2, 1, sharedregion_getregsetentry_iov, sharedregion_getregsetentry_iov, NULL);
		}
        break;

        case CMD_SHAREDREGION_CLEARENTRY:
        {
			osStatus = devctl( IpcDrv_handle, DCMD_SHAREDREGION_CLEARENTRY, cargs, sizeof(SharedRegionDrv_CmdArgs), NULL);
        }
        break;

        case CMD_SHAREDREGION_GETHEAP:
        {

			osStatus = devctl( IpcDrv_handle, DCMD_SHAREDREGION_GETHEAP, cargs, sizeof(SharedRegionDrv_CmdArgs), NULL);
        }
        break;

        case CMD_SHAREDREGION_RESERVEMEMORY:
        {
			osStatus = devctl( IpcDrv_handle, DCMD_SHAREDREGION_RESERVEMEMORY, cargs, sizeof(SharedRegionDrv_CmdArgs), NULL);
        }
        break;

        case CMD_SHAREDREGION_CLEARRESERVEDMEMORY:
        {
			osStatus = devctl( IpcDrv_handle, DCMD_SHAREDREGION_CLEARRESERVEDMEMORY, cargs, sizeof(SharedRegionDrv_CmdArgs), NULL);
        }
        break;

        default:
        {
            /* This does not impact return status of this function, so retVal
             * comment is not used.
             */
            status = SharedRegion_E_INVALIDARG;
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "SharedRegionDrv_ioctl",
                                 status,
                                 "Unsupported ioctl command specified");
        }
        break;
    }

    if (osStatus != 0) {
        /*! @retval SharedRegion_E_OSFAILURE Driver ioctl failed */
        status = SharedRegion_E_OSFAILURE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "SharedRegionDrv_ioctl",
                             status,
                             "Driver ioctl failed!");
    }
    else {
        /* First field in the structure is the API status. */
        status = ((SharedRegionDrv_CmdArgs *) cargs)->apiStatus;

        /* Convert the base address to user virtual address */
        if (cmd == CMD_SHAREDREGION_SETUP) {
            config = cargs->args.setup.config;
            for (i = 0u; (   (i < config->numEntries) && (status >= 0)); i++) {
                regions = &(cargs->args.setup.regions [i]);
                if (regions->entry.isValid == TRUE) {
                    mapInfo.src  = (UInt32) regions->entry.base;
                    mapInfo.size = regions->entry.len;
                    status = Memory_map (&mapInfo);
                    if (status < 0) {
                        GT_setFailureReason (curTrace,
                                             GT_4CLASS,
                                             "SharedRegionDrv_ioctl",
                                             status,
                                             "Memory_map failed!");
                    }
                    else {
                        regions->entry.base = (Ptr) mapInfo.dst;
                    }
                }
            }
        }
        else {
            /* TBD: Need to do Memory_unmap in destroy. */
        }
    }

    GT_1trace (curTrace, GT_LEAVE, "SharedRegionDrv_ioctl", status);

/*! @retval SharedRegion_S_SUCCESS Operation successfully completed. */
    return status;
}
/*!
 *  @brief  Function to invoke the APIs through devctl.
 *
 *  @param  cmd     Command for driver ioctl
 *  @param  args    Arguments for the ioctl command
 *
 *  @sa
 */
Int
MultiProcDrv_ioctl (UInt32 cmd, Ptr args)
{
    Int status      = MultiProc_S_SUCCESS;
    int osStatus    = 0;

	MultiProcDrv_CmdArgs *	cargs	 = (MultiProcDrv_CmdArgs *) args;

    GT_2trace (curTrace, GT_ENTER, "MultiProcDrv_ioctl", cmd, args);

	switch (cmd) {

		   case CMD_MULTIPROC_SETUP:
		   {
			   iov_t setup_iov[2];

			   SETIOV( &setup_iov[0], cargs, sizeof(MultiProcDrv_CmdArgs) );
			   SETIOV( &setup_iov[1], cargs->args.setup.config, sizeof(MultiProc_Config) );

			   osStatus = devctlv( IpcDrv_handle, DCMD_MULTIPROC_SETUP, 2, 2, setup_iov, setup_iov, NULL);

				if ( osStatus != 0 ){
					status = MultiProc_E_OSFAILURE;
				}

		   }
		   break;

		   case CMD_MULTIPROC_DESTROY:
		   {
			   	osStatus = devctl( IpcDrv_handle, DCMD_MULTIPROC_DESTROY, cargs, sizeof(MultiProcDrv_CmdArgs), NULL);

				if ( osStatus != 0 ){
					status = MultiProc_E_OSFAILURE;
				}
		   }
		   break;
		   case CMD_MULTIPROC_GETCONFIG:
		   {
  				iov_t		multiproc_getconfig_iov[2];

				MultiProc_Config *	save_multiprocconfig = (MultiProc_Config *)cargs->args.getConfig.config;

  				SETIOV( &multiproc_getconfig_iov[0], cargs, sizeof(MultiProcDrv_CmdArgs) );
  				SETIOV( &multiproc_getconfig_iov[1], cargs->args.getConfig.config, sizeof(MultiProc_Config) );

				/* the osal_drv handle is used instead of ipcdrv_handle as the ipcdrc_handle is not yet initialized */
				osStatus = devctlv( OsalDrv_handle, DCMD_MULTIPROC_GETCONFIG, 2, 2, multiproc_getconfig_iov, multiproc_getconfig_iov, NULL);

				if ( osStatus != 0 ){
					status = MultiProc_E_OSFAILURE;
    			}
    			else{
    				cargs->args.getConfig.config= (MultiProc_Config *) (save_multiprocconfig);
    			}
		   }
		   break;
		   case CMD_MULTIPROC_SETLOCALID:
		   		osStatus = devctl( IpcDrv_handle, DCMD_MULTIPROC_SETLOCALID, cargs, sizeof(MultiProcDrv_CmdArgs), NULL);

				if ( osStatus != 0 ){
					status = MultiProc_E_OSFAILURE;
				}
		   break;
		   default:
		   {
			   /* This does not impact return status of this function, so retVal
				* comment is not used.
				*/
			   status = MultiProc_E_FAIL;
			   GT_setFailureReason (curTrace,
									GT_4CLASS,
									"MultiProcDrv_ioctl",
									status,
									"Unsupported ioctl command specified");
		   }
		   break;

	   }


	if ( osStatus != 0 ){
		status = MultiProc_E_OSFAILURE;
	}
    else {
        /* First field in the structure is the API status. */
        status = ((MultiProcDrv_CmdArgs *) cargs)->apiStatus;
    }

    GT_1trace (curTrace, GT_LEAVE, "MultiProcDrv_ioctl", status);

    /*! @retval MultiProc_S_SUCCESS Operation successfully completed. */
    return status;
}
/*!
 *  @brief  Function to invoke the APIs through ioctl.
 *
 *  @param  cmd     Command for driver ioctl
 *  @param  args    Arguments for the ioctl command
 *
 *  @sa
 */
Int
HeapBufMPDrv_ioctl (UInt32 cmd, Ptr args)
{
    Int status      = HeapBufMP_S_SUCCESS;
    int osStatus    = -1;

    GT_2trace (curTrace, GT_ENTER, "HeapBufMPDrv_ioctl", cmd, args);

    switch (cmd) {
        case CMD_HEAPBUFMP_ALLOC:
            osStatus = devctl(IpcDrv_handle, DCMD_HEAPBUFMP_ALLOC, args,
                    sizeof(HeapBufMPDrv_CmdArgs), NULL);
            break;

        case CMD_HEAPBUFMP_FREE:
            osStatus = devctl( IpcDrv_handle, DCMD_HEAPBUFMP_FREE, args,
                    sizeof(HeapBufMPDrv_CmdArgs), NULL);
            break;

        case CMD_HEAPBUFMP_PARAMS_INIT:
            {
                HeapBufMPDrv_CmdArgs *cargs = (HeapBufMPDrv_CmdArgs *)args;
                iov_t hbmpparamsinit_iov[2];

                SETIOV( &hbmpparamsinit_iov[0], cargs, sizeof(HeapBufMPDrv_CmdArgs) );
                SETIOV( &hbmpparamsinit_iov[1], cargs->args.ParamsInit.params, sizeof(HeapBufMP_Params) );
                osStatus = devctlv( IpcDrv_handle, DCMD_HEAPBUFMP_PARAMS_INIT, 1, 2, hbmpparamsinit_iov, hbmpparamsinit_iov, NULL);
            }
            break;

        case CMD_HEAPBUFMP_CREATE: {
            HeapBufMPDrv_CmdArgs *cargs;
            iov_t iov[3];

            cargs = (HeapBufMPDrv_CmdArgs *)args;
            SETIOV(&iov[0], cargs, sizeof(HeapBufMPDrv_CmdArgs));
            SETIOV(&iov[1], cargs->args.create.params,
                sizeof(HeapBufMP_Params));
            SETIOV(&iov[2], cargs->args.create.params->name,
                cargs->args.create.nameLen * sizeof(Char));

            osStatus = devctlv(IpcDrv_handle, DCMD_HEAPBUFMP_CREATE, 3, 1,
                iov, iov, NULL);
        }
        break;

        case CMD_HEAPBUFMP_DELETE: {
            osStatus = devctl(IpcDrv_handle, DCMD_HEAPBUFMP_DELETE, args,
                sizeof(HeapBufMPDrv_CmdArgs), NULL);
        }
        break;

        case CMD_HEAPBUFMP_OPEN:
            {
			HeapBufMPDrv_CmdArgs *cargs = (HeapBufMPDrv_CmdArgs *)args;
			iov_t hbmpopen_iov[2];

			SETIOV( &hbmpopen_iov[0], cargs, sizeof(HeapBufMPDrv_CmdArgs) );
			SETIOV( &hbmpopen_iov[1], cargs->args.open.name, sizeof(char) * cargs->args.open.nameLen );
			osStatus = devctlv( IpcDrv_handle, DCMD_HEAPBUFMP_OPEN, 2, 1, hbmpopen_iov, hbmpopen_iov, NULL);
            }
            break;

        case CMD_HEAPBUFMP_OPENBYADDR:
        {
           osStatus = devctl( IpcDrv_handle, DCMD_HEAPBUFMP_OPENBYADDR, args, sizeof(HeapBufMPDrv_CmdArgs), NULL);
        }
        break;

        case CMD_HEAPBUFMP_CLOSE:
        {
           osStatus = devctl( IpcDrv_handle, DCMD_HEAPBUFMP_CLOSE, args, sizeof(HeapBufMPDrv_CmdArgs), NULL);
        }
        break;

        case CMD_HEAPBUFMP_SHAREDMEMREQ:
        {
			HeapBufMPDrv_CmdArgs *cargs = (HeapBufMPDrv_CmdArgs *)args;
			iov_t hbmpshm_iov[2];

			SETIOV( &hbmpshm_iov[0], cargs, sizeof(HeapBufMPDrv_CmdArgs) );
			SETIOV( &hbmpshm_iov[1], cargs->args.sharedMemReq.params, sizeof(HeapBufMP_Params) );
			osStatus = devctlv( IpcDrv_handle, DCMD_HEAPBUFMP_SHAREDMEMREQ, 2, 1, hbmpshm_iov, hbmpshm_iov, NULL);
        }
        break;

        case CMD_HEAPBUFMP_GETCONFIG:
        {
			HeapBufMPDrv_CmdArgs *cargs = (HeapBufMPDrv_CmdArgs *)args;
			iov_t hbmpgconfig_iov[2];

			SETIOV( &hbmpgconfig_iov[0], cargs, sizeof(HeapBufMPDrv_CmdArgs) );
			SETIOV( &hbmpgconfig_iov[1], cargs->args.getConfig.config, sizeof(HeapBufMP_Config) );
			osStatus = devctlv( OsalDrv_handle, DCMD_HEAPBUFMP_GETCONFIG, 1, 2, hbmpgconfig_iov, hbmpgconfig_iov, NULL);
        }
        break;

        case CMD_HEAPBUFMP_SETUP:
        {
			HeapBufMPDrv_CmdArgs *cargs = (HeapBufMPDrv_CmdArgs *)args;
			iov_t hbmpsetup_iov[2];

			SETIOV( &hbmpsetup_iov[0], cargs, sizeof(HeapBufMPDrv_CmdArgs) );
			SETIOV( &hbmpsetup_iov[1], cargs->args.setup.config, sizeof(HeapBufMP_Config) );
            osStatus = devctlv( IpcDrv_handle, DCMD_HEAPBUFMP_SETUP, 2, 1, hbmpsetup_iov, hbmpsetup_iov, NULL);
        }
        break;

        case CMD_HEAPBUFMP_DESTROY:
        {
          osStatus = devctl( IpcDrv_handle, DCMD_HEAPBUFMP_DESTROY, args, sizeof(HeapBufMPDrv_CmdArgs), NULL);
        }
        break;

        case CMD_HEAPBUFMP_GETSTATS:
        {
			HeapBufMPDrv_CmdArgs *cargs = (HeapBufMPDrv_CmdArgs *)args;
			iov_t hbmpstats_iov[2];

			SETIOV( &hbmpstats_iov[0], cargs, sizeof(HeapBufMPDrv_CmdArgs) );
			SETIOV( &hbmpstats_iov[1], cargs->args.getStats.stats, sizeof(Memory_Stats) );
			osStatus = devctlv( IpcDrv_handle, DCMD_HEAPBUFMP_GETSTATS, 1, 2, hbmpstats_iov, hbmpstats_iov, NULL);
        }
        break;

        case CMD_HEAPBUFMP_GETEXTENDEDSTATS:
        {
			HeapBufMPDrv_CmdArgs *cargs = (HeapBufMPDrv_CmdArgs *)args;
			iov_t hbmpstats_iov[2];

			SETIOV( &hbmpstats_iov[0], cargs, sizeof(HeapBufMPDrv_CmdArgs) );
			SETIOV( &hbmpstats_iov[1], cargs->args.getExtendedStats.stats, sizeof(HeapBufMP_ExtendedStats) );

			osStatus = devctlv( IpcDrv_handle, DCMD_HEAPBUFMP_GETEXTENDEDSTATS, 1, 2, hbmpstats_iov, hbmpstats_iov, NULL);
        }
        break;

        default :
        {
            /* This does not impact return status of this function, so retVal
             * comment is not used.
             */
            status = HeapBufMP_E_INVALIDARG;
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "HeapBufMPDrv_ioctl",
                                 status,
                                 "Unsupported ioctl command specified");
        }
        break;
  }

    if (osStatus != 0) {
        /*! @retval HeapBufMP_E_OSFAILURE Driver ioctl failed */
        status = HeapBufMP_E_OSFAILURE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "HeapBufMPDrv_ioctl",
                             status,
                             "Driver ioctl failed!");
    }
    else {
        /* First field in the structure is the API status. */
        status = ((HeapBufMPDrv_CmdArgs *) args)->apiStatus;
    }

    GT_1trace (curTrace, GT_LEAVE, "HeapBufMPDrv_ioctl", status);

    return status;
}
Exemple #13
0
/*!
 *  @brief  Function to invoke the APIs through ioctl.
 *
 *  @param  cmd     Command for driver ioctl
 *  @param  args    Arguments for the ioctl command
 *
 *  @sa
 */
Int
ListMPDrv_ioctl (UInt32 cmd, Ptr args)
{
    Int status      = ListMP_S_SUCCESS;
    Int osStatus    = -1;

    GT_2trace (curTrace, GT_ENTER, "ListMPDrv_ioctl", cmd, args);

    switch (cmd) {
        case CMD_LISTMP_CREATE: {
            ListMPDrv_CmdArgs * cargs;
            iov_t               iov[3];

            cargs = (ListMPDrv_CmdArgs *)args;
            SETIOV(&iov[0], cargs, sizeof(ListMPDrv_CmdArgs));
            SETIOV(&iov[1], cargs->args.create.params, sizeof(ListMP_Params));
            SETIOV(&iov[2], cargs->args.create.params->name,
                cargs->args.create.nameLen * sizeof(Char));

            osStatus = devctlv(IpcDrv_handle, DCMD_LISTMP_CREATE, 3, 1,
                iov, iov, NULL);
        }
        break;

        case CMD_LISTMP_DELETE: {
            osStatus = devctl(IpcDrv_handle, DCMD_LISTMP_DELETE, args,
                sizeof(ListMPDrv_CmdArgs), NULL);
        }
        break;

			case CMD_LISTMP_OPEN:
			{
				ListMPDrv_CmdArgs *cargs = (ListMPDrv_CmdArgs *)args;
				iov_t open_iov[2];

				SETIOV( &open_iov[0], cargs, sizeof(ListMPDrv_CmdArgs) );
				SETIOV( &open_iov[1], cargs->args.open.name, sizeof(char) * cargs->args.open.nameLen );
				osStatus = devctlv( IpcDrv_handle, DCMD_LISTMP_OPEN, 2, 1, open_iov, open_iov, NULL);
			}
			break;

			case CMD_LISTMP_OPENBYADDR:
			{

				osStatus = devctl( IpcDrv_handle, DCMD_LISTMP_OPENBYADDR, args, sizeof(ListMPDrv_CmdArgs), NULL);
			}
			break;

			case CMD_LISTMP_CLOSE:
			{
					osStatus = devctl( IpcDrv_handle, DCMD_LISTMP_CLOSE, args, sizeof(ListMPDrv_CmdArgs), NULL);
			}
			break;

			case CMD_LISTMP_SHAREDMEMREQ:
			{
				ListMPDrv_CmdArgs *cargs = (ListMPDrv_CmdArgs *)args;
				iov_t shm_iov[2];

				SETIOV( &shm_iov[0], cargs, sizeof(ListMPDrv_CmdArgs) );
				SETIOV( &shm_iov[1], cargs->args.sharedMemReq.params, sizeof(ListMP_Params) );

				osStatus = devctlv( IpcDrv_handle, DCMD_LISTMP_SHAREDMEMREQ, 2, 1, shm_iov, shm_iov, NULL);
			}
			break;

			case CMD_LISTMP_ISEMPTY:
			{
					osStatus = devctl( IpcDrv_handle, DCMD_LISTMP_ISEMPTY, args, sizeof(ListMPDrv_CmdArgs), NULL);
			}
			break;

			case CMD_LISTMP_PUTTAIL:
			{
					osStatus = devctl( IpcDrv_handle, DCMD_LISTMP_PUTTAIL, args, sizeof(ListMPDrv_CmdArgs), NULL);
			}
			break;

			case CMD_LISTMP_GETHEAD:
			{
					osStatus = devctl( IpcDrv_handle, DCMD_LISTMP_GETHEAD, args, sizeof(ListMPDrv_CmdArgs), NULL);
			}
			break;

			case CMD_LISTMP_NEXT:
			{
					osStatus = devctl( IpcDrv_handle, DCMD_LISTMP_NEXT, args, sizeof(ListMPDrv_CmdArgs), NULL);
			}
			break;

			case CMD_LISTMP_PREV:
			{
					osStatus = devctl( IpcDrv_handle, DCMD_LISTMP_PREV, args, sizeof(ListMPDrv_CmdArgs), NULL);
			}
			break;

			case CMD_LISTMP_INSERT:
			{
					osStatus = devctl( IpcDrv_handle, DCMD_LISTMP_INSERT, args, sizeof(ListMPDrv_CmdArgs), NULL);
			}
			break;

			case CMD_LISTMP_REMOVE:
			{
					osStatus = devctl( IpcDrv_handle, DCMD_LISTMP_REMOVE, args, sizeof(ListMPDrv_CmdArgs), NULL);
			}
			break;

			case CMD_LISTMP_GETTAIL:
			{
					osStatus = devctl( IpcDrv_handle, DCMD_LISTMP_GETTAIL, args, sizeof(ListMPDrv_CmdArgs), NULL);
			}
			break;

			case CMD_LISTMP_PUTHEAD:
			{
					osStatus = devctl( IpcDrv_handle, DCMD_LISTMP_PUTHEAD, args, sizeof(ListMPDrv_CmdArgs), NULL);
			}
			break;

			case CMD_LISTMP_GETCONFIG:
			{
				ListMPDrv_CmdArgs *cargs = (ListMPDrv_CmdArgs *)args;
				iov_t config_iov[2];

				SETIOV( &config_iov[0], cargs, sizeof(ListMPDrv_CmdArgs) );
				SETIOV( &config_iov[1], cargs->args.getConfig.config, sizeof(ListMP_Config) );

				/* the osal_drv handle is used instead of ipcdrv_handle as the ipcdrc_handle is not yet initialized */
				osStatus = devctlv( OsalDrv_handle, DCMD_LISTMP_GETCONFIG, 2, 2, config_iov, config_iov, NULL);
			}
			break;

			case CMD_LISTMP_SETUP:
			{
				ListMPDrv_CmdArgs *cargs = (ListMPDrv_CmdArgs *)args;
				iov_t setup_iov[2];

				SETIOV( &setup_iov[0], cargs, sizeof(ListMPDrv_CmdArgs) );
				SETIOV( &setup_iov[1], cargs->args.setup.config, sizeof(ListMP_Config) );

				osStatus = devctlv( IpcDrv_handle, DCMD_LISTMP_SETUP, 2, 1, setup_iov, setup_iov, NULL);
			}
			break;

			case CMD_LISTMP_DESTROY:
			{
					osStatus = devctl( IpcDrv_handle, DCMD_LISTMP_DESTROY, args, sizeof(ListMPDrv_CmdArgs), NULL);
			}
			break;

			case CMD_LISTMP_PARAMS_INIT:
			{
				ListMPDrv_CmdArgs *cargs = (ListMPDrv_CmdArgs *)args;
				iov_t params_iov[2];

				SETIOV( &params_iov[0], cargs, sizeof(ListMPDrv_CmdArgs) );
				SETIOV( &params_iov[1], cargs->args.ParamsInit.params, sizeof(ListMP_Params) );

				osStatus = devctlv( IpcDrv_handle, DCMD_LISTMP_PARAMS_INIT, 1, 2, params_iov, params_iov, NULL);
			}
			break;

			default:
			{
				/* This does not impact return status of this function, so retVal
				 * comment is not used.
				 */
				status = ListMP_E_INVALIDARG;
				GT_setFailureReason (curTrace,
									 GT_4CLASS,
									 "ListMPDrv_ioctl",
									 status,
									 "Unsupported ioctl command specified");
			}
			break;
		}


    if (osStatus != 0) {
        /*! @retval ListMP_E_OSFAILURE Driver ioctl failed */
        status = ListMP_E_OSFAILURE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "ListMPDrv_ioctl",
                             status,
                             "Driver ioctl failed!");
    }
    else {
        /* First field in the structure is the API status. */
        status = ((ListMPDrv_CmdArgs *) args)->apiStatus;
    }

    GT_1trace (curTrace, GT_LEAVE, "ListMPDrv_ioctl", status);

    return status;
}
Exemple #14
0
/*!
 *  @brief  Function to invoke the APIs through ioctl.
 *
 *  @param  cmd     Command for driver ioctl
 *  @param  args    Arguments for the ioctl command
 *
 *  @sa
 */
Int
MessageQDrv_ioctl (UInt32 cmd, Ptr args)
{
    Int status      = MessageQ_S_SUCCESS;
    int osStatus    = -1;

    GT_2trace (curTrace, GT_ENTER, "MessageQDrv_ioctl", cmd, args);

    switch (cmd) {

          case CMD_MESSAGEQ_CREATE:
          {
              MessageQDrv_CmdArgs *cargs = (MessageQDrv_CmdArgs *)args;
              iov_t mqcreate_iov[3];
              int i = 0;

              SETIOV(&mqcreate_iov[i], cargs, sizeof(MessageQDrv_CmdArgs));
              i++;
              if (cargs->args.create.params) {
                  SETIOV(&mqcreate_iov[i], cargs->args.create.params,
                      sizeof(MessageQ_Params) );
                  i++;
              }
              if (cargs->args.create.name) {
                  SETIOV(&mqcreate_iov[i], cargs->args.create.name, sizeof(char)
                      * cargs->args.create.nameLen );
                  i++;
              }

              // send i iov, return 1 iov
              osStatus = devctlv(IpcDrv_handle, DCMD_MESSAGEQ_CREATE, i, 1,
                  mqcreate_iov, mqcreate_iov, NULL);
          }
          break;

          case CMD_MESSAGEQ_DELETE:
          {
              osStatus = devctl(IpcDrv_handle, DCMD_MESSAGEQ_DELETE, args,
                  sizeof(MessageQDrv_CmdArgs), NULL);
          }
          break;

          case CMD_MESSAGEQ_GETCONFIG:
          {
              MessageQDrv_CmdArgs *cargs = (MessageQDrv_CmdArgs *)args;
                  iov_t mqgetconfig_iov[2];

              SETIOV(&mqgetconfig_iov[0], cargs, sizeof(MessageQDrv_CmdArgs));
              SETIOV(&mqgetconfig_iov[1], cargs->args.getConfig.config,
                  sizeof(MessageQ_Config));
              osStatus = devctlv(IpcDrv_handle, DCMD_MESSAGEQ_GETCONFIG, 1, 2,
                  mqgetconfig_iov, mqgetconfig_iov, NULL);
          }
          break;

          case CMD_MESSAGEQ_SETUP:
          {
              MessageQDrv_CmdArgs *cargs = (MessageQDrv_CmdArgs *)args;
              iov_t mqsetup_iov[2];

              SETIOV(&mqsetup_iov[0], cargs, sizeof(MessageQDrv_CmdArgs));
              SETIOV(&mqsetup_iov[1], cargs->args.setup.config,
                  sizeof(MessageQ_Config) );
                // send 2 iov, get back 1 iov
              osStatus = devctlv(IpcDrv_handle, DCMD_MESSAGEQ_SETUP, 2, 1,
                  mqsetup_iov, mqsetup_iov, NULL);
          }
          break;

          case CMD_MESSAGEQ_DESTROY:
          {
              osStatus = devctl(IpcDrv_handle, DCMD_MESSAGEQ_DESTROY, args,
                  sizeof(MessageQDrv_CmdArgs), NULL);
          }
          break;

          default:
          {
              /* This does not impact return status of this function, so retVal
               * comment is not used.
               */
              status = MessageQ_E_INVALIDARG;
              GT_setFailureReason (curTrace,
                                   GT_4CLASS,
                                   "MessageQDrv_ioctl",
                                   status,
                                   "Unsupported ioctl command specified");
          }
          break;
      }


    if (osStatus != 0) {
        /*! @retval MessageQ_E_OSFAILURE Driver ioctl failed */
        status = MessageQ_E_OSFAILURE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "MessageQDrv_ioctl",
                             status,
                             "Driver ioctl failed!");
    }
    else {
        /* First field in the structure is the API status. */
        status = ((MessageQDrv_CmdArgs *) args)->apiStatus;
    }

    GT_1trace (curTrace, GT_LEAVE, "MessageQDrv_ioctl", status);

    return status;
}