Import STI wscons(4) driver from OpenBSD and add new driver for PS/2

keyboard / mouse pots of LASI.
This commit is contained in:
jkunz 2004-08-26 16:48:06 +00:00
parent 318777e22f
commit 1035c6af08
13 changed files with 2094 additions and 126 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.29 2004/07/29 19:10:23 jkunz Exp $
# $NetBSD: GENERIC,v 1.30 2004/08/26 16:48:06 jkunz Exp $
#
# GENERIC machine description file
#
@ -23,7 +23,7 @@ include "arch/hp700/conf/std.hp700"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
options SYSCTL_INCLUDE_DESCR # Include sysctl descriptions in kernel
#ident "GENERIC-$Revision: 1.29 $"
#ident "GENERIC-$Revision: 1.30 $"
maxusers 32 # estimated number of users
@ -163,12 +163,21 @@ options NFS_BOOT_DHCP,NFS_BOOT_BOOTPARAM
# wscons options
#
# builtin terminal emulations
options WSEMUL_DUMB
#options WSEMUL_SUN # sun terminal emulation
options WSEMUL_VT100 # VT100 / VT220 emulation
# different kernel output - see dev/wscons/wsdisplayvar.h
# customization of console and kernel output - see dev/wscons/wsdisplayvar.h
options WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8)
#options WS_DEFAULT_FG=WSCOL_WHITE
#options WS_DEFAULT_BG=WSCOL_BLACK
#options WS_DEFAULT_COLATTR=""
#options WS_DEFAULT_MONOATTR=""
options WS_KERNEL_FG=WSCOL_GREEN
#options WS_KERNEL_BG=WSCOL_BLACK
#options WS_KERNEL_COLATTR=""
#options WS_KERNEL_MONOATTR=""
# customization of console border color
options WSDISPLAY_CUSTOM_BORDER # border customization from wsconsctl(8)
#options WSDISPLAY_BORDER_COLOR=WSCOL_BLUE # default color
# compatibility to other console drivers
options WSDISPLAY_COMPAT_PCVT # emulate some ioctls
options WSDISPLAY_COMPAT_SYSCONS # emulate some ioctls
@ -182,6 +191,16 @@ options WSDISPLAY_COMPAT_RAWKBD # can get raw scancodes
options PCDISPLAY_SOFTCURSOR
# modify the screen type of the console; defaults to "80x25"
#options VGA_CONSOLE_SCREENTYPE="\"80x24\""
# work around a hardware bug that loaded fonts don't work; found on ATI cards
#options VGA_CONSOLE_ATI_BROKEN_FONTSEL
# the following enables some functions to get mouse console support.
# if you want a really secure system, it may be better not to enable them,
# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
#options WSDISPLAY_CHARFUNCS # mouse console support
# console scrolling support.
#options WSDISPLAY_SCROLLSUPPORT
# enable VGA raster mode capable of displaying multilingual text on console
#options VGA_RASTERCONSOLE
# Kernel root file system and dump configuration.
config netbsd root on ? type ?
@ -253,17 +272,14 @@ eisa* at mongoose?
#hms* at hil? code 1 # mice & trackballs
# wscons
#pckbc* at gsc? # pc keyboard controller
#pckbd* at pckbc? # PC keyboard
#pms* at pckbc? # PS/2 mouse for wsmouse
#vga* at pci? dev ? function ?
#wsdisplay* at sti?
#wsdisplay* at vga? console ?
#wsdisplay* at pcdisplay? console ?
#wskbd* at pckbd? console ?
gsckbc* at gsc? # pc keyboard controller
pckbd* at gsckbc? # PC keyboard
pms* at gsckbc? # PS/2 mouse for wsmouse
wskbd* at pckbd? console ?
wsmouse* at pms? mux 0
#wskbd* at hkbd? console ?
#wsmouse* at pms? mux 0
#wsmouse* at hms? mux 0
wsdisplay* at sti?
# Serial Devices

View File

@ -1,4 +1,4 @@
# $NetBSD: files.hp700,v 1.11 2004/07/29 19:10:23 jkunz Exp $
# $NetBSD: files.hp700,v 1.12 2004/08/26 16:48:06 jkunz Exp $
#
# $OpenBSD: files.hp700,v 1.31 2001/06/26 02:41:25 mickey Exp $
#
@ -19,6 +19,7 @@ include "dev/wscons/files.wscons"
include "dev/wsfont/files.wsfont"
include "dev/pckbport/files.pckbport"
#
# Machine-independent SCSI drivers
#
@ -125,9 +126,9 @@ file arch/hp700/dev/dino.c dino
attach com at dino with com_dino
file arch/hp700/dev/com_dino.c com_dino
device sti: wsemuldisplaydev
attach sti at mainbus with sti_sgc
file arch/hp700/dev/sti_sgc.c sti_sgc
attach sti at phantomas with sti_phantomas
file arch/hp700/dev/sti_sgc.c sti_sgc | sti_phantomas
###
@ -180,8 +181,9 @@ device hil: tty
attach hil at gsc
file arch/hp700/gsc/hil.c hil
attach pckbc at gsc with pckbc_gsc
file arch/hp700/gsc/pckbc_gsc.c pckbc_gsc
device gsckbc: pckbport
attach gsckbc at gsc
file arch/hp700/gsc/gsckbc.c gsckbc
# PSB 2160-N based 8bit mono audio (705, 710, 745i/*, 747i/*)
device aone: audiobus, mulaw, auconv

View File

@ -1,9 +1,9 @@
/* $NetBSD: sti_sgc.c,v 1.6 2003/11/23 17:09:29 chs Exp $ */
/* $NetBSD: sti_sgc.c,v 1.7 2004/08/26 16:48:06 jkunz Exp $ */
/* $OpenBSD: sti_sgc.c,v 1.6 2001/09/11 20:05:24 miod Exp $ */
/* $OpenBSD: sti_sgc.c,v 1.21 2003/12/22 23:39:06 mickey Exp $ */
/*
* Copyright (c) 2000 Michael Shalayeff
* Copyright (c) 2000-2003 Michael Shalayeff
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sti_sgc.c,v 1.6 2003/11/23 17:09:29 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: sti_sgc.c,v 1.7 2004/08/26 16:48:06 jkunz Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -58,99 +58,161 @@ __KERNEL_RCSID(0, "$NetBSD: sti_sgc.c,v 1.6 2003/11/23 17:09:29 chs Exp $");
#include <dev/ic/stireg.h>
#include <dev/ic/stivar.h>
#include <hp700/hp700/machdep.h>
#include <hp700/dev/cpudevs.h>
#include <hp700/hp700/machdep.h>
#define STI_MEMSIZE 0x1000000
#define STI_ROMSIZE 0x0004000
#define STI_ROMSIZE (sizeof(struct sti_dd) * 4)
#define STI_ID_FDDI 0x280b31af /* Medusa FDDI ROM id */
/* gecko optional graphics */
#define STI_GOPT1_REV 0x17
#define STI_GOPT2_REV 0x70
/* internal EG */
#define STI_INEG_REV 0x60
#define STI_INEG_PROM 0xf0011000
int sti_sgc_probe(struct device *, struct cfdata *, void *);
void sti_sgc_attach(struct device *, struct device *, void *);
CFATTACH_DECL(sti_sgc, sizeof(struct sti_softc),
sti_sgc_probe, sti_sgc_attach, NULL, NULL);
CFATTACH_DECL(sti_sgc, sizeof(struct sti_softc), sti_sgc_probe, sti_sgc_attach,
NULL, NULL);
int
sti_sgc_probe(struct device *parent, struct cfdata *match, void *aux)
{
struct confargs *ca = aux;
bus_space_handle_t ioh, romh;
u_int rom;
u_char devtype;
int rv = 0, romh_is_subregion;
int pagezero_cookie;
CFATTACH_DECL(sti_phantomas, sizeof(struct sti_softc), sti_sgc_probe,
sti_sgc_attach, NULL, NULL);
if (ca->ca_type.iodc_type != HPPA_TYPE_FIO ||
(ca->ca_type.iodc_sv_model != HPPA_FIO_GSGC &&
ca->ca_type.iodc_sv_model != HPPA_FIO_SGC))
return 0;
if ((rv = bus_space_map(ca->ca_iot, ca->ca_hpa, STI_MEMSIZE, 0, &ioh))) {
#ifdef STIDEBUG
printf("st: cannot map io space (%d)\n", rv);
#endif
return 0;
}
paddr_t sti_sgc_getrom(int, struct confargs *);
/*
/*
* Locate STI ROM.
* On some machines it may not be part of the HPA space.
*/
pagezero_cookie = hp700_pagezero_map();
if (PAGE0->pd_resv2[1] < HPPA_IOBEGIN) {
rom = ca->ca_hpa;
} else
rom = PAGE0->pd_resv2[1];
hp700_pagezero_unmap(pagezero_cookie);
paddr_t
sti_sgc_getrom(int unit, struct confargs *ca)
{
paddr_t rom;
int pagezero_cookie;
pagezero_cookie = hp700_pagezero_map();
rom = PAGE0->pd_resv2[1];
if (unit) {
if (ca->ca_type.iodc_sv_model == HPPA_FIO_GSGC &&
(ca->ca_type.iodc_revision == STI_GOPT1_REV ||
ca->ca_type.iodc_revision == STI_GOPT2_REV))
/* these two share the onboard's prom */ ;
else
rom = 0;
}
if (rom < HPPA_IOBEGIN) {
if (unit == 0 &&
ca->ca_type.iodc_sv_model == HPPA_FIO_GSGC &&
ca->ca_type.iodc_revision == STI_INEG_REV)
rom = STI_INEG_PROM;
else
rom = ca->ca_hpa;
}
hp700_pagezero_unmap(pagezero_cookie);
return (rom);
}
int
sti_sgc_probe(struct device *parent, struct cfdata *cf, void *aux)
{
struct confargs *ca = aux;
bus_space_handle_t romh;
paddr_t rom;
u_int32_t id, romend;
u_char devtype;
int rv = 0, romunmapped = 0;
if (ca->ca_type.iodc_type != HPPA_TYPE_FIO)
return (0);
/* these need futher checking for the graphics id */
if (ca->ca_type.iodc_sv_model != HPPA_FIO_GSGC &&
ca->ca_type.iodc_sv_model != HPPA_FIO_SGC)
return 0;
rom = sti_sgc_getrom(cf->cf_unit, ca);
#ifdef STIDEBUG
printf ("sti: hpa=%x, rom=%x\n", ca->ca_hpa, rom);
printf ("sti: hpa=%x, rom=%x\n", (uint)ca->ca_hpa, (uint)rom);
#endif
/*
* Map the ROM.
*/
if (ca->ca_hpa <= rom &&
(rom + STI_ROMSIZE) <= (ca->ca_hpa + STI_MEMSIZE)) {
romh_is_subregion = TRUE;
rv = bus_space_subregion(ca->ca_iot, ioh,
rom - ca->ca_hpa, STI_ROMSIZE, &romh);
} else {
romh_is_subregion = FALSE;
rv = bus_space_map(ca->ca_iot, rom, STI_ROMSIZE, 0, &romh);
}
if (rv) {
/* if it does not map, probably part of the lasi space */
if ((rv = bus_space_map(ca->ca_iot, rom, STI_ROMSIZE, 0, &romh))) {
#ifdef STIDEBUG
printf ("sti: cannot map rom space (%d)\n", rv);
#endif
bus_space_unmap(ca->ca_iot, ioh, STI_MEMSIZE);
if ((rom & HPPA_IOBEGIN) == HPPA_IOBEGIN) {
romh = rom;
romunmapped++;
} else {
/* in this case nobody has no freaking idea */
return 0;
}
#ifdef STIDEBUG
printf("sti: ioh=%x, romh=%x\n", ioh, romh);
#endif
}
devtype = bus_space_read_1(ca->ca_iot, romh, 3);
#ifdef STIDEBUG
printf("sti: devtype=%d\n", devtype);
#endif
#if 0 /* ignore this for now */
if ((ca->ca_type.iodc_sv_model == HPPA_FIO_SGC &&
STI_ID_HI(STI_TYPE_BWGRF, rioh) == STI_ID_FDDI) ||
(devtype != STI_TYPE_BWGRF && devtype != STI_TYPE_WWGRF)) {
#ifdef STIDEBUG
printf("sti: not a graphics device (%x)\n", devtype);
#endif
} else
#endif
rv = 1;
switch (devtype) {
case STI_DEVTYPE4:
id = bus_space_read_4(ca->ca_iot, romh, STI_DEV4_DD_GRID);
romend = bus_space_read_4(ca->ca_iot, romh, STI_DEV4_DD_ROMEND);
break;
case STI_DEVTYPE1:
id = (bus_space_read_1(ca->ca_iot, romh, STI_DEV1_DD_GRID
+ 3) << 24) |
(bus_space_read_1(ca->ca_iot, romh, STI_DEV1_DD_GRID
+ 7) << 16) |
(bus_space_read_1(ca->ca_iot, romh, STI_DEV1_DD_GRID
+ 11) << 8) |
(bus_space_read_1(ca->ca_iot, romh, STI_DEV1_DD_GRID
+ 15));
romend = (bus_space_read_1(ca->ca_iot, romh, STI_DEV1_DD_ROMEND
+ 3) << 24) |
(bus_space_read_1(ca->ca_iot, romh, STI_DEV1_DD_ROMEND
+ 7) << 16) |
(bus_space_read_1(ca->ca_iot, romh, STI_DEV1_DD_ROMEND
+ 11) << 8) |
(bus_space_read_1(ca->ca_iot, romh, STI_DEV1_DD_ROMEND
+ 15));
break;
default:
#ifdef STIDEBUG
printf("sti: unknown type (%x)\n", devtype);
#endif
rv = 0;
}
bus_space_unmap(ca->ca_iot, ioh, STI_MEMSIZE);
if (!romh_is_subregion)
if (rv &&
ca->ca_type.iodc_sv_model == HPPA_FIO_SGC && id == STI_ID_FDDI) {
#ifdef STIDEBUG
printf("sti: not a graphics device\n");
#endif
rv = 0;
}
if (ca->ca_naddrs >= sizeof(ca->ca_addrs) / sizeof(ca->ca_addrs[0])) {
printf("sti: address list overflow\n");
return (0);
}
ca->ca_addrs[ca->ca_naddrs].addr = rom;
ca->ca_addrs[ca->ca_naddrs].size = round_page(romend);
ca->ca_naddrs++;
if (!romunmapped)
bus_space_unmap(ca->ca_iot, romh, STI_ROMSIZE);
return rv;
return (rv);
}
void
@ -158,50 +220,42 @@ sti_sgc_attach(struct device *parent, struct device *self, void *aux)
{
struct sti_softc *sc = (void *)self;
struct confargs *ca = aux;
bus_addr_t addr;
paddr_t rom;
u_int32_t romlen;
int rv;
int pagezero_cookie;
pagezero_cookie = hp700_pagezero_map();
if (PAGE0->pd_resv2[1] < HPPA_IOBEGIN)
addr = ca->ca_hpa;
else
addr = PAGE0->pd_resv2[1];
hp700_pagezero_unmap(pagezero_cookie);
sc->memt = sc->iot = ca->ca_iot;
sc->base = ca->ca_hpa;
if ((rv = bus_space_map(ca->ca_iot, ca->ca_hpa, STI_MEMSIZE, 0,
&sc->ioh))) {
#ifdef STIDEBUG
printf("st: cannot map io space (%d)\n", rv);
#endif
/* we stashed rom addr/len into the last slot during probe */
rom = ca->ca_addrs[ca->ca_naddrs - 1].addr;
romlen = ca->ca_addrs[ca->ca_naddrs - 1].size;
if ((rv = bus_space_map(ca->ca_iot, rom, romlen, 0, &sc->romh))) {
if ((rom & HPPA_IOBEGIN) == HPPA_IOBEGIN)
sc->romh = rom;
else {
printf (": cannot map rom space (%d)\n", rv);
return;
}
}
#ifdef HP7300LC_CPU
/*
* Map the ROM.
* PCXL2: enable accel I/O for this space, see PCX-L2 ERS "ACCEL_IO".
* "pcxl2_ers.{ps,pdf}", (section / chapter . rel. page / abs. page)
* 8.7.4 / 8-12 / 92, 11.3.14 / 11-14 / 122 and 14.8 / 14-5 / 203.
*/
if (ca->ca_hpa <= addr &&
(addr + STI_ROMSIZE) <= (ca->ca_hpa + STI_MEMSIZE)) {
rv = bus_space_subregion(ca->ca_iot, sc->ioh,
addr - ca->ca_hpa, STI_ROMSIZE, &sc->romh);
} else {
rv = bus_space_map(ca->ca_iot, addr, STI_ROMSIZE, 0, &sc->romh);
}
if (rv) {
#ifdef STIDEBUG
printf ("sti: cannot map rom space (%d)\n", rv);
#endif
bus_space_unmap(ca->ca_iot, sc->ioh, STI_MEMSIZE);
return;
}
if (strcmp(hppa_cpu_info->hppa_cpu_info_chip_type, "PCX-L2") == 0
&& ca->ca_hpa >= PCXL2_ACCEL_IO_START
&& ca->ca_hpa <= PCXL2_ACCEL_IO_END)
eaio_l2(PCXL2_ACCEL_IO_ADDR2MASK(ca->ca_hpa));
#endif /* HP7300LC_CPU */
sc->sc_devtype = bus_space_read_1(sc->iot, sc->romh, 3);
#ifdef STIDEBUG
printf("sti: hpa=%x, rom=%x\n", ca->ca_hpa, addr);
printf("sti: ioh=%x, romh=%x\n", sc->ioh, sc->romh);
#endif
if (ca->ca_hpa == (hppa_hpa_t)PAGE0->mem_cons.pz_hpa)
sc->sc_flags |= STI_CONSOLE;
hp700_pagezero_unmap(pagezero_cookie);
sti_attach_common(sc);
}

314
sys/arch/hp700/gsc/gsckbc.c Normal file
View File

@ -0,0 +1,314 @@
/* $NetBSD: gsckbc.c,v 1.1 2004/08/26 16:48:06 jkunz Exp $ */
/*
* Copyright (c) 2004 Jochen Kunz.
* 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.
* 3. The name of Jochen Kunz may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY JOCHEN KUNZ
* ``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 JOCHEN KUNZ
* 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.
*/
/*
* hp700 GSC bus MD pckbport(9) frontend for the PS/2 ports found in LASI chips.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: gsckbc.c,v 1.1 2004/08/26 16:48:06 jkunz Exp $");
/* autoconfig and device stuff */
#include <sys/param.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <machine/iomod.h>
#include <machine/autoconf.h>
#include <hp700/dev/cpudevs.h>
#include <hp700/gsc/gscbusvar.h>
#include <hp700/hp700/machdep.h>
#include "locators.h"
#include "ioconf.h"
/* bus_space / bus_dma etc. */
#include <machine/bus.h>
#include <machine/intr.h>
/* general system data and functions */
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/ioccom.h>
#include <sys/types.h>
/* pckbport interface */
#include <dev/pckbport/pckbportvar.h>
/* register offsets */
#define REG_ID 0x0 /* R: ID register */
#define REG_RESET 0x0 /* W: reset port */
#define REG_RCVDATA 0x4 /* R: received data (4 byte FIFO) */
#define REG_XMITDATA 0x4 /* W: data to transmit */
#define REG_CONTROL 0x8 /* Controll Bits */
#define REG_STATUS 0xc /* Status Bits */
#define REG_SZ 0xc /* Size of register set */
#define REG_OFFSET 0x100 /* Address Offset of the two ports */
/* ID values for REG_ID */
#define ID_KBD 0 /* keyboard port */
#define ID_AUX 1 /* mouse / aux port */
/* Control Register Bits (R/W) */
#define CTRL_ENBL 0x01 /* Enable */
#define CTRL_LPBXR 0x02 /* Loopback Xmt/Rcv mode */
#define CTRL_DIAG 0x20 /* Diagnostic mode */
#define CTRL_DATDIR 0x40 /* External data line direct control */
#define CTRL_CLKDIR 0x80 /* External clock line direct control */
/* Status Register Bits (RO) */
#define STAT_RBNE 0x01 /* Receive buffer not empty */
#define STAT_TBNE 0x02 /* Transmit buffer not empty */
#define STAT_TERR 0x04 /* Timeout Error */
#define STAT_PERR 0x08 /* Parity Error */
#define STAT_CMPINTR 0x10 /* Composite interrupt */
#define STAT_DATSHD 0x40 /* Data line shadow */
#define STAT_CLKSHD 0x80 /* Clock line shadow */
/* autoconfig stuff */
static int gsckbc_match(struct device *, struct cfdata *, void *);
static void gsckbc_attach(struct device *, struct device *, void *);
static int gsckbc_xt_translation(void *, pckbport_slot_t, int);
static int gsckbc_send_devcmd(void *, pckbport_slot_t, u_char);
static int gsckbc_poll_data1(void *, pckbport_slot_t);
static void gsckbc_slot_enable(void *, pckbport_slot_t, int);
static void gsckbc_intr_establish(void *, pckbport_slot_t);
static void gsckbc_set_poll(void *, pckbport_slot_t, int);
static int gsckbc_intr(void *);
struct gsckbc_softc {
struct device sc_dev; /* general dev info */
bus_space_tag_t sc_iot; /* bus_space(9) tag */
bus_space_handle_t sc_ioh; /* bus_space(9) handle */
struct gsckbc_softc *sc_op; /* other port */
void *sc_ih; /* interrupt handle */
pckbport_slot_t sc_slot; /* kbd or mouse / aux slot */
pckbport_tag_t sc_pckbport; /* port tag */
struct device *sc_child; /* our child devices */
int sc_poll; /* if != 0 then pooling mode */
int sc_enable; /* if != 0 then enable */
};
CFATTACH_DECL(gsckbc, sizeof(struct gsckbc_softc), gsckbc_match, gsckbc_attach,
NULL, NULL);
const struct pckbport_accessops gsckbc_accessops = {
gsckbc_xt_translation,
gsckbc_send_devcmd,
gsckbc_poll_data1,
gsckbc_slot_enable,
gsckbc_intr_establish,
gsckbc_set_poll
};
static int
gsckbc_xt_translation(void *cookie, pckbport_slot_t slot, int on)
{
return 0;
}
static int
gsckbc_send_devcmd(void *cookie, pckbport_slot_t slot, u_char byte)
{
struct gsckbc_softc *sc = (struct gsckbc_softc *) cookie;
if ((bus_space_read_1(sc->sc_iot, sc->sc_ioh, REG_STATUS) & STAT_TBNE)
!= 0)
DELAY(100);
if ((bus_space_read_1(sc->sc_iot, sc->sc_ioh, REG_STATUS) & STAT_TBNE)
!= 0)
return 0;
bus_space_write_1(sc->sc_iot, sc->sc_ioh, REG_XMITDATA, byte);
return 1;
}
static int
gsckbc_poll_data1(void *cookie, pckbport_slot_t slot)
{
struct gsckbc_softc *sc = (struct gsckbc_softc *) cookie;
int i;
for (i = 0; i < 1000; i++) {
if ((bus_space_read_1(sc->sc_iot, sc->sc_ioh, REG_STATUS) &
STAT_RBNE) != 0 || sc->sc_poll == 0) {
return bus_space_read_1(sc->sc_iot, sc->sc_ioh,
REG_RCVDATA);
}
DELAY(100);
}
return -1;
}
static void
gsckbc_slot_enable(void *cookie, pckbport_slot_t slot, int on)
{
struct gsckbc_softc *sc = (struct gsckbc_softc *) cookie;
sc->sc_enable = on;
}
static void
gsckbc_intr_establish(void *cookie, pckbport_slot_t slot)
{
return;
}
static void
gsckbc_set_poll(void *cookie, pckbport_slot_t slot, int on)
{
struct gsckbc_softc *sc = (struct gsckbc_softc *) cookie;
sc->sc_poll = on;
}
static int
gsckbc_intr(void *arg)
{
struct gsckbc_softc *sc = (struct gsckbc_softc *) arg;
int data;
while ((bus_space_read_1(sc->sc_iot, sc->sc_ioh, REG_STATUS)
& STAT_RBNE) != 0 && sc->sc_poll == 0) {
data = bus_space_read_1(sc->sc_iot, sc->sc_ioh, REG_RCVDATA);
if (sc->sc_enable != 0)
pckbportintr(sc->sc_pckbport, sc->sc_slot, data);
}
while ((bus_space_read_1(sc->sc_op->sc_iot, sc->sc_op->sc_ioh,
REG_STATUS) & STAT_RBNE) != 0 && sc->sc_op->sc_poll == 0) {
data = bus_space_read_1(sc->sc_op->sc_iot, sc->sc_op->sc_ioh,
REG_RCVDATA);
if (sc->sc_op->sc_enable != 0)
pckbportintr(sc->sc_op->sc_pckbport, sc->sc_op->sc_slot,
data);
}
return 1;
}
static int
gsckbc_match(struct device *parent, struct cfdata *match, void *aux)
{
struct gsc_attach_args *ga = aux;
if (ga->ga_type.iodc_type == HPPA_TYPE_FIO
&& ga->ga_type.iodc_sv_model == HPPA_FIO_GPCIO)
return(1);
return(0);
}
static void
gsckbc_attach(struct device *parent, struct device *self, void *aux)
{
struct gsckbc_softc *sc = (struct gsckbc_softc *) self;
struct gsc_attach_args *ga = aux;
static struct gsckbc_softc *master_sc;
int pagezero_cookie;
int i;
/*
* On hp700 bus_space_map(9) mapes whole pages. (surprise, surprise)
* The registers are within the same page so we can do only a single
* mapping for both devices. Also both devices use the same IRQ.
* Actually you can think of the two PS/2 ports to be a single
* device. The firmware lists them as individual devices in the
* firmware device tree so we keep this illusion to map the firmware
* device tree as close as possible to the kernel device tree.
* So we do one mapping and IRQ for both devices. The first device
* is caled "master", gets the IRQ and the other is the "slave".
*
* Assumption: Master attaches first, gets the IRQ and has lower HPA.
*/
sc->sc_iot = ga->ga_iot;
if (ga->ga_irq >= 0) {
if (bus_space_map(sc->sc_iot, ga->ga_hpa, REG_SZ + REG_OFFSET,
0, &sc->sc_ioh)) {
aprint_normal(": gsckbc_attach: can't map I/O space\n");
return;
}
aprint_debug(" (master)");
sc->sc_ih = hp700_intr_establish(&sc->sc_dev, IPL_TTY,
gsckbc_intr, sc, ga->ga_int_reg, ga->ga_irq);
master_sc = sc;
} else {
if (master_sc == NULL) {
aprint_normal(": can't find master device\n");
return;
}
sc->sc_op = master_sc;
master_sc->sc_op = sc;
sc->sc_ioh = sc->sc_op->sc_ioh + REG_OFFSET;
aprint_debug(" (slave)");
}
/* We start in polling mode. */
sc->sc_poll = 1;
/* Reset port. */
bus_space_write_1(sc->sc_iot, sc->sc_ioh, REG_RESET, 0);
/* Enable port hardware. */
bus_space_write_1(sc->sc_iot, sc->sc_ioh, REG_CONTROL, CTRL_ENBL);
/* Flush RX FIFO. */
for (i = 0; i < 5; i++)
bus_space_read_1(sc->sc_iot, sc->sc_ioh, REG_RCVDATA);
if (bus_space_read_1(sc->sc_iot, sc->sc_ioh, REG_ID) == ID_KBD) {
aprint_normal(": keyboard\n");
sc->sc_slot = PCKBPORT_KBD_SLOT;
pagezero_cookie = hp700_pagezero_map();
if ((hppa_hpa_t)PAGE0->mem_kbd.pz_hpa == ga->ga_hpa) {
if (pckbport_cnattach(sc, &gsckbc_accessops,
sc->sc_slot) != 0)
aprint_normal("Faild to attach console "
"keyboard!\n");
else
sc->sc_enable = 1;
}
hp700_pagezero_unmap(pagezero_cookie);
} else {
aprint_normal(": mouse\n");
sc->sc_slot = PCKBPORT_AUX_SLOT;
}
sc->sc_pckbport = pckbport_attach(sc, &gsckbc_accessops);
if (sc->sc_pckbport != NULL)
sc->sc_child = pckbport_attach_slot(self, sc->sc_pckbport,
sc->sc_slot);
sc->sc_poll = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: types.h,v 1.2 2004/06/15 20:43:41 jkunz Exp $ */
/* $NetBSD: types.h,v 1.3 2004/08/26 16:48:06 jkunz Exp $ */
#ifndef _HP700_TYPES_H_
#define _HP700_TYPES_H_
@ -7,5 +7,6 @@
#define __HAVE_GENERIC_SOFT_INTERRUPTS
#define __HAVE_DEVICE_REGISTER
#define __HAVE_NWSCONS
#endif /* _HP700_TYPES_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: support.S,v 1.3 2004/08/07 21:41:18 chs Exp $ */
/* $NetBSD: support.S,v 1.4 2004/08/26 16:48:06 jkunz Exp $ */
/* $OpenBSD: locore.S,v 1.46 2001/09/20 18:33:03 mickey Exp $ */
@ -233,6 +233,22 @@ fic_none:
sync
EXIT(ficache)
#ifdef HP7300LC_CPU
.section .bss
eaio_l2_mask:
.block 4
.text
LEAF_ENTRY(eaio_l2)
ldil L%eaio_l2_mask, %t2
ldw R%eaio_l2_mask(%t2), %t1
or %t1, %arg0, %t1
MTCPU_C(22, DR0_PCXL2_ACCEL_IO)
nop
nop
bv 0(%rp)
stw %t1, R%eaio_l2_mask(%t2)
EXIT(eaio_l2)
#endif /* HP7300LC_CPU */
LEAF_ENTRY(setjmp)
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpufunc.h,v 1.2 2002/08/19 18:58:29 fredette Exp $ */
/* $NetBSD: cpufunc.h,v 1.3 2004/08/26 16:48:06 jkunz Exp $ */
/* $OpenBSD: cpufunc.h,v 1.17 2000/05/15 17:22:40 mickey Exp $ */
@ -184,6 +184,11 @@ void fcacheall __P((void));
void ptlball __P((void));
hppa_hpa_t cpu_gethpa __P((int n));
#define PCXL2_ACCEL_IO_START 0xf4000000
#define PCXL2_ACCEL_IO_END (0xfc000000 - 1)
#define PCXL2_ACCEL_IO_ADDR2MASK(a) (0x8 >> ((((a) >> 25) - 2) & 3))
void eaio_l2(int);
/*
* These flush or purge the data cache for a item whose total
* size is <= the size of a data cache line, however they don't

View File

@ -1,4 +1,4 @@
/* $NetBSD: reg.h,v 1.2 2004/07/18 23:21:35 chs Exp $ */
/* $NetBSD: reg.h,v 1.3 2004/08/26 16:48:06 jkunz Exp $ */
/* $OpenBSD: reg.h,v 1.7 2000/06/15 17:00:37 mickey Exp $ */
@ -137,6 +137,8 @@
#define DR0_PCXL2_L1DHPMC_DIS 9 /* r/w L1 D-cache hpmc disable */
#define DR0_PCXL2_L2DHPMC 10 /* r/c L1 I-cache error flag */
#define DR0_PCXL2_L2DHPMC_DIS 11 /* r/w L1 I-cache hpmc disable */
#define DR0_PCXL2_SCRATCH 12 /* r/w scratch register */
#define DR0_PCXL2_ACCEL_IO 13 /* /w enable accel IO writes */
#define DR0_PCXL2_STORE0 16 /* r/w scratch space */
#define DR0_PCXL2_PFMASK 17 /* r/w power-fail trap mask */
#define DR0_PCXL2_STORE1 18 /* r/w scratch */
@ -155,6 +157,16 @@
#define DR_ITLB 9
#define DR0_PCXL2_HTLB_ADDR 24 /* page address of the htlb */
#define DR0_PCXL2_HTLB_CFG 25 /* htlb config */
#define DR0_PCXL2_HTLB_P 0 /* r latches power fail signal */
#define DR0_PCXL2_HTLB_MASK 19 /* w 12bit mask of the hash */
#define DR0_PCXL2_HTLB_FP 26 /* r/w 3bit FP delay */
#define DR0_PCXL2_HTLB_I 28 /* r/w disable ITLB htlb lookup */
#define DR0_PCXL2_HTLB_U 29 /* r/w set cr28 only if tag nomatch */
#define DR0_PCXL2_HTLB_N 30 /* r/w set cr28 from w3 or w7 (0) */
#define DR0_PCXL2_HTLB_D 31 /* r/w disable DTLB htlb lookup */
#define DR_ITLB_SIZE_1 24
#define DR_ITLB_SIZE_0 25

View File

@ -1,4 +1,4 @@
# $NetBSD: files,v 1.682 2004/08/26 14:13:46 itohy Exp $
# $NetBSD: files,v 1.683 2004/08/26 16:48:06 jkunz Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@ -894,6 +894,10 @@ device igsfb: wsemuldisplaydev, wsrasteremulops, rasops8
file dev/ic/igsfb.c igsfb needs-flag
file dev/ic/igsfb_subr.c igsfb
# STI (hp graphics)
device sti: wsemuldisplaydev
file dev/ic/sti.c sti & (sti_pci | sti_sgc | sti_phantom)
# Attributes which machine-independent bus support can be attached to.
# These should be defined here, because some of these busses can have
# devices which provide these attributes, and we'd like to avoid hairy

855
sys/dev/ic/sti.c Normal file
View File

@ -0,0 +1,855 @@
/* $NetBSD: sti.c,v 1.1 2004/08/26 16:48:06 jkunz Exp $ */
/* $OpenBSD: sti.c,v 1.35 2003/12/16 06:07:13 mickey Exp $ */
/*
* 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.
*/
/*
* TODO:
* call sti procs asynchronously;
* implement console scroll-back;
* X11 support.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.1 2004/08/26 16:48:06 jkunz Exp $");
#include "wsdisplay.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <uvm/uvm.h>
#include <machine/bus.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsconsio.h>
#include <dev/ic/stireg.h>
#include <dev/ic/stivar.h>
void sti_cursor(void *, int, int, int);
int sti_mapchar(void *, int, u_int *);
void sti_putchar(void *, int, int, u_int, long);
void sti_copycols(void *, int, int, int, int);
void sti_erasecols(void *, int, int, int, long);
void sti_copyrows(void *, int, int, int);
void sti_eraserows(void *, int, int, long);
int sti_alloc_attr(void *, int, int, int, long *);
struct wsdisplay_emulops sti_emulops = {
sti_cursor,
sti_mapchar,
sti_putchar,
sti_copycols,
sti_erasecols,
sti_copyrows,
sti_eraserows,
sti_alloc_attr
};
int sti_ioctl(void *, u_long, caddr_t, int, struct proc *);
paddr_t sti_mmap(void *, off_t, int);
int sti_alloc_screen(void *, const struct wsscreen_descr *,
void **, int *, int *, long *);
void sti_free_screen(void *, void *);
int sti_show_screen(void *, void *, int, void (*cb)(void *, int, int), void *);
int sti_load_font(void *, void *, struct wsdisplay_font *);
const struct wsdisplay_accessops sti_accessops = {
sti_ioctl,
sti_mmap,
sti_alloc_screen,
sti_free_screen,
sti_show_screen,
sti_load_font
};
struct wsscreen_descr sti_default_screen = {
"default", 0, 0,
&sti_emulops,
0, 0,
WSSCREEN_REVERSE | WSSCREEN_UNDERLINE
};
const struct wsscreen_descr *sti_default_scrlist[] = {
&sti_default_screen
};
struct wsscreen_list sti_default_screenlist = {
sizeof(sti_default_scrlist) / sizeof(sti_default_scrlist[0]),
sti_default_scrlist
};
enum sti_bmove_funcs {
bmf_clear, bmf_copy, bmf_invert, bmf_underline
};
int sti_init(struct sti_softc *, int);
int sti_inqcfg(struct sti_softc *, struct sti_inqconfout *);
void sti_bmove(struct sti_softc *, int, int, int, int, int, int,
enum sti_bmove_funcs);
int sti_setcment(struct sti_softc *, u_int, u_char, u_char, u_char);
int sti_fetchfonts(struct sti_softc *, struct sti_inqconfout *, u_int32_t);
void sti_attach_deferred(struct device *);
void
sti_attach_common(struct sti_softc *sc)
{
struct sti_inqconfout cfg;
struct sti_einqconfout ecfg;
bus_space_handle_t fbh;
struct sti_dd *dd;
struct sti_cfg *cc;
int error, size, i;
u_int8_t *p = (u_int8_t *)sc->sc_code;
u_int32_t addr, eaddr;
struct sti_region r;
u_int32_t *q;
dd = &sc->sc_dd;
if (sc->sc_devtype == STI_DEVTYPE1) {
#define parseshort(o) \
((bus_space_read_1(sc->memt, sc->romh, (o) + 3) << 8) | \
(bus_space_read_1(sc->memt, sc->romh, (o) + 7)))
#define parseword(o) \
((bus_space_read_1(sc->memt, sc->romh, (o) + 3) << 24) | \
(bus_space_read_1(sc->memt, sc->romh, (o) + 7) << 16) | \
(bus_space_read_1(sc->memt, sc->romh, (o) + 11) << 8) | \
(bus_space_read_1(sc->memt, sc->romh, (o) + 15)))
dd->dd_type = bus_space_read_1(sc->memt, sc->romh, 0x03);
dd->dd_nmon = bus_space_read_1(sc->memt, sc->romh, 0x07);
dd->dd_grrev = bus_space_read_1(sc->memt, sc->romh, 0x0b);
dd->dd_lrrev = bus_space_read_1(sc->memt, sc->romh, 0x0f);
dd->dd_grid[0] = parseword(0x10);
dd->dd_grid[1] = parseword(0x20);
dd->dd_fntaddr = parseword(0x30) & ~3;
dd->dd_maxst = parseword(0x40);
dd->dd_romend = parseword(0x50) & ~3;
dd->dd_reglst = parseword(0x60) & ~3;
dd->dd_maxreent= parseshort(0x70);
dd->dd_maxtimo = parseshort(0x78);
dd->dd_montbl = parseword(0x80) & ~3;
dd->dd_udaddr = parseword(0x90) & ~3;
dd->dd_stimemreq=parseword(0xa0);
dd->dd_udsize = parseword(0xb0);
dd->dd_pwruse = parseshort(0xc0);
dd->dd_bussup = bus_space_read_1(sc->memt, sc->romh, 0xcb);
dd->dd_ebussup = bus_space_read_1(sc->memt, sc->romh, 0xcf);
dd->dd_altcodet= bus_space_read_1(sc->memt, sc->romh, 0xd3);
dd->dd_eddst[0]= bus_space_read_1(sc->memt, sc->romh, 0xd7);
dd->dd_eddst[1]= bus_space_read_1(sc->memt, sc->romh, 0xdb);
dd->dd_eddst[2]= bus_space_read_1(sc->memt, sc->romh, 0xdf);
dd->dd_cfbaddr = parseword(0xe0) & ~3;
dd->dd_pacode[0x0] = parseword(0x100) & ~3;
dd->dd_pacode[0x1] = parseword(0x110) & ~3;
dd->dd_pacode[0x2] = parseword(0x120) & ~3;
dd->dd_pacode[0x3] = parseword(0x130) & ~3;
dd->dd_pacode[0x4] = parseword(0x140) & ~3;
dd->dd_pacode[0x5] = parseword(0x150) & ~3;
dd->dd_pacode[0x6] = parseword(0x160) & ~3;
dd->dd_pacode[0x7] = parseword(0x170) & ~3;
dd->dd_pacode[0x8] = parseword(0x180) & ~3;
dd->dd_pacode[0x9] = parseword(0x190) & ~3;
dd->dd_pacode[0xa] = parseword(0x1a0) & ~3;
dd->dd_pacode[0xb] = parseword(0x1b0) & ~3;
dd->dd_pacode[0xc] = parseword(0x1c0) & ~3;
dd->dd_pacode[0xd] = parseword(0x1d0) & ~3;
dd->dd_pacode[0xe] = parseword(0x1e0) & ~3;
dd->dd_pacode[0xf] = parseword(0x1f0) & ~3;
} else /* STI_DEVTYPE4 */
bus_space_read_region_4(sc->memt, sc->romh, 0, (u_int32_t *)dd,
sizeof(*dd) / 4);
#ifdef STIDEBUG
printf("dd:\n"
"devtype=%x, rev=%x;%d, altt=%x, gid=%016llx, font=%x, mss=%x\n"
"end=%x, regions=%x, msto=%x, timo=%d, mont=%x, user=%x[%x]\n"
"memrq=%x, pwr=%d, bus=%x, ebus=%x, cfb=%x\n"
"code=",
dd->dd_type & 0xff, dd->dd_grrev, dd->dd_lrrev, dd->dd_altcodet,
*(u_int64_t *)dd->dd_grid, dd->dd_fntaddr, dd->dd_maxst,
dd->dd_romend, dd->dd_reglst, dd->dd_maxreent, dd->dd_maxtimo,
dd->dd_montbl, dd->dd_udaddr, dd->dd_udsize, dd->dd_stimemreq,
dd->dd_pwruse, dd->dd_bussup, dd->dd_ebussup, dd->dd_cfbaddr);
printf("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x\n",
dd->dd_pacode[0x0], dd->dd_pacode[0x1], dd->dd_pacode[0x2],
dd->dd_pacode[0x3], dd->dd_pacode[0x4], dd->dd_pacode[0x5],
dd->dd_pacode[0x6], dd->dd_pacode[0x7], dd->dd_pacode[0x8],
dd->dd_pacode[0x9], dd->dd_pacode[0xa], dd->dd_pacode[0xb],
dd->dd_pacode[0xc], dd->dd_pacode[0xd], dd->dd_pacode[0xe],
dd->dd_pacode[0xf]);
#endif
/* divise code size, could be less than STI_END entries */
for (i = STI_END; !dd->dd_pacode[i]; i--);
size = dd->dd_pacode[i] - dd->dd_pacode[STI_BEGIN];
if (sc->sc_devtype == STI_DEVTYPE1)
size = (size + 3) / 4;
if (!(sc->sc_code = uvm_km_alloc1(kernel_map, round_page(size), 0))) {
printf(": cannot allocate %u bytes for code\n", size);
return;
}
#ifdef STIDEBUG
printf("code=0x%x[%x]\n", (uint)sc->sc_code, size);
#endif
/* copy code into memory */
if (sc->sc_devtype == STI_DEVTYPE1) {
p = (u_int8_t *)sc->sc_code;
for (addr = dd->dd_pacode[STI_BEGIN], eaddr = addr + size * 4;
addr < eaddr; addr += 4 )
*p++ = bus_space_read_4(sc->memt, sc->romh, addr)
& 0xff;
} else /* STI_DEVTYPE4 */
bus_space_read_region_4(sc->memt, sc->romh,
dd->dd_pacode[STI_BEGIN], (u_int32_t *)sc->sc_code,
size / 4);
#define O(i) (dd->dd_pacode[(i)] ? (sc->sc_code + \
(dd->dd_pacode[(i)] - dd->dd_pacode[0]) / \
(sc->sc_devtype == STI_DEVTYPE1 ? 4 : 1)) : 0)
sc->init = (sti_init_t) O(STI_INIT_GRAPH);
sc->mgmt = (sti_mgmt_t) O(STI_STATE_MGMT);
sc->unpmv = (sti_unpmv_t) O(STI_FONT_UNPMV);
sc->blkmv = (sti_blkmv_t) O(STI_BLOCK_MOVE);
sc->test = (sti_test_t) O(STI_SELF_TEST);
sc->exhdl = (sti_exhdl_t) O(STI_EXCEP_HDLR);
sc->inqconf = (sti_inqconf_t)O(STI_INQ_CONF);
sc->scment = (sti_scment_t)O(STI_SCM_ENT);
sc->dmac = (sti_dmac_t) O(STI_DMA_CTRL);
sc->flowc = (sti_flowc_t) O(STI_FLOW_CTRL);
sc->utiming = (sti_utiming_t)O(STI_UTIMING);
sc->pmgr = (sti_pmgr_t) O(STI_PROC_MGR);
sc->util = (sti_util_t) O(STI_UTIL);
if ((error = uvm_map_protect(kernel_map, sc->sc_code,
sc->sc_code + round_page(size), UVM_PROT_RX, FALSE))) {
printf(": uvm_map_protect failed (%d)\n", error);
uvm_km_free(kernel_map, sc->sc_code, round_page(size));
return;
}
cc = &sc->sc_cfg;
memset(cc, 0, sizeof (*cc));
i = dd->dd_reglst;
#ifdef STIDEBUG
printf("stiregions @%d:\n", i);
#endif
r.last = 0;
for (q = cc->regions; !r.last &&
q < &cc->regions[STI_REGION_MAX]; q++) {
if (sc->sc_devtype == STI_DEVTYPE1)
*(u_int *)&r = parseword(i), i += 16;
else
*(u_int *)&r = bus_space_read_4(sc->memt, sc->romh, i),
i += 4;
*q = (q == cc->regions ? sc->romh : sc->base) +
(r.offset << PGSHIFT);
#ifdef STIDEBUG
printf("%x @ 0x%x%s%s%s%s\n",
r.length << PGSHIFT, *q, r.sys_only ? " sys" : "",
r.cache ? " cache" : "", r.btlb ? " btlb" : "",
r.last ? " last" : "");
#endif
/* rom has already been mapped */
if (q != cc->regions) {
if (bus_space_map(sc->memt, *q,
r.length << PGSHIFT, 0, &fbh)) {
#ifdef STIDEBUG
printf("already mapped region\n");
#endif
} else {
if (q - cc->regions == 1) {
sc->fbaddr = *q;
sc->fblen = r.length << PGSHIFT;
}
*q = fbh;
}
}
}
if ((error = sti_init(sc, 0))) {
printf(": can not initialize (%d)\n", error);
return;
}
memset(&cfg, 0, sizeof(cfg));
memset(&ecfg, 0, sizeof(ecfg));
cfg.ext = &ecfg;
if ((error = sti_inqcfg(sc, &cfg))) {
printf(": error %d inquiring config\n", error);
return;
}
if ((error = sti_init(sc, STI_TEXTMODE))) {
printf(": can not initialize (%d)\n", error);
return;
}
#ifdef STIDEBUG
printf("conf: bpp=%d planes=%d attr=%d\n"
"crt=0x%x:0x%x:0x%x hw=0x%x:0x%x:0x%x\n",
cfg.bpp, cfg.planes, cfg.attributes,
ecfg.crt_config[0], ecfg.crt_config[1], ecfg.crt_config[2],
ecfg.crt_hw[0], ecfg.crt_hw[1], ecfg.crt_hw[2]);
#endif
sc->sc_wsmode = WSDISPLAYIO_MODE_EMUL;
sc->sc_bpp = cfg.bppu;
printf(": %s rev %d.%02d;%d, ID 0x%016llX\n"
"%s: %dx%d frame buffer, %dx%dx%d display, offset %dx%d\n",
cfg.name, dd->dd_grrev >> 4, dd->dd_grrev & 0xf, dd->dd_lrrev,
*(u_int64_t *)dd->dd_grid, sc->sc_dev.dv_xname, cfg.fbwidth,
cfg.fbheight, cfg.width, cfg.height, cfg.bppu, cfg.owidth,
cfg.oheight);
if ((error = sti_fetchfonts(sc, &cfg, dd->dd_fntaddr))) {
printf("%s: cannot fetch fonts (%d)\n", sc->sc_dev.dv_xname,
error);
return;
}
/*
* parse screen descriptions:
* figure number of fonts supported;
* allocate wscons structures;
* calculate dimensions.
*/
sti_default_screen.ncols = cfg.width / sc->sc_curfont.width;
sti_default_screen.nrows = cfg.height / sc->sc_curfont.height;
sti_default_screen.fontwidth = sc->sc_curfont.width;
sti_default_screen.fontheight = sc->sc_curfont.height;
#if NWSDISPLAY > 0
config_interrupts(&sc->sc_dev, sti_attach_deferred);
#endif
}
void
sti_attach_deferred(struct device *dev)
{
struct sti_softc *sc = (struct sti_softc *) dev;
struct wsemuldisplaydev_attach_args waa;
long defattr;
waa.console = sc->sc_flags & STI_CONSOLE ? 1 : 0;
waa.scrdata = &sti_default_screenlist;
waa.accessops = &sti_accessops;
waa.accesscookie = sc;
/* attach as console if required */
if (waa.console) {
sti_alloc_attr(sc, 0, 0, 0, &defattr);
wsdisplay_cnattach(&sti_default_screen, sc,
0, sti_default_screen.nrows - 1, defattr);
}
config_found(&sc->sc_dev, &waa, wsemuldisplaydevprint);
}
int
sti_fetchfonts(struct sti_softc *sc, struct sti_inqconfout *cfg, u_int32_t addr)
{
struct sti_font *fp = &sc->sc_curfont;
int size;
#ifdef notyet
int uc;
struct {
struct sti_unpmvflags flags;
struct sti_unpmvin in;
struct sti_unpmvout out;
} a;
#endif
/*
* Get the first PROM font in memory
*/
do {
if (sc->sc_devtype == STI_DEVTYPE1) {
fp->first = parseshort(addr + 0x00);
fp->last = parseshort(addr + 0x08);
fp->width = bus_space_read_1(sc->memt, sc->romh,
addr + 0x13);
fp->height = bus_space_read_1(sc->memt, sc->romh,
addr + 0x17);
fp->type = bus_space_read_1(sc->memt, sc->romh,
addr + 0x1b);
fp->bpc = bus_space_read_1(sc->memt, sc->romh,
addr + 0x1f);
fp->next = parseword(addr + 0x23);
fp->uheight= bus_space_read_1(sc->memt, sc->romh,
addr + 0x33);
fp->uoffset= bus_space_read_1(sc->memt, sc->romh,
addr + 0x37);
} else /* STI_DEVTYPE4 */
bus_space_read_region_4(sc->memt, sc->romh, addr,
(u_int32_t *)fp, sizeof(struct sti_font) / 4);
printf("%s: %dx%d font type %d, %d bpc, charset %d-%d\n",
sc->sc_dev.dv_xname, fp->width, fp->height, fp->type,
fp->bpc, fp->first, fp->last);
size = sizeof(struct sti_font) +
(fp->last - fp->first + 1) * fp->bpc;
if (sc->sc_devtype == STI_DEVTYPE1)
size *= 4;
sc->sc_romfont = malloc(size, M_DEVBUF, M_NOWAIT);
if (sc->sc_romfont == NULL)
return (ENOMEM);
bus_space_read_region_4(sc->memt, sc->romh, addr,
(u_int32_t *)sc->sc_romfont, size / 4);
addr = 0; /* fp->next */
} while (addr);
#ifdef notyet
/*
* If there is enough room in the off-screen framebuffer memory,
* display all the characters there in order to display them
* faster with blkmv operations rather than unpmv later on.
*/
if (size <= cfg->fbheight *
(cfg->fbwidth - cfg->width - cfg->owidth)) {
memset(&a, 0, sizeof(a));
a.flags.flags = STI_UNPMVF_WAIT;
a.in.fg_colour = STI_COLOUR_WHITE;
a.in.bg_colour = STI_COLOUR_BLACK;
a.in.font_addr = sc->sc_romfont;
sc->sc_fontmaxcol = cfg->fbheight / fp->height;
sc->sc_fontbase = cfg->width + cfg->owidth;
for (uc = fp->first; uc <= fp->last; uc++) {
a.in.x = ((uc - fp->first) / sc->sc_fontmaxcol) *
fp->width + sc->sc_fontbase;
a.in.y = ((uc - fp->first) % sc->sc_fontmaxcol) *
fp->height;
a.in.index = uc;
(*sc->unpmv)(&a.flags, &a.in, &a.out, &sc->sc_cfg);
if (a.out.errno) {
printf("%s: unpmv %d returned %d\n",
sc->sc_dev.dv_xname, uc, a.out.errno);
return (0);
}
}
free(sc->sc_romfont, M_DEVBUF);
sc->sc_romfont = NULL;
}
#endif
return (0);
}
int
sti_init(struct sti_softc *sc, int mode)
{
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 |
(mode & STI_TEXTMODE ? STI_INITF_TEXT | STI_INITF_PBET |
STI_INITF_PBETI | STI_INITF_ICMT : 0);
a.in.text_planes = 1;
#ifdef STIDEBUG
printf("%s: init,%p(%x, %p, %p, %p)\n", sc->sc_dev.dv_xname,
sc->init, a.flags.flags, &a.in, &a.out, &sc->sc_cfg);
#endif
(*sc->init)(&a.flags, &a.in, &a.out, &sc->sc_cfg);
return (a.out.text_planes != a.in.text_planes || a.out.errno);
}
int
sti_inqcfg(struct sti_softc *sc, struct sti_inqconfout *out)
{
struct {
struct sti_inqconfflags flags;
struct sti_inqconfin in;
} a;
memset(&a, 0, sizeof(a));
a.flags.flags = STI_INQCONFF_WAIT;
(*sc->inqconf)(&a.flags, &a.in, out, &sc->sc_cfg);
return out->errno;
}
void
sti_bmove(struct sti_softc *sc, int x1, int y1, int x2, int y2, int h, int w,
enum sti_bmove_funcs f)
{
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;
switch (f) {
case bmf_clear:
a.flags.flags |= STI_BLKMVF_CLR;
a.in.bg_colour = STI_COLOUR_BLACK;
break;
case bmf_underline:
case bmf_copy:
a.in.fg_colour = STI_COLOUR_WHITE;
a.in.bg_colour = STI_COLOUR_BLACK;
break;
case bmf_invert:
a.flags.flags |= STI_BLKMVF_COLR;
a.in.fg_colour = STI_COLOUR_BLACK;
a.in.bg_colour = STI_COLOUR_WHITE;
break;
}
a.in.srcx = x1;
a.in.srcy = y1;
a.in.dstx = x2;
a.in.dsty = y2;
a.in.height = h;
a.in.width = w;
(*sc->blkmv)(&a.flags, &a.in, &a.out, &sc->sc_cfg);
#ifdef STIDEBUG
if (a.out.errno)
printf("%s: blkmv returned %d\n", sc->sc_dev.dv_xname,
a.out.errno);
#endif
}
int
sti_setcment(struct sti_softc *sc, u_int i, u_char r, u_char g, u_char b)
{
struct {
struct sti_scmentflags flags;
struct sti_scmentin in;
struct sti_scmentout out;
} a;
memset(&a, 0, sizeof(a));
a.flags.flags = STI_SCMENTF_WAIT;
a.in.entry = i;
a.in.value = (r << 16) | (g << 8) | b;
(*sc->scment)(&a.flags, &a.in, &a.out, &sc->sc_cfg);
return a.out.errno;
}
int
sti_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
{
struct sti_softc *sc = v;
struct wsdisplay_fbinfo *wdf;
struct wsdisplay_cmap *cmapp;
u_int mode, idx, count;
int i, ret;
ret = 0;
switch (cmd) {
case WSDISPLAYIO_GMODE:
*(u_int *)data = sc->sc_wsmode;
break;
case WSDISPLAYIO_SMODE:
mode = *(u_int *)data;
if (sc->sc_wsmode == WSDISPLAYIO_MODE_EMUL &&
mode == WSDISPLAYIO_MODE_DUMBFB)
ret = sti_init(sc, 0);
else if (sc->sc_wsmode == WSDISPLAYIO_MODE_DUMBFB &&
mode == WSDISPLAYIO_MODE_EMUL)
ret = sti_init(sc, STI_TEXTMODE);
sc->sc_wsmode = mode;
break;
case WSDISPLAYIO_GTYPE:
*(u_int *)data = WSDISPLAY_TYPE_STI;
break;
case WSDISPLAYIO_GINFO:
wdf = (struct wsdisplay_fbinfo *)data;
wdf->height = sc->sc_cfg.scr_height;
wdf->width = sc->sc_cfg.scr_width;
wdf->depth = sc->sc_bpp;
wdf->cmsize = STI_NCMAP;
break;
case WSDISPLAYIO_LINEBYTES:
*(u_int *)data = sc->sc_cfg.fb_width;
break;
case WSDISPLAYIO_GETCMAP:
if (sc->scment == NULL)
return ENOTTY;
cmapp = (struct wsdisplay_cmap *)data;
idx = cmapp->index;
count = cmapp->count;
if (idx > STI_NCMAP || idx + count >= STI_NCMAP)
return EINVAL;
if ((ret = copyout(&sc->sc_rcmap[idx], cmapp->red, count)))
break;
if ((ret = copyout(&sc->sc_gcmap[idx], cmapp->green, count)))
break;
if ((ret = copyout(&sc->sc_bcmap[idx], cmapp->blue, count)))
break;
break;
case WSDISPLAYIO_PUTCMAP:
if (sc->scment == NULL)
return ENOTTY;
cmapp = (struct wsdisplay_cmap *)data;
idx = cmapp->index;
count = cmapp->count;
if (idx > STI_NCMAP || idx + count >= STI_NCMAP)
return EINVAL;
if ((ret = copyin(cmapp->red, &sc->sc_rcmap[idx], count)))
break;
if ((ret = copyin(cmapp->green, &sc->sc_gcmap[idx], count)))
break;
if ((ret = copyin(cmapp->blue, &sc->sc_bcmap[idx], count)))
break;
for (i = idx + count - 1; i >= idx; i--)
if ((ret = sti_setcment(sc, i, sc->sc_rcmap[i],
sc->sc_gcmap[i], sc->sc_bcmap[i]))) {
#ifdef STIDEBUG
printf("sti_ioctl: "
"sti_setcment(%d, %u, %u, %u): %%d\n", i,
(u_int)sc->sc_rcmap[i],
(u_int)sc->sc_gcmap[i],
(u_int)sc->sc_bcmap[i]);
#endif
ret = EINVAL;
break;
}
break;
case WSDISPLAYIO_SVIDEO:
case WSDISPLAYIO_GVIDEO:
case WSDISPLAYIO_GCURPOS:
case WSDISPLAYIO_SCURPOS:
case WSDISPLAYIO_GCURMAX:
case WSDISPLAYIO_GCURSOR:
case WSDISPLAYIO_SCURSOR:
default:
return (ENOTTY); /* not supported yet */
}
return (ret);
}
paddr_t
sti_mmap(void *v, off_t offset, int prot)
{
/* XXX not finished */
return -1;
}
int
sti_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
int *cxp, int *cyp, long *defattr)
{
struct sti_softc *sc = v;
if (sc->sc_nscreens > 0)
return ENOMEM;
*cookiep = sc;
*cxp = 0;
*cyp = 0;
sti_alloc_attr(sc, 0, 0, 0, defattr);
sc->sc_nscreens++;
return 0;
}
void
sti_free_screen(void *v, void *cookie)
{
struct sti_softc *sc = v;
sc->sc_nscreens--;
}
int
sti_show_screen(void *v, void *cookie, int waitok, void (*cb)(void *, int, int), void *cbarg)
{
return 0;
}
int
sti_load_font(void *v, void *cookie, struct wsdisplay_font *font)
{
return -1;
}
void
sti_cursor(void *v, int on, int row, int col)
{
struct sti_softc *sc = v;
struct sti_font *fp = &sc->sc_curfont;
sti_bmove(sc, col * fp->width, row * fp->height, col * fp->width,
row * fp->height, fp->height, fp->width, bmf_invert);
}
int
sti_mapchar(void *v, int uni, u_int *index)
{
if (uni < 256)
*index = uni;
return 1;
}
void
sti_putchar(void *v, int row, int col, u_int uc, long attr)
{
struct sti_softc *sc = v;
struct sti_font *fp = &sc->sc_curfont;
if (sc->sc_romfont != NULL) {
/*
* Font is in memory, use 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;
/* XXX does not handle text attributes */
a.in.fg_colour = STI_COLOUR_WHITE;
a.in.bg_colour = STI_COLOUR_BLACK;
a.in.x = col * fp->width;
a.in.y = row * fp->height;
a.in.font_addr = sc->sc_romfont;
a.in.index = uc;
(*sc->unpmv)(&a.flags, &a.in, &a.out, &sc->sc_cfg);
} else {
/*
* Font is in frame buffer, use 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;
/* XXX does not handle text attributes */
a.in.fg_colour = STI_COLOUR_WHITE;
a.in.bg_colour = STI_COLOUR_BLACK;
a.in.srcx = ((uc - fp->first) / sc->sc_fontmaxcol) *
fp->width + sc->sc_fontbase;
a.in.srcy = ((uc - fp->first) % sc->sc_fontmaxcol) *
fp->height;
a.in.dstx = col * fp->width;
a.in.dsty = row * fp->height;
a.in.height = fp->height;
a.in.width = fp->width;
(*sc->blkmv)(&a.flags, &a.in, &a.out, &sc->sc_cfg);
}
}
void
sti_copycols(void *v, int row, int srccol, int dstcol, int ncols)
{
struct sti_softc *sc = v;
struct sti_font *fp = &sc->sc_curfont;
sti_bmove(sc, srccol * fp->width, row * fp->height, dstcol * fp->width,
row * fp->height, fp->height, ncols * fp->width, bmf_copy);
}
void
sti_erasecols(void *v, int row, int startcol, int ncols, long attr)
{
struct sti_softc *sc = v;
struct sti_font *fp = &sc->sc_curfont;
sti_bmove(sc, startcol * fp->width, row * fp->height,
startcol * fp->width, row * fp->height, fp->height,
ncols * fp->width, bmf_clear);
}
void
sti_copyrows(void *v, int srcrow, int dstrow, int nrows)
{
struct sti_softc *sc = v;
struct sti_font *fp = &sc->sc_curfont;
sti_bmove(sc, sc->sc_cfg.oscr_width, srcrow * fp->height,
sc->sc_cfg.oscr_width, dstrow * fp->height,
nrows * fp->height, sc->sc_cfg.scr_width, bmf_copy);
}
void
sti_eraserows(void *v, int srcrow, int nrows, long attr)
{
struct sti_softc *sc = v;
struct sti_font *fp = &sc->sc_curfont;
sti_bmove(sc, sc->sc_cfg.oscr_width, srcrow * fp->height,
sc->sc_cfg.oscr_width, srcrow * fp->height,
nrows * fp->height, sc->sc_cfg.scr_width, bmf_clear);
}
int
sti_alloc_attr(void *v, int fg, int bg, int flags, long *pattr)
{
/* struct sti_softc *sc = v; */
*pattr = 0;
return 0;
}

606
sys/dev/ic/stireg.h Normal file
View File

@ -0,0 +1,606 @@
/* $NetBSD: stireg.h,v 1.1 2004/08/26 16:48:06 jkunz Exp $ */
/* $OpenBSD: stireg.h,v 1.8 2003/08/19 02:52:38 mickey Exp $ */
/*
* Copyright (c) 2000 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.
*/
#ifndef _IC_STIREG_H_
#define _IC_STIREG_H_
/* #define STIDEBUG */
#define STI_REGION_MAX 8
#define STI_MONITOR_MAX 256
#define STI_DEVNAME_LEN 32
#define STI_NCMAP 256
/* code ROM definitions */
#define STI_BEGIN 0
#define STI_INIT_GRAPH 0
#define STI_STATE_MGMT 1
#define STI_FONT_UNPMV 2
#define STI_BLOCK_MOVE 3
#define STI_SELF_TEST 4
#define STI_EXCEP_HDLR 5
#define STI_INQ_CONF 6
#define STI_SCM_ENT 7
#define STI_DMA_CTRL 8
#define STI_FLOW_CTRL 9
#define STI_UTIMING 10
#define STI_PROC_MGR 11
#define STI_UTIL 12
#define STI_END 13
#define STI_CODECNT 16
/* sti returns */
#define STI_OK 0
#define STI_FAIL -1
#define STI_NRDY 1
/* sti errno */
#define STI_NOERRNO 0 /* no error */
#define STI_BADREENTLVL 1 /* bad reentry level */
#define STI_NOREGIONSDEF 2 /* region table is not setup */
#define STI_ILLNPLANES 3 /* invalid num of text planes */
#define STI_ILLINDEX 4 /* invalid fond index */
#define STI_ILLLOC 5 /* invalid font location */
#define STI_ILLCOLOUR 6 /* invalid colour */
#define STI_ILLBLKMVFROM 7 /* invalid from in blkmv */
#define STI_ILLBLKMVTO 8 /* invalid to in blkmv */
#define STI_ILLBLKMVSIZE 9 /* invalid siz in blkmv */
#define STI_BEIUNSUPP 10 /* bus error ints unsupported */
#define STI_UNXPBE 11 /* unexpected bus error */
#define STI_UNXHWF 12 /* unexpected hardware failure */
#define STI_NEGCFG 13 /* no ext global config struct */
#define STI_NEIG 14 /* no ext init struct */
#define STI_ILLSCME 15 /* invalid set cmap entry */
#define STI_ILLCMVAL 16 /* invalid cmap value */
#define STI_NORESMEM 17 /* no requested global memory */
#define STI_RESMEMCORR 18 /* reserved memory corrupted */
#define STI_ILLNTBLKMV 19 /* invalid non-text blkmv */
#define STI_ILLMONITOR 20 /* monitor selection is out of range */
#define STI_ILLEXCADDR 21 /* invalid excpt handler addr */
#define STI_ILLEXCFLAGS 22 /* invalid excpt handler flags */
#define STI_NOEHE 23 /* no ext exhdl struct */
#define STI_NOINQCE 24 /* no ext inq cfg struct */
#define STI_ILLRGNPTR 25 /* invalid region pointer */
#define STI_ILLUTLOP 26 /* invalid util opcode */
#define STI_UNKNOWN 250 /* unknown error */
#define STI_NOCFGPTR 251 /* no config ptr defined */
#define STI_NOFLPTR 252 /* no flag ptr defined */
#define STI_NOINPTR 253 /* no in ptr defined */
#define STI_NOOUTPTR 254 /* no way you can get it */
#define STI_NOLOCK 255 /* kernel dishonour graphics lock */
/* colours */
#define STI_COLOUR_BLACK 0
#define STI_COLOUR_WHITE 1
#define STI_COLOUR_RED 2
#define STI_COLOUR_YELLOW 3
#define STI_COLOUR_GREEN 4
#define STI_COLOUR_CYAN 5
#define STI_COLOUR_BLUE 6
#define STI_COLOUR_MAGENTA 7
#pragma pack(1)
/* LSB high */
struct sti_dd {
u_int32_t dd_type; /* 0x00 device type */
#define STI_DEVTYPE1 1
#define STI_DEVTYPE4 3
u_int8_t dd_unused;
u_int8_t dd_nmon; /* 0x05 number monitor rates */
u_int8_t dd_grrev; /* 0x06 global rom revision */
u_int8_t dd_lrrev; /* 0x07 local rom revision */
u_int8_t dd_grid[8]; /* 0x08 graphics id */
#define STI_DEV4_DD_GRID 0x08 /* offset for STI_DEVTYPE4 */
#define STI_DEV1_DD_GRID 0x10 /* offset for STI_DEVTYPE1 */
u_int32_t dd_fntaddr; /* 0x10 font start address */
u_int32_t dd_maxst; /* 0x14 max state storage */
u_int32_t dd_romend; /* 0x18 rom last address */
#define STI_DEV4_DD_ROMEND 0x18 /* offset for STI_DEVTYPE4 */
#define STI_DEV1_DD_ROMEND 0x50 /* offset for STI_DEVTYPE1 */
u_int32_t dd_reglst; /* 0x1c device region list */
u_int16_t dd_maxreent; /* 0x20 max reent storage */
u_int16_t dd_maxtimo; /* 0x22 max execution timeout .1 sec */
u_int32_t dd_montbl; /* 0x24 mon table address, array of
names num of dd_nmon */
u_int32_t dd_udaddr; /* 0x28 user data address */
u_int32_t dd_stimemreq; /* 0x2c sti memory request */
u_int32_t dd_udsize; /* 0x30 user data size */
u_int16_t dd_pwruse; /* 0x34 power usage */
u_int8_t dd_bussup; /* 0x36 bus support */
#define STI_BUSSUPPORT_GSCINTL 0x01 /* supports pulling INTL for int */
#define STI_BUSSUPPORT_GSC15X 0x02 /* supports GSC 1.5X */
#define STI_BUSSUPPORT_GSC2X 0x04 /* supports GSC 2.X */
#define STI_BUSSUPPORT_PCIIOEIM 0x08 /* will use directed int */
#define STI_BUSSUPPORT_PCISTD 0x10 /* will use std PCI int */
#define STI_BUSSUPPORT_ILOCK 0x20 /* supports implicit locking */
#define STI_BUSSUPPORT_ROMMAP 0x40 /* rom is only in pci erom space */
#define STI_BUSSUPPORT_2DECODE 0x80 /* single address decoder */
u_int8_t dd_ebussup; /* 0x37 extended bus support */
#define STI_EBUSSUPPORT_DMA 0x01 /* supports dma */
#define STI_EBUSSUPPORT_PIOLOCK 0x02 /* no implicit locking for dma */
u_int8_t dd_altcodet; /* 0x38 alternate code type */
#define STI_ALTCODE_UNKNOWN 0x00
#define STI_ALTCODE_PA64 0x01 /* alt code is in pa64 */
u_int8_t dd_eddst[3]; /* 0x39 extended DD struct */
u_int32_t dd_cfbaddr; /* 0x3c CFB address, location of
X11 driver to be used for
servers w/o accel */
u_int32_t dd_pacode[16]; /* 0x40 routines for pa-risc */
u_int32_t dd_altcode[16]; /* 0x80 routines for m68k/i386 */
};
/* after the last region there is one indirect list ptr */
struct sti_region {
u_int offset :14; /* page offset dev io space relative */
u_int sys_only: 1; /* whether allow user access */
u_int cache : 1; /* map in cache */
u_int btlb : 1; /* should use BTLB if available */
u_int last : 1; /* last region in the list */
u_int length :14; /* size in pages */
};
struct sti_font {
u_int16_t first;
u_int16_t last;
u_int8_t width;
u_int8_t height;
u_int8_t type;
#define STI_FONT_HPROMAN8 1
#define STI_FONT_KANA8 2
u_int8_t bpc;
u_int32_t next;
u_int8_t uheight;
u_int8_t uoffset;
u_int8_t unused[2];
};
struct sti_fontcfg {
u_int16_t first;
u_int16_t last;
u_int8_t width;
u_int8_t height;
u_int8_t type;
u_int8_t bpc;
u_int8_t uheight;
u_int8_t uoffset;
};
typedef struct sti_ecfg {
u_int8_t current_monitor;
u_int8_t uf_boot;
u_int16_t power; /* power dissipation Watts */
u_int32_t freq_ref;
u_int32_t *addr; /* memory block of size dd_stimemreq */
void *future;
} *sti_ecfg_t;
typedef struct sti_cfg {
u_int32_t text_planes;
u_int16_t scr_width;
u_int16_t scr_height;
u_int16_t oscr_width;
u_int16_t oscr_height;
u_int16_t fb_width;
u_int16_t fb_height;
u_int32_t regions[STI_REGION_MAX];
u_int32_t reent_level;
u_int32_t *save_addr;
sti_ecfg_t ext_cfg;
} *sti_cfg_t;
/* routine types */
#define STI_DEP(n) \
typedef int (*sti_##n##_t)( \
sti_##n##flags_t, sti_##n##in_t, sti_##n##out_t, sti_cfg_t);
typedef struct sti_initflags {
u_int32_t flags;
#define STI_INITF_WAIT 0x80000000
#define STI_INITF_RESET 0x40000000
#define STI_INITF_TEXT 0x20000000
#define STI_INITF_NTEXT 0x10000000
#define STI_INITF_CLEAR 0x08000000
#define STI_INITF_CMB 0x04000000 /* non-text planes cmap black */
#define STI_INITF_EBET 0x02000000 /* enable bus error timer */
#define STI_INITF_EBETI 0x01000000 /* enable bus error timer interrupt */
#define STI_INITF_PTS 0x00800000 /* preserve text settings */
#define STI_INITF_PNTS 0x00400000 /* preserve non-text settings */
#define STI_INITF_PBET 0x00200000 /* preserve BET settings */
#define STI_INITF_PBETI 0x00100000 /* preserve BETI settings */
#define STI_INITF_ICMT 0x00080000 /* init cmap for text planes */
#define STI_INITF_SCMT 0x00040000 /* change current monitor type */
#define STI_INITF_RIE 0x00020000 /* retain int enables */
void *future;
} *sti_initflags_t;
typedef struct sti_einitin {
u_int8_t mon_type;
u_int8_t pad;
u_int16_t inflight; /* possible on pci */
void *future;
} *sti_einitin_t;
typedef struct sti_initin {
u_int32_t text_planes; /* number of planes for text */
sti_einitin_t ext_in;
} *sti_initin_t;
typedef struct sti_initout {
int32_t errno;
u_int32_t text_planes; /* number of planes used for text */
void *future;
} *sti_initout_t;
STI_DEP(init);
typedef struct sti_mgmtflags {
u_int32_t flags;
#define STI_MGMTF_WAIT 0x80000000
#define STI_MGMTF_SAVE 0x40000000
#define STI_MGMTF_RALL 0x20000000 /* restore all display planes */
void *future;
} *sti_mgmtflags_t;
typedef struct sti_mgmtin {
void *addr;
void *future;
} *sti_mgmtin_t;
typedef struct sti_mgmtout {
int32_t errno;
void *future;
} *sti_mgmtout_t;
STI_DEP(mgmt);
typedef struct sti_unpmvflags {
u_int32_t flags;
#define STI_UNPMVF_WAIT 0x80000000
#define STI_UNPMVF_NTXT 0x40000000 /* intp non-text planes */
void *future;
} *sti_unpmvflags_t;
typedef struct sti_unpmvin {
u_int32_t *font_addr; /* font */
u_int16_t index; /* character index in the font */
u_int8_t fg_colour;
u_int8_t bg_colour;
u_int16_t x, y;
void *future;
} *sti_unpmvin_t;
typedef struct sti_unpmvout {
u_int32_t errno;
void *future;
} *sti_unpmvout_t;
STI_DEP(unpmv);
typedef struct sti_blkmvflags {
u_int32_t flags;
#define STI_BLKMVF_WAIT 0x80000000
#define STI_BLKMVF_COLR 0x40000000 /* change colour on move */
#define STI_BLKMVF_CLR 0x20000000 /* clear on move */
#define STI_BLKMVF_NTXT 0x10000000 /* move in non-text planes */
void *future;
} *sti_blkmvflags_t;
typedef struct sti_blkmvin {
u_int8_t fg_colour;
u_int8_t bg_colour;
u_int16_t srcx, srcy, dstx, dsty;
u_int16_t width, height;
u_int16_t pad;
void *future;
} *sti_blkmvin_t;
typedef struct sti_blkmvout {
u_int32_t errno;
void *future;
} *sti_blkmvout_t;
STI_DEP(blkmv);
typedef struct sti_testflags {
u_int32_t flags;
#define STI_TESTF_WAIT 0x80000000
#define STI_TESTF_ETST 0x40000000
void *future;
} *sti_testflags_t;
typedef struct sti_testin {
void *future;
} *sti_testin_t;
typedef struct sti_testout {
u_int32_t errno;
u_int32_t result;
void *future;
} *sti_testout_t;
STI_DEP(test);
typedef struct sti_exhdlflags {
u_int32_t flags;
#define STI_EXHDLF_WAIT 0x80000000
#define STI_EXHDLF_CINT 0x40000000 /* clear int */
#define STI_EXHDLF_CBE 0x20000000 /* clear BE */
#define STI_EXHDLF_PINT 0x10000000 /* preserve int */
#define STI_EXHDLF_RINT 0x08000000 /* restore int */
#define STI_EXHDLF_WEIM 0x04000000 /* write eim w/ sti_eexhdlin */
#define STI_EXHDLF_REIM 0x02000000 /* read eim to sti_eexhdlout */
#define STI_EXHDLF_GIE 0x01000000 /* global int enable */
#define STI_EXHDLF_PGIE 0x00800000
#define STI_EXHDLF_WIEM 0x00400000
#define STI_EXHDLF_EIEM 0x00200000
#define STI_EXHDLF_BIC 0x00100000 /* begin int cycle */
#define STI_EXHDLF_EIC 0x00080000 /* end int cycle */
#define STI_EXHDLF_RIE 0x00040000 /* reset do not clear int enables */
void *future;
} *sti_exhdlflags_t;
typedef struct sti_eexhdlin {
u_int32_t eim_addr;
u_int32_t eim_data;
u_int32_t iem; /* enable mask */
u_int32_t icm; /* clear mask */
void *future;
} *sti_eexhdlin_t;
typedef struct sti_exhdlint {
u_int32_t flags;
#define STI_EXHDLINT_BET 0x80000000 /* bus error timer */
#define STI_EXHDLINT_HW 0x40000000 /* high water */
#define STI_EXHDLINT_LW 0x20000000 /* low water */
#define STI_EXHDLINT_TM 0x10000000 /* texture map */
#define STI_EXHDLINT_VB 0x08000000 /* vertical blank */
#define STI_EXHDLINT_UDC 0x04000000 /* unbuffered dma complete */
#define STI_EXHDLINT_BDC 0x02000000 /* buffered dma complete */
#define STI_EXHDLINT_UDPC 0x01000000 /* unbuf priv dma complete */
#define STI_EXHDLINT_BDPC 0x00800000 /* buffered priv dma complete */
} *sti_exhdlint_t;
typedef struct sti_exhdlin {
sti_exhdlint_t addr;
sti_eexhdlin_t ext;
} *sti_exhdlin_t;
typedef struct sti_eexhdlout {
u_int32_t eim_addr;
u_int32_t eim_data;
u_int32_t iem; /* enable mask */
u_int32_t icm; /* clear mask */
void *future;
} *sti_eexhdlout_t;
typedef struct sti_exhdlout {
u_int32_t errno;
u_int32_t flags;
#define STI_EXHDLO_BE 0x80000000 /* BE was intercepted */
#define STI_EXHDLO_IP 0x40000000 /* there is int pending */
#define STI_EXHDLO_IE 0x20000000 /* global enable set */
sti_eexhdlout_t ext;
} *sti_exhdlout_t;
STI_DEP(exhdl);
typedef struct sti_inqconfflags {
u_int32_t flags;
#define STI_INQCONFF_WAIT 0x80000000
void *future;
} *sti_inqconfflags_t;
typedef struct sti_inqconfin {
void *future;
} *sti_inqconfin_t;
typedef struct sti_einqconfout {
u_int32_t crt_config[3];
u_int32_t crt_hw[3];
void *future;
} *sti_einqconfout_t;
typedef struct sti_inqconfout {
u_int32_t errno;
u_int16_t width, height, owidth, oheight, fbwidth, fbheight;
u_int32_t bpp; /* bits per pixel */
u_int32_t bppu; /* accessible bpp */
u_int32_t planes;
u_int8_t name[STI_DEVNAME_LEN];
u_int32_t attributes;
#define STI_INQCONF_Y2X 0x0001 /* pixel is higher tan wider */
#define STI_INQCONF_HWBLKMV 0x0002 /* hw blkmv is present */
#define STI_INQCONF_AHW 0x0004 /* adv hw accel */
#define STI_INQCONF_INT 0x0008 /* can interrupt */
#define STI_INQCONF_GONOFF 0x0010 /* supports on/off */
#define STI_INQCONF_AONOFF 0x0020 /* supports alpha on/off */
#define STI_INQCONF_VARY 0x0040 /* variable fb height */
#define STI_INQCONF_ODDBYTES 0x0080 /* use only odd fb bytes */
#define STI_INQCONF_FLUSH 0x0100 /* fb cache requires flushing */
#define STI_INQCONF_DMA 0x0200 /* supports dma */
#define STI_INQCONF_VDMA 0x0400 /* supports vdma */
#define STI_INQCONF_YUV1 0x2000 /* supports YUV type 1 */
#define STI_INQCONF_YUV2 0x4000 /* supports YUV type 2 */
#define STI_INQCONF_BITS \
"\020\001y2x\002hwblkmv\003ahw\004int\005gonoff\006aonoff\007vary"\
"\010oddb\011flush\012dma\013vdma\016yuv1\017yuv2"
sti_einqconfout_t ext;
} *sti_inqconfout_t;
STI_DEP(inqconf);
typedef struct sti_scmentflags {
u_int32_t flags;
#define STI_SCMENTF_WAIT 0x80000000
void *future;
} *sti_scmentflags_t;
typedef struct sti_scmentin {
u_int32_t entry;
u_int32_t value;
void *future;
} *sti_scmentin_t;
typedef struct sti_scmentout {
u_int32_t errno;
void *future;
} *sti_scmentout_t;
STI_DEP(scment);
typedef struct sti_dmacflags {
u_int32_t flags;
#define STI_DMACF_WAIT 0x80000000
#define STI_DMACF_PRIV 0x40000000 /* priv dma */
#define STI_DMACF_DIS 0x20000000 /* disable */
#define STI_DMACF_BUF 0x10000000 /* buffered */
#define STI_DMACF_MRK 0x08000000 /* write a marker */
#define STI_DMACF_ABRT 0x04000000 /* abort dma xfer */
void *future;
} *sti_dmacflags_t;
typedef struct sti_dmacin {
u_int32_t pa_upper;
u_int32_t pa_lower;
u_int32_t len;
u_int32_t mrk_data;
u_int32_t mrk_off;
void *future;
} *sti_dmacin_t;
typedef struct sti_dmacout {
u_int32_t errno;
void *future;
} *sti_dmacout_t;
STI_DEP(dmac);
typedef struct sti_flowcflags {
u_int32_t flags;
#define STI_FLOWCF_WAIT 0x80000000
#define STI_FLOWCF_CHW 0x40000000 /* check high water */
#define STI_FLOWCF_WHW 0x20000000 /* write high water */
#define STI_FLOWCF_WLW 0x10000000 /* write low water */
#define STI_FLOWCF_PCSE 0x08000000 /* preserve cse */
#define STI_FLOWCF_CSE 0x04000000
#define STI_FLOWCF_CSWF 0x02000000 /* cs write fine */
#define STI_FLOWCF_CSWC 0x01000000 /* cs write coarse */
#define STI_FLOWCF_CSWQ 0x00800000 /* cs write fifo */
void *future;
} *sti_flowcflags_t;
typedef struct sti_flowcin {
u_int32_t retry;
u_int32_t bufz;
u_int32_t hwcnt;
u_int32_t lwcnt;
u_int32_t csfv; /* cs fine value */
u_int32_t cscv; /* cs coarse value */
u_int32_t csqc; /* cs fifo count */
void *future;
} *sti_flowcin_t;
typedef struct sti_flowcout {
u_int32_t errno;
u_int32_t retry_result;
u_int32_t fifo_size;
void *future;
} *sti_flowcout_t;
STI_DEP(flowc);
typedef struct sti_utimingflags {
u_int32_t flags;
#define STI_UTIMF_WAIT 0x80000000
#define STI_UTIMF_HKS 0x40000000 /* has kbuf_size */
void *future;
} *sti_utimingflags_t;
typedef struct sti_utimingin {
void *data;
void *kbuf;
void *future;
} *sti_utimingin_t;
typedef struct sti_utimingout {
u_int32_t errno;
u_int32_t kbuf_size; /* buffer required size */
void *future;
} *sti_utimingout_t;
STI_DEP(utiming);
typedef struct sti_pmgrflags {
u_int32_t flags;
#define STI_UTIMF_WAIT 0x80000000
#define STI_UTIMOP_CLEANUP 0x00000000
#define STI_UTIMOP_BAC 0x10000000
#define STI_UTIMF_CRIT 0x04000000
#define STI_UTIMF_BUFF 0x02000000
#define STI_UTIMF_IBUFF 0x01000000
void *future;
} *sti_pmgrflags_t;
typedef struct sti_pmgrin {
u_int32_t reserved[4];
void *future;
} *sti_pmgrin_t;
typedef struct sti_pmgrout {
int32_t errno;
void *future;
} *sti_pmgrout_t;
STI_DEP(pmgr);
typedef struct sti_utilflags {
u_int32_t flags;
#define STI_UTILF_ROOT 0x80000000 /* was called as root */
void *future;
} *sti_utilflags_t;
typedef struct sti_utilin {
u_int32_t in_size;
u_int32_t out_size;
u_int8_t *buf;
} *sti_utilin_t;
typedef struct sti_utilout {
int32_t errno;
void *future;
} *sti_utilout_t;
STI_DEP(util);
#pragma pack()
#endif /* _IC_STIREG_H_ */

82
sys/dev/ic/stivar.h Normal file
View File

@ -0,0 +1,82 @@
/* $NetBSD: stivar.h,v 1.1 2004/08/26 16:48:06 jkunz Exp $ */
/* $OpenBSD: stivar.h,v 1.15 2003/12/16 06:07:13 mickey Exp $ */
/*
* 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.
*/
#ifndef _IC_STIVAR_H_
#define _IC_STIVAR_H_
struct sti_softc {
struct device sc_dev;
void *sc_ih;
u_int sc_wsmode;
u_int sc_flags;
#define STI_TEXTMODE 0x0001
#define STI_CLEARSCR 0x0002
#define STI_CONSOLE 0x0004
int sc_devtype;
int sc_nscreens;
int sc_bpp;
bus_space_tag_t iot, memt;
bus_space_handle_t romh;
bus_addr_t base, fbaddr;
bus_size_t fblen;
struct sti_dd sc_dd; /* in word format */
struct sti_font sc_curfont;
struct sti_cfg sc_cfg;
struct sti_ecfg sc_ecfg;
void *sc_romfont; /* ROM font copy, either in memory... */
u_int sc_fontmaxcol; /* ...or in off-screen frame buffer */
u_int sc_fontbase;
u_int8_t sc_rcmap[STI_NCMAP], sc_gcmap[STI_NCMAP], sc_bcmap[STI_NCMAP];
vaddr_t sc_code;
sti_init_t init;
sti_mgmt_t mgmt;
sti_unpmv_t unpmv;
sti_blkmv_t blkmv;
sti_test_t test;
sti_exhdl_t exhdl;
sti_inqconf_t inqconf;
sti_scment_t scment;
sti_dmac_t dmac;
sti_flowc_t flowc;
sti_utiming_t utiming;
sti_pmgr_t pmgr;
sti_util_t util;
};
void sti_attach_common(struct sti_softc *sc);
int sti_intr(void *v);
#endif /* _IC_STIVAR_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsconsio.h,v 1.69 2004/07/29 22:29:37 jmmv Exp $ */
/* $NetBSD: wsconsio.h,v 1.70 2004/08/26 16:48:06 jkunz Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -283,6 +283,7 @@ struct wsmouse_id {
#define WSDISPLAY_TYPE_SUNCG14 37 /* Sun cgfourteen */
#define WSDISPLAY_TYPE_SUNTCX 38 /* Sun TCX */
#define WSDISPLAY_TYPE_SUNFFB 39 /* Sun creator FFB */
#define WSDISPLAY_TYPE_STI 40 /* HP STI frambuffers */
/* Basic display information. Not applicable to all display types. */
struct wsdisplay_fbinfo {