Home | History | Annotate | Line # | Download | only in dev
grf_subr.c revision 1.7
      1  1.7    scottr /*	$NetBSD: grf_subr.c,v 1.7 1997/05/11 19:11:30 scottr Exp $	*/
      2  1.1    scottr 
      3  1.1    scottr /*-
      4  1.1    scottr  * Copyright (c) 1996 The NetBSD Foundation, Inc.
      5  1.1    scottr  * All rights reserved.
      6  1.1    scottr  *
      7  1.1    scottr  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1    scottr  * by Jason R. Thorpe.
      9  1.1    scottr  *
     10  1.1    scottr  * Redistribution and use in source and binary forms, with or without
     11  1.1    scottr  * modification, are permitted provided that the following conditions
     12  1.1    scottr  * are met:
     13  1.1    scottr  * 1. Redistributions of source code must retain the above copyright
     14  1.1    scottr  *    notice, this list of conditions and the following disclaimer.
     15  1.1    scottr  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1    scottr  *    notice, this list of conditions and the following disclaimer in the
     17  1.1    scottr  *    documentation and/or other materials provided with the distribution.
     18  1.1    scottr  * 3. All advertising materials mentioning features or use of this software
     19  1.1    scottr  *    must display the following acknowledgement:
     20  1.1    scottr  *        This product includes software developed by the NetBSD
     21  1.1    scottr  *        Foundation, Inc. and its contributors.
     22  1.1    scottr  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1    scottr  *    contributors may be used to endorse or promote products derived
     24  1.1    scottr  *    from this software without specific prior written permission.
     25  1.1    scottr  *
     26  1.1    scottr  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1    scottr  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1    scottr  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1    scottr  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
     30  1.1    scottr  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1    scottr  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1    scottr  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1    scottr  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1    scottr  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1    scottr  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1    scottr  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1    scottr  */
     38  1.1    scottr 
     39  1.1    scottr #include <sys/param.h>
     40  1.1    scottr #include <sys/device.h>
     41  1.1    scottr #include <sys/systm.h>
     42  1.1    scottr 
     43  1.6    scottr #include <machine/bus.h>
     44  1.1    scottr #include <machine/grfioctl.h>
     45  1.1    scottr 
     46  1.1    scottr #include <mac68k/dev/nubus.h>
     47  1.1    scottr #include <mac68k/dev/grfvar.h>
     48  1.1    scottr 
     49  1.1    scottr void
     50  1.2    scottr grf_establish(sc, sp, g_mode, g_phys)
     51  1.1    scottr 	struct grfbus_softc *sc;
     52  1.2    scottr 	nubus_slot *sp;
     53  1.1    scottr 	int (*g_mode) __P((struct grf_softc *, int, void *));
     54  1.1    scottr 	caddr_t (*g_phys) __P((struct grf_softc *, vm_offset_t));
     55  1.1    scottr {
     56  1.1    scottr 	struct grfmode *gm = &sc->curr_mode;
     57  1.1    scottr 	struct grfbus_attach_args ga;
     58  1.1    scottr 
     59  1.1    scottr 	/* Print hardware characteristics. */
     60  1.5  christos 	printf("%s: %d x %d, ", sc->sc_dev.dv_xname, gm->width, gm->height);
     61  1.1    scottr 	if (gm->psize == 1)
     62  1.5  christos 		printf("monochrome\n");
     63  1.1    scottr 	else
     64  1.5  christos 		printf("%d color\n", 1 << gm->psize);
     65  1.1    scottr 
     66  1.1    scottr 	/* Attach grf semantics to the hardware. */
     67  1.1    scottr 	ga.ga_name = "grf";
     68  1.1    scottr 	ga.ga_grfmode = gm;
     69  1.2    scottr 	ga.ga_slot = sp;
     70  1.7    scottr 	ga.ga_tag = sc->sc_tag;
     71  1.7    scottr 	ga.ga_handle = sc->sc_tag;
     72  1.1    scottr 	ga.ga_mode = g_mode;
     73  1.1    scottr 	ga.ga_phys = g_phys;
     74  1.1    scottr 	(void)config_found(&sc->sc_dev, &ga, grfbusprint);
     75  1.1    scottr }
     76  1.1    scottr 
     77  1.1    scottr int
     78  1.1    scottr grfbusprint(aux, name)
     79  1.1    scottr 	void *aux;
     80  1.3       cgd 	const char *name;
     81  1.1    scottr {
     82  1.1    scottr 	struct grfbus_attach_args *ga = aux;
     83  1.1    scottr 
     84  1.1    scottr 	if (name)
     85  1.5  christos 		printf("%s at %s", ga->ga_name, name);
     86  1.1    scottr 
     87  1.1    scottr 	return (UNCONF);
     88  1.1    scottr }
     89