1 /* SPARC specific core note handling. 2 Copyright (C) 2007 Red Hat, Inc. 3 Copyright (C) 2015 Oracle, Inc. 4 This file is part of elfutils. 5 6 This file is free software; you can redistribute it and/or modify 7 it under the terms of either 8 9 * the GNU Lesser General Public License as published by the Free 10 Software Foundation; either version 3 of the License, or (at 11 your option) any later version 12 13 or 14 15 * the GNU General Public License as published by the Free 16 Software Foundation; either version 2 of the License, or (at 17 your option) any later version 18 19 or both in parallel, as here. 20 21 elfutils is distributed in the hope that it will be useful, but 22 WITHOUT ANY WARRANTY; without even the implied warranty of 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 General Public License for more details. 25 26 You should have received copies of the GNU General Public License and 27 the GNU Lesser General Public License along with this program. If 28 not, see <http://www.gnu.org/licenses/>. */ 29 30 #ifdef HAVE_CONFIG_H 31 # include <config.h> 32 #endif 33 34 #include <elf.h> 35 #include <inttypes.h> 36 #include <stddef.h> 37 #include <stdio.h> 38 #include <sys/time.h> 39 40 #ifndef BITS 41 # define BITS 32 42 # define BACKEND sparc_ 43 #else 44 # define BITS 64 45 # define BACKEND sparc64_ 46 #endif 47 #include "libebl_CPU.h" 48 49 #define GR(at, n, dwreg) \ 50 { .offset = at * BITS/8, .regno = dwreg, .count = n, .bits = BITS } 51 52 static const Ebl_Register_Location prstatus_regs[] = 53 { 54 GR (0, 32, 0), /* %g0-%g7, %o0-%o7, %i0-%i7 */ 55 #if BITS == 32 56 GR (32, 1, 65), /* %psr */ 57 GR (33, 2, 68), /* %pc, %npc */ 58 GR (35, 1, 64), /* %y */ 59 GR (36, 1, 66), /* %wim, %tbr */ 60 #else 61 GR (32, 1, 82), /* %state */ 62 GR (33, 2, 80), /* %pc, %npc */ 63 GR (35, 1, 85), /* %y */ 64 #endif 65 }; 66 #define PRSTATUS_REGS_SIZE (BITS / 8 * (32 + (BITS == 32 ? 6 : 4))) 67 68 static const Ebl_Register_Location fpregset_regs[] = 69 { 70 #if BITS == 32 71 GR (0, 32, 32), /* %f0-%f31 */ 72 /* padding word */ 73 GR (33, 1, 70), /* %fsr */ 74 /* qcnt, q_entrysize, en, q, padding */ 75 # define FPREGSET_SIZE (34 * 4 + 4 + 64 * 4 + 4) 76 #else 77 GR (0, 32, 32), /* %f0-%f31 */ 78 GR (32, 1, 83), /* %fsr */ 79 /* 33, 1, %gsr */ 80 GR (34, 1, 84), /* %fprs */ 81 # define FPREGSET_SIZE (35 * 8) 82 #endif 83 }; 84 85 #if BITS == 32 86 # define ULONG uint32_t 87 # define ALIGN_ULONG 4 88 # define TYPE_ULONG ELF_T_WORD 89 # define TYPE_LONG ELF_T_SWORD 90 # define UID_T uint16_t 91 # define GID_T uint16_t 92 # define ALIGN_UID_T 2 93 # define ALIGN_GID_T 2 94 # define TYPE_UID_T ELF_T_HALF 95 # define TYPE_GID_T ELF_T_HALF 96 #else 97 # define ULONG uint64_t 98 # define ALIGN_ULONG 8 99 # define TYPE_ULONG ELF_T_XWORD 100 # define TYPE_LONG ELF_T_SXWORD 101 # define UID_T uint32_t 102 # define GID_T uint32_t 103 # define ALIGN_UID_T 4 104 # define ALIGN_GID_T 4 105 # define TYPE_UID_T ELF_T_WORD 106 # define TYPE_GID_T ELF_T_WORD 107 # define SUSECONDS_HALF 1 108 #endif 109 #define PID_T int32_t 110 #define ALIGN_PID_T 4 111 #define TYPE_PID_T ELF_T_SWORD 112 113 #define PRSTATUS_REGSET_ITEMS \ 114 { \ 115 .name = "pc", .type = ELF_T_ADDR, .format = 'x', \ 116 .offset = offsetof (struct EBLHOOK(prstatus), pr_reg[33]), \ 117 .group = "register", .pc_register = true \ 118 } 119 120 #include "linux-core-note.c" 121