Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2777 → Rev 2776

/trunk/uspace/lib/libc/arch/amd64/src/fibril.S
31,7 → 31,7
.global context_save
.global context_restore
 
#include <kernel/arch/context_offset.h>
#include <libarch/context_offset.h>
 
## Save current CPU context
#
40,10 → 40,17
#
context_save:
movq (%rsp), %rdx # the caller's return %eip
# In %edi is passed 1st argument
CONTEXT_SAVE_ARCH_CORE %rdi %rdx
movq %rdx, OFFSET_PC(%rdi)
movq %rsp, OFFSET_SP(%rdi)
movq %rbx, OFFSET_RBX(%rdi)
movq %rbp, OFFSET_RBP(%rdi)
movq %r12, OFFSET_R12(%rdi)
movq %r13, OFFSET_R13(%rdi)
movq %r14, OFFSET_R14(%rdi)
movq %r15, OFFSET_R15(%rdi)
 
# Save TLS
movq %fs:0, %rax
movq %rax, OFFSET_TLS(%rdi)
59,9 → 66,16
# pointed by the 1st argument. Returns 0 in EAX.
#
context_restore:
movq OFFSET_R15(%rdi), %r15
movq OFFSET_R14(%rdi), %r14
movq OFFSET_R13(%rdi), %r13
movq OFFSET_R12(%rdi), %r12
movq OFFSET_RBP(%rdi), %rbp
movq OFFSET_RBX(%rdi), %rbx
CONTEXT_RESTORE_ARCH_CORE %rdi %rdx
movq OFFSET_SP(%rdi), %rsp # ctx->sp -> %rsp
movq OFFSET_PC(%rdi), %rdx
movq %rdx,(%rsp)
 
# Set thread local storage
/trunk/uspace/lib/libc/arch/amd64/include/context_offset.h
0,0 → 1,12
/* This file is automatically generated by gencontext.c. */
#define OFFSET_SP 0x0
#define OFFSET_PC 0x8
#define OFFSET_RBX 0x10
#define OFFSET_RBP 0x18
#define OFFSET_R12 0x20
#define OFFSET_R13 0x28
#define OFFSET_R14 0x30
#define OFFSET_R15 0x38
#define OFFSET_TLS 0x40