Home | History | Annotate | Line # | Download | only in isa
isa_machdep.c revision 1.1
      1  1.1  cgd /*	$NetBSD: isa_machdep.c,v 1.1 1995/06/28 01:24:59 cgd Exp $	*/
      2  1.1  cgd 
      3  1.1  cgd /*
      4  1.1  cgd  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
      5  1.1  cgd  * All rights reserved.
      6  1.1  cgd  *
      7  1.1  cgd  * Author: Chris G. Demetriou
      8  1.1  cgd  *
      9  1.1  cgd  * Permission to use, copy, modify and distribute this software and
     10  1.1  cgd  * its documentation is hereby granted, provided that both the copyright
     11  1.1  cgd  * notice and this permission notice appear in all copies of the
     12  1.1  cgd  * software, derivative works or modified versions, and any portions
     13  1.1  cgd  * thereof, and that both notices appear in supporting documentation.
     14  1.1  cgd  *
     15  1.1  cgd  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  1.1  cgd  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17  1.1  cgd  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  1.1  cgd  *
     19  1.1  cgd  * Carnegie Mellon requests users of this software to return to
     20  1.1  cgd  *
     21  1.1  cgd  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22  1.1  cgd  *  School of Computer Science
     23  1.1  cgd  *  Carnegie Mellon University
     24  1.1  cgd  *  Pittsburgh PA 15213-3890
     25  1.1  cgd  *
     26  1.1  cgd  * any improvements or extensions that they make and grant Carnegie the
     27  1.1  cgd  * rights to redistribute these changes.
     28  1.1  cgd  */
     29  1.1  cgd 
     30  1.1  cgd #include <sys/param.h>
     31  1.1  cgd #include <sys/systm.h>
     32  1.1  cgd #include <sys/kernel.h>
     33  1.1  cgd #include <sys/conf.h>
     34  1.1  cgd #include <sys/malloc.h>
     35  1.1  cgd #include <sys/device.h>
     36  1.1  cgd 
     37  1.1  cgd #include <machine/autoconf.h>
     38  1.1  cgd #include <machine/pio.h>
     39  1.1  cgd #include <machine/rpb.h>
     40  1.1  cgd #include <machine/vmparam.h>
     41  1.1  cgd #include <machine/pte.h>
     42  1.1  cgd 
     43  1.1  cgd #include <dev/isa/isareg.h>
     44  1.1  cgd #include <dev/isa/isavar.h>
     45  1.1  cgd #include <dev/isa/isadmavar.h>
     46  1.1  cgd 
     47  1.1  cgd #include <alpha/isa/isa_intr.h>
     48  1.1  cgd #include <alpha/isa/isa_dma.h>
     49  1.1  cgd 
     50  1.1  cgd int isamatch __P((struct device *, void *, void *));
     51  1.1  cgd void isaattach __P((struct device *, struct device *, void *));
     52  1.1  cgd 
     53  1.1  cgd struct cfdriver isacd = {
     54  1.1  cgd 	NULL, "isa", isamatch, isaattach, DV_DULL, sizeof(struct isa_softc), 1
     55  1.1  cgd };
     56  1.1  cgd 
     57  1.1  cgd int
     58  1.1  cgd isamatch(parent, cfdata, aux)
     59  1.1  cgd 	struct device *parent;
     60  1.1  cgd 	void *cfdata, *aux;
     61  1.1  cgd {
     62  1.1  cgd 	struct cfdata *cf = cfdata;
     63  1.1  cgd 	struct confargs *ca = aux;
     64  1.1  cgd 
     65  1.1  cgd #if 0 /* XXX -- Assume that it's valid if unit number OK */
     66  1.1  cgd 	/* It can only occur on the mainbus. */
     67  1.1  cgd 	if (ca->ca_bus->ab_type != BUS_MAIN)
     68  1.1  cgd 		return (0);
     69  1.1  cgd 
     70  1.1  cgd 	/* Make sure that we're looking for this type of device. */
     71  1.1  cgd 	if (!BUS_MATCHNAME(ca, "isa"))
     72  1.1  cgd 		return (0);
     73  1.1  cgd #endif /* XXX */
     74  1.1  cgd 
     75  1.1  cgd 	/* See if the unit number is valid. */
     76  1.1  cgd 	switch (hwrpb->rpb_type) {
     77  1.1  cgd #if defined(DEC_2100_A50)
     78  1.1  cgd 	case ST_DEC_2100_A50:
     79  1.1  cgd 		if (cf->cf_unit > 0)
     80  1.1  cgd 			return (0);
     81  1.1  cgd 		break;
     82  1.1  cgd #endif
     83  1.1  cgd 	default:
     84  1.1  cgd 		return (0);
     85  1.1  cgd 	}
     86  1.1  cgd 
     87  1.1  cgd 	return (1);
     88  1.1  cgd }
     89  1.1  cgd 
     90  1.1  cgd void
     91  1.1  cgd isaattach(parent, self, aux)
     92  1.1  cgd 	struct device *parent, *self;
     93  1.1  cgd 	void *aux;
     94  1.1  cgd {
     95  1.1  cgd 	struct isa_softc *sc = (struct isa_softc *)self;
     96  1.1  cgd 
     97  1.1  cgd 	printf("\n");
     98  1.1  cgd 
     99  1.1  cgd 	TAILQ_INIT(&sc->sc_subdevs);
    100  1.1  cgd 
    101  1.1  cgd 	/* XXX set up ISA DMA controllers? */
    102  1.1  cgd 
    103  1.1  cgd 	config_scan(isascan, self);
    104  1.1  cgd }
    105  1.1  cgd 
    106  1.1  cgd void *
    107  1.1  cgd isa_intr_establish(irq, type, level, ih_fun, ih_arg)
    108  1.1  cgd 	int irq;
    109  1.1  cgd 	isa_intrtype type;
    110  1.1  cgd 	isa_intrlevel level;
    111  1.1  cgd 	int (*ih_fun)(void *);
    112  1.1  cgd 	void *ih_arg;
    113  1.1  cgd {
    114  1.1  cgd 
    115  1.1  cgd 	return (*isa_intr_fcns->isa_intr_establish)(irq, type, level,
    116  1.1  cgd 	    ih_fun, ih_arg);
    117  1.1  cgd }
    118  1.1  cgd 
    119  1.1  cgd void
    120  1.1  cgd isa_intr_disestablish(handler)
    121  1.1  cgd 	void *handler;
    122  1.1  cgd {
    123  1.1  cgd 
    124  1.1  cgd 	(*isa_intr_fcns->isa_intr_disestablish)(handler);
    125  1.1  cgd }
    126  1.1  cgd 
    127  1.1  cgd int
    128  1.1  cgd isadma_map(addr, size, mappings, flags)
    129  1.1  cgd 	caddr_t addr;
    130  1.1  cgd 	vm_size_t size;
    131  1.1  cgd 	vm_offset_t *mappings;
    132  1.1  cgd 	int flags;
    133  1.1  cgd {
    134  1.1  cgd 
    135  1.1  cgd 	(*isadma_fcns->isadma_map)(addr, size, mappings, flags);
    136  1.1  cgd }
    137  1.1  cgd 
    138  1.1  cgd void
    139  1.1  cgd isadma_unmap(addr, size, nmappings, mappings)
    140  1.1  cgd 	caddr_t addr;
    141  1.1  cgd 	vm_size_t size;
    142  1.1  cgd 	int nmappings;
    143  1.1  cgd 	vm_offset_t *mappings;
    144  1.1  cgd {
    145  1.1  cgd 
    146  1.1  cgd 	(*isadma_fcns->isadma_unmap)(addr, size, nmappings, mappings);
    147  1.1  cgd }
    148  1.1  cgd 
    149  1.1  cgd void
    150  1.1  cgd isadma_copytobuf(addr, size, nmappings, mappings)
    151  1.1  cgd 	caddr_t addr;
    152  1.1  cgd 	vm_size_t size;
    153  1.1  cgd 	int nmappings;
    154  1.1  cgd 	vm_offset_t *mappings;
    155  1.1  cgd {
    156  1.1  cgd 
    157  1.1  cgd 	(*isadma_fcns->isadma_copytobuf)(addr, size, nmappings, mappings);
    158  1.1  cgd }
    159  1.1  cgd 
    160  1.1  cgd void
    161  1.1  cgd isadma_copyfrombuf(addr, size, nmappings, mappings)
    162  1.1  cgd 	caddr_t addr;
    163  1.1  cgd 	vm_size_t size;
    164  1.1  cgd 	int nmappings;
    165  1.1  cgd 	vm_offset_t *mappings;
    166  1.1  cgd {
    167  1.1  cgd 
    168  1.1  cgd 	(*isadma_fcns->isadma_copyfrombuf)(addr, size, nmappings, mappings);
    169  1.1  cgd }
    170