18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: LGPL-2.1
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * trace/beauty/x86_msr.c
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (C) 2019, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include "trace/beauty/beauty.h"
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include "trace/beauty/generated/x86_arch_MSRs_array.c"
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cistatic DEFINE_STRARRAY(x86_MSRs, "MSR_");
138c2ecf20Sopenharmony_cistatic DEFINE_STRARRAY_OFFSET(x86_64_specific_MSRs, "MSR_", x86_64_specific_MSRs_offset);
148c2ecf20Sopenharmony_cistatic DEFINE_STRARRAY_OFFSET(x86_AMD_V_KVM_MSRs, "MSR_", x86_AMD_V_KVM_MSRs_offset);
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_cistatic struct strarray *x86_MSRs_tables[] = {
178c2ecf20Sopenharmony_ci	&strarray__x86_MSRs,
188c2ecf20Sopenharmony_ci	&strarray__x86_64_specific_MSRs,
198c2ecf20Sopenharmony_ci	&strarray__x86_AMD_V_KVM_MSRs,
208c2ecf20Sopenharmony_ci};
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cistatic DEFINE_STRARRAYS(x86_MSRs_tables);
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistatic size_t x86_MSR__scnprintf(unsigned long msr, char *bf, size_t size, bool show_prefix)
258c2ecf20Sopenharmony_ci{
268c2ecf20Sopenharmony_ci	return strarrays__scnprintf(&strarrays__x86_MSRs_tables, bf, size, "%#x", show_prefix, msr);
278c2ecf20Sopenharmony_ci}
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cisize_t syscall_arg__scnprintf_x86_MSR(char *bf, size_t size, struct syscall_arg *arg)
308c2ecf20Sopenharmony_ci{
318c2ecf20Sopenharmony_ci	unsigned long flags = arg->val;
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci	return x86_MSR__scnprintf(flags, bf, size, arg->show_string_prefix);
348c2ecf20Sopenharmony_ci}
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cibool syscall_arg__strtoul_x86_MSR(char *bf, size_t size, struct syscall_arg *arg __maybe_unused, u64 *ret)
378c2ecf20Sopenharmony_ci{
388c2ecf20Sopenharmony_ci	return strarrays__strtoul(&strarrays__x86_MSRs_tables, bf, size, ret);
398c2ecf20Sopenharmony_ci}
40