Home | History | Annotate | Line # | Download | only in isa
isa.c revision 1.59
      1  1.59  mycroft /*	$NetBSD: isa.c,v 1.59 1994/11/03 23:53:19 mycroft Exp $	*/
      2  1.58      cgd 
      3   1.1      cgd /*-
      4  1.59  mycroft  * Copyright (c) 1993, 1994 Charles Hannum.  All rights reserved.
      5   1.1      cgd  *
      6   1.1      cgd  * Redistribution and use in source and binary forms, with or without
      7   1.1      cgd  * modification, are permitted provided that the following conditions
      8   1.1      cgd  * are met:
      9   1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     10   1.1      cgd  *    notice, this list of conditions and the following disclaimer.
     11   1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     12   1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     13   1.1      cgd  *    documentation and/or other materials provided with the distribution.
     14   1.1      cgd  * 3. All advertising materials mentioning features or use of this software
     15   1.1      cgd  *    must display the following acknowledgement:
     16  1.59  mycroft  *	This product includes software developed by Charles Hannum.
     17  1.59  mycroft  * 4. The name of the author may not be used to endorse or promote products
     18  1.59  mycroft  *    derived from this software without specific prior written permission.
     19   1.1      cgd  *
     20  1.59  mycroft  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  1.59  mycroft  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  1.59  mycroft  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  1.59  mycroft  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  1.59  mycroft  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  1.59  mycroft  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  1.59  mycroft  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  1.59  mycroft  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  1.59  mycroft  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  1.59  mycroft  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30   1.1      cgd  */
     31   1.1      cgd 
     32  1.31  mycroft #include <sys/param.h>
     33  1.31  mycroft #include <sys/systm.h>
     34  1.40  mycroft #include <sys/kernel.h>
     35  1.31  mycroft #include <sys/conf.h>
     36  1.31  mycroft #include <sys/malloc.h>
     37  1.46  mycroft #include <sys/device.h>
     38  1.31  mycroft 
     39  1.52  mycroft #include <i386/isa/isareg.h>
     40  1.46  mycroft #include <i386/isa/isavar.h>
     41  1.14  deraadt 
     42  1.14  deraadt /* sorry, has to be here, no place else really suitable */
     43  1.31  mycroft #include <machine/pc/display.h>
     44  1.14  deraadt u_short *Crtat = (u_short *)MONO_BUF;
     45   1.1      cgd 
     46  1.59  mycroft int isamatch __P((struct device *, void *, void *));
     47  1.59  mycroft void isaattach __P((struct device *, struct device *, void *));
     48  1.46  mycroft 
     49  1.46  mycroft int
     50  1.59  mycroft isamatch(parent, match, aux)
     51  1.46  mycroft 	struct device *parent;
     52  1.59  mycroft 	void *match, *aux;
     53  1.46  mycroft {
     54  1.46  mycroft 
     55  1.59  mycroft 	return (1);
     56  1.46  mycroft }
     57  1.46  mycroft 
     58  1.46  mycroft int
     59  1.46  mycroft isaprint(aux, isa)
     60  1.46  mycroft 	void *aux;
     61  1.46  mycroft 	char *isa;
     62  1.46  mycroft {
     63  1.46  mycroft 	struct isa_attach_args *ia = aux;
     64  1.46  mycroft 
     65  1.46  mycroft 	if (ia->ia_iosize)
     66  1.46  mycroft 		printf(" port 0x%x", ia->ia_iobase);
     67  1.46  mycroft 	if (ia->ia_iosize > 1)
     68  1.46  mycroft 		printf("-0x%x", ia->ia_iobase + ia->ia_iosize - 1);
     69  1.46  mycroft 	if (ia->ia_msize)
     70  1.46  mycroft 		printf(" iomem 0x%x", ia->ia_maddr - atdevbase + 0xa0000);
     71  1.46  mycroft 	if (ia->ia_msize > 1)
     72  1.46  mycroft 		printf("-0x%x",
     73  1.46  mycroft 		    ia->ia_maddr - atdevbase + 0xa0000 + ia->ia_msize - 1);
     74  1.46  mycroft 	if (ia->ia_irq)
     75  1.46  mycroft 		printf(" irq %d", ffs(ia->ia_irq) - 1);
     76  1.46  mycroft 	if (ia->ia_drq != (u_short)-1)
     77  1.46  mycroft 		printf(" drq %d", ia->ia_drq);
     78  1.46  mycroft 	/* XXXX print flags */
     79  1.59  mycroft 	return (QUIET);
     80  1.46  mycroft }
     81  1.46  mycroft 
     82  1.46  mycroft int
     83  1.59  mycroft isasubmatch(parent, match, aux)
     84  1.59  mycroft 	struct device *parent;
     85  1.59  mycroft 	void *match, *aux;
     86  1.46  mycroft {
     87  1.59  mycroft 	struct cfdata *cf = self->dv_cfdata;
     88  1.46  mycroft 	struct isa_attach_args ia;
     89  1.46  mycroft 
     90  1.59  mycroft 	ia.ia_iobase = cf->cf_loc[0];
     91  1.46  mycroft 	ia.ia_iosize = 0x666;
     92  1.59  mycroft 	ia.ia_maddr = cf->cf_loc[2] - 0xa0000 + atdevbase;
     93  1.59  mycroft 	ia.ia_msize = cf->cf_loc[3];
     94  1.59  mycroft 	ia.ia_irq = cf->cf_loc[4];
     95  1.59  mycroft 	ia.ia_drq = cf->cf_loc[5];
     96  1.46  mycroft 
     97  1.59  mycroft 	if ((*id->id_driver->cd_match)(parent, match, &ia) <= 0) {
     98  1.46  mycroft 		/*
     99  1.59  mycroft 		 * If we don't do this, isaattach() will repeatedly try to
    100  1.46  mycroft 		 * probe devices that weren't found.  But we need to be careful
    101  1.46  mycroft 		 * to do it only for the ISA bus, or we would cause things like
    102  1.46  mycroft 		 * `com0 at ast? slave ?' to not probe on the second ast.
    103  1.46  mycroft 		 */
    104  1.59  mycroft 		if (parent->dv_cfdata->cf_driver == &isacd)
    105  1.46  mycroft 			id->id_state = FSTATE_FOUND;
    106  1.59  mycroft 		return (0);
    107  1.46  mycroft 	}
    108  1.46  mycroft 
    109  1.59  mycroft 	config_attach(parent, match, &ia, isaprint);
    110  1.59  mycroft 	return (1);
    111  1.46  mycroft }
    112  1.46  mycroft 
    113  1.21   andrew void
    114  1.59  mycroft isaattach(parent, self, aux)
    115  1.59  mycroft 	struct device *parent, *self;
    116  1.59  mycroft 	void *aux;
    117  1.30  mycroft {
    118  1.55      cgd 
    119  1.59  mycroft 	while (config_search(isasubmatch, self, NULL));
    120   1.1      cgd }
    121