1  #ifndef __XEN_CPU_H__
2  #define __XEN_CPU_H__
3  
4  #include <xen/types.h>
5  #include <xen/spinlock.h>
6  #include <xen/notifier.h>
7  
8  /* Safely access cpu_online_map, cpu_present_map, etc. */
9  bool_t get_cpu_maps(void);
10  void put_cpu_maps(void);
11  
12  /* Safely perform CPU hotplug and update cpu_online_map, etc. */
13  bool_t cpu_hotplug_begin(void);
14  void cpu_hotplug_done(void);
15  
16  /* Receive notification of CPU hotplug events. */
17  void register_cpu_notifier(struct notifier_block *nb);
18  
19  /*
20   * Possible event sequences for a given CPU:
21   *  CPU_UP_PREPARE -> CPU_UP_CANCELLED           -- failed CPU up
22   *  CPU_UP_PREPARE -> CPU_STARTING -> CPU_ONLINE -- successful CPU up
23   *  CPU_DOWN_PREPARE -> CPU_DOWN_FAILED          -- failed CPU down
24   *  CPU_DOWN_PREPARE -> CPU_DYING -> CPU_DEAD    -- successful CPU down
25   *
26   * Hence note that only CPU_*_PREPARE handlers are allowed to fail. Also note
27   * that once CPU_DYING is delivered, an offline action can no longer fail.
28   *
29   * Notifiers are called highest-priority-first when:
30   *  (a) A CPU is coming up; or (b) CPU_DOWN_FAILED
31   * Notifiers are called lowest-priority-first when:
32   *  (a) A CPU is going down; or (b) CPU_UP_CANCELED
33   */
34  /* CPU_UP_PREPARE: Preparing to bring CPU online. */
35  #define CPU_UP_PREPARE   (0x0001 | NOTIFY_FORWARD)
36  /* CPU_UP_CANCELED: CPU is no longer being brought online. */
37  #define CPU_UP_CANCELED  (0x0002 | NOTIFY_REVERSE)
38  /* CPU_STARTING: CPU nearly online. Runs on new CPU, irqs still disabled. */
39  #define CPU_STARTING     (0x0003 | NOTIFY_FORWARD)
40  /* CPU_ONLINE: CPU is up. */
41  #define CPU_ONLINE       (0x0004 | NOTIFY_FORWARD)
42  /* CPU_DOWN_PREPARE: CPU is going down. */
43  #define CPU_DOWN_PREPARE (0x0005 | NOTIFY_REVERSE)
44  /* CPU_DOWN_FAILED: CPU is no longer going down. */
45  #define CPU_DOWN_FAILED  (0x0006 | NOTIFY_FORWARD)
46  /* CPU_DYING: CPU is nearly dead (in stop_machine context). */
47  #define CPU_DYING        (0x0007 | NOTIFY_REVERSE)
48  /* CPU_DEAD: CPU is dead. */
49  #define CPU_DEAD         (0x0008 | NOTIFY_REVERSE)
50  
51  /* Perform CPU hotplug. May return -EAGAIN. */
52  int cpu_down(unsigned int cpu);
53  int cpu_up(unsigned int cpu);
54  
55  /* From arch code, send CPU_STARTING notification. */
56  void notify_cpu_starting(unsigned int cpu);
57  
58  /* Power management. */
59  int disable_nonboot_cpus(void);
60  void enable_nonboot_cpus(void);
61  
62  /* Private arch-dependent helpers for CPU hotplug. */
63  int __cpu_up(unsigned int cpunum);
64  void __cpu_disable(void);
65  void __cpu_die(unsigned int cpu);
66  
67  #endif /* __XEN_CPU_H__ */
68