From bd97cea9c50060b869940bf1cdcfd6c00a757d79 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 3 Sep 1998 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1998-09-03 --- pc/i8253.c | 15 +++++++++++++++ port/sysproc.c | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pc/i8253.c b/pc/i8253.c index dc0ad552815d53854ce9ad742d3ffac397c9641a..94925eca3a37d75be4e252b2bde9ecd56cd14e5a 100644 --- a/pc/i8253.c +++ b/pc/i8253.c @@ -40,6 +40,21 @@ i8253init(int aalcycles) outb(Tmode, Load0|Square); outb(T0cntr, (Freq/HZ)); /* low byte */ outb(T0cntr, (Freq/HZ)>>8); /* high byte */ + + /* + * Introduce a little delay to make sure the count is + * latched and the timer is counting down; with a fast + * enough processor this may not be the case. + * The i8254 (which this probably is) has a read-back + * command which can be used to make sure the counting + * register has been written into the counting element. + */ + x = (Freq/HZ); + for(loops = 0; loops < 100000 && x >= (Freq/HZ); loops++){ + outb(Tmode, Latch0); + x = inb(T0cntr); + x |= inb(T0cntr)<<8; + } } /* find biggest loop that doesn't wrap */ diff --git a/port/sysproc.c b/port/sysproc.c index 8013d8b95215113e389bea83d94779c89ee488da..5e3a6d65ac570b9354b6bee2fe119c381ab9b7c7 100644 --- a/port/sysproc.c +++ b/port/sysproc.c @@ -650,7 +650,7 @@ sysbrk_(ulong *arg) long sysrendezvous(ulong *arg) { - int tag; + ulong tag; ulong val; Proc *p, **l;