~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/arch/riscv/util/dwarf-regs.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
  4  * Mapping of DWARF debug register numbers into register names.
  5  */
  6 
  7 #include <stddef.h>
  8 #include <errno.h> /* for EINVAL */
  9 #include <string.h> /* for strcmp */
 10 #include <dwarf-regs.h>
 11 
 12 struct pt_regs_dwarfnum {
 13         const char *name;
 14         unsigned int dwarfnum;
 15 };
 16 
 17 #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num}
 18 #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0}
 19 
 20 struct pt_regs_dwarfnum riscv_dwarf_regs_table[] = {
 21         REG_DWARFNUM_NAME("%zero", 0),
 22         REG_DWARFNUM_NAME("%ra", 1),
 23         REG_DWARFNUM_NAME("%sp", 2),
 24         REG_DWARFNUM_NAME("%gp", 3),
 25         REG_DWARFNUM_NAME("%tp", 4),
 26         REG_DWARFNUM_NAME("%t0", 5),
 27         REG_DWARFNUM_NAME("%t1", 6),
 28         REG_DWARFNUM_NAME("%t2", 7),
 29         REG_DWARFNUM_NAME("%s0", 8),
 30         REG_DWARFNUM_NAME("%s1", 9),
 31         REG_DWARFNUM_NAME("%a0", 10),
 32         REG_DWARFNUM_NAME("%a1", 11),
 33         REG_DWARFNUM_NAME("%a2", 12),
 34         REG_DWARFNUM_NAME("%a3", 13),
 35         REG_DWARFNUM_NAME("%a4", 14),
 36         REG_DWARFNUM_NAME("%a5", 15),
 37         REG_DWARFNUM_NAME("%a6", 16),
 38         REG_DWARFNUM_NAME("%a7", 17),
 39         REG_DWARFNUM_NAME("%s2", 18),
 40         REG_DWARFNUM_NAME("%s3", 19),
 41         REG_DWARFNUM_NAME("%s4", 20),
 42         REG_DWARFNUM_NAME("%s5", 21),
 43         REG_DWARFNUM_NAME("%s6", 22),
 44         REG_DWARFNUM_NAME("%s7", 23),
 45         REG_DWARFNUM_NAME("%s8", 24),
 46         REG_DWARFNUM_NAME("%s9", 25),
 47         REG_DWARFNUM_NAME("%s10", 26),
 48         REG_DWARFNUM_NAME("%s11", 27),
 49         REG_DWARFNUM_NAME("%t3", 28),
 50         REG_DWARFNUM_NAME("%t4", 29),
 51         REG_DWARFNUM_NAME("%t5", 30),
 52         REG_DWARFNUM_NAME("%t6", 31),
 53         REG_DWARFNUM_END,
 54 };
 55 
 56 #define RISCV_MAX_REGS ((sizeof(riscv_dwarf_regs_table) / \
 57                  sizeof(riscv_dwarf_regs_table[0])) - 1)
 58 
 59 const char *get_arch_regstr(unsigned int n)
 60 {
 61         return (n < RISCV_MAX_REGS) ? riscv_dwarf_regs_table[n].name : NULL;
 62 }
 63 
 64 int regs_query_register_offset(const char *name)
 65 {
 66         const struct pt_regs_dwarfnum *roff;
 67 
 68         for (roff = riscv_dwarf_regs_table; roff->name; roff++)
 69                 if (!strcmp(roff->name, name))
 70                         return roff->dwarfnum;
 71         return -EINVAL;
 72 }
 73 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php