| 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 KERN_ARCH_CONTEXT_STRUCT_H_
|
|---|
| 30 | #define KERN_ARCH_CONTEXT_STRUCT_H_
|
|---|
| 31 |
|
|---|
| 32 | #define CONTEXT_OFFSET_AR_PFS 0x00
|
|---|
| 33 | #define CONTEXT_OFFSET_AR_UNAT_CALLER 0x08
|
|---|
| 34 | #define CONTEXT_OFFSET_AR_UNAT_CALLEE 0x10
|
|---|
| 35 | #define CONTEXT_OFFSET_AR_RSC 0x18
|
|---|
| 36 | #define CONTEXT_OFFSET_BSP 0x20
|
|---|
| 37 | #define CONTEXT_OFFSET_AR_RNAT 0x28
|
|---|
| 38 | #define CONTEXT_OFFSET_AR_LC 0x30
|
|---|
| 39 | #define CONTEXT_OFFSET_AR_FPSR 0x38
|
|---|
| 40 | #define CONTEXT_OFFSET_R1 0x40
|
|---|
| 41 | #define CONTEXT_OFFSET_R4 0x48
|
|---|
| 42 | #define CONTEXT_OFFSET_R5 0x50
|
|---|
| 43 | #define CONTEXT_OFFSET_R6 0x58
|
|---|
| 44 | #define CONTEXT_OFFSET_R7 0x60
|
|---|
| 45 | #define CONTEXT_OFFSET_SP 0x68
|
|---|
| 46 | #define CONTEXT_OFFSET_R13 0x70
|
|---|
| 47 | #define CONTEXT_OFFSET_PC 0x78
|
|---|
| 48 | #define CONTEXT_OFFSET_B1 0x80
|
|---|
| 49 | #define CONTEXT_OFFSET_B2 0x88
|
|---|
| 50 | #define CONTEXT_OFFSET_B3 0x90
|
|---|
| 51 | #define CONTEXT_OFFSET_B4 0x98
|
|---|
| 52 | #define CONTEXT_OFFSET_B5 0xa0
|
|---|
| 53 | #define CONTEXT_OFFSET_PR 0xa8
|
|---|
| 54 | #define CONTEXT_OFFSET_F2 0xb0
|
|---|
| 55 | #define CONTEXT_OFFSET_F3 0xc0
|
|---|
| 56 | #define CONTEXT_OFFSET_F4 0xd0
|
|---|
| 57 | #define CONTEXT_OFFSET_F5 0xe0
|
|---|
| 58 | #define CONTEXT_OFFSET_F16 0xf0
|
|---|
| 59 | #define CONTEXT_OFFSET_F17 0x100
|
|---|
| 60 | #define CONTEXT_OFFSET_F18 0x110
|
|---|
| 61 | #define CONTEXT_OFFSET_F19 0x120
|
|---|
| 62 | #define CONTEXT_OFFSET_F20 0x130
|
|---|
| 63 | #define CONTEXT_OFFSET_F21 0x140
|
|---|
| 64 | #define CONTEXT_OFFSET_F22 0x150
|
|---|
| 65 | #define CONTEXT_OFFSET_F23 0x160
|
|---|
| 66 | #define CONTEXT_OFFSET_F24 0x170
|
|---|
| 67 | #define CONTEXT_OFFSET_F25 0x180
|
|---|
| 68 | #define CONTEXT_OFFSET_F26 0x190
|
|---|
| 69 | #define CONTEXT_OFFSET_F27 0x1a0
|
|---|
| 70 | #define CONTEXT_OFFSET_F28 0x1b0
|
|---|
| 71 | #define CONTEXT_OFFSET_F29 0x1c0
|
|---|
| 72 | #define CONTEXT_OFFSET_F30 0x1d0
|
|---|
| 73 | #define CONTEXT_OFFSET_F31 0x1e0
|
|---|
| 74 | #define CONTEXT_OFFSET_IPL 0x1f0
|
|---|
| 75 | #define CONTEXT_SIZE 0x200
|
|---|
| 76 |
|
|---|
| 77 | #ifndef __ASSEMBLER__
|
|---|
| 78 |
|
|---|
| 79 | #include <typedefs.h>
|
|---|
| 80 |
|
|---|
| 81 | // Only save registers that must be preserved across function calls.
|
|---|
| 82 | typedef struct context {
|
|---|
| 83 | // Application registers.
|
|---|
| 84 | uint64_t ar_pfs;
|
|---|
| 85 | uint64_t ar_unat_caller;
|
|---|
| 86 | uint64_t ar_unat_callee;
|
|---|
| 87 | uint64_t ar_rsc;
|
|---|
| 88 | // ar_bsp
|
|---|
| 89 | uint64_t bsp;
|
|---|
| 90 | uint64_t ar_rnat;
|
|---|
| 91 | uint64_t ar_lc;
|
|---|
| 92 | uint64_t ar_fpsr;
|
|---|
| 93 |
|
|---|
| 94 | // General registers.
|
|---|
| 95 | uint64_t r1;
|
|---|
| 96 | uint64_t r4;
|
|---|
| 97 | uint64_t r5;
|
|---|
| 98 | uint64_t r6;
|
|---|
| 99 | uint64_t r7;
|
|---|
| 100 | // r12
|
|---|
| 101 | uint64_t sp;
|
|---|
| 102 | uint64_t r13;
|
|---|
| 103 |
|
|---|
| 104 | // Branch registers.
|
|---|
| 105 | // b0
|
|---|
| 106 | uint64_t pc;
|
|---|
| 107 | uint64_t b1;
|
|---|
| 108 | uint64_t b2;
|
|---|
| 109 | uint64_t b3;
|
|---|
| 110 | uint64_t b4;
|
|---|
| 111 | uint64_t b5;
|
|---|
| 112 |
|
|---|
| 113 | // Predicate registers.
|
|---|
| 114 | uint64_t pr;
|
|---|
| 115 |
|
|---|
| 116 | // Floating-point registers.
|
|---|
| 117 | uint128_t f2;
|
|---|
| 118 | uint128_t f3;
|
|---|
| 119 | uint128_t f4;
|
|---|
| 120 | uint128_t f5;
|
|---|
| 121 | uint128_t f16;
|
|---|
| 122 | uint128_t f17;
|
|---|
| 123 | uint128_t f18;
|
|---|
| 124 | uint128_t f19;
|
|---|
| 125 | uint128_t f20;
|
|---|
| 126 | uint128_t f21;
|
|---|
| 127 | uint128_t f22;
|
|---|
| 128 | uint128_t f23;
|
|---|
| 129 | uint128_t f24;
|
|---|
| 130 | uint128_t f25;
|
|---|
| 131 | uint128_t f26;
|
|---|
| 132 | uint128_t f27;
|
|---|
| 133 | uint128_t f28;
|
|---|
| 134 | uint128_t f29;
|
|---|
| 135 | uint128_t f30;
|
|---|
| 136 | uint128_t f31;
|
|---|
| 137 |
|
|---|
| 138 | ipl_t ipl;
|
|---|
| 139 | } context_t;
|
|---|
| 140 |
|
|---|
| 141 | #endif /* __ASSEMBLER__ */
|
|---|
| 142 | #endif
|
|---|