From b711f597e8fb9bd7da25f04caa25a0d3d92b7dfb Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 11 Jun 2000 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2000-06-11 --- pc/vgamach64xx.c | 22 ++++++++++++++++------ pc/vgas3.c | 27 +++++++++++++++++++-------- port/rdb.c | 13 ++++++++++--- 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/pc/vgamach64xx.c b/pc/vgamach64xx.c index e9a19fac0da43755efb9e3ded3631068ed00f2ea..a17bb7c8eb01505b1ad4eced9978a407025b7570 100644 --- a/pc/vgamach64xx.c +++ b/pc/vgamach64xx.c @@ -85,7 +85,7 @@ static ulong mach64xxlinear(VGAscr* scr, int* size, int* align) { ulong aperture, osize, oaperture; - int oapsize, wasupamem; + int i, oapsize, wasupamem; Pcidev *p; Physseg seg; @@ -93,17 +93,27 @@ mach64xxlinear(VGAscr* scr, int* size, int* align) oaperture = scr->aperture; oapsize = scr->apsize; wasupamem = scr->isupamem; - if(wasupamem) - upafree(oaperture, oapsize); - scr->isupamem = 0; if(p = mach64xxpci()){ - aperture = p->mem[0].bar & ~0x0F; - *size = p->mem[0].size; + for(i=0; imem); i++){ + if(p->mem[i].size >= *size + && ((p->mem[i].bar & ~0x0F) & (*align-1)) == 0) + break; + } + if(i >= nelem(p->mem)){ + print("vgamach64xx: aperture not found\n"); + return 0; + } + aperture = p->mem[i].bar & ~0x0F; + *size = p->mem[i].size; } else aperture = 0; + if(wasupamem) + upafree(oaperture, oapsize); + scr->isupamem = 0; + aperture = upamalloc(aperture, *size, *align); if(aperture == 0){ if(wasupamem && upamalloc(oaperture, oapsize, 0)) diff --git a/pc/vgas3.c b/pc/vgas3.c index c6c7f0a4ad59e615ebadc6e61be1b042fba4df23..38f656aec1479633b85078d06e3f3a33ef6a37d5 100644 --- a/pc/vgas3.c +++ b/pc/vgas3.c @@ -65,7 +65,7 @@ static ulong s3linear(VGAscr* scr, int* size, int* align) { ulong aperture, oaperture; - int osize, oapsize, wasupamem; + int i, osize, oapsize, wasupamem; Pcidev *p; Physseg seg; @@ -73,17 +73,26 @@ s3linear(VGAscr* scr, int* size, int* align) oaperture = scr->aperture; oapsize = scr->apsize; wasupamem = scr->isupamem; - if(wasupamem) - upafree(oaperture, oapsize); - scr->isupamem = 0; if(p = pcimatch(nil, 0x5333, 0)){ - aperture = p->mem[0].bar & ~0x0F; - *size = p->mem[0].size; - } - else + for(i=0; imem); i++){ + if(p->mem[i].size >= *size + && ((p->mem[i].bar & ~0x0F) & (*align-1)) == 0) + break; + } + if(i >= nelem(p->mem)){ + print("vgas3: aperture not found\n"); + return 0; + } + aperture = p->mem[i].bar & ~0x0F; + *size = p->mem[i].size; + }else aperture = 0; + if(wasupamem) + upafree(oaperture, oapsize); + scr->isupamem = 0; + aperture = upamalloc(aperture, *size, *align); if(aperture == 0){ if(wasupamem && upamalloc(oaperture, oapsize, 0)) @@ -191,6 +200,7 @@ s3load(VGAscr* scr, Cursor* curs) case 0xE18A: /* ViRGE/[DG]X */ case 0xE110: /* ViRGE/GX2 */ case 0xE13D: /* ViRGE/VX */ + case 0xE122: /* Savage4 */ p += scr->storage; break; @@ -237,6 +247,7 @@ s3load(VGAscr* scr, Cursor* curs) case 0xE18A: /* ViRGE/[DG]X */ case 0xE110: /* ViRGE/GX2 */ case 0xE13D: /* ViRGE/VX */ + case 0xE122: /* Savage4 */ break; default: diff --git a/port/rdb.c b/port/rdb.c index dda9ee78ff27bf47ec86f91640b21f0a4c8dae56..ca5559173701793ad9f9f8fc183321399537ba73 100644 --- a/port/rdb.c +++ b/port/rdb.c @@ -45,11 +45,11 @@ getline(void) } static void* -addr(char *s, Ureg *ureg) +addr(char *s, Ureg *ureg, char **p) { ulong a; - a = strtoul(s, 0, 16); + a = strtoul(s, p, 16); if(a < sizeof(Ureg)) return ((uchar*)ureg)+a; return (void*)a; @@ -59,6 +59,7 @@ static void talkrdb(Ureg *ureg) { uchar *a; + char *p; char *req; printq = nil; // turn off serial console @@ -68,10 +69,16 @@ talkrdb(Ureg *ureg) req = getline(); switch(*req){ case 'r': - a = addr(req+1, ureg); + a = addr(req+1, ureg, nil); DBG("read %p\n", a); iprint("R%.8lux %.2ux %.2ux %.2ux %.2ux\n", strtoul(req+1, 0, 16), a[0], a[1], a[2], a[3]); break; + + case 'w': + a = addr(req+1, ureg, &p); + *(ulong*)a = strtoul(p, nil, 16); + iprint("W\n"); + break; /* * case Tmput: n = min[4];