-/* $OpenBSD: intr.c,v 1.21 2021/03/11 11:16:55 jsg Exp $ */
+/* $OpenBSD: intr.c,v 1.22 2021/05/15 11:30:27 kettenis Exp $ */
/*
* Copyright (c) 2011 Dale Rahn <drahn@openbsd.org>
*
arm_do_pending_intr(int pcpl)
{
struct cpu_info *ci = curcpu();
- int oldirqstate;
+ u_long oldirqstate;
- oldirqstate = disable_interrupts();
+ oldirqstate = intr_disable();
#define DO_SOFTINT(si, ipl) \
if ((ci->ci_ipending & arm_smask[pcpl]) & \
- SI_TO_IRQBIT(si)) { \
- ci->ci_ipending &= ~SI_TO_IRQBIT(si); \
- arm_intr_func.setipl(ipl); \
- restore_interrupts(oldirqstate); \
- softintr_dispatch(si); \
- oldirqstate = disable_interrupts(); \
+ SI_TO_IRQBIT(si)) { \
+ ci->ci_ipending &= ~SI_TO_IRQBIT(si); \
+ arm_intr_func.setipl(ipl); \
+ intr_restore(oldirqstate); \
+ softintr_dispatch(si); \
+ oldirqstate = intr_disable(); \
}
do {
/* Don't use splx... we are here already! */
arm_intr_func.setipl(pcpl);
- restore_interrupts(oldirqstate);
+ intr_restore(oldirqstate);
}
void
-/* $OpenBSD: syscall.c,v 1.6 2020/03/13 05:20:07 deraadt Exp $ */
+/* $OpenBSD: syscall.c,v 1.7 2021/05/15 11:30:27 kettenis Exp $ */
/*
* Copyright (c) 2015 Dale Rahn <drahn@dalerahn.com>
*
/* Re-enable interrupts if they were enabled previously */
if (__predict_true((frame->tf_spsr & I_bit) == 0))
- enable_interrupts();
+ intr_enable();
/* Skip over speculation-blocking barrier. */
frame->tf_elr += 8;
-/* $OpenBSD: trap.c,v 1.36 2021/05/05 07:29:00 mpi Exp $ */
+/* $OpenBSD: trap.c,v 1.37 2021/05/15 11:30:27 kettenis Exp $ */
/*-
* Copyright (c) 2014 Andrew Turner
* All rights reserved.
exception = ESR_ELx_EXCEPTION(esr);
far = READ_SPECIALREG(far_el1);
- enable_interrupts();
+ intr_enable();
/*
* Sanity check we are in an exception er can handle. The IL bit
exception = ESR_ELx_EXCEPTION(esr);
far = READ_SPECIALREG(far_el1);
- enable_interrupts();
+ intr_enable();
p->p_addr->u_pcb.pcb_tf = frame;
refreshcreds(p);
-/* $OpenBSD: vfp.c,v 1.4 2018/07/02 07:23:37 kettenis Exp $ */
+/* $OpenBSD: vfp.c,v 1.5 2021/05/15 11:30:27 kettenis Exp $ */
/*
* Copyright (c) 2011 Dale Rahn <drahn@openbsd.org>
*
if (curproc->p_addr->u_pcb.pcb_fpcpu == ci &&
ci->ci_fpuproc == curproc) {
- disable_interrupts();
+ intr_disable();
/* FPU state is still valid, just enable and go */
set_vfp_enable(1);
struct cpu_info *ci = curcpu();
struct pcb *pcb = &p->p_addr->u_pcb;
uint32_t scratch = 0;
- int psw;
+ u_long psw;
/* do not allow a partially synced state here */
- psw = disable_interrupts();
+ psw = intr_disable();
/*
* p->p_pcb->pcb_fpucpu _may_ not be NULL here, but the FPU state
/* disable until return to userland */
set_vfp_enable(0);
- restore_interrupts(psw);
+ intr_restore(psw);
}
-/* $OpenBSD: agintc.c,v 1.31 2021/05/05 12:02:21 kettenis Exp $ */
+/* $OpenBSD: agintc.c,v 1.32 2021/05/15 11:30:27 kettenis Exp $ */
/*
* Copyright (c) 2007, 2009, 2011, 2017 Dale Rahn <drahn@dalerahn.com>
* Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org>
struct fdt_attach_args *faa = aux;
struct cpu_info *ci;
CPU_INFO_ITERATOR cii;
+ u_long psw;
uint32_t typer;
uint32_t nsacr, oldnsacr;
uint32_t pmr, oldpmr;
uint32_t ctrl, bits;
uint32_t affinity;
int i, nbits, nintr;
- int psw;
int offset, nredist;
#ifdef MULTIPROCESSOR
int nipi, ipiirq[2];
#endif
- psw = disable_interrupts();
+ psw = intr_disable();
arm_init_smask();
sc->sc_iot = faa->fa_iot;
sc->sc_ic.ic_barrier = agintc_intr_barrier;
arm_intr_register_fdt(&sc->sc_ic);
- restore_interrupts(psw);
+ intr_restore(psw);
/* Attach ITS. */
simplebus_attach(parent, &sc->sc_sbus.sc_dev, faa);
__asm volatile("msr "STR(ICC_PMR)", %x0" :: "r"(0xff));
__asm volatile("msr "STR(ICC_BPR1)", %x0" :: "r"(0));
__asm volatile("msr "STR(ICC_IGRPEN1)", %x0" :: "r"(1));
- enable_interrupts();
+ intr_enable();
}
void
{
struct agintc_softc *sc = agintc_sc;
struct cpu_info *ci = curcpu();
- int psw;
+ u_long psw;
uint32_t prival;
/* disable here is only to keep hardware in sync with ci->ci_cpl */
- psw = disable_interrupts();
+ psw = intr_disable();
ci->ci_cpl = ipl;
prival = ((0xff - ipl) << sc->sc_pmr_shift) & 0xff;
__asm volatile("msr "STR(ICC_PMR)", %x0" : : "r" (prival));
__isb();
- restore_interrupts(psw);
+ intr_restore(psw);
}
void
else
arg = frame;
- enable_interrupts();
+ intr_enable();
handled = ih->ih_func(arg);
- disable_interrupts();
+ intr_disable();
if (handled)
ih->ih_count.ec_count++;
{
struct agintc_softc *sc = agintc_sc;
struct intrhand *ih;
- int psw;
+ u_long psw;
if (irqno < 0 || (irqno >= sc->sc_nintr && irqno < LPI_BASE) ||
irqno >= LPI_BASE + sc->sc_nlpi)
ih->ih_name = name;
ih->ih_ci = ci;
- psw = disable_interrupts();
+ psw = intr_disable();
if (irqno < LPI_BASE) {
if (!TAILQ_EMPTY(&sc->sc_handler[irqno].iq_list) &&
sc->sc_handler[irqno].iq_ci != ci) {
+ intr_restore(psw);
free(ih, M_DEVBUF, sizeof *ih);
- restore_interrupts(psw);
return NULL;
}
TAILQ_INSERT_TAIL(&sc->sc_handler[irqno].iq_list, ih, ih_list);
__asm volatile("dsb sy");
}
- restore_interrupts(psw);
+ intr_restore(psw);
return (ih);
}
struct agintc_softc *sc = agintc_sc;
struct intrhand *ih = cookie;
int irqno = ih->ih_irq;
- int psw;
+ u_long psw;
- psw = disable_interrupts();
+ psw = intr_disable();
TAILQ_REMOVE(&sc->sc_handler[irqno].iq_list, ih, ih_list);
if (ih->ih_name != NULL)
agintc_calc_irq(sc, irqno);
- restore_interrupts(psw);
+ intr_restore(psw);
free(ih, M_DEVBUF, 0);
}
-/* $OpenBSD: ampintc.c,v 1.21 2021/02/17 12:11:45 kettenis Exp $ */
+/* $OpenBSD: ampintc.c,v 1.22 2021/05/15 11:30:27 kettenis Exp $ */
/*
* Copyright (c) 2007,2009,2011 Dale Rahn <drahn@openbsd.org>
*
/* enable interrupts */
bus_space_write_4(sc->sc_iot, sc->sc_d_ioh, ICD_DCR, 3);
bus_space_write_4(sc->sc_iot, sc->sc_p_ioh, ICPICR, 1);
- enable_interrupts();
+ intr_enable();
sc->sc_ic.ic_node = faa->fa_node;
sc->sc_ic.ic_cookie = self;
{
struct cpu_info *ci = curcpu();
struct ampintc_softc *sc = ampintc;
- int psw;
+ u_long psw;
/* disable here is only to keep hardware in sync with ci->ci_cpl */
- psw = disable_interrupts();
+ psw = intr_disable();
ci->ci_cpl = new;
/* low values are higher priority thus IPL_HIGH - pri */
bus_space_write_4(sc->sc_iot, sc->sc_p_ioh, ICPIPMR,
(IPL_HIGH - new) << ICMIPMR_SH);
- restore_interrupts(psw);
+ intr_restore(psw);
}
void
else
arg = frame;
- enable_interrupts();
+ intr_enable();
handled = ih->ih_func(arg);
- disable_interrupts();
+ intr_disable();
if (handled)
ih->ih_count.ec_count++;
{
struct ampintc_softc *sc = ampintc;
struct intrhand *ih;
- int psw;
+ u_long psw;
if (irqno < 0 || irqno >= sc->sc_nintr)
panic("ampintc_intr_establish: bogus irqnumber %d: %s",
ih->ih_name = name;
ih->ih_ci = ci;
- psw = disable_interrupts();
+ psw = intr_disable();
if (!TAILQ_EMPTY(&sc->sc_handler[irqno].iq_list) &&
sc->sc_handler[irqno].iq_ci != ci) {
free(ih, M_DEVBUF, sizeof(*ih));
- restore_interrupts(psw);
+ intr_restore(psw);
return NULL;
}
ampintc_intr_config(irqno, type);
ampintc_calc_mask();
- restore_interrupts(psw);
+ intr_restore(psw);
return (ih);
}
{
struct ampintc_softc *sc = ampintc;
struct intrhand *ih = cookie;
- int psw;
+ u_long psw;
#ifdef DEBUG_INTC
printf("ampintc_intr_disestablish irq %d level %d [%s]\n",
ih->ih_irq, ih->ih_ipl, ih->ih_name);
#endif
- psw = disable_interrupts();
+ psw = intr_disable();
TAILQ_REMOVE(&sc->sc_handler[ih->ih_irq].iq_list, ih, ih_list);
if (ih->ih_name != NULL)
evcount_detach(&ih->ih_count);
- free(ih, M_DEVBUF, sizeof(*ih));
ampintc_calc_mask();
- restore_interrupts(psw);
+ intr_restore(psw);
+
+ free(ih, M_DEVBUF, sizeof(*ih));
}
const char *
-/* $OpenBSD: bcm2836_intr.c,v 1.10 2021/02/17 12:11:45 kettenis Exp $ */
+/* $OpenBSD: bcm2836_intr.c,v 1.11 2021/05/15 11:30:27 kettenis Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2015 Patrick Wildt <patrick@blueri.se>
intr_send_ipi_func = bcm_intc_send_ipi;
bcm_intc_setipl(IPL_HIGH); /* XXX ??? */
- enable_interrupts();
+ intr_enable();
}
void
{
struct cpu_info *ci = curcpu();
struct bcm_intc_softc *sc = bcm_intc;
- int psw;
+ u_long psw;
- psw = disable_interrupts();
+ psw = intr_disable();
ci->ci_cpl = new;
if (cpu_number() == 0) {
bus_space_write_4(sc->sc_iot, sc->sc_ioh, INTC_DISABLE_BANK0,
ARM_LOCAL_INT_TIMER(cpu_number()),
sc->sc_bcm_intc_imask[3][ci->ci_cpl] &
sc->sc_localcoremask[cpu_number()]);
- restore_interrupts(psw);
+ intr_restore(psw);
}
int
else
arg = frame;
- enable_interrupts();
+ intr_enable();
handled = ih->ih_func(arg);
- disable_interrupts();
+ intr_disable();
if (handled)
ih->ih_count.ec_count++;
{
struct bcm_intc_softc *sc = bcm_intc;
struct intrhand *ih;
- int psw;
+ u_long psw;
if (irqno < 0 || irqno >= INTC_NIRQ)
panic("bcm_intc_intr_establish: bogus irqnumber %d: %s",
if (ci != NULL && !CPU_IS_PRIMARY(ci))
return NULL;
- psw = disable_interrupts();
+ psw = intr_disable();
ih = malloc(sizeof *ih, M_DEVBUF, M_WAITOK);
ih->ih_func = func;
#endif
bcm_intc_calc_mask();
- restore_interrupts(psw);
+ intr_restore(psw);
return (ih);
}
struct bcm_intc_softc *sc = bcm_intc;
struct intrhand *ih = cookie;
int irqno = ih->ih_irq;
- int psw;
+ u_long psw;
- psw = disable_interrupts();
+ psw = intr_disable();
TAILQ_REMOVE(&sc->sc_bcm_intc_handler[irqno].is_list, ih, ih_list);
if (ih->ih_name != NULL)
evcount_detach(&ih->ih_count);
+ intr_restore(psw);
+
free(ih, M_DEVBUF, 0);
- restore_interrupts(psw);
}
void
-/* $OpenBSD: efi.c,v 1.9 2021/03/11 11:16:56 jsg Exp $ */
+/* $OpenBSD: efi.c,v 1.10 2021/05/15 11:30:27 kettenis Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
struct device sc_dev;
struct pmap *sc_pm;
EFI_RUNTIME_SERVICES *sc_rs;
- int sc_psw;
+ u_long sc_psw;
struct todr_chip_handle sc_todr;
};
{
struct pmap *pm = sc->sc_pm;
- sc->sc_psw = disable_interrupts();
+ sc->sc_psw = intr_disable();
WRITE_SPECIALREG(ttbr0_el1, pmap_kernel()->pm_pt0pa);
__asm volatile("isb");
cpu_setttb(pm->pm_asid, pm->pm_pt0pa);
WRITE_SPECIALREG(ttbr0_el1, pmap_kernel()->pm_pt0pa);
__asm volatile("isb");
cpu_setttb(pm->pm_asid, pm->pm_pt0pa);
- restore_interrupts(sc->sc_psw);
+ intr_restore(sc->sc_psw);
}
int
-/* $OpenBSD: cpu.h,v 1.19 2021/02/17 12:11:45 kettenis Exp $ */
+/* $OpenBSD: cpu.h,v 1.20 2021/05/15 11:30:27 kettenis Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
*
void board_startup(void);
// functions to manipulate interrupt state
-static __inline uint32_t
-get_daif(void)
-{
- uint32_t daif;
-
- __asm volatile ("mrs %x0, daif": "=r"(daif));
- return daif;
-}
-
static __inline void
restore_daif(uint32_t daif)
{
return daif;
}
-#define get_interrupts(mask) \
- (__get_daif())
-
-#define disable_interrupts() \
- disable_irq_daif_ret()
-
-#define enable_interrupts() \
- enable_irq_daif()
-
-#define restore_interrupts(old_daif) \
- restore_daif(old_daif)
-
static inline void
intr_enable(void)
{