Repository navigation
Expand file tree
/
Copy pathsmp.h
More file actions
82 lines (63 loc) · 2.31 KB
/
Copy pathsmp.h
File metadata and controls
82 lines (63 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
97CA
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef __SMP_H__
#define __SMP_H__
#ifdef CONFIG_SMP
#ifndef __ASSEMBLY__
#include "kernel/kernel.h"
#include "arch_smp.h"
#include "spinlock.h"
/* number of CPUs (execution strands in the system */
EXTERN unsigned ncpus;
/* Number of virtual strands per physical core */
EXTERN unsigned ht_per_core;
/* which cpu is bootstrapping */
EXTERN unsigned bsp_cpu_id;
#define cpu_is_bsp(cpu) (bsp_cpu_id == cpu)
/*
* SMP initialization is largely architecture dependent and each architecture
* must provide a method how to do it. If initiating SMP fails the function does
* not report it. However it must put the system in such a state that it falls
* back to a uniprocessor system. Although the uniprocessor configuration may be
* suboptimal, the system must be able to run on the bootstrap processor as if
* it was the only processor in the system
*/
void smp_init(void);
#define CPU_IS_BSP 1
#define CPU_IS_READY 2
struct cpu {
u32_t flags;
};
EXTERN struct cpu cpus[CONFIG_MAX_CPUS];
#define cpu_set_flag(cpu, flag) do { cpus[cpu].flags |= (flag); } while(0)
#define cpu_clear_flag(cpu, flag) do { cpus[cpu].flags &= ~(flag); } while(0)
#define cpu_test_flag(cpu, flag) (cpus[cpu].flags & (flag))
#define cpu_is_ready(cpu) cpu_test_flag(cpu, CPU_IS_READY)
/*
* Big Kernel Lock prevents more then one cpu executing the kernel code
*/
SPINLOCK_DECLARE(big_kernel_lock)
/*
* to sync the booting APs
*/
SPINLOCK_DECLARE(boot_lock)
void wait_for_APs_to_finish_booting(void);
void ap_boot_finished(unsigned cpu);
void smp_shutdown_aps(void );
/* IPI handlers */
void smp_ipi_halt_handler(void);
void smp_ipi_sched_handler(void);
void smp_schedule(unsigned cpu);
/* stop a processes on a different cpu */
void smp_schedule_stop_proc(struct proc * p);
/* stop a process on a different cpu because its address space is being changed */
void smp_schedule_vminhibit(struct proc * p);
/* stop the process and for saving its full context */
void smp_schedule_stop_proc_save_ctx(struct proc * p);
/* migrate the full context of a process to the destination CPU */
void smp_schedule_migrate_proc(struct proc * p, unsigned dest_cpu);
void arch_send_smp_schedule_ipi(unsigned cpu);
void arch_smp_halt_cpu(void);
/* deal with x-cpu scheduling event */
void smp_sched_handler(void);
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_SMP */
#endif /* __SMP_H__ */