1 | /*
|
---|
2 | * Copyright (c) 2014 Jakub Jermar
|
---|
3 | * All rights preserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | #ifndef _LIBC_ARCH_FIBRIL_CONTEXT_H_
|
---|
30 | #define _LIBC_ARCH_FIBRIL_CONTEXT_H_
|
---|
31 |
|
---|
32 | #define __CONTEXT_OFFSET_AR_PFS 0x000
|
---|
33 | #define __CONTEXT_OFFSET_AR_UNAT_CALLER 0x008
|
---|
34 | #define __CONTEXT_OFFSET_AR_UNAT_CALLEE 0x010
|
---|
35 | #define __CONTEXT_OFFSET_AR_RSC 0x018
|
---|
36 | #define __CONTEXT_OFFSET_BSP 0x020
|
---|
37 | #define __CONTEXT_OFFSET_AR_RNAT 0x028
|
---|
38 | #define __CONTEXT_OFFSET_AR_LC 0x030
|
---|
39 | #define __CONTEXT_OFFSET_R1 0x038
|
---|
40 | #define __CONTEXT_OFFSET_R4 0x040
|
---|
41 | #define __CONTEXT_OFFSET_R5 0x048
|
---|
42 | #define __CONTEXT_OFFSET_R6 0x050
|
---|
43 | #define __CONTEXT_OFFSET_R7 0x058
|
---|
44 | #define __CONTEXT_OFFSET_SP 0x060
|
---|
45 | #define __CONTEXT_OFFSET_TP 0x068
|
---|
46 | #define __CONTEXT_OFFSET_PC 0x070
|
---|
47 | #define __CONTEXT_OFFSET_B1 0x078
|
---|
48 | #define __CONTEXT_OFFSET_B2 0x080
|
---|
49 | #define __CONTEXT_OFFSET_B3 0x088
|
---|
50 | #define __CONTEXT_OFFSET_B4 0x090
|
---|
51 | #define __CONTEXT_OFFSET_B5 0x098
|
---|
52 | #define __CONTEXT_OFFSET_PR 0x0a0
|
---|
53 | #define __CONTEXT_OFFSET_F2 0x0b0
|
---|
54 | #define __CONTEXT_OFFSET_F3 0x0c0
|
---|
55 | #define __CONTEXT_OFFSET_F4 0x0d0
|
---|
56 | #define __CONTEXT_OFFSET_F5 0x0e0
|
---|
57 | #define __CONTEXT_OFFSET_F16 0x0f0
|
---|
58 | #define __CONTEXT_OFFSET_F17 0x100
|
---|
59 | #define __CONTEXT_OFFSET_F18 0x110
|
---|
60 | #define __CONTEXT_OFFSET_F19 0x120
|
---|
61 | #define __CONTEXT_OFFSET_F20 0x130
|
---|
62 | #define __CONTEXT_OFFSET_F21 0x140
|
---|
63 | #define __CONTEXT_OFFSET_F22 0x150
|
---|
64 | #define __CONTEXT_OFFSET_F23 0x160
|
---|
65 | #define __CONTEXT_OFFSET_F24 0x170
|
---|
66 | #define __CONTEXT_OFFSET_F25 0x180
|
---|
67 | #define __CONTEXT_OFFSET_F26 0x190
|
---|
68 | #define __CONTEXT_OFFSET_F27 0x1a0
|
---|
69 | #define __CONTEXT_OFFSET_F28 0x1b0
|
---|
70 | #define __CONTEXT_OFFSET_F29 0x1c0
|
---|
71 | #define __CONTEXT_OFFSET_F30 0x1d0
|
---|
72 | #define __CONTEXT_OFFSET_F31 0x1e0
|
---|
73 | #define __CONTEXT_SIZE 0x1f0
|
---|
74 |
|
---|
75 | #ifndef __ASSEMBLER__
|
---|
76 |
|
---|
77 | #include <stdint.h>
|
---|
78 | #include <_bits/int128_t.h>
|
---|
79 |
|
---|
80 | // Only save registers that must be preserved across function calls.
|
---|
81 | typedef struct __context {
|
---|
82 | // Application registers.
|
---|
83 | uint64_t ar_pfs;
|
---|
84 | uint64_t ar_unat_caller;
|
---|
85 | uint64_t ar_unat_callee;
|
---|
86 | uint64_t ar_rsc;
|
---|
87 | // ar_bsp
|
---|
88 | uint64_t bsp;
|
---|
89 | uint64_t ar_rnat;
|
---|
90 | uint64_t ar_lc;
|
---|
91 |
|
---|
92 | // General registers.
|
---|
93 | uint64_t r1;
|
---|
94 | uint64_t r4;
|
---|
95 | uint64_t r5;
|
---|
96 | uint64_t r6;
|
---|
97 | uint64_t r7;
|
---|
98 | // r12
|
---|
99 | uint64_t sp;
|
---|
100 | // r13
|
---|
101 | uint64_t tp;
|
---|
102 |
|
---|
103 | // Branch registers.
|
---|
104 | // b0
|
---|
105 | uint64_t pc;
|
---|
106 | uint64_t b1;
|
---|
107 | uint64_t b2;
|
---|
108 | uint64_t b3;
|
---|
109 | uint64_t b4;
|
---|
110 | uint64_t b5;
|
---|
111 |
|
---|
112 | // Predicate registers.
|
---|
113 | uint64_t pr;
|
---|
114 | uint128_t f2;
|
---|
115 | uint128_t f3;
|
---|
116 | uint128_t f4;
|
---|
117 | uint128_t f5;
|
---|
118 | uint128_t f16;
|
---|
119 | uint128_t f17;
|
---|
120 | uint128_t f18;
|
---|
121 | uint128_t f19;
|
---|
122 | uint128_t f20;
|
---|
123 | uint128_t f21;
|
---|
124 | uint128_t f22;
|
---|
125 | uint128_t f23;
|
---|
126 | uint128_t f24;
|
---|
127 | uint128_t f25;
|
---|
128 | uint128_t f26;
|
---|
129 | uint128_t f27;
|
---|
130 | uint128_t f28;
|
---|
131 | uint128_t f29;
|
---|
132 | uint128_t f30;
|
---|
133 | uint128_t f31;
|
---|
134 | } __context_t;
|
---|
135 |
|
---|
136 | #endif /* __ASSEMBLER__ */
|
---|
137 | #endif
|
---|