gdium_genfb.c revision 1.6
11.6Smatt/* $NetBSD: gdium_genfb.c,v 1.6 2011/07/10 00:03:53 matt Exp $ */ 21.1Smatt 31.1Smatt/* 41.1Smatt * Copyright (c) 1995, 1996 Carnegie-Mellon University. 51.1Smatt * All rights reserved. 61.1Smatt * 71.1Smatt * Author: Chris G. Demetriou 81.1Smatt * 91.1Smatt * Permission to use, copy, modify and distribute this software and 101.1Smatt * its documentation is hereby granted, provided that both the copyright 111.1Smatt * notice and this permission notice appear in all copies of the 121.1Smatt * software, derivative works or modified versions, and any portions 131.1Smatt * thereof, and that both notices appear in supporting documentation. 141.1Smatt * 151.1Smatt * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 161.1Smatt * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 171.1Smatt * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 181.1Smatt * 191.1Smatt * Carnegie Mellon requests users of this software to return to 201.1Smatt * 211.1Smatt * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 221.1Smatt * School of Computer Science 231.1Smatt * Carnegie Mellon University 241.1Smatt * Pittsburgh PA 15213-3890 251.1Smatt * 261.1Smatt * any improvements or extensions that they make and grant Carnegie the 271.1Smatt * rights to redistribute these changes. 281.1Smatt */ 291.1Smatt 301.1Smatt#include <sys/cdefs.h> 311.6Smatt__KERNEL_RCSID(0, "$NetBSD: gdium_genfb.c,v 1.6 2011/07/10 00:03:53 matt Exp $"); 321.1Smatt 331.1Smatt#include <sys/param.h> 341.1Smatt#include <sys/buf.h> 351.6Smatt#include <sys/bus.h> 361.1Smatt#include <sys/conf.h> 371.1Smatt#include <sys/device.h> 381.1Smatt#include <sys/ioctl.h> 391.1Smatt#include <sys/kernel.h> 401.1Smatt#include <sys/malloc.h> 411.1Smatt#include <sys/systm.h> 421.1Smatt 431.1Smatt#include <dev/wscons/wsconsio.h> 441.1Smatt#include <dev/wscons/wsdisplayvar.h> 451.1Smatt#include <dev/rasops/rasops.h> 461.1Smatt#include <dev/wsfont/wsfont.h> 471.1Smatt#include <dev/wscons/wsdisplay_vconsvar.h> 481.1Smatt 491.1Smatt#include <mips/bonito/bonitoreg.h> 501.1Smatt#include <evbmips/gdium/gdiumvar.h> 511.1Smatt#include <dev/pci/pcireg.h> 521.1Smatt#include <dev/pci/pcivar.h> 531.1Smatt 541.1Smatt#include "wsdisplay.h" 551.1Smatt 561.1Smatt/* we need a wsdisplay to do anything halfway useful */ 571.1Smatt#if NWSDISPLAY > 0 581.1Smatt 591.1Smattstatic struct vcons_screen gdium_console_screen; 601.1Smatt 611.1Smattstatic struct wsscreen_descr gdium_stdscreen = { 621.1Smatt .name = "std", 631.1Smatt}; 641.1Smatt 651.1Smattint 661.1Smattgdium_cnattach(struct gdium_config *gc) 671.1Smatt{ 681.1Smatt struct rasops_info * const ri = &gdium_console_screen.scr_ri; 691.1Smatt long defattr; 701.1Smatt pcireg_t reg; 711.1Smatt 721.1Smatt wsfont_init(); 731.1Smatt 741.1Smatt /* set up rasops */ 751.1Smatt ri->ri_width = 1024; 761.1Smatt ri->ri_height = 600; 771.1Smatt ri->ri_depth = 16; 781.1Smatt ri->ri_stride = 0x800; 791.3Smatt 801.1Smatt /* read the mapping register for the frame buffer */ 811.3Smatt reg = pci_conf_read(&gc->gc_pc, pci_make_tag(&gc->gc_pc, 0, 14, 0), 821.3Smatt PCI_MAPREG_START); 831.3Smatt 841.1Smatt ri->ri_bits = (char *)MIPS_PHYS_TO_KSEG1(BONITO_PCILO_BASE + reg); 851.4Smacallan ri->ri_flg = RI_CENTER | RI_NO_AUTO; 861.1Smatt 871.2Smatt memset(ri->ri_bits, 0, 0x200000); 881.2Smatt 891.1Smatt /* use as much of the screen as the font permits */ 901.1Smatt rasops_init(ri, 30, 80); 911.1Smatt 921.1Smatt rasops_reconfig(ri, ri->ri_height / ri->ri_font->fontheight, 931.1Smatt ri->ri_width / ri->ri_font->fontwidth); 941.1Smatt 951.1Smatt gdium_stdscreen.nrows = ri->ri_rows; 961.1Smatt gdium_stdscreen.ncols = ri->ri_cols; 971.1Smatt gdium_stdscreen.textops = &ri->ri_ops; 981.1Smatt gdium_stdscreen.capabilities = ri->ri_caps; 991.1Smatt 1001.2Smatt ri->ri_ops.allocattr(ri, 0, ri->ri_rows - 1, 0, &defattr); 1011.1Smatt 1021.1Smatt wsdisplay_preattach(&gdium_stdscreen, ri, 0, 0, defattr); 1031.1Smatt 1041.1Smatt return 0; 1051.1Smatt} 1061.1Smatt#else /* NWSDISPLAY > 0 */ 1071.1Smattint 1081.2Smattgdium_cnattach(struct gdium_config *gc) 1091.1Smatt{ 1101.1Smatt return -1; 1111.1Smatt} 1121.1Smatt#endif 113