~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/kernel/hibernate.c

Version: ~ [ linux-6.0-rc6 ] ~ [ linux-5.19.10 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.69 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.144 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.214 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.259 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.294 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.329 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Hibernation support specific for ARM
  3  *
  4  * Derived from work on ARM hibernation support by:
  5  *
  6  * Ubuntu project, hibernation support for mach-dove
  7  * Copyright (C) 2010 Nokia Corporation (Hiroshi Doyu)
  8  * Copyright (C) 2010 Texas Instruments, Inc. (Teerth Reddy et al.)
  9  *  https://lkml.org/lkml/2010/6/18/4
 10  *  https://lists.linux-foundation.org/pipermail/linux-pm/2010-June/027422.html
 11  *  https://patchwork.kernel.org/patch/96442/
 12  *
 13  * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
 14  *
 15  * License terms: GNU General Public License (GPL) version 2
 16  */
 17 
 18 #include <linux/mm.h>
 19 #include <linux/suspend.h>
 20 #include <asm/system_misc.h>
 21 #include <asm/idmap.h>
 22 #include <asm/suspend.h>
 23 #include <asm/memory.h>
 24 #include <asm/sections.h>
 25 #include "reboot.h"
 26 
 27 int pfn_is_nosave(unsigned long pfn)
 28 {
 29         unsigned long nosave_begin_pfn = virt_to_pfn(&__nosave_begin);
 30         unsigned long nosave_end_pfn = virt_to_pfn(&__nosave_end - 1);
 31 
 32         return (pfn >= nosave_begin_pfn) && (pfn <= nosave_end_pfn);
 33 }
 34 
 35 void notrace save_processor_state(void)
 36 {
 37         WARN_ON(num_online_cpus() != 1);
 38         local_fiq_disable();
 39 }
 40 
 41 void notrace restore_processor_state(void)
 42 {
 43         local_fiq_enable();
 44 }
 45 
 46 /*
 47  * Snapshot kernel memory and reset the system.
 48  *
 49  * swsusp_save() is executed in the suspend finisher so that the CPU
 50  * context pointer and memory are part of the saved image, which is
 51  * required by the resume kernel image to restart execution from
 52  * swsusp_arch_suspend().
 53  *
 54  * soft_restart is not technically needed, but is used to get success
 55  * returned from cpu_suspend.
 56  *
 57  * When soft reboot completes, the hibernation snapshot is written out.
 58  */
 59 static int notrace arch_save_image(unsigned long unused)
 60 {
 61         int ret;
 62 
 63         ret = swsusp_save();
 64         if (ret == 0)
 65                 _soft_restart(virt_to_idmap(cpu_resume), false);
 66         return ret;
 67 }
 68 
 69 /*
 70  * Save the current CPU state before suspend / poweroff.
 71  */
 72 int notrace swsusp_arch_suspend(void)
 73 {
 74         return cpu_suspend(0, arch_save_image);
 75 }
 76 
 77 /*
 78  * Restore page contents for physical pages that were in use during loading
 79  * hibernation image.  Switch to idmap_pgd so the physical page tables
 80  * are overwritten with the same contents.
 81  */
 82 static void notrace arch_restore_image(void *unused)
 83 {
 84         struct pbe *pbe;
 85 
 86         cpu_switch_mm(idmap_pgd, &init_mm);
 87         for (pbe = restore_pblist; pbe; pbe = pbe->next)
 88                 copy_page(pbe->orig_address, pbe->address);
 89 
 90         _soft_restart(virt_to_idmap(cpu_resume), false);
 91 }
 92 
 93 static u64 resume_stack[PAGE_SIZE/2/sizeof(u64)] __nosavedata;
 94 
 95 /*
 96  * Resume from the hibernation image.
 97  * Due to the kernel heap / data restore, stack contents change underneath
 98  * and that would make function calls impossible; switch to a temporary
 99  * stack within the nosave region to avoid that problem.
100  */
101 int swsusp_arch_resume(void)
102 {
103         call_with_stack(arch_restore_image, 0,
104                 resume_stack + ARRAY_SIZE(resume_stack));
105         return 0;
106 }
107 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp