No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / evbmips / gdium / gdium_genfb.c
blobdefb5cfe87132eb2a84401fafeab46ccabc9a7e7
1 /* $NetBSD: gdium_genfb.c,v 1.2 2009/08/06 16:37:01 matt Exp $ */
3 /*
4 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved.
7 * Author: Chris G. Demetriou
8 *
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 * Carnegie Mellon requests users of this software to return to
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: gdium_genfb.c,v 1.2 2009/08/06 16:37:01 matt Exp $");
33 #include <sys/param.h>
34 #include <sys/buf.h>
35 #include <sys/conf.h>
36 #include <sys/device.h>
37 #include <sys/ioctl.h>
38 #include <sys/kernel.h>
39 #include <sys/malloc.h>
40 #include <sys/systm.h>
42 #include <machine/bus.h>
44 #include <dev/wscons/wsconsio.h>
45 #include <dev/wscons/wsdisplayvar.h>
46 #include <dev/rasops/rasops.h>
47 #include <dev/wsfont/wsfont.h>
48 #include <dev/wscons/wsdisplay_vconsvar.h>
50 #include <mips/bonito/bonitoreg.h>
51 #include <evbmips/gdium/gdiumvar.h>
52 #include <dev/pci/pcireg.h>
53 #include <dev/pci/pcivar.h>
55 #include "wsdisplay.h"
57 /* we need a wsdisplay to do anything halfway useful */
58 #if NWSDISPLAY > 0
60 static struct vcons_screen gdium_console_screen;
62 static struct wsscreen_descr gdium_stdscreen = {
63 .name = "std",
66 int
67 gdium_cnattach(struct gdium_config *gc)
69 struct rasops_info * const ri = &gdium_console_screen.scr_ri;
70 long defattr;
71 pcireg_t reg;
73 wsfont_init();
75 /* set up rasops */
76 ri->ri_width = 1024;
77 ri->ri_height = 600;
78 ri->ri_depth = 16;
79 ri->ri_stride = 0x800;
81 /* read the mapping register for the frame buffer */
82 reg = pci_conf_read(&gc->gc_pc, pci_make_tag(&gc->gc_pc, 0, 14, 0),
83 PCI_MAPREG_START);
85 ri->ri_bits = (char *)MIPS_PHYS_TO_KSEG1(BONITO_PCILO_BASE + reg);
86 ri->ri_flg = RI_CENTER;
88 memset(ri->ri_bits, 0, 0x200000);
90 /* use as much of the screen as the font permits */
91 rasops_init(ri, 30, 80);
93 rasops_reconfig(ri, ri->ri_height / ri->ri_font->fontheight,
94 ri->ri_width / ri->ri_font->fontwidth);
96 gdium_stdscreen.nrows = ri->ri_rows;
97 gdium_stdscreen.ncols = ri->ri_cols;
98 gdium_stdscreen.textops = &ri->ri_ops;
99 gdium_stdscreen.capabilities = ri->ri_caps;
101 ri->ri_ops.allocattr(ri, 0, ri->ri_rows - 1, 0, &defattr);
103 wsdisplay_preattach(&gdium_stdscreen, ri, 0, 0, defattr);
105 return 0;
107 #else /* NWSDISPLAY > 0 */
109 gdium_cnattach(struct gdium_config *gc)
111 return -1;
113 #endif