Rev 312 | Rev 501 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 312 | Rev 414 | ||
---|---|---|---|
Line 26... | Line 26... | ||
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | # |
27 | # |
28 | 28 | ||
29 | .text |
29 | .text |
30 | 30 | ||
31 | .global context_save |
31 | .global context_save_arch |
32 | .global context_restore |
32 | .global context_restore_arch |
33 | 33 | ||
34 | 34 | ||
35 | ## Save current CPU context |
35 | ## Save current CPU context |
36 | # |
36 | # |
37 | # Save CPU context to the kernel_context variable |
37 | # Save CPU context to the context_t variable |
38 | # pointed by the 1st argument. Returns 1 in EAX. |
38 | # pointed by the 1st argument. Returns 1 in EAX. |
39 | # |
39 | # |
40 | context_save: |
40 | context_save_arch: |
41 | movl 0(%esp),%eax # the caller's return %eip |
41 | movl 0(%esp),%eax # the caller's return %eip |
42 | movl 4(%esp),%edx # address of the kernel_context variable to save context to |
42 | movl 4(%esp),%edx # address of the kernel_context variable to save context to |
43 | 43 | ||
44 | movl %esp,0(%edx) # %esp -> ctx->sp |
44 | movl %esp,0(%edx) # %esp -> ctx->sp |
45 | movl %eax,4(%edx) # %eip -> ctx->pc |
45 | movl %eax,4(%edx) # %eip -> ctx->pc |
Line 51... | Line 51... | ||
51 | xorl %eax,%eax # context_save returns 1 |
51 | xorl %eax,%eax # context_save returns 1 |
52 | incl %eax |
52 | incl %eax |
53 | ret |
53 | ret |
54 | 54 | ||
55 | 55 | ||
56 | ## Restore current CPU context |
56 | ## Restore saved CPU context |
57 | # |
57 | # |
58 | # Restore CPU context from the kernel_context variable |
58 | # Restore CPU context from context_t variable |
59 | # pointed by the 1st argument. Returns 0 in EAX. |
59 | # pointed by the 1st argument. Returns 0 in EAX. |
60 | # |
60 | # |
61 | context_restore: |
61 | context_restore_arch: |
62 | movl 4(%esp),%eax # address of the kernel_context variable to restore context from |
62 | movl 4(%esp),%eax # address of the kernel_context variable to restore context from |
63 | movl 0(%eax),%esp # ctx->sp -> %esp |
63 | movl 0(%eax),%esp # ctx->sp -> %esp |
64 | movl 4(%eax),%edx # ctx->pc -> %edx |
64 | movl 4(%eax),%edx # ctx->pc -> %edx |
65 | movl 8(%eax),%ebx # ctx->ebx -> %ebx |
65 | movl 8(%eax),%ebx # ctx->ebx -> %ebx |
66 | movl 12(%eax),%esi # ctx->esi -> %esi |
66 | movl 12(%eax),%esi # ctx->esi -> %esi |