• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Marl Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #define MARL_REG_r0 0x00
16 #define MARL_REG_r1 0x04
17 #define MARL_REG_r12 0x08
18 #define MARL_REG_r4 0x0c
19 #define MARL_REG_r5 0x10
20 #define MARL_REG_r6 0x14
21 #define MARL_REG_r7 0x18
22 #define MARL_REG_r8 0x1c
23 #define MARL_REG_r9 0x20
24 #define MARL_REG_r10 0x24
25 #define MARL_REG_r11 0x28
26 #define MARL_REG_v8 0x2c
27 #define MARL_REG_v9 0x30
28 #define MARL_REG_v10 0x34
29 #define MARL_REG_v11 0x38
30 #define MARL_REG_v12 0x3c
31 #define MARL_REG_v13 0x40
32 #define MARL_REG_v14 0x44
33 #define MARL_REG_v15 0x48
34 #define MARL_REG_SP 0x4c
35 #define MARL_REG_LR 0x50
36 
37 #ifndef MARL_BUILD_ASM
38 #include <stdint.h>
39 
40 // Procedure Call Standard for the ARM 64-bit Architecture
41 // http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf
42 struct marl_fiber_context {
43   // parameter registers
44   uintptr_t r0;
45   uintptr_t r1;
46 
47   // special purpose registers
48   uintptr_t r12;  // Intra-Procedure-call
49 
50   // callee-saved registers
51   uintptr_t r4;
52   uintptr_t r5;
53   uintptr_t r6;
54   uintptr_t r7;
55   uintptr_t r8;
56   uintptr_t r9;
57   uintptr_t r10;
58   uintptr_t r11;
59 
60   uintptr_t v8;
61   uintptr_t v9;
62   uintptr_t v10;
63   uintptr_t v11;
64   uintptr_t v12;
65   uintptr_t v13;
66   uintptr_t v14;
67   uintptr_t v15;
68 
69   uintptr_t SP;  // stack pointer (r13)
70   uintptr_t LR;  // link register (r14)
71 };
72 
73 #ifdef __cplusplus
74 #include <cstddef>
75 static_assert(offsetof(marl_fiber_context, r0) == MARL_REG_r0,
76               "Bad register offset");
77 static_assert(offsetof(marl_fiber_context, r1) == MARL_REG_r1,
78               "Bad register offset");
79 static_assert(offsetof(marl_fiber_context, r12) == MARL_REG_r12,
80               "Bad register offset");
81 static_assert(offsetof(marl_fiber_context, r4) == MARL_REG_r4,
82               "Bad register offset");
83 static_assert(offsetof(marl_fiber_context, r5) == MARL_REG_r5,
84               "Bad register offset");
85 static_assert(offsetof(marl_fiber_context, r6) == MARL_REG_r6,
86               "Bad register offset");
87 static_assert(offsetof(marl_fiber_context, r7) == MARL_REG_r7,
88               "Bad register offset");
89 static_assert(offsetof(marl_fiber_context, r8) == MARL_REG_r8,
90               "Bad register offset");
91 static_assert(offsetof(marl_fiber_context, r9) == MARL_REG_r9,
92               "Bad register offset");
93 static_assert(offsetof(marl_fiber_context, r10) == MARL_REG_r10,
94               "Bad register offset");
95 static_assert(offsetof(marl_fiber_context, r11) == MARL_REG_r11,
96               "Bad register offset");
97 static_assert(offsetof(marl_fiber_context, v8) == MARL_REG_v8,
98               "Bad register offset");
99 static_assert(offsetof(marl_fiber_context, v9) == MARL_REG_v9,
100               "Bad register offset");
101 static_assert(offsetof(marl_fiber_context, v10) == MARL_REG_v10,
102               "Bad register offset");
103 static_assert(offsetof(marl_fiber_context, v11) == MARL_REG_v11,
104               "Bad register offset");
105 static_assert(offsetof(marl_fiber_context, v12) == MARL_REG_v12,
106               "Bad register offset");
107 static_assert(offsetof(marl_fiber_context, v13) == MARL_REG_v13,
108               "Bad register offset");
109 static_assert(offsetof(marl_fiber_context, v14) == MARL_REG_v14,
110               "Bad register offset");
111 static_assert(offsetof(marl_fiber_context, v15) == MARL_REG_v15,
112               "Bad register offset");
113 static_assert(offsetof(marl_fiber_context, SP) == MARL_REG_SP,
114               "Bad register offset");
115 static_assert(offsetof(marl_fiber_context, LR) == MARL_REG_LR,
116               "Bad register offset");
117 #endif  // __cplusplus
118 
119 #endif  // MARL_BUILD_ASM
120