From 8fabec29e10be2fcf4ee418c1ad20a9fcca3172e Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 11 May 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-05-11 --- alphapc/arch164.c | 4 +- alphapc/io.h | 2 +- alphapc/main.c | 3 +- alphapc/mmu.c | 17 +++- alphapc/screen.c | 2 +- alphapc/vgatvp3026.c | 189 +++++++++++++++++++++++++++++++++++++++++++ port/alloc.c | 2 +- 7 files changed, 210 insertions(+), 9 deletions(-) create mode 100644 alphapc/vgatvp3026.c diff --git a/alphapc/arch164.c b/alphapc/arch164.c index d0762f2acf05abdec392413c7b4db8908f4c3fe0..61883a6845db736af04a6a9be93b3bd9eb40a337 100644 --- a/alphapc/arch164.c +++ b/alphapc/arch164.c @@ -44,9 +44,9 @@ sginit(void) wind[0x400/4] = ISAWINDOW|2|1; wind[0x440/4] = 0x00700000; - wind[0x480/4] = PADDR(sgmap)>>2; + wind[0x480/4] = PADDR(sgmap)>>2; /* why the shift? */ - wind[0x100/4] = 3; /* invalidate tlb cache */ + wind[0x100/4] = 3; /* invalidate tlb cache */ } static void * diff --git a/alphapc/io.h b/alphapc/io.h index b8fe902d7311db74ff7dce1964b09b6ce9c24eca..8fb896039c2bdbc5e4f2fbefc556df90f1f91ab3 100644 --- a/alphapc/io.h +++ b/alphapc/io.h @@ -30,7 +30,7 @@ enum { VectorLPT = VectorPIC+7, VectorIRQ7 = VectorPIC+7, VectorAUX = VectorPIC+12, /* PS/2 port */ - VectorIRQ13 = VectorPIC+13, /* corocessor on x386 */ + VectorIRQ13 = VectorPIC+13, /* coprocessor on x386 */ VectorATA0 = VectorPIC+14, MaxVectorPIC = VectorPIC+15, VectorPCI = 16, /* PCI bus (PLD) */ diff --git a/alphapc/main.c b/alphapc/main.c index e5716414cab2a02f0ee0d7531fc0d49fc2273ab5..6a25be362cb77da8f138c3d00a448a379b47d649 100644 --- a/alphapc/main.c +++ b/alphapc/main.c @@ -234,8 +234,7 @@ confinit(void) if(cpuserver) conf.nproc = 500; -/* else - conf.monitor = 1; /* BUG */ + conf.monitor = 1; /* BUG */ } void diff --git a/alphapc/mmu.c b/alphapc/mmu.c index 85985c248e142ff0aca583c43687733b2b58e74e..0beaaba530bbf96552f2fa5a58007cded3d7ff4e 100644 --- a/alphapc/mmu.c +++ b/alphapc/mmu.c @@ -233,9 +233,22 @@ flushmmu(void) } ulong -upamalloc(...) +upamalloc(ulong pa, int size, int align) { - panic("upamalloc"); + void *va; + + /* + * Viability hack. + return kmapv(((uvlong)space<<32LL)|offset, size); + return kmapio(0x88, addr, len); + */ + USED(align); +print("upa0: pa %luX size %d, align %d nextio %luX\n", pa, size, align, nextio); + va = kmapv(((uvlong)0x88<<32LL)|pa, size); +print("upa1: va %luX nextio %luX\n", va, nextio); + if(va == nil) + return 0; + return PADDR(va); } void diff --git a/alphapc/screen.c b/alphapc/screen.c index a634ab32c42e5f59b4800e9825557ae0e8a106ea..70e439e94729f0d10666bbae5909f615738018a4 100644 --- a/alphapc/screen.c +++ b/alphapc/screen.c @@ -70,7 +70,7 @@ screensize(int x, int y, int z) memset(gscreendata.data, Backgnd, width*BY2WD*y); scr->useflush = 1; - scr->aperture = (ulong)arch->pcimem(0xA0000, 1<<16); + scr->aperture = PADDR(arch->pcimem(0xA0000, 1<<16)); scr->apsize = 1<<16; } else diff --git a/alphapc/vgatvp3026.c b/alphapc/vgatvp3026.c new file mode 100644 index 0000000000000000000000000000000000000000..1b97d1bf7a830af4cea6670618f8aff2b5dfe4ed --- /dev/null +++ b/alphapc/vgatvp3026.c @@ -0,0 +1,189 @@ +#include "u.h" +#include "../port/lib.h" +#include "mem.h" +#include "dat.h" +#include "fns.h" +#include "../port/error.h" + +#define Image IMAGE +#include +#include +#include +#include "screen.h" + +/* + * TVP3026 Viewpoint Video Interface Pallette. + * Assumes hooked up to an S3 Vision968. + */ +enum { + Index = 0x00, /* Index */ + Data = 0x0A, /* Data */ + + CaddrW = 0x04, /* Colour Write Address */ + Cdata = 0x05, /* Colour Data */ + + Cctl = 0x09, /* Direct Cursor Control */ + Cram = 0x0B, /* Cursor Ram Data */ + Cxlsb = 0x0C, /* Cursor X LSB */ + Cxmsb = 0x0D, /* Cursor X MSB */ + Cylsb = 0x0E, /* Cursor Y LSB */ + Cymsb = 0x0F, /* Cursor Y MSB */ + + Icctl = 0x06, /* Indirect Cursor Control */ +}; + +/* + * Lower 2-bits of indirect DAC register + * addressing. + */ +static ushort dacxreg[4] = { + PaddrW, Pdata, Pixmask, PaddrR +}; + +static uchar +tvp3026io(uchar reg, uchar data) +{ + uchar crt55; + + crt55 = vgaxi(Crtx, 0x55) & 0xFC; + vgaxo(Crtx, 0x55, crt55|((reg>>2) & 0x03)); + vgao(dacxreg[reg & 0x03], data); + + return crt55; +} + +static void +tvp3026o(uchar reg, uchar data) +{ + uchar crt55; + + crt55 = tvp3026io(reg, data); + vgaxo(Crtx, 0x55, crt55); +} + +void +tvp3026xo(uchar index, uchar data) +{ + uchar crt55; + + crt55 = tvp3026io(Index, index); + vgaxo(Crtx, 0x55, crt55|((Data>>2) & 0x03)); + vgao(dacxreg[Data & 0x03], data); + vgaxo(Crtx, 0x55, crt55); +} + +static void +tvp3026disable(VGAscr*) +{ + tvp3026xo(Icctl, 0x90); + tvp3026o(Cctl, 0x00); +} + +static void +tvp3026enable(VGAscr*) +{ + /* + * Make sure cursor is off and direct control enabled. + */ + tvp3026xo(Icctl, 0x90); + tvp3026o(Cctl, 0x00); + + /* + * Overscan colour, + * cursor colour 1 (white), + * cursor colour 2, 3 (black). + */ + tvp3026o(CaddrW, 0x00); + tvp3026o(Cdata, Pwhite); tvp3026o(Cdata, Pwhite); tvp3026o(Cdata, Pwhite); + tvp3026o(Cdata, Pwhite); tvp3026o(Cdata, Pwhite); tvp3026o(Cdata, Pwhite); + tvp3026o(Cdata, Pblack); tvp3026o(Cdata, Pblack); tvp3026o(Cdata, Pblack); + tvp3026o(Cdata, Pblack); tvp3026o(Cdata, Pblack); tvp3026o(Cdata, Pblack); + + /* + * Enable the cursor in 3-colour mode. + */ + tvp3026o(Cctl, 0x01); +} + +static void +tvp3026load(VGAscr* scr, Cursor* curs) +{ + int x, y; + + /* + * Make sure cursor is off by initialising the cursor + * control to defaults. + * Write to the indirect control register to make sure + * direct register is enabled and upper 2 bits of cursor + * RAM address are 0. + * The LSBs of the cursor RAM address are in PaddrW. + */ + tvp3026xo(Icctl, 0x90); + tvp3026o(Cctl, 0x00); + vgao(PaddrW, 0x00); + + /* + * Initialise the 64x64 cursor RAM array. There are 2 planes, + * p0 and p1. Data is written 8 pixels per byte, with p0 in the + * first 512 bytes of the array and p1 in the second. + * The cursor is set in 3-colour mode which gives the following + * truth table: + * p1 p0 colour + * 0 0 transparent + * 0 1 cursor colour 0 + * 1 0 cursor colour 1 + * 1 1 cursor colour 2 + * Put the cursor into the top-left of the 64x64 array. + * The 0,0 cursor point is bottom-right, so positioning will + * have to take that into account. + */ + for(y = 0; y < 64; y++){ + for(x = 0; x < 64/8; x++){ + if(x < 16/8 && y < 16) + tvp3026o(Cram, curs->clr[x+y*2]); + else + tvp3026o(Cram, 0x00); + } + } + for(y = 0; y < 64; y++){ + for(x = 0; x < 64/8; x++){ + if(x < 16/8 && y < 16) + tvp3026o(Cram, curs->set[x+y*2]); + else + tvp3026o(Cram, 0x00); + } + } + + /* + * Initialise the cursor hotpoint + * and enable the cursor in 3-colour mode. + */ + scr->offset.x = 64+curs->offset.x; + scr->offset.y = 64+curs->offset.y; + tvp3026o(Cctl, 0x01); +} + +static int +tvp3026move(VGAscr* scr, Point p) +{ + int x, y; + + x = p.x+scr->offset.x; + y = p.y+scr->offset.y; + + tvp3026o(Cxlsb, x & 0xFF); + tvp3026o(Cxmsb, (x>>8) & 0x0F); + tvp3026o(Cylsb, y & 0xFF); + tvp3026o(Cymsb, (y>>8) & 0x0F); + + return 0; +} + +VGAcur vgatvp3026cur = { + "tvp3026hwgc", + + tvp3026enable, + tvp3026disable, + tvp3026load, + tvp3026move, +}; diff --git a/port/alloc.c b/port/alloc.c index 57df945ba3058cd1ec5544bc44439d172303d8d1..7048b5b76ada9d792eb5b33add5d9b4e728a7b09 100644 --- a/port/alloc.c +++ b/port/alloc.c @@ -403,11 +403,11 @@ mallocz(ulong size, int clr) v = poolalloc(mainmem, size); if(clr && v != nil) - memset(v, 0, size); { Bhdr *h; D2B(h, v); B2T(h)->pad = getcallerpc(&size); + memset(v, 0, size); } return v; }