Home | History | Annotate | Line # | Download | only in isa
vga_isa.c revision 1.15.6.2
      1  1.15.6.1     skrll /* $NetBSD: vga_isa.c,v 1.15.6.2 2004/09/21 13:29:49 skrll Exp $ */
      2       1.1  drochner 
      3       1.1  drochner /*
      4       1.1  drochner  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      5       1.1  drochner  * All rights reserved.
      6       1.1  drochner  *
      7       1.1  drochner  * Author: Chris G. Demetriou
      8       1.1  drochner  *
      9       1.1  drochner  * Permission to use, copy, modify and distribute this software and
     10       1.1  drochner  * its documentation is hereby granted, provided that both the copyright
     11       1.1  drochner  * notice and this permission notice appear in all copies of the
     12       1.1  drochner  * software, derivative works or modified versions, and any portions
     13       1.1  drochner  * thereof, and that both notices appear in supporting documentation.
     14       1.1  drochner  *
     15       1.1  drochner  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16       1.1  drochner  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17       1.1  drochner  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18       1.1  drochner  *
     19       1.1  drochner  * Carnegie Mellon requests users of this software to return to
     20       1.1  drochner  *
     21       1.1  drochner  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22       1.1  drochner  *  School of Computer Science
     23       1.1  drochner  *  Carnegie Mellon University
     24       1.1  drochner  *  Pittsburgh PA 15213-3890
     25       1.1  drochner  *
     26       1.1  drochner  * any improvements or extensions that they make and grant Carnegie the
     27       1.1  drochner  * rights to redistribute these changes.
     28       1.1  drochner  */
     29       1.6     lukem 
     30       1.6     lukem #include <sys/cdefs.h>
     31  1.15.6.1     skrll __KERNEL_RCSID(0, "$NetBSD: vga_isa.c,v 1.15.6.2 2004/09/21 13:29:49 skrll Exp $");
     32       1.1  drochner 
     33       1.1  drochner #include <sys/param.h>
     34       1.1  drochner #include <sys/systm.h>
     35       1.1  drochner #include <sys/kernel.h>
     36       1.1  drochner #include <sys/device.h>
     37       1.1  drochner #include <sys/malloc.h>
     38       1.1  drochner 
     39       1.1  drochner #include <dev/isa/isavar.h>
     40       1.1  drochner 
     41       1.2  drochner #include <dev/ic/mc6845reg.h>
     42       1.2  drochner #include <dev/ic/pcdisplayvar.h>
     43       1.1  drochner #include <dev/ic/vgareg.h>
     44       1.1  drochner #include <dev/ic/vgavar.h>
     45       1.1  drochner #include <dev/isa/vga_isavar.h>
     46       1.1  drochner 
     47       1.1  drochner #include <dev/wscons/wsconsio.h>
     48       1.1  drochner #include <dev/wscons/wsdisplayvar.h>
     49       1.1  drochner 
     50      1.12  junyoung int	vga_isa_match(struct device *, struct cfdata *, void *);
     51      1.12  junyoung void	vga_isa_attach(struct device *, struct device *, void *);
     52       1.1  drochner 
     53      1.15   thorpej CFATTACH_DECL(vga_isa, sizeof(struct vga_softc),
     54      1.15   thorpej     vga_isa_match, vga_isa_attach, NULL, NULL);
     55       1.1  drochner 
     56       1.1  drochner int
     57      1.12  junyoung vga_isa_match(struct device *parent, struct cfdata *match, void *aux)
     58       1.1  drochner {
     59       1.1  drochner 	struct isa_attach_args *ia = aux;
     60       1.1  drochner 
     61       1.7   thorpej 	if (ISA_DIRECT_CONFIG(ia))
     62       1.7   thorpej 		return (0);
     63       1.7   thorpej 
     64       1.1  drochner 	/* If values are hardwired to something that they can't be, punt. */
     65       1.7   thorpej 	if (ia->ia_nio < 1 ||
     66  1.15.6.1     skrll 	    (ia->ia_io[0].ir_addr != ISA_UNKNOWN_PORT &&
     67       1.7   thorpej 	     ia->ia_io[0].ir_addr != 0x3b0))
     68       1.7   thorpej 		return (0);
     69       1.7   thorpej 
     70       1.7   thorpej 	if (ia->ia_niomem < 1 ||
     71  1.15.6.1     skrll 	    (ia->ia_iomem[0].ir_addr != ISA_UNKNOWN_IOMEM &&
     72       1.7   thorpej 	     ia->ia_iomem[0].ir_addr != 0xa0000))
     73       1.7   thorpej 		return (0);
     74       1.7   thorpej 	if (ia->ia_iomem[0].ir_size != 0 &&
     75       1.7   thorpej 	    ia->ia_iomem[0].ir_size != 0x20000)
     76       1.7   thorpej 		return (0);
     77       1.7   thorpej 
     78       1.7   thorpej 	if (ia->ia_nirq > 0 &&
     79  1.15.6.1     skrll 	    ia->ia_irq[0].ir_irq != ISA_UNKNOWN_IRQ)
     80       1.7   thorpej 		return (0);
     81       1.7   thorpej 
     82       1.7   thorpej 	if (ia->ia_ndrq > 0 &&
     83  1.15.6.1     skrll 	    ia->ia_drq[0].ir_drq != ISA_UNKNOWN_DRQ)
     84       1.1  drochner 		return (0);
     85       1.1  drochner 
     86       1.3  drochner 	if (!vga_is_console(ia->ia_iot, WSDISPLAY_TYPE_ISAVGA) &&
     87       1.3  drochner 	    !vga_common_probe(ia->ia_iot, ia->ia_memt))
     88       1.3  drochner 		return (0);
     89       1.3  drochner 
     90       1.7   thorpej 	ia->ia_nio = 1;
     91       1.7   thorpej 	ia->ia_io[0].ir_addr = 0x3b0;	/* XXX mono 0x3b0 color 0x3c0 */
     92       1.7   thorpej 	ia->ia_io[0].ir_size = 0x30;	/* XXX 0x20 */
     93       1.7   thorpej 
     94       1.7   thorpej 	ia->ia_niomem = 1;
     95       1.7   thorpej 	ia->ia_iomem[0].ir_addr = 0xa0000;
     96       1.7   thorpej 	ia->ia_iomem[0].ir_size = 0x20000;
     97       1.7   thorpej 
     98       1.7   thorpej 	ia->ia_nirq = 0;
     99       1.7   thorpej 	ia->ia_ndrq = 0;
    100       1.7   thorpej 
    101       1.3  drochner 	return (2);	/* more than generic pcdisplay */
    102       1.1  drochner }
    103       1.1  drochner 
    104       1.1  drochner void
    105      1.12  junyoung vga_isa_attach(struct device *parent, struct device *self, void *aux)
    106       1.1  drochner {
    107       1.5   thorpej 	struct vga_softc *sc = (void *) self;
    108       1.1  drochner 	struct isa_attach_args *ia = aux;
    109       1.1  drochner 
    110       1.1  drochner 	printf("\n");
    111       1.1  drochner 
    112       1.5   thorpej 	vga_common_attach(sc, ia->ia_iot, ia->ia_memt, WSDISPLAY_TYPE_ISAVGA,
    113      1.11  drochner 	    0, NULL);
    114       1.1  drochner }
    115       1.1  drochner 
    116       1.1  drochner int
    117      1.12  junyoung vga_isa_cnattach(bus_space_tag_t iot, bus_space_tag_t memt)
    118       1.1  drochner {
    119       1.9    simonb 
    120       1.1  drochner 	return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_ISAVGA, 1));
    121       1.1  drochner }
    122