16a484265SFrançois Tigeot /* 254e9b9a4SFrançois Tigeot * Copyright (c) 2015-2020 François Tigeot <ftigeot@wolfpond.org> 36a484265SFrançois Tigeot * All rights reserved. 46a484265SFrançois Tigeot * 56a484265SFrançois Tigeot * Redistribution and use in source and binary forms, with or without 66a484265SFrançois Tigeot * modification, are permitted provided that the following conditions 76a484265SFrançois Tigeot * are met: 86a484265SFrançois Tigeot * 1. Redistributions of source code must retain the above copyright 96a484265SFrançois Tigeot * notice unmodified, this list of conditions, and the following 106a484265SFrançois Tigeot * disclaimer. 116a484265SFrançois Tigeot * 2. Redistributions in binary form must reproduce the above copyright 126a484265SFrançois Tigeot * notice, this list of conditions and the following disclaimer in the 136a484265SFrançois Tigeot * documentation and/or other materials provided with the distribution. 146a484265SFrançois Tigeot * 156a484265SFrançois Tigeot * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 166a484265SFrançois Tigeot * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 176a484265SFrançois Tigeot * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 186a484265SFrançois Tigeot * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 196a484265SFrançois Tigeot * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 206a484265SFrançois Tigeot * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 216a484265SFrançois Tigeot * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 226a484265SFrançois Tigeot * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 236a484265SFrançois Tigeot * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 246a484265SFrançois Tigeot * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 256a484265SFrançois Tigeot */ 266a484265SFrançois Tigeot 276a484265SFrançois Tigeot #ifndef _LINUX_IRQFLAGS_H_ 286a484265SFrançois Tigeot #define _LINUX_IRQFLAGS_H_ 296a484265SFrançois Tigeot 30*a85cb24fSFrançois Tigeot #if 0 316a484265SFrançois Tigeot /* 32f48f2686SFrançois Tigeot * local_irq_disable/enable functions prevent interrupts to run on the 33f48f2686SFrançois Tigeot * current CPU in critical sections of code. 34f48f2686SFrançois Tigeot * This maps nicely to crit_enter/exit sequences in the DragonFly kernel 356a484265SFrançois Tigeot */ 36f48f2686SFrançois Tigeot #define local_irq_disable() crit_enter() 37f48f2686SFrançois Tigeot #define local_irq_enable() crit_exit() 38*a85cb24fSFrançois Tigeot #endif 396a484265SFrançois Tigeot 40*a85cb24fSFrançois Tigeot static inline void 41*a85cb24fSFrançois Tigeot local_irq_disable(void) 42*a85cb24fSFrançois Tigeot { 43*a85cb24fSFrançois Tigeot __asm __volatile("cli": : :"memory"); 44*a85cb24fSFrançois Tigeot } 45*a85cb24fSFrançois Tigeot 46*a85cb24fSFrançois Tigeot static inline void 47*a85cb24fSFrançois Tigeot local_irq_enable(void) 48*a85cb24fSFrançois Tigeot { 49*a85cb24fSFrançois Tigeot __asm __volatile("sti": : :"memory"); 50*a85cb24fSFrançois Tigeot } 51056b029cSFrançois Tigeot 52056b029cSFrançois Tigeot static inline bool 53056b029cSFrançois Tigeot irqs_disabled(void) 54056b029cSFrançois Tigeot { 5554e9b9a4SFrançois Tigeot return !(read_rflags() & 0x200UL); 56056b029cSFrançois Tigeot } 57056b029cSFrançois Tigeot 586a484265SFrançois Tigeot #endif /* _LINUX_IRQFLAGS_H_ */ 59