Pull down from marc-pcmcia branch:
Implement new ISA interface functions: * isa_intr_alloc() - allocate an ISA IRQ * isa_mem_alloc() - allocate ISA memory space * isa_mem_free() - free ISA memory space
This commit is contained in:
parent
be34bc3390
commit
799112abbe
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: isa_machdep.c,v 1.22 1997/06/12 23:57:32 thorpej Exp $ */
|
||||
/* $NetBSD: isa_machdep.c,v 1.23 1997/10/14 20:34:38 thorpej Exp $ */
|
||||
|
||||
#define ISA_DMA_STATS
|
||||
|
||||
|
@ -354,6 +354,79 @@ fakeintr(arg)
|
|||
|
||||
#define LEGAL_IRQ(x) ((x) >= 0 && (x) < ICU_LEN && (x) != 2)
|
||||
|
||||
int
|
||||
isa_intr_alloc(ic, mask, type, irq)
|
||||
isa_chipset_tag_t ic;
|
||||
int mask;
|
||||
int type;
|
||||
int *irq;
|
||||
{
|
||||
int i, tmp, bestirq, count;
|
||||
struct intrhand **p, *q;
|
||||
|
||||
if (type == IST_NONE)
|
||||
panic("intr_alloc: bogus type");
|
||||
|
||||
bestirq = -1;
|
||||
count = -1;
|
||||
|
||||
/* some interrupts should never be dynamically allocated */
|
||||
mask &= 0xdef8;
|
||||
|
||||
/*
|
||||
* XXX some interrupts will be used later (6 for fdc, 12 for pms).
|
||||
* the right answer is to do "breadth-first" searching of devices.
|
||||
*/
|
||||
mask &= 0xefbf;
|
||||
|
||||
for (i = 0; i < ICU_LEN; i++) {
|
||||
if (LEGAL_IRQ(i) == 0 || (mask & (1<<i)) == 0)
|
||||
continue;
|
||||
|
||||
switch(intrtype[i]) {
|
||||
case IST_NONE:
|
||||
/*
|
||||
* if nothing's using the irq, just return it
|
||||
*/
|
||||
*irq = i;
|
||||
return (0);
|
||||
|
||||
case IST_EDGE:
|
||||
case IST_LEVEL:
|
||||
if (type != intrtype[i])
|
||||
continue;
|
||||
/*
|
||||
* if the irq is shareable, count the number of other
|
||||
* handlers, and if it's smaller than the last irq like
|
||||
* this, remember it
|
||||
*
|
||||
* XXX We should probably also consider the
|
||||
* interrupt level and stick IPL_TTY with other
|
||||
* IPL_TTY, etc.
|
||||
*/
|
||||
for (p = &intrhand[i], tmp = 0; (q = *p) != NULL;
|
||||
p = &q->ih_next, tmp++)
|
||||
;
|
||||
if ((bestirq == -1) || (count > tmp)) {
|
||||
bestirq = i;
|
||||
count = tmp;
|
||||
}
|
||||
break;
|
||||
|
||||
case IST_PULSE:
|
||||
/* this just isn't shareable */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestirq == -1)
|
||||
return (1);
|
||||
|
||||
*irq = bestirq;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up an interrupt handler to start being called.
|
||||
* XXX PRONE TO RACE CONDITIONS, UGLY, 'INTERESTING' INSERTION ALGORITHM.
|
||||
|
@ -476,6 +549,33 @@ isa_attach_hook(parent, self, iba)
|
|||
isa_has_been_seen = 1;
|
||||
}
|
||||
|
||||
int
|
||||
isa_mem_alloc(t, size, align, boundary, flags, addrp, bshp)
|
||||
bus_space_tag_t t;
|
||||
bus_size_t size, align;
|
||||
bus_addr_t boundary;
|
||||
int flags;
|
||||
bus_addr_t *addrp;
|
||||
bus_space_handle_t *bshp;
|
||||
{
|
||||
|
||||
/*
|
||||
* Allocate physical address space in the ISA hole.
|
||||
*/
|
||||
return (bus_space_alloc(t, IOM_BEGIN, IOM_END - 1, size, align,
|
||||
boundary, flags, addrp, bshp));
|
||||
}
|
||||
|
||||
void
|
||||
isa_mem_free(t, bsh, size)
|
||||
bus_space_tag_t t;
|
||||
bus_space_handle_t bsh;
|
||||
bus_size_t size;
|
||||
{
|
||||
|
||||
bus_space_free(t, bsh, size);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* bus.h dma interface entry points
|
||||
**********************************************************************/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: isa_machdep.h,v 1.7 1997/06/06 23:28:42 thorpej Exp $ */
|
||||
/* $NetBSD: isa_machdep.h,v 1.8 1997/10/14 20:34:40 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -106,9 +106,13 @@ struct isabus_attach_args; /* XXX */
|
|||
*/
|
||||
void isa_attach_hook __P((struct device *, struct device *,
|
||||
struct isabus_attach_args *));
|
||||
int isa_intr_alloc __P((isa_chipset_tag_t, int, int, int *));
|
||||
void *isa_intr_establish __P((isa_chipset_tag_t ic, int irq, int type,
|
||||
int level, int (*ih_fun)(void *), void *ih_arg));
|
||||
void isa_intr_disestablish __P((isa_chipset_tag_t ic, void *handler));
|
||||
int isa_mem_alloc __P((bus_space_tag_t, bus_size_t, bus_size_t,
|
||||
bus_addr_t, int, bus_addr_t *, bus_space_handle_t *));
|
||||
void isa_mem_free __P((bus_space_tag_t, bus_space_handle_t, bus_size_t));
|
||||
|
||||
/*
|
||||
* ALL OF THE FOLLOWING ARE MACHINE-DEPENDENT, AND SHOULD NOT BE USED
|
||||
|
|
Loading…
Reference in New Issue