add support for uploading firmware on 64 bit arches, and added support
authorFrank Mori Hess <fmhess@speakeasy.net>
Thu, 17 Mar 2005 17:25:42 +0000 (17:25 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Thu, 17 Mar 2005 17:25:42 +0000 (17:25 +0000)
for loading up to 4 different firmware files (will be needed by
ni pci-6534).

comedi/comedi_fops.c
comedi/drivers/daqboard2000.c
comedi/drivers/me_daq.c
comedi/drivers/usbdux.c
comedi/drivers/usbduxfast.c
include/linux/comedi.h
include/linux/comedidev.h

index c99f05760f1943a8076115d87d4efc19bc2ca12e..d872a1967be9ee25137cf88b4a683b1e6c4b757d 100644 (file)
@@ -168,8 +168,9 @@ static int do_devconfig_ioctl(comedi_device *dev,comedi_devconfig *arg, unsigned
 
        it.board_name[COMEDI_NAMELEN-1]=0;
 
-       if(it.options[COMEDI_DEVCONF_AUX_DATA] &&
-          it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH]){
+       if(comedi_aux_data(it.options, 0) &&
+               it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH]){
+               int bit_shift;
                aux_len = it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
                if(aux_len<0)return -EFAULT;
 
@@ -177,12 +178,17 @@ static int do_devconfig_ioctl(comedi_device *dev,comedi_devconfig *arg, unsigned
                if(!aux_data)return -EFAULT;
 
                if(copy_from_user(aux_data,
-                   (void *)it.options[COMEDI_DEVCONF_AUX_DATA], aux_len)){
+                       comedi_aux_data(it.options, 0), aux_len)){
                        kfree(aux_data);
                        return -EFAULT;
                }
-
-               it.options[COMEDI_DEVCONF_AUX_DATA] = (unsigned long)aux_data;
+               it.options[COMEDI_DEVCONF_AUX_DATA_LO] = (unsigned long)aux_data;
+               if(sizeof(void*) > sizeof(int))
+               {
+                       bit_shift = sizeof(int) * 8;
+                       it.options[COMEDI_DEVCONF_AUX_DATA_HI] = ((unsigned long)aux_data) >> bit_shift;
+               }else
+                       it.options[COMEDI_DEVCONF_AUX_DATA_HI] = 0;
        }
 
        ret = comedi_device_attach(dev,&it);
index b24f497301343f248aa12f49eefba57495abd5af..fb39b4609d27118504dc5a29fe3d9d556043325f 100644 (file)
@@ -741,7 +741,7 @@ static int daqboard2000_attach(comedi_device *dev, comedi_devconfig *it)
     printk("Interrupt before is: %x\n", interrupt);
   */
 
-  aux_data = (void *)it->options[COMEDI_DEVCONF_AUX_DATA];
+  aux_data = comedi_aux_data(it->options, 0);
   aux_len = it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
 
   if(aux_data && aux_len){
index 8931feb392f74cd782db27ad2cc6e66d047a9b18..2b8b99ab95dba8aeee8362ec4780dbc74c98c67c 100644 (file)
@@ -810,7 +810,7 @@ found:
     unsigned char *aux_data;
     int aux_len;
 
-    aux_data = (unsigned char *)it->options[COMEDI_DEVCONF_AUX_DATA];
+    aux_data = comedi_aux_data(it->options, 0);
     aux_len = it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
 
     if(!aux_data || aux_len)return -EINVAL;
index af1e289f6a3e62b2b0ff1ff80913a5a2e67a0c46..1a7540084baf3ce4d30a832ef4b65de5ef8dd183 100644 (file)
@@ -2132,7 +2132,7 @@ static unsigned hex2unsigned(char *h) {
 #define FIRMWARE_MAX_LEN 0x2000
 
 // taken from David Brownell's fxload and adjusted for this driver
-static int read_firmware(usbduxsub_t* usbduxsub,int firmwarePtr,long size) {
+static int read_firmware(usbduxsub_t* usbduxsub,void *firmwarePtr,long size) {
        int i=0;
        unsigned char* fp=(char*)firmwarePtr;
        unsigned char* firmwareBinary=NULL;
@@ -2540,10 +2540,10 @@ static int usbdux_attach(comedi_device * dev, comedi_devconfig * it)
        usbduxsub[index].comedidev=dev;
 
        // trying to upload the firmware into the chip
-       if(it->options[COMEDI_DEVCONF_AUX_DATA] && 
+       if(comedi_aux_data(it->options, 0) && 
           it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]){
                read_firmware(usbduxsub,
-                             it->options[COMEDI_DEVCONF_AUX_DATA],
+                       comedi_aux_data(it->options, 0),
                              it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]);
        } 
 
index 9fb73bc6f7093addd618b8c585a4d385813257ef..3362c3edfa523040a9a3b52ea774e0cfd84fe444 100644 (file)
@@ -1333,7 +1333,7 @@ static unsigned hex2unsigned(char *h) {
 #define FIRMWARE_MAX_LEN 0x2000
 
 // taken from David Brownell's fxload and adjusted for this driver
-static int read_firmware(usbduxfastsub_t* usbduxfastsub,int firmwarePtr,long size) {
+static int read_firmware(usbduxfastsub_t* usbduxfastsub, void *firmwarePtr,long size) {
        int i=0;
        unsigned char* fp=(char*)firmwarePtr;
        unsigned char* firmwareBinary=NULL;
@@ -1670,10 +1670,10 @@ static int usbduxfast_attach(comedi_device * dev, comedi_devconfig * it)
        usbduxfastsub[index].comedidev=dev;
 
        // trying to upload the firmware into the chip
-       if(it->options[COMEDI_DEVCONF_AUX_DATA] && 
+       if(comedi_aux_data(it->options, 0) && 
           it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]){
                read_firmware(usbduxfastsub,
-                             it->options[COMEDI_DEVCONF_AUX_DATA],
+                       comedi_aux_data(it->options, 0),
                              it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]);
        } 
 
index 7ad60f90573d643f2f44dbb2ad6cb336bc3c909e..90b5644610672e16d9f4c25466e4c4d254040a90 100644 (file)
@@ -41,8 +41,14 @@ extern "C" {
 
 /* number of config options in the config structure */
 #define COMEDI_NDEVCONFOPTS 32
-#define COMEDI_DEVCONF_AUX_DATA                30
-#define COMEDI_DEVCONF_AUX_DATA_LENGTH 31
+/*length of nth chunk of firmware data*/
+#define COMEDI_DEVCONF_AUX_DATA3_LENGTH                25
+#define COMEDI_DEVCONF_AUX_DATA2_LENGTH                26
+#define COMEDI_DEVCONF_AUX_DATA1_LENGTH                27
+#define COMEDI_DEVCONF_AUX_DATA0_LENGTH                28
+#define COMEDI_DEVCONF_AUX_DATA_HI             29      /*most significant 32 bits of pointer address (if needed)*/
+#define COMEDI_DEVCONF_AUX_DATA_LO             30      /*least significant 32 bits of pointer address*/
+#define COMEDI_DEVCONF_AUX_DATA_LENGTH 31      /* total data length */
 
 /* max length of device and driver names */
 #define COMEDI_NAMELEN 20
@@ -438,9 +444,12 @@ struct comedi_bufinfo_struct{
        information about their use
 */
 
-#define GPCT_X1                 0x01 // X1 encoding
-#define GPCT_X2                 0x02 // X2 encoding
-#define GPCT_X4                 0x04 // X3 encoding
+// X1 encoding
+#define GPCT_X1                 0x01
+// X2 encoding
+#define GPCT_X2                 0x02
+// X3 encoding
+#define GPCT_X4                 0x04 
 // When to take into account the indexpulse:
 #define GPCT_IndexPhaseHighHigh 0
 #define GPCT_IndexPhaseLowHigh 1
index 93d3909f4418e7067e6db61fead693602abc5d2f..b5028f350e6218d5af8a4a8aaaaa26aa917a8662 100644 (file)
@@ -367,6 +367,30 @@ void comedi_buf_memcpy_from( comedi_async *async, unsigned int offset, void *des
 unsigned int comedi_buf_munge( comedi_device *dev, comedi_subdevice *s,
        unsigned int num_bytes );
 
+static inline void* comedi_aux_data(int options[], int n)
+{
+       unsigned long address;
+       unsigned long addressLow;
+       int bit_shift;
+       if(sizeof(int) >= sizeof(void*))
+               address = options[COMEDI_DEVCONF_AUX_DATA_LO];
+       else
+       {
+               address = options[COMEDI_DEVCONF_AUX_DATA_HI];
+               bit_shift = sizeof(int) * 8;
+               address <<= bit_shift;
+               addressLow = options[COMEDI_DEVCONF_AUX_DATA_LO];
+               addressLow &= (1UL << bit_shift) - 1;
+               address |= addressLow;
+       }
+       if(n >= 1)
+               address += options[COMEDI_DEVCONF_AUX_DATA0_LENGTH];
+       if(n >= 2)
+               address += options[COMEDI_DEVCONF_AUX_DATA1_LENGTH];
+       if(n >= 3)
+               address += options[COMEDI_DEVCONF_AUX_DATA2_LENGTH];
+       return (void*) address;
+}
 //#ifdef CONFIG_COMEDI_RT
 #include <linux/comedi_rt.h>
 //#endif