EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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

Subject: Re: A simple EPICS driver example for PCI devices using asynPortDriver on Linux
From: "Perez Juarez, Emilio \(DLSLtd, RAL, LSCI\) via Tech-talk" <tech-talk at aps.anl.gov>
To: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>, "Wang, Lin" <wanglin at ihep.ac.cn>
Date: Sun, 4 Dec 2022 10:39:37 +0000
Hi Lin Wang and thanks for sharing,

I have some comments/questions:
  • Is there a reason why you prefer to use ioctl for register access instead of mmap and letting userspace access directly?
  • I know security is usually not a priority, but I've noticed you don't check/validate the register offset passed in the ioctl syscall, which means it could give access to other resources (memory or I/O)
  • You might want to provide a fallback path when the target system doesn't have your kernel module installed, in which case, you can get register access by mmap'ing /sys/bus/pci/devices/<X>/resource<Y>, where <X> is the domain:bus:devices.function of your device and <Y> is the BAR number you want to access
  • I noticed you dereference a volatile pointer to access the registers, in kernel space I'd recommend using the functions ioread<X> or iowrite<X> instead, where <X> is the access size (8, 16 or 32). This will make code more portable.
I hope any of that was useful,

Kind Regards,
Emilio


From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Wang, Lin via Tech-talk <tech-talk at aps.anl.gov>
Sent: 02 December 2022 10:15
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: A simple EPICS driver example for PCI devices using asynPortDriver on Linux
 

Dear all,


A simple EPICS driver example for PCI devices using asynPortDriver on Linux is shared in the following GitHub link in case somebody might be interested,

https://github.com/wanglin86769/cpciEpicsApp


This is an EPICS IOC developed for the LLRF system of a small-scale accelerator facility at CSNS campus. The LLRF board is a customized cPCI FPGA board with PCI 9056 bridge, the control interface is merely register access plus waveform read with 1 second update period, no interrupt or DMA is needed.


The Linux driver part is implemented as kernel module rather than UIO (Userspace I/O). This example is only useful for simple customized PCI devices that does not need interrupt and DMA, and only one MMIO (Memory mapped I/O) BAR is used to access the FPGA registers.


This is my first assignment to control PCI under Linux rather than vxWorks, any suggestion is appreciated.



Regards,

Lin Wang

Staff Engineer

Controls Group, Accelerator System Division, CSNS (China Spallation Neutron Source)

IHEP (Institute of High Energy Physics), Chinese Academy of Science

 

-- 

This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
 


Replies:
Re: A simple EPICS driver example for PCI devices using asynPortDriver on Linux Wang, Lin via Tech-talk
Re: A simple EPICS driver example for PCI devices using asynPortDriver on Linux Michael Davidsaver via Tech-talk
References:
A simple EPICS driver example for PCI devices using asynPortDriver on Linux Wang, Lin via Tech-talk

Navigate by Date:
Prev: Re: booting error on VxWorks Andrew Johnson via Tech-talk
Next: Re: A simple EPICS driver example for PCI devices using asynPortDriver on Linux Wang, Lin via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
Navigate by Thread:
Prev: A simple EPICS driver example for PCI devices using asynPortDriver on Linux Wang, Lin via Tech-talk
Next: Re: A simple EPICS driver example for PCI devices using asynPortDriver on Linux Wang, Lin via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
ANJ, 06 Dec 2022 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·