BSD-SCCS END release
[unix-history] / usr / src / sys / hp300 / dev / grf_machdep.c
CommitLineData
9acfa6cd
MH
1/*
2 * Copyright (c) 1991 University of Utah.
030a8056
KB
3 * Copyright (c) 1990, 1993
4 * The Regents of the University of California. All rights reserved.
9acfa6cd
MH
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 *
2c0f281d 14 * @(#)grf_machdep.c 8.2 (Berkeley) %G%
9acfa6cd
MH
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
38a01dbe 25#include <sys/param.h>
9acfa6cd 26
38a01dbe
KB
27#include <hp/dev/device.h>
28#include <hp/dev/grfioctl.h>
29#include <hp/dev/grfvar.h>
30#include <hp/dev/grfreg.h>
9acfa6cd
MH
31
32int grfprobe();
33struct 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 */
39grfconfig()
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 */
84grfprobe(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
102grfinit(addr, unit)
103 caddr_t addr;
2c0f281d 104 int unit;
9acfa6cd
MH
105{
106 struct grf_softc *gp = &grf_softc[unit];
107 register struct grfsw *gsw;
108 struct grfreg *gr;
109
110 gr = (struct grfreg *) addr;
111 if (gr->gr_id != GRFHWID)
112 return(0);
113 for (gsw = grfsw; gsw < &grfsw[ngrfsw]; gsw++)
114 if (gsw->gd_hwid == gr->gr_id2)
115 break;
116 if (gsw < &grfsw[ngrfsw] && (*gsw->gd_init)(gp, addr)) {
117 gp->g_sw = gsw;
118 gp->g_display.gd_id = gsw->gd_swid;
119 gp->g_flags = GF_ALIVE;
120 return(1);
121 }
122 return(0);
123}
124#endif