Changes in uspace/lib/c/arch/ia32/src/fibril.S [2b903ca:d6f9fff] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/ia32/src/fibril.S
r2b903ca rd6f9fff 27 27 # 28 28 29 #include <libarch/context_offset.h> 29 #include <abi/asmtool.h> 30 #include <libarch/fibril_context.h> 30 31 31 32 .text 32 33 .global context_save34 .global context_restore35 33 36 34 ## Save current CPU context … … 39 37 # pointed by the 1st argument. Returns 1 in EAX. 40 38 # 41 context_save: 39 FUNCTION_BEGIN(context_save) 42 40 movl 0(%esp), %eax # the caller's return %eip 43 41 movl 4(%esp), %edx # address of the context variable to save context to 44 42 45 43 # save registers to the context structure 46 CONTEXT_SAVE_ARCH_CORE %edx %eax 44 movl %esp, CONTEXT_OFFSET_SP(%edx) # %esp -> ctx->sp 45 movl %eax, CONTEXT_OFFSET_PC(%edx) # %eip -> ctx->pc 46 movl %ebx, CONTEXT_OFFSET_EBX(%edx) # %ebx -> ctx->ebx 47 movl %esi, CONTEXT_OFFSET_ESI(%edx) # %esi -> ctx->esi 48 movl %edi, CONTEXT_OFFSET_EDI(%edx) # %edi -> ctx->edi 49 movl %ebp, CONTEXT_OFFSET_EBP(%edx) # %ebp -> ctx->ebp 47 50 48 51 # save TLS 49 52 movl %gs:0, %eax 50 movl %eax, OFFSET_TLS(%edx)# tls -> ctx->tls53 movl %eax, CONTEXT_OFFSET_TLS(%edx) # tls -> ctx->tls 51 54 52 xorl %eax, %eax 55 xorl %eax, %eax # context_save returns 1 53 56 incl %eax 54 57 ret 58 FUNCTION_END(context_save) 55 59 56 60 ## Restore saved CPU context … … 59 63 # pointed by the 1st argument. Returns 0 in EAX. 60 64 # 61 context_restore: 65 FUNCTION_BEGIN(context_restore) 62 66 movl 4(%esp), %eax # address of the context variable to restore context from 63 67 64 68 # restore registers from the context structure 65 CONTEXT_RESTORE_ARCH_CORE %eax %edx 69 movl CONTEXT_OFFSET_SP(%eax),%esp # ctx->sp -> %esp 70 movl CONTEXT_OFFSET_PC(%eax),%edx # ctx->pc -> \pc 71 movl CONTEXT_OFFSET_EBX(%eax),%ebx # ctx->ebx -> %ebx 72 movl CONTEXT_OFFSET_ESI(%eax),%esi # ctx->esi -> %esi 73 movl CONTEXT_OFFSET_EDI(%eax),%edi # ctx->edi -> %edi 74 movl CONTEXT_OFFSET_EBP(%eax),%ebp # ctx->ebp -> %ebp 66 75 67 76 movl %edx, 0(%esp) # ctx->pc -> saver's return %eip 68 77 69 78 # set thread local storage 70 pushl %edx 71 movl OFFSET_TLS(%eax), %edx # Set arg1 to TLS addr 72 movl $1, %eax # Syscall SYS_TLS_SET 73 int $0x30 74 popl %edx 79 movl CONTEXT_OFFSET_TLS(%eax), %edx # Set arg1 to TLS addr 80 movl %edx, %gs:0 75 81 76 xorl %eax, %eax 82 xorl %eax, %eax # context_restore returns 0 77 83 ret 84 FUNCTION_END(context_restore) 85
Note:
See TracChangeset
for help on using the changeset viewer.