linux sleep and hibernate

S3:

初始化:

acpi_init

    acpi_bus_init

        acpi_sleep_init

            acpi_sleep_suspend_setup

                suspend_set_ops(old_suspend_ordering ?
&acpi_suspend_ops_old : &acpi_suspend_ops);

state_store

    pm_suspend

        enter_state

            suspend_devices_and_enter

                suspend_enter

                    error = suspend_ops->enter(state);//suspend_ops为acpi_suspend_ops_old or acpi_suspend_ops

static const struct platform_suspend_ops acpi_suspend_ops = {
.valid = acpi_suspend_state_valid,
.begin = acpi_suspend_begin,
.prepare_late = acpi_pm_prepare,
.enter = acpi_suspend_enter,
.wake = acpi_pm_finish,
.end = acpi_pm_end,

};

static const struct platform_suspend_ops acpi_suspend_ops_old = {
.valid = acpi_suspend_state_valid,
.begin = acpi_suspend_begin_old,
.prepare_late = acpi_pm_pre_suspend,
.enter = acpi_suspend_enter,
.wake = acpi_pm_finish,
.end = acpi_pm_end,
.recover = acpi_pm_finish,
};

S5是poweroff


hibernate    (kernel/power/hibernate.c)

    |- hibernation_snapshot
    |    |- create_images
    |        |- disable_nonboot_cpus        (kernel/cpu.c)
    |        |    |- _cpu_down
    |        |    |    |- take_cpu_down
    |        |    |    |    |- __cpu_disable    (arch/x86/include/asm/smp.h)    // Ensure this CPU doesn't handle any more interrupts
    |        |    |    |        |- native_cpu_disable    (arch/x86/kernel/Smpboot.c)
    |        |    |    |- __cpu_die    (arch/x86/include/asm/smp.h)    // This actually kills the CPU
    |        |    |        |- native_cpu_die    (arch/x86/kernel/Smpboot.c)
    |        |    |
    |        |    |- cpumask_set_cpu    (include/linux/cpumask.h)
    |        |    
    |        |- in_suspend = 1;
    |        |
    |        |- save_processor_state        (arch/x86/power/cpu.c)
    |        |    |- __save_processor_state
    |        |
    |        |- swsusp_arch_suspend    (arch/x86/power/hibernate_asm_32.S)
    |        |    |- swsusp_save    (kernel/power/snapshot.c)
    |        |
    |        |- restore_processor_state    (arch/x86/power/cpu.c)
    |        |
    |        |- enable_nonboot_cpus        (kernel/cpu.c)
    |
    |-     if (in_suspend) 
        {
            swsusp_write;
            power_down;
            in_suspend = 0;
        }

    

    
software_resume    (kernel/power/hibernate.c)
    |- hibernation_restore        // If successful, control returns after hibernation_snapshot->create_images->swsusp_arch_suspend
        |- resume_target_kernel
            |- disable_nonboot_cpus        (kernel/cpu.c)
            |- swsusp_arch_resume        (arch/x86/power/Hibernate_32.c)    
            |    |- restore_image    (arch/x86/power/hibernate_asm_32.S)
            |- // The code below is only ever reached in case of a failure.

猜你喜欢

转载自blog.csdn.net/qq_38712943/article/details/80175935