Resguardo inicial

This commit is contained in:
lastdragon
2026-09-06 12:53:21 -06:00
parent 662efe3c2a
commit ad2088d178
94853 changed files with 43200404 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
perf-util-y += util/
@@ -0,0 +1,2 @@
# SPDX-License-Identifier: GPL-2.0
PERF_HAVE_JITDUMP := 1
@@ -0,0 +1,43 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifdef DEFINE_DWARF_REGSTR_TABLE
/* This is included in perf/util/dwarf-regs.c */
#undef REG_DWARFNUM_NAME
#define REG_DWARFNUM_NAME(reg, idx) [idx] = reg
static const char * const riscv_regstr_tbl[] = {
REG_DWARFNUM_NAME("%zero", 0),
REG_DWARFNUM_NAME("%ra", 1),
REG_DWARFNUM_NAME("%sp", 2),
REG_DWARFNUM_NAME("%gp", 3),
REG_DWARFNUM_NAME("%tp", 4),
REG_DWARFNUM_NAME("%t0", 5),
REG_DWARFNUM_NAME("%t1", 6),
REG_DWARFNUM_NAME("%t2", 7),
REG_DWARFNUM_NAME("%s0", 8),
REG_DWARFNUM_NAME("%s1", 9),
REG_DWARFNUM_NAME("%a0", 10),
REG_DWARFNUM_NAME("%a1", 11),
REG_DWARFNUM_NAME("%a2", 12),
REG_DWARFNUM_NAME("%a3", 13),
REG_DWARFNUM_NAME("%a4", 14),
REG_DWARFNUM_NAME("%a5", 15),
REG_DWARFNUM_NAME("%a6", 16),
REG_DWARFNUM_NAME("%a7", 17),
REG_DWARFNUM_NAME("%s2", 18),
REG_DWARFNUM_NAME("%s3", 19),
REG_DWARFNUM_NAME("%s4", 20),
REG_DWARFNUM_NAME("%s5", 21),
REG_DWARFNUM_NAME("%s6", 22),
REG_DWARFNUM_NAME("%s7", 23),
REG_DWARFNUM_NAME("%s8", 24),
REG_DWARFNUM_NAME("%s9", 25),
REG_DWARFNUM_NAME("%s10", 26),
REG_DWARFNUM_NAME("%s11", 27),
REG_DWARFNUM_NAME("%t3", 28),
REG_DWARFNUM_NAME("%t4", 29),
REG_DWARFNUM_NAME("%t5", 30),
REG_DWARFNUM_NAME("%t6", 31),
};
#endif
@@ -0,0 +1,24 @@
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. */
#ifndef ARCH_PERF_REGS_H
#define ARCH_PERF_REGS_H
#include <stdlib.h>
#include <linux/types.h>
#include "../../../../arch/riscv/include/uapi/asm/perf_regs.h"
#define PERF_REGS_MASK ((1ULL << PERF_REG_RISCV_MAX) - 1)
#define PERF_REGS_MAX PERF_REG_RISCV_MAX
#if defined(__riscv_xlen)
#if __riscv_xlen == 64
#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_64
#else
#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32
#endif
#else
#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_NONE
#endif
#endif /* ARCH_PERF_REGS_H */
@@ -0,0 +1 @@
perf-util-y += header.o
@@ -0,0 +1,104 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Implementation of get_cpuid().
*
* Author: Nikita Shubin <n.shubin@yadro.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <api/fs/fs.h>
#include <errno.h>
#include "../../util/debug.h"
#include "../../util/header.h"
#define CPUINFO_MVEN "mvendorid"
#define CPUINFO_MARCH "marchid"
#define CPUINFO_MIMP "mimpid"
#define CPUINFO "/proc/cpuinfo"
static char *_get_field(const char *line)
{
const char *line2, *nl;
line2 = strrchr(line, ' ');
if (!line2)
return NULL;
line2++;
nl = strrchr(line, '\n');
if (!nl)
return NULL;
return strndup(line2, nl - line2);
}
static char *_get_cpuid(void)
{
char *line = NULL;
char *mvendorid = NULL;
char *marchid = NULL;
char *mimpid = NULL;
char *cpuid = NULL;
int read;
size_t line_sz;
FILE *cpuinfo;
cpuinfo = fopen(CPUINFO, "r");
if (cpuinfo == NULL)
return cpuid;
while ((read = getline(&line, &line_sz, cpuinfo)) != -1) {
if (!strncmp(line, CPUINFO_MVEN, strlen(CPUINFO_MVEN))) {
mvendorid = _get_field(line);
if (!mvendorid)
goto free;
} else if (!strncmp(line, CPUINFO_MARCH, strlen(CPUINFO_MARCH))) {
marchid = _get_field(line);
if (!marchid)
goto free;
} else if (!strncmp(line, CPUINFO_MIMP, strlen(CPUINFO_MIMP))) {
mimpid = _get_field(line);
if (!mimpid)
goto free;
break;
}
}
if (!mvendorid || !marchid || !mimpid)
goto free;
if (asprintf(&cpuid, "%s-%s-%s", mvendorid, marchid, mimpid) < 0)
cpuid = NULL;
free:
fclose(cpuinfo);
free(mvendorid);
free(marchid);
free(mimpid);
return cpuid;
}
int get_cpuid(char *buffer, size_t sz, struct perf_cpu cpu __maybe_unused)
{
char *cpuid = _get_cpuid();
int ret = 0;
if (sz < strlen(cpuid)) {
ret = -EINVAL;
goto free;
}
scnprintf(buffer, sz, "%s", cpuid);
free:
free(cpuid);
return ret;
}
char *
get_cpuid_str(struct perf_cpu cpu __maybe_unused)
{
return _get_cpuid();
}