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 get_cpu_maps(void); 10 void put_cpu_maps(void); 11 12 /* Safely perform CPU hotplug and update cpu_online_map, etc. */ 13 void 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 * in the resume case we have additionally: 26 * CPU_UP_PREPARE -> CPU_UP_CANCELLED -> CPU_RESUME_FAILED -- CPU not resumed 27 * with the CPU_RESUME_FAILED handler called only after all CPUs have been 28 * tried to put online again in order to know which CPUs did restart 29 * successfully. 30 * 31 * Hence note that only CPU_*_PREPARE handlers are allowed to fail. Also note 32 * that once CPU_DYING is delivered, an offline action can no longer fail. 33 * 34 * Notifiers are called highest-priority-first when: 35 * (a) A CPU is coming up; or (b) CPU_DOWN_FAILED 36 * Notifiers are called lowest-priority-first when: 37 * (a) A CPU is going down; or (b) CPU_UP_CANCELED 38 */ 39 /* CPU_UP_PREPARE: Preparing to bring CPU online. */ 40 #define CPU_UP_PREPARE (0x0001 | NOTIFY_FORWARD) 41 /* CPU_UP_CANCELED: CPU is no longer being brought online. */ 42 #define CPU_UP_CANCELED (0x0002 | NOTIFY_REVERSE) 43 /* CPU_STARTING: CPU nearly online. Runs on new CPU, irqs still disabled. */ 44 #define CPU_STARTING (0x0003 | NOTIFY_FORWARD) 45 /* CPU_ONLINE: CPU is up. */ 46 #define CPU_ONLINE (0x0004 | NOTIFY_FORWARD) 47 /* CPU_DOWN_PREPARE: CPU is going down. */ 48 #define CPU_DOWN_PREPARE (0x0005 | NOTIFY_REVERSE) 49 /* CPU_DOWN_FAILED: CPU is no longer going down. */ 50 #define CPU_DOWN_FAILED (0x0006 | NOTIFY_FORWARD) 51 /* CPU_DYING: CPU is nearly dead (in stop_machine context). */ 52 #define CPU_DYING (0x0007 | NOTIFY_REVERSE) 53 /* CPU_DEAD: CPU is dead. */ 54 #define CPU_DEAD (0x0008 | NOTIFY_REVERSE) 55 /* CPU_REMOVE: CPU was removed. */ 56 #define CPU_REMOVE (0x0009 | NOTIFY_REVERSE) 57 /* CPU_RESUME_FAILED: CPU failed to come up in resume, all other CPUs up. */ 58 #define CPU_RESUME_FAILED (0x000a | NOTIFY_REVERSE) 59 60 /* Perform CPU hotplug. May return -EAGAIN. */ 61 int cpu_down(unsigned int cpu); 62 int cpu_up(unsigned int cpu); 63 64 /* From arch code, send CPU_STARTING notification. */ 65 void notify_cpu_starting(unsigned int cpu); 66 67 /* Power management. */ 68 int disable_nonboot_cpus(void); 69 void enable_nonboot_cpus(void); 70 71 /* Private arch-dependent helpers for CPU hotplug. */ 72 int __cpu_up(unsigned int cpunum); 73 void __cpu_disable(void); 74 void __cpu_die(unsigned int cpu); 75 76 #endif /* __XEN_CPU_H__ */ 77