suspend.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include <linux/types.h>
  2. #include <linux/clockchips.h>
  3. #include <xen/interface/xen.h>
  4. #include <xen/grant_table.h>
  5. #include <xen/events.h>
  6. #include <asm/xen/hypercall.h>
  7. #include <asm/xen/page.h>
  8. #include <asm/fixmap.h>
  9. #include "xen-ops.h"
  10. #include "mmu.h"
  11. void xen_pre_suspend(void)
  12. {
  13. xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
  14. xen_start_info->console.domU.mfn =
  15. mfn_to_pfn(xen_start_info->console.domU.mfn);
  16. BUG_ON(!irqs_disabled());
  17. HYPERVISOR_shared_info = &xen_dummy_shared_info;
  18. if (HYPERVISOR_update_va_mapping(fix_to_virt(FIX_PARAVIRT_BOOTMAP),
  19. __pte_ma(0), 0))
  20. BUG();
  21. }
  22. void xen_hvm_post_suspend(int suspend_cancelled)
  23. {
  24. int cpu;
  25. xen_hvm_init_shared_info();
  26. xen_callback_vector();
  27. if (xen_feature(XENFEAT_hvm_safe_pvclock)) {
  28. for_each_online_cpu(cpu) {
  29. xen_setup_runstate_info(cpu);
  30. }
  31. }
  32. }
  33. void xen_post_suspend(int suspend_cancelled)
  34. {
  35. xen_build_mfn_list_list();
  36. xen_setup_shared_info();
  37. if (suspend_cancelled) {
  38. xen_start_info->store_mfn =
  39. pfn_to_mfn(xen_start_info->store_mfn);
  40. xen_start_info->console.domU.mfn =
  41. pfn_to_mfn(xen_start_info->console.domU.mfn);
  42. } else {
  43. #ifdef CONFIG_SMP
  44. BUG_ON(xen_cpu_initialized_map == NULL);
  45. cpumask_copy(xen_cpu_initialized_map, cpu_online_mask);
  46. #endif
  47. xen_vcpu_restore();
  48. }
  49. }
  50. static void xen_vcpu_notify_restore(void *data)
  51. {
  52. unsigned long reason = (unsigned long)data;
  53. /* Boot processor notified via generic timekeeping_resume() */
  54. if ( smp_processor_id() == 0)
  55. return;
  56. clockevents_notify(reason, NULL);
  57. }
  58. void xen_arch_resume(void)
  59. {
  60. on_each_cpu(xen_vcpu_notify_restore,
  61. (void *)CLOCK_EVT_NOTIFY_RESUME, 1);
  62. }