1 /* 2 * Copyright 2003-2010, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 * 5 * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. 6 * Distributed under the terms of the NewOS License. 7 */ 8 #ifndef _KERNEL_INT_H 9 #define _KERNEL_INT_H 10 11 12 #include <KernelExport.h> 13 #include <arch/int.h> 14 15 #include <util/list.h> 16 17 // private install_io_interrupt_handler() flags 18 #define B_NO_LOCK_VECTOR 0x100 19 #define B_NO_HANDLED_INFO 0x200 20 21 struct kernel_args; 22 23 24 enum interrupt_type { 25 INTERRUPT_TYPE_EXCEPTION, 26 INTERRUPT_TYPE_IRQ, 27 INTERRUPT_TYPE_LOCAL_IRQ, 28 INTERRUPT_TYPE_SYSCALL, 29 INTERRUPT_TYPE_ICI, 30 INTERRUPT_TYPE_UNKNOWN 31 }; 32 33 struct irq_assignment { 34 list_link link; 35 36 uint32 irq; 37 uint32 count; 38 39 int32 handlers_count; 40 41 int32 load; 42 int32 cpu; 43 }; 44 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 status_t int_init(struct kernel_args* args); 51 status_t int_init_post_vm(struct kernel_args* args); 52 status_t int_init_io(struct kernel_args* args); 53 status_t int_init_post_device_manager(struct kernel_args* args); 54 int int_io_interrupt_handler(int vector, bool levelTriggered); 55 56 bool interrupts_enabled(void); 57 58 static inline void 59 enable_interrupts(void) 60 { 61 arch_int_enable_interrupts(); 62 } 63 64 static inline bool 65 are_interrupts_enabled(void) 66 { 67 return arch_int_are_interrupts_enabled(); 68 } 69 70 #ifdef __cplusplus 71 } 72 #endif 73 74 75 // map those directly to the arch versions, so they can be inlined 76 #define disable_interrupts() arch_int_disable_interrupts() 77 #define restore_interrupts(status) arch_int_restore_interrupts(status) 78 79 80 status_t reserve_io_interrupt_vectors(int32 count, int32 startVector, 81 enum interrupt_type type); 82 status_t allocate_io_interrupt_vectors(int32 count, int32 *startVector, 83 enum interrupt_type type); 84 void free_io_interrupt_vectors(int32 count, int32 startVector); 85 86 void assign_io_interrupt_to_cpu(int32 vector, int32 cpu); 87 88 #endif /* _KERNEL_INT_H */ 89