Linux-Suspend-to-Disk【Hibernate,S4】

S4:suspend to disk


基于Linux-3.16.0内核

  (1)进入S4的调用脉络

state_store
   hibernate
      hibernation_snapshot
         create_image
             swsusp_arch_suspend//调用汇编code,进入S4
             /*当从S4返回时会接着执行后面的code
              *S4返回是由new kernel通过software_resume转到该处执行
              *software_resume是在initcall 7s段执行
              */
             ...
             restore_processor_state
             ...

(2)从S4返回。称S4返回时的kernel为new kernel,进入S4之前的kernel为old kernel。从S4返回的时候,new kernel执行software_resume,首先suspend当前new kernel,然后会转向old kernel调用swsusp_arch_suspend的地方继续执行,这样就把平台切换到old kernel状态。如果resume失败,那么就会让new kernel从suspend状态返回,平台的控制权还是在new kernel手中。

/*#define late_initcall_sync(fn)		__define_initcall(fn, 7s)*/
late_initcall_sync(software_resume);

software_resume
    hibernation_restore
        resume_target_kernel
            swsusp_arch_resume
            /*接下来的执行会转向swsusp_arch_suspend调用的地方执行
             *只有resume失败的时候才会执行后续的code
             */

(3)hibernation_ops的初始化脉络,hibernation_ops最终初始为acpi_hibernation_ops/acpi_hibernation_ops_old

/*#define subsys_initcall(fn)		__define_initcall(fn, 4)*/
subsys_initcall(acpi_init);

acpi_init
   acpi_bus_init
           acpi_sleep_init
               acpi_sleep_suspend_setup//S3时ops的初始化
               acpi_sleep_hibernate_setup//S4时ops的初始化
                     hibernation_set_ops(old_suspend_ordering ? &acpi_hibernation_ops_old : &acpi_hibernation_ops);

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值