xref: /haiku/headers/private/kernel/cpu.h (revision 1e36cfc2721ef13a187c6f7354dc9cbc485e89d3)
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 #include <arch/cpu.h>
16 
17 
18 /* CPU local data structure */
19 
20 typedef struct cpu_ent {
21 	int cpu_num;
22 
23 	// thread.c: used to force a reschedule at quantum expiration time
24 	int preempted;
25 	timer quantum_timer;
26 
27 	// keeping track of CPU activity
28 	bigtime_t active_time;
29 	bigtime_t last_kernel_time;
30 	bigtime_t last_user_time;
31 
32 	bool disabled;
33 
34 	// arch-specific stuff
35 	arch_cpu_info arch;
36 } cpu_ent __attribute__((aligned(64)));
37 
38 
39 extern cpu_ent gCPU[MAX_BOOT_CPUS];
40 
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 status_t cpu_preboot_init_percpu(struct kernel_args *args, int curr_cpu);
47 status_t cpu_init(struct kernel_args *args);
48 status_t cpu_init_percpu(kernel_args *ka, int curr_cpu);
49 status_t cpu_init_post_vm(struct kernel_args *args);
50 status_t cpu_init_post_modules(struct kernel_args *args);
51 bigtime_t cpu_get_active_time(int32 cpu);
52 
53 cpu_ent *get_cpu_struct(void);
54 extern inline cpu_ent *get_cpu_struct(void) { return &gCPU[smp_get_current_cpu()]; }
55 
56 void _user_clear_caches(void *address, size_t length, uint32 flags);
57 bool _user_cpu_enabled(int32 cpu);
58 status_t _user_set_cpu_enabled(int32 cpu, bool enabled);
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 
64 #endif	/* _KERNEL_CPU_H */
65