From aea8d731dceb6987760d15c2d00dc363b8c03212 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 14 Sep 2001 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2001-09-14 --- bitsy/etherwavelan.c | 11 ++++++++--- pc/etherwavelan.c | 11 ++++++++--- pc/trap.c | 9 ++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/bitsy/etherwavelan.c b/bitsy/etherwavelan.c index 25433f31dd10b0466abc1f8ab13e7254310be6a5..af7c7b57d4f8b625ab9cc0c7d4b3f9804f9aa0d4 100644 --- a/bitsy/etherwavelan.c +++ b/bitsy/etherwavelan.c @@ -438,7 +438,7 @@ ltv_outstr(Ctlr* ctlr, int type, char* val) ltv.type = type; // This should be ltv.slen = len; according to Axel Belinfante - ltv.slen = (len+1) & ~1; + ltv.slen = len; strncpy(ltv.s, val, len); w_outltv(ctlr, <v); @@ -451,15 +451,20 @@ static char* ltv_inname(Ctlr* ctlr, int type) { static Wltv ltv; + int len; memset(<v,0,sizeof(ltv)); ltv.len = WNameLen/2+2; ltv.type = type; if (w_inltv(ctlr, <v)) return Unkname; - if (ltv.name[2] == 0) + len = ltv.slen; + if(len == 0 || ltv.s[0] == 0) return Nilname; - return ltv.name+2; + if(len >= sizeof ltv.s) + len = sizeof ltv.s - 1; + ltv.s[len] = '\0'; + return ltv.s; } static int diff --git a/pc/etherwavelan.c b/pc/etherwavelan.c index d952917396573759280e88aacc38a71bff3b2c08..548588c6b56ff4214963084e4d9eec16112e9f18 100644 --- a/pc/etherwavelan.c +++ b/pc/etherwavelan.c @@ -438,7 +438,7 @@ ltv_outstr(Ctlr* ctlr, int type, char* val) ltv.type = type; // This should be ltv.slen = len; according to Axel Belinfante - ltv.slen = (len+1) & ~1; + ltv.slen = len; strncpy(ltv.s, val, len); w_outltv(ctlr, <v); @@ -451,15 +451,20 @@ static char* ltv_inname(Ctlr* ctlr, int type) { static Wltv ltv; + int len; memset(<v,0,sizeof(ltv)); ltv.len = WNameLen/2+2; ltv.type = type; if (w_inltv(ctlr, <v)) return Unkname; - if (ltv.name[2] == 0) + len = ltv.slen; + if(len == 0 || ltv.s[0] == 0) return Nilname; - return ltv.name+2; + if(len >= sizeof ltv.s) + len = sizeof ltv.s - 1; + ltv.s[len] = '\0'; + return ltv.s; } static int diff --git a/pc/trap.c b/pc/trap.c index 1810073fbe79322e4a7ce818d81a055a531c197d..546d5a6ad5c30847c7f1447c4b6835da5e39af5f 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -56,6 +56,13 @@ intrdisable(int irq, void (*f)(Ureg *, void *), void *a, int tbdf, char *name) Vctl **pv, *v; int vno; + /* + * For now, none of this will work with the APIC code, + * there is no mapping between irq and vector as the IRQ + * is pretty meaningless. + */ + if(arch->intrvecno == nil) + return; vno = arch->intrvecno(irq); ilock(&vctllock); pv = &vctl[vno]; @@ -68,7 +75,7 @@ intrdisable(int irq, void (*f)(Ureg *, void *), void *a, int tbdf, char *name) v = *pv; *pv = (*pv)->next; /* Link out the entry */ - if (vctl[vno] == nil) + if (vctl[vno] == nil && arch->intrdisable != nil) arch->intrdisable(irq); iunlock(&vctllock); xfree(v);