xref: /haiku/headers/private/kernel/smp.h (revision 746cac055adc6ac3308c7bc2d29040fb95689cc9)
1 /*
2  * Copyright 2002-2005, 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_SMP_H
9 #define KERNEL_SMP_H
10 
11 
12 #include <KernelExport.h>
13 
14 struct kernel_args;
15 
16 
17 // intercpu messages
18 enum {
19 	SMP_MSG_INVALIDATE_PAGE_RANGE = 0,
20 	SMP_MSG_INVALIDATE_PAGE_LIST,
21 	SMP_MSG_USER_INVALIDATE_PAGES,
22 	SMP_MSG_GLOBAL_INVALIDATE_PAGES,
23 	SMP_MSG_RESCHEDULE,
24 	SMP_MSG_CPU_HALT,
25 	SMP_MSG_CALL_FUNCTION,
26 };
27 
28 enum {
29 	SMP_MSG_FLAG_ASYNC		= 0x0,
30 	SMP_MSG_FLAG_SYNC		= 0x1,
31 	SMP_MSG_FLAG_FREE_ARG	= 0x2,
32 };
33 
34 typedef void (*smp_call_func)(uint32 data1, int32 currentCPU, uint32 data2, uint32 data3);
35 
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 status_t smp_init(struct kernel_args *args);
42 status_t smp_per_cpu_init(struct kernel_args *args, int32 cpu);
43 status_t smp_init_post_generic_syscalls(void);
44 bool smp_trap_non_boot_cpus(int32 cpu);
45 void smp_wake_up_non_boot_cpus(void);
46 void smp_cpu_rendezvous(volatile uint32 *var, int current_cpu);
47 void smp_send_ici(int32 targetCPU, int32 message, uint32 data, uint32 data2, uint32 data3,
48 		void *data_ptr, uint32 flags);
49 void smp_send_broadcast_ici(int32 message, uint32 data, uint32 data2, uint32 data3,
50 		void *data_ptr, uint32 flags);
51 
52 int32 smp_get_num_cpus(void);
53 void smp_set_num_cpus(int32 numCPUs);
54 int32 smp_get_current_cpu(void);
55 
56 int smp_intercpu_int_handler(void);
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 
62 #endif	/* KERNEL_SMP_H */
63