From 583dccc2befa17cd7f7133e05d812658a3f86dc7 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Thu, 17 Mar 2005 17:25:42 +0000 Subject: [PATCH] add support for uploading firmware on 64 bit arches, and added support for loading up to 4 different firmware files (will be needed by ni pci-6534). --- comedi/comedi_fops.c | 16 +++++++++++----- comedi/drivers/daqboard2000.c | 2 +- comedi/drivers/me_daq.c | 2 +- comedi/drivers/usbdux.c | 6 +++--- comedi/drivers/usbduxfast.c | 6 +++--- include/linux/comedi.h | 19 ++++++++++++++----- include/linux/comedidev.h | 24 ++++++++++++++++++++++++ 7 files changed, 57 insertions(+), 18 deletions(-) diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index c99f0576..d872a196 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -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); diff --git a/comedi/drivers/daqboard2000.c b/comedi/drivers/daqboard2000.c index b24f4973..fb39b460 100644 --- a/comedi/drivers/daqboard2000.c +++ b/comedi/drivers/daqboard2000.c @@ -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){ diff --git a/comedi/drivers/me_daq.c b/comedi/drivers/me_daq.c index 8931feb3..2b8b99ab 100644 --- a/comedi/drivers/me_daq.c +++ b/comedi/drivers/me_daq.c @@ -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; diff --git a/comedi/drivers/usbdux.c b/comedi/drivers/usbdux.c index af1e289f..1a754008 100644 --- a/comedi/drivers/usbdux.c +++ b/comedi/drivers/usbdux.c @@ -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]); } diff --git a/comedi/drivers/usbduxfast.c b/comedi/drivers/usbduxfast.c index 9fb73bc6..3362c3ed 100644 --- a/comedi/drivers/usbduxfast.c +++ b/comedi/drivers/usbduxfast.c @@ -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]); } diff --git a/include/linux/comedi.h b/include/linux/comedi.h index 7ad60f90..90b56446 100644 --- a/include/linux/comedi.h +++ b/include/linux/comedi.h @@ -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 diff --git a/include/linux/comedidev.h b/include/linux/comedidev.h index 93d3909f..b5028f35 100644 --- a/include/linux/comedidev.h +++ b/include/linux/comedidev.h @@ -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 //#endif -- 2.26.2