On 5 Jul, Oliver Ryan wrote:
> 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);
>> }
>
Are you writing a kernel module? Device driver? Or actually doing kernel hacking?
If you are then there's a ton of stuff you have to #include that you're not.
Have a look on google or similar for docs on kernel hacking, module and device driver writing.
You can't just write user programs that use kernel functions or read/write memory addresses
This ain't DOS, CP/M or MacOS.
--
--Harry Moreau----------------
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!