EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: Using Asyn driver or modifying devLib (or related programs) of EPICSbase for any knid of cPCI cards
From: "Jenny Chen" <[email protected]>
To: "'Jukka Pietarinen'" <[email protected]>
Cc: [email protected]
Date: Mon, 8 Oct 2007 16:28:10 +0800
> The sources for MRF CompactPCI EVG/EVR drivers are available from me. 
> Please let me know if you want a copy.

Thanks a lot if you can send me a copy. We may have a cPCI crate with an
Intel CPU and four DI/DO/AI/AO cards soon. The OS might be Fedora
Linux2.6. Before we write any Asyn driver for EPICS, I think we need to
know how to write/install the driver and implement test programs for the
cards. We purchase the cards locally (might be ADLink). We might also
buy some other cards later (might from other company). The Linux kernel
2.6 and 2.4 are quite different, right? The way to install driver for
cPCI cards is similar or not? One more question, is it difficult to
handle interrupt from cPCI cards?
Jenny.

-----Original Message-----
From: Jukka Pietarinen [mailto:[email protected]] 
Sent: Saturday, October 06, 2007 1:39 AM
To: Jenny Chen
Cc: [email protected]
Subject: Re: Using Asyn driver or modifying devLib (or related programs)
of EPICSbase for any knid of cPCI cards

Emmanuel Mayssat wrote:
> To find the pci address in linux, use 'lspci' as root
> The PCI address is function of the hardware location (pci slot) in the
> computer. So if you fiddle with the hardware that address will change.

The kernel driver should take care of handling the PCI addresses and 
provide a method to memory map (mmap) the hardware address into user 
space. When this is done the hardware I/O or memory space can be 
accessed directly from user space.

>> . insmod xxx.ko should be called once during system boot (this might
not
>> be correct, maybe just only once then don't have to be called
>> anymore)???
> 
> Look at 'modprobe' instead of 'insmod'. Modprobe loads driver
> dependencies, while insmod doesn't.
> Look at /etc/modprobe.conf or /etc/modules.conf that is where the
driver
> configuration goes. Use 'modprobe' in /etc/rc.d/rc.local

Many drivers allocate device numbers dynamically and the major number 
assigned can be found from /proc/devices. A device node in /dev has to 
be created for each major/minor combination the device is using. After 
this the application can open the device /dev/xxx and perform file 
operations e.g. mmap.

As an example the Linux kernel driver for the MRF cPCI-EVG is loaded 
following:

/sbin/modprobe pci_mrfevg || exit 1

majors=$(awk "\$2==\"mrfevg\" {print \$1}" /proc/devices)

echo "Found" $(echo $majors | wc -w) "Event Generators."
echo "Creating device nodes..."

device=1
for major in $majors; do
     dev=$(echo $device | awk '{ printf "%c", 96+ $1}')
     device=$((++device))
     rm -f /dev/eg$dev[0-3]
     echo "Creating nodes /dev/eg"$dev"[0-3] for major" $major
     mknod '/dev/eg'$dev'0' c $major 0
     mknod '/dev/eg'$dev'1' c $major 1
     mknod '/dev/eg'$dev'2' c $major 2
     mknod '/dev/eg'$dev'3' c $major 3
# Allow write access to members of group mrf
     chgrp mrf '/dev/eg'$dev[0-3]
     chmod g+w '/dev/eg'$dev'3'
done

In this driver minor number 3 provides a direct memory map to a PCI 
address space of the hardware.

Below is an excerpt from the API sources for the EVG to show how the
user space access to the EVG registers is gained. The function is called

with "/dev/ega3" as the device name and it return a pointer to a user 
space address (*pEg) which the kernel directly maps to hardware.

int EvgOpen(struct MrfEgRegs **pEg, char *device_name)
{
   int fd;

   /* Open Event Generator device for read/write */
   fd = open(device_name, O_RDWR);
#ifdef DEBUG
   DEBUG_PRINTF("EvgOpen: open(\"%s\", O_RDWR) returned %d\n", 
device_name, fd);
#endif
   if (fd != -1)
     {
       /* Memory map Event Generator registers */
       *pEg = (struct MrfEgRegs *) mmap(0, EVG_MEM_WINDOW, PROT_READ | 
PROT_WRITE, MAP_SHARED, fd, 0);
#ifdef DEBUG
   DEBUG_PRINTF("EvgOpen: mmap returned %08x, errno %d\n", (int) *pEg,
                errno);
#endif
       if (*pEg == MAP_FAILED)
         {
           close(fd);
           return -1;
         }
     }

   return fd;
}

The sources for MRF CompactPCI EVG/EVR drivers are available from me. 
Please let me know if you want a copy.

Regards,
Jukka


Replies:
RE: Using Asyn driver or modifying devLib (or related programs) of EPICSbase for any knid of cPCI cards Emmanuel Mayssat
Re: Using Asyn driver or modifying devLib (or related programs) of EPICSbase for any knid of cPCI cards Andrew Johnson
References:
Re: Using Asyn driver or modifying devLib (or related programs) of EPICSbase for any knid of cPCI cards Jukka Pietarinen

Navigate by Date:
Prev: Re: Using Asyn driver or modifying devLib (or related programs) of EPICSbase for any knid of cPCI cards Jukka Pietarinen
Next: PV aliases Lecorche Eric
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Using Asyn driver or modifying devLib (or related programs) of EPICSbase for any knid of cPCI cards Jukka Pietarinen
Next: RE: Using Asyn driver or modifying devLib (or related programs) of EPICSbase for any knid of cPCI cards Emmanuel Mayssat
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Nov 2011 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·