Brian Silverman | 8649792 | 2018-02-10 19:28:39 -0500 | [diff] [blame^] | 1 | /* PowerPC specific core note handling. |
| 2 | Copyright (C) 2007, 2008 Red Hat, Inc. |
| 3 | This file is part of elfutils. |
| 4 | |
| 5 | This file is free software; you can redistribute it and/or modify |
| 6 | it under the terms of either |
| 7 | |
| 8 | * the GNU Lesser General Public License as published by the Free |
| 9 | Software Foundation; either version 3 of the License, or (at |
| 10 | your option) any later version |
| 11 | |
| 12 | or |
| 13 | |
| 14 | * the GNU General Public License as published by the Free |
| 15 | Software Foundation; either version 2 of the License, or (at |
| 16 | your option) any later version |
| 17 | |
| 18 | or both in parallel, as here. |
| 19 | |
| 20 | elfutils is distributed in the hope that it will be useful, but |
| 21 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 23 | General Public License for more details. |
| 24 | |
| 25 | You should have received copies of the GNU General Public License and |
| 26 | the GNU Lesser General Public License along with this program. If |
| 27 | not, see <http://www.gnu.org/licenses/>. */ |
| 28 | |
| 29 | #ifdef HAVE_CONFIG_H |
| 30 | # include <config.h> |
| 31 | #endif |
| 32 | |
| 33 | #include <elf.h> |
| 34 | #include <inttypes.h> |
| 35 | #include <stddef.h> |
| 36 | #include <stdio.h> |
| 37 | #include <sys/time.h> |
| 38 | |
| 39 | #ifndef BITS |
| 40 | # define BITS 32 |
| 41 | # define BACKEND ppc_ |
| 42 | #else |
| 43 | # define BITS 64 |
| 44 | # define BACKEND ppc64_ |
| 45 | #endif |
| 46 | #include "libebl_CPU.h" |
| 47 | |
| 48 | static const Ebl_Register_Location prstatus_regs[] = |
| 49 | { |
| 50 | #define GR(at, n, dwreg) \ |
| 51 | { .offset = at * BITS/8, .regno = dwreg, .count = n, .bits = BITS } |
| 52 | |
| 53 | GR (0, 32, 0), /* r0-r31 */ |
| 54 | /* 32, 1, nip */ |
| 55 | GR (33, 1, 66), /* msr */ |
| 56 | /* 34, 1, orig_gpr3 */ |
| 57 | GR (35, 1, 109), /* ctr */ |
| 58 | GR (36, 1, 108), /* lr */ |
| 59 | GR (37, 1, 101), /* xer */ |
| 60 | GR (38, 1, 64), /* cr */ |
| 61 | GR (39, 1, 100), /* mq */ |
| 62 | /* 40, 1, trap */ |
| 63 | GR (41, 1, 119), /* dar */ |
| 64 | GR (42, 1, 118), /* dsisr */ |
| 65 | |
| 66 | #undef GR |
| 67 | }; |
| 68 | #define PRSTATUS_REGS_SIZE (BITS / 8 * 48) |
| 69 | |
| 70 | static const Ebl_Register_Location fpregset_regs[] = |
| 71 | { |
| 72 | { .offset = 0, .regno = 32, .count = 32, .bits = 64 }, /* f0-f31 */ |
| 73 | { .offset = 32 * 8 + 4, .regno = 65, .count = 1, .bits = 32 } /* fpscr */ |
| 74 | }; |
| 75 | #define FPREGSET_SIZE (33 * 8) |
| 76 | |
| 77 | static const Ebl_Register_Location altivec_regs[] = |
| 78 | { |
| 79 | /* vr0-vr31 */ |
| 80 | { .offset = 0, .regno = 1124, .count = 32, .bits = 128 }, |
| 81 | /* vscr XXX 67 is an unofficial assignment */ |
| 82 | { .offset = 32 * 16, .regno = 67, .count = 1, .bits = 32, .pad = 12 }, |
| 83 | /* vrsave */ |
| 84 | { .offset = 33 * 16, .regno = 356, .count = 1, .bits = 32, .pad = 12 } |
| 85 | }; |
| 86 | |
| 87 | static const Ebl_Register_Location spe_regs[] = |
| 88 | { |
| 89 | /* evr0-evr31 |
| 90 | { .offset = 0, .regno = ???, .count = 32, .bits = 32 }, |
| 91 | * acc * |
| 92 | { .offset = 32 * 4, .regno = ???, .count = 1, .bits = 64 }, */ |
| 93 | /* spefscr */ |
| 94 | { .offset = 34 * 4, .regno = 612, .count = 1, .bits = 32 } |
| 95 | }; |
| 96 | |
| 97 | static const Ebl_Register_Location tm_spr_regs[] = |
| 98 | { |
| 99 | /* tfhar */ |
| 100 | { .offset = 0, .regno = 114, .count = 1, .bits = 64 }, |
| 101 | /* texasr */ |
| 102 | { .offset = 8, .regno = 116, .count = 1, .bits = 64 }, |
| 103 | /* tfiar */ |
| 104 | { .offset = 16, .regno = 115, .count = 1, .bits = 64 } |
| 105 | }; |
| 106 | |
| 107 | #define EXTRA_NOTES \ |
| 108 | EXTRA_REGSET (NT_PPC_VMX, 34 * 16, altivec_regs) \ |
| 109 | EXTRA_REGSET (NT_PPC_SPE, 35 * 4, spe_regs) \ |
| 110 | EXTRA_REGSET (NT_PPC_TM_SPR, 3 * 8, tm_spr_regs) |
| 111 | |
| 112 | #if BITS == 32 |
| 113 | # define ULONG uint32_t |
| 114 | # define ALIGN_ULONG 4 |
| 115 | # define TYPE_ULONG ELF_T_WORD |
| 116 | # define TYPE_LONG ELF_T_SWORD |
| 117 | #else |
| 118 | # define ULONG uint64_t |
| 119 | # define ALIGN_ULONG 8 |
| 120 | # define TYPE_ULONG ELF_T_XWORD |
| 121 | # define TYPE_LONG ELF_T_SXWORD |
| 122 | #endif |
| 123 | #define PID_T int32_t |
| 124 | #define UID_T uint32_t |
| 125 | #define GID_T uint32_t |
| 126 | #define ALIGN_PID_T 4 |
| 127 | #define ALIGN_UID_T 4 |
| 128 | #define ALIGN_GID_T 4 |
| 129 | #define TYPE_PID_T ELF_T_SWORD |
| 130 | #define TYPE_UID_T ELF_T_WORD |
| 131 | #define TYPE_GID_T ELF_T_WORD |
| 132 | |
| 133 | #define PRSTATUS_REGSET_ITEMS \ |
| 134 | { \ |
| 135 | .name = "nip", .type = ELF_T_ADDR, .format = 'x', \ |
| 136 | .offset = offsetof (struct EBLHOOK(prstatus), pr_reg[32]), \ |
| 137 | .group = "register", .pc_register = true \ |
| 138 | }, \ |
| 139 | { \ |
| 140 | .name = "orig_gpr3", .type = TYPE_LONG, .format = 'd', \ |
| 141 | .offset = offsetof (struct EBLHOOK(prstatus), pr_reg[34]), \ |
| 142 | .group = "register" \ |
| 143 | } |
| 144 | |
| 145 | #include "linux-core-note.c" |