Beef up the stic X interface, and tighten a few screws here and there.

This commit is contained in:
ad 2001-09-18 19:51:23 +00:00
parent ef8abe0767
commit 4824a8d9d9
9 changed files with 709 additions and 226 deletions

View File

@ -1,10 +1,10 @@
# $NetBSD: Makefile,v 1.11 2001/06/30 21:16:52 tron Exp $
# $NetBSD: Makefile,v 1.12 2001/09/18 19:51:23 ad Exp $
# use 'make -f Makefile.tcdevs' to make tcdevs.h and tcdevs_data.h
INCSDIR= /usr/include/dev/tc
# Only install includes which are used by userland
INCS= sfbreg.h sticreg.h sticvar.h
INCS= sfbreg.h sticio.h sticreg.h
.include <bsd.kinc.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: files.tc,v 1.23 2001/08/26 11:47:19 simonb Exp $
# $NetBSD: files.tc,v 1.24 2001/09/18 19:51:23 ad Exp $
#
# Config file and device description for machine-independent
# TURBOchannel code. Included by ports that need it.
@ -61,7 +61,7 @@ file dev/tc/if_fta.c fta
# STIC (stamp interface chip) for PX and PXG
#define stic
#file dev/tc/stic.c stic
#file dev/tc/stic.c stic needs-flag
# PX PMAG-C
#device px: wsemuldisplaydev, stic

View File

@ -1,4 +1,4 @@
/* $NetBSD: px.c,v 1.8 2001/09/18 18:15:54 wiz Exp $ */
/* $NetBSD: px.c,v 1.9 2001/09/18 19:51:23 ad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -68,6 +68,7 @@
#include <dev/tc/tcvar.h>
#include <dev/tc/sticreg.h>
#include <dev/tc/sticio.h>
#include <dev/tc/sticvar.h>
#define PX_STIC_POLL_OFFSET 0x000000 /* STIC DMA poll space */
@ -77,29 +78,45 @@
#define PX_VDAC_RESET_OFFSET 0x300000 /* VDAC reset register */
#define PX_ROM_OFFSET 0x300000 /* ROM code */
#define PX_BUF_SIZE (STIC_PACKET_SIZE*2 + STIC_IMGBUF_SIZE*2)
#define PX_BUF_COUNT 16
#define PX_BUF_INC(x) ((x + 1) & (PX_BUF_COUNT - 1))
/*
* We need enough aligned memory to hold:
*
* - Xserver communication area (4096 bytes)
* - 16 packet buffers (4096 bytes each)
* - 2 image buffers (5120 bytes each)
*
*/
#define PX_BUF_SIZE \
(STIC_PACKET_SIZE * PX_BUF_COUNT + STIC_IMGBUF_SIZE*2 + STIC_XCOMM_SIZE)
#define PX_BUF_ALIGN 32768
static void px_attach(struct device *, struct device *, void *);
static void px_init(struct stic_info *, int);
static int px_match(struct device *, struct cfdata *, void *);
#define PXF_QUEUE 0x01
static int px_intr(void *);
static u_int32_t *px_pbuf_get(struct stic_info *);
static int px_pbuf_post(struct stic_info *, u_int32_t *);
void px_attach(struct device *, struct device *, void *);
void px_init(struct stic_info *, int);
int px_ioctl(struct stic_info *, u_long, caddr_t, int, struct proc *);
int px_match(struct device *, struct cfdata *, void *);
int px_intr(void *);
u_int32_t *px_pbuf_get(struct stic_info *);
int px_pbuf_post(struct stic_info *, u_int32_t *);
void px_cnattach(tc_addr_t);
struct px_softc {
struct device px_dv;
struct stic_info *px_si;
volatile u_int32_t *px_qpoll[PX_BUF_COUNT];
};
struct cfattach px_ca = {
sizeof(struct px_softc), px_match, px_attach
};
static int
int
px_match(struct device *parent, struct cfdata *match, void *aux)
{
struct tc_attach_args *ta;
@ -109,13 +126,14 @@ px_match(struct device *parent, struct cfdata *match, void *aux)
return (strncmp("PMAG-CA ", ta->ta_modname, TC_ROM_LLEN) == 0);
}
static void
void
px_attach(struct device *parent, struct device *self, void *aux)
{
struct stic_info *si;
struct tc_attach_args *ta;
struct px_softc *px;
int console;
int console, i;
u_long v;
px = (struct px_softc *)self;
ta = (struct tc_attach_args *)aux;
@ -136,10 +154,19 @@ px_attach(struct device *parent, struct device *self, void *aux)
}
px->px_si = si;
si->si_dv = self;
tc_intr_establish(parent, ta->ta_cookie, IPL_TTY, px_intr, si);
printf(": 8 plane, %dx%d stamp\n", si->si_stampw, si->si_stamph);
for (i = 0; i < PX_BUF_COUNT; i++) {
v = i * STIC_PACKET_SIZE +
si->si_buf_phys + STIC_XCOMM_SIZE;
v = ((v & 0xffff8000) << 3) | (v & 0x7fff);
px->px_qpoll[i] = (volatile u_int32_t *)
((caddr_t)si->si_slotbase + (v >> 9));
}
stic_attach(self, si, console);
}
@ -154,11 +181,11 @@ px_cnattach(tc_addr_t addr)
stic_cnattach(si);
}
static void
void
px_init(struct stic_info *si, int bootstrap)
{
struct pglist pglist;
caddr_t kva;
caddr_t kva, bva;
paddr_t bpa;
/*
@ -172,7 +199,7 @@ px_init(struct stic_info *si, int bootstrap)
* UVM won't be initialised at this point, so grab memory
* directly from vm_physmem[].
*/
kva = (caddr_t)uvm_pageboot_alloc(PX_BUF_SIZE + PX_BUF_ALIGN);
bva = (caddr_t)uvm_pageboot_alloc(PX_BUF_SIZE + PX_BUF_ALIGN);
bpa = (STIC_KSEG_TO_PHYS(kva) + PX_BUF_ALIGN - 1) &
~(PX_BUF_ALIGN - 1);
if (bpa + PX_BUF_SIZE > 8192*1024)
@ -180,12 +207,12 @@ px_init(struct stic_info *si, int bootstrap)
} else {
TAILQ_INIT(&pglist);
if (uvm_pglistalloc(PX_BUF_SIZE, 0, 8192*1024, PX_BUF_ALIGN,
PX_BUF_ALIGN, &pglist, 1, 0) != 0)
0, &pglist, 1, 0) != 0)
panic("px_init: allocation failure");
bpa = TAILQ_FIRST(&pglist)->phys_addr;
}
kva = (caddr_t)TC_PHYS_TO_UNCACHED(si->si_slotbase);
kva = (caddr_t)si->si_slotbase;
si->si_vdac = (u_int32_t *)(kva + PX_VDAC_OFFSET);
si->si_vdac_reset = (u_int32_t *)(kva + PX_VDAC_RESET_OFFSET);
@ -196,53 +223,106 @@ px_init(struct stic_info *si, int bootstrap)
si->si_buf_size = PX_BUF_SIZE;
si->si_disptype = WSDISPLAY_TYPE_PX;
si->si_depth = 8;
si->si_sxc = (volatile struct stic_xcomm *)si->si_buf;
si->si_pbuf_get = px_pbuf_get;
si->si_pbuf_post = px_pbuf_post;
si->si_ioctl = px_ioctl;
memset(si->si_buf, 0, PX_BUF_SIZE);
stic_init(si);
}
static int
int
px_intr(void *cookie)
{
volatile struct stic_regs *sr;
volatile struct stic_xcomm *sxc;
struct stic_info *si;
struct px_softc *px;
int state;
si = cookie;
px = (struct px_softc *)si->si_dv;
sr = si->si_stic;
state = sr->sr_ipdvint;
sxc = si->si_sxc;
/*
* Vertical-retrace condition.
*
* Clear the flag and flush out any waiting VDAC updates. We do
* this at retrace time to avoid producing `shearing' and other
* nasty artifacts.
*/
if ((state & STIC_INT_V) != 0) {
sr->sr_ipdvint =
STIC_INT_V_WE | (sr->sr_ipdvint & STIC_INT_V_EN);
sr->sr_ipdvint = STIC_INT_V_WE | STIC_INT_V_EN;
tc_wmb();
stic_flush(si);
}
#ifdef DEBUG
if ((sr->sr_ipdvint & STIC_INT_E) != 0) {
printf("%s: error intr, %x %x %x %x %x", si->si_dv.dv_xname,
/*
* Error condition.
*
* Simply clear the flag and report the error.
*/
if ((state & STIC_INT_E) != 0) {
printf("%s: error intr, %x %x %x %x %x", px->px_dv.dv_xname,
sr->sr_ipdvint, sr->sr_sticsr, sr->sr_buscsr,
sr->sr_busadr, sr->sr_busdat);
sr->sr_ipdvint = STIC_INT_E_WE | STIC_INT_E_EN;
tc_wmb();
}
#endif
/*
* Check for queue stalls.
*/
if (sxc->sxc_tail != sxc->sxc_head && !sxc->sxc_busy)
state |= STIC_INT_P;
/*
* Packet-done condition.
*
* If packet queueing is enabled, clear the condition, and increment
* the tail (submitted) pointer.
*/
if ((si->si_hwflags & PXF_QUEUE) != 0 && (state & STIC_INT_P) != 0) {
sr->sr_ipdvint = STIC_INT_P_WE | STIC_INT_P_EN;
tc_wmb();
if (sxc->sxc_tail != sxc->sxc_head) {
sxc->sxc_done[sxc->sxc_tail] = 0;
sxc->sxc_tail = PX_BUF_INC(sxc->sxc_tail);
}
if (sxc->sxc_tail != sxc->sxc_head) {
if (*px->px_qpoll[sxc->sxc_tail] != STAMP_OK) {
sxc->sxc_nreject++;
sxc->sxc_busy = 0;
} else
sxc->sxc_busy = 1;
} else
sxc->sxc_busy = 0;
}
if ((si->si_hwflags & PXF_QUEUE) != 0 && (state & STIC_INT_P_EN) == 0)
printf("px_intr: STIC_INT_P_EN == 0\n");
return (1);
}
static u_int32_t *
u_int32_t *
px_pbuf_get(struct stic_info *si)
{
u_long off;
si->si_pbuf_select ^= STIC_PACKET_SIZE;
return ((u_int32_t *)((caddr_t)si->si_buf + si->si_pbuf_select));
off = si->si_pbuf_select + STIC_XCOMM_SIZE;
return ((u_int32_t *)((caddr_t)si->si_buf + off));
}
static int
int
px_pbuf_post(struct stic_info *si, u_int32_t *buf)
{
volatile u_int32_t *poll, junk;
@ -266,7 +346,7 @@ px_pbuf_post(struct stic_info *si, u_int32_t *buf)
for (c = STAMP_RETRIES; c != 0; c--) {
if ((sr->sr_ipdvint & STIC_INT_P) != 0) {
sr->sr_ipdvint = STIC_INT_P_WE | STIC_INT_P_EN;
sr->sr_ipdvint = STIC_INT_P_WE;
tc_wmb();
junk = *poll;
return (0);
@ -278,3 +358,69 @@ px_pbuf_post(struct stic_info *si, u_int32_t *buf)
stic_reset(si);
return (-1);
}
int
px_ioctl(struct stic_info *si, u_long cmd, caddr_t data, int flag,
struct proc *p)
{
volatile struct stic_xcomm *sxc;
volatile struct stic_regs *sr;
struct stic_xinfo *sxi;
int rv, s;
sr = si->si_stic;
switch (cmd) {
case STICIO_STARTQ:
if (si->si_dispmode != WSDISPLAYIO_MODE_MAPPED ||
(si->si_hwflags & PXF_QUEUE) != 0) {
rv = EBUSY;
break;
}
sxc = si->si_sxc;
memset((void *)sxc->sxc_done, 0, sizeof(sxc->sxc_done));
sxc->sxc_head = 0;
sxc->sxc_tail = 0;
sxc->sxc_nreject = 0;
sxc->sxc_nstall = 0;
s = spltty();
si->si_hwflags |= PXF_QUEUE;
sr->sr_ipdvint = STIC_INT_P_WE | STIC_INT_P_EN;
tc_wmb();
splx(s);
rv = 0;
break;
case STICIO_STOPQ:
s = spltty();
si->si_hwflags &= ~PXF_QUEUE;
sr->sr_ipdvint = STIC_INT_P_WE | STIC_INT_P;
tc_wmb();
splx(s);
rv = 0;
break;
case STICIO_GXINFO:
sxi = (struct stic_xinfo *)data;
sxi->sxi_unit = si->si_unit;
sxi->sxi_stampw = si->si_stampw;
sxi->sxi_stamph = si->si_stamph;
sxi->sxi_buf_size = si->si_buf_size;
sxi->sxi_buf_phys = (u_int)si->si_buf_phys;
sxi->sxi_buf_pktoff = STIC_XCOMM_SIZE;
sxi->sxi_buf_pktcnt = PX_BUF_COUNT;
sxi->sxi_buf_imgoff =
STIC_XCOMM_SIZE + STIC_PACKET_SIZE * PX_BUF_COUNT;
rv = 0;
break;
default:
rv = ENOTTY;
break;
}
return (rv);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pxg.c,v 1.5 2001/07/04 14:17:58 ad Exp $ */
/* $NetBSD: pxg.c,v 1.6 2001/09/18 19:51:23 ad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -68,7 +68,9 @@
#include <dev/tc/tcvar.h>
#include <dev/tc/sticreg.h>
#include <dev/tc/sticio.h>
#include <dev/tc/sticvar.h>
#include <dev/tc/pxgvar.h>
#define PXG_STIC_POLL_OFFSET 0x000000 /* STIC DMA poll space */
#define PXG_STAMP_OFFSET 0x0c0000 /* pixelstamp space on STIC */
@ -82,17 +84,16 @@
#define PXG_I860_START_OFFSET 0x380000 /* i860 start register */
#define PXG_I860_RESET_OFFSET 0x3c0000 /* i860 stop register */
static void pxg_attach(struct device *, struct device *, void *);
static int pxg_intr(void *);
static int pxg_match(struct device *, struct cfdata *, void *);
void pxg_attach(struct device *, struct device *, void *);
int pxg_intr(void *);
int pxg_match(struct device *, struct cfdata *, void *);
static void pxg_init(struct stic_info *);
static int pxg_ioctl(struct stic_info *, u_long, caddr_t, int,
struct proc *);
static u_int32_t *pxg_pbuf_get(struct stic_info *);
static int pxg_pbuf_post(struct stic_info *, u_int32_t *);
static int pxg_probe_planes(struct stic_info *);
static int pxg_probe_sram(struct stic_info *);
void pxg_init(struct stic_info *);
int pxg_ioctl(struct stic_info *, u_long, caddr_t, int, struct proc *);
u_int32_t *pxg_pbuf_get(struct stic_info *);
int pxg_pbuf_post(struct stic_info *, u_int32_t *);
int pxg_probe_planes(struct stic_info *);
int pxg_probe_sram(struct stic_info *);
void pxg_cnattach(tc_addr_t);
@ -113,7 +114,7 @@ static const char *pxg_types[] = {
"PMAGB-FB",
};
static int
int
pxg_match(struct device *parent, struct cfdata *match, void *aux)
{
struct tc_attach_args *ta;
@ -128,7 +129,7 @@ pxg_match(struct device *parent, struct cfdata *match, void *aux)
return (0);
}
static void
void
pxg_attach(struct device *parent, struct device *self, void *aux)
{
struct stic_info *si;
@ -155,12 +156,25 @@ pxg_attach(struct device *parent, struct device *self, void *aux)
}
pxg->pxg_si = si;
si->si_dv = self;
tc_intr_establish(parent, ta->ta_cookie, IPL_TTY, pxg_intr, si);
printf(": %d plane, %dx%d stamp, %dkB SRAM\n", si->si_depth,
si->si_stampw, si->si_stamph, (int)si->si_buf_size >> 10);
stic_attach(self, si, console);
#ifdef notyet
/* Load the co-processor "firmware". */
for (i = 0; i < sizeof(pxg_fwsegs) / sizeof(pxg_fwsegs[0]); i++)
pxg_load_fwseg(si, &pxg_fwsegs[i]);
/* Start the i860. */
si->si_slotbase[PXG_I860_START_OFFSET >> 2] = 1;
tc_wmb();
tc_syncbus();
DELAY(40000);
#endif
}
void
@ -174,7 +188,7 @@ pxg_cnattach(tc_addr_t addr)
stic_cnattach(si);
}
static void
void
pxg_init(struct stic_info *si)
{
volatile u_int32_t *slot;
@ -190,6 +204,7 @@ pxg_init(struct stic_info *si)
si->si_buf_phys = STIC_KSEG_TO_PHYS(si->si_buf);
si->si_buf_size = pxg_probe_sram(si);
si->si_disptype = WSDISPLAY_TYPE_PXG;
si->si_sxc = (volatile struct stic_xcomm *)si->si_buf;
si->si_pbuf_get = pxg_pbuf_get;
si->si_pbuf_post = pxg_pbuf_post;
@ -213,7 +228,7 @@ pxg_init(struct stic_info *si)
stic_init(si);
}
static int
int
pxg_probe_sram(struct stic_info *si)
{
volatile u_int32_t *a, *b;
@ -226,7 +241,7 @@ pxg_probe_sram(struct stic_info *si)
return ((*a == *b) ? 0x20000 : 0x40000);
}
static int
int
pxg_probe_planes(struct stic_info *si)
{
volatile u_int32_t *vdac;
@ -258,9 +273,10 @@ pxg_probe_planes(struct stic_info *si)
return (8);
}
static int
int
pxg_intr(void *cookie)
{
#ifdef notyet
struct stic_info *si;
volatile struct stic_regs *sr;
volatile u_int32_t *hi;
@ -280,29 +296,30 @@ pxg_intr(void *cookie)
hi[2] = 0;
tc_wmb();
/*
* On the PXG, STIC interrupts are posted to the co-processor.
* Since we don't yet run it, this code is useless.
*/
if (it == 3) {
sr->sr_ipdvint =
STIC_INT_V_WE | (sr->sr_ipdvint & STIC_INT_V_EN);
switch (it) {
case 3:
sr->sr_ipdvint = STIC_INT_V_WE | STIC_INT_V_EN;
tc_wmb();
stic_flush(si);
break;
}
#else
printf("pxg_intr: how did this happen?\n");
#endif
return (1);
}
static u_int32_t *
u_int32_t *
pxg_pbuf_get(struct stic_info *si)
{
u_long off;
si->si_pbuf_select ^= STIC_PACKET_SIZE;
return ((u_int32_t *)((caddr_t)si->si_buf + si->si_pbuf_select));
off = si->si_pbuf_select + STIC_XCOMM_SIZE;
return ((u_int32_t *)((caddr_t)si->si_buf + off));
}
static int
int
pxg_pbuf_post(struct stic_info *si, u_int32_t *buf)
{
volatile u_int32_t *poll, junk;
@ -325,7 +342,7 @@ pxg_pbuf_post(struct stic_info *si, u_int32_t *buf)
for (c = STAMP_RETRIES; c != 0; c--) {
if ((sr->sr_ipdvint & STIC_INT_P) != 0) {
sr->sr_ipdvint = STIC_INT_P_WE | STIC_INT_P_EN;
sr->sr_ipdvint = STIC_INT_P_WE;
tc_wmb();
junk = *poll;
return (0);
@ -338,25 +355,86 @@ pxg_pbuf_post(struct stic_info *si, u_int32_t *buf)
return (-1);
}
static int
int
pxg_ioctl(struct stic_info *si, u_long cmd, caddr_t data, int flag,
struct proc *p)
{
struct stic_xinfo *sxi;
volatile u_int32_t *ptr;
int rv;
int rv, s;
if (cmd == STICIO_START860 || cmd == STICIO_RESET860) {
switch (cmd) {
case STICIO_START860:
case STICIO_RESET860:
if ((rv = suser(p->p_ucred, &p->p_acflag)) != 0)
return (rv);
if (si->si_dispmode != WSDISPLAYIO_MODE_MAPPED)
return (EBUSY);
ptr = (volatile u_int32_t *)si->si_slotbase;
if (cmd == STICIO_START860)
break;
}
switch (cmd) {
case STICIO_START860:
s = spltty();
ptr[PXG_I860_START_OFFSET >> 2] = 1;
else
tc_wmb();
splx(s);
rv = 0;
break;
case STICIO_RESET860:
s = spltty();
ptr[PXG_I860_RESET_OFFSET >> 2] = 0;
tc_wmb();
splx(s);
rv = 0;
} else
break;
case STICIO_GXINFO:
sxi = (struct stic_xinfo *)data;
sxi->sxi_unit = si->si_unit;
sxi->sxi_stampw = si->si_stampw;
sxi->sxi_stamph = si->si_stamph;
sxi->sxi_buf_size = si->si_buf_size;
sxi->sxi_buf_phys = 0;
sxi->sxi_buf_pktoff = STIC_XCOMM_SIZE;
sxi->sxi_buf_pktcnt = 2;
sxi->sxi_buf_imgoff = STIC_XCOMM_SIZE + STIC_PACKET_SIZE * 2;
rv = 0;
break;
default:
rv = ENOTTY;
break;
}
return (rv);
}
#ifdef notyet
void
pxg_load_fwseg(struct stic_info *si, struct pxg_fwseg *pfs)
{
const u_int32_t *src;
u_int32_t *dst;
u_int left, i;
dst = (u_int32_t *)((caddr_t)si->si_buf + pfs->pfs_addr);
src = pfs->pfs_data;
for (left = pfs->pfs_compsize; left != 0; left -= 4) {
if (src[0] == PXGFW_RLE_MAGIC) {
for (i = src[2]; i != 0; i--)
*dst++ = src[1];
src += 3;
} else {
*dst++ = src[0];
src++;
}
}
if (src == NULL)
memset(dst, 0, pfs->pfs_realsize);
}
#endif

60
sys/dev/tc/pxgvar.h Normal file
View File

@ -0,0 +1,60 @@
/* $NetBSD: pxgvar.h,v 1.1 2001/09/18 19:51:23 ad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _TC_PXGVAR_H_
#define _TC_PXGVAR_H_
/*
* Firmware segment. If pfs_data is NULL, this is BSS and should be zeroed.
* Otherwise, pfs_data points to an RLE compressed binary image. If a word
* is read and matches PXGFW_RLE_MAGIC, the next word contains the data, and
* the next the repeat count. All segment sizes and addresses must be
* aligned to a 32-bit boundary.
*/
struct pxg_fwseg {
u_int pfs_addr; /* load address */
u_int pfs_compsize; /* compressed size in bytes */
u_int pfs_realsize; /* real size in bytes */
const u_int32_t *pfs_data; /* pointer to compressed data */
};
#define PXGFW_RLE_MAGIC 0xfffffffe
extern const struct pxg_fwseg pxg_fwsegs[];
#endif /* _TC_PXGVAR_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: stic.c,v 1.10 2001/09/18 18:15:54 wiz Exp $ */
/* $NetBSD: stic.c,v 1.11 2001/09/18 19:51:23 ad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -80,6 +80,7 @@
#include <sys/buf.h>
#include <sys/ioctl.h>
#include <sys/callout.h>
#include <sys/conf.h>
#include <uvm/uvm_extern.h>
@ -102,6 +103,7 @@
#include <dev/tc/tcvar.h>
#include <dev/tc/sticreg.h>
#include <dev/tc/sticio.h>
#include <dev/tc/sticvar.h>
#define DUPBYTE0(x) ((((x)&0xff)<<16) | (((x)&0xff)<<8) | ((x)&0xff))
@ -152,32 +154,37 @@
tc_wmb(); \
} while (0)
static int sticioctl(void *, u_long, caddr_t, int, struct proc *);
static paddr_t sticmmap(void *, off_t, int);
static int stic_alloc_screen(void *, const struct wsscreen_descr *,
void **, int *, int *, long *);
static void stic_free_screen(void *, void *);
static int stic_show_screen(void *, void *, int,
void (*) (void *, int, int), void *);
static void stic_do_switch(void *);
static void stic_setup_backing(struct stic_info *, struct stic_screen *);
static void stic_setup_vdac(struct stic_info *si);
int sticioctl(void *, u_long, caddr_t, int, struct proc *);
int stic_alloc_screen(void *, const struct wsscreen_descr *, void **,
int *, int *, long *);
void stic_free_screen(void *, void *);
int stic_show_screen(void *, void *, int, void (*)(void *, int, int),
void *);
static int stic_get_cmap(struct stic_info *, struct wsdisplay_cmap *);
static int stic_set_cmap(struct stic_info *, struct wsdisplay_cmap *);
static int stic_set_cursor(struct stic_info *, struct wsdisplay_cursor *);
static int stic_get_cursor(struct stic_info *, struct wsdisplay_cursor *);
static void stic_set_curpos(struct stic_info *, struct wsdisplay_curpos *);
static void stic_set_hwcurpos(struct stic_info *);
int sticopen(dev_t, int, int, struct proc *);
int sticclose(dev_t, int, int, struct proc *);
paddr_t sticmmap(dev_t, off_t, int);
static void stic_cursor(void *, int, int, int);
static void stic_copycols(void *, int, int, int, int);
static void stic_copyrows(void *, int, int, int);
static void stic_erasecols(void *, int, int, int, long);
static void stic_eraserows(void *, int, int, long);
static int stic_mapchar(void *, int, u_int *);
static void stic_putchar(void *, int, int, u_int, long);
static int stic_alloc_attr(void *, int, int, int, long *);
void stic_do_switch(void *);
void stic_setup_backing(struct stic_info *, struct stic_screen *);
void stic_setup_vdac(struct stic_info *);
void stic_clear_screen(struct stic_info *);
int stic_get_cmap(struct stic_info *, struct wsdisplay_cmap *);
int stic_set_cmap(struct stic_info *, struct wsdisplay_cmap *);
int stic_set_cursor(struct stic_info *, struct wsdisplay_cursor *);
int stic_get_cursor(struct stic_info *, struct wsdisplay_cursor *);
void stic_set_curpos(struct stic_info *, struct wsdisplay_curpos *);
void stic_set_hwcurpos(struct stic_info *);
void stic_cursor(void *, int, int, int);
void stic_copycols(void *, int, int, int, int);
void stic_copyrows(void *, int, int, int);
void stic_erasecols(void *, int, int, int, long);
void stic_eraserows(void *, int, int, long);
int stic_mapchar(void *, int, u_int *);
void stic_putchar(void *, int, int, u_int, long);
int stic_alloc_attr(void *, int, int, int, long *);
/* Colormap for wscons, matching WSCOL_*. Upper 8 are high-intensity. */
static const u_int8_t stic_cmap[16*3] = {
@ -244,11 +251,11 @@ static const u_int8_t shuffle[256] = {
static const struct wsdisplay_accessops stic_accessops = {
sticioctl,
sticmmap,
NULL, /* mmap */
stic_alloc_screen,
stic_free_screen,
stic_show_screen,
0 /* load_font */
NULL, /* load_font */
};
static const struct wsdisplay_emulops stic_emulops = {
@ -280,6 +287,8 @@ static const struct wsscreen_list stic_screenlist = {
struct stic_info stic_consinfo;
static struct stic_screen stic_consscr;
static struct stic_info *stic_info[STIC_MAXDV];
static int stic_unit;
void
stic_init(struct stic_info *si)
@ -345,6 +354,8 @@ stic_init(struct stic_info *si)
#endif
stic_setup_vdac(si);
stic_clear_screen(si);
si->si_dispmode = WSDISPLAYIO_MODE_EMUL;
}
void
@ -361,7 +372,7 @@ stic_reset(struct stic_info *si)
sr->sr_sticsr = 0x00000030; /* Get the STIC's attention. */
tc_wmb();
tc_syncbus();
DELAY(4000); /* wait 4ms for STIC to respond. */
DELAY(2000); /* wait 2ms for STIC to respond. */
sr->sr_sticsr = 0x00000000; /* Hit the STIC's csr again... */
tc_wmb();
sr->sr_buscsr = 0xffffffff; /* and bash its bus-acess csr. */
@ -390,14 +401,17 @@ stic_reset(struct stic_info *si)
}
/*
* Initialize STIC video registers.
* Initialize STIC video registers. Enable error and vertical
* retrace interrupts. Set the packet done flag so the Xserver will
* not time-out on the first packet submitted.
*/
sr->sr_vblank = (1024 << 16) | 1063;
sr->sr_vsync = (1027 << 16) | 1030;
sr->sr_hblank = (255 << 16) | 340;
sr->sr_hsync2 = 245;
sr->sr_hsync = (261 << 16) | 293;
sr->sr_ipdvint = STIC_INT_CLR | STIC_INT_WE | STIC_INT_P;
sr->sr_ipdvint =
STIC_INT_WE | STIC_INT_P | STIC_INT_E_EN | STIC_INT_V_EN;
sr->sr_sticsr = 8;
tc_wmb();
tc_syncbus();
@ -408,6 +422,12 @@ stic_attach(struct device *self, struct stic_info *si, int console)
{
struct wsemuldisplaydev_attach_args waa;
if (stic_unit < STIC_MAXDV) {
stic_info[stic_unit] = si;
si->si_unit = stic_unit++;
} else
si->si_unit = -1;
callout_init(&si->si_switch_callout);
/*
@ -423,6 +443,7 @@ stic_attach(struct device *self, struct stic_info *si, int console)
waa.scrdata = &stic_screenlist;
waa.accessops = &stic_accessops;
waa.accesscookie = si;
config_found(self, &waa, wsemuldisplaydevprint);
}
@ -445,26 +466,28 @@ stic_cnattach(struct stic_info *si)
wsdisplay_cnattach(&stic_stdscreen, ss, 0, 0, defattr);
}
static void
void
stic_setup_vdac(struct stic_info *si)
{
u_int8_t *ip, *mp;
int r, c, o, b, i;
int r, c, o, b, i, s;
s = spltty();
ip = (u_int8_t *)si->si_cursor.cc_image;
mp = ip + (sizeof(si->si_cursor.cc_image) >> 1);
memset(ip, 0, sizeof(si->si_cursor.cc_image));
for (r = 0; r < si->si_fonth; r++) {
for (c = 0; c < si->si_fontw; c++) {
for (c = r & 1; c < si->si_fontw; c += 2) {
o = c >> 3;
b = 1 << (c & 7);
ip[o] |= b;
mp[o] |= b;
}
ip += 16;
mp += 16;
ip += 8;
mp += 8;
}
si->si_cursor.cc_size.x = 64;
@ -488,13 +511,40 @@ stic_setup_vdac(struct stic_info *si)
si->si_flags |= SI_CMAP_CHANGED | SI_CURSHAPE_CHANGED |
SI_CURCMAP_CHANGED;
splx(s);
}
static int
void
stic_clear_screen(struct stic_info *si)
{
u_int32_t *pb;
int i;
/*
* Do this twice, since the first packet after a reset may be
* silently ignored.
*/
for (i = 0; i < 2; i++) {
pb = (*si->si_pbuf_get)(si);
pb[0] = STAMP_CMD_LINES | STAMP_RGB_CONST | STAMP_LW_PERPACKET;
pb[1] = 0x01ffffff;
pb[2] = 0;
pb[3] = STAMP_UPDATE_ENABLE | STAMP_METHOD_COPY;
pb[4] = (1024 << 2) - 1;
pb[5] = 0;
pb[6] = 0;
pb[7] = (1280 << 19) | ((1024 << 3) + pb[4]);
(*si->si_pbuf_post)(si, pb);
}
}
int
sticioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
{
struct stic_info *si;
struct stic_xinfo *sxi;
si = v;
@ -553,9 +603,12 @@ sticioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
return (stic_set_cursor(si, (struct wsdisplay_cursor *)data));
case WSDISPLAYIO_SMODE:
if (*(int *)data == WSDISPLAYIO_MODE_EMUL) {
si->si_dispmode = *(int *)data;
if (si->si_dispmode == WSDISPLAYIO_MODE_EMUL) {
(*si->si_ioctl)(si, STICIO_STOPQ, NULL, flag, p);
stic_setup_vdac(si);
stic_flush(si);
stic_clear_screen(si);
stic_do_switch(si->si_curscreen);
}
return (0);
@ -563,14 +616,6 @@ sticioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
case STICIO_RESET:
stic_reset(si);
return (0);
case STICIO_GXINFO:
sxi = (struct stic_xinfo *)data;
sxi->sxi_stampw = si->si_stampw;
sxi->sxi_stamph = si->si_stamph;
sxi->sxi_buf_size = si->si_buf_size;
sxi->sxi_buf_phys = (u_long)si->si_buf_phys;
return (0);
}
if (si->si_ioctl != NULL)
@ -579,37 +624,7 @@ sticioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
return (ENOTTY);
}
static paddr_t
sticmmap(void *v, off_t offset, int prot)
{
struct stic_info *si;
struct stic_xmap sxm;
paddr_t pa;
si = v;
if (offset < 0)
return ((paddr_t)-1L);
if (offset < sizeof(sxm.sxm_stic)) {
pa = STIC_KSEG_TO_PHYS(si->si_stic);
return (machine_btop(pa + offset));
}
offset -= sizeof(sxm.sxm_stic);
if (offset < sizeof(sxm.sxm_poll)) {
pa = STIC_KSEG_TO_PHYS(si->si_slotbase);
return (machine_btop(pa + offset));
}
offset -= sizeof(sxm.sxm_poll);
if (offset < si->si_buf_size)
return (machine_btop(si->si_buf_phys + offset));
return ((paddr_t)-1L);
}
static void
void
stic_setup_backing(struct stic_info *si, struct stic_screen *ss)
{
int size;
@ -619,7 +634,7 @@ stic_setup_backing(struct stic_info *si, struct stic_screen *ss)
memset(ss->ss_backing, 0, size);
}
static int
int
stic_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
int *curxp, int *curyp, long *attrp)
{
@ -647,7 +662,7 @@ stic_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
return (0);
}
static void
void
stic_free_screen(void *v, void *cookie)
{
struct stic_screen *ss;
@ -665,7 +680,7 @@ stic_free_screen(void *v, void *cookie)
free(ss, M_DEVBUF);
}
static int
int
stic_show_screen(void *v, void *cookie, int waitok,
void (*cb)(void *, int, int), void *cbarg)
{
@ -687,7 +702,7 @@ stic_show_screen(void *v, void *cookie, int waitok,
return (0);
}
static void
void
stic_do_switch(void *cookie)
{
struct stic_screen *ss;
@ -704,6 +719,7 @@ stic_do_switch(void *cookie)
#endif
/* Swap in the new screen, and temporarily disable its backing. */
if (si->si_curscreen != NULL)
si->si_curscreen->ss_flags ^= SS_ACTIVE;
si->si_curscreen = ss;
ss->ss_flags |= SS_ACTIVE;
@ -754,7 +770,7 @@ stic_do_switch(void *cookie)
}
}
static int
int
stic_alloc_attr(void *cookie, int fg, int bg, int flags, long *attr)
{
long tmp;
@ -775,7 +791,7 @@ stic_alloc_attr(void *cookie, int fg, int bg, int flags, long *attr)
return (0);
}
static void
void
stic_erasecols(void *cookie, int row, int col, int num, long attr)
{
struct stic_info *si;
@ -816,7 +832,7 @@ stic_erasecols(void *cookie, int row, int col, int num, long attr)
(*si->si_pbuf_post)(si, pb);
}
static void
void
stic_eraserows(void *cookie, int row, int num, long attr)
{
struct stic_info *si;
@ -855,7 +871,7 @@ stic_eraserows(void *cookie, int row, int num, long attr)
(*si->si_pbuf_post)(si, pb);
}
static void
void
stic_copyrows(void *cookie, int src, int dst, int height)
{
struct stic_info *si;
@ -915,7 +931,7 @@ stic_copyrows(void *cookie, int src, int dst, int height)
}
}
static void
void
stic_copycols(void *cookie, int row, int src, int dst, int num)
{
struct stic_info *si;
@ -967,7 +983,7 @@ stic_copycols(void *cookie, int row, int src, int dst, int num)
(*si->si_pbuf_post)(si, pbs);
}
static void
void
stic_putchar(void *cookie, int r, int c, u_int uc, long attr)
{
struct wsdisplay_font *font;
@ -1087,7 +1103,7 @@ stic_putchar(void *cookie, int r, int c, u_int uc, long attr)
(*si->si_pbuf_post)(si, pb);
}
static int
int
stic_mapchar(void *cookie, int c, u_int *cp)
{
struct stic_info *si;
@ -1108,11 +1124,12 @@ stic_mapchar(void *cookie, int c, u_int *cp)
return (5);
}
static void
void
stic_cursor(void *cookie, int on, int row, int col)
{
struct stic_screen *ss;
struct stic_info *si;
int s;
ss = cookie;
si = ss->ss_si;
@ -1120,6 +1137,8 @@ stic_cursor(void *cookie, int on, int row, int col)
ss->ss_curx = col * si->si_fontw;
ss->ss_cury = row * si->si_fonth;
s = spltty();
if (on)
ss->ss_flags |= SS_CURENB;
else
@ -1138,6 +1157,8 @@ stic_cursor(void *cookie, int on, int row, int col)
if (si->si_disptype == WSDISPLAY_TYPE_PXG)
stic_flush(si);
}
splx(s);
}
void
@ -1185,14 +1206,9 @@ stic_flush(struct stic_info *si)
mp = (u_int8_t *)(si->si_cursor.cc_image + CURSOR_MAX_SIZE);
bcnt = 0;
SELECT(vdac, BT459_IREG_CRAM_BASE+0);
SELECT(vdac, BT459_IREG_CRAM_BASE);
/* 64 pixel scan line is consisted with 16 byte cursor ram */
while (bcnt < si->si_cursor.cc_size.y * 16) {
/* pad right half 32 pixel when smaller than 33 */
if ((bcnt & 0x8) && si->si_cursor.cc_size.x < 33) {
REG(vdac, bt_reg) = 0; tc_wmb();
REG(vdac, bt_reg) = 0; tc_wmb();
} else {
while (bcnt < CURSOR_MAX_SIZE * 16) {
img = *ip++;
msk = *mp++;
img &= msk; /* cookie off image */
@ -1202,13 +1218,6 @@ stic_flush(struct stic_info *si)
u = (msk & 0xf0) | (img & 0xf0) >> 4;
REG(vdac, bt_reg) = DUPBYTE0(shuffle[u]);
tc_wmb();
}
bcnt += 2;
}
/* pad unoccupied scan lines */
while (bcnt < CURSOR_MAX_SIZE * 16) {
REG(vdac, bt_reg) = 0; tc_wmb();
REG(vdac, bt_reg) = 0; tc_wmb();
bcnt += 2;
}
}
@ -1232,7 +1241,7 @@ stic_flush(struct stic_info *si)
}
}
static int
int
stic_get_cmap(struct stic_info *si, struct wsdisplay_cmap *p)
{
u_int index, count;
@ -1254,10 +1263,11 @@ stic_get_cmap(struct stic_info *si, struct wsdisplay_cmap *p)
return (0);
}
static int
int
stic_set_cmap(struct stic_info *si, struct wsdisplay_cmap *p)
{
u_int index, count;
int s;
index = p->index;
count = p->count;
@ -1270,11 +1280,12 @@ stic_set_cmap(struct stic_info *si, struct wsdisplay_cmap *p)
!uvm_useracc(p->blue, count, B_READ))
return (EFAULT);
s = spltty();
copyin(p->red, &si->si_cmap.r[index], count);
copyin(p->green, &si->si_cmap.g[index], count);
copyin(p->blue, &si->si_cmap.b[index], count);
si->si_flags |= SI_CMAP_CHANGED;
splx(s);
/*
* XXX Since we don't yet receive vblank interrupts from the PXG, we
@ -1286,12 +1297,13 @@ stic_set_cmap(struct stic_info *si, struct wsdisplay_cmap *p)
return (0);
}
static int
int
stic_set_cursor(struct stic_info *si, struct wsdisplay_cursor *p)
{
#define cc (&si->si_cursor)
u_int v, index, count, icount;
struct stic_screen *ss;
int s;
v = p->which;
ss = si->si_curscreen;
@ -1323,6 +1335,8 @@ stic_set_cursor(struct stic_info *si, struct wsdisplay_cursor *p)
stic_set_curpos(si, &p->pos);
}
s = spltty();
if ((v & WSDISPLAY_CURSOR_DOCUR) != 0) {
if (p->enable)
ss->ss_flags |= SS_CURENB;
@ -1339,13 +1353,14 @@ stic_set_cursor(struct stic_info *si, struct wsdisplay_cursor *p)
}
if ((v & WSDISPLAY_CURSOR_DOSHAPE) != 0) {
cc->cc_size = p->size;
memset(cc->cc_image, 0, sizeof cc->cc_image);
memset(cc->cc_image, 0, sizeof(cc->cc_image));
copyin(p->image, cc->cc_image, icount);
copyin(p->mask, cc->cc_image + CURSOR_MAX_SIZE, icount);
si->si_flags |= SI_CURSHAPE_CHANGED;
}
splx(s);
/*
* XXX Since we don't yet receive vblank interrupts from the PXG, we
* must flush immediatley.
@ -1357,7 +1372,7 @@ stic_set_cursor(struct stic_info *si, struct wsdisplay_cursor *p)
#undef cc
}
static int
int
stic_get_cursor(struct stic_info *si, struct wsdisplay_cursor *p)
{
@ -1365,7 +1380,7 @@ stic_get_cursor(struct stic_info *si, struct wsdisplay_cursor *p)
return (ENOTTY);
}
static void
void
stic_set_curpos(struct stic_info *si, struct wsdisplay_curpos *curpos)
{
int x, y;
@ -1387,7 +1402,7 @@ stic_set_curpos(struct stic_info *si, struct wsdisplay_curpos *curpos)
stic_set_hwcurpos(si);
}
static void
void
stic_set_hwcurpos(struct stic_info *si)
{
volatile u_int32_t *vdac;
@ -1408,3 +1423,87 @@ stic_set_hwcurpos(struct stic_info *si)
REG(vdac, bt_reg) = DUPBYTE1(y); tc_wmb();
splx(s);
}
/*
* STIC control inteface. We have a seperate device for mapping the board,
* because access to the DMA engine means that it's possible to circumvent
* the securelevel mechanism. Given the way devices work in the BSD kernel,
* and given the unfortunate design of the mmap() call it's near impossible
* to protect against this using a shared device (i.e. wsdisplay).
*
* This is a gross hack... Hopefully not too many other devices will need
* it.
*/
int
sticopen(dev_t dev, int flag, int mode, struct proc *p)
{
struct stic_info *si;
int s;
if (securelevel > 0)
return (EPERM);
if (minor(dev) >= STIC_MAXDV)
return (ENXIO);
if ((si = stic_info[minor(dev)]) == NULL)
return (ENXIO);
s = spltty();
if ((si->si_flags & SI_DVOPEN) != 0) {
splx(s);
return (EBUSY);
}
si->si_flags |= SI_DVOPEN;
splx(s);
return (0);
}
int
sticclose(dev_t dev, int flag, int mode, struct proc *p)
{
struct stic_info *si;
int s;
si = stic_info[minor(dev)];
s = spltty();
si->si_flags &= ~SI_DVOPEN;
splx(s);
return (0);
}
paddr_t
sticmmap(dev_t dev, off_t offset, int prot)
{
struct stic_info *si;
struct stic_xmap *sxm;
paddr_t pa;
si = stic_info[minor(dev)];
sxm = NULL;
if (securelevel > 0)
return (-1L);
if (si->si_dispmode != WSDISPLAYIO_MODE_MAPPED)
return (-1L);
if (offset < 0)
return ((paddr_t)-1L);
if (offset < sizeof(sxm->sxm_stic)) {
pa = STIC_KSEG_TO_PHYS(si->si_stic);
return (machine_btop(pa + offset));
}
offset -= sizeof(sxm->sxm_stic);
if (offset < sizeof(sxm->sxm_poll)) {
pa = STIC_KSEG_TO_PHYS(si->si_slotbase);
return (machine_btop(pa + offset));
}
offset -= sizeof(sxm->sxm_poll);
if (offset < si->si_buf_size)
return (machine_btop(si->si_buf_phys + offset));
return ((paddr_t)-1L);
}

101
sys/dev/tc/sticio.h Normal file
View File

@ -0,0 +1,101 @@
/* $NetBSD: sticio.h,v 1.1 2001/09/18 19:51:23 ad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _TC_STICIO_H_
#define _TC_STICIO_H_
/*
* Buffer sizes. Image buffers (span buffers, really) must be able to hold
* 1280 32-bit pixels, even for the 8-bit boards.
*/
#define STIC_XCOMM_SIZE 4096
#define STIC_PACKET_SIZE 4096
#define STIC_IMGBUF_SIZE 1280*4
/*
* stic_xinfo: info about the board that can't be gleaned using the generic
* wscons interfaces.
*/
struct stic_xinfo {
int sxi_stampw; /* stamp width */
int sxi_stamph; /* stamp height */
int sxi_unit; /* control device unit (-1 == none) */
u_int sxi_buf_size; /* total buffer size in bytes */
u_int sxi_buf_phys; /* buffer PA (STIC address space) */
u_int sxi_buf_pktoff; /* offset to packet buffers */
u_int sxi_buf_pktcnt; /* packet buffer count */
u_int sxi_buf_imgoff; /* offset to image buffers */
};
/*
* stic_xcomm: Xserver communication area. Used to communicate with the
* kernel or i860 firmware when performing packet queueing or other such
* funkiness.
*/
struct stic_xcomm {
u_int sxc_head; /* Xserver submit pointer */
u_int sxc_tail; /* STIC execute pointer */
u_int sxc_nreject; /* number of rejected STIC polls */
u_int sxc_nstall; /* number of queue stalls */
u_int sxc_busy; /* true if STIC is busy */
u_int sxc_reserved[8]; /* reserved for future use */
u_int sxc_done[16]; /* packet completion semaphores */
};
/*
* stic_xmap: a description of the area returned by mapping the board.
* sxm_xcomm and sxm_buf are physically contigious and of variable size as a
* whole; the combined size is learnt from stic_xinfo::sxi_buf_size.
*/
struct stic_xmap {
u_int8_t sxm_stic[NBPG]; /* STIC registers */
u_int8_t sxm_poll[0xc0000]; /* poll registers */
u_int8_t sxm_xcomm[256 * 1024]; /* X comms area */
};
/*
* ioctl interface.
*/
#define STICIO_GXINFO _IOR('S', 0, struct stic_xinfo)
#define STICIO_RESET _IO('S', 1)
#define STICIO_START860 _IO('S', 2) /* PXG only, may disappear */
#define STICIO_RESET860 _IO('S', 3) /* PXG only, may disappear */
#define STICIO_STARTQ _IO('S', 4) /* currently PX only */
#define STICIO_STOPQ _IO('S', 5) /* currently PX only */
#endif /* !_TC_STICIO_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: sticreg.h,v 1.4 2001/03/04 13:32:25 ad Exp $ */
/* $NetBSD: sticreg.h,v 1.5 2001/09/18 19:51:23 ad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -67,6 +67,8 @@
/*
* Command word.
*/
/* Base command */
#define STAMP_CMD_POINTS (0x0000)
#define STAMP_CMD_LINES (0x0001)
#define STAMP_CMD_TRIANGLES (0x0002)
@ -75,24 +77,29 @@
#define STAMP_CMD_WRITESPANS (0x0007)
#define STAMP_CMD_VIDEO (0x0008)
/* Color */
#define STAMP_RGB_NONE (0x0000)
#define STAMP_RGB_CONST (0x0010)
#define STAMP_RGB_FLAT (0x0020)
#define STAMP_RGB_SMOOTH (0x0030)
/* Z */
#define STAMP_Z_NONE (0x0000)
#define STAMP_Z_CONST (0x0040)
#define STAMP_Z_FLAT (0x0080)
#define STAMP_Z_SMOOTH (0x00c0)
/* XYMASK */
#define STAMP_XY_NONE (0x0000)
#define STAMP_XY_PERPACKET (0x0100)
#define STAMP_XY_PERPRIMATIVE (0x0200)
/* Line width */
#define STAMP_LW_NONE (0x0000)
#define STAMP_LW_PERPACKET (0x0400)
#define STAMP_LW_PERPRIMATIVE (0x0800)
/* Miscellaneous flags */
#define STAMP_CLIPRECT (0x00080000)
#define STAMP_MESH (0x00200000)
#define STAMP_AALINE (0x00800000)
@ -101,6 +108,8 @@
/*
* Update word.
*/
/* XXX What does this do? Perhaps for 96-bit boards? */
#define STAMP_PLANE_8X3 (0 << 5)
#define STAMP_PLANE_24 (1 << 5)
@ -110,6 +119,7 @@
#define STAMP_WE_CLIPRECT (0x01 << 8)
#define STAMP_WE_NONE (0x00 << 8)
/* Pixel write method */
#define STAMP_METHOD_CLEAR (0x60 << 12)
#define STAMP_METHOD_AND (0x14 << 12)
#define STAMP_METHOD_ANDREV (0x15 << 12)
@ -136,6 +146,7 @@
#define STAMP_DB_12 (0x02 << 28)
#define STAMP_DB_02 (0x04 << 28)
/* Miscellaneous flags */
#define STAMP_UPDATE_ENABLE (1 << 0)
#define STAMP_SAVE_SIGN (1 << 6)
#define STAMP_SAVE_ALPHA (1 << 7)
@ -149,7 +160,7 @@
#define STAMP_INITIALIZE (1 << 31)
/*
* Mask address calculation.
* XYMASK address calculation.
*/
#define XMASKADDR(sw, sx, a) (((a)-((sx) % (sw))) & 15)
#define YMASKADDR(sh, sy, b) (((b)-((sy) % (sh))) & 15)
@ -162,6 +173,9 @@
#define STIC_MAGIC_X 370
#define STIC_MAGIC_Y 37
/*
* Poll register magic values.
*/
#define STAMP_OK (0)
#define STAMP_BUSY (1)
#define STAMP_RETRIES (100000)
@ -187,7 +201,7 @@ struct stic_regs {
u_int32_t sr_pad3;
u_int32_t sr_buscsr;
u_int32_t sr_modcl;
};
} __attribute__ ((__packed__));
/*
* Bit definitions for stic_regs::sticsr.
@ -205,9 +219,10 @@ struct stic_regs {
/*
* Bit definitions for stic_regs::int. Three four-bit wide fields, for
* error (E), vertical-blank (V), and packetbuf-done (P) intererupts,
* respectively. The low-order three bits of each field are enable,
* requested, and acknowledge bits. The top bit of each field is unused.
* error (E), vertical-blank (V), and packet-done (P) intererupts,
* respectively. The low-order three bits of each field are interrupt
* enable, condition flagged, and nybble write enable. The top bit of each
* field is unused.
*/
#define STIC_INT_E_EN 0x00000001
#define STIC_INT_E 0x00000002

View File

@ -1,4 +1,4 @@
/* $NetBSD: sticvar.h,v 1.8 2001/03/04 13:32:25 ad Exp $ */
/* $NetBSD: sticvar.h,v 1.9 2001/09/18 19:51:23 ad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -39,8 +39,6 @@
#ifndef _TC_STICVAR_H_
#define _TC_STICVAR_H_
#ifdef _KERNEL
#if defined(pmax)
#define STIC_KSEG_TO_PHYS(x) MIPS_KSEG0_TO_PHYS(x)
#elif defined(alpha)
@ -48,6 +46,8 @@
#else No support for your architecture
#endif
#define STIC_MAXDV 5
struct stic_hwcmap256 {
#define CMAP_SIZE 256 /* 256 R/G/B entries */
u_int8_t r[CMAP_SIZE];
@ -77,17 +77,21 @@ struct stic_screen {
#define SS_CURENB 0x04
struct stic_info {
struct device *si_dv;
u_int32_t *si_stamp;
u_int32_t *si_buf;
u_int32_t *si_vdac;
u_int32_t *si_vdac_reset;
volatile struct stic_regs *si_stic;
volatile struct stic_xcomm *si_sxc;
u_int32_t *(*si_pbuf_get)(struct stic_info *);
int (*si_pbuf_post)(struct stic_info *, u_int32_t *);
int (*si_ioctl)(struct stic_info *, u_long, caddr_t, int,
struct proc *);
int si_pbuf_select;
int si_hwflags;
struct stic_screen *si_curscreen;
struct wsdisplay_font *si_font;
@ -99,9 +103,11 @@ struct stic_info {
int si_stamph;
int si_stampw;
int si_depth;
int si_disptype;
int si_dispmode;
int si_unit;
tc_addr_t si_slotbase;
int si_disptype;
paddr_t si_buf_phys;
size_t si_buf_size;
@ -119,6 +125,7 @@ struct stic_info {
#define SI_CURSHAPE_CHANGED 0x0004
#define SI_CMAP_CHANGED 0x0008
#define SI_ALL_CHANGED 0x000f
#define SI_DVOPEN 0x0010
void stic_init(struct stic_info *);
void stic_attach(struct device *, struct stic_info *, int);
@ -128,27 +135,4 @@ void stic_flush(struct stic_info *);
extern struct stic_info stic_consinfo;
#endif /* _KERNEL */
#define STIC_PACKET_SIZE 4096
#define STIC_IMGBUF_SIZE 1280*4
struct stic_xinfo {
int sxi_stampw;
int sxi_stamph;
u_long sxi_buf_size;
u_long sxi_buf_phys;
};
#define STICIO_GXINFO _IOR('S', 0, struct stic_xinfo)
#define STICIO_RESET _IO('S', 1)
#define STICIO_START860 _IO('S', 2)
#define STICIO_RESET860 _IO('S', 3)
struct stic_xmap {
u_int8_t sxm_stic[NBPG];
u_int8_t sxm_poll[0x0c0000];
u_int8_t sxm_buf[256 * 1024];
};
#endif /* !_TC_STICVAR_H_ */