Path: blob/main/sys/compat/linuxkpi/common/include/linux/debugfs.h
39604 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2016-2018, Matthew Macy <[email protected]>4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND15* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE18* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24* SUCH DAMAGE.25*/2627#ifndef _LINUXKPI_LINUX_DEBUGFS_H_28#define _LINUXKPI_LINUX_DEBUGFS_H_2930#include <linux/fs.h>31#include <linux/module.h>32#include <linux/seq_file.h>33#include <linux/types.h>3435MALLOC_DECLARE(M_DFSINT);3637struct debugfs_reg32 {38char *name;39unsigned long offset;40};4142struct debugfs_regset32 {43const struct debugfs_reg32 *regs;44int nregs;45};4647struct debugfs_blob_wrapper {48void *data;49size_t size;50};5152static inline bool53debugfs_initialized(void)54{5556return (true);57}5859struct dentry *debugfs_create_file(const char *name, umode_t mode,60struct dentry *parent, void *data,61const struct file_operations *fops);6263/* TODO: We currently ignore the `file_size` argument. */64struct dentry *debugfs_create_file_size(const char *name, umode_t mode,65struct dentry *parent, void *data,66const struct file_operations *fops,67loff_t file_size);6869struct dentry *debugfs_create_file_unsafe(const char *name, umode_t mode,70struct dentry *parent, void *data,71const struct file_operations *fops);7273struct dentry *debugfs_create_mode_unsafe(const char *name, umode_t mode,74struct dentry *parent, void *data,75const struct file_operations *fops,76const struct file_operations *fops_ro,77const struct file_operations *fops_wo);7879struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);8081struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,82const char *dest);8384struct dentry *debugfs_lookup(const char *name, struct dentry *parent);8586void debugfs_remove(struct dentry *dentry);8788void debugfs_remove_recursive(struct dentry *dentry);8990#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \91DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt)92#define DEFINE_DEBUGFS_ATTRIBUTE_SIGNED(__fops, __get, __set, __fmt) \93DEFINE_SIMPLE_ATTRIBUTE_SIGNED(__fops, __get, __set, __fmt)9495void debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent,96bool *value);97void debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent,98uint8_t *value);99void debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent,100uint16_t *value);101void debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent,102uint32_t *value);103void debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent,104uint64_t *value);105void debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent,106uint8_t *value);107void debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent,108uint16_t *value);109void debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent,110uint32_t *value);111void debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent,112uint64_t *value);113void debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent,114unsigned long *value);115void debugfs_create_atomic_t(const char *name, umode_t mode, struct dentry *parent,116atomic_t *value);117void debugfs_create_str(const char *name, umode_t mode, struct dentry *parent,118char **value);119120struct dentry *debugfs_create_blob(const char *name, umode_t mode,121struct dentry *parent, struct debugfs_blob_wrapper *value);122123#endif /* _LINUXKPI_LINUX_DEBUGFS_H_ */124125126