context_frame.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017, 2019 JP Bonn, Ken Rabold
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
19 #ifndef CONTEXT_FRAME_H
20 #define CONTEXT_FRAME_H
21 
22 #if !defined(__ASSEMBLER__)
23 #include <stdint.h>
24 #include <assert.h>
25 #endif /* __ASSEMBLER__ */
26 
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #if !defined(__ASSEMBLER__)
33 
43  /* Callee saved registers */
44  uint32_t s0;
45  uint32_t s1;
46  uint32_t s2;
47  uint32_t s3;
48  uint32_t s4;
49  uint32_t s5;
50  uint32_t s6;
51  uint32_t s7;
52  uint32_t s8;
53  uint32_t s9;
54  uint32_t s10;
55  uint32_t s11;
56  /* Caller saved registers */
57  uint32_t ra;
58  uint32_t t0;
59  uint32_t t1;
60  uint32_t t2;
61  uint32_t t3;
62  uint32_t t4;
63  uint32_t t5;
64  uint32_t t6;
65  uint32_t a0;
66  uint32_t a1;
67  uint32_t a2;
68  uint32_t a3;
69  uint32_t a4;
70  uint32_t a5;
71  uint32_t a6;
72  uint32_t a7;
73  /* Saved PC for return from ISR */
74  uint32_t pc;
75  uint32_t pad[3];
76 };
77 
78 #endif /* __ASSEMBLER__ */
79 
80 
85 /* These values are checked for correctness in context_frame.c */
86 #define s0_OFFSET 0
87 #define s1_OFFSET 4
88 #define s2_OFFSET 8
89 #define s3_OFFSET 12
90 #define s4_OFFSET 16
91 #define s5_OFFSET 20
92 #define s6_OFFSET 24
93 #define s7_OFFSET 28
94 #define s8_OFFSET 32
95 #define s9_OFFSET 36
96 #define s10_OFFSET 40
97 #define s11_OFFSET 44
98 #define ra_OFFSET 48
99 #define t0_OFFSET 52
100 #define t1_OFFSET 56
101 #define t2_OFFSET 60
102 #define t3_OFFSET 64
103 #define t4_OFFSET 68
104 #define t5_OFFSET 72
105 #define t6_OFFSET 76
106 #define a0_OFFSET 80
107 #define a1_OFFSET 84
108 #define a2_OFFSET 88
109 #define a3_OFFSET 92
110 #define a4_OFFSET 96
111 #define a5_OFFSET 100
112 #define a6_OFFSET 104
113 #define a7_OFFSET 108
114 #define pc_OFFSET 112
115 #define pad_OFFSET 116
116 
121 #define CONTEXT_FRAME_SIZE (pad_OFFSET + 12)
122 
126 #define SP_OFFSET_IN_THREAD 0
127 
128 
129 #ifdef __cplusplus
130 }
131 #endif
132 
133 #endif /* CONTEXT_FRAME_H */
134 
uint32_t s5
s5 register
Definition: context_frame.h:49
uint32_t s9
s9 register
Definition: context_frame.h:53
uint32_t s11
s11 register
Definition: context_frame.h:55
uint32_t a6
a6 register
Definition: context_frame.h:71
uint32_t s1
s1 register
Definition: context_frame.h:45
uint32_t a3
a3 register
Definition: context_frame.h:68
uint32_t s10
s10 register
Definition: context_frame.h:54
uint32_t s0
s0 register
Definition: context_frame.h:44
uint32_t a0
a0 register
Definition: context_frame.h:65
uint32_t s6
s6 register
Definition: context_frame.h:50
uint32_t s3
s3 register
Definition: context_frame.h:47
uint32_t a7
a7 register
Definition: context_frame.h:72
POSIX.1-2008 compliant version of the assert macro.
uint32_t s2
s2 register
Definition: context_frame.h:46
uint32_t a2
a2 register
Definition: context_frame.h:67
uint32_t ra
ra register
Definition: context_frame.h:57
uint32_t a5
a5 register
Definition: context_frame.h:70
uint32_t t1
t1 register
Definition: context_frame.h:59
uint32_t a4
a4 register
Definition: context_frame.h:69
uint32_t s7
s7 register
Definition: context_frame.h:51
uint32_t t3
t3 register
Definition: context_frame.h:61
uint32_t pad[3]
padding to maintain 16 byte alignment
Definition: context_frame.h:75
uint32_t pc
program counter
Definition: context_frame.h:74
uint32_t a1
a1 register
Definition: context_frame.h:66
uint32_t t0
t0 register
Definition: context_frame.h:58
uint32_t s4
s4 register
Definition: context_frame.h:48
uint32_t t6
t6 register
Definition: context_frame.h:64
uint32_t s8
s8 register
Definition: context_frame.h:52
Stores the registers and PC for a context switch.
Definition: context_frame.h:42
uint32_t t4
t4 register
Definition: context_frame.h:62
uint32_t t5
t5 register
Definition: context_frame.h:63
uint32_t t2
t2 register
Definition: context_frame.h:60