1 /* RISC-V specific core note handling. 2 This file is part of elfutils. 3 4 This file is free software; you can redistribute it and/or modify 5 it under the terms of either 6 7 * the GNU Lesser General Public License as published by the Free 8 Software Foundation; either version 3 of the License, or (at 9 your option) any later version 10 11 or 12 13 * the GNU General Public License as published by the Free 14 Software Foundation; either version 2 of the License, or (at 15 your option) any later version 16 17 or both in parallel, as here. 18 19 elfutils is distributed in the hope that it will be useful, but 20 WITHOUT ANY WARRANTY; without even the implied warranty of 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 General Public License for more details. 23 24 You should have received copies of the GNU General Public License and 25 the GNU Lesser General Public License along with this program. If 26 not, see <http://www.gnu.org/licenses/>. */ 27 28 #ifdef HAVE_CONFIG_H 29 # include <config.h> 30 #endif 31 32 #include <elf.h> 33 #include <inttypes.h> 34 #include <stddef.h> 35 #include <stdio.h> 36 #include <sys/time.h> 37 38 #ifndef BITS 39 # define BITS 32 40 # define BACKEND riscv_ 41 #else 42 # define BITS 64 43 # define BACKEND riscv64_ 44 #endif 45 46 #include "libebl_CPU.h" 47 48 #if BITS == 32 49 # define ULONG uint32_t 50 # define UID_T uint16_t 51 # define GID_T uint16_t 52 # define ALIGN_ULONG 4 53 # define ALIGN_UID_T 2 54 # define ALIGN_GID_T 2 55 # define TYPE_ULONG ELF_T_WORD 56 # define TYPE_UID_T ELF_T_HALF 57 # define TYPE_GID_T ELF_T_HALF 58 #else 59 # define ULONG uint64_t 60 # define UID_T uint32_t 61 # define GID_T uint32_t 62 # define ALIGN_ULONG 8 63 # define ALIGN_UID_T 4 64 # define ALIGN_GID_T 4 65 # define TYPE_ULONG ELF_T_XWORD 66 # define TYPE_UID_T ELF_T_WORD 67 # define TYPE_GID_T ELF_T_WORD 68 #endif 69 70 #define PID_T int32_t 71 #define ALIGN_PID_T 4 72 #define TYPE_PID_T ELF_T_SWORD 73 74 75 static const Ebl_Register_Location prstatus_regs[] = 76 { 77 { .offset = BITS/8, .regno = 1, .count = 31, .bits = BITS } /* x1..x31 */ 78 }; 79 #define PRSTATUS_REGS_SIZE (32 * (BITS/8)) 80 81 #define PRSTATUS_REGSET_ITEMS \ 82 { \ 83 .name = "pc", .type = ELF_T_ADDR, .format = 'x', \ 84 .offset = offsetof (struct EBLHOOK(prstatus), pr_reg[0]), \ 85 .group = "register", .pc_register = true \ 86 } 87 88 #include "linux-core-note.c" 89