ldivmod, uldivmod: fix qdivrem calls
[minix.git] / kernel / cpulocals.h
bloba13e58a61c7a7f9568562706ba072a93c179fa12
1 /* Implementation of CPU local variables generics */
2 #ifndef __CPULOCALS_H__
3 #define __CPULOCALS_H__
5 #ifndef __ASSEMBLY__
7 #ifdef CONFIG_SMP
9 /* SMP */
11 #define CPULOCAL_ARRAY [CONFIG_MAX_CPUS]
13 #define get_cpu_var(cpu, name) CPULOCAL_STRUCT[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)
18 /* FIXME - padd the structure so that items in the array do not share cacheline
19 * with other cpus */
21 #else
23 /* single CPU */
25 #define CPULOCAL_ARRAY
27 #define get_cpulocal_var(name) CPULOCAL_STRUCT.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)
32 #endif
36 #define DECLARE_CPULOCAL(type, name) type name
38 #define CPULOCAL_STRUCT __cpu_local_vars
39 #define ___CPULOCAL_START struct CPULOCAL_STRUCT {
40 #define ___CPULOCAL_END } CPULOCAL_STRUCT CPULOCAL_ARRAY;
42 #define DECLARE_CPULOCAL_START extern ___CPULOCAL_START
43 #define DECLARE_CPULOCAL_END ___CPULOCAL_END
45 #define DEFINE_CPULOCAL_VARS struct CPULOCAL_STRUCT CPULOCAL_STRUCT CPULOCAL_ARRAY
49 * The global cpu local variables in use
51 DECLARE_CPULOCAL_START
53 /* Process scheduling information and the kernel reentry count. */
54 DECLARE_CPULOCAL(struct proc *,proc_ptr);/* pointer to currently running process */
55 DECLARE_CPULOCAL(struct proc *,bill_ptr);/* process to bill for clock ticks */
56 DECLARE_CPULOCAL(struct proc ,idle_proc);/* stub for an idle process */
58 /*
59 * signal whether pagefault is already being handled to detect recursive
60 * pagefaults
62 DECLARE_CPULOCAL(int, pagefault_handled);
65 * which processpage tables are loaded right now. We need to know this because
66 * some processes are loaded in each process pagetables and don't have their own
67 * pagetables. Therefore we cannot use the proc_ptr pointer
69 DECLARE_CPULOCAL(struct proc *, ptproc);
71 /* CPU private run queues */
72 DECLARE_CPULOCAL(struct proc *, run_q_head[NR_SCHED_QUEUES]); /* ptrs to ready list headers */
73 DECLARE_CPULOCAL(struct proc *, run_q_tail[NR_SCHED_QUEUES]); /* ptrs to ready list tails */
74 DECLARE_CPULOCAL(volatile int, cpu_is_idle); /* let the others know that you are idle */
76 DECLARE_CPULOCAL(volatile int, idle_interrupted); /* to interrupt busy-idle
77 while profiling */
79 DECLARE_CPULOCAL(u64_t ,tsc_ctr_switch); /* when did we switched time accounting */
81 /* last values read from cpu when sending ooq msg to scheduler */
82 DECLARE_CPULOCAL(u64_t, cpu_last_tsc);
83 DECLARE_CPULOCAL(u64_t, cpu_last_idle);
86 DECLARE_CPULOCAL(char ,fpu_presence); /* whether the cpu has FPU or not */
87 DECLARE_CPULOCAL(struct proc * ,fpu_owner); /* who owns the FPU of the local cpu */
89 DECLARE_CPULOCAL_END
91 #endif /* __ASSEMBLY__ */
93 #endif /* __CPULOCALS_H__ */