diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2008-04-27 14:36:39 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2008-04-27 14:36:39 +0000 |
commit | 40bc344abbd1e4bd7a01917f5b47e1da92e10adc (patch) | |
tree | 6272b5d56f1ee9c15e0204e05afc2b2879fa4961 | |
parent | 211cadec3cf8a93535c231d379c43edb026a8a38 (diff) |
Move hppa to __HAVE_GENERIC_SOFT_INTERRUPTS
-rw-r--r-- | sys/arch/hppa/hppa/intr.c | 92 | ||||
-rw-r--r-- | sys/arch/hppa/include/_types.h | 3 | ||||
-rw-r--r-- | sys/arch/hppa/include/intr.h | 8 |
3 files changed, 89 insertions, 14 deletions
diff --git a/sys/arch/hppa/hppa/intr.c b/sys/arch/hppa/hppa/intr.c index 8a9dbbb7282..858e307d3a0 100644 --- a/sys/arch/hppa/hppa/intr.c +++ b/sys/arch/hppa/hppa/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.23 2007/05/27 16:36:07 kettenis Exp $ */ +/* $OpenBSD: intr.c,v 1.24 2008/04/27 14:36:38 kettenis Exp $ */ /* * Copyright (c) 2002-2004 Michael Shalayeff @@ -66,10 +66,10 @@ u_long cpu_mask; struct hppa_iv intr_store[8*2*CPU_NINTS] __attribute__ ((aligned(32))), *intr_more = intr_store, *intr_list; struct hppa_iv intr_table[CPU_NINTS] __attribute__ ((aligned(32))) = { - { IPL_SOFTCLOCK, 0, HPPA_IV_SOFT, 0, 0, (int (*)(void *))&softclock }, + { IPL_SOFTCLOCK, 0, HPPA_IV_SOFT, 0, 0, NULL }, { IPL_SOFTNET , 0, HPPA_IV_SOFT, 0, 0, (int (*)(void *))&softnet }, { 0 }, { 0 }, - { IPL_SOFTTTY , 0, HPPA_IV_SOFT, 0, 0, (int (*)(void *))&softtty } + { IPL_SOFTTTY , 0, HPPA_IV_SOFT, 0, 0, NULL } }; volatile u_long ipending, imask[NIPL] = { 0, @@ -102,12 +102,6 @@ softnet(void) } void -softtty(void) -{ - -} - -void cpu_intr_init(void) { u_long mask = cpu_mask | SOFTINT_MASK; @@ -162,7 +156,8 @@ cpu_intr_findirq(void) int irq; for (irq = 0; irq < CPU_NINTS; irq++) - if (intr_table[irq].handler == NULL) + if (intr_table[irq].handler == NULL && + intr_table[irq].pri == 0) return irq; return -1; @@ -327,3 +322,80 @@ cpu_intr(void *v) cpu_inintr--; cpl = s; } + + +void * +softintr_establish(int pri, void (*handler)(void *), void *arg) +{ + struct hppa_iv *iv; + int irq; + + if (pri == IPL_TTY) + pri = IPL_SOFTTTY; + + irq = pri - 1; + iv = &intr_table[irq]; + if ((iv->flags & HPPA_IV_SOFT) == 0 || iv->pri != pri) + return (NULL); + + if (iv->handler) { + iv->next = malloc(sizeof *iv, M_DEVBUF, M_NOWAIT); + iv = iv->next; + } else { + cpu_mask |= (1 << irq); + imask[pri] |= (1 << irq); + } + + if (iv != NULL) { + iv->pri = pri; + iv->irq = 0; + iv->bit = 1 << irq; + iv->flags = HPPA_IV_SOFT; + iv->handler = (int (*)(void *))handler; /* XXX */ + iv->arg = arg; + iv->cnt = NULL; + iv->next = NULL; + iv->share = NULL; + } + + return (iv); +} + +void +softintr_disestablish(void *cookie) +{ + struct hppa_iv *iv = cookie; + int irq = iv->pri - 1; + + if (&intr_table[irq] == cookie) { + if (iv->next) { + struct hppa_iv *nv = iv->next; + + iv->handler = nv->handler; + iv->arg = nv->arg; + iv->next = nv->next; + free(nv, M_DEVBUF); + return; + } else { + iv->handler = NULL; + iv->arg = NULL; + return; + } + } + + for (iv = &intr_table[irq]; iv; iv = iv->next) { + if (iv->next == cookie) { + iv->next = iv->next->next; + free(cookie, M_DEVBUF); + return; + } + } +} + +void +softintr_schedule(void *cookie) +{ + struct hppa_iv *iv = cookie; + + softintr(1 << (iv->pri - 1)); +} diff --git a/sys/arch/hppa/include/_types.h b/sys/arch/hppa/include/_types.h index 4fda82021fb..c1b8062d201 100644 --- a/sys/arch/hppa/include/_types.h +++ b/sys/arch/hppa/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.8 2007/07/22 19:24:45 kettenis Exp $ */ +/* $OpenBSD: _types.h,v 1.9 2008/04/27 14:36:38 kettenis Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -123,6 +123,7 @@ typedef void * __wctrans_t; typedef void * __wctype_t; /* Feature test macros */ +#define __HAVE_GENERIC_SOFT_INTERRUPTS #define __HAVE_TIMECOUNTER #endif /* _HPPA__TYPES_H_ */ diff --git a/sys/arch/hppa/include/intr.h b/sys/arch/hppa/include/intr.h index fa2b3b61d4c..7586fc83f00 100644 --- a/sys/arch/hppa/include/intr.h +++ b/sys/arch/hppa/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.23 2007/05/16 19:37:06 thib Exp $ */ +/* $OpenBSD: intr.h,v 1.24 2008/04/27 14:36:38 kettenis Exp $ */ /* * Copyright (c) 2002-2004 Michael Shalayeff @@ -125,9 +125,11 @@ splx(int ncpl) (1 << (IPL_SOFTNET - 1)) | (1 << (IPL_SOFTTTY - 1))) #define setsoftast() (astpending = 1) -#define setsoftclock() softintr(1 << (IPL_SOFTCLOCK - 1)) #define setsoftnet() softintr(1 << (IPL_SOFTNET - 1)) -#define setsofttty() softintr(1 << (IPL_SOFTTTY - 1)) + +void *softintr_establish(int, void (*)(void *), void *); +void softintr_disestablish(void *); +void softintr_schedule(void *); #endif /* !_LOCORE && _KERNEL */ #endif /* _MACHINE_INTR_H_ */ |