@@ -23,49 +23,57 @@ GDATA(_pm_save_gdtr)
23
23
GDATA(_pm_save_idtr)
24
24
GDATA(_pm_save_esp)
25
25
26
- GTEXT(_sys_soc_save_cpu_context)
27
- GTEXT(_sys_soc_restore_cpu_context)
28
26
GTEXT(_sys_soc_resume_from_deep_sleep)
27
+ GTEXT(_power_restore_cpu_context)
28
+ GTEXT(_power_soc_sleep)
29
+ GTEXT(_power_soc_deep_sleep)
30
+
31
+ SECTION_FUNC(TEXT, save_cpu_context)
32
+ movl %esp , %eax /* save ptr to return address */
29
33
30
- SECTION_FUNC(TEXT, _sys_soc_save_cpu_context)
31
- movl %esp , %eax /* save ptr to return address */
32
34
pushf /* save flags */
33
35
pusha /* save GPRs */
34
-
35
36
movl %esp , _pm_save_esp /* save stack ptr */
36
37
sidtl _pm_save_idtr /* save idtr */
37
38
sgdtl _pm_save_gdtr /* save gdtr */
38
39
39
- pushl (%eax ) /* push return address */
40
-
41
- xorl %eax , %eax /* 0 indicates saved context */
40
+ pushl (%eax ) /* push return address */
42
41
ret
43
42
44
- SECTION_FUNC(TEXT, _sys_soc_restore_cpu_context)
45
- /*
46
- * Will transfer control to _sys_power_save_cpu_context,
47
- * from where it will return 1 indicating the function
48
- * is exiting after a context switch.
49
- */
43
+ SECTION_FUNC(TEXT, _power_restore_cpu_context)
50
44
lgdtl _pm_save_gdtr /* restore gdtr */
51
45
lidtl _pm_save_idtr /* restore idtr */
52
46
movl _pm_save_esp, %esp /* restore saved stack ptr */
53
47
popa /* restore saved GPRs */
54
48
popf /* restore saved flags */
55
49
56
50
/*
57
- * At this point context is restored as it was saved
58
- * in _sys_soc_save_cpu_context. The following ret
59
- * will emulate a return from that function. Move 1
60
- * to eax to emulate a return 1. The caller of
61
- * _sys_soc_save_cpu_context will identify it is
62
- * returning from a context restore based on the
63
- * return value = 1.
51
+ * At this point the stack contents will be as follows:
52
+ *
53
+ * Saved context
54
+ * ESP ---> Return address of save_cpu_context
55
+ * Return address of _power_soc_sleep/deep_sleep
56
+ *
57
+ * We just popped the saved context. Next we pop out the address
58
+ * of the caller of save_cpu_context.Then the ret would return
59
+ * to caller of _power_soc_sleep or _power_soc_deep_sleep.
60
+ *
64
61
*/
65
- xorl %eax , %eax
66
- incl %eax
62
+ addl $4 , %esp
67
63
ret
68
64
65
+ SECTION_FUNC(TEXT, _power_soc_sleep)
66
+ call save_cpu_context
67
+ wbinvd
68
+ call power_soc_sleep
69
+ /* Does not return */
70
+
71
+ SECTION_FUNC(TEXT, _power_soc_deep_sleep)
72
+ call save_cpu_context
73
+ wbinvd
74
+ call power_soc_deep_sleep
75
+ /* Does not return */
76
+
69
77
/*
70
78
* This is an example function to handle the deep sleep resume notification
71
79
* in the absence of bootloader context restore support.
@@ -78,8 +86,8 @@ SECTION_FUNC(TEXT, _sys_soc_restore_cpu_context)
78
86
*/
79
87
SECTION_FUNC(TEXT, _sys_soc_resume_from_deep_sleep)
80
88
movl $CONFIG_BSP_SHARED_RAM_ADDR, %eax
81
- cmpl $_sys_soc_restore_cpu_context , (%eax )
82
- je _sys_soc_restore_cpu_context
89
+ cmpl $_power_restore_cpu_context , (%eax )
90
+ je _power_restore_cpu_context
83
91
ret
84
92
85
93
#endif
0 commit comments