1 /* $OpenBSD: vga_isa.c,v 1.11 2022/04/06 18:59:29 naddy Exp $ */
2 /* $NetBSD: vga_isa.c,v 1.3 1998/06/12 18:45:48 drochner Exp $ */
3
4 /*
5 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
6 * All rights reserved.
7 *
8 * Author: Chris G. Demetriou
9 *
10 * Permission to use, copy, modify and distribute this software and
11 * its documentation is hereby granted, provided that both the copyright
12 * notice and this permission notice appear in all copies of the
13 * software, derivative works or modified versions, and any portions
14 * thereof, and that both notices appear in supporting documentation.
15 *
16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 *
20 * Carnegie Mellon requests users of this software to return to
21 *
22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
26 *
27 * any improvements or extensions that they make and grant Carnegie the
28 * rights to redistribute these changes.
29 */
30
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/kernel.h>
34 #include <sys/device.h>
35 #include <sys/malloc.h>
36
37 #include <dev/isa/isavar.h>
38
39 #include <dev/ic/mc6845reg.h>
40 #include <dev/ic/pcdisplayvar.h>
41 #include <dev/ic/vgareg.h>
42
43 #include <dev/wscons/wsconsio.h>
44 #include <dev/wscons/wsdisplayvar.h>
45
46 #include <dev/ic/vgavar.h>
47 #include <dev/isa/vga_isavar.h>
48
49 struct vga_isa_softc {
50 struct device sc_dev;
51 #if 0
52 struct vga_config *sc_vc; /* VGA configuration */
53 #endif
54 };
55
56 int vga_isa_match(struct device *, void *, void *);
57 void vga_isa_attach(struct device *, struct device *, void *);
58
59 const struct cfattach vga_isa_ca = {
60 sizeof(struct vga_isa_softc), vga_isa_match, vga_isa_attach,
61 };
62
63 int
vga_isa_match(struct device * parent,void * match,void * aux)64 vga_isa_match(struct device *parent, void *match, void *aux)
65 {
66 struct isa_attach_args *ia = aux;
67
68 /* If values are hardwired to something that they can't be, punt. */
69 if ((ia->ia_iobase != IOBASEUNK && ia->ia_iobase != 0x3b0) ||
70 /* ia->ia_iosize != 0 || XXX isa.c */
71 (ia->ia_maddr != MADDRUNK && ia->ia_maddr != 0xa0000) ||
72 (ia->ia_msize != 0 && ia->ia_msize != 0x20000) ||
73 ia->ia_irq != IRQUNK || ia->ia_drq != DRQUNK)
74 return (0);
75
76 if (!vga_is_console(ia->ia_iot, WSDISPLAY_TYPE_ISAVGA) &&
77 !vga_common_probe(ia->ia_iot, ia->ia_memt))
78 return (0);
79
80 ia->ia_iobase = 0x3b0; /* XXX mono 0x3b0 color 0x3c0 */
81 ia->ia_iosize = 0x30; /* XXX 0x20 */
82 ia->ia_maddr = 0xa0000;
83 ia->ia_msize = 0x20000;
84 return (2); /* more than generic pcdisplay */
85 }
86
87 void
vga_isa_attach(struct device * parent,struct device * self,void * aux)88 vga_isa_attach(struct device *parent, struct device *self, void *aux)
89 {
90 struct isa_attach_args *ia = aux;
91 #if 0
92 struct vga_isa_softc *sc = (struct vga_isa_softc *)self;
93 #endif
94
95 printf("\n");
96
97 vga_common_attach(self, ia->ia_iot, ia->ia_memt,
98 WSDISPLAY_TYPE_ISAVGA);
99 }
100
101 int
vga_isa_cnattach(bus_space_tag_t iot,bus_space_tag_t memt)102 vga_isa_cnattach(bus_space_tag_t iot, bus_space_tag_t memt)
103 {
104 return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_ISAVGA, 1));
105 }
106