From: patrick Date: Wed, 8 Aug 2018 11:06:33 +0000 (+0000) Subject: Extend the FDT interrupt API to support masking and unmasking IRQs. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=575c38b7a70a591e79a8ae61d42299b9f9eb5121;p=openbsd Extend the FDT interrupt API to support masking and unmasking IRQs. Discussed with kettenis@ --- diff --git a/sys/arch/arm/include/fdt.h b/sys/arch/arm/include/fdt.h index a0f571e2f4c..8269c3f4d5e 100644 --- a/sys/arch/arm/include/fdt.h +++ b/sys/arch/arm/include/fdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.h,v 1.8 2018/08/06 10:52:30 patrick Exp $ */ +/* $OpenBSD: fdt.h,v 1.9 2018/08/08 11:06:33 patrick Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * @@ -40,10 +40,12 @@ extern bus_space_tag_t fdt_cons_bs_tag; void *fdt_find_cons(const char *); +#define fdt_intr_enable arm_intr_enable #define fdt_intr_establish arm_intr_establish_fdt #define fdt_intr_establish_idx arm_intr_establish_fdt_idx #define fdt_intr_establish_imap arm_intr_establish_fdt_imap #define fdt_intr_establish_msi arm_intr_establish_fdt_msi +#define fdt_intr_disable arm_intr_disable #define fdt_intr_disestablish arm_intr_disestablish_fdt #define fdt_intr_get_parent arm_intr_get_parent #define fdt_intr_parent_establish arm_intr_parent_establish_fdt diff --git a/sys/arch/arm64/arm64/intr.c b/sys/arch/arm64/arm64/intr.c index 96e27963e5c..8daaaf1bfeb 100644 --- a/sys/arch/arm64/arm64/intr.c +++ b/sys/arch/arm64/arm64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.12 2018/07/30 10:56:00 kettenis Exp $ */ +/* $OpenBSD: intr.c,v 1.13 2018/08/08 11:06:33 patrick Exp $ */ /* * Copyright (c) 2011 Dale Rahn * @@ -463,6 +463,26 @@ arm_intr_disestablish_fdt(void *cookie) free(ih, M_DEVBUF, sizeof(*ih)); } +void +arm_intr_enable(void *cookie) +{ + struct arm_intr_handle *ih = cookie; + struct interrupt_controller *ic = ih->ih_ic; + + KASSERT(ic->ic_enable != NULL); + ic->ic_enable(ih->ih_ih); +} + +void +arm_intr_disable(void *cookie) +{ + struct arm_intr_handle *ih = cookie; + struct interrupt_controller *ic = ih->ih_ic; + + KASSERT(ic->ic_disable != NULL); + ic->ic_disable(ih->ih_ih); +} + /* * Some interrupt controllers transparently forward interrupts to * their parent. Such interrupt controllers can use this function to diff --git a/sys/arch/arm64/include/fdt.h b/sys/arch/arm64/include/fdt.h index 0ae8b4f988a..86df93d8b92 100644 --- a/sys/arch/arm64/include/fdt.h +++ b/sys/arch/arm64/include/fdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.h,v 1.5 2018/08/06 10:52:30 patrick Exp $ */ +/* $OpenBSD: fdt.h,v 1.6 2018/08/08 11:06:33 patrick Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * @@ -40,10 +40,12 @@ extern bus_space_tag_t fdt_cons_bs_tag; void *fdt_find_cons(const char *); +#define fdt_intr_enable arm_intr_enable #define fdt_intr_establish arm_intr_establish_fdt #define fdt_intr_establish_idx arm_intr_establish_fdt_idx #define fdt_intr_establish_imap arm_intr_establish_fdt_imap #define fdt_intr_establish_msi arm_intr_establish_fdt_msi +#define fdt_intr_disable arm_intr_disable #define fdt_intr_disestablish arm_intr_disestablish_fdt #define fdt_intr_get_parent arm_intr_get_parent #define fdt_intr_parent_establish arm_intr_parent_establish_fdt diff --git a/sys/arch/arm64/include/intr.h b/sys/arch/arm64/include/intr.h index 45c740648ac..0f702861965 100644 --- a/sys/arch/arm64/include/intr.h +++ b/sys/arch/arm64/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.10 2018/04/09 18:35:13 kettenis Exp $ */ +/* $OpenBSD: intr.h,v 1.11 2018/08/08 11:06:33 patrick Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -142,6 +142,8 @@ struct interrupt_controller { void *(*ic_establish_msi)(void *, uint64_t *, uint64_t *, int, int (*)(void *), void *, char *); void (*ic_disestablish)(void *); + void (*ic_enable)(void *); + void (*ic_disable)(void *); void (*ic_route)(void *, int, struct cpu_info *); void (*ic_cpu_enable)(void); @@ -161,6 +163,8 @@ void *arm_intr_establish_fdt_imap(int, int *, int, int, int (*)(void *), void *arm_intr_establish_fdt_msi(int, uint64_t *, uint64_t *, int , int (*)(void *), void *, char *); void arm_intr_disestablish_fdt(void *); +void arm_intr_enable(void *); +void arm_intr_disable(void *); void arm_intr_route(void *, int, struct cpu_info *); void arm_intr_cpu_enable(void); void *arm_intr_parent_establish_fdt(void *, int *, int, diff --git a/sys/arch/armv7/armv7/intr.c b/sys/arch/armv7/armv7/intr.c index 5de9d0aabc3..0e81fc4d54f 100644 --- a/sys/arch/armv7/armv7/intr.c +++ b/sys/arch/armv7/armv7/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.13 2018/07/06 13:08:10 patrick Exp $ */ +/* $OpenBSD: intr.c,v 1.14 2018/08/08 11:06:33 patrick Exp $ */ /* * Copyright (c) 2011 Dale Rahn * @@ -434,6 +434,26 @@ arm_intr_disestablish_fdt(void *cookie) free(ih, M_DEVBUF, sizeof(*ih)); } +void +arm_intr_enable(void *cookie) +{ + struct arm_intr_handle *ih = cookie; + struct interrupt_controller *ic = ih->ih_ic; + + KASSERT(ic->ic_enable != NULL); + ic->ic_enable(ih->ih_ih); +} + +void +arm_intr_disable(void *cookie) +{ + struct arm_intr_handle *ih = cookie; + struct interrupt_controller *ic = ih->ih_ic; + + KASSERT(ic->ic_disable != NULL); + ic->ic_disable(ih->ih_ih); +} + /* * Some interrupt controllers transparently forward interrupts to * their parent. Such interrupt controllers can use this function to diff --git a/sys/arch/armv7/include/intr.h b/sys/arch/armv7/include/intr.h index 61ff23e53f2..96c17d84c78 100644 --- a/sys/arch/armv7/include/intr.h +++ b/sys/arch/armv7/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.8 2018/07/06 13:08:10 patrick Exp $ */ +/* $OpenBSD: intr.h,v 1.9 2018/08/08 11:06:33 patrick Exp $ */ /* $NetBSD: intr.h,v 1.12 2003/06/16 20:00:59 thorpej Exp $ */ /* @@ -156,6 +156,8 @@ struct interrupt_controller { void *(*ic_establish_msi)(void *, uint64_t *, uint64_t *, int, int (*)(void *), void *, char *); void (*ic_disestablish)(void *); + void (*ic_enable)(void *); + void (*ic_disable)(void *); void (*ic_route)(void *, int, struct cpu_info *); LIST_ENTRY(interrupt_controller) ic_list; @@ -174,6 +176,8 @@ void *arm_intr_establish_fdt_imap(int, int *, int, int, int (*)(void *), void *arm_intr_establish_fdt_msi(int, uint64_t *, uint64_t *, int , int (*)(void *), void *, char *); void arm_intr_disestablish_fdt(void *); +void arm_intr_enable(void *); +void arm_intr_disable(void *); void arm_intr_route(void *, int, struct cpu_info *); void *arm_intr_parent_establish_fdt(void *, int *, int,