use popal/pushal for context switch
Should take fewer clock nd save esp
This commit is contained in:
parent
79c1fda419
commit
5141044c06
@ -36,12 +36,13 @@ struct cpu_state {
|
||||
thread, even for a user thread */
|
||||
uint16_t alignment_padding; /* unused */
|
||||
uint32_t eax;
|
||||
uint32_t ebx;
|
||||
uint32_t ecx;
|
||||
uint32_t edx;
|
||||
uint32_t ebx;
|
||||
uint32_t ebp;
|
||||
uint32_t esp;
|
||||
uint32_t esi;
|
||||
uint32_t edi;
|
||||
uint32_t ebp;
|
||||
|
||||
/* MUST NEVER CHANGE (dependent on the IA32 iret instruction) */
|
||||
uint32_t error_code;
|
||||
|
@ -6,20 +6,14 @@
|
||||
.globl cpu_context_switch
|
||||
.type cpu_context_switch, @function
|
||||
cpu_context_switch:
|
||||
// arg2= to_context -- esp+64
|
||||
// arg1= from_context -- esp+60
|
||||
// caller ip -- esp+56
|
||||
pushf // (eflags) esp+52
|
||||
pushl %cs // (cs) esp+48
|
||||
pushl $resume_pc // (ip) esp+44
|
||||
pushl $0 // (error code) esp+40
|
||||
pushl %ebp // esp+36
|
||||
pushl %edi // esp+32
|
||||
pushl %esi // esp+28
|
||||
pushl %edx // esp+24
|
||||
pushl %ecx // esp+20
|
||||
pushl %ebx // esp+16
|
||||
pushl %eax // esp+12
|
||||
// arg2= to_context -- esp+68
|
||||
// arg1= from_context -- esp+64
|
||||
// caller ip -- esp+60
|
||||
pushf // (eflags) esp+56
|
||||
pushl %cs // (cs) esp+52
|
||||
pushl $resume_pc // (ip) esp+48
|
||||
pushl $0 // (error code) esp+44
|
||||
pushal // (general reg) esp+12+8*4
|
||||
subl $2, %esp // (alignment) esp+10
|
||||
pushw %ss // esp+8
|
||||
pushw %ds // esp+6
|
||||
@ -32,11 +26,11 @@ cpu_context_switch:
|
||||
*/
|
||||
|
||||
/* Store the address of the saved context */
|
||||
movl 60(%esp), %ebx
|
||||
movl 64(%esp), %ebx
|
||||
movl %esp, (%ebx)
|
||||
|
||||
/* This is the proper context switch ! We change the stack here */
|
||||
movl 64(%esp), %esp
|
||||
movl 68(%esp), %esp
|
||||
|
||||
/* Restore the CPU context */
|
||||
popw %gs
|
||||
@ -45,13 +39,7 @@ cpu_context_switch:
|
||||
popw %ds
|
||||
popw %ss
|
||||
addl $2,%esp
|
||||
popl %eax
|
||||
popl %ebx
|
||||
popl %ecx
|
||||
popl %edx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
popal
|
||||
addl $4, %esp /* Ignore "error code" */
|
||||
|
||||
/* This restores the eflags, the cs and the eip registers */
|
||||
@ -94,13 +82,7 @@ cpu_context_exit_to:
|
||||
popw %ds
|
||||
popw %ss
|
||||
addl $2,%esp
|
||||
popl %eax
|
||||
popl %ebx
|
||||
popl %ecx
|
||||
popl %edx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
popal
|
||||
addl $4, %esp /* Ignore "error code" */
|
||||
|
||||
/* This restores the eflags, the cs and the eip registers */
|
||||
|
Loading…
Reference in New Issue
Block a user