suspend.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_arch_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_arch_hvm_post_suspend(int suspend_cancelled)
  23. {
  24. #ifdef CONFIG_XEN_PVHVM
  25. int cpu;
  26. xen_hvm_init_shared_info();
  27. xen_callback_vector();
  28. xen_unplug_emulated_devices();
  29. if (xen_feature(XENFEAT_hvm_safe_pvclock)) {
  30. for_each_online_cpu(cpu) {
  31. xen_setup_runstate_info(cpu);
  32. }
  33. }
  34. #endif
  35. }
  36. void xen_arch_post_suspend(int suspend_cancelled)
  37. {
  38. xen_build_mfn_list_list();
  39. xen_setup_shared_info();
  40. if (suspend_cancelled) {
  41. xen_start_info->store_mfn =
  42. pfn_to_mfn(xen_start_info->store_mfn);
  43. xen_start_info->console.domU.mfn =
  44. pfn_to_mfn(xen_start_info->console.domU.mfn);
  45. } else {
  46. #ifdef CONFIG_SMP
  47. BUG_ON(xen_cpu_initialized_map == NULL);
  48. cpumask_copy(xen_cpu_initialized_map, cpu_online_mask);
  49. #endif
  50. xen_vcpu_restore();
  51. }
  52. }
  53. static void xen_vcpu_notify_restore(void *data)
  54. {
  55. unsigned long reason = (unsigned long)data;
  56. /* Boot processor notified via generic timekeeping_resume() */
  57. if ( smp_processor_id() == 0)
  58. return;
  59. clockevents_notify(reason, NULL);
  60. }
  61. void xen_arch_resume(void)
  62. {
  63. on_each_cpu(xen_vcpu_notify_restore,
  64. (void *)CLOCK_EVT_NOTIFY_RESUME, 1);
  65. }