Ignore:
File:
1 edited

Legend:

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

    r9d58539 re98f1c3e  
    2727#
    2828
    29 #include <arch/context_offset.h>
     29#include <abi/asmtool.h>
     30#include <arch/context_struct.h>
     31#include <arch/vreg.h>
    3032
    3133.text
    32 
    33 .global context_save_arch
    34 .global context_restore_arch
    35 
    3634
    3735## Save current CPU context
     
    4038# pointed by the 1st argument. Returns 1 in EAX.
    4139#
    42 context_save_arch:
    43         movl 0(%esp),%eax       # save pc value into eax       
    44         movl 4(%esp),%edx       # address of the context variable to save context to
     40FUNCTION_BEGIN(context_save_arch)
     41        movl 0(%esp), %eax      # save pc value into eax       
     42        movl 4(%esp), %edx      # address of the context variable to save context to
    4543
    46                 # save registers to given structure
    47         CONTEXT_SAVE_ARCH_CORE %edx %eax
     44        # save registers to given structure
     45        movl %esp, CONTEXT_OFFSET_SP(%edx)      # %esp -> ctx->sp
     46        movl %eax, CONTEXT_OFFSET_PC(%edx)      # %eip -> ctx->pc
     47        movl %ebx, CONTEXT_OFFSET_EBX(%edx)     # %ebx -> ctx->ebx
     48        movl %esi, CONTEXT_OFFSET_ESI(%edx)     # %esi -> ctx->esi
     49        movl %edi, CONTEXT_OFFSET_EDI(%edx)     # %edi -> ctx->edi
     50        movl %ebp, CONTEXT_OFFSET_EBP(%edx)     # %ebp -> ctx->ebp
    4851
    49         xorl %eax,%eax          # context_save returns 1
     52        mov vreg_ptr, %ecx
     53        movl %gs:VREG_TP(%ecx), %ecx
     54        movl %ecx, CONTEXT_OFFSET_TP(%edx)
     55
     56        xorl %eax, %eax         # context_save returns 1
    5057        incl %eax
    5158        ret
    52 
     59FUNCTION_END(context_save_arch)
    5360
    5461## Restore saved CPU context
     
    5764# pointed by the 1st argument. Returns 0 in EAX.
    5865#
    59 context_restore_arch:
    60         movl 4(%esp),%eax       # address of the context variable to restore context from
     66FUNCTION_BEGIN(context_restore_arch)
     67        movl 4(%esp), %eax      # address of the context variable to restore context from
    6168
    62                 # restore registers from given structure
    63         CONTEXT_RESTORE_ARCH_CORE %eax %edx
     69        # restore registers from given structure
     70        movl CONTEXT_OFFSET_SP(%eax), %esp      # ctx->sp -> %esp
     71        movl CONTEXT_OFFSET_PC(%eax), %edx      # ctx->pc -> \pc
     72        movl CONTEXT_OFFSET_EBX(%eax), %ebx     # ctx->ebx -> %ebx
     73        movl CONTEXT_OFFSET_ESI(%eax), %esi     # ctx->esi -> %esi
     74        movl CONTEXT_OFFSET_EDI(%eax), %edi     # ctx->edi -> %edi
     75        movl CONTEXT_OFFSET_EBP(%eax), %ebp     # ctx->ebp -> %ebp
    6476
    65         movl %edx,0(%esp)       # put saved pc on stack
    66         xorl %eax,%eax          # context_restore returns 0
     77        movl %edx, 0(%esp)      # put saved pc on stack
     78
     79        mov vreg_ptr, %ecx
     80        movl CONTEXT_OFFSET_TP(%eax), %edx
     81        movl %edx, %gs:VREG_TP(%ecx)
     82
     83        xorl %eax, %eax         # context_restore returns 0
    6784        ret
Note: See TracChangeset for help on using the changeset viewer.