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> 34f697b943SJake Freeland #include <linux/module.h> 353f6cab07SMatt Macy #include <linux/seq_file.h> 363f6cab07SMatt Macy #include <linux/types.h> 373f6cab07SMatt Macy 38f697b943SJake Freeland MALLOC_DECLARE(M_DFSINT); 39f697b943SJake Freeland 40f697b943SJake Freeland struct debugfs_reg32 { 41f697b943SJake Freeland char *name; 42f697b943SJake Freeland unsigned long offset; 43f697b943SJake Freeland }; 44f697b943SJake Freeland 45f697b943SJake Freeland struct debugfs_regset32 { 46f697b943SJake Freeland const struct debugfs_reg32 *regs; 47f697b943SJake Freeland int nregs; 48f697b943SJake Freeland }; 493f6cab07SMatt Macy 500fce2dc1SBjoern A. Zeeb struct debugfs_blob_wrapper { 510fce2dc1SBjoern A. Zeeb void *data; 520fce2dc1SBjoern A. Zeeb size_t size; 530fce2dc1SBjoern A. Zeeb }; 540fce2dc1SBjoern A. Zeeb 553f6cab07SMatt Macy struct dentry *debugfs_create_file(const char *name, umode_t mode, 563f6cab07SMatt Macy struct dentry *parent, void *data, 573f6cab07SMatt Macy const struct file_operations *fops); 583f6cab07SMatt Macy 59f697b943SJake Freeland struct dentry *debugfs_create_file_unsafe(const char *name, umode_t mode, 60f697b943SJake Freeland struct dentry *parent, void *data, 61f697b943SJake Freeland const struct file_operations *fops); 62f697b943SJake Freeland 63f697b943SJake Freeland struct dentry *debugfs_create_mode_unsafe(const char *name, umode_t mode, 64f697b943SJake Freeland struct dentry *parent, void *data, 65f697b943SJake Freeland const struct file_operations *fops, 66f697b943SJake Freeland const struct file_operations *fops_ro, 67f697b943SJake Freeland const struct file_operations *fops_wo); 68f697b943SJake Freeland 693f6cab07SMatt Macy struct dentry *debugfs_create_dir(const char *name, struct dentry *parent); 703f6cab07SMatt Macy 713f6cab07SMatt Macy struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, 723f6cab07SMatt Macy const char *dest); 733f6cab07SMatt Macy 74f697b943SJake Freeland void debugfs_remove(struct dentry *dentry); 75f697b943SJake Freeland 763f6cab07SMatt Macy void debugfs_remove_recursive(struct dentry *dentry); 773f6cab07SMatt Macy 78f697b943SJake Freeland #define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \ 79f697b943SJake Freeland DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt) 80f697b943SJake Freeland 81f697b943SJake Freeland void debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent, 82f697b943SJake Freeland bool *value); 830fce2dc1SBjoern A. Zeeb void debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent, 840fce2dc1SBjoern A. Zeeb uint8_t *value); 85*976aa07aSJean-Sébastien Pédron void debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent, 86*976aa07aSJean-Sébastien Pédron uint16_t *value); 87*976aa07aSJean-Sébastien Pédron void debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent, 88*976aa07aSJean-Sébastien Pédron uint32_t *value); 89*976aa07aSJean-Sébastien Pédron void debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent, 90*976aa07aSJean-Sébastien Pédron uint64_t *value); 91*976aa07aSJean-Sébastien Pédron void debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, 92*976aa07aSJean-Sébastien Pédron uint8_t *value); 93*976aa07aSJean-Sébastien Pédron void debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, 94*976aa07aSJean-Sébastien Pédron uint16_t *value); 95*976aa07aSJean-Sébastien Pédron void debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent, 96*976aa07aSJean-Sébastien Pédron uint32_t *value); 97*976aa07aSJean-Sébastien Pédron void debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent, 98*976aa07aSJean-Sébastien Pédron uint64_t *value); 99f697b943SJake Freeland void debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent, 100f697b943SJake Freeland unsigned long *value); 101f2044a30SJean-Sébastien Pédron void debugfs_create_atomic_t(const char *name, umode_t mode, struct dentry *parent, 102f2044a30SJean-Sébastien Pédron atomic_t *value); 103f697b943SJake Freeland 1040fce2dc1SBjoern A. Zeeb struct dentry *debugfs_create_blob(const char *name, umode_t mode, 1050fce2dc1SBjoern A. Zeeb struct dentry *parent, struct debugfs_blob_wrapper *value); 1060fce2dc1SBjoern A. Zeeb 107f697b943SJake Freeland #endif /* _LINUXKPI_LINUX_DEBUGFS_H_ */ 108