The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/sbus/cgthree_sbus.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: cgthree_sbus.c,v 1.14 2004/03/17 17:04:58 pk Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Paul Kranenburg.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *        This product includes software developed by the NetBSD
   21  *        Foundation, Inc. and its contributors.
   22  * 4. Neither the name of The NetBSD Foundation nor the names of its
   23  *    contributors may be used to endorse or promote products derived
   24  *    from this software without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36  * POSSIBILITY OF SUCH DAMAGE.
   37  */
   38 
   39 /*
   40  * Copyright (c) 1992, 1993
   41  *      The Regents of the University of California.  All rights reserved.
   42  *
   43  * This software was developed by the Computer Systems Engineering group
   44  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
   45  * contributed to Berkeley.
   46  *
   47  * All advertising materials mentioning features or use of this software
   48  * must display the following acknowledgement:
   49  *      This product includes software developed by the University of
   50  *      California, Lawrence Berkeley Laboratory.
   51  *
   52  * Redistribution and use in source and binary forms, with or without
   53  * modification, are permitted provided that the following conditions
   54  * are met:
   55  * 1. Redistributions of source code must retain the above copyright
   56  *    notice, this list of conditions and the following disclaimer.
   57  * 2. Redistributions in binary form must reproduce the above copyright
   58  *    notice, this list of conditions and the following disclaimer in the
   59  *    documentation and/or other materials provided with the distribution.
   60  * 3. Neither the name of the University nor the names of its contributors
   61  *    may be used to endorse or promote products derived from this software
   62  *    without specific prior written permission.
   63  *
   64  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   65  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   66  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   67  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   68  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   69  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   70  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   71  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   72  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   73  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   74  * SUCH DAMAGE.
   75  *
   76  *      @(#)cgthree.c   8.2 (Berkeley) 10/30/93
   77  */
   78 
   79 /*
   80  * color display (cgthree) driver.
   81  *
   82  * Does not handle interrupts, even though they can occur.
   83  *
   84  * XXX should defer colormap updates to vertical retrace interrupts
   85  */
   86 
   87 #include <sys/cdefs.h>
   88 __KERNEL_RCSID(0, "$NetBSD: cgthree_sbus.c,v 1.14 2004/03/17 17:04:58 pk Exp $");
   89 
   90 #include <sys/param.h>
   91 #include <sys/systm.h>
   92 #include <sys/buf.h>
   93 #include <sys/device.h>
   94 #include <sys/ioctl.h>
   95 #include <sys/malloc.h>
   96 #include <sys/mman.h>
   97 #include <sys/tty.h>
   98 #include <sys/conf.h>
   99 
  100 #include <machine/bus.h>
  101 #include <machine/autoconf.h>
  102 
  103 #include <dev/sun/fbio.h>
  104 #include <dev/sun/fbvar.h>
  105 
  106 #include <dev/sun/btreg.h>
  107 #include <dev/sun/btvar.h>
  108 #include <dev/sun/cgthreereg.h>
  109 #include <dev/sun/cgthreevar.h>
  110 
  111 #include <dev/sbus/sbusvar.h>
  112 
  113 /* Allocate an `sbusdev' in addition to the cgthree softc */
  114 struct cgthree_sbus_softc {
  115         struct cgthree_softc bss_softc;
  116         struct sbusdev bss_sd;
  117 };
  118 
  119 
  120 /* autoconfiguration driver */
  121 static int      cgthreematch_sbus(struct device *, struct cfdata *, void *);
  122 static void     cgthreeattach_sbus(struct device *, struct device *, void *);
  123 
  124 CFATTACH_DECL(cgthree_sbus, sizeof(struct cgthree_softc),
  125     cgthreematch_sbus, cgthreeattach_sbus, NULL, NULL);
  126 
  127 /*
  128  * Match a cgthree.
  129  */
  130 int
  131 cgthreematch_sbus(parent, cf, aux)
  132         struct device *parent;
  133         struct cfdata *cf;
  134         void *aux;
  135 {
  136         struct sbus_attach_args *sa = aux;
  137 
  138         return (strcmp(cf->cf_name, sa->sa_name) == 0);
  139 }
  140 
  141 /*
  142  * Attach a display.  We need to notice if it is the console, too.
  143  */
  144 void
  145 cgthreeattach_sbus(parent, self, args)
  146         struct device *parent, *self;
  147         void *args;
  148 {
  149         struct cgthree_softc *sc = (struct cgthree_softc *)self;
  150         struct sbusdev *sd = &((struct cgthree_sbus_softc *)self)->bss_sd;
  151         struct sbus_attach_args *sa = args;
  152         struct fbdevice *fb = &sc->sc_fb;
  153         int node = sa->sa_node;
  154         int isconsole;
  155         char *name;
  156         bus_space_handle_t bh;
  157 
  158         /* Remember cookies for cgthree_mmap() */
  159         sc->sc_bustag = sa->sa_bustag;
  160         sc->sc_paddr = sbus_bus_addr(sa->sa_bustag, sa->sa_slot, sa->sa_offset);
  161 
  162         fb->fb_device = &sc->sc_dev;
  163         fb->fb_flags = sc->sc_dev.dv_cfdata->cf_flags & FB_USERMASK;
  164         fb->fb_type.fb_type = FBTYPE_SUN3COLOR;
  165 
  166         fb->fb_type.fb_depth = 8;
  167         fb_setsize_obp(fb, fb->fb_type.fb_depth, 1152, 900, node);
  168 
  169         /*
  170          * When the ROM has mapped in a cgthree display, the address
  171          * maps only the video RAM, so in any case we have to map the
  172          * registers ourselves.  We only need the video RAM if we are
  173          * going to print characters via rconsole.
  174          */
  175         if (sbus_bus_map(sa->sa_bustag,
  176                          sa->sa_slot,
  177                          sa->sa_offset + CG3REG_REG,
  178                          sizeof(struct fbcontrol),
  179                          BUS_SPACE_MAP_LINEAR, &bh) != 0) {
  180                 printf("%s: cannot map control registers\n", self->dv_xname);
  181                 return;
  182         }
  183         sc->sc_fbc = (struct fbcontrol *)bus_space_vaddr(sa->sa_bustag, bh);
  184 
  185         isconsole = fb_is_console(node);
  186         name = prom_getpropstring(node, "model");
  187         if (name == NULL)
  188                 name = "cgthree";
  189 
  190         if (sa->sa_npromvaddrs != 0)
  191                 fb->fb_pixels = (caddr_t)(u_long)sa->sa_promvaddrs[0];
  192         if (isconsole && fb->fb_pixels == NULL) {
  193                 int ramsize = fb->fb_type.fb_height * fb->fb_linebytes;
  194                 if (sbus_bus_map(sa->sa_bustag,
  195                                  sa->sa_slot,
  196                                  sa->sa_offset + CG3REG_MEM,
  197                                  ramsize,
  198                                  BUS_SPACE_MAP_LINEAR, &bh) != 0) {
  199                         printf("%s: cannot map pixels\n", self->dv_xname);
  200                         return;
  201                 }
  202                 fb->fb_pixels = (char *)bus_space_vaddr(sa->sa_bustag, bh);
  203         }
  204 
  205         sbus_establish(sd, &sc->sc_dev);
  206         cgthreeattach(sc, name, isconsole);
  207 }

Cache object: 6d8f5680b23144ab5c693968d4de7cb7


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.