xref: /haiku/headers/private/kernel/cpu.h (revision e39da397f5ff79f2db9f9a3ddf1852b6710578af)
1 /*
2  * Copyright 2002-2006, 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 #include <boot/kernel_args.h>
15 
16 
17 /* CPU local data structure */
18 
19 typedef struct cpu_ent {
20 	int cpu_num;
21 
22 	// thread.c: used to force a reschedule at quantum expiration time
23 	int preempted;
24 	timer quantum_timer;
25 
26 	// keeping track of CPU activity
27 	bigtime_t active_time;
28 	bigtime_t last_kernel_time;
29 	bigtime_t last_user_time;
30 
31 	bool disabled;
32 } cpu_ent __attribute__((aligned(64)));
33 
34 
35 extern cpu_ent gCPU[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 status_t cpu_init_post_modules(struct kernel_args *args);
46 bigtime_t cpu_get_active_time(int32 cpu);
47 
48 cpu_ent *get_cpu_struct(void);
49 extern inline cpu_ent *get_cpu_struct(void) { return &gCPU[smp_get_current_cpu()]; }
50 
51 void _user_clear_caches(void *address, size_t length, uint32 flags);
52 bool _user_cpu_enabled(int32 cpu);
53 status_t _user_set_cpu_enabled(int32 cpu, bool enabled);
54 
55 #ifdef __cplusplus
56 }
57 #endif
58 
59 #endif	/* _KERNEL_CPU_H */
60