xref: /minix3/minix/kernel/cpulocals.h (revision 733a844ac6282c03308d5ea03426b5863dfb06c3)
1 /* Implementation of CPU local variables generics */
2 #ifndef __CPULOCALS_H__
3 #define __CPULOCALS_H__
4 
5 #ifndef __ASSEMBLY__
6 
7 #ifdef CONFIG_SMP
8 
9 /* SMP */
10 
11 #define CPULOCAL_ARRAY	[CONFIG_MAX_CPUS]
12 
13 #define get_cpu_var(cpu, name)		__cpu_local_vars[cpu].name
14 #define get_cpu_var_ptr(cpu, name)	(&(get_cpu_var(cpu, name)))
15 #define get_cpulocal_var(name)		get_cpu_var(cpuid, name)
16 #define get_cpulocal_var_ptr(name)	get_cpu_var_ptr(cpuid, name)
17 
18 /* FIXME - padd the structure so that items in the array do not share cacheline
19  * with other cpus */
20 
21 #else
22 
23 /* single CPU */
24 
25 #define CPULOCAL_ARRAY
26 
27 #define get_cpulocal_var(name)		__cpu_local_vars.name
28 #define get_cpulocal_var_ptr(name)	&(get_cpulocal_var(name))
29 #define get_cpu_var(cpu, name)		get_cpulocal_var(name)
30 #define get_cpu_var_ptr(cpu, name)	get_cpulocal_var_ptr(name)
31 
32 #endif
33 
34 /*
35  * The global cpu local variables in use
36  */
37 extern struct __cpu_local_vars {
38 
39 /* Process scheduling information and the kernel reentry count. */
40 	struct proc *proc_ptr;/* pointer to currently running process */
41 	struct proc *bill_ptr;/* process to bill for clock ticks */
42 	struct proc idle_proc;/* stub for an idle process */
43 
44 /*
45  * signal whether pagefault is already being handled to detect recursive
46  * pagefaults
47  */
48 	int pagefault_handled;
49 
50 /*
51  * which processpage tables are loaded right now. We need to know this because
52  * some processes are loaded in each process pagetables and don't have their own
53  * pagetables. Therefore we cannot use the proc_ptr pointer
54  */
55 	struct proc * ptproc;
56 
57 /* CPU private run queues */
58 	struct proc * run_q_head[NR_SCHED_QUEUES]; /* ptrs to ready list headers */
59 	struct proc * run_q_tail[NR_SCHED_QUEUES]; /* ptrs to ready list tails */
60 	int cpu_is_idle; /* let the others know that you are idle */
61 
62 	int idle_interrupted; /* to interrupt busy-idle
63 						     while profiling */
64 
65 	u64_t tsc_ctr_switch; /* when did we switched time accounting */
66 
67 /* last values read from cpu when sending ooq msg to scheduler */
68 	u64_t cpu_last_tsc;
69 	u64_t cpu_last_idle;
70 
71 
72 	char fpu_presence; /* whether the cpu has FPU or not */
73 	struct proc * fpu_owner; /* who owns the FPU of the local cpu */
74 
75 } __cpu_local_vars CPULOCAL_ARRAY;
76 
77 #endif /* __ASSEMBLY__ */
78 
79 #endif /* __CPULOCALS_H__ */
80