2012-10-27 21:17:22 +04:00
|
|
|
/* $NetBSD: grf_machdep.c,v 1.32 2012/10/27 17:18:13 chs Exp $ */
|
1996-05-05 16:17:03 +04:00
|
|
|
|
|
|
|
/*
|
2011-02-08 23:20:06 +03:00
|
|
|
* Copyright (c) 1991 University of Utah.
|
1996-05-05 16:17:03 +04:00
|
|
|
* Copyright (c) 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* the Systems Programming Group of the University of Utah Computer
|
|
|
|
* Science Department.
|
|
|
|
*
|
|
|
|
* 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.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
|
|
|
*
|
|
|
|
* from: Utah $Hdr: grf_machdep.c 1.1 92/01/21
|
|
|
|
*
|
|
|
|
* @(#)grf_machdep.c 8.2 (Berkeley) 1/12/94
|
|
|
|
*/
|
1996-05-05 16:17:03 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Graphics display driver for the HP300/400 DIO/DIO-II based machines.
|
|
|
|
* This is the hardware-dependent configuration portion of the driver.
|
|
|
|
*/
|
|
|
|
|
2003-07-15 05:44:50 +04:00
|
|
|
#include <sys/cdefs.h>
|
2012-10-27 21:17:22 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: grf_machdep.c,v 1.32 2012/10/27 17:18:13 chs Exp $");
|
2005-01-18 10:27:20 +03:00
|
|
|
|
|
|
|
#include "locators.h"
|
2003-07-15 05:44:50 +04:00
|
|
|
|
1996-05-05 16:17:03 +04:00
|
|
|
#include <sys/param.h>
|
1996-05-21 19:31:55 +04:00
|
|
|
#include <sys/systm.h>
|
1996-05-05 16:17:03 +04:00
|
|
|
#include <sys/device.h>
|
|
|
|
|
2009-01-17 12:20:46 +03:00
|
|
|
#include <machine/autoconf.h>
|
1998-08-06 18:08:53 +04:00
|
|
|
#include <machine/grfioctl.h>
|
1996-05-05 16:17:03 +04:00
|
|
|
#include <x68k/dev/grfvar.h>
|
|
|
|
#include <x68k/x68k/iodevice.h>
|
|
|
|
|
2004-01-25 16:17:00 +03:00
|
|
|
/* grfbus: is this necessary? */
|
2012-10-27 21:17:22 +04:00
|
|
|
int grfbusprint(void *, const char *);
|
2009-01-17 13:02:23 +03:00
|
|
|
int grfbusmatch(device_t, cfdata_t, void *);
|
|
|
|
void grfbusattach(device_t, device_t, void *);
|
|
|
|
int grfbussearch(device_t, cfdata_t, const int *, void *);
|
1996-05-05 16:17:03 +04:00
|
|
|
|
2004-01-25 16:17:00 +03:00
|
|
|
/* grf itself */
|
2009-01-17 13:02:23 +03:00
|
|
|
int grfmatch(device_t, cfdata_t, void *);
|
|
|
|
void grfattach(device_t, device_t, void *);
|
2004-01-25 16:17:00 +03:00
|
|
|
int grfprint(void *, const char *);
|
1996-05-05 16:17:03 +04:00
|
|
|
|
2009-01-17 13:02:23 +03:00
|
|
|
static int grfinit(struct grf_softc *, int);
|
1997-10-12 18:44:12 +04:00
|
|
|
|
2009-01-17 13:02:23 +03:00
|
|
|
CFATTACH_DECL_NEW(grfbus, 0,
|
2002-10-02 20:02:08 +04:00
|
|
|
grfbusmatch, grfbusattach, NULL, NULL);
|
1996-05-05 16:17:03 +04:00
|
|
|
|
2009-01-17 13:02:23 +03:00
|
|
|
CFATTACH_DECL_NEW(grf, sizeof(struct grf_softc),
|
2002-10-02 20:02:08 +04:00
|
|
|
grfmatch, grfattach, NULL, NULL);
|
1996-05-05 16:17:03 +04:00
|
|
|
|
1998-01-12 23:52:29 +03:00
|
|
|
extern struct cfdriver grfbus_cd;
|
|
|
|
|
1996-05-05 16:17:03 +04:00
|
|
|
int
|
2012-10-13 10:43:00 +04:00
|
|
|
grfbusmatch(device_t parent, cfdata_t cf, void *aux)
|
1996-05-05 16:17:03 +04:00
|
|
|
{
|
2012-10-13 10:43:00 +04:00
|
|
|
if (strcmp(aux, grfbus_cd.cd_name))
|
2005-01-18 10:27:20 +03:00
|
|
|
return (0);
|
1996-05-05 16:17:03 +04:00
|
|
|
|
2005-01-18 10:27:20 +03:00
|
|
|
return (1);
|
1996-05-05 16:17:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-10-13 10:43:00 +04:00
|
|
|
grfbusattach(device_t parent, device_t self, void *aux)
|
1996-05-05 16:17:03 +04:00
|
|
|
{
|
2009-01-17 12:20:46 +03:00
|
|
|
|
2009-01-17 13:02:23 +03:00
|
|
|
aprint_normal("\n");
|
2012-10-13 10:43:00 +04:00
|
|
|
config_search_ia(grfbussearch, self, "grfb", NULL);
|
1996-05-05 16:17:03 +04:00
|
|
|
}
|
|
|
|
|
1996-12-09 19:12:19 +03:00
|
|
|
int
|
2012-10-13 10:43:00 +04:00
|
|
|
grfbussearch(device_t self, cfdata_t match, const int *ldesc, void *aux)
|
1996-05-05 16:17:03 +04:00
|
|
|
{
|
2005-01-18 10:12:15 +03:00
|
|
|
|
2012-10-13 10:43:00 +04:00
|
|
|
config_found(self, &match->cf_loc[GRFBCF_ADDR], grfbusprint);
|
1996-12-09 19:12:19 +03:00
|
|
|
return (0);
|
1996-05-05 16:17:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-10-13 10:43:00 +04:00
|
|
|
grfbusprint(void *aux, const char *name)
|
1996-05-05 16:17:03 +04:00
|
|
|
{
|
2005-01-18 10:12:15 +03:00
|
|
|
|
|
|
|
if (name == NULL)
|
2005-01-18 10:27:20 +03:00
|
|
|
return (UNCONF);
|
|
|
|
return (QUIET);
|
1996-05-05 16:17:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Normal init routine called by configure() code
|
|
|
|
*/
|
|
|
|
int
|
2009-01-17 13:02:23 +03:00
|
|
|
grfmatch(device_t parent, cfdata_t cfp, void *aux)
|
1996-05-05 16:17:03 +04:00
|
|
|
{
|
2005-01-18 10:27:20 +03:00
|
|
|
int addr;
|
|
|
|
|
|
|
|
addr = cfp->cf_loc[GRFBCF_ADDR];
|
|
|
|
if (addr < 0 || addr > ngrfsw)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
1996-05-05 16:17:03 +04:00
|
|
|
}
|
|
|
|
|
2009-01-17 12:20:46 +03:00
|
|
|
struct grf_softc congrf;
|
2004-01-25 16:17:00 +03:00
|
|
|
|
1996-05-05 16:17:03 +04:00
|
|
|
void
|
2012-10-13 10:43:00 +04:00
|
|
|
grfattach(device_t parent, device_t self, void *aux)
|
1996-05-05 16:17:03 +04:00
|
|
|
{
|
|
|
|
struct grf_softc *gp;
|
2005-01-18 10:27:20 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
int addr;
|
1996-05-05 16:17:03 +04:00
|
|
|
|
2012-10-13 10:43:00 +04:00
|
|
|
cf = device_cfdata(self);
|
2005-01-18 10:27:20 +03:00
|
|
|
addr = cf->cf_loc[GRFBCF_ADDR];
|
2004-01-25 16:17:00 +03:00
|
|
|
|
2012-10-13 10:43:00 +04:00
|
|
|
gp = device_private(self);
|
|
|
|
gp->g_device = self;
|
2005-01-18 10:27:20 +03:00
|
|
|
gp->g_cfaddr = addr;
|
2009-01-17 13:02:23 +03:00
|
|
|
grfinit(gp, addr);
|
|
|
|
|
|
|
|
aprint_normal(": %d x %d ",
|
|
|
|
gp->g_display.gd_dwidth, gp->g_display.gd_dheight);
|
1996-05-05 16:17:03 +04:00
|
|
|
if (gp->g_display.gd_colors == 2)
|
2009-01-17 13:02:23 +03:00
|
|
|
aprint_normal("monochrome");
|
1996-05-05 16:17:03 +04:00
|
|
|
else
|
2009-01-17 13:02:23 +03:00
|
|
|
aprint_normal("%d colors", gp->g_display.gd_colors);
|
|
|
|
aprint_normal(" %s display\n", gp->g_sw->gd_desc);
|
1996-05-05 16:17:03 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* try and attach an ite
|
|
|
|
*/
|
2012-10-13 10:43:00 +04:00
|
|
|
config_found(self, gp, grfprint);
|
1996-05-05 16:17:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-10-13 10:43:00 +04:00
|
|
|
grfprint(void *aux, const char *pnp)
|
1996-05-05 16:17:03 +04:00
|
|
|
{
|
2005-01-18 10:27:20 +03:00
|
|
|
|
|
|
|
if (pnp)
|
2003-01-01 05:31:13 +03:00
|
|
|
aprint_normal("ite at %s", pnp);
|
2004-01-25 16:17:00 +03:00
|
|
|
return UNCONF;
|
1996-05-05 16:17:03 +04:00
|
|
|
}
|
|
|
|
|
1996-05-21 19:31:55 +04:00
|
|
|
int
|
2009-01-17 13:02:23 +03:00
|
|
|
grfinit(struct grf_softc *gp, int cfaddr)
|
1996-05-05 16:17:03 +04:00
|
|
|
{
|
2005-01-18 10:12:15 +03:00
|
|
|
struct grfsw *gsw;
|
2007-03-04 08:59:00 +03:00
|
|
|
void *addr;
|
1997-01-19 09:37:47 +03:00
|
|
|
|
2005-01-18 10:27:20 +03:00
|
|
|
if (cfaddr == 0)
|
2007-03-04 08:59:00 +03:00
|
|
|
addr = (void *)__UNVOLATILE(IODEVbase->tvram);
|
1997-01-19 09:37:47 +03:00
|
|
|
else
|
2007-03-04 08:59:00 +03:00
|
|
|
addr = (void *)__UNVOLATILE(IODEVbase->gvram);
|
1996-05-05 16:17:03 +04:00
|
|
|
|
2005-01-18 10:27:20 +03:00
|
|
|
gsw = &grfsw[cfaddr];
|
1996-05-05 16:17:03 +04:00
|
|
|
if (gsw < &grfsw[ngrfsw] && (*gsw->gd_init)(gp, addr)) {
|
|
|
|
gp->g_sw = gsw;
|
|
|
|
gp->g_display.gd_id = gsw->gd_swid;
|
|
|
|
gp->g_flags = GF_ALIVE;
|
2004-01-25 16:17:00 +03:00
|
|
|
return 1;
|
1996-05-05 16:17:03 +04:00
|
|
|
}
|
2004-01-25 16:17:00 +03:00
|
|
|
|
|
|
|
return 0;
|
1996-05-05 16:17:03 +04:00
|
|
|
}
|
2009-01-17 12:20:46 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
grf_config_console(void)
|
|
|
|
{
|
|
|
|
grfinit(&congrf, 0);
|
|
|
|
}
|