xref: /haiku/headers/private/kernel/int.h (revision 02463fb461904c264e5d559f6ec1de92cf35e436)
152a38012Sejakowatz /*
29de17be6SAxel Dörfler  * Copyright 2003-2010, Axel Dörfler, axeld@pinc-software.de.
3f80b1fa5SAxel Dörfler  * Distributed under the terms of the MIT License.
4f80b1fa5SAxel Dörfler  *
5f80b1fa5SAxel Dörfler  * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
6f80b1fa5SAxel Dörfler  * Distributed under the terms of the NewOS License.
752a38012Sejakowatz  */
852a38012Sejakowatz #ifndef _KERNEL_INT_H
952a38012Sejakowatz #define _KERNEL_INT_H
1052a38012Sejakowatz 
1152a38012Sejakowatz 
12f80b1fa5SAxel Dörfler #include <KernelExport.h>
13564cba31SAxel Dörfler #include <arch/int.h>
14c6aa0539SDavid Reid 
15d897a478SPawel Dziepak #include <util/list.h>
16d897a478SPawel Dziepak 
173684e40bSMichael Lotz // private install_io_interrupt_handler() flags
183684e40bSMichael Lotz #define B_NO_LOCK_VECTOR	0x100
193684e40bSMichael Lotz #define B_NO_HANDLED_INFO	0x200
203684e40bSMichael Lotz 
21564cba31SAxel Dörfler struct kernel_args;
22c6aa0539SDavid Reid 
23f80b1fa5SAxel Dörfler 
246a164daaSPawel Dziepak enum interrupt_type {
256a164daaSPawel Dziepak 	INTERRUPT_TYPE_EXCEPTION,
266a164daaSPawel Dziepak 	INTERRUPT_TYPE_IRQ,
276a164daaSPawel Dziepak 	INTERRUPT_TYPE_LOCAL_IRQ,
286a164daaSPawel Dziepak 	INTERRUPT_TYPE_SYSCALL,
296a164daaSPawel Dziepak 	INTERRUPT_TYPE_ICI,
306a164daaSPawel Dziepak 	INTERRUPT_TYPE_UNKNOWN
316a164daaSPawel Dziepak };
326a164daaSPawel Dziepak 
33d897a478SPawel Dziepak struct irq_assignment {
34d897a478SPawel Dziepak 	list_link	link;
3566395144SPawel Dziepak 
36d897a478SPawel Dziepak 	uint32		irq;
3766395144SPawel Dziepak 	uint32		count;
38d897a478SPawel Dziepak 
3966395144SPawel Dziepak 	int32		handlers_count;
4066395144SPawel Dziepak 
41d897a478SPawel Dziepak 	int32		load;
42d897a478SPawel Dziepak 	int32		cpu;
43d897a478SPawel Dziepak };
44d897a478SPawel Dziepak 
456a164daaSPawel Dziepak 
46229ad83bSAxel Dörfler #ifdef __cplusplus
47229ad83bSAxel Dörfler extern "C" {
48229ad83bSAxel Dörfler #endif
49229ad83bSAxel Dörfler 
50b0d8e689SAxel Dörfler status_t int_init(struct kernel_args* args);
51b0d8e689SAxel Dörfler status_t int_init_post_vm(struct kernel_args* args);
5245bd7bb3SIngo Weinhold status_t int_init_io(struct kernel_args* args);
53f4b0f67cSIngo Weinhold status_t int_init_post_device_manager(struct kernel_args* args);
5477a08c68SAxel Dörfler int int_io_interrupt_handler(int vector, bool levelTriggered);
55b20667b3SAxel Dörfler 
56b20667b3SAxel Dörfler bool interrupts_enabled(void);
5752a38012Sejakowatz 
58229ad83bSAxel Dörfler static inline void
enable_interrupts(void)59229ad83bSAxel Dörfler enable_interrupts(void)
60229ad83bSAxel Dörfler {
61229ad83bSAxel Dörfler 	arch_int_enable_interrupts();
62229ad83bSAxel Dörfler }
6352a38012Sejakowatz 
64229ad83bSAxel Dörfler static inline bool
are_interrupts_enabled(void)65229ad83bSAxel Dörfler are_interrupts_enabled(void)
66229ad83bSAxel Dörfler {
67229ad83bSAxel Dörfler 	return arch_int_are_interrupts_enabled();
68229ad83bSAxel Dörfler }
69229ad83bSAxel Dörfler 
70229ad83bSAxel Dörfler #ifdef __cplusplus
71229ad83bSAxel Dörfler }
72229ad83bSAxel Dörfler #endif
737991b1a0Sbeveloper 
74567f7889SIngo Weinhold 
75567f7889SIngo Weinhold // map those directly to the arch versions, so they can be inlined
76567f7889SIngo Weinhold #define disable_interrupts()		arch_int_disable_interrupts()
77567f7889SIngo Weinhold #define restore_interrupts(status)	arch_int_restore_interrupts(status)
78567f7889SIngo Weinhold 
79567f7889SIngo Weinhold 
80*02463fb4SX512 status_t reserve_io_interrupt_vectors(int32 count, int32 startVector,
816a164daaSPawel Dziepak 	enum interrupt_type type);
82*02463fb4SX512 status_t allocate_io_interrupt_vectors(int32 count, int32 *startVector,
8366395144SPawel Dziepak 	enum interrupt_type type);
84*02463fb4SX512 void free_io_interrupt_vectors(int32 count, int32 startVector);
85fc2d7cb0SMichael Lotz 
86*02463fb4SX512 void assign_io_interrupt_to_cpu(int32 vector, int32 cpu);
87d897a478SPawel Dziepak 
88ca91310aSDavid Reid #endif /* _KERNEL_INT_H */
89