OpenCores
URL https://opencores.org/ocsvn/hf-risc/hf-risc/trunk

Subversion Repositories hf-risc

[/] [hf-risc/] [trunk/] [tools/] [riscv-gnu-toolchain-master/] [glibc/] [sysdeps/] [unix/] [sysv/] [linux/] [riscv/] [setcontext.S] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 serginhofr
/* Set current context.
2
   Copyright (C) 2009 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
   Contributed by Maciej W. Rozycki .
5
 
6
   The GNU C Library is free software; you can redistribute it and/or
7
   modify it under the terms of the GNU Lesser General Public
8
   License as published by the Free Software Foundation; either
9
   version 2.1 of the License, or (at your option) any later version.
10
 
11
   The GNU C Library is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
   Lesser General Public License for more details.
15
 
16
   You should have received a copy of the GNU Lesser General Public
17
   License along with the GNU C Library; if not, write to the Free
18
   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19
   02110-1301, USA.  */
20
 
21
#include 
22
#include 
23
 
24
#include "ucontext_i.h"
25
 
26
#define RESTORE_FP_REG(name, num, base)                 \
27
  fld  name, ((num) * 8 + MCONTEXT_FPREGS)(base)
28
 
29
#define RESTORE_FP_REG_CFI(name, num, base)             \
30
  RESTORE_FP_REG (name, num, base);                     \
31
  cfi_offset (name, (num) * SZREG + MCONTEXT_GREGS)
32
 
33
#define RESTORE_INT_REG(name, num, base)                \
34
  REG_L name, ((num) * SZREG + MCONTEXT_GREGS)(base)
35
 
36
#define RESTORE_INT_REG_CFI(name, num, base)            \
37
  RESTORE_INT_REG (name, num, base);                    \
38
  cfi_offset (name, (num) * SZREG + MCONTEXT_GREGS)
39
 
40
/* int setcontext (const ucontext_t *ucp) */
41
 
42
        .text
43
LEAF (__setcontext)
44
 
45
        mv      t0, a0                                  /* t0 <- ucp */
46
 
47
/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */
48
        li      a3, _NSIG8
49
        move    a2, zero
50
        add     a1, a0, UCONTEXT_SIGMASK
51
        li      a0, SIG_SETMASK
52
 
53
        li      a7, SYS_ify (rt_sigprocmask)
54
        scall
55
 
56
        bltz    a0, 99f
57
 
58
        cfi_def_cfa (t0, 0)
59
 
60
#ifdef __riscv_hard_float
61
        lw      t1, MCONTEXT_FSR(t0)
62
 
63
        RESTORE_FP_REG_CFI (fs0,   8, t0)
64
        RESTORE_FP_REG_CFI (fs1,   9, t0)
65
        RESTORE_FP_REG_CFI (fs2,  18, t0)
66
        RESTORE_FP_REG_CFI (fs3,  19, t0)
67
        RESTORE_FP_REG_CFI (fs4,  20, t0)
68
        RESTORE_FP_REG_CFI (fs5,  21, t0)
69
        RESTORE_FP_REG_CFI (fs6,  22, t0)
70
        RESTORE_FP_REG_CFI (fs7,  23, t0)
71
        RESTORE_FP_REG_CFI (fs8,  24, t0)
72
        RESTORE_FP_REG_CFI (fs9,  25, t0)
73
        RESTORE_FP_REG_CFI (fs10, 26, t0)
74
        RESTORE_FP_REG_CFI (fs11, 27, t0)
75
 
76
        fssr    t1
77
#endif /* __riscv_hard_float */
78
 
79
        /* Note the contents of argument registers will be random
80
           unless makecontext() has been called.  */
81
        REG_L   t1, MCONTEXT_PC(t0)
82
        RESTORE_INT_REG_CFI (ra,   1, t0)
83
        RESTORE_INT_REG     (sp,   2, t0)
84
        RESTORE_INT_REG_CFI (s0,   8, t0)
85
        RESTORE_INT_REG_CFI (s1,   9, t0)
86
        RESTORE_INT_REG     (a0,  10, t0)
87
        RESTORE_INT_REG     (a1,  11, t0)
88
        RESTORE_INT_REG     (a2,  12, t0)
89
        RESTORE_INT_REG     (a3,  13, t0)
90
        RESTORE_INT_REG     (a4,  14, t0)
91
        RESTORE_INT_REG     (a5,  15, t0)
92
        RESTORE_INT_REG     (a6,  16, t0)
93
        RESTORE_INT_REG     (a7,  17, t0)
94
        RESTORE_INT_REG_CFI (s2,  18, t0)
95
        RESTORE_INT_REG_CFI (s3,  19, t0)
96
        RESTORE_INT_REG_CFI (s4,  20, t0)
97
        RESTORE_INT_REG_CFI (s5,  21, t0)
98
        RESTORE_INT_REG_CFI (s6,  22, t0)
99
        RESTORE_INT_REG_CFI (s7,  23, t0)
100
        RESTORE_INT_REG_CFI (s8,  24, t0)
101
        RESTORE_INT_REG_CFI (s9,  25, t0)
102
        RESTORE_INT_REG_CFI (s10, 26, t0)
103
        RESTORE_INT_REG_CFI (s11, 27, t0)
104
 
105
        jr      t1
106
 
107
99:     j       __syscall_error
108
 
109
PSEUDO_END (__setcontext)
110
weak_alias (__setcontext, setcontext)
111
 
112
LEAF (__start_context)
113
 
114
        /* Terminate call stack by noting ra == 0.  Happily, s0 == 0 here.  */
115
        cfi_register (ra, s0)
116
 
117
        /* Call the function passed to makecontext.  */
118
        jalr    s1
119
 
120
        /* Invoke subsequent context if present, else exit(0).  */
121
        mv      a0, s2
122
        beqz    s2, 1f
123
        jal     __setcontext
124
1:      j       exit
125
 
126
PSEUDO_END (__start_context)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.