1 | /*
|
---|
2 | * Copyright (c) 2016 Martin Decky
|
---|
3 | * All rights reserved.
|
---|
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_SP 0x00
|
---|
33 | #define __CONTEXT_OFFSET_PC 0x08
|
---|
34 | #define __CONTEXT_OFFSET_ZERO 0x10
|
---|
35 | #define __CONTEXT_OFFSET_RA 0x18
|
---|
36 | #define __CONTEXT_OFFSET_X3 0x20
|
---|
37 | #define __CONTEXT_OFFSET_X4 0x28
|
---|
38 | #define __CONTEXT_OFFSET_X5 0x30
|
---|
39 | #define __CONTEXT_OFFSET_X6 0x38
|
---|
40 | #define __CONTEXT_OFFSET_X7 0x40
|
---|
41 | #define __CONTEXT_OFFSET_X8 0x48
|
---|
42 | #define __CONTEXT_OFFSET_X9 0x50
|
---|
43 | #define __CONTEXT_OFFSET_X10 0x58
|
---|
44 | #define __CONTEXT_OFFSET_X11 0x60
|
---|
45 | #define __CONTEXT_OFFSET_X12 0x68
|
---|
46 | #define __CONTEXT_OFFSET_X13 0x70
|
---|
47 | #define __CONTEXT_OFFSET_X14 0x78
|
---|
48 | #define __CONTEXT_OFFSET_X15 0x80
|
---|
49 | #define __CONTEXT_OFFSET_X16 0x88
|
---|
50 | #define __CONTEXT_OFFSET_X17 0x90
|
---|
51 | #define __CONTEXT_OFFSET_X18 0x98
|
---|
52 | #define __CONTEXT_OFFSET_X19 0xa0
|
---|
53 | #define __CONTEXT_OFFSET_X20 0xa8
|
---|
54 | #define __CONTEXT_OFFSET_X21 0xb0
|
---|
55 | #define __CONTEXT_OFFSET_X22 0xb8
|
---|
56 | #define __CONTEXT_OFFSET_X23 0xc0
|
---|
57 | #define __CONTEXT_OFFSET_X24 0xc8
|
---|
58 | #define __CONTEXT_OFFSET_X25 0xd0
|
---|
59 | #define __CONTEXT_OFFSET_X26 0xd8
|
---|
60 | #define __CONTEXT_OFFSET_X27 0xe0
|
---|
61 | #define __CONTEXT_OFFSET_X28 0xe8
|
---|
62 | #define __CONTEXT_OFFSET_X29 0xf0
|
---|
63 | #define __CONTEXT_OFFSET_X30 0xf8
|
---|
64 | #define __CONTEXT_OFFSET_X31 0x100
|
---|
65 | #define __CONTEXT_SIZE 0x108
|
---|
66 |
|
---|
67 | #ifndef __ASSEMBLER__
|
---|
68 |
|
---|
69 | #include <stddef.h>
|
---|
70 | #include <stdint.h>
|
---|
71 |
|
---|
72 | /*
|
---|
73 | * There is a room for optimization (we can store just those
|
---|
74 | * registers that must be preserved during ABI function call).
|
---|
75 | */
|
---|
76 |
|
---|
77 | typedef struct __context {
|
---|
78 | uint64_t sp;
|
---|
79 | uint64_t pc;
|
---|
80 | uint64_t zero;
|
---|
81 | uint64_t ra;
|
---|
82 | uint64_t x3;
|
---|
83 | uint64_t x4;
|
---|
84 | uint64_t x5;
|
---|
85 | uint64_t x6;
|
---|
86 | uint64_t x7;
|
---|
87 | uint64_t x8;
|
---|
88 | uint64_t x9;
|
---|
89 | uint64_t x10;
|
---|
90 | uint64_t x11;
|
---|
91 | uint64_t x12;
|
---|
92 | uint64_t x13;
|
---|
93 | uint64_t x14;
|
---|
94 | uint64_t x15;
|
---|
95 | uint64_t x16;
|
---|
96 | uint64_t x17;
|
---|
97 | uint64_t x18;
|
---|
98 | uint64_t x19;
|
---|
99 | uint64_t x20;
|
---|
100 | uint64_t x21;
|
---|
101 | uint64_t x22;
|
---|
102 | uint64_t x23;
|
---|
103 | uint64_t x24;
|
---|
104 | uint64_t x25;
|
---|
105 | uint64_t x26;
|
---|
106 | uint64_t x27;
|
---|
107 | uint64_t x28;
|
---|
108 | uint64_t x29;
|
---|
109 | uint64_t x30;
|
---|
110 | uint64_t x31;
|
---|
111 | } __context_t;
|
---|
112 |
|
---|
113 | #endif
|
---|
114 | #endif
|
---|