Ignore:
Timestamp:
Apr 30, 2019, 2:53:41 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8278abf
Parents:
673cd63
Message:

Added new suspen_then function which runs a callback in the middle of susending

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/CtxSwitch-x86_64.S

    r673cd63 r5b11c25  
    4040#define FP_OFFSET       ( 1 * PTR_BYTE )
    4141
     42//-----------------------------------------------------------------------------
     43// Regular context switch routine which enables switching from one context to anouther
    4244        .text
    4345        .align 2
     
    7779        .size  CtxSwitch, .-CtxSwitch
    7880
    79 .text
     81//-----------------------------------------------------------------------------
     82// Part of a 2 part context switch routine, use with CtxRet, stores the current context and then makes a function call
     83        .text
    8084        .align 2
    81 .globl  CtxInvokeStub
     85        .globl CtxStore
     86        .type  CtxStore, @function
     87CtxStore:
     88
     89        // Save volatile registers on the stack.
     90
     91        pushq %r15
     92        pushq %r14
     93        pushq %r13
     94        pushq %r12
     95        pushq %rbx
     96
     97        // Save old context in the "from" area.
     98
     99        movq %rsp,SP_OFFSET(%rdi)
     100        movq %rbp,FP_OFFSET(%rdi)
     101
     102        // Don't load a new context, directly jump to the desired function
     103
     104        jmp *%rsi
     105        .size  CtxStore, .-CtxStore
     106
     107//-----------------------------------------------------------------------------
     108// Part of a 2 part context switch routine, use with CtxStore, context switches to the desired target without saving the current context
     109        .text
     110        .align 2
     111        .globl CtxRet
     112        .type  CtxRet, @function
     113CtxRet:
     114        // Load new context from the "to" area.
     115
     116        movq SP_OFFSET(%rdi),%rsp
     117        movq FP_OFFSET(%rdi),%rbp
     118
     119        // Load volatile registers from the stack.
     120
     121        popq %rbx
     122        popq %r12
     123        popq %r13
     124        popq %r14
     125        popq %r15
     126
     127        // Return to thread.
     128
     129        ret
     130        .size  CtxRet, .-CtxRet
     131
     132
     133//-----------------------------------------------------------------------------
     134// Stub used to create new stacks which are ready to be context switched to
     135        .text
     136        .align 2
     137        .globl CtxInvokeStub
     138        .type    CtxInvokeStub, @function
    82139CtxInvokeStub:
    83140        movq %rbx, %rdi
    84141        jmp *%r12
     142        .size  CtxInvokeStub, .-CtxInvokeStub
    85143
    86144// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.