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  <20092010  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  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: Access to IO registers from user-space in recent Linux versions
From: "Mark Rivers" <[email protected]>
To: "Till Straumann" <[email protected]>
Cc: [email protected], tech-talk <[email protected]>
Date: Thu, 9 Jul 2009 15:42:18 -0500
Till,

Your program works on my system accessing the EPP port (0x378).

So it must not be a security problem, it must be a problem with my code.

Thanks very much for sending the code.

Mark


-----Original Message-----
From: Till Straumann [mailto:[email protected]] 
Sent: Thursday, July 09, 2009 2:06 PM
To: Mark Rivers
Cc: tech-talk; [email protected]
Subject: Re: Access to IO registers from user-space in recent Linux
versions

The iopl(3) followed by 'in' works fine for me (both, when compiled -m32

or without)

till@tillbook:~/tmp$ uname -a
Linux tillbook 2.6.28-13-generic #45-Ubuntu SMP Tue Jun 30 22:12:12 UTC 
2009 x86_64 GNU/Linux


#include <stdio.h>
#include <sys/io.h>

int main(int argc, char **argv)
{
unsigned char  v;
unsigned short p;

    if ( argc < 2 || 1 != sscanf(argv[1],"%hi",&p) ) {
        fprintf(stderr,"Usage: %s <port>\n",argv[0]);
        return 1;
    }

    if ( iopl(3) ) {
        perror("iopl");
        return 1;
    }

    asm volatile ( "inb %1,%0" : "=a" (v) : "d"(p));

    printf("0x%02x\n",v);
    return 0;
}

-- Till


Mark Rivers wrote:
>
> Folks,
>
>  
>
> I have an EPICS application that directly accesses the parallel port 
> (EPP) registers from user space on Linux.  This is to communicate with

> an XIA Saturn spectroscopy module.
>
>  
>
> In order versions of Linux this worked fine if I ran the application 
> as root, or by calling iopl(3) as root before exec-ing the EPICS 
> application.
>
>  
>
> I am now trying to run this under a recent Linux (Redhat Fedora)
version
>
>  
>
> baja:~>more /proc/version
>
> Linux version 2.6.26.8-57.fc8 ([email protected])
>
> (gcc version 4.1.2 20070925 (Red Hat 4.1.2-33))
>
> #1 SMP Thu Dec 18 18:59:49 EST 2008
>
>  
>
> The EPICS IOC now crashes with a segmentation fault when trying to 
> access the EPP port, even when running as root, and the following 
> entry appears in /var/log/messages
>
>  
>
> Jul  9 11:43:44 baja kernel: dxpApp[27837] general protection 
> ip:80a90a6 sp:ff8ea8ac error:0 in dxpApp[8048000+1f7000]
>
>  
>
> Does anyone know what one needs to do in recent Linux versions to get 
> access to the IO registers from user-space?
>
>  
>
> Thanks,
>
> Mark
>
>  
>
>  
>



Replies:
RE: [APS Beamline_controls] Access to IO registers from user-spacein recent Linux versions Mark Rivers
References:
Access to IO registers from user-space in recent Linux versions Mark Rivers
Re: Access to IO registers from user-space in recent Linux versions Till Straumann

Navigate by Date:
Prev: Re: Access to IO registers from user-space in recent Linux versions John Sinclair
Next: Re: Access to IO registers from user-space in recent Linux versions J. Lewis Muir
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Access to IO registers from user-space in recent Linux versions David Kline
Next: RE: [APS Beamline_controls] Access to IO registers from user-spacein recent Linux versions Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 31 Jan 2014 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·