Changeset e74b24f in mainline


Ignore:
Timestamp:
2014-09-03T20:35:31Z (10 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5eae56a
Parents:
41f9802
Message:

Autogenerate ia32 fibril context_t and its offsets.

Location:
uspace/lib/c/arch/ia32
Files:
1 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/ia32/Makefile.inc

    r41f9802 re74b24f  
    3939        arch/$(UARCH)/src/rtld/reloc.c
    4040
     41ARCH_AUTOGENS_AG = \
     42        arch/$(UARCH)/include/libarch/fibril_context.ag
     43
    4144.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/ia32/include/libarch/fibril.h

    r41f9802 re74b24f  
    3737
    3838#include <sys/types.h>
     39#include <libarch/fibril_context.h>
    3940
    4041/*
     
    5354        } while (0)
    5455
    55 /*
    56  * We include only registers that must be preserved
    57  * during function call
    58  */
    59 typedef struct {
    60         uint32_t sp;
    61         uint32_t pc;
    62        
    63         uint32_t ebx;
    64         uint32_t esi;
    65         uint32_t edi;
    66         uint32_t ebp;
    67        
    68         uint32_t tls;
    69 } context_t;
    70 
    7156static inline uintptr_t context_get_fp(context_t *ctx)
    7257{
  • uspace/lib/c/arch/ia32/src/fibril.S

    r41f9802 re74b24f  
    2727#
    2828
    29 #include <libarch/context_offset.h>
     29#include <libarch/fibril_context.h>
    3030
    3131.text
     
    4444       
    4545        # save registers to the context structure
    46         CONTEXT_SAVE_ARCH_CORE %edx %eax
     46        movl %esp, CONTEXT_OFFSET_SP(%edx)      # %esp -> ctx->sp
     47        movl %eax, CONTEXT_OFFSET_PC(%edx)      # %eip -> ctx->pc
     48        movl %ebx, CONTEXT_OFFSET_EBX(%edx)     # %ebx -> ctx->ebx
     49        movl %esi, CONTEXT_OFFSET_ESI(%edx)     # %esi -> ctx->esi
     50        movl %edi, CONTEXT_OFFSET_EDI(%edx)     # %edi -> ctx->edi
     51        movl %ebp, CONTEXT_OFFSET_EBP(%edx)     # %ebp -> ctx->ebp
    4752       
    4853        # save TLS
    4954        movl %gs:0, %eax
    50         movl %eax, OFFSET_TLS(%edx)     # tls -> ctx->tls
     55        movl %eax, CONTEXT_OFFSET_TLS(%edx)     # tls -> ctx->tls
    5156       
    52         xorl %eax, %eax     # context_save returns 1
     57        xorl %eax, %eax         # context_save returns 1
    5358        incl %eax
    5459        ret
     
    6368       
    6469        # restore registers from the context structure
    65         CONTEXT_RESTORE_ARCH_CORE %eax %edx
     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
    6676       
    6777        movl %edx, 0(%esp)  # ctx->pc -> saver's return %eip
     
    6979        # set thread local storage
    7080        pushl %edx
    71         movl OFFSET_TLS(%eax), %edx  # Set arg1 to TLS addr
    72         movl $1, %eax                # Syscall SYS_TLS_SET
     81        movl CONTEXT_OFFSET_TLS(%eax), %edx     # Set arg1 to TLS addr
     82        movl $1, %eax                           # Syscall SYS_TLS_SET
    7383        int $0x30
    7484        popl %edx
    7585       
    76         xorl %eax, %eax     # context_restore returns 0
     86        xorl %eax, %eax         # context_restore returns 0
    7787        ret
     88
Note: See TracChangeset for help on using the changeset viewer.