Rev 125 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 125 | Rev 312 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | # |
36 | # |
37 | # Save CPU context to the kernel_context variable |
37 | # Save CPU context to the kernel_context 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: |
41 | push %ebx |
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 | 43 | ||
43 | movl 4(%esp),%eax # the caller's return %eip |
44 | movl %esp,0(%edx) # %esp -> ctx->sp |
44 | movl 8(%esp),%ebx # address of the kernel_context variable to save context to |
- | |
45 | movl %eax,4(%ebx) # %eip -> ctx->pc |
45 | movl %eax,4(%edx) # %eip -> ctx->pc |
46 | movl %esp,(%ebx) # %esp -> ctx->sp |
46 | movl %ebx,8(%edx) # %ebx -> ctx->ebx |
47 | - | ||
48 | movl %ebx,%eax |
- | |
49 | pop %ebx |
- | |
50 | - | ||
51 | movl %ebx,8(%eax) |
- | |
52 | movl %ecx,12(%eax) |
47 | movl %esi,12(%edx) # %esi -> ctx->esi |
53 | movl %edx,16(%eax) |
48 | movl %edi,16(%edx) # %edi -> ctx->edi |
54 | movl %esi,20(%eax) |
- | |
55 | movl %edi,24(%eax) |
- | |
56 | movl %ebp,28(%eax) |
49 | movl %ebp,20(%edx) # %ebp -> ctx->ebp |
57 | 50 | ||
58 | xorl %eax,%eax # context_save returns 1 |
51 | xorl %eax,%eax # context_save returns 1 |
59 | incl %eax |
52 | incl %eax |
60 | ret |
53 | ret |
61 | 54 | ||
Line 65... | Line 58... | ||
65 | # Restore CPU context from the kernel_context variable |
58 | # Restore CPU context from the kernel_context variable |
66 | # pointed by the 1st argument. Returns 0 in EAX. |
59 | # pointed by the 1st argument. Returns 0 in EAX. |
67 | # |
60 | # |
68 | context_restore: |
61 | context_restore: |
69 | 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 |
70 | movl (%eax),%esp # ctx->sp -> %esp |
63 | movl 0(%eax),%esp # ctx->sp -> %esp |
71 | addl $4,%esp # this is for the pop we don't do |
64 | movl 4(%eax),%edx # ctx->pc -> %edx |
72 | - | ||
73 | movl 8(%eax),%ebx |
65 | movl 8(%eax),%ebx # ctx->ebx -> %ebx |
74 | movl 12(%eax),%ecx |
66 | movl 12(%eax),%esi # ctx->esi -> %esi |
75 | movl 16(%eax),%edx |
67 | movl 16(%eax),%edi # ctx->edi -> %edi |
76 | movl 20(%eax),%esi |
- | |
77 | movl 24(%eax),%edi |
- | |
78 | movl 28(%eax),%ebp |
68 | movl 20(%eax),%ebp # ctx->ebp -> %ebp |
79 | 69 | ||
80 | movl 4(%eax),%eax |
- | |
81 | movl %eax,(%esp) # ctx->pc -> saver's return %eip |
70 | movl %edx,0(%esp) # ctx->pc -> saver's return %eip |
82 | xorl %eax,%eax # context_restore returns 0 |
71 | xorl %eax,%eax # context_restore returns 0 |
83 | ret |
72 | ret |