1 /* 2 * Copyright (c) 1991 University of Utah. 3 * Copyright (c) 1990 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the Systems Programming Group of the University of Utah Computer 8 * Science Department. 9 * 10 * %sccs.include.redist.c% 11 * 12 * from: Utah $Hdr: grf_machdep.c 1.1 92/01/21 13 * 14 * @(#)grf_machdep.c 7.1 (Berkeley) 06/05/92 15 */ 16 17 /* 18 * Graphics display driver for the HP300/400 DIO/DIO-II based machines. 19 * This is the hardware-dependent configuration portion of the driver. 20 */ 21 22 #include "grf.h" 23 #if NGRF > 0 24 25 #include "sys/param.h" 26 27 #include "hp/dev/device.h" 28 #include "hp/dev/grfioctl.h" 29 #include "hp/dev/grfvar.h" 30 #include "hp/dev/grfreg.h" 31 32 int grfprobe(); 33 struct driver grfdriver = { grfprobe, "grf" }; 34 35 /* 36 * XXX called from ite console init routine. 37 * Does just what configure will do later but without printing anything. 38 */ 39 grfconfig() 40 { 41 register caddr_t addr; 42 register struct hp_hw *hw; 43 register struct hp_device *hd, *nhd; 44 45 for (hw = sc_table; hw->hw_type; hw++) { 46 if (!HW_ISDEV(hw, D_BITMAP)) 47 continue; 48 /* 49 * Found one, now match up with a logical unit number 50 */ 51 nhd = NULL; 52 addr = hw->hw_kva; 53 for (hd = hp_dinit; hd->hp_driver; hd++) { 54 if (hd->hp_driver != &grfdriver || hd->hp_alive) 55 continue; 56 /* 57 * Wildcarded. If first, remember as possible match. 58 */ 59 if (hd->hp_addr == NULL) { 60 if (nhd == NULL) 61 nhd = hd; 62 continue; 63 } 64 /* 65 * Not wildcarded. 66 * If exact match done searching, else keep looking. 67 */ 68 if (sctova(hd->hp_addr) == addr) { 69 nhd = hd; 70 break; 71 } 72 } 73 /* 74 * Found a match, initialize 75 */ 76 if (nhd && grfinit(addr, nhd->hp_unit)) 77 nhd->hp_addr = addr; 78 } 79 } 80 81 /* 82 * Normal init routine called by configure() code 83 */ 84 grfprobe(hd) 85 struct hp_device *hd; 86 { 87 struct grf_softc *gp = &grf_softc[hd->hp_unit]; 88 89 if ((gp->g_flags & GF_ALIVE) == 0 && 90 !grfinit(hd->hp_addr, hd->hp_unit)) 91 return(0); 92 printf("grf%d: %d x %d ", hd->hp_unit, 93 gp->g_display.gd_dwidth, gp->g_display.gd_dheight); 94 if (gp->g_display.gd_colors == 2) 95 printf("monochrome"); 96 else 97 printf("%d color", gp->g_display.gd_colors); 98 printf(" %s display\n", gp->g_sw->gd_desc); 99 return(1); 100 } 101 102 grfinit(addr, unit) 103 caddr_t addr; 104 { 105 struct grf_softc *gp = &grf_softc[unit]; 106 register struct grfsw *gsw; 107 struct grfreg *gr; 108 109 gr = (struct grfreg *) addr; 110 if (gr->gr_id != GRFHWID) 111 return(0); 112 for (gsw = grfsw; gsw < &grfsw[ngrfsw]; gsw++) 113 if (gsw->gd_hwid == gr->gr_id2) 114 break; 115 if (gsw < &grfsw[ngrfsw] && (*gsw->gd_init)(gp, addr)) { 116 gp->g_sw = gsw; 117 gp->g_display.gd_id = gsw->gd_swid; 118 gp->g_flags = GF_ALIVE; 119 return(1); 120 } 121 return(0); 122 } 123 #endif 124