blob: 987267f79bf5154648cb729cedf29e712fa58ab3 [file] [log] [blame]
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +01001#include <linux/types.h>
Ian Campbellf6eafe32009-11-25 14:12:08 +00002#include <linux/clockchips.h>
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +01003
4#include <xen/interface/xen.h>
5#include <xen/grant_table.h>
6#include <xen/events.h>
7
8#include <asm/xen/hypercall.h>
9#include <asm/xen/page.h>
Ingo Molnar99d00002009-01-23 11:09:15 +010010#include <asm/fixmap.h>
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010011
12#include "xen-ops.h"
13#include "mmu.h"
14
15void xen_pre_suspend(void)
16{
17 xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
18 xen_start_info->console.domU.mfn =
19 mfn_to_pfn(xen_start_info->console.domU.mfn);
20
21 BUG_ON(!irqs_disabled());
22
23 HYPERVISOR_shared_info = &xen_dummy_shared_info;
24 if (HYPERVISOR_update_va_mapping(fix_to_virt(FIX_PARAVIRT_BOOTMAP),
25 __pte_ma(0), 0))
26 BUG();
27}
28
29void xen_post_suspend(int suspend_cancelled)
30{
Ian Campbellfa24ba62009-11-21 11:32:49 +000031 xen_build_mfn_list_list();
32
Jeremy Fitzhardinge9c7a7942008-05-31 01:33:02 +010033 xen_setup_shared_info();
34
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010035 if (suspend_cancelled) {
36 xen_start_info->store_mfn =
37 pfn_to_mfn(xen_start_info->store_mfn);
38 xen_start_info->console.domU.mfn =
39 pfn_to_mfn(xen_start_info->console.domU.mfn);
40 } else {
41#ifdef CONFIG_SMP
Mike Travisb78936e2008-12-16 17:33:57 -080042 BUG_ON(xen_cpu_initialized_map == NULL);
43 cpumask_copy(xen_cpu_initialized_map, cpu_online_mask);
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010044#endif
Jeremy Fitzhardinge9c7a7942008-05-31 01:33:02 +010045 xen_vcpu_restore();
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010046 }
47
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010048}
49
Ian Campbellf6eafe32009-11-25 14:12:08 +000050static void xen_vcpu_notify_restore(void *data)
51{
52 unsigned long reason = (unsigned long)data;
53
54 /* Boot processor notified via generic timekeeping_resume() */
55 if ( smp_processor_id() == 0)
56 return;
57
58 clockevents_notify(reason, NULL);
59}
60
Isaku Yamahataad55db92008-07-08 15:06:32 -070061void xen_arch_resume(void)
62{
Ian Campbellf6eafe32009-11-25 14:12:08 +000063 smp_call_function(xen_vcpu_notify_restore,
64 (void *)CLOCK_EVT_NOTIFY_RESUME, 1);
Isaku Yamahataad55db92008-07-08 15:06:32 -070065}