home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.sys5.r4:1226 comp.unix.pc-clone.32bit:1022 comp.sys.ibm.pc.misc:16543
- Newsgroups: comp.unix.sys5.r4,comp.unix.pc-clone.32bit,comp.sys.ibm.pc.misc
- Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!torvalds
- From: torvalds@klaava.Helsinki.FI (Linus Torvalds)
- Subject: Re: 386 device drivers: machine-independent I/O timing?
- Message-ID: <1993Jan11.190124.16891@klaava.Helsinki.FI>
- Organization: University of Helsinki
- References: <1993Jan11.120230.1322@smoke.marlboro.vt.us> <LILJEBER.93Jan11190510@hydra.Helsinki.FI>
- Date: Mon, 11 Jan 1993 19:01:24 GMT
- Lines: 49
-
- In article <LILJEBER.93Jan11190510@hydra.Helsinki.FI> liljeber@hydra.Helsinki.FI (Mika Liljeberg) writes:
- >In article <1993Jan11.120230.1322@smoke.marlboro.vt.us> jhood@smoke.marlboro.vt.us (Lord Yertle) wrote:
- >>
- >> Sometime in the deep murky mists of time (within the last two years,
- >> anyway) somebody from Compaq or Dell posted an article about I/O
- >> delays in (I think) Unix device drivers. He suggested reading or
- >> writing some I/O port on the motherboard I/O bus to get ~ 1 us delays
- >> for I/O access timing, but I can't find the article (which I thought I
- >> saved) or remember what exactly he was suggesting.
- >
- >I didn't see the article, but Linux uses outb on port 0x80 for I/O
- >delays. It seems to work very well.
-
- The outb to port 0x80 seems to be one of the better solutions (and
- thanks to James van Artsdalen for the tip..), although I have one report
- that says it leads to problems (but that's still a lot less than all the
- other solutions I've tried).
-
- Other possibilities:
-
- + inb from port 0x61 is reported to work well
- - I tried it with one release of linux, but there were problems on
- some hardware. Also, this naturally messes up %al, which makes the
- code look uglier (I usually want to take a look at the generated
- assembler...)
-
- + no delay at all
- - works on a lot of harware, and is likely to be the fastest solution
- as long as it doesn't lead to other problems. If it's something
- meant to work only on your hardware, try it out. I've found that
- my machine is happy with just about anything I feed it, but not
- everybody is as lucky..
-
- + short jumps
- - doesn't work too well on 486's, and you might as well use no delay
- at all. Besides, it's hardware-dependent, and becomes less useful
- just when the timings are getting more critical.
-
- + timing loops. You might try to time your hardware, and use a
- variable number loop.
- - probably isn't worth it for small delays, and gets confused if you
- play around with a turbo button..
-
- I've been happy with the "outb 0x80" trick: it works fine, and using
- four of them as a delay between IO instructions for critical things
- seems to be enough for almost everything (anything less has resulted in
- problems with the harddisk driver under linux).
-
- Linus
-