/*-
* Copyright (c) 1999, 2002
* Shin Takemura and PocketBSD Project. All rights reserved.
*
* 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. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
*/
static int
vr4181ip_comintr(void *arg)
{
struct vr4181ip_intrhand *ih = arg;
int i;
for (i = 0; i < MAXCOMINTR; i++) {
if (ih[i].ih_fun)
ih[i].ih_fun(ih[i].ih_arg);
}
return 1;
}
void
vr4181ip_comintr_establish(vrip_chipset_tag_t vc, int unit, int line,
int level, int (*ih_fun)(void *), void *ih_arg)
{
int i;
if (!registered) {
if (!vrip_intr_establish(vc, unit, 0, IPL_TTY,
vr4181ip_comintr, intrhands)) {
panic("vr4181ip_comintr_establish: "
"can't map interrupt line.");
}
registered = 1;
}
for (i = 0; i < MAXCOMINTR; i++) {
if (intrhands[i].ih_fun == NULL) {
intrhands[i].ih_fun = ih_fun;
intrhands[i].ih_arg = ih_arg;
break;
}
}
if (i >= MAXCOMINTR)
panic("too many vr4181 SIU");
}