From 8fa17e17bf0e835e7745d6546cc520d1da43f3bb Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 21 Dec 2000 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2000-12-21 --- ip/devip.c | 18 ++++++++++++++---- ip/tcp.c | 41 +++++++++++++++++++++++++---------------- pc/apm.c | 1 + pc/fns.h | 4 +++- pc/l.s | 8 ++++++++ 5 files changed, 51 insertions(+), 21 deletions(-) diff --git a/ip/devip.c b/ip/devip.c index a62b266e71476efbda0bdc0dd161dce38ecb19f2..b6418e33e7b034e607e628e0ad44e247719d1242 100644 --- a/ip/devip.c +++ b/ip/devip.c @@ -799,11 +799,16 @@ connectctlmsg(Proto *x, Conv *c, Cmdbuf *cb) p = x->connect(c, cb->f, cb->nf); if(p != nil) error(p); - qunlock(c); + qunlock(c); + if(waserror()){ + qlock(c); + nexterror(); + } sleep(&c->cr, connected, c); - qlock(c); + poperror(); + if(c->cerr[0] != '\0') error(c->cerr); } @@ -846,11 +851,16 @@ announcectlmsg(Proto *x, Conv *c, Cmdbuf *cb) p = x->announce(c, cb->f, cb->nf); if(p != nil) error(p); - qunlock(c); + qunlock(c); + if(waserror()){ + qlock(c); + nexterror(); + } sleep(&c->cr, announced, c); - qlock(c); + poperror(); + if(c->cerr[0] != '\0') error(c->cerr); } diff --git a/ip/tcp.c b/ip/tcp.c index 62dcf35cd1c213e3319b3f2aa98ea8ac01d410ad..9d514994bcb8422255814ed6d6baad818c342548 100644 --- a/ip/tcp.c +++ b/ip/tcp.c @@ -1649,7 +1649,9 @@ raise: } /* - * always enters and exits with the tcb locked + * always enters and exits with the s locked. We drop + * the lock to ipoput the packet so some care has to be + * taken by callers. */ void tcpoutput(Conv *s) @@ -1667,22 +1669,22 @@ tcpoutput(Conv *s) f = s->p->f; tpriv = s->p->priv; - tcb = (Tcpctl*)s->ptcl; - - switch(tcb->state) { - case Listen: - case Closed: - case Finwait2: - return; - } - - /* force an ack when a window has opened up */ - if(tcb->rcv.blocked && tcb->rcv.wnd > 0){ - tcb->rcv.blocked = 0; - tcb->flags |= FORCE; - } - for(msgs = 0; msgs < 100; msgs++) { + tcb = (Tcpctl*)s->ptcl; + + switch(tcb->state) { + case Listen: + case Closed: + case Finwait2: + return; + } + + /* force an ack when a window has opened up */ + if(tcb->rcv.blocked && tcb->rcv.wnd > 0){ + tcb->rcv.blocked = 0; + tcb->flags |= FORCE; + } + sndcnt = tcb->sndcnt; sent = tcb->snd.ptr - tcb->snd.una; @@ -1850,7 +1852,14 @@ tcpoutput(Conv *s) tpriv->stats[OutSegs]++; if(tcb->kacounter > 0) tcpgo(tpriv, &tcb->katimer); + qunlock(s); + if(waserror()){ + qlock(s); + nexterror(); + } ipoput(f, hbp, 0, s->ttl, s->tos); + qlock(s); + poperror(); } } diff --git a/pc/apm.c b/pc/apm.c index 3e5797a99d17dd3a5d36aed6e78b507848533f00..01e83d5d58fcdc26913dc274f5e8d3321e6efce7 100644 --- a/pc/apm.c +++ b/pc/apm.c @@ -162,6 +162,7 @@ apmlink(void) loadgdt(); addarchfile("apm", 0660, apmread, apmwrite); + doze = halt; print("apm0: configured cbase %.8lux off %.8lux\n", ax<<4, ebx); diff --git a/pc/fns.h b/pc/fns.h index da5cee1d332cfe1e787f0a8b8f416ce8c0023eb9..0729055afd38c312f500ae2cce542d4d6bf3c597 100644 --- a/pc/fns.h +++ b/pc/fns.h @@ -25,6 +25,7 @@ int dmadone(int); void dmaend(int); int dmainit(int, int); long dmasetup(int, void*, long, int); +void (*doze)(void); #define evenaddr(x) /* x86 doesn't care */ void fpenv(FPsave*); void fpinit(void); @@ -38,6 +39,7 @@ ulong getcr3(void); ulong getcr4(void); char* getconf(char*); int havecycintr(void); +void halt(void); /* x86 HLT */ int i8042auxcmd(int); void i8042auxenable(void (*)(int, int)); void i8042reset(void); @@ -47,7 +49,7 @@ uvlong i8253read(uvlong*); void i8259init(void); int i8259enable(Vctl*); void idle(void); -#define idlehands() /* nothing to do in the runproc */ +#define idlehands() if(doze==0);else doze() /* nothing to do in the runproc */ int inb(int); void insb(int, void*, int); ushort ins(int); diff --git a/pc/l.s b/pc/l.s index c83941e7679a707dbe45567fa93eb77445f48f15..42478b685e855fa70e5baed09f13533856652009 100644 --- a/pc/l.s +++ b/pc/l.s @@ -12,6 +12,7 @@ #define WRMSR BYTE $0x0F; BYTE $0x30 /* WRMSR, argument in AX/DX (lo/hi) */ #define RDMSR BYTE $0x0F; BYTE $0x32 /* RDMSR, result in AX/DX (lo/hi) */ #define WBINVD BYTE $0x0F; BYTE $0x09 +#define HLT BYTE $0xF4 /* * Macros for calculating offsets within the page directory base @@ -504,6 +505,13 @@ TEXT setlabel(SB), $0 MOVL $0, AX /* return 0 */ RET +/* + * Attempt at power saving. -rsc + */ +TEXT halt(SB), $0 + HLT + RET + /* * Interrupt/exception handling. * Each entry in the vector table calls either _strayintr or _strayintrx depending