suspend.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_post_suspend(int suspend_cancelled)
  23. {
  24. xen_build_mfn_list_list();
  25. xen_setup_shared_info();
  26. if (suspend_cancelled) {
  27. xen_start_info->store_mfn =
  28. pfn_to_mfn(xen_start_info->store_mfn);
  29. xen_start_info->console.domU.mfn =
  30. pfn_to_mfn(xen_start_info->console.domU.mfn);
  31. } else {
  32. #ifdef CONFIG_SMP
  33. BUG_ON(xen_cpu_initialized_map == NULL);
  34. cpumask_copy(xen_cpu_initialized_map, cpu_online_mask);
  35. #endif
  36. xen_vcpu_restore();
  37. }
  38. }
  39. static void xen_vcpu_notify_restore(void *data)
  40. {
  41. unsigned long reason = (unsigned long)data;
  42. /* Boot processor notified via generic timekeeping_resume() */
  43. if ( smp_processor_id() == 0)
  44. return;
  45. clockevents_notify(reason, NULL);
  46. }
  47. void xen_arch_resume(void)
  48. {
  49. on_each_cpu(xen_vcpu_notify_restore,
  50. (void *)CLOCK_EVT_NOTIFY_RESUME, 1);
  51. }