Hi,
I've a PCI card and am told that certain onboard registers are memory
mapped out into the PCI memory at a particular offset from the
PCI_BASE_ADDRESS_2 of the onboard device (the address in this case is
0xfc020000). To read/write to these 32bit registers then I use the snippet
below. I compile with gcc altregread.c -D __KERNEL__ -o altregread.o but
then get lines and lines of parse errors in header files (see below). The
KERNEL bit is for the io.h header file.
Ideas? Thanks in advance.
#include<stdio.h>
#include<stdlib.h>
#include<asm/io.h> //contains readl/writel, etc.
int main(void)
{
int status, *base = ioremap(0xfc020000, 1024*1024);
status = readl(base + 0x40);
iounmap(base);
printf("%x", status);
return(0);
}
In file included from /usr/include/linux/affs_fs_i.h:5,
from /usr/include/linux/fs.h:270,
from
/usr/include/linux/capability.h:13,
from
/usr/include/linux/binfmts.h:5,
from
/usr/include/linux/sched.h:8,
from
/usr/include/linux/vmalloc.h:4,
from
/usr/include/asm/io.h:102,
from
altregread.c:4:
/usr/include/linux/time.h:69: warning: `FD_SET'
redefined
/usr/include/sys/select.h:63: warning: this is the location of
the previous definition
/usr/include/linux/time.h:70: warning: `FD_CLR'
redefined
/usr/include/sys/select.h:64: warning: this is the location of
the previous definition
/usr/include/linux/time.h:71: warning: `FD_ISSET'
redefined
/usr/include/sys/select.h:65: warning: this is the location of
the previous definition
/usr/include/linux/time.h:72: warning: `FD_ZERO'
redefined
/usr/include/sys/select.h:66: warning: this is the location of
the previous definition
In file included from
/usr/include/linux/affs_fs_i.h:5,
from
/usr/include/linux/fs.h:270,
from
/usr/include/linux/capability.h:13,
from
/usr/include/linux/binfmts.h:5,
from
/usr/include/linux/sched.h:8,
from
/usr/include/linux/vmalloc.h:4,
from
/usr/include/asm/io.h:102,
from
altregread.c:4:
/usr/include/linux/time.h:9: redefinition of `struct
timespec'
/usr/include/linux/time.h:51: parse error before
`suseconds_t'
/usr/include/linux/time.h:51: warning: no semicolon at end of
struct or union
/usr/include/linux/time.h:88: field `it_interval' has
incomplete type
/usr/include/linux/time.h:89: field `it_value' has
incomplete type
In file included from /usr/include/linux/fs.h:270,
from /usr/include/linux/capability.h:13,
from /usr/include/linux/binfmts.h:5,
from
/usr/include/linux/sched.h:8,
from
/usr/include/linux/vmalloc.h:4,
from
/usr/include/asm/io.h:102,
from
altregread.c:4:
/usr/include/linux/affs_fs_i.h:11: field `kc_lru_time' has
incomplete type
In file included from /usr/include/linux/fs.h:272,
from /usr/include/linux/capability.h:13,
from /usr/include/linux/binfmts.h:5,
from
/usr/include/linux/sched.h:8,
from
/usr/include/linux/vmalloc.h:4,
from
/usr/include/asm/io.h:102,
from
altregread.c:4:
/usr/include/linux/efs_fs_i.h:13: parse error before
`efs_ino_t'
/usr/include/linux/efs_fs_i.h:13: warning: data definition has
no type or storage class
/usr/include/linux/efs_fs_i.h:49: parse error
before `uint32_t'
/usr/include/linux/efs_fs_i.h:49: warning: no semicolon
at end of struct or union
/usr/include/linux/efs_fs_i.h:57: parse error
before `}'
In file included from /usr/include/linux/coda_fs_i.h:14,
from /usr/include/linux/fs.h:273,
from
/usr/include/linux/capability.h:13,
from
/usr/include/linux/binfmts.h:5,
from
/usr/include/linux/sched.h:8,
from
/usr/include/linux/vmalloc.h:4,
from
/usr/include/asm/io.h:102,
from
altregread.c:4:
/usr/include/linux/coda.h:109: warning: redefinition of
`u_quad_t'
/usr/include/sys/types.h:38: warning: `u_quad_t' previously
declared here
In file included from /usr/include/linux/sched.h:13,
from /usr/include/linux/vmalloc.h:4,
from
/usr/include/asm/io.h:102,
from
altregread.c:4:
/usr/include/linux/times.h:5: parse error before
`clock_t'
/usr/include/linux/times.h:5: warning: no semicolon at end of
struct or union
/usr/include/linux/times.h:6: warning: data definition has
no type or storage class
/usr/include/linux/times.h:7: parse error before
`tms_cutime'
/usr/include/linux/times.h:7: warning: data definition has no
type or storage class
/usr/include/linux/times.h:8: parse error before
`tms_cstime'
/usr/include/linux/times.h:8: warning: data definition has no
type or storage class
In file included from /usr/include/linux/sched.h:14,
from /usr/include/linux/vmalloc.h:4,
from
/usr/include/asm/io.h:102,
from
altregread.c:4:
/usr/include/linux/timex.h:159: field `time' has incomplete
type
In file included from /usr/include/linux/signal.h:5,
from /usr/include/linux/sched.h:23,
from
/usr/include/linux/vmalloc.h:4,
from
/usr/include/asm/io.h:102,
from
altregread.c:4:
/usr/include/asm/siginfo.h:48: parse error before
`clock_t'
/usr/include/asm/siginfo.h:48: warning: no semicolon at end of
struct or union
/usr/include/asm/siginfo.h:48: warning: no semicolon at end
of struct or union
/usr/include/asm/siginfo.h:49: warning: no semicolon at
end of struct or union
/usr/include/asm/siginfo.h:50: warning: data
definition has no type or storage class
/usr/include/asm/siginfo.h:62:
parse error before `}'
/usr/include/asm/siginfo.h:62: warning: data
definition has no type or storage class
/usr/include/asm/siginfo.h:63:
parse error before `}'
/usr/include/asm/siginfo.h:63: warning: data
definition has no type or storage class
In file included from
/usr/include/linux/sched.h:23,
from
/usr/include/linux/vmalloc.h:4,
from
/usr/include/asm/io.h:102,
from
altregread.c:4:
/usr/include/linux/signal.h:15: parse error before
`siginfo_t'
/usr/include/linux/signal.h:15: warning: no semicolon at end of
struct or union
In file included from /usr/include/linux/sched.h:71,
from /usr/include/linux/vmalloc.h:4,
from
/usr/include/asm/io.h:102,
from
altregread.c:4:
/usr/include/linux/resource.h:22: field `ru_utime' has
incomplete type
/usr/include/linux/resource.h:23: field `ru_stime' has
incomplete type
In file included from /usr/include/linux/vmalloc.h:4,
from /usr/include/asm/io.h:102,
from
altregread.c:4:
/usr/include/linux/sched.h:288: field `times' has
incomplete type
In file included from /usr/include/linux/vmalloc.h:4,
from /usr/include/asm/io.h:102,
from
altregread.c:4:
/usr/include/linux/sched.h:500: parse error before
`siginfo_t'
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!