Linux Audio

Check our new training course

Embedded Linux training

Mar 10-20, 2025, special US time zones
Register
Loading...
v6.13.7
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2	.text
  3#include <linux/linkage.h>
  4#include <asm/segment.h>
  5#include <asm/page_types.h>
  6
  7# Copyright 2003, 2008 Pavel Machek <pavel@suse.cz
  8
  9	.code32
 10	ALIGN
 11
 12SYM_CODE_START(wakeup_pmode_return)
 
 13	movw	$__KERNEL_DS, %ax
 14	movw	%ax, %ss
 15	movw	%ax, %fs
 16	movw	%ax, %gs
 17
 18	movw	$__USER_DS, %ax
 19	movw	%ax, %ds
 20	movw	%ax, %es
 
 
 21
 22	# reload the gdt, as we need the full 32 bit address
 23	lidt	saved_idt
 24	lldt	saved_ldt
 25	ljmp	$(__KERNEL_CS), $1f
 261:
 27	movl	%cr3, %eax
 28	movl	%eax, %cr3
 29	wbinvd
 30
 31	# and restore the stack ... but you need gdt for this to work
 32	movl	saved_context_esp, %esp
 33
 34	movl	%cs:saved_magic, %eax
 35	cmpl	$0x12345678, %eax
 36	jne	bogus_magic
 37
 38	# jump to place where we left off
 39	movl	saved_eip, %eax
 40	jmp	*%eax
 41SYM_CODE_END(wakeup_pmode_return)
 42
 43bogus_magic:
 44	jmp	bogus_magic
 45
 46
 47
 48save_registers:
 49	sidt	saved_idt
 50	sldt	saved_ldt
 51	str	saved_tss
 52
 53	leal	4(%esp), %eax
 54	movl	%eax, saved_context_esp
 55	movl	%ebx, saved_context_ebx
 56	movl	%ebp, saved_context_ebp
 57	movl	%esi, saved_context_esi
 58	movl	%edi, saved_context_edi
 59	pushfl
 60	popl	saved_context_eflags
 61
 62	movl	$ret_point, saved_eip
 63	RET
 64
 65
 66restore_registers:
 67	movl	saved_context_ebp, %ebp
 68	movl	saved_context_ebx, %ebx
 69	movl	saved_context_esi, %esi
 70	movl	saved_context_edi, %edi
 71	pushl	saved_context_eflags
 72	popfl
 73	RET
 74
 75SYM_CODE_START(do_suspend_lowlevel)
 76	call	save_processor_state
 77	call	save_registers
 78	pushl	$3
 79	call	x86_acpi_enter_sleep_state
 80	addl	$4, %esp
 81
 82#	In case of S3 failure, we'll emerge here.  Jump
 83# 	to ret_point to recover
 84	jmp	ret_point
 85	.p2align 4,,7
 86ret_point:
 87	call	restore_registers
 88	call	restore_processor_state
 89	RET
 90SYM_CODE_END(do_suspend_lowlevel)
 91
 92.data
 93ALIGN
 94SYM_DATA(saved_magic,	.long 0)
 95saved_eip:		.long 0
 96
 97# saved registers
 98saved_idt:	.long	0,0
 99saved_ldt:	.long	0
100saved_tss:	.long	0
101
v3.15
 
 1	.text
 2#include <linux/linkage.h>
 3#include <asm/segment.h>
 4#include <asm/page_types.h>
 5
 6# Copyright 2003, 2008 Pavel Machek <pavel@suse.cz>, distribute under GPLv2
 7
 8	.code32
 9	ALIGN
10
11ENTRY(wakeup_pmode_return)
12wakeup_pmode_return:
13	movw	$__KERNEL_DS, %ax
14	movw	%ax, %ss
 
 
 
 
15	movw	%ax, %ds
16	movw	%ax, %es
17	movw	%ax, %fs
18	movw	%ax, %gs
19
20	# reload the gdt, as we need the full 32 bit address
21	lidt	saved_idt
22	lldt	saved_ldt
23	ljmp	$(__KERNEL_CS), $1f
241:
25	movl	%cr3, %eax
26	movl	%eax, %cr3
27	wbinvd
28
29	# and restore the stack ... but you need gdt for this to work
30	movl	saved_context_esp, %esp
31
32	movl	%cs:saved_magic, %eax
33	cmpl	$0x12345678, %eax
34	jne	bogus_magic
35
36	# jump to place where we left off
37	movl	saved_eip, %eax
38	jmp	*%eax
 
39
40bogus_magic:
41	jmp	bogus_magic
42
43
44
45save_registers:
46	sidt	saved_idt
47	sldt	saved_ldt
48	str	saved_tss
49
50	leal	4(%esp), %eax
51	movl	%eax, saved_context_esp
52	movl	%ebx, saved_context_ebx
53	movl	%ebp, saved_context_ebp
54	movl	%esi, saved_context_esi
55	movl	%edi, saved_context_edi
56	pushfl
57	popl	saved_context_eflags
58
59	movl	$ret_point, saved_eip
60	ret
61
62
63restore_registers:
64	movl	saved_context_ebp, %ebp
65	movl	saved_context_ebx, %ebx
66	movl	saved_context_esi, %esi
67	movl	saved_context_edi, %edi
68	pushl	saved_context_eflags
69	popfl
70	ret
71
72ENTRY(do_suspend_lowlevel)
73	call	save_processor_state
74	call	save_registers
75	pushl	$3
76	call	x86_acpi_enter_sleep_state
77	addl	$4, %esp
78
79#	In case of S3 failure, we'll emerge here.  Jump
80# 	to ret_point to recover
81	jmp	ret_point
82	.p2align 4,,7
83ret_point:
84	call	restore_registers
85	call	restore_processor_state
86	ret
 
87
88.data
89ALIGN
90ENTRY(saved_magic)	.long	0
91ENTRY(saved_eip)	.long	0
92
93# saved registers
94saved_idt:	.long	0,0
95saved_ldt:	.long	0
96saved_tss:	.long	0
97