xref: /haiku/headers/private/kernel/cpu.h (revision fef6144999c2fa611f59ee6ffe6dd7999501385c)
1 /*
2  * Copyright 2002-2005, Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Copyright 2002, Travis Geiselbrecht. All rights reserved.
6  * Distributed under the terms of the NewOS License.
7  */
8 #ifndef _KERNEL_CPU_H
9 #define _KERNEL_CPU_H
10 
11 
12 #include <smp.h>
13 #include <timer.h>
14 
15 struct kernel_args;
16 
17 
18 /* CPU local data structure */
19 
20 typedef union cpu_ent {
21 	struct {
22 		int cpu_num;
23 
24 		// thread.c: used to force a reschedule at quantum expiration time
25 		int preempted;
26 		timer quantum_timer;
27 	} info;
28 	// ToDo: align manually on CPU cache lines if possible
29 	uint32 align[16];
30 } cpu_ent;
31 
32 /**
33  * Defined in core/cpu.c
34  */
35 extern cpu_ent cpu[MAX_BOOT_CPUS];
36 
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 status_t cpu_preboot_init(struct kernel_args *args);
43 status_t cpu_init(struct kernel_args *args);
44 status_t cpu_init_post_vm(struct kernel_args *args);
45 
46 cpu_ent *get_cpu_struct(void);
47 extern inline cpu_ent *get_cpu_struct(void) { return &cpu[smp_get_current_cpu()]; }
48 
49 void _user_clear_caches(void *address, size_t length, uint32 flags);
50 
51 #ifdef __cplusplus
52 }
53 #endif
54 
55 #endif	/* _KERNEL_CPU_H */
56