Add sti(4) at sgc screen console support. From (the late) OpenBSD/hp300.

Tested on HP9000/425e, which was sent from Miod Vallat and
demonstrated at Open Source unConference 2014 Kagawa.
This commit is contained in:
tsutsui 2014-04-13 15:45:26 +00:00
parent 360bbc64e4
commit c6dcfa5a19
4 changed files with 431 additions and 4 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.buildboot,v 1.33 2014/01/12 15:26:29 tsutsui Exp $
# $NetBSD: Makefile.buildboot,v 1.34 2014/04/13 15:45:26 tsutsui Exp $
# RELOC=FFF00000 allows for boot prog up to FF000 (1044480) bytes long
RELOC= FFF00000
@ -59,6 +59,7 @@ COMMONSOURCE= srt0.S autoconf.c clock.c conf.c cons.c devopen.c \
DRIVERSOURCE= apci.c ct.c dca.c dcm.c dnkbd.c fhpib.c hil.c \
hpib.c if_le.c ite.c ite_dumb.c ite_dv.c ite_gb.c \
ite_hy.c ite_rb.c ite_subr.c ite_tc.c ite_tvrx.c \
ite_sti.c \
kbd.c kbdconf.c nhpib.c rd.c scsi.c sd.c
.include <bsd.own.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: ite.c,v 1.16 2011/02/12 05:08:40 tsutsui Exp $ */
/* $NetBSD: ite.c,v 1.17 2014/04/13 15:45:27 tsutsui Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -49,6 +49,8 @@
#include <hp300/stand/common/grfreg.h>
#include <hp300/dev/intioreg.h>
#include <hp300/dev/sgcreg.h>
#include <dev/ic/stireg.h>
#include <hp300/stand/common/device.h>
#include <hp300/stand/common/itevar.h>
@ -60,6 +62,8 @@ static void iteconfig(void);
static void ite_clrtoeol(struct ite_data *, struct itesw *, int, int);
static void itecheckwrap(struct ite_data *, struct itesw *);
#define GID_STI 0x100 /* any value which is not a DIO fb, really */
struct itesw itesw[] = {
{ GID_TOPCAT,
topcat_init, ite_dio_clear, ite_dio_putc8bpp,
@ -104,6 +108,10 @@ struct itesw itesw[] = {
{ GID_A147xVGA,
dumb_init, dumb_clear, dumb_putc,
dumb_cursor, dumb_scroll },
{ GID_STI,
sti_iteinit_sgc, sti_clear, sti_putc,
sti_cursor, sti_scroll },
};
int nitesw = sizeof(itesw) / sizeof(itesw[0]);
@ -118,7 +126,8 @@ int ite_scode[NITE] = { 0 };
static void
iteconfig(void)
{
int dtype, fboff, i;
int dtype, fboff, slotno, i;
uint8_t *va;
struct hp_hw *hw;
struct grfreg *gr;
struct ite_data *ip;
@ -165,6 +174,50 @@ iteconfig(void)
ip->alive = 1;
i++;
}
/*
* Now probe for SGC frame buffers.
*/
switch (machineid) {
case HP_400:
case HP_425:
case HP_433:
break;
default:
return;
}
/* SGC frame buffers can only be STI... */
for (dtype = 0; dtype < __arraycount(itesw); dtype++) {
if (itesw[dtype].ite_hwid == GID_STI)
break;
}
if (dtype == __arraycount(itesw))
return;
for (slotno = 0; slotno < SGC_NSLOTS; slotno++) {
va = (uint8_t *)IIOV(SGC_BASE + (slotno * SGC_DEVSIZE));
/* Check to see if hardware exists. */
if (badaddr(va) != 0)
continue;
/* Check hardware. */
if (va[3] == STI_DEVTYPE1) {
if (i >= NITE)
break;
ip = &ite_data[i];
ip->scode = slotno;
ip->isw = &itesw[dtype];
/* to get CN_MIDPRI */
ip->regbase = (uint8_t *)(INTIOBASE + FB_BASE);
/* ...and do not need an ite_probe() check */
ip->alive = 1;
i++;
/* we only support one SGC frame buffer at the moment */
break;
}
}
}
#ifdef CONSDEBUG

View File

@ -0,0 +1,365 @@
/* $NetBSD: ite_sti.c,v 1.1 2014/04/13 15:45:27 tsutsui Exp $ */
/* $OpenBSD: ite_sti.c,v 1.2 2011/08/18 20:02:58 miod Exp $ */
/*
* Copyright (c) 2006, 2011, Miodrag Vallat
* Copyright (c) 2000-2003 Michael Shalayeff
* All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR OR HIS RELATIVES 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 MIND, 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.
*/
#ifdef ITECONSOLE
#include <sys/param.h>
#include <lib/libsa/stand.h>
#include <hp300/stand/common/samachdep.h>
#include <hp300/stand/common/itevar.h>
#if 0
#include <hp300/dev/dioreg.h>
#endif
#include <hp300/dev/sgcreg.h>
#include <dev/ic/stireg.h>
/*
* sti-specific data not available in the ite_data structure.
* Since we will only configure one sti display, it is ok to use a global.
*/
static struct {
uint32_t codeptr[STI_CODECNT];
uint8_t *code;
uint32_t fontbase;
u_int firstchar, lastchar;
struct sti_cfg cfg;
struct sti_ecfg ecfg;
} sti;
#define parseshort1(addr, ofs) \
(((addr)[(ofs) + 3] << 8) | ((addr)[(ofs) + 7]))
#define parseword1(addr, ofs) \
(((addr)[(ofs) + 3] << 24) | ((addr)[(ofs) + 7] << 16) | \
((addr)[(ofs) + 11] << 8) | ((addr)[(ofs) + 15]))
void sti_do_cursor(struct ite_data *);
void sti_fontinfo(struct ite_data *);
void sti_init(int);
void sti_inqcfg(struct sti_inqconfout *);
void sti_iteinit_common(struct ite_data *);
#if 0 /* not yet */
/* kinda similar to sti_dio_probe() */
int
sti_dio_probe(struct ite_data *ip)
{
int scode = ip->scode;
uint8_t *id_reg;
id_reg = (uint8_t *)sctoaddr(scode);
if (id_reg[DIOII_SIZEOFF] < STI_DIO_SIZE - 1)
return ENODEV;
id_reg = (uint8_t *)sctoaddr(scode + STI_DIO_SCODE_OFFSET);
if (id_reg[3] != STI_DEVTYPE1)
return ENODEV;
return 0;
}
void
sti_iteinit_dio(struct ite_data *ip)
{
ip->fbbase = (caddr_t)sctoaddr(ip->scode + STI_DIO_SCODE_OFFSET);
sti_iteinit_common(ip);
}
#endif
void
sti_iteinit_sgc(struct ite_data *ip)
{
ip->fbbase = (uint8_t *)IIOV(SGC_BASE + (ip->scode * SGC_DEVSIZE));
sti_iteinit_common(ip);
}
/*
* Initialize the sti device for ite's needs.
* We don't bother to check for failures since
* - we are in tight space already
* - since romputchar() does not work with sti devices, there is no way we
* can report errors (although we could switch to serial...)
*/
void
sti_iteinit_common(struct ite_data *ip)
{
int i;
size_t codesize, memsize;
uint8_t *va, *code;
u_int addr, eaddr, reglist, tmp;
struct sti_inqconfout cfg;
struct sti_einqconfout ecfg;
memset(&sti, 0, sizeof sti);
va = (uint8_t *)ip->fbbase;
/*
* Read the microcode.
*/
for (i = 0; i < STI_CODECNT; i++)
sti.codeptr[i] =
parseword1(va, (STI_CODEBASE_M68K << 2) + i * 0x10);
for (i = STI_END; sti.codeptr[i] == 0; i--)
continue;
codesize = sti.codeptr[i] - sti.codeptr[STI_BEGIN];
codesize = (codesize + 3) / 4;
sti.code = (uint8_t *)alloc(codesize);
code = sti.code;
addr = (u_int)va + sti.codeptr[STI_BEGIN];
eaddr = addr + codesize * 4;
for (; addr < eaddr; addr += 4)
*code++ = *(uint8_t *)addr;
for (i = STI_CODECNT - 1; i != 0; i--)
if (sti.codeptr[i] != 0) {
sti.codeptr[i] -= sti.codeptr[0];
sti.codeptr[i] /= 4;
}
sti.codeptr[0] = 0;
for (i = STI_END; sti.codeptr[i] == 0; i--);
sti.codeptr[i] = 0;
/*
* Read the regions list.
*/
reglist = parseword1(va, 0x60);
for (i = 0; i < STI_REGION_MAX; i++) {
tmp = parseword1(va, (reglist & ~3) + i * 0x10);
sti.cfg.regions[i] = (u_int)va + ((tmp >> 18) << 12);
if (tmp & 0x4000)
break;
}
/*
* Allocate scratch memory for the microcode if it needs it.
*/
sti.cfg.ext_cfg = &sti.ecfg;
memsize = parseword1(va, 0xa0);
if (memsize != 0)
sti.ecfg.addr = alloc(memsize);
/*
* Initialize the display, and get geometry information.
*/
sti_init(0);
memset(&cfg, 0, sizeof cfg);
memset(&ecfg, 0, sizeof ecfg);
cfg.ext = &ecfg;
sti_inqcfg(&cfg);
if (cfg.owidth == cfg.width && cfg.oheight == cfg.height) {
sti.cfg.oscr_width = cfg.owidth = cfg.fbwidth - cfg.width;
sti.cfg.oscr_height = cfg.oheight = cfg.fbheight - cfg.height;
}
ip->dheight = cfg.height;
ip->dwidth = cfg.width;
ip->fbheight = cfg.fbheight;
ip->fbwidth = cfg.fbwidth;
/*
* Get ready for ite operation!
*/
sti_init(1);
sti_fontinfo(ip);
sti_clear(ip, 0, 0, ip->rows, ip->cols); /* necessary? */
}
void
sti_putc(struct ite_data *ip, int c, int dy, int dx)
{
sti_unpmv_t unpmv;
struct {
struct sti_unpmvflags flags;
struct sti_unpmvin in;
struct sti_unpmvout out;
} a;
memset(&a, 0, sizeof a);
a.flags.flags = STI_UNPMVF_WAIT;
a.in.bg_colour = STI_COLOUR_BLACK;
a.in.fg_colour = STI_COLOUR_WHITE;
a.in.x = dx * ip->ftwidth;
a.in.y = dy * ip->ftheight;
a.in.font_addr = (uint32_t *)((uint8_t *)ip->fbbase + sti.fontbase);
a.in.index = c;
unpmv = (sti_unpmv_t)(sti.code + sti.codeptr[STI_FONT_UNPMV]);
(*unpmv)(&a.flags, &a.in, &a.out, &sti.cfg);
}
void
sti_cursor(struct ite_data *ip, int flag)
{
switch (flag) {
case MOVE_CURSOR:
sti_do_cursor(ip);
/* FALLTHROUGH */
case DRAW_CURSOR:
ip->cursorx = ip->curx;
ip->cursory = ip->cury;
/* FALLTHROUGH */
default:
sti_do_cursor(ip);
break;
}
}
void
sti_do_cursor(struct ite_data *ip)
{
sti_blkmv_t blkmv;
struct {
struct sti_blkmvflags flags;
struct sti_blkmvin in;
struct sti_blkmvout out;
} a;
memset(&a, 0, sizeof a);
a.flags.flags = STI_BLKMVF_WAIT | STI_BLKMVF_COLR;
a.in.fg_colour = STI_COLOUR_BLACK;
a.in.bg_colour = STI_COLOUR_WHITE;
a.in.dstx = a.in.srcx = ip->cursorx * ip->ftwidth;
a.in.dsty = a.in.srcy = ip->cursory * ip->ftheight;
a.in.width = ip->ftwidth;
a.in.height = ip->ftheight;
blkmv = (sti_blkmv_t)(sti.code + sti.codeptr[STI_BLOCK_MOVE]);
(*blkmv)(&a.flags, &a.in, &a.out, &sti.cfg);
}
void
sti_clear(struct ite_data *ip, int sy, int sx, int h, int w)
{
sti_blkmv_t blkmv;
struct {
struct sti_blkmvflags flags;
struct sti_blkmvin in;
struct sti_blkmvout out;
} a;
memset(&a, 0, sizeof a);
a.flags.flags = STI_BLKMVF_WAIT | STI_BLKMVF_CLR;
a.in.bg_colour = STI_COLOUR_BLACK;
a.in.dstx = a.in.srcx = sx * ip->ftwidth;
a.in.dsty = a.in.srcy = sy * ip->ftheight;
a.in.width = w * ip->ftwidth;
a.in.height = h * ip->ftheight;
blkmv = (sti_blkmv_t)(sti.code + sti.codeptr[STI_BLOCK_MOVE]);
(*blkmv)(&a.flags, &a.in, &a.out, &sti.cfg);
}
void
sti_scroll(struct ite_data *ip)
{
sti_blkmv_t blkmv;
struct {
struct sti_blkmvflags flags;
struct sti_blkmvin in;
struct sti_blkmvout out;
} a;
memset(&a, 0, sizeof a);
a.flags.flags = STI_BLKMVF_WAIT;
a.in.bg_colour = STI_COLOUR_BLACK;
a.in.fg_colour = STI_COLOUR_WHITE;
a.in.dstx = a.in.srcx = 0;
a.in.dsty = 0;
a.in.srcy = ip->ftheight;
a.in.width = ip->dwidth;
a.in.height = (ip->rows - 1) * ip->ftheight;
blkmv = (sti_blkmv_t)(sti.code + sti.codeptr[STI_BLOCK_MOVE]);
(*blkmv)(&a.flags, &a.in, &a.out, &sti.cfg);
}
void
sti_fontinfo(struct ite_data *ip)
{
uint32_t fontbase;
volatile uint8_t *fbbase = ip->fbbase;
fontbase = sti.fontbase = parseword1(fbbase, 0x30) & ~3;
ip->ftwidth = (uint8_t)fbbase[fontbase + 0x13];
ip->ftheight = (uint8_t)fbbase[fontbase + 0x17];
ip->rows = ip->dheight / ip->ftheight;
ip->cols = ip->dwidth / ip->ftwidth;
}
void
sti_init(int full)
{
sti_init_t init;
struct {
struct sti_initflags flags;
struct sti_initin in;
struct sti_initout out;
} a;
memset(&a, 0, sizeof a);
a.flags.flags = STI_INITF_WAIT | STI_INITF_CMB | STI_INITF_EBET;
if (full)
a.flags.flags |= STI_INITF_TEXT | STI_INITF_PBET |
STI_INITF_PBETI | STI_INITF_ICMT;
a.in.text_planes = 1;
init = (sti_init_t)(sti.code + sti.codeptr[STI_INIT_GRAPH]);
(*init)(&a.flags, &a.in, &a.out, &sti.cfg);
}
void
sti_inqcfg(struct sti_inqconfout *ico)
{
sti_inqconf_t inqconf;
struct {
struct sti_inqconfflags flags;
struct sti_inqconfin in;
} a;
memset(&a, 0, sizeof a);
a.flags.flags = STI_INQCONFF_WAIT;
inqconf = (sti_inqconf_t)(sti.code + sti.codeptr[STI_INQ_CONF]);
(*inqconf)(&a.flags, &a.in, ico, &sti.cfg);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: itevar.h,v 1.15 2011/02/12 05:08:41 tsutsui Exp $ */
/* $NetBSD: itevar.h,v 1.16 2014/04/13 15:45:27 tsutsui Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -55,6 +55,7 @@ typedef void (*ite_windowmover)(struct ite_data *, int, int, int, int, int,
struct ite_data {
int alive;
int scode; /* DIO selectcode or SGC slot # */
struct itesw *isw;
void *regbase, *fbbase;
short curx, cury;
@ -139,6 +140,13 @@ void rbox_init(struct ite_data *);
void dvbox_init(struct ite_data *);
void hyper_init(struct ite_data *);
void tvrx_init(struct ite_data *);
void sti_iteinit_sgc(struct ite_data *);
void sti_cursor(struct ite_data *, int);
void sti_putc(struct ite_data *, int, int, int);
void sti_clear(struct ite_data *, int, int, int, int);
void sti_scroll(struct ite_data *);
void dumb_init(struct ite_data *);
void dumb_cursor(struct ite_data *, int);
void dumb_putc(struct ite_data *, int, int, int);