1
0
mirror of synced 2026-03-04 18:14:17 +00:00

16 MiB for Goblin

This commit is contained in:
Romain Dolbeau
2022-03-13 07:59:30 +01:00
parent fb9cbeb165
commit 936736d35a
12 changed files with 175 additions and 43 deletions

View File

@@ -96,7 +96,7 @@ const struct cdevsw goblin_cdevsw = {
/* frame buffer generic driver */
static struct fbdriver goblinfbdriver = {
goblinunblank, goblinopen, nullclose, goblinioctl, nopoll,
goblinunblank, goblinopen, goblinclose, goblinioctl, nopoll,
goblinmmap, nokqfilter
};
@@ -713,17 +713,16 @@ goblin_set_depth(struct goblin_softc *sc, int depth)
static void
goblin_init(struct goblin_softc *sc)
{
//goblin_set_depth(sc, 32);
goblin_set_depth(sc, 32);
}
static void
/* Restore the state saved on goblin_init */
goblin_reset(struct goblin_softc *sc)
{
//goblin_set_depth(sc, 8);
goblin_set_depth(sc, 8);
}
#define CONFIG_CSR_DATA_WIDTH 32
#define sbusfpga_jareth_softc goblin_softc
#include "dev/sbus/sbusfpga_csr_jareth.h"
@@ -743,13 +742,13 @@ static int jareth_scroll(struct goblin_softc *sc, enum jareth_verbosity verbose,
power_on(sc);
if (y0 > y1) {
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(0,0), (0x8f800000 + y0 * sc->sc_stride + x0)); /* fixme: replace 0x8f800000 by a prom attributes */
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(0,1), (0x8f800000 + y1 * sc->sc_stride + x0));
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(0,0), (sc->sc_internal_adr + y0 * sc->sc_stride + x0));
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(0,1), (sc->sc_internal_adr + y1 * sc->sc_stride + x0));
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(4,0), (sc->sc_stride));
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(4,1), (sc->sc_stride));
} else {
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(0,0), (0x8f800000 + y0 * sc->sc_stride + x0 + (n-1) * sc->sc_stride)); /* fixme: replace 0x8f800000 by a prom attributes */
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(0,1), (0x8f800000 + y1 * sc->sc_stride + x0 + (n-1) * sc->sc_stride));
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(0,0), (sc->sc_internal_adr + y0 * sc->sc_stride + x0 + (n-1) * sc->sc_stride));
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(0,1), (sc->sc_internal_adr + y1 * sc->sc_stride + x0 + (n-1) * sc->sc_stride));
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(4,0), (-sc->sc_stride));
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(4,1), (-sc->sc_stride));
}
@@ -779,7 +778,7 @@ static int jareth_fill(struct goblin_softc *sc, enum jareth_verbosity verbose, i
power_on(sc);
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(0,0), (0x8f800000 + y0 * sc->sc_stride + x0));
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(0,0), (sc->sc_internal_adr + y0 * sc->sc_stride + x0));
for (i = 0 ; i < 8 ; i++) {
bus_space_write_4(sc->sc_bustag, sc->sc_bhregs_regfile,SUBREG_ADDR(1,i), pat);
}

View File

@@ -155,7 +155,8 @@ goblinattach_sbus(device_t parent, device_t self, void *args)
fb->fb_pixels = (char *)bus_space_vaddr(sa->sa_bustag, bh);
}
sc->sc_has_jareth = prom_getpropint(node, "goblin_has_jareth", 0);
sc->sc_has_jareth = prom_getpropint(node, "goblin-has-jareth", 0);
sc->sc_internal_adr = prom_getpropint(node, "goblin-internal-fb", 0x8f000000);
if (sc->sc_has_jareth) {
if (sa->sa_nreg < 5) {

View File

@@ -32,7 +32,7 @@
/* offsets */
#define GOBOFB_REG_BASE 0x200000
#define GOBOFB_MEM_BASE 0x800000
#define GOBOFB_MEM_BASE 0x1000000
#define GOBOFB_MODE 0x0
#define GOBOFB_VBL_MASK 0x4
#define GOBOFB_VIDEOCTRL 0x8

View File

@@ -53,6 +53,7 @@ struct goblin_softc {
uint32_t sc_size; /* full memory size */
int sc_opens; /* number of open() to track 8/24 bits */
int sc_has_jareth; /* whether we have a Jareth vector engine available */
uint32_t sc_internal_adr;
bus_space_handle_t sc_bhregs_jareth; /* bus handle */
bus_space_handle_t sc_bhregs_microcode; /* bus handle */

View File

@@ -37,15 +37,7 @@
/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */
#define GOBLIN_FBC_VOFF 0x70000000
#define GOBLIN_TEC_VOFF 0x70001000
#define GOBLIN_BTREGS_VOFF 0x70002000
#define GOBLIN_FHC_VOFF 0x70004000
#define GOBLIN_THC_VOFF 0x70005000
#define GOBLIN_ROM_VOFF 0x70006000
#define GOBLIN_RAM_VOFF 0x70016000
#define GOBLIN_DHC_VOFF 0x80000000
typedef struct {
unsigned int fg, bg; /* FG/BG colors for stipple */
@@ -102,4 +94,12 @@ int GOBLINAccelInit(ScrnInfoPtr);
Bool GoblinDGAInit(ScreenPtr);
int GOBLINEXAInit(ScreenPtr);
#ifdef __NetBSD__
#include <dev/sun/fbio.h>
#include <sys/ioccom.h>
#define GOBLIN_SET_PIXELMODE _IOW('M', 3, int)
#else
#define GOBLIN_SET_PIXELMODE (('M' << 8) | 3)
#endif
#endif /* GOBLIN_H */

View File

@@ -90,13 +90,13 @@ GoblinDGAInit(ScreenPtr pScreen)
mode->bytesPerScanline = mode->imageWidth;
mode->byteOrder = pScrn->imageByteOrder;
mode->depth = 8;
mode->bitsPerPixel = 8;
mode->depth = pScrn->depth;
mode->bitsPerPixel = pScrn->bitsPerPixel;
mode->red_mask = pScrn->mask.red;
mode->green_mask = pScrn->mask.green;
mode->blue_mask = pScrn->mask.blue;
mode->visualClass = PseudoColor;
mode->visualClass = TrueColor;
mode->address = pGoblin->fb;
result = DGAInit(pScreen, &Goblin_DGAFuncs, mode, 1);

View File

@@ -27,6 +27,7 @@
#endif
#include <string.h>
#include <sys/ioctl.h>
#include "goblin.h"
#include "xf86.h"
@@ -39,6 +40,29 @@
#include "compat-api.h"
/*
0011 src
0101 dst
GXclear 0x0 0 0000
GXand 0x1 src AND dst 0001
GXandReverse 0x2 src AND NOT dst 0010
GXcopy 0x3 src 0011
GXandInverted 0x4 (NOT src) AND dst 0100
GXnoop 0x5 dst 0101
GXxor 0x6 src XOR dst 0110
GXor 0x7 src OR dst 0111
GXnor 0x8 (NOT src) AND (NOT dst) 1000
GXequiv 0x9 (NOT src) XOR dst 1001
GXinvert 0xa NOT dst 1010
GXorReverse 0xb src OR (NOT dst) 1011
GXcopyInverted 0xc NOT src 1100
GXorInverted 0xd (NOT src) OR dst 1101
GXnand 0xe (NOT src) OR (NOT dst) 1110
GXset 0xf 1 1111
*/
static const OptionInfoRec * GOBLINAvailableOptions(int chipid, int busid);
static void GOBLINIdentify(int flags);
static Bool GOBLINProbe(DriverPtr drv, int flags);
@@ -48,6 +72,8 @@ static Bool GOBLINEnterVT(VT_FUNC_ARGS_DECL);
static void GOBLINLeaveVT(VT_FUNC_ARGS_DECL);
static Bool GOBLINCloseScreen(CLOSE_SCREEN_ARGS_DECL);
static Bool GOBLINSaveScreen(ScreenPtr pScreen, int mode);
static void GOBLINInitCplane24(ScrnInfoPtr pScrn);
static void GOBLINExitCplane24(ScrnInfoPtr pScrn);
/* Required if the driver supports mode switching */
static Bool GOBLINSwitchMode(SWITCH_MODE_ARGS_DECL);
@@ -328,7 +354,7 @@ GOBLINPreInit(ScrnInfoPtr pScrn, int flags)
/*********************
deal with depth
*********************/
#if 0
if (!xf86SetDepthBpp(pScrn, 8, 0, 0, NoDepth24Support)) {
return FALSE;
} else {
@@ -344,6 +370,22 @@ GOBLINPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
}
#else
if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb|Support32bppFb))
return FALSE;
/* Check that the returned depth is one we support */
switch (pScrn->depth) {
case 32:
case 24:
/* OK */
break;
default:
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Given depth (%d) is not supported by this driver\n",
pScrn->depth);
return FALSE;
}
#endif
/* Collect all of the relevant option flags (fill in pScrn->options) */
xf86CollectOptions(pScrn, NULL);
@@ -352,9 +394,31 @@ GOBLINPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
memcpy(pGoblin->Options, GOBLINOptions, sizeof(GOBLINOptions));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pGoblin->Options);
/*
* This must happen after pScrn->display has been set because
* xf86SetWeight references it.
*/
if (pScrn->depth > 8) {
rgb weight = {0, 0, 0};
rgb mask = {0xff, 0xff00, 0xff0000};
if (!xf86SetWeight(pScrn, weight, mask)) {
return FALSE;
}
}
if (!xf86SetDefaultVisual(pScrn, -1))
return FALSE;
else if (pScrn->depth > 8) {
/* We don't currently support DirectColor */
if (pScrn->defaultVisual != TrueColor) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual"
" (%s) is not supported\n",
xf86GetVisualName(pScrn->defaultVisual));
return FALSE;
}
}
/*
* The new cmap code requires this to be initialised.
@@ -434,7 +498,7 @@ GOBLINScreenInit(SCREEN_INIT_ARGS_DECL)
*/
pGoblin->fb = NULL;
for (i = 8 ; (i > 0) && (pGoblin->fb == NULL) ; i = i / 2) {
for (i = 16 ; (i > 0) && (pGoblin->fb == NULL) ; i = i / 2) {
pGoblin->vidmem = i * 1024 * 1024;
pGoblin->fb = xf86MapSbusMem(psdp, GOBLIN_RAM_VOFF, pGoblin->vidmem);
}
@@ -479,9 +543,11 @@ GOBLINScreenInit(SCREEN_INIT_ARGS_DECL)
*/
miClearVisualTypes();
#if 0
/* Set the bits per RGB for 8bpp mode */
pScrn->rgbBits = 8;
#endif
/* Setup the visuals we support. */
if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
@@ -494,12 +560,13 @@ GOBLINScreenInit(SCREEN_INIT_ARGS_DECL)
* Call the framebuffer layer's ScreenInit function, and fill in other
* pScreen fields.
*/
GOBLINInitCplane24(pScrn);
ret = fbScreenInit(pScreen, pGoblin->fb, pScrn->virtualX,
pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
pScrn->virtualX, 8);
pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
pScrn->virtualX, pScrn->bitsPerPixel);
if (!ret)
return FALSE;
return FALSE;
pGoblin->width = pScrn->virtualX;
pGoblin->height = pScrn->virtualY;
@@ -512,6 +579,22 @@ GOBLINScreenInit(SCREEN_INIT_ARGS_DECL)
xf86SetBlackWhitePixels(pScreen);
if (pScrn->bitsPerPixel > 8) {
VisualPtr visual;
/* Fixup RGB ordering */
visual = pScreen->visuals + pScreen->numVisuals;
while (--visual >= pScreen->visuals) {
if ((visual->class | DynamicClass) == DirectColor) {
visual->offsetRed = pScrn->offset.red;
visual->offsetGreen = pScrn->offset.green;
visual->offsetBlue = pScrn->offset.blue;
visual->redMask = pScrn->mask.red;
visual->greenMask = pScrn->mask.green;
visual->blueMask = pScrn->mask.blue;
}
}
}
if (!pGoblin->NoAccel) {
#if 0
{
@@ -543,18 +626,20 @@ GOBLINScreenInit(SCREEN_INIT_ARGS_DECL)
/* Initialise default colourmap */
if (!miCreateDefColormap(pScreen))
return FALSE;
return FALSE;
#if 0
if(!xf86SbusHandleColormaps(pScreen, pGoblin->psdp))
return FALSE;
return FALSE;
#endif
pGoblin->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = GOBLINCloseScreen;
pScreen->SaveScreen = GOBLINSaveScreen;
/* Report any unused options (only for the first generation) */
if (serverGeneration == 1) {
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
}
/* unblank the screen */
@@ -595,8 +680,9 @@ static Bool
GOBLINEnterVT(VT_FUNC_ARGS_DECL)
{
SCRN_INFO_PTR(arg);
GoblinPtr pGoblin = GET_GOBLIN_FROM_SCRN(pScrn);
/* GoblinPtr pGoblin = GET_GOBLIN_FROM_SCRN(pScrn); */
GOBLINInitCplane24 (pScrn);
return TRUE;
}
@@ -609,6 +695,10 @@ GOBLINEnterVT(VT_FUNC_ARGS_DECL)
static void
GOBLINLeaveVT(VT_FUNC_ARGS_DECL)
{
SCRN_INFO_PTR(arg);
/* GoblinPtr pGoblin = GET_GOBLIN_FROM_SCRN(pScrn); */
GOBLINExitCplane24 (pScrn);
return;
}
@@ -638,6 +728,8 @@ GOBLINCloseScreen(CLOSE_SCREEN_ARGS_DECL)
xf86UnmapSbusMem(psdp, pGoblin->fb, pGoblin->vidmem);
pGoblin->fb = NULL;
}
GOBLINExitCplane24(pScrn);
pScreen->CloseScreen = pGoblin->CloseScreen;
return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS);
@@ -714,3 +806,31 @@ GOBLINDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op,
}
}
/*
* This initializes the card for 24 bit mode.
*/
static void
GOBLINInitCplane24(ScrnInfoPtr pScrn)
{
GoblinPtr pGoblin = GET_GOBLIN_FROM_SCRN(pScrn);
int size, bpp;
size = pScrn->virtualX * pScrn->virtualY;
bpp = 32;
ioctl (pGoblin->psdp->fd, GOBLIN_SET_PIXELMODE, &bpp);
memset (pGoblin->fb, 0, size * 4);
}
/*
* This initializes the card for 8 bit mode.
*/
static void
GOBLINExitCplane24(ScrnInfoPtr pScrn)
{
GoblinPtr pGoblin = GET_GOBLIN_FROM_SCRN(pScrn);
int bpp = 8;
ioctl (pGoblin->psdp->fd, GOBLIN_SET_PIXELMODE, &bpp);
}

View File

@@ -26,7 +26,7 @@
/* offsets */
#define GOBOFB_REG_BASE 0x200000
#define GOBOFB_MEM_BASE 0x800000
#define GOBOFB_MEM_BASE 0x1000000
#define GOBOFB_MODE 0x0
#define GOBOFB_VBL_MASK 0x4
#define GOBOFB_VIDEOCTRL 0x8

View File

@@ -17,13 +17,16 @@
sbusfpga_regionaddr_goblin_bt constant goblin-off-dac
h# 20 constant /goblin-off-dac
h# 800000 constant goblin-off-fb
h# 1000000 constant goblin-off-fb
h# SBUSFPGA_CG3_BUFSIZE constant /goblin-off-fb
\ only map the first two MiB
h# 200000 constant /goblin-mapped-fb
h# 8f000000 constant goblin-internal-fb
: goblin-reg
my-address sbusfpga_regionaddr_goblin_bt + my-space encode-phys /goblin-off-dac encode-int encode+
my-address goblin-off-fb + my-space encode-phys encode+ /goblin-off-fb encode-int encode+
h# 1 goblin_has_jareth = if
h# 1 goblin-has-jareth = if
my-address sbusfpga_csraddr_jareth + my-space encode-phys encode+ h# 1000 encode-int encode+
my-address sbusfpga_regionaddr_jareth-microcode + my-space encode-phys encode+ h# 1000 encode-int encode+
my-address sbusfpga_regionaddr_jareth-regfile + my-space encode-phys encode+ h# 1000 encode-int encode+
@@ -76,11 +79,11 @@ headerless
;
: fb-map
goblin-off-fb /goblin-off-fb do-map-in to fb-addr
goblin-off-fb /goblin-mapped-fb do-map-in to fb-addr
;
: fb-unmap
goblin-off-fb /goblin-off-fb do-map-out
goblin-off-fb /goblin-mapped-fb do-map-out
-1 to fb-addr
;
@@ -147,8 +150,10 @@ headerless
" RDOL" encode-string " manufacturer" property
" ISO8859-1" encode-string " character-set" property
h# c encode-int " cursorshift" property
/goblin-mapped-fb h# 14 >> encode-int " vmmapped" property
/goblin-off-fb h# 14 >> encode-int " vmsize" property
goblin_has_jareth encode-int " goblin_has_jareth" property
goblin-internal-fb encode-int " goblin-internal-fb" property
goblin-has-jareth encode-int " goblin-has-jareth" property
map-regs
h# 0 h# 4 dac! \ disable irq

View File

@@ -225,6 +225,11 @@ class SBusFPGABus(Module):
CG3_KEPT_UPPER_BIT=23
CG3_PIXELS_ADDR_BIGVAL = 0x08>>3
CG3_PIXELS_ADDR_BIGPFX = Signal(5, reset = CG3_PIXELS_ADDR_BIGVAL)
elif (cg3_fb_size == 16*1048576):
CG3_UPPER_BITS=8
CG3_KEPT_UPPER_BIT=24
CG3_PIXELS_ADDR_BIGVAL = 0x10>>4
CG3_PIXELS_ADDR_BIGPFX = Signal(4, reset = CG3_PIXELS_ADDR_BIGVAL)
else:
print(f"{cg3_fb_size//1048576} mebibytes framebuffer not supported")
assert(False)

View File

@@ -223,7 +223,7 @@ def get_prom(soc,
r += ": sbusfpga_regionaddr_jareth-microcode sbusfpga_regionaddr_jareth ;\n"
r += ": sbusfpga_regionaddr_jareth-regfile sbusfpga_regionaddr_jareth h# 10000 + ;\n"
r += get_header_mapx_stuff("jareth", [ "jareth", "jareth-microcode", "jareth-regfile" ], [ 4096, 4096, 4096 ], ["csr", "region", "region" ], doreg=False )
r += "h# 1 constant goblin_has_jareth\n"
r += "h# 1 constant goblin-has-jareth\n"
r += "fload goblin_jareth_define.fth\n"
r += "fload goblin_jareth_init.fth\n"
else:
@@ -231,7 +231,7 @@ def get_prom(soc,
r += "h# -1 constant sbusfpga_csraddr_jareth\n"
r += "h# -1 constant sbusfpga_regionaddr_jareth-microcode\n"
r += "h# -1 constant sbusfpga_regionaddr_jareth-regfile\n"
r += "h# 0 constant goblin_has_jareth\n"
r += "h# 0 constant goblin-has-jareth\n"
if (bw2):
cg3_file = open("bw2.fth")

View File

@@ -288,6 +288,7 @@ class SBusFPGA(SoCCore):
"cg6_fbc": 0x00700000, # required for compatibility
#"cg6_tec": 0x00701000, # required for compatibility
"cg3_pixels": 0x00800000, # required for compatibility, 1/2/4/8 MiB for now (up to 0x00FFFFFF inclusive) (bw2, cg3 and cg6 idem)
"goblin_pixels": 0x01000000, # base address for 16 MiB Goblin Framebuffer
"main_ram": 0x80000000, # not directly reachable from SBus mapping (only 0x0 - 0x10000000 is accessible),
"video_framebuffer":0x80000000 + 0x10000000 - cg3_fb_size, # Updated later
"dvma_bridge": 0xfc000000, # required to match DVMA virtual addresses