Ignore:
File:
1 edited

Legend:

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

    r2b903ca rd6f9fff  
    2727#
    2828
    29 #include <libarch/context_offset.h>
     29#include <abi/asmtool.h>
     30#include <libarch/fibril_context.h>
    3031
    3132.text
    32 
    33 .global context_save
    34 .global context_restore
    3533
    3634## Save current CPU context
     
    3937# pointed by the 1st argument. Returns 1 in EAX.
    4038#
    41 context_save:
     39FUNCTION_BEGIN(context_save)
    4240        movl 0(%esp), %eax  # the caller's return %eip
    4341        movl 4(%esp), %edx  # address of the context variable to save context to
    4442       
    4543        # save registers to the context structure
    46         CONTEXT_SAVE_ARCH_CORE %edx %eax
     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
    4750       
    4851        # save TLS
    4952        movl %gs:0, %eax
    50         movl %eax, OFFSET_TLS(%edx)     # tls -> ctx->tls
     53        movl %eax, CONTEXT_OFFSET_TLS(%edx)     # tls -> ctx->tls
    5154       
    52         xorl %eax, %eax     # context_save returns 1
     55        xorl %eax, %eax         # context_save returns 1
    5356        incl %eax
    5457        ret
     58FUNCTION_END(context_save)
    5559
    5660## Restore saved CPU context
     
    5963# pointed by the 1st argument. Returns 0 in EAX.
    6064#
    61 context_restore:
     65FUNCTION_BEGIN(context_restore)
    6266        movl 4(%esp), %eax  # address of the context variable to restore context from
    6367       
    6468        # restore registers from the context structure
    65         CONTEXT_RESTORE_ARCH_CORE %eax %edx
     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
    6675       
    6776        movl %edx, 0(%esp)  # ctx->pc -> saver's return %eip
    6877       
    6978        # set thread local storage
    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
     79        movl CONTEXT_OFFSET_TLS(%eax), %edx     # Set arg1 to TLS addr
     80        movl %edx, %gs:0
    7581       
    76         xorl %eax, %eax     # context_restore returns 0
     82        xorl %eax, %eax         # context_restore returns 0
    7783        ret
     84FUNCTION_END(context_restore)
     85
Note: See TracChangeset for help on using the changeset viewer.