M pc/vgamach64xx.c => pc/vgamach64xx.c +16 -6
@@ 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; i<nelem(p->mem); 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))
M pc/vgas3.c => pc/vgas3.c +19 -8
@@ 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; i<nelem(p->mem); 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:
M port/rdb.c => port/rdb.c +10 -3
@@ 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];