Subversion Repositories f9daq

Rev

Rev 11 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 11 Rev 362
Line 65... Line 65...
65
#include <asm/types.h>
65
#include <asm/types.h>
66
#include <asm/uaccess.h>
66
#include <asm/uaccess.h>
67
 
67
 
68
#include <linux/sched.h>
68
#include <linux/sched.h>
69
#include <linux/fs.h>
69
#include <linux/fs.h>
70
#if HAVE_UNLOCKED_IOCTL
-
 
71
    #include <linux/mutex.h>
70
#include <linux/mutex.h>
72
#else
-
 
73
    #include <linux/smp_lock.h>
-
 
74
#endif
-
 
75
 
71
 
76
 
72
 
77
#include "fops.h"
73
#include "fops.h"
78
#include "plx9050.h"
74
#include "plx9050.h"
79
#include "pcivme.h"      /* the common ioctl commands and structures between driver and application */
75
#include "pcivme.h"      /* the common ioctl commands and structures between driver and application */
Line 255... Line 251...
255
{
251
{
256
    u16 tmp;
252
    u16 tmp;
257
 
253
 
258
    __get_user(tmp, increment16(pvBuffer));
254
    __get_user(tmp, increment16(pvBuffer));
259
    writew(tmp, (volatile void *) ( pd->pVME + dwLocalAddressInPage ));
255
    writew(tmp, (volatile void *) ( pd->pVME + dwLocalAddressInPage ));
260
}
256
}
261
 
257
 
262
static void readLong(DEVICE_OBJ *pd, void **pvBuffer, u32 dwLocalAddressInPage)
258
static void readLong(DEVICE_OBJ *pd, void **pvBuffer, u32 dwLocalAddressInPage)
263
{
259
{
264
    u32 tmp;
260
    u32 tmp;
265
 
261
 
266
    tmp = readl((const volatile void *) (pd->pVME + dwLocalAddressInPage));
262
    tmp = readl((const volatile void *) (pd->pVME + dwLocalAddressInPage));
Line 442... Line 438...
442
    fail:
438
    fail:
443
    return err;
439
    return err;
444
}
440
}
445
 
441
 
446
static int access_command(PATH_OBJ *pp, DEVICE_OBJ *pd, PCIVME_ACCESS_COMMAND *cmd)
442
static int access_command(PATH_OBJ *pp, DEVICE_OBJ *pd, PCIVME_ACCESS_COMMAND *cmd)
447
{
443
{
448
    PRINTK(KERN_DEBUG "%s : access_command()\n", DEVICE_NAME);
444
    PRINTK(KERN_DEBUG "%s : access_command()\n", DEVICE_NAME);
449
 
445
 
450
    pp->bModifier    = cmd->bModifier;
446
    pp->bModifier    = cmd->bModifier;
451
    pp->bAccessType  = cmd->bAccessType;
447
    pp->bAccessType  = cmd->bAccessType;
452
    pp->bIncrement   = cmd->bIncrement;
448
    pp->bIncrement   = cmd->bIncrement;
Line 722... Line 718...
722
    PATH_OBJ   *pp = (PATH_OBJ *)pFile->private_data;
718
    PATH_OBJ   *pp = (PATH_OBJ *)pFile->private_data;
723
    DEVICE_OBJ *pd = pp->pDo;
719
    DEVICE_OBJ *pd = pp->pDo;
724
    int err = 1;
720
    int err = 1;
725
   
721
   
726
    PRINTK(KERN_DEBUG "%s : pcivme_ioctl(0x%08x), size = %d\n", DEVICE_NAME, cmd, _IOC_SIZE(cmd));
722
    PRINTK(KERN_DEBUG "%s : pcivme_ioctl(0x%08x), size = %d\n", DEVICE_NAME, cmd, _IOC_SIZE(cmd));
727
 
723
 
728
    if (_IOC_TYPE(cmd) != PCIVME_MAGIC)
724
    if (_IOC_TYPE(cmd) != PCIVME_MAGIC)
729
        return -EINVAL;
725
        return -EINVAL;
730
 
726
 
731
    // check for accessible user buffer
727
    // check for accessible user buffer
732
    if (_IOC_DIR(cmd) & _IOC_READ)
728
    if (_IOC_DIR(cmd) & _IOC_READ)
733
        err = !access_ok(VERIFY_WRITE, (void *)arg, _IOC_SIZE(cmd));
729
        err = !access_ok( (void *)arg, _IOC_SIZE(cmd));
734
    if (_IOC_DIR(cmd) & _IOC_WRITE)
730
    if (_IOC_DIR(cmd) & _IOC_WRITE)
735
        err = !access_ok(VERIFY_READ,  (void *)arg, _IOC_SIZE(cmd));
731
        err = !access_ok( (void *)arg, _IOC_SIZE(cmd));
736
    if (err)
732
    if (err)
737
        return -EFAULT;
733
        return -EFAULT;
738
 
734
 
739
    switch (_IOC_NR(cmd))
735
    switch (_IOC_NR(cmd))
740
    {
736
    {
Line 748... Line 744...
748
                return -EINVAL;
744
                return -EINVAL;
749
            return read_vector_polling(pp, pd, (PCIVME_VECTOR_LEVEL *)arg);
745
            return read_vector_polling(pp, pd, (PCIVME_VECTOR_LEVEL *)arg);
750
 
746
 
751
        case _IOC_NR(PCIVME_CONTROL_INTERRUPTS):
747
        case _IOC_NR(PCIVME_CONTROL_INTERRUPTS):
752
            if (_IOC_SIZE(cmd) < sizeof(PCIVME_IRQ_CONTROL))
748
            if (_IOC_SIZE(cmd) < sizeof(PCIVME_IRQ_CONTROL))
753
                return -EINVAL;
749
                return -EINVAL;
754
            return control_interrupts(pp, pd, (PCIVME_IRQ_CONTROL *)arg);
750
            return control_interrupts(pp, pd, (PCIVME_IRQ_CONTROL *)arg);
755
 
751
 
756
        case _IOC_NR(PCIVME_TAS):
752
        case _IOC_NR(PCIVME_TAS):
757
            if (_IOC_SIZE(cmd) < sizeof(PCIVME_TAS_STRUCT))
753
            if (_IOC_SIZE(cmd) < sizeof(PCIVME_TAS_STRUCT))
758
                return -EINVAL;
754
                return -EINVAL;
Line 810... Line 806...
810
 
806
 
811
static long  pcivme_unlocked_ioctl(struct file *pFile, unsigned int cmd, unsigned long arg){
807
static long  pcivme_unlocked_ioctl(struct file *pFile, unsigned int cmd, unsigned long arg){
812
long retval=0;
808
long retval=0;
813
 
809
 
814
 
810
 
815
#if HAVE_UNLOCKED_IOCTL
-
 
816
    struct mutex  fs_mutex;
811
    struct mutex  fs_mutex;
817
   mutex_init(&fs_mutex);
812
   mutex_init(&fs_mutex);
818
   mutex_lock(&fs_mutex);
813
   mutex_lock(&fs_mutex);
819
#else
-
 
820
   lock_kernel();
-
 
821
#endif
-
 
822
 
814
 
823
PRINTK(KERN_DEBUG "%s : pcivme_unlocked_ioctl(0x%08x), size = %d\n", DEVICE_NAME, cmd, _IOC_SIZE(cmd));
815
PRINTK(KERN_DEBUG "%s : pcivme_unlocked_ioctl(0x%08x), size = %d\n", DEVICE_NAME, cmd, _IOC_SIZE(cmd));
824
retval = pcivme_ioctl(NULL, pFile, cmd,arg);
816
retval = pcivme_ioctl(NULL, pFile, cmd,arg);
825
 
817
 
826
#if HAVE_UNLOCKED_IOCTL
-
 
827
   mutex_unlock(&fs_mutex);
818
   mutex_unlock(&fs_mutex);
828
#else
-
 
829
   unlock_kernel();
-
 
830
#endif
-
 
831
 
819
 
832
return retval;
820
return retval;
833
}
821
}
834
 
822
 
835
int pcivme_open(struct inode *pInode, struct file *pFile)
823
int pcivme_open(struct inode *pInode, struct file *pFile)
Line 955... Line 943...
955
    // inhibit misaligned accesses
943
    // inhibit misaligned accesses
956
    if (pp->AlignmentCheck(*offp))
944
    if (pp->AlignmentCheck(*offp))
957
        return -EFAULT;
945
        return -EFAULT;
958
 
946
 
959
    // check for free access to user buffer
947
    // check for free access to user buffer
960
    if (!access_ok(VERIFY_WRITE, pcBuffer, count))
948
    if (!access_ok( pcBuffer, count))
961
        return -EFAULT;
949
        return -EFAULT;
962
 
950
 
963
    // do I still have the same modifier?
951
    // do I still have the same modifier?
964
    if (pp->bModifier != pd->bCurrentModifier)
952
    if (pp->bModifier != pd->bCurrentModifier)
965
        setModifier(pd, pp->bModifier);
953
        setModifier(pd, pp->bModifier);
Line 997... Line 985...
997
    // inhibit misaligned accesses
985
    // inhibit misaligned accesses
998
    if (pp->AlignmentCheck(*offp))
986
    if (pp->AlignmentCheck(*offp))
999
        return -EFAULT;
987
        return -EFAULT;
1000
 
988
 
1001
    // check for free access to user buffer
989
    // check for free access to user buffer
1002
    if (!access_ok(VERIFY_READ, pcBuffer, count))
990
    if (!access_ok( pcBuffer, count))
1003
        return -EFAULT;
991
        return -EFAULT;
1004
 
992
 
1005
    // do I still have the same modifier?
993
    // do I still have the same modifier?
1006
    if (pp->bModifier != pd->bCurrentModifier)
994
    if (pp->bModifier != pd->bCurrentModifier)
1007
        setModifier(pd, pp->bModifier);
995
        setModifier(pd, pp->bModifier);