1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 * See "LICENSE_BSD2.txt" for details.
9 *
10 * @TAG(DATA61_BSD)
11 */
12
13#pragma once
14
15#include <sel4/sel4.h>
16#include <stddef.h>
17#include <utils/util.h>
18
19static UNUSED const char *register_names[] = {
20    "pc",
21    "sp",
22    "spsr",
23    "x0",
24    "x1",
25    "x2",
26    "x3",
27    "x4",
28    "x5",
29    "x6",
30    "x7",
31    "x8",
32    "x16",
33    "x17",
34    "x18",
35    "x29",
36    "x30",
37    "x9",
38    "x10",
39    "x11",
40    "x12",
41    "x13",
42    "x14",
43    "x15",
44    "x19",
45    "x20",
46    "x21",
47    "x22",
48    "x23",
49    "x24",
50    "x25",
51    "x26",
52    "x27",
53    "x28",
54    "tpidr_el0",
55    "tpidrro_el0"
56};
57
58/* assert that register_names correspond to seL4_UserContext */
59compile_time_assert(pc_correct_position, offsetof(seL4_UserContext, pc)           == 0);
60compile_time_assert(sp_correct_position, offsetof(seL4_UserContext, sp)           == 1 *  sizeof(seL4_Word));
61compile_time_assert(spsr_correct_position, offsetof(seL4_UserContext, spsr)       == 2 *  sizeof(seL4_Word));
62compile_time_assert(x0_correct_position, offsetof(seL4_UserContext, x0)           == 3 *  sizeof(seL4_Word));
63compile_time_assert(x1_correct_position, offsetof(seL4_UserContext, x1)           == 4 *  sizeof(seL4_Word));
64compile_time_assert(x2_correct_position, offsetof(seL4_UserContext, x2)           == 5 *  sizeof(seL4_Word));
65compile_time_assert(x3_correct_position, offsetof(seL4_UserContext, x3)           == 6 *  sizeof(seL4_Word));
66compile_time_assert(x4_correct_position, offsetof(seL4_UserContext, x4)           == 7 * sizeof(seL4_Word));
67compile_time_assert(x5_correct_position, offsetof(seL4_UserContext, x5)           == 8 * sizeof(seL4_Word));
68compile_time_assert(x6_correct_position, offsetof(seL4_UserContext, x6)           == 9 * sizeof(seL4_Word));
69compile_time_assert(x7_correct_position, offsetof(seL4_UserContext, x7)           == 10 * sizeof(seL4_Word));
70compile_time_assert(x8_correct_position, offsetof(seL4_UserContext, x8)           == 11 * sizeof(seL4_Word));
71compile_time_assert(x16_correct_position, offsetof(seL4_UserContext, x16)         == 12 * sizeof(seL4_Word));
72compile_time_assert(x17_correct_position, offsetof(seL4_UserContext, x17)         == 13 * sizeof(seL4_Word));
73compile_time_assert(x18_correct_position, offsetof(seL4_UserContext, x18)         == 14 * sizeof(seL4_Word));
74compile_time_assert(x29_correct_position, offsetof(seL4_UserContext, x29)         == 15 * sizeof(seL4_Word));
75compile_time_assert(x30_correct_position, offsetof(seL4_UserContext, x30)         == 16 * sizeof(seL4_Word));
76compile_time_assert(x9_correct_position, offsetof(seL4_UserContext, x9)           == 17 * sizeof(seL4_Word));
77compile_time_assert(x10_correct_position, offsetof(seL4_UserContext, x10)         == 18 * sizeof(seL4_Word));
78compile_time_assert(x11_correct_position, offsetof(seL4_UserContext, x11)         == 19 *  sizeof(seL4_Word));
79compile_time_assert(x12_correct_position, offsetof(seL4_UserContext, x12)         == 20 *  sizeof(seL4_Word));
80compile_time_assert(x13_correct_position, offsetof(seL4_UserContext, x13)         == 21 *  sizeof(seL4_Word));
81compile_time_assert(x14_correct_position, offsetof(seL4_UserContext, x14)         == 22 * sizeof(seL4_Word));
82compile_time_assert(x15_correct_position, offsetof(seL4_UserContext, x15)         == 23 * sizeof(seL4_Word));
83compile_time_assert(x19_correct_position, offsetof(seL4_UserContext, x19)         == 24 * sizeof(seL4_Word));
84compile_time_assert(x20_correct_position, offsetof(seL4_UserContext, x20)         == 25 * sizeof(seL4_Word));
85compile_time_assert(x21_correct_position, offsetof(seL4_UserContext, x21)         == 26 * sizeof(seL4_Word));
86compile_time_assert(x22_correct_position, offsetof(seL4_UserContext, x22)         == 27 * sizeof(seL4_Word));
87compile_time_assert(x23_correct_position, offsetof(seL4_UserContext, x23)         == 28 * sizeof(seL4_Word));
88compile_time_assert(x24_correct_position, offsetof(seL4_UserContext, x24)         == 29 * sizeof(seL4_Word));
89compile_time_assert(x25_correct_position, offsetof(seL4_UserContext, x25)         == 30 * sizeof(seL4_Word));
90compile_time_assert(x26_correct_position, offsetof(seL4_UserContext, x26)         == 31 * sizeof(seL4_Word));
91compile_time_assert(x27_correct_position, offsetof(seL4_UserContext, x27)         == 32 * sizeof(seL4_Word));
92compile_time_assert(x28_correct_position, offsetof(seL4_UserContext, x28)         == 33 * sizeof(seL4_Word));
93compile_time_assert(tpidr_el0_correct_position, offsetof(seL4_UserContext, tpidr_el0)   == 34 * sizeof(seL4_Word));
94compile_time_assert(tpidrro_el0_correct_position, offsetof(seL4_UserContext, tpidrro_el0)   == 35 * sizeof(seL4_Word));
95
96