Example #1
0
static int __init debugfs_fpuemu(void)
{
	struct dentry *d, *dir;

	if (!mips_debugfs_dir)
		return -ENODEV;
	dir = debugfs_create_dir("fpuemustats", mips_debugfs_dir);
	if (!dir)
		return -ENOMEM;

#define FPU_EMU_STAT_OFFSET(m)						\
	offsetof(struct mips_fpu_emulator_stats, m)

#define FPU_STAT_CREATE(m)						\
do {									\
	d = debugfs_create_file(#m , S_IRUGO, dir,			\
				(void *)FPU_EMU_STAT_OFFSET(m),		\
				&fops_fpuemu_stat);			\
	if (!d)								\
		return -ENOMEM;						\
} while (0)

	FPU_STAT_CREATE(emulated);
	FPU_STAT_CREATE(loads);
	FPU_STAT_CREATE(stores);
	FPU_STAT_CREATE(cp1ops);
	FPU_STAT_CREATE(cp1xops);
	FPU_STAT_CREATE(errors);
	FPU_STAT_CREATE(ieee754_inexact);
	FPU_STAT_CREATE(ieee754_underflow);
	FPU_STAT_CREATE(ieee754_overflow);
	FPU_STAT_CREATE(ieee754_zerodiv);
	FPU_STAT_CREATE(ieee754_invalidop);
	FPU_STAT_CREATE(ds_emul);

	return 0;
}
static int __init debugfs_fpuemu(void)
{
	struct dentry *fpuemu_debugfs_base_dir;
	struct dentry *fpuemu_debugfs_inst_dir;

	fpuemu_debugfs_base_dir = debugfs_create_dir("fpuemustats",
						     mips_debugfs_dir);

	debugfs_create_file("fpuemustats_clear", 0444, mips_debugfs_dir, NULL,
			    &fpuemustats_clear_fops);

#define FPU_EMU_STAT_OFFSET(m)						\
	offsetof(struct mips_fpu_emulator_stats, m)

#define FPU_STAT_CREATE(m)						\
do {									\
	debugfs_create_file(#m, 0444, fpuemu_debugfs_base_dir,		\
				(void *)FPU_EMU_STAT_OFFSET(m),		\
				&fops_fpuemu_stat);			\
} while (0)

	FPU_STAT_CREATE(emulated);
	FPU_STAT_CREATE(loads);
	FPU_STAT_CREATE(stores);
	FPU_STAT_CREATE(branches);
	FPU_STAT_CREATE(cp1ops);
	FPU_STAT_CREATE(cp1xops);
	FPU_STAT_CREATE(errors);
	FPU_STAT_CREATE(ieee754_inexact);
	FPU_STAT_CREATE(ieee754_underflow);
	FPU_STAT_CREATE(ieee754_overflow);
	FPU_STAT_CREATE(ieee754_zerodiv);
	FPU_STAT_CREATE(ieee754_invalidop);
	FPU_STAT_CREATE(ds_emul);

	fpuemu_debugfs_inst_dir = debugfs_create_dir("instructions",
						     fpuemu_debugfs_base_dir);

#define FPU_STAT_CREATE_EX(m)						\
do {									\
	char name[32];							\
									\
	adjust_instruction_counter_name(name, #m);			\
									\
	debugfs_create_file(name, 0444, fpuemu_debugfs_inst_dir,	\
				(void *)FPU_EMU_STAT_OFFSET(m),		\
				&fops_fpuemu_stat);			\
} while (0)

	FPU_STAT_CREATE_EX(abs_s);
	FPU_STAT_CREATE_EX(abs_d);
	FPU_STAT_CREATE_EX(add_s);
	FPU_STAT_CREATE_EX(add_d);
	FPU_STAT_CREATE_EX(bc1eqz);
	FPU_STAT_CREATE_EX(bc1nez);
	FPU_STAT_CREATE_EX(ceil_w_s);
	FPU_STAT_CREATE_EX(ceil_w_d);
	FPU_STAT_CREATE_EX(ceil_l_s);
	FPU_STAT_CREATE_EX(ceil_l_d);
	FPU_STAT_CREATE_EX(class_s);
	FPU_STAT_CREATE_EX(class_d);
	FPU_STAT_CREATE_EX(cmp_af_s);
	FPU_STAT_CREATE_EX(cmp_af_d);
	FPU_STAT_CREATE_EX(cmp_eq_s);
	FPU_STAT_CREATE_EX(cmp_eq_d);
	FPU_STAT_CREATE_EX(cmp_le_s);
	FPU_STAT_CREATE_EX(cmp_le_d);
	FPU_STAT_CREATE_EX(cmp_lt_s);
	FPU_STAT_CREATE_EX(cmp_lt_d);
	FPU_STAT_CREATE_EX(cmp_ne_s);
	FPU_STAT_CREATE_EX(cmp_ne_d);
	FPU_STAT_CREATE_EX(cmp_or_s);
	FPU_STAT_CREATE_EX(cmp_or_d);
	FPU_STAT_CREATE_EX(cmp_ueq_s);
	FPU_STAT_CREATE_EX(cmp_ueq_d);
	FPU_STAT_CREATE_EX(cmp_ule_s);
	FPU_STAT_CREATE_EX(cmp_ule_d);
	FPU_STAT_CREATE_EX(cmp_ult_s);
	FPU_STAT_CREATE_EX(cmp_ult_d);
	FPU_STAT_CREATE_EX(cmp_un_s);
	FPU_STAT_CREATE_EX(cmp_un_d);
	FPU_STAT_CREATE_EX(cmp_une_s);
	FPU_STAT_CREATE_EX(cmp_une_d);
	FPU_STAT_CREATE_EX(cmp_saf_s);
	FPU_STAT_CREATE_EX(cmp_saf_d);
	FPU_STAT_CREATE_EX(cmp_seq_s);
	FPU_STAT_CREATE_EX(cmp_seq_d);
	FPU_STAT_CREATE_EX(cmp_sle_s);
	FPU_STAT_CREATE_EX(cmp_sle_d);
	FPU_STAT_CREATE_EX(cmp_slt_s);
	FPU_STAT_CREATE_EX(cmp_slt_d);
	FPU_STAT_CREATE_EX(cmp_sne_s);
	FPU_STAT_CREATE_EX(cmp_sne_d);
	FPU_STAT_CREATE_EX(cmp_sor_s);
	FPU_STAT_CREATE_EX(cmp_sor_d);
	FPU_STAT_CREATE_EX(cmp_sueq_s);
	FPU_STAT_CREATE_EX(cmp_sueq_d);
	FPU_STAT_CREATE_EX(cmp_sule_s);
	FPU_STAT_CREATE_EX(cmp_sule_d);
	FPU_STAT_CREATE_EX(cmp_sult_s);
	FPU_STAT_CREATE_EX(cmp_sult_d);
	FPU_STAT_CREATE_EX(cmp_sun_s);
	FPU_STAT_CREATE_EX(cmp_sun_d);
	FPU_STAT_CREATE_EX(cmp_sune_s);
	FPU_STAT_CREATE_EX(cmp_sune_d);
	FPU_STAT_CREATE_EX(cvt_d_l);
	FPU_STAT_CREATE_EX(cvt_d_s);
	FPU_STAT_CREATE_EX(cvt_d_w);
	FPU_STAT_CREATE_EX(cvt_l_s);
	FPU_STAT_CREATE_EX(cvt_l_d);
	FPU_STAT_CREATE_EX(cvt_s_d);
	FPU_STAT_CREATE_EX(cvt_s_l);
	FPU_STAT_CREATE_EX(cvt_s_w);
	FPU_STAT_CREATE_EX(cvt_w_s);
	FPU_STAT_CREATE_EX(cvt_w_d);
	FPU_STAT_CREATE_EX(div_s);
	FPU_STAT_CREATE_EX(div_d);
	FPU_STAT_CREATE_EX(floor_w_s);
	FPU_STAT_CREATE_EX(floor_w_d);
	FPU_STAT_CREATE_EX(floor_l_s);
	FPU_STAT_CREATE_EX(floor_l_d);
	FPU_STAT_CREATE_EX(maddf_s);
	FPU_STAT_CREATE_EX(maddf_d);
	FPU_STAT_CREATE_EX(max_s);
	FPU_STAT_CREATE_EX(max_d);
	FPU_STAT_CREATE_EX(maxa_s);
	FPU_STAT_CREATE_EX(maxa_d);
	FPU_STAT_CREATE_EX(min_s);
	FPU_STAT_CREATE_EX(min_d);
	FPU_STAT_CREATE_EX(mina_s);
	FPU_STAT_CREATE_EX(mina_d);
	FPU_STAT_CREATE_EX(mov_s);
	FPU_STAT_CREATE_EX(mov_d);
	FPU_STAT_CREATE_EX(msubf_s);
	FPU_STAT_CREATE_EX(msubf_d);
	FPU_STAT_CREATE_EX(mul_s);
	FPU_STAT_CREATE_EX(mul_d);
	FPU_STAT_CREATE_EX(neg_s);
	FPU_STAT_CREATE_EX(neg_d);
	FPU_STAT_CREATE_EX(recip_s);
	FPU_STAT_CREATE_EX(recip_d);
	FPU_STAT_CREATE_EX(rint_s);
	FPU_STAT_CREATE_EX(rint_d);
	FPU_STAT_CREATE_EX(round_w_s);
	FPU_STAT_CREATE_EX(round_w_d);
	FPU_STAT_CREATE_EX(round_l_s);
	FPU_STAT_CREATE_EX(round_l_d);
	FPU_STAT_CREATE_EX(rsqrt_s);
	FPU_STAT_CREATE_EX(rsqrt_d);
	FPU_STAT_CREATE_EX(sel_s);
	FPU_STAT_CREATE_EX(sel_d);
	FPU_STAT_CREATE_EX(seleqz_s);
	FPU_STAT_CREATE_EX(seleqz_d);
	FPU_STAT_CREATE_EX(selnez_s);
	FPU_STAT_CREATE_EX(selnez_d);
	FPU_STAT_CREATE_EX(sqrt_s);
	FPU_STAT_CREATE_EX(sqrt_d);
	FPU_STAT_CREATE_EX(sub_s);
	FPU_STAT_CREATE_EX(sub_d);
	FPU_STAT_CREATE_EX(trunc_w_s);
	FPU_STAT_CREATE_EX(trunc_w_d);
	FPU_STAT_CREATE_EX(trunc_l_s);
	FPU_STAT_CREATE_EX(trunc_l_d);

	return 0;
}