Messages in this thread | | | Date | Wed, 30 Apr 1997 20:45:44 -0700 (PDT) | From | Mark Johnson <> | Subject | writing to an IO port |
| |
I'm sorry if this might not be completely linux-kernel related. It seemed appropriate to me, since it the kernel routines I need to understand to get this thing to work.
I have a very simple ISA based watchdog card. Its for a Pentium based PC running kernel 2.0.29. All that needs to be done is write to an IO port to initialize the card's timer. The value written to the port sets the timeout before the card will pull the reset switch (wired to the card).
If 0 is written to the port, it disables the card. The card is setup to use port 0x380.
Here is an example from the manual of how to use it (for ioport 300):
PCWDTaddress = &H300 LatchValue= &H7 DO WHILE INKEYS$="" OUT PCWDTaddress,LatchValue LOOP OUT PCWDTaddress,0 END
Here is the code I came up:
/* gcc -O2 -o pcwdt pcwdt.c */ #include <unistd.h> #include <asm/io.h> main () { if (ioperm (0x380, 1, 1)) exit (1);
while (!sleep(10)) outb (0xd, 0x380);
outb (0x0, 0x380); }
Does this look correct? I'm inexperienced with this sort of thing, and the man page for outb and ioperm aren't very clear to me. I've tried the above code and it doesn't seem to work :( Actually, I tried just setting the timer with the first outb, which sets it to reset in 5 minutes if not written to again, but it never resets. Thanks for any help.
| |