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