Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 4dc7a84 in mainline


Ignore:
Timestamp:
2014-09-02T20:16:21Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
0aee9b4
Parents:
21365c0
Message:

Autogenerate amd64 fibril context_t and its offsets

Generate the userspace context_t structure and its offsets by
autogen.py. Decouple the context definition from the kernel context_t,
because these structures can, and in fact already do, have different
members. Do not share the corresponding common assembly between the
kernel and the userspace.

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

Legend:

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

    r21365c0 r4dc7a84  
    3838
    3939.PRECIOUS: arch/$(UARCH)/src/entry.o
     40
     41ARCH_AUTOGENS_AG = \
     42        arch/$(UARCH)/include/libarch/fibril_context.ag
     43
  • uspace/lib/c/arch/amd64/include/libarch/fibril.h

    r21365c0 r4dc7a84  
    3636#define LIBC_amd64_FIBRIL_H_
    3737
    38 #include <sys/types.h>
     38#include <libarch/fibril_context.h>
    3939
    4040/*
     
    5353        } while (0)
    5454
    55 /* We include only registers that must be preserved
    56  * during function call
    57  */
    58 typedef struct {
    59         uint64_t sp;
    60         uint64_t pc;
    61 
    62         uint64_t rbx;
    63         uint64_t rbp;
    64 
    65         uint64_t r12;
    66         uint64_t r13;
    67         uint64_t r14;
    68         uint64_t r15;
    69 
    70         uint64_t tls;
    71 } context_t;
    72 
    7355static inline uintptr_t context_get_fp(context_t *ctx)
    7456{
  • uspace/lib/c/arch/amd64/src/fibril.S

    r21365c0 r4dc7a84  
    3232.global context_restore
    3333
    34 #include <libarch/context_offset.h>
     34#include <libarch/fibril_context.h>
    3535
    3636## Save current CPU context
     
    4242        movq (%rsp), %rdx     # the caller's return %eip
    4343       
    44         # in %edi is passed 1st argument
    45         CONTEXT_SAVE_ARCH_CORE %rdi %rdx
     44        # in %rdi is passed 1st argument
     45        movq %rdx, CONTEXT_OFFSET_PC(%rdi)
     46        movq %rsp, CONTEXT_OFFSET_SP(%rdi)
     47       
     48        movq %rbx, CONTEXT_OFFSET_RBX(%rdi)
     49        movq %rbp, CONTEXT_OFFSET_RBP(%rdi)
     50        movq %r12, CONTEXT_OFFSET_R12(%rdi)
     51        movq %r13, CONTEXT_OFFSET_R13(%rdi)
     52        movq %r14, CONTEXT_OFFSET_R14(%rdi)
     53        movq %r15, CONTEXT_OFFSET_R15(%rdi)
    4654       
    4755        # save TLS
    4856        movq %fs:0, %rax
    49         movq %rax, OFFSET_TLS(%rdi)
     57        movq %rax, CONTEXT_OFFSET_TLS(%rdi)
    5058       
    51         xorl %eax, %eax       # context_save returns 1
     59        xorl %eax, %eax                      # context_save returns 1
    5260        incl %eax
    5361        ret
     
    6068context_restore:
    6169       
    62         CONTEXT_RESTORE_ARCH_CORE %rdi %rdx
     70        movq CONTEXT_OFFSET_R15(%rdi), %r15
     71        movq CONTEXT_OFFSET_R14(%rdi), %r14
     72        movq CONTEXT_OFFSET_R13(%rdi), %r13
     73        movq CONTEXT_OFFSET_R12(%rdi), %r12
     74        movq CONTEXT_OFFSET_RBP(%rdi), %rbp
     75        movq CONTEXT_OFFSET_RBX(%rdi), %rbx
     76       
     77        movq CONTEXT_OFFSET_SP(%rdi), %rsp   # ctx->sp -> %rsp
     78       
     79        movq CONTEXT_OFFSET_PC(%rdi), %rdx
    6380       
    6481        movq %rdx,(%rsp)
    6582       
    6683        # Set thread local storage
    67         movq OFFSET_TLS(%rdi), %rdi  # Set arg1 to TLS addr
    68         movl $1, %eax                # SYS_TLS_SET
     84        movq CONTEXT_OFFSET_TLS(%rdi), %rdi  # Set arg1 to TLS addr
     85        movl $1, %eax                        # SYS_TLS_SET
    6986        syscall
    7087       
    71         xorl %eax, %eax              # context_restore returns 0
     88        xorl %eax, %eax                      # context_restore returns 0
    7289        ret
     90
Note: See TracChangeset for help on using the changeset viewer.