1994-11-04 03:53:06 +03:00
|
|
|
/* $NetBSD: isa.c,v 1.61 1994/11/04 00:53:06 mycroft Exp $ */
|
1994-10-27 07:14:23 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*-
|
1994-11-04 02:53:19 +03:00
|
|
|
* Copyright (c) 1993, 1994 Charles Hannum. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1994-11-04 02:53:19 +03:00
|
|
|
* This product includes software developed by Charles Hannum.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
1994-11-04 02:53:19 +03:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1994-03-06 20:37:56 +03:00
|
|
|
#include <sys/kernel.h>
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/malloc.h>
|
1994-03-29 08:34:18 +04:00
|
|
|
#include <sys/device.h>
|
1993-12-20 12:05:17 +03:00
|
|
|
|
1994-04-24 05:34:05 +04:00
|
|
|
#include <i386/isa/isareg.h>
|
1994-03-29 08:34:18 +04:00
|
|
|
#include <i386/isa/isavar.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-05-28 13:10:52 +04:00
|
|
|
/* sorry, has to be here, no place else really suitable */
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <machine/pc/display.h>
|
1993-05-28 13:10:52 +04:00
|
|
|
u_short *Crtat = (u_short *)MONO_BUF;
|
|
|
|
|
1994-11-04 02:53:19 +03:00
|
|
|
int isamatch __P((struct device *, void *, void *));
|
|
|
|
void isaattach __P((struct device *, struct device *, void *));
|
1994-03-29 08:34:18 +04:00
|
|
|
|
1994-11-04 03:07:39 +03:00
|
|
|
struct cfdriver isacd = {
|
|
|
|
NULL, "isa", isamatch, isaattach, DV_DULL, sizeof(struct device), 1
|
|
|
|
};
|
|
|
|
|
1994-03-29 08:34:18 +04:00
|
|
|
int
|
1994-11-04 02:53:19 +03:00
|
|
|
isamatch(parent, match, aux)
|
1994-03-29 08:34:18 +04:00
|
|
|
struct device *parent;
|
1994-11-04 02:53:19 +03:00
|
|
|
void *match, *aux;
|
1994-03-29 08:34:18 +04:00
|
|
|
{
|
|
|
|
|
1994-11-04 02:53:19 +03:00
|
|
|
return (1);
|
1994-03-29 08:34:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
isaprint(aux, isa)
|
|
|
|
void *aux;
|
|
|
|
char *isa;
|
|
|
|
{
|
|
|
|
struct isa_attach_args *ia = aux;
|
|
|
|
|
|
|
|
if (ia->ia_iosize)
|
|
|
|
printf(" port 0x%x", ia->ia_iobase);
|
|
|
|
if (ia->ia_iosize > 1)
|
|
|
|
printf("-0x%x", ia->ia_iobase + ia->ia_iosize - 1);
|
|
|
|
if (ia->ia_msize)
|
|
|
|
printf(" iomem 0x%x", ia->ia_maddr - atdevbase + 0xa0000);
|
|
|
|
if (ia->ia_msize > 1)
|
|
|
|
printf("-0x%x",
|
|
|
|
ia->ia_maddr - atdevbase + 0xa0000 + ia->ia_msize - 1);
|
|
|
|
if (ia->ia_irq)
|
|
|
|
printf(" irq %d", ffs(ia->ia_irq) - 1);
|
|
|
|
if (ia->ia_drq != (u_short)-1)
|
|
|
|
printf(" drq %d", ia->ia_drq);
|
|
|
|
/* XXXX print flags */
|
1994-11-04 02:53:19 +03:00
|
|
|
return (QUIET);
|
1994-03-29 08:34:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1994-11-04 02:53:19 +03:00
|
|
|
isasubmatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
void *match, *aux;
|
1994-03-29 08:34:18 +04:00
|
|
|
{
|
1994-11-04 03:53:06 +03:00
|
|
|
struct device *self = match;
|
1994-11-04 02:53:19 +03:00
|
|
|
struct cfdata *cf = self->dv_cfdata;
|
1994-03-29 08:34:18 +04:00
|
|
|
struct isa_attach_args ia;
|
|
|
|
|
1994-11-04 02:53:19 +03:00
|
|
|
ia.ia_iobase = cf->cf_loc[0];
|
1994-03-29 08:34:18 +04:00
|
|
|
ia.ia_iosize = 0x666;
|
1994-11-04 02:53:19 +03:00
|
|
|
ia.ia_maddr = cf->cf_loc[2] - 0xa0000 + atdevbase;
|
|
|
|
ia.ia_msize = cf->cf_loc[3];
|
|
|
|
ia.ia_irq = cf->cf_loc[4];
|
|
|
|
ia.ia_drq = cf->cf_loc[5];
|
1994-03-29 08:34:18 +04:00
|
|
|
|
1994-11-04 03:53:06 +03:00
|
|
|
if ((*cf->cf_driver->cd_match)(parent, match, &ia) <= 0) {
|
1994-03-29 08:34:18 +04:00
|
|
|
/*
|
1994-11-04 02:53:19 +03:00
|
|
|
* If we don't do this, isaattach() will repeatedly try to
|
1994-03-29 08:34:18 +04:00
|
|
|
* probe devices that weren't found. But we need to be careful
|
|
|
|
* to do it only for the ISA bus, or we would cause things like
|
|
|
|
* `com0 at ast? slave ?' to not probe on the second ast.
|
|
|
|
*/
|
1994-11-04 02:53:19 +03:00
|
|
|
if (parent->dv_cfdata->cf_driver == &isacd)
|
1994-11-04 03:53:06 +03:00
|
|
|
cf->cf_fstate = FSTATE_FOUND;
|
1994-11-04 02:53:19 +03:00
|
|
|
return (0);
|
1994-03-29 08:34:18 +04:00
|
|
|
}
|
|
|
|
|
1994-11-04 02:53:19 +03:00
|
|
|
config_attach(parent, match, &ia, isaprint);
|
|
|
|
return (1);
|
1994-03-29 08:34:18 +04:00
|
|
|
}
|
|
|
|
|
1993-06-27 10:27:29 +04:00
|
|
|
void
|
1994-11-04 02:53:19 +03:00
|
|
|
isaattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
1993-12-17 03:10:06 +03:00
|
|
|
{
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-11-04 02:53:19 +03:00
|
|
|
while (config_search(isasubmatch, self, NULL));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|