tools/perf/util/dwarf-regs-arch/dwarf-regs-csky.c
Source file repositories/reference/linux-study-clean/tools/perf/util/dwarf-regs-arch/dwarf-regs-csky.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/dwarf-regs-arch/dwarf-regs-csky.c- Extension
.c- Size
- 4242 bytes
- Lines
- 127
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
errno.hstddef.hdwarf-regs.h../../../arch/csky/include/uapi/asm/perf_regs.h
Detected Declarations
function __get_dwarf_regnumfunction __get_csky_regnumfunction __get_dwarf_regnum_for_perf_regnum_csky
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
// Mapping of DWARF debug register numbers into register names.
#include <errno.h>
#include <stddef.h>
#include <dwarf-regs.h>
// Ensure the V2 perf reg definitions are included.
#undef __CSKYABIV2__
#define __CSKYABIV2__ 1
#include "../../../arch/csky/include/uapi/asm/perf_regs.h"
#define CSKY_ABIV2_MAX_REGS 73
static const char * const csky_dwarf_regs_table_abiv2[CSKY_ABIV2_MAX_REGS] = {
/* r0 ~ r8 */
"%a0", "%a1", "%a2", "%a3", "%regs0", "%regs1", "%regs2", "%regs3",
/* r9 ~ r15 */
"%regs4", "%regs5", "%regs6", "%regs7", "%regs8", "%regs9", "%sp",
"%lr",
/* r16 ~ r23 */
"%exregs0", "%exregs1", "%exregs2", "%exregs3", "%exregs4",
"%exregs5", "%exregs6", "%exregs7",
/* r24 ~ r31 */
"%exregs8", "%exregs9", "%exregs10", "%exregs11", "%exregs12",
"%exregs13", "%exregs14", "%tls",
"%pc", NULL, NULL, NULL, "%hi", "%lo", NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
"%epc",
};
#define CSKY_ABIV1_MAX_REGS 57
static const char * const csky_dwarf_regs_table_abiv1[CSKY_ABIV1_MAX_REGS] = {
/* r0 ~ r8 */
"%sp", "%regs9", "%a0", "%a1", "%a2", "%a3", "%regs0", "%regs1",
/* r9 ~ r15 */
"%regs2", "%regs3", "%regs4", "%regs5", "%regs6", "%regs7", "%regs8",
"%lr",
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
"%epc",
};
const char *__get_csky_regstr(unsigned int n, unsigned int flags)
{
if (flags & EF_CSKY_ABIV2)
return (n < CSKY_ABIV2_MAX_REGS) ? csky_dwarf_regs_table_abiv2[n] : NULL;
return (n < CSKY_ABIV1_MAX_REGS) ? csky_dwarf_regs_table_abiv1[n] : NULL;
}
static int __get_dwarf_regnum(const char *const *regstr, size_t num_regstr, const char *name)
{
for (size_t i = 0; i < num_regstr; i++) {
if (regstr[i] && !strcmp(regstr[i], name))
return i;
}
return -ENOENT;
}
int __get_csky_regnum(const char *name, unsigned int flags)
{
if (flags & EF_CSKY_ABIV2)
return __get_dwarf_regnum(csky_dwarf_regs_table_abiv2, CSKY_ABIV2_MAX_REGS, name);
return __get_dwarf_regnum(csky_dwarf_regs_table_abiv1, CSKY_ABIV1_MAX_REGS, name);
}
int __get_dwarf_regnum_for_perf_regnum_csky(int perf_regnum, unsigned int flags)
{
static const int dwarf_csky_regnums[][2] = {
[PERF_REG_CSKY_TLS] = {-ENOENT, 31},
[PERF_REG_CSKY_LR] = {15, 15},
[PERF_REG_CSKY_PC] = {-ENOENT, 32},
/* TODO: PERF_REG_CSKY_SR */
[PERF_REG_CSKY_SP] = {0, 14},
/* TODO: PERF_REG_CSKY_ORIG_A0 */
[PERF_REG_CSKY_A0] = {2, 0},
[PERF_REG_CSKY_A1] = {3, 1},
[PERF_REG_CSKY_A2] = {4, 2},
[PERF_REG_CSKY_A3] = {5, 3},
[PERF_REG_CSKY_REGS0] = {6, 4},
[PERF_REG_CSKY_REGS1] = {7, 5},
[PERF_REG_CSKY_REGS2] = {8, 6},
[PERF_REG_CSKY_REGS3] = {9, 7},
Annotation
- Immediate include surface: `errno.h`, `stddef.h`, `dwarf-regs.h`, `../../../arch/csky/include/uapi/asm/perf_regs.h`.
- Detected declarations: `function __get_dwarf_regnum`, `function __get_csky_regnum`, `function __get_dwarf_regnum_for_perf_regnum_csky`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.