152a38012Sejakowatz /* 252a38012Sejakowatz ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. 352a38012Sejakowatz ** Distributed under the terms of the NewOS License. 452a38012Sejakowatz */ 552a38012Sejakowatz #ifndef _KERNEL_INT_H 652a38012Sejakowatz #define _KERNEL_INT_H 752a38012Sejakowatz 852a38012Sejakowatz #include <stage2.h> 952a38012Sejakowatz #include <arch/int.h> 1052a38012Sejakowatz 11c6aa0539SDavid Reid /** 12c6aa0539SDavid Reid * @defgroup kernelint Interrupts 13c6aa0539SDavid Reid * @ingroup OpenBeOS_Kernel 14c6aa0539SDavid Reid * @brief Interrupts for the kernel and device drivers 15c6aa0539SDavid Reid * @{ 16c6aa0539SDavid Reid */ 17c6aa0539SDavid Reid 18c6aa0539SDavid Reid /** 19c6aa0539SDavid Reid * @defgroup Intreturns Interrupt Handler return codes 20c6aa0539SDavid Reid * @ingroup kernelint 21c6aa0539SDavid Reid * @{ 22c6aa0539SDavid Reid */ 23c6aa0539SDavid Reid /** @def B_UNHANDLED_INTERRUPT interrupt wasn't handled by this handler */ 24c6aa0539SDavid Reid /** @def B_HANDLED_INTERRUPT the handler handled the interrupt */ 25c6aa0539SDavid Reid /** @def B_INVOKE_SCHEDULER the handler handled the interrupt and wants the 26c6aa0539SDavid Reid * scheduler invoked 27c6aa0539SDavid Reid */ 28c6aa0539SDavid Reid #define B_UNHANDLED_INTERRUPT 0 29c6aa0539SDavid Reid #define B_HANDLED_INTERRUPT 1 30c6aa0539SDavid Reid #define B_INVOKE_SCHEDULER 2 31c6aa0539SDavid Reid /** @} */ 32c6aa0539SDavid Reid 33c6aa0539SDavid Reid /** @def B_NO_ENABLE_COUNTER add the handler but don't change whether or 34c6aa0539SDavid Reid * not the interrupt is currently enabled 35c6aa0539SDavid Reid */ 36c6aa0539SDavid Reid #define B_NO_ENABLE_COUNTER 1 37c6aa0539SDavid Reid 38c6aa0539SDavid Reid typedef int32 (*interrupt_handler) (void *data); 39c6aa0539SDavid Reid 4052a38012Sejakowatz int int_init(kernel_args *ka); 4152a38012Sejakowatz int int_init2(kernel_args *ka); 4252a38012Sejakowatz int int_io_interrupt_handler(int vector); 43c6aa0539SDavid Reid long install_interrupt_handler(long, interrupt_handler, void *); 44c6aa0539SDavid Reid long remove_interrupt_handler (long, interrupt_handler, void *); 4552a38012Sejakowatz 46*2ba192e3SDavid Reid #define enable_interrupts arch_int_enable_interrupts 47*2ba192e3SDavid Reid #define disable_interrupts arch_int_disable_interrupts 48*2ba192e3SDavid Reid #define restore_interrupts arch_int_restore_interrupts 49*2ba192e3SDavid Reid #define are_interrupts_enabled arch_int_is_interrupts_enabled 5052a38012Sejakowatz 51*2ba192e3SDavid Reid /** @fn long install_io_interrupt_handler(long interrupt, interrupt_handler handler, void *data, ulong flags); 52*2ba192e3SDavid Reid * 53*2ba192e3SDavid Reid * @note This function is used for devices that can generate an "actual" 54*2ba192e3SDavid Reid * interrupt, i.e. where IRQ < 16 55*2ba192e3SDavid Reid */ 56*2ba192e3SDavid Reid long install_io_interrupt_handler(long, 57*2ba192e3SDavid Reid interrupt_handler, 58*2ba192e3SDavid Reid void *, ulong); 59ca91310aSDavid Reid 60*2ba192e3SDavid Reid /** @fn long remove_io_interrupt_handler(long interrupt, interrupt_handler handler, void *data); 61*2ba192e3SDavid Reid * 62*2ba192e3SDavid Reid * @note This function is used for devices that can generate an "actual" 63*2ba192e3SDavid Reid * interrupt, i.e. where IRQ < 16 64*2ba192e3SDavid Reid */ 65*2ba192e3SDavid Reid long remove_io_interrupt_handler (long, 66*2ba192e3SDavid Reid interrupt_handler, 67*2ba192e3SDavid Reid void *); 68ca91310aSDavid Reid 69c6aa0539SDavid Reid /** @} */ 70c6aa0539SDavid Reid 71ca91310aSDavid Reid #endif /* _KERNEL_INT_H */ 72