aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2010-12-08 10:57:26 +0000
committerAlan Cox <alan@linux.intel.com>2010-12-08 10:57:26 +0000
commit70c82f1dafc4494ec39b3149620bd63ab9550d3b (patch)
tree28cdd336b200fa0d5d8e5584587eb294492d6572
parentb48177cb523020f3263fac07cf1998e09eafc8b0 (diff)
downloadmrst-s0i3-test-70c82f1dafc4494ec39b3149620bd63ab9550d3b.tar.gz
mrst-s0i3-test-70c82f1dafc4494ec39b3149620bd63ab9550d3b.tar.xz
mrst-s0i3-test-70c82f1dafc4494ec39b3149620bd63ab9550d3b.zip
Signed-off-by: Mark A. Allyn <mark.a.allyn@intel.com>
-rw-r--r--drivers/staging/sep/sep_driver.c237
1 files changed, 198 insertions, 39 deletions
diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index 5f230dc5b49..d9db3cc9684 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -3533,61 +3533,83 @@ end_function:
return error;
}
+
+/*
+ * Ioctl API
+ * @filp: pointer to struct file
+ * @cmd: command
+ * @arg: pointer to argument structure
+*/
static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
int error = 0;
struct sep_device *sep = filp->private_data;
- dbg("------------>SEP Driver: ioctl start\n");
+ dev_dbg(&sep->pdev->dev, "ioctl start\n");
+
+ dev_dbg(&sep->pdev->dev, "cmd is %x\n", cmd);
+ dev_dbg(&sep->pdev->dev,
+ "SEP_IOCSENDSEPCOMMAND is %x\n", SEP_IOCSENDSEPCOMMAND);
+ dev_dbg(&sep->pdev->dev,
+ "SEP_IOCALLOCDATAPOLL is %x\n", SEP_IOCALLOCDATAPOLL);
+ dev_dbg(&sep->pdev->dev,
+ "SEP_IOCCREATESYMDMATABLE is %x\n", SEP_IOCCREATESYMDMATABLE);
+ dev_dbg(&sep->pdev->dev,
+ "SEP_IOCFREEDMATABLEDATA is %x\n", SEP_IOCFREEDMATABLEDATA);
+ dev_dbg(&sep->pdev->dev,
+ "SEP_IOCSEPSTART is %x\n", SEP_IOCSEPSTART);
+ dev_dbg(&sep->pdev->dev,
+ "SEP_IOCSEPINIT is %x\n", SEP_IOCSEPINIT);
+ dev_dbg(&sep->pdev->dev,
+ "SEP_IOCGETSTATICPOOLADDR is %x\n", SEP_IOCGETSTATICPOOLADDR);
+ dev_dbg(&sep->pdev->dev,
+ "SEP_IOCENDTRANSACTION is %x\n", SEP_IOCENDTRANSACTION);
+ dev_dbg(&sep->pdev->dev,
+ "SEP_IOCREALLOCEXTCACHE is %x\n", SEP_IOCREALLOCEXTCACHE);
+ dev_dbg(&sep->pdev->dev,
+ "SEP_IOCRARPREPAREMESSAGE is %x\n", SEP_IOCRARPREPAREMESSAGE);
+ dev_dbg(&sep->pdev->dev,
+ "SEP_IOCPREPAREDCB is %x\n", SEP_IOCPREPAREDCB);
+ dev_dbg(&sep->pdev->dev,
+ "SEP_IOCFREEDCB is %x\n", SEP_IOCFREEDCB);
- edbg("SEP Driver: cmd is %x\n", cmd);
+ /* make sure we own this device */
+ if ((current->pid != sep->pid_doing_transaction) &&
+ (sep->pid_doing_transaction != 0)) {
+
+ dev_dbg(&sep->pdev->dev, "ioctl pid is not owner\n");
+ error = -EACCES;
+ goto end_function;
+ }
+
+ /* check that the command is for sep device */
+ if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) {
+ dev_dbg(&sep->pdev->dev, "ioctl incorrect magic nbr\n");
+ error = -EFAULT;
+ goto end_function;
+ }
+
+ /* lock access to ioctl because we don't
+ want the daemon to interfere with operation */
+ mutex_lock(&ioctl_mutex);
switch (cmd) {
case SEP_IOCSENDSEPCOMMAND:
/* send command to SEP */
sep_send_command_handler(sep);
- edbg("SEP Driver: after sep_send_command_handler\n");
- break;
- case SEP_IOCSENDSEPRPLYCOMMAND:
- /* send reply command to SEP */
- sep_send_reply_command_handler(sep);
break;
case SEP_IOCALLOCDATAPOLL:
/* allocate data pool */
error = sep_allocate_data_pool_memory_handler(sep, arg);
break;
- case SEP_IOCWRITEDATAPOLL:
- /* write data into memory pool */
- error = sep_write_into_data_pool_handler(sep, arg);
- break;
- case SEP_IOCREADDATAPOLL:
- /* read data from data pool into application memory */
- error = sep_read_from_data_pool_handler(sep, arg);
- break;
case SEP_IOCCREATESYMDMATABLE:
/* create dma table for synhronic operation */
error = sep_create_sync_dma_tables_handler(sep, arg);
break;
- case SEP_IOCCREATEFLOWDMATABLE:
- /* create flow dma tables */
- error = sep_create_flow_dma_tables_handler(sep, arg);
- break;
case SEP_IOCFREEDMATABLEDATA:
/* free the pages */
error = sep_free_dma_table_data_handler(sep);
break;
- case SEP_IOCSETFLOWID:
- /* set flow id */
- error = sep_set_flow_id_handler(sep, (unsigned long)arg);
- break;
- case SEP_IOCADDFLOWTABLE:
- /* add tables to the dynamic flow */
- error = sep_add_flow_tables_handler(sep, arg);
- break;
- case SEP_IOCADDFLOWMESSAGE:
- /* add message of add tables to flow */
- error = sep_add_flow_tables_message_handler(sep, arg);
- break;
case SEP_IOCSEPSTART:
/* start command to sep */
error = sep_start_handler(sep);
@@ -3601,26 +3623,163 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
error = sep_get_static_pool_addr_handler(sep, arg);
break;
case SEP_IOCENDTRANSACTION:
- error = sep_end_transaction_handler(sep, arg);
+ error = sep_end_transaction_handler(sep);
+ break;
+ case SEP_IOCREALLOCEXTCACHE:
+ if (sep->mrst)
+ error = -ENODEV;
+ else
+ error = sep_realloc_ext_cache_handler(sep, arg);
break;
- case SEP_IOCREALLOCCACHERES:
- error = sep_realloc_cache_resident_handler(sep, arg);
+ case SEP_IOCRARPREPAREMESSAGE:
+ error = sep_rar_prepare_output_msg_handler(sep, arg);
break;
- case SEP_IOCGETMAPPEDADDROFFSET:
- error = sep_get_physical_mapped_offset_handler(sep, arg);
+ case SEP_IOCPREPAREDCB:
+ error = sep_prepare_dcb_handler(sep, arg);
break;
- case SEP_IOCGETIME:
- error = sep_get_time_handler(sep, arg);
+ case SEP_IOCFREEDCB:
+ error = sep_free_dcb_handler(sep);
break;
default:
error = -ENOTTY;
break;
}
- dbg("SEP Driver:<-------- ioctl end\n");
+
+ mutex_unlock(&ioctl_mutex);
+
+end_function:
+
+ dev_dbg(&sep->pdev->dev, "ioctl end\n");
+ return error;
+}
+
+/*
+ singleton ioctl
+ * @filp: pointer to struct file
+ * @cmd: command
+ * @arg: pointer to argument structure
+*/
+static long sep_singleton_ioctl(struct file *filp, u32 cmd, unsigned long arg)
+{
+
+ /* error */
+ long error;
+ struct sep_device *sep = filp->private_data;
+
+ /*------------------------
+ CODE
+ ------------------------*/
+ error = 0;
+
+ dev_dbg(&sep->pdev->dev,
+ "singleton_ioctl start\n");
+
+ dev_dbg(&sep->pdev->dev,
+ "cmd is %x\n", cmd);
+
+ /* check that the command is for sep device */
+ if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) {
+ dev_warn(&sep->pdev->dev, "singleton ictl wrong magic\n");
+ error = -ENOTTY;
+ goto end_function;
+ }
+
+ /* make sure we own this device */
+ if ((current->pid != sep->pid_doing_transaction) &&
+ (sep->pid_doing_transaction != 0)) {
+
+ dev_dbg(&sep->pdev->dev, "singleton ioctl pid is not owner\n");
+ error = -EACCES;
+ goto end_function;
+ }
+
+ switch (cmd) {
+
+ case SEP_IOCTLSETCALLERID:
+
+ mutex_lock(&ioctl_mutex);
+ error = sep_set_caller_id_handler(sep, arg);
+ mutex_unlock(&ioctl_mutex);
+ break;
+
+ default:
+
+ error = sep_ioctl(filp, cmd, arg);
+ break;
+
+ }
+
+end_function:
+
+ dev_dbg(&sep->pdev->dev, "singleton ioctl end\n");
return error;
}
+/**
+ * sep_request_daemon_ioctl - ioctl for daemon
+ * @filp: pointer to struct file
+ * @cmd: command
+ * @arg: pointer to argument structure
+ * Called by the request daemon to perform ioctls on the daemon device
+ */
+
+static long sep_request_daemon_ioctl(struct file *filp, u32 cmd,
+ unsigned long arg)
+{
+
+ long error = 0;
+ struct sep_device *sep = filp->private_data;
+
+ /*------------------------
+ CODE
+ ------------------------*/
+
+ dev_dbg(&sep->pdev->dev,
+ "daemon ioctl: start\n");
+
+ dev_dbg(&sep->pdev->dev,
+ "daemon ioctl: cmd is %x\n", cmd);
+
+ /* check that the command is for sep device */
+ if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) {
+ dev_warn(&sep->pdev->dev,
+ "daemon ioctl: wrong magic number\n");
+ error = -EFAULT;
+ goto end_function;
+ }
+
+ /* only one process can access ioctl at any given time */
+ mutex_lock(&ioctl_mutex);
+
+ switch (cmd) {
+ case SEP_IOCSENDSEPRPLYCOMMAND:
+
+ /* send reply command to SEP */
+ error = sep_req_daemon_send_reply_command_handler(sep);
+ break;
+
+ case SEP_IOCENDTRANSACTION:
+
+ /* end req daemon transaction, do nothing */
+ error = sep_req_daemon_end_transaction_handler(sep, filp);
+ break;
+
+ default:
+ dev_dbg(&sep->pdev->dev,
+ "daemon ioctl: no such IOCTL\n");
+ error = -ENOIOCTLCMD;
+ }
+
+ mutex_unlock(&ioctl_mutex);
+
+end_function:
+
+ dev_dbg(&sep->pdev->dev,
+ "daemon ioctl: end\n");
+ return error;
+
+}
#if !SEP_DRIVER_POLLING_MODE