xref: /freebsd/sys/compat/linuxkpi/common/include/linux/debugfs.h (revision f697b9432d9c7aa4c5ab5f5445ef5dc1bd40ce00)
13f6cab07SMatt Macy /*-
23f6cab07SMatt Macy  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
33f6cab07SMatt Macy  *
43f6cab07SMatt Macy  * Copyright (c) 2016-2018, Matthew Macy <mmacy@freebsd.org>
53f6cab07SMatt Macy  *
63f6cab07SMatt Macy  * Redistribution and use in source and binary forms, with or without
73f6cab07SMatt Macy  * modification, are permitted provided that the following conditions
83f6cab07SMatt Macy  * are met:
93f6cab07SMatt Macy  * 1. Redistributions of source code must retain the above copyright
103f6cab07SMatt Macy  *    notice, this list of conditions and the following disclaimer.
113f6cab07SMatt Macy  * 2. Redistributions in binary form must reproduce the above copyright
123f6cab07SMatt Macy  *    notice, this list of conditions and the following disclaimer in the
133f6cab07SMatt Macy  *    documentation and/or other materials provided with the distribution.
143f6cab07SMatt Macy  *
153f6cab07SMatt Macy  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
163f6cab07SMatt Macy  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
173f6cab07SMatt Macy  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
183f6cab07SMatt Macy  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
193f6cab07SMatt Macy  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
203f6cab07SMatt Macy  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
213f6cab07SMatt Macy  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
223f6cab07SMatt Macy  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
233f6cab07SMatt Macy  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
243f6cab07SMatt Macy  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
253f6cab07SMatt Macy  * SUCH DAMAGE.
263f6cab07SMatt Macy  *
273f6cab07SMatt Macy  * $FreeBSD$
283f6cab07SMatt Macy  */
293f6cab07SMatt Macy 
30307f78f3SVladimir Kondratyev #ifndef _LINUXKPI_LINUX_DEBUGFS_H_
31307f78f3SVladimir Kondratyev #define _LINUXKPI_LINUX_DEBUGFS_H_
323f6cab07SMatt Macy 
333f6cab07SMatt Macy #include <linux/fs.h>
34*f697b943SJake Freeland #include <linux/module.h>
353f6cab07SMatt Macy #include <linux/seq_file.h>
363f6cab07SMatt Macy #include <linux/types.h>
373f6cab07SMatt Macy 
38*f697b943SJake Freeland MALLOC_DECLARE(M_DFSINT);
39*f697b943SJake Freeland 
40*f697b943SJake Freeland struct debugfs_reg32 {
41*f697b943SJake Freeland 	char *name;
42*f697b943SJake Freeland 	unsigned long offset;
43*f697b943SJake Freeland };
44*f697b943SJake Freeland 
45*f697b943SJake Freeland struct debugfs_regset32 {
46*f697b943SJake Freeland 	const struct debugfs_reg32 *regs;
47*f697b943SJake Freeland 	int nregs;
48*f697b943SJake Freeland };
493f6cab07SMatt Macy 
503f6cab07SMatt Macy struct dentry *debugfs_create_file(const char *name, umode_t mode,
513f6cab07SMatt Macy     struct dentry *parent, void *data,
523f6cab07SMatt Macy     const struct file_operations *fops);
533f6cab07SMatt Macy 
54*f697b943SJake Freeland struct dentry *debugfs_create_file_unsafe(const char *name, umode_t mode,
55*f697b943SJake Freeland     struct dentry *parent, void *data,
56*f697b943SJake Freeland     const struct file_operations *fops);
57*f697b943SJake Freeland 
58*f697b943SJake Freeland struct dentry *debugfs_create_mode_unsafe(const char *name, umode_t mode,
59*f697b943SJake Freeland     struct dentry *parent, void *data,
60*f697b943SJake Freeland     const struct file_operations *fops,
61*f697b943SJake Freeland     const struct file_operations *fops_ro,
62*f697b943SJake Freeland     const struct file_operations *fops_wo);
63*f697b943SJake Freeland 
643f6cab07SMatt Macy struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
653f6cab07SMatt Macy 
663f6cab07SMatt Macy struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
673f6cab07SMatt Macy     const char *dest);
683f6cab07SMatt Macy 
69*f697b943SJake Freeland void debugfs_remove(struct dentry *dentry);
70*f697b943SJake Freeland 
713f6cab07SMatt Macy void debugfs_remove_recursive(struct dentry *dentry);
723f6cab07SMatt Macy 
73*f697b943SJake Freeland #define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \
74*f697b943SJake Freeland 	DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt)
75*f697b943SJake Freeland 
76*f697b943SJake Freeland void debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent,
77*f697b943SJake Freeland     bool *value);
78*f697b943SJake Freeland 
79*f697b943SJake Freeland void debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent,
80*f697b943SJake Freeland     unsigned long *value);
81*f697b943SJake Freeland 
82*f697b943SJake Freeland #endif /* _LINUXKPI_LINUX_DEBUGFS_H_ */
83