From eaa55ec8f618c965c894d6a5f4123e388ec5978d Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 4 Feb 2003 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2003-02-04 --- pc/devarch.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pc/devarch.c b/pc/devarch.c index f1031d92804f50949a385115da4541686f45e903..df4c7ca97698dc1382ba190dd7cc1c8e2d62cf98 100644 --- a/pc/devarch.c +++ b/pc/devarch.c @@ -108,8 +108,11 @@ ioinit(void) // a dummy entry at 2^16 ioalloc(0x10000, 1, 0, "dummy"); + /* + * Someone needs to explain why this was here... ioalloc(0x0fff, 1, 0, "dummy"); // i82557 is at 0x1000, the dummy // entry is needed for swappable devs. + */ if ((excluded = getconf("ioexclude")) != nil) { char *s; @@ -341,7 +344,7 @@ enum static long archread(Chan *c, void *a, long n, vlong offset) { - char buf[Linelen+1], *p; + char *buf, *p; int port; ushort *sp; ulong *lp; @@ -388,23 +391,29 @@ archread(Chan *c, void *a, long n, vlong offset) break; } - offset = offset/Linelen; + if((buf = malloc(n)) == nil) + error(Enomem); + p = buf; n = n/Linelen; - p = a; + offset = offset/Linelen; + lock(&iomap); for(m = iomap.m; n > 0 && m != nil; m = m->next){ if(offset-- > 0) continue; if(strcmp(m->tag, "dummy") == 0) break; - sprint(buf, "%8lux %8lux %-12.12s\n", m->start, m->end-1, m->tag); - memmove(p, buf, Linelen); + sprint(p, "%8lux %8lux %-12.12s\n", m->start, m->end-1, m->tag); p += Linelen; n--; } unlock(&iomap); - return p - (char*)a; + n = p - buf; + memmove(a, buf, n); + free(buf); + + return n; } static long