First Support on Ginger and OMAP TI
[linux-ginger.git] / arch / s390 / kernel / suspend.c
blobcf9e5c6d55274ce2da221e5f258fab08c58ee21e
1 /*
2 * Suspend support specific for s390.
4 * Copyright IBM Corp. 2009
6 * Author(s): Hans-Joachim Picht <hans@linux.vnet.ibm.com>
7 */
9 #include <linux/pfn.h>
10 #include <asm/system.h>
13 * References to section boundaries
15 extern const void __nosave_begin, __nosave_end;
17 int pfn_is_nosave(unsigned long pfn)
19 unsigned long nosave_begin_pfn = PFN_DOWN(__pa(&__nosave_begin));
20 unsigned long nosave_end_pfn = PFN_DOWN(__pa(&__nosave_end));
22 /* Always save lowcore pages (LC protection might be enabled). */
23 if (pfn <= LC_PAGES)
24 return 0;
25 if (pfn >= nosave_begin_pfn && pfn < nosave_end_pfn)
26 return 1;
27 /* Skip memory holes and read-only pages (NSS, DCSS, ...). */
28 if (tprot(PFN_PHYS(pfn)))
29 return 1;
30 return 0;
33 void save_processor_state(void)
35 /* swsusp_arch_suspend() actually saves all cpu register contents.
36 * Machine checks must be disabled since swsusp_arch_suspend() stores
37 * register contents to their lowcore save areas. That's the same
38 * place where register contents on machine checks would be saved.
39 * To avoid register corruption disable machine checks.
40 * We must also disable machine checks in the new psw mask for
41 * program checks, since swsusp_arch_suspend() may generate program
42 * checks. Disabling machine checks for all other new psw masks is
43 * just paranoia.
45 local_mcck_disable();
46 /* Disable lowcore protection */
47 __ctl_clear_bit(0,28);
48 S390_lowcore.external_new_psw.mask &= ~PSW_MASK_MCHECK;
49 S390_lowcore.svc_new_psw.mask &= ~PSW_MASK_MCHECK;
50 S390_lowcore.io_new_psw.mask &= ~PSW_MASK_MCHECK;
51 S390_lowcore.program_new_psw.mask &= ~PSW_MASK_MCHECK;
54 void restore_processor_state(void)
56 S390_lowcore.external_new_psw.mask |= PSW_MASK_MCHECK;
57 S390_lowcore.svc_new_psw.mask |= PSW_MASK_MCHECK;
58 S390_lowcore.io_new_psw.mask |= PSW_MASK_MCHECK;
59 S390_lowcore.program_new_psw.mask |= PSW_MASK_MCHECK;
60 /* Enable lowcore protection */
61 __ctl_set_bit(0,28);
62 local_mcck_enable();