2005-04-16 22:20:36 +00:00
|
|
|
.text
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <asm/segment.h>
|
2009-02-13 19:14:01 +00:00
|
|
|
#include <asm/pgtable_types.h>
|
|
|
|
#include <asm/page_types.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/msr.h>
|
2007-10-23 20:37:24 +00:00
|
|
|
#include <asm/asm-offsets.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
# Copyright 2003 Pavel Machek <pavel@suse.cz>, distribute under GPLv2
|
|
|
|
|
|
|
|
.code64
|
|
|
|
/*
|
2008-04-10 21:28:10 +00:00
|
|
|
* Hooray, we are in Long 64-bit mode (but still running in low memory)
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2008-04-10 21:28:10 +00:00
|
|
|
ENTRY(wakeup_long64)
|
|
|
|
movq saved_magic, %rax
|
|
|
|
movq $0x123456789abcdef0, %rdx
|
|
|
|
cmpq %rdx, %rax
|
|
|
|
jne bogus_64_magic
|
2007-05-02 17:27:07 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
movw $__KERNEL_DS, %ax
|
|
|
|
movw %ax, %ss
|
|
|
|
movw %ax, %ds
|
|
|
|
movw %ax, %es
|
|
|
|
movw %ax, %fs
|
|
|
|
movw %ax, %gs
|
2007-05-02 17:27:07 +00:00
|
|
|
movq saved_rsp, %rsp
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-05-02 17:27:07 +00:00
|
|
|
movq saved_rbx, %rbx
|
|
|
|
movq saved_rdi, %rdi
|
|
|
|
movq saved_rsi, %rsi
|
|
|
|
movq saved_rbp, %rbp
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-05-02 17:27:07 +00:00
|
|
|
movq saved_rip, %rax
|
2005-04-16 22:20:36 +00:00
|
|
|
jmp *%rax
|
2009-02-15 21:45:49 +00:00
|
|
|
ENDPROC(wakeup_long64)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-05-02 17:27:07 +00:00
|
|
|
bogus_64_magic:
|
2008-04-10 21:28:10 +00:00
|
|
|
jmp bogus_64_magic
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-02-15 21:45:49 +00:00
|
|
|
ENTRY(do_suspend_lowlevel)
|
2005-04-16 22:20:36 +00:00
|
|
|
subq $8, %rsp
|
|
|
|
xorl %eax, %eax
|
|
|
|
call save_processor_state
|
|
|
|
|
2007-10-23 20:37:24 +00:00
|
|
|
movq $saved_context, %rax
|
2008-01-30 12:30:56 +00:00
|
|
|
movq %rsp, pt_regs_sp(%rax)
|
|
|
|
movq %rbp, pt_regs_bp(%rax)
|
|
|
|
movq %rsi, pt_regs_si(%rax)
|
|
|
|
movq %rdi, pt_regs_di(%rax)
|
|
|
|
movq %rbx, pt_regs_bx(%rax)
|
|
|
|
movq %rcx, pt_regs_cx(%rax)
|
|
|
|
movq %rdx, pt_regs_dx(%rax)
|
2007-10-23 20:37:24 +00:00
|
|
|
movq %r8, pt_regs_r8(%rax)
|
|
|
|
movq %r9, pt_regs_r9(%rax)
|
|
|
|
movq %r10, pt_regs_r10(%rax)
|
|
|
|
movq %r11, pt_regs_r11(%rax)
|
|
|
|
movq %r12, pt_regs_r12(%rax)
|
|
|
|
movq %r13, pt_regs_r13(%rax)
|
|
|
|
movq %r14, pt_regs_r14(%rax)
|
|
|
|
movq %r15, pt_regs_r15(%rax)
|
|
|
|
pushfq
|
2008-01-30 12:30:56 +00:00
|
|
|
popq pt_regs_flags(%rax)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-02-15 21:45:49 +00:00
|
|
|
movq $resume_point, saved_rip(%rip)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-10-23 20:37:24 +00:00
|
|
|
movq %rsp, saved_rsp
|
|
|
|
movq %rbp, saved_rbp
|
|
|
|
movq %rbx, saved_rbx
|
|
|
|
movq %rdi, saved_rdi
|
|
|
|
movq %rsi, saved_rsi
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
addq $8, %rsp
|
x86, acpi: Call acpi_enter_sleep_state via an asmlinkage C function from assembler
With commit a2ef5c4fd44ce3922435139393b89f2cce47f576
"ACPI: Move module parameter gts and bfs to sleep.c" the
wake_sleep_flags is required when calling acpi_enter_sleep_state.
The assembler code in wakeup_*.S did not do that. One solution
is to call it from assembler and stick the wake_sleep_flags on
the stack (for 32-bit) or in %esi (for 64-bit). hpa and rafael
both suggested however to create a wrapper function to call
acpi_enter_sleep_state and call said wrapper function
("acpi_enter_s3") from assembler.
For 32-bit, the acpi_enter_s3 ends up looking as so:
push %ebp
mov %esp,%ebp
sub $0x8,%esp
movzbl 0xc1809314,%eax [wake_sleep_flags]
movl $0x3,(%esp)
mov %eax,0x4(%esp)
call 0xc12d1fa0 <acpi_enter_sleep_state>
leave
ret
And 64-bit:
movzbl 0x9afde1(%rip),%esi [wake_sleep_flags]
push %rbp
mov $0x3,%edi
mov %rsp,%rbp
callq 0xffffffff812e9800 <acpi_enter_sleep_state>
leaveq
retq
Reviewed-by: H. Peter Anvin <hpa@zytor.com>
Suggested-by: H. Peter Anvin <hpa@zytor.com>
[v2: Remove extra assembler operations, per hpa review]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Link: http://lkml.kernel.org/r/1335150198-21899-3-git-send-email-konrad.wilk@oracle.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-04-23 03:03:18 +00:00
|
|
|
call acpi_enter_s3
|
2009-02-15 21:46:45 +00:00
|
|
|
/* in case something went wrong, restore the machine status and go on */
|
|
|
|
jmp resume_point
|
2007-10-23 20:37:24 +00:00
|
|
|
|
2009-02-15 21:45:49 +00:00
|
|
|
.align 4
|
|
|
|
resume_point:
|
2007-10-23 20:37:24 +00:00
|
|
|
/* We don't restore %rax, it must be 0 anyway */
|
|
|
|
movq $saved_context, %rax
|
|
|
|
movq saved_context_cr4(%rax), %rbx
|
|
|
|
movq %rbx, %cr4
|
|
|
|
movq saved_context_cr3(%rax), %rbx
|
|
|
|
movq %rbx, %cr3
|
|
|
|
movq saved_context_cr2(%rax), %rbx
|
|
|
|
movq %rbx, %cr2
|
|
|
|
movq saved_context_cr0(%rax), %rbx
|
|
|
|
movq %rbx, %cr0
|
2008-01-30 12:30:56 +00:00
|
|
|
pushq pt_regs_flags(%rax)
|
2007-10-23 20:37:24 +00:00
|
|
|
popfq
|
2008-01-30 12:30:56 +00:00
|
|
|
movq pt_regs_sp(%rax), %rsp
|
|
|
|
movq pt_regs_bp(%rax), %rbp
|
|
|
|
movq pt_regs_si(%rax), %rsi
|
|
|
|
movq pt_regs_di(%rax), %rdi
|
|
|
|
movq pt_regs_bx(%rax), %rbx
|
|
|
|
movq pt_regs_cx(%rax), %rcx
|
|
|
|
movq pt_regs_dx(%rax), %rdx
|
2007-10-23 20:37:24 +00:00
|
|
|
movq pt_regs_r8(%rax), %r8
|
|
|
|
movq pt_regs_r9(%rax), %r9
|
|
|
|
movq pt_regs_r10(%rax), %r10
|
|
|
|
movq pt_regs_r11(%rax), %r11
|
|
|
|
movq pt_regs_r12(%rax), %r12
|
|
|
|
movq pt_regs_r13(%rax), %r13
|
|
|
|
movq pt_regs_r14(%rax), %r14
|
|
|
|
movq pt_regs_r15(%rax), %r15
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
xorl %eax, %eax
|
|
|
|
addq $8, %rsp
|
|
|
|
jmp restore_processor_state
|
2009-02-15 21:45:49 +00:00
|
|
|
ENDPROC(do_suspend_lowlevel)
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
.data
|
2007-05-02 17:27:07 +00:00
|
|
|
ENTRY(saved_rbp) .quad 0
|
|
|
|
ENTRY(saved_rsi) .quad 0
|
|
|
|
ENTRY(saved_rdi) .quad 0
|
|
|
|
ENTRY(saved_rbx) .quad 0
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-05-02 17:27:07 +00:00
|
|
|
ENTRY(saved_rip) .quad 0
|
|
|
|
ENTRY(saved_rsp) .quad 0
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
ENTRY(saved_magic) .quad 0
|