xv6-cs450/swtch.S

37 lines
700 B
ArmAsm
Raw Normal View History

2009-07-12 04:28:29 +02:00
# Context switch
#
# void swtch(struct context **old, struct context *new);
#
2007-08-28 14:48:33 +02:00
# Save current register context in old
# and then load register context from new.
.globl swtch
swtch:
movl 4(%esp), %eax
2008-10-15 07:14:10 +02:00
movl 8(%esp), %edx
2007-08-28 14:48:33 +02:00
2008-10-15 07:14:10 +02:00
# Save old callee-save registers
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
2007-08-28 14:48:33 +02:00
2008-10-15 07:14:10 +02:00
# Switch stacks
movl %esp, (%eax)
2009-07-12 04:28:29 +02:00
movl %edx, %esp
2007-08-28 14:48:33 +02:00
2008-10-15 07:14:10 +02:00
# Load new callee-save registers
popl %edi
popl %esi
popl %ebx
popl %ebp
2007-08-28 14:48:33 +02:00
ret
# Jump on a new stack, fake C calling conventions
.globl jstack
jstack:
movl 4(%esp), %esp
subl $16, %esp # space for arguments
movl $0, %ebp # terminate functions that follow ebp's
call mainc # continue at mainc