Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/ia32/src/fibril.S

    rd6f9fff r2b903ca  
    2727#
    2828
    29 #include <abi/asmtool.h>
    30 #include <libarch/fibril_context.h>
     29#include <libarch/context_offset.h>
    3130
    3231.text
     32
     33.global context_save
     34.global context_restore
    3335
    3436## Save current CPU context
     
    3739# pointed by the 1st argument. Returns 1 in EAX.
    3840#
    39 FUNCTION_BEGIN(context_save)
     41context_save:
    4042        movl 0(%esp), %eax  # the caller's return %eip
    4143        movl 4(%esp), %edx  # address of the context variable to save context to
    4244       
    4345        # 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
    5047       
    5148        # save TLS
    5249        movl %gs:0, %eax
    53         movl %eax, CONTEXT_OFFSET_TLS(%edx)     # tls -> ctx->tls
     50        movl %eax, OFFSET_TLS(%edx)     # tls -> ctx->tls
    5451       
    55         xorl %eax, %eax         # context_save returns 1
     52        xorl %eax, %eax     # context_save returns 1
    5653        incl %eax
    5754        ret
    58 FUNCTION_END(context_save)
    5955
    6056## Restore saved CPU context
     
    6359# pointed by the 1st argument. Returns 0 in EAX.
    6460#
    65 FUNCTION_BEGIN(context_restore)
     61context_restore:
    6662        movl 4(%esp), %eax  # address of the context variable to restore context from
    6763       
    6864        # 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
    7566       
    7667        movl %edx, 0(%esp)  # ctx->pc -> saver's return %eip
    7768       
    7869        # 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
    8175       
    82         xorl %eax, %eax         # context_restore returns 0
     76        xorl %eax, %eax     # context_restore returns 0
    8377        ret
    84 FUNCTION_END(context_restore)
    85 
Note: See TracChangeset for help on using the changeset viewer.