| /pcivme-3.2/test/simpleTest |
|---|
| Cannot display: file marked as a binary type. |
| svn:mime-type = application/octet-stream |
| /pcivme-3.2/test/simpleTest.c |
|---|
| 99,7 → 99,7 |
| if (error) |
| { |
| dwErrorCount++; |
| printf("%s : Can't write @ adr: 0x%08x (%s)\n", cszPrgName, start, strerror(error)); |
| printf("%s : Can't write @ adr: 0x%08x AM 0x%0x %d(%s)\n", cszPrgName, start, accessWidth,error, strerror(error)); |
| } |
| else |
| { |
| 228,7 → 228,7 |
| { |
| printf("%s : Can't open path to %s! (%s)\n", cszPrgName, fname, strerror(error)); |
| exit(error); |
| } |
| } |
| //----------------------------------------------------------------------------------- |
| // loop until error |
| /pcivme-3.2/lib/pcivme_ni.c |
|---|
| 129,6 → 129,7 |
| if (ioctl(dev->nFileNo, PCIVME_INIT_HARDWARE, &init) < 0) |
| { |
| dev->nLastError = errno; |
| printf("initHardware:err=%d %s\n" , errno, strerror(errno) ); |
| return errno; |
| } |
| 147,6 → 148,7 |
| if (ioctl(dev->nFileNo, PCIVME_DEINIT_HARDWARE, &deinit) < 0) |
| { |
| dev->nLastError = errno; |
| printf("deInitHardware:err=%d %s\n" , errno, strerror(errno) ); |
| return errno; |
| } |
| 165,10 → 167,11 |
| return errno; |
| dev->nFileNo = open(cszDeviceName, O_RDWR); |
| printf("VMEopen: dev->nFileNo %d size=%d %s\n" , dev->nFileNo,sizeof(*dev), cszDeviceName ); |
| if (dev->nFileNo == -1) |
| { |
| error = errno; |
| printf("VMEopen:err=%d %s\n" , error, strerror(error) ); |
| free(dev); |
| return error; |
| } |
| 177,7 → 180,7 |
| *pnHandle = (int)dev; |
| error = initHardware(dev); |
| if (error) |
| if (error) |
| return error; |
| dev->nLastError = 0; |
| 205,6 → 208,7 |
| if (ioctl(dev->nFileNo, PCIVME_SET_ACCESS_PARA, &access_command) < 0) |
| { |
| dev->nLastError = errno; |
| printf("setAccessProperties:err=%d %s\n" , errno, strerror(errno) ); |
| return errno; |
| } |
| 220,18 → 224,31 |
| size_t count = (size_t)(ulElementCount * ubAccessWidth); |
| ssize_t result; |
| int error; |
| long pos; |
| printf("VMEread: AW 0x%0x 0x%0x , AM 0x%0x \n", dev->cAccessWidth, ubAccessWidth, dev->cAddressModifier); |
| if (dev->cAccessWidth != ubAccessWidth) |
| { |
| if ((error = setAccessProperties(nHandle, dev->cAddressModifier, ubAccessWidth))) |
| return error; |
| } |
| pos = lseek(dev->nFileNo, ulAddress, SEEK_SET); |
| if ( pos < 0){ |
| printf("VMEread: pos=0x%08lx dev->nFileNo=%d ADDR=0x%08lx %s\n",pos, dev->nFileNo, ulAddress, strerror(errno)); |
| switch (errno){ |
| case EBADF:printf("errno =EBADF\n");break; |
| case EINVAL:printf("errno =EINVAL\n");break; |
| case EOVERFLOW:printf("errno =EOVERFLOW\n");break; |
| case ESPIPE:printf("errno =ESPIPE\n");break; |
| case ENXIO:printf("errno =ENXIO\n");break; |
| } |
| //return errno; |
| } |
| if (lseek(dev->nFileNo, ulAddress, SEEK_SET) < 0) |
| return errno; |
| result = read(dev->nFileNo, pvBuffer, count); |
| printf("VMEread: read %d dev->nFileNo=%d err=%d %s\n",count, dev->nFileNo, errno, strerror(errno)); |
| if (result != count) |
| { |
| if (result < 0) |
| 252,7 → 269,9 |
| size_t count = (size_t)(ulElementCount * ubAccessWidth); |
| ssize_t result; |
| int error; |
| long pos; |
| printf("VMEwrite: AW 0x%0x 0x%0x , AM 0x%0x \n", dev->cAccessWidth, ubAccessWidth, dev->cAddressModifier); |
| if (dev->cAccessWidth != ubAccessWidth) |
| { |
| if ((error = setAccessProperties(nHandle, dev->cAddressModifier, ubAccessWidth))) |
| 259,16 → 278,26 |
| return error; |
| } |
| if (lseek(dev->nFileNo, ulAddress, SEEK_SET) < 0) |
| return errno; |
| pos = lseek(dev->nFileNo, ulAddress, SEEK_SET); |
| if (pos < 0){ |
| printf("VMEwrite: pos=0x%08lx dev->nFileNo=%d ADDR=0x%08lx %s\n",pos, dev->nFileNo, ulAddress, strerror(errno)); |
| switch (errno){ |
| case EBADF:printf("errno =EBADF\n");break; |
| case EINVAL:printf("errno =EINVAL\n");break; |
| case EOVERFLOW:printf("errno =EOVERFLOW\n");break; |
| case ESPIPE:printf("errno =ESPIPE\n");break; |
| case ENXIO:printf("errno =ENXIO\n");break; |
| } |
| //return errno; |
| } |
| result = write(dev->nFileNo, pvBuffer, count); |
| printf("VMEwrite: write %d dev->nFileNo=%d err=%d %s\n",count, dev->nFileNo,errno, strerror(errno)); |
| if (result != count) |
| { |
| if (result < 0) |
| { |
| dev->nLastError = errno; |
| return errno; |
| } |
| else |
| /pcivme-3.2/driver/pcivme_load |
|---|
| 19,6 → 19,9 |
| # the modulenumber must be given |
| if test $1 |
| then |
| # invoke insmod |
| lsmod | grep $module |
| /sbin/rmmod $module |
| # invoke insmod |
| /sbin/insmod $module.ko || /sbin/insmod $module.o || exit 1 |
| 30,6 → 33,7 |
| chgrp $group /dev/${device}$1 |
| chmod $mode /dev/${device}$1 |
| ls -latr /dev/${device}$1 |
| else |
| echo "usage: pcivme_load module_number" |
| fi |
| /pcivme-3.2/driver/pcivme.mod.c |
|---|
| 60,4 → 60,4 |
| "depends="; |
| MODULE_INFO(srcversion, "BC454FCFCA2F039491927C2"); |
| MODULE_INFO(srcversion, "A7BD2186CAC138621574913"); |
| /pcivme-3.2/driver/fops.c |
|---|
| 349,7 → 349,7 |
| u32 adr; |
| int err; |
| PRINTK(KERN_DEBUG "%s : CmdMachine()\n", DEVICE_NAME); |
| //PRINTK(KERN_DEBUG "%s : CmdMachine()\n", DEVICE_NAME); |
| // loop through the init (or deinit) list |
| while (psInitElement->bDestination != STOP) |
| 402,7 → 402,7 |
| int err; |
| PCIVME_INIT_ELEMENT *element = init->sVie; |
| PRINTK(KERN_DEBUG "%s : init_hardware()\n", DEVICE_NAME); |
| PRINTK(KERN_INFO "%s : init_hardware()\n", DEVICE_NAME); |
| err = CmdMachine(pd, element); |
| if (err) |
| 621,7 → 621,7 |
| u16 intCSR = readw((const volatile void *) pd->pPCIADAIntCSR); |
| int status = 0; |
| PRINTK(KERN_DEBUG "%s : VMEMM_RESET()\n", DEVICE_NAME); |
| PRINTK(KERN_INFO "%s : VMEMM_RESET()\n", DEVICE_NAME); |
| // am I connected and switched on?? |
| if ((cntrl & 0x0980) == 0x0980) |
| 801,8 → 801,17 |
| return 0; |
| } |
| /* |
| static long pcivme_compat_ioctl(struct file *pFile, unsigned int cmd, unsigned long arg){ |
| PRINTK(KERN_DEBUG "%s : pcivme_compat_ioctl(0x%08x), size = %d\n", DEVICE_NAME, cmd, _IOC_SIZE(cmd)); |
| return pcivme_ioctl(NULL, pFile, cmd,arg); |
| } |
| */ |
| static long pcivme_unlocked_ioctl(struct file *pFile, unsigned int cmd, unsigned long arg){ |
| long retval=0; |
| #if HAVE_UNLOCKED_IOCTL |
| struct mutex fs_mutex; |
| mutex_init(&fs_mutex); |
| 811,6 → 820,7 |
| lock_kernel(); |
| #endif |
| PRINTK(KERN_DEBUG "%s : pcivme_unlocked_ioctl(0x%08x), size = %d\n", DEVICE_NAME, cmd, _IOC_SIZE(cmd)); |
| retval = pcivme_ioctl(NULL, pFile, cmd,arg); |
| #if HAVE_UNLOCKED_IOCTL |
| 818,6 → 828,7 |
| #else |
| unlock_kernel(); |
| #endif |
| return retval; |
| } |
| 825,10 → 836,10 |
| { |
| DEVICE_OBJ *pd = 0; |
| DEVICE_OBJ *desc = 0; |
| int nMinor = MINOR(pInode->i_rdev); |
| int nMinor = MINOR(pInode->i_rdev); |
| struct list_head *ptr; |
| PRINTK(KERN_DEBUG "%s : pcivme_open(), %d, %d, scanning %d devices\n", DEVICE_NAME, major(pInode->i_rdev), nMinor, drv.count); |
| PRINTK(KERN_DEBUG "%s : pcivme_open(), %d, scanning %d devices\n", DEVICE_NAME, nMinor, drv.count); |
| /* search for device */ |
| for (ptr = drv.devList.next; ptr != &drv.devList; ptr = ptr->next) |
| 839,7 → 850,7 |
| { |
| if (test_connection(pd)) |
| { |
| printk(KERN_ERR "%s : connection test for module %d failed!\n", DEVICE_NAME, pd->cModuleNumber); |
| printk(KERN_ERR "%s : pcivme_open() connection test for module %d failed!\n", DEVICE_NAME, pd->cModuleNumber); |
| pd->bConnected = 0; |
| } |
| else |
| 850,7 → 861,7 |
| } |
| } |
| else |
| PRINTK(KERN_DEBUG "%s : module %d not connected!\n", DEVICE_NAME, nMinor); |
| PRINTK(KERN_DEBUG "%s pcivme_open(): module %d not connected!\n", DEVICE_NAME, nMinor); |
| } |
| if (desc) |
| 871,7 → 882,7 |
| pp->AlignmentCheck = MisalignmentForByteAccess; |
| pFile->private_data = (void *)pp; |
| PRINTK(KERN_DEBUG "%s : found VMEMM module with number %d.\n", DEVICE_NAME, nMinor); |
| PRINTK(KERN_DEBUG "%s : pcivme_open() found VMEMM module with number %d.\n", DEVICE_NAME, nMinor); |
| if (!pd->nOpenCounter) |
| { |
| 878,7 → 889,7 |
| err = CmdMachine(pd, init_element); |
| if (err) |
| { |
| printk(KERN_ERR "%s : default init failed with err = %d!\n", DEVICE_NAME, err); |
| printk(KERN_ERR "%s : pcivme_open() default init failed with err = %d!\n", DEVICE_NAME, err); |
| kfree_s(pp, sizeof(*pp)); // FREE(pFile->private_data); |
| return err; |
| } |
| 888,7 → 899,7 |
| } |
| else |
| { |
| printk(KERN_ERR "%s : No VMEMM module found.\n", DEVICE_NAME); |
| printk(KERN_ERR "%s pcivme_open(): No VMEMM module found.\n", DEVICE_NAME); |
| return -ENODEV; |
| } |
| 900,7 → 911,7 |
| { |
| PATH_OBJ *pp; |
| PRINTK(KERN_DEBUG "%s : release()\n", DEVICE_NAME); |
| PRINTK(KERN_DEBUG "%s : pcivme_release()\n", DEVICE_NAME); |
| if (pFile->private_data) |
| { |
| 1016,32 → 1027,43 |
| } |
| #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) |
| struct file_operations pcivme_fops = |
| // http://learninglinuxkernel.in/writing-char-driver-for-linux-kernel-2-6/ |
| // http://appusajeev.wordpress.com/2011/06/18/writing-a-linux-character-device-driver/ |
| loff_t pcivme_lseek(struct file* filep, loff_t offset, int whence) |
| { |
| NULL, /* lseek */ |
| pcivme_read, /* read */ |
| pcivme_write, /* write */ |
| NULL, /* readdir */ |
| NULL, /* select */ |
| pcivme_ioctl, /* ioctl */ |
| NULL, /* mmap */ |
| pcivme_open, /* open */ |
| NULL, /* flush */ |
| pcivme_release, /* release */ |
| }; |
| #else |
| PRINTK(KERN_DEBUG "%s : pcivme_lseek(0x%08x, %d)\n", DEVICE_NAME, (u32) offset, whence); |
| switch (whence) { |
| case 0: /* SEEK_SET */ |
| filep->f_pos = offset; |
| break; |
| case 1: /* SEEK_CUR */ |
| filep->f_pos += offset; |
| break; |
| case 2: /* SEEK_END */ |
| return -EINVAL; |
| default: |
| return -EINVAL; |
| }; |
| return filep->f_pos; |
| } |
| struct file_operations pcivme_fops = |
| { |
| .llseek = pcivme_lseek, /* lseek */ |
| .read = pcivme_read, /* read */ |
| .write = pcivme_write, /* write */ |
| // .compat_ioctl = pcivme_compat_ioctl, /* ioctl */ |
| .unlocked_ioctl = pcivme_unlocked_ioctl, /* ioctl */ |
| .open = pcivme_open, /* open */ |
| .release = pcivme_release, /* release */ |
| }; |
| #endif |
| /pcivme-3.2/driver/pcivme.ko |
|---|
| Cannot display: file marked as a binary type. |
| svn:mime-type = application/octet-stream |
| /pcivme-3.2/driver/main.c |
|---|
| 144,19 → 144,19 |
| { |
| if (check_mem_region(pci_resource_start(pPch->pciDev, 0), LCR_SPACE)) |
| { |
| PRINTK(KERN_DEBUG "%s : LCR 0x%08lx\n", DEVICE_NAME, pci_resource_start(pPch->pciDev, 0)); |
| PRINTK(KERN_DEBUG "%s : LCR 0x%08lx\n", DEVICE_NAME, (long unsigned int) pci_resource_start(pPch->pciDev, 0)); |
| return -EBUSY; |
| } |
| if (check_mem_region(pci_resource_start(pPch->pciDev, 2), CTL_SPACE)) |
| { |
| PRINTK(KERN_DEBUG "%s : CTL 0x%08lx\n", DEVICE_NAME, pci_resource_start(pPch->pciDev, 2)); |
| PRINTK(KERN_DEBUG "%s : CTL 0x%08lx\n", DEVICE_NAME, (long unsigned int) pci_resource_start(pPch->pciDev, 2)); |
| return -EBUSY; |
| } |
| if (check_mem_region(pci_resource_start(pPch->pciDev, 2) + CTL_SPACE, VME_SPACE)) |
| { |
| PRINTK(KERN_DEBUG "%s : VME 0x%08lx\n", DEVICE_NAME, pci_resource_start(pPch->pciDev, 2) + CTL_SPACE); |
| PRINTK(KERN_DEBUG "%s : VME 0x%08lx\n", DEVICE_NAME, (long unsigned int) pci_resource_start(pPch->pciDev, 2) + CTL_SPACE); |
| return -EBUSY; |
| } |
| /pcivme-3.2/driver/Makefile |
|---|
| 71,8 → 71,9 |
| #**************************************************************************** |
| # where the driver should be installed - change here for cross install - currently not functional |
| # |
| INSTALL_LOCATION = /lib/modules/2.6.24-19-generic/ubuntu/misc/ |
| INSTALL_LOCATION = /lib/modules/$(shell uname -r)/kernel/drivers/misc/ |
| #**************************************************************************** |
| # get extracted kernel VERSION and PATCHLEVEL for comparison |
| # decide to use KBUILD for kernels greater 2.6.0 |
| 79,14 → 80,12 |
| # |
| KVERSION := $(shell echo $(VERSION) | sed -e 's;\([1-9]\)\..*;\1;g' ) |
| KPATCHLEVEL := $(shell echo $(VERSION) | sed -e 's;[1-9]\.\([0-9]\{0,3\}\)\..*;\1;g' ) |
| USEKBUILD := $(shell if [ $(KVERSION) -gt 2 ] || [ $(KVERSION) -eq 2 ] && [ $(KPATCHLEVEL) -ge 6 ] ; \ |
| then echo "yes" ; else echo "no" ; fi) |
| USEKBUILD := yes |
| #**************************************************************************** |
| # some common switches and defines |
| # |
| DBG = __NO_DEBUG__ # or __DEBUG__ to debug the driver |
| #DBG = __DEBUG__ |
| SRC = . |
| 112,8 → 111,10 |
| #**************************************************************************** |
| # do it |
| # |
| KBUILD_CPPFLAGS += -D$(DBG) |
| all : message |
| $(MAKE) -C $(KERNSRC) M=$(PWD) V=$(VERBOSE) $(filter-out all, $(MAKECMDGOLAS)) modules |
| $(MAKE) -C $(KERNSRC) M=$(PWD) V=$(VERBOSE) $(filter-out all, $(MAKECMDGOLAS)) modules |
| else # <<<<< USEKBUILD >>>>>> |
| 177,7 → 178,9 |
| @ echo "***" |
| #********** root installation only ****************************************** |
| install: |
| install: |
| -rmmod pcivme |
| -cp -r pcivme.ko $(INSTALL_LOCATION) |
| ./pcivme_load 1 |
| endif # <<<<< HASVERSION_H >>>>>> |