>To: <[EMAIL PROTECTED]>
>Subject: [rtl] programming IO
>From: "Michael Nielsen" <[EMAIL PROTECTED]>
>Date: Sat, 27 Oct 2001 14:03:07 +0200
>
>Hi!
>Even though my problem isn't concerning realtime yet, i hope that you will
be able to help out.
>I have that some of you have maked some programs accessing IO, and thats
where my problem is right now.
>I am trying to make a realtime device driver ARCNET. The project is in its
early stages and i just start out with trying to make a device driver then
later on, make >it realtime.
>But it is givin me some problems when i try to write/read to the
ISA-netcard.
>The ISA-card is at adress 0x300 (the card is I/O mapped).
>The ISA-card have some internal RAM.
>My problem is like this : i write something to the internal RAM via a
data-register, then i write "something" else to the data-register, the i
read from the internal >RAM (same adress as i wrote to earlier) (this read
should put data into the data-register), but i only read the "something"
that i temporary wrote to the data->register before.
>I can easily register my ISA-card to port 0x300.
>I have put the source code at the buttom of this email.
>
>Does somebody have any idea to help me out ?
>
>Thanks in advance
>Michael
>
>//source-code starts here
>
>#ifndef __KERNEL__
># define __KERNEL__
>#endif
>#ifndef MODULE
># define MODULE
>#endif
>
>#include <linux/module.h>
>#include <linux/version.h>
>#include <linux/kernel.h>
>#include <linux/ioport.h>
>#include <linux/errno.h>
>#include <asm/system.h>
>#include <asm/bitops.h>
>#include <asm/io.h>
>
>#define ADRESS 0x300
>
...
>/*funktion til at initialisere isa-kortet*/
>void init_card(void){
> int value;
> void *io_base;
> io_base = ioremap(ADRESS,8);
> writeb(1,io_base+SUBADR); //prepare to write NODEID
> writeb(241,io_base+REG7); //NODEID=241
> writeb(0x7,io_base+DATA); //put 0x7 into data-register
> writeb(WRITE,io_base+ADR_PTR_H); //prepare to write
> writeb(0x11,io_base+ADR_PTR_L); //write to odd adr
> writeb(0xff,io_base+DATA); // put something else into
data-register than what was written
> writeb(READ,io_base+ADR_PTR_H); //prepare to read
> writeb(0x11,io_base+ADR_PTR_L); //read at adr=0x11
> value=readb(io_base+DATA);
> printk("First READ gives : %X \n",value);
> iounmap(io_base);
>}
>
>int init_module(void){
> int errno;
> char *nam="test driver";
> request_region(ADRESS,8,nam);
> init_card();
> return 0;
>}
>
>void cleanup_module(void){
> release_region(ADRESS,8);
>}
If your card is PCI :
--------------------
If you want to access register in your "memory mapped" card, try to use
ioremap_nocache() instead of ioremap().
Otherwise, when you read at same address you just write, you see the value
that is in cache and not the register value.
Look at file "pci.txt" at
http://www.linux.org.ve/pub/slackware/docs/linux-2.2.16/pci.txt
In your case, your card is ISA and not PCI.
I don't know if you have to use ioremap() or ioremap_nocache() with ISA card
(i think no, but i'm not sure).
In all case, your card is IO mapped and not Memory mapped, so i think that
you don't have to use "writeb()" or "readb()", but fct. like "outb()" and
"inb()"
Tell me if this help and sorry for my English, but I'm FRENCH.
Gerard LASSAILLY
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/