Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/src/context.S

    r0aee9b4 r3eebe571  
    2727#
    2828
     29#include <abi/asmtool.h>
     30#include <arch/context_struct.h>
     31#include <arch/vreg.h>
     32
    2933.text
    30 
    31 .global context_save_arch
    32 .global context_restore_arch
    33 
    34 #include <arch/context_struct.h>
    3534
    3635## Save current CPU context
     
    3938# pointed by the 1st argument. Returns 1 in EAX.
    4039#
    41 context_save_arch:
    42         movq (%rsp), %rdx     # the caller's return %eip
     40FUNCTION_BEGIN(context_save_arch)
     41        movq (%rsp), %rdx     # the caller's return %rip
    4342       
    44         # 1st argument passed in %edi
    4543        movq %rdx, CONTEXT_OFFSET_PC(%rdi)
    4644        movq %rsp, CONTEXT_OFFSET_SP(%rdi)
     
    5250        movq %r14, CONTEXT_OFFSET_R14(%rdi)
    5351        movq %r15, CONTEXT_OFFSET_R15(%rdi)
     52
     53        movq vreg_ptr, %rsi
     54        movq %fs:VREG_TP(%rsi), %rsi
     55        movq %rsi, CONTEXT_OFFSET_TP(%rdi)
    5456       
    5557        xorl %eax, %eax       # context_save returns 1
    5658        incl %eax
    5759        ret
     60FUNCTION_END(context_save_arch)
    5861
    5962
     
    6366# pointed by the 1st argument. Returns 0 in EAX.
    6467#
    65 context_restore_arch:
     68FUNCTION_BEGIN(context_restore_arch)
    6669        movq CONTEXT_OFFSET_R15(%rdi), %r15
    6770        movq CONTEXT_OFFSET_R14(%rdi), %r14
     
    7174        movq CONTEXT_OFFSET_RBX(%rdi), %rbx
    7275       
    73         movq CONTEXT_OFFSET_SP(%rdi), %rsp   # ctx->sp -> %rsp
     76        movq CONTEXT_OFFSET_SP(%rdi), %rsp
    7477       
    75         movq CONTEXT_OFFSET_PC(%rdi), %rdx
    76        
     78        movq CONTEXT_OFFSET_PC(%rdi), %rdx
    7779        movq %rdx, (%rsp)
     80
     81        movq CONTEXT_OFFSET_TP(%rdi), %rcx
     82        movq vreg_ptr, %rsi
     83        movq %rcx, %fs:VREG_TP(%rsi)
    7884       
    7985        xorl %eax, %eax       # context_restore returns 0
    8086        ret
     87FUNCTION_END(context_restore_arch)
    8188
Note: See TracChangeset for help on using the changeset viewer.