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: Jukka Pietarinen <[email protected]>
To: Jenny Chen <[email protected]>
Cc: [email protected]
Date: Fri, 05 Oct 2007 20:39:13 +0300
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 Jenny Chen
References:
RE: Using Asyn driver or modifying devLib (or related programs) of EPICSbase for any knid of cPCI cards Jenny Chen
RE: Using Asyn driver or modifying devLib (or related programs) of EPICSbase for any knid of cPCI cards Emmanuel Mayssat

Navigate by Date:
Prev: RE: Use of waveform records Mark Rivers
Next: RE: Using Asyn driver or modifying devLib (or related programs) of EPICSbase for any knid of cPCI cards Jenny Chen
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 Emmanuel Mayssat
Next: RE: Using Asyn driver or modifying devLib (or related programs) of EPICSbase for any knid of cPCI cards Jenny Chen
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 ·