1 /* $NetBSD: gdium_genfb.c,v 1.4 2010/05/11 01:38:14 macallan Exp $ */ 2 3 /* 4 * Copyright (c) 1995, 1996 Carnegie-Mellon University. 5 * All rights reserved. 6 * 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. 14 * 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. 18 * 19 * Carnegie Mellon requests users of this software to return to 20 * 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 22 * School of Computer Science 23 * Carnegie Mellon University 24 * Pittsburgh PA 15213-3890 25 * 26 * any improvements or extensions that they make and grant Carnegie the 27 * rights to redistribute these changes. 28 */ 29 30 #include <sys/cdefs.h> 31 __KERNEL_RCSID(0, "$NetBSD: gdium_genfb.c,v 1.4 2010/05/11 01:38:14 macallan Exp $"); 32 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> 41 42 #include <machine/bus.h> 43 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> 49 50 #include <mips/bonito/bonitoreg.h> 51 #include <evbmips/gdium/gdiumvar.h> 52 #include <dev/pci/pcireg.h> 53 #include <dev/pci/pcivar.h> 54 55 #include "wsdisplay.h" 56 57 /* we need a wsdisplay to do anything halfway useful */ 58 #if NWSDISPLAY > 0 59 60 static struct vcons_screen gdium_console_screen; 61 62 static struct wsscreen_descr gdium_stdscreen = { 63 .name = "std", 64 }; 65 66 int 67 gdium_cnattach(struct gdium_config *gc) 68 { 69 struct rasops_info * const ri = &gdium_console_screen.scr_ri; 70 long defattr; 71 pcireg_t reg; 72 73 wsfont_init(); 74 75 /* set up rasops */ 76 ri->ri_width = 1024; 77 ri->ri_height = 600; 78 ri->ri_depth = 16; 79 ri->ri_stride = 0x800; 80 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); 84 85 ri->ri_bits = (char *)MIPS_PHYS_TO_KSEG1(BONITO_PCILO_BASE + reg); 86 ri->ri_flg = RI_CENTER | RI_NO_AUTO; 87 88 memset(ri->ri_bits, 0, 0x200000); 89 90 /* use as much of the screen as the font permits */ 91 rasops_init(ri, 30, 80); 92 93 rasops_reconfig(ri, ri->ri_height / ri->ri_font->fontheight, 94 ri->ri_width / ri->ri_font->fontwidth); 95 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; 100 101 ri->ri_ops.allocattr(ri, 0, ri->ri_rows - 1, 0, &defattr); 102 103 wsdisplay_preattach(&gdium_stdscreen, ri, 0, 0, defattr); 104 105 return 0; 106 } 107 #else /* NWSDISPLAY > 0 */ 108 int 109 gdium_cnattach(struct gdium_config *gc) 110 { 111 return -1; 112 } 113 #endif 114