xref: /haiku/headers/private/kernel/smp.h (revision 3cb015b1ee509d69c643506e8ff573808c86dcfc)
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 bool smp_trap_non_boot_cpus(int32 cpu);
44 void smp_wake_up_non_boot_cpus(void);
45 void smp_wait_for_non_boot_cpus(void);
46 void smp_send_ici(int32 targetCPU, int32 message, uint32 data, uint32 data2, uint32 data3,
47 		void *data_ptr, uint32 flags);
48 void smp_send_broadcast_ici(int32 message, uint32 data, uint32 data2, uint32 data3,
49 		void *data_ptr, uint32 flags);
50 
51 int32 smp_get_num_cpus(void);
52 void smp_set_num_cpus(int32 numCPUs);
53 int32 smp_get_current_cpu(void);
54 
55 int smp_intercpu_int_handler(void);
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 #endif	/* KERNEL_SMP_H */
62