[f42730a] | 1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
| 2 | |
---|
[6d6891e] | 3 | /** |
---|
[d9e0006] | 4 | * @file |
---|
| 5 | * |
---|
| 6 | * @brief Intel I386 Interrupt Macros |
---|
| 7 | * |
---|
| 8 | * Formerly contained in and extracted from libcpu/i386/cpu.h |
---|
[cc9f433] | 9 | * |
---|
| 10 | * Applications must not include this file directly. |
---|
[6d6891e] | 11 | */ |
---|
| 12 | |
---|
[a324355] | 13 | /* |
---|
| 14 | * COPYRIGHT (c) 1998 valette@crf.canon.fr |
---|
| 15 | * |
---|
[f42730a] | 16 | * Redistribution and use in source and binary forms, with or without |
---|
| 17 | * modification, are permitted provided that the following conditions |
---|
| 18 | * are met: |
---|
| 19 | * 1. Redistributions of source code must retain the above copyright |
---|
| 20 | * notice, this list of conditions and the following disclaimer. |
---|
| 21 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
| 22 | * notice, this list of conditions and the following disclaimer in the |
---|
| 23 | * documentation and/or other materials provided with the distribution. |
---|
| 24 | * |
---|
| 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
| 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
| 35 | * POSSIBILITY OF SUCH DAMAGE. |
---|
[a324355] | 36 | */ |
---|
| 37 | |
---|
[d670ef9] | 38 | /** |
---|
| 39 | * @defgroup RTEMSScoreCPUi386Interrupt Processor Dependent Interrupt Management |
---|
| 40 | * |
---|
| 41 | * @ingroup RTEMSScoreCPUi386 |
---|
| 42 | * |
---|
| 43 | * @brief i386 Interrupt Management |
---|
| 44 | */ |
---|
| 45 | /**@{**/ |
---|
| 46 | |
---|
[7f70d1b7] | 47 | #ifndef _RTEMS_SCORE_INTERRUPTS_H |
---|
| 48 | #define _RTEMS_SCORE_INTERRUPTS_H |
---|
[a324355] | 49 | |
---|
| 50 | #ifndef ASM |
---|
| 51 | |
---|
| 52 | struct __rtems_raw_irq_connect_data__; |
---|
| 53 | |
---|
| 54 | typedef void (*rtems_raw_irq_hdl) (void); |
---|
| 55 | typedef void (*rtems_raw_irq_enable) (const struct __rtems_raw_irq_connect_data__*); |
---|
| 56 | typedef void (*rtems_raw_irq_disable) (const struct __rtems_raw_irq_connect_data__*); |
---|
| 57 | typedef int (*rtems_raw_irq_is_enabled) (const struct __rtems_raw_irq_connect_data__*); |
---|
| 58 | |
---|
[d9e0006] | 59 | /** |
---|
| 60 | * @name Interrupt Level Macros |
---|
| 61 | * |
---|
[a324355] | 62 | */ |
---|
[b697bc6] | 63 | /**@{**/ |
---|
[7c39cab] | 64 | #if !defined(I386_DISABLE_INLINE_ISR_DISABLE_ENABLE) |
---|
[a324355] | 65 | #define i386_disable_interrupts( _level ) \ |
---|
| 66 | { \ |
---|
[c05f6238] | 67 | __asm__ volatile ( "pushf ; \ |
---|
[a324355] | 68 | cli ; \ |
---|
| 69 | pop %0" \ |
---|
| 70 | : "=rm" ((_level)) \ |
---|
| 71 | ); \ |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | #define i386_enable_interrupts( _level ) \ |
---|
| 75 | { \ |
---|
[c05f6238] | 76 | __asm__ volatile ( "push %0 ; \ |
---|
[a324355] | 77 | popf" \ |
---|
| 78 | : : "rm" ((_level)) : "cc" \ |
---|
| 79 | ); \ |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | #define i386_flash_interrupts( _level ) \ |
---|
| 83 | { \ |
---|
[c05f6238] | 84 | __asm__ volatile ( "push %0 ; \ |
---|
[a324355] | 85 | popf ; \ |
---|
| 86 | cli" \ |
---|
| 87 | : : "rm" ((_level)) : "cc" \ |
---|
| 88 | ); \ |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | #define i386_get_interrupt_level( _level ) \ |
---|
| 92 | do { \ |
---|
[f35c3be9] | 93 | uint32_t _eflags; \ |
---|
[a324355] | 94 | \ |
---|
[c05f6238] | 95 | __asm__ volatile ( "pushf ; \ |
---|
[a324355] | 96 | pop %0" \ |
---|
| 97 | : "=rm" ((_eflags)) \ |
---|
| 98 | ); \ |
---|
| 99 | \ |
---|
| 100 | _level = (_eflags & EFLAGS_INTR_ENABLE) ? 0 : 1; \ |
---|
| 101 | } while (0) |
---|
[3267f95] | 102 | #else |
---|
| 103 | uint32_t i386_disable_interrupts( void ); |
---|
| 104 | void i386_enable_interrupts(uint32_t level); |
---|
| 105 | void i386_flash_interrupts(uint32_t level); |
---|
| 106 | void i386_set_interrupt_level(uint32_t new_level); |
---|
| 107 | uint32_t i386_get_interrupt_level( void ); |
---|
| 108 | #endif /* PARAVIRT */ |
---|
[a324355] | 109 | |
---|
[d9e0006] | 110 | /** @} */ |
---|
| 111 | |
---|
[d670ef9] | 112 | /**@}**/ |
---|
[a324355] | 113 | #endif |
---|
| 114 | #endif |
---|