0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include <linux/mm.h>
0018 #include <linux/suspend.h>
0019 #include <asm/system_misc.h>
0020 #include <asm/idmap.h>
0021 #include <asm/suspend.h>
0022 #include <asm/memory.h>
0023 #include <asm/sections.h>
0024 #include "reboot.h"
0025
0026 int pfn_is_nosave(unsigned long pfn)
0027 {
0028 unsigned long nosave_begin_pfn = virt_to_pfn(&__nosave_begin);
0029 unsigned long nosave_end_pfn = virt_to_pfn(&__nosave_end - 1);
0030
0031 return (pfn >= nosave_begin_pfn) && (pfn <= nosave_end_pfn);
0032 }
0033
0034 void notrace save_processor_state(void)
0035 {
0036 WARN_ON(num_online_cpus() != 1);
0037 local_fiq_disable();
0038 }
0039
0040 void notrace restore_processor_state(void)
0041 {
0042 local_fiq_enable();
0043 }
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 static int notrace arch_save_image(unsigned long unused)
0059 {
0060 int ret;
0061
0062 ret = swsusp_save();
0063 if (ret == 0)
0064 _soft_restart(virt_to_idmap(cpu_resume), false);
0065 return ret;
0066 }
0067
0068
0069
0070
0071 int notrace swsusp_arch_suspend(void)
0072 {
0073 return cpu_suspend(0, arch_save_image);
0074 }
0075
0076
0077
0078
0079
0080
0081 static void notrace arch_restore_image(void *unused)
0082 {
0083 struct pbe *pbe;
0084
0085 cpu_switch_mm(idmap_pgd, &init_mm);
0086 for (pbe = restore_pblist; pbe; pbe = pbe->next)
0087 copy_page(pbe->orig_address, pbe->address);
0088
0089 _soft_restart(virt_to_idmap(cpu_resume), false);
0090 }
0091
0092 static u64 resume_stack[PAGE_SIZE/2/sizeof(u64)] __nosavedata;
0093
0094
0095
0096
0097
0098
0099
0100 int swsusp_arch_resume(void)
0101 {
0102 call_with_stack(arch_restore_image, 0,
0103 resume_stack + ARRAY_SIZE(resume_stack));
0104 return 0;
0105 }