19c0af131SPoul-Henning Kamp /*- 24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3d63027b6SPedro F. Giffuni * 49c0af131SPoul-Henning Kamp * Copyright (c) 2005 Poul-Henning Kamp. All rights reserved. 59c0af131SPoul-Henning Kamp * 69c0af131SPoul-Henning Kamp * Redistribution and use in source and binary forms, with or without 79c0af131SPoul-Henning Kamp * modification, are permitted provided that the following conditions 89c0af131SPoul-Henning Kamp * are met: 99c0af131SPoul-Henning Kamp * 1. Redistributions of source code must retain the above copyright 109c0af131SPoul-Henning Kamp * notice, this list of conditions and the following disclaimer. 119c0af131SPoul-Henning Kamp * 2. Neither the name of the University nor the names of its contributors 129c0af131SPoul-Henning Kamp * may be used to endorse or promote products derived from this software 139c0af131SPoul-Henning Kamp * without specific prior written permission. 149c0af131SPoul-Henning Kamp * 159c0af131SPoul-Henning Kamp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 169c0af131SPoul-Henning Kamp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 179c0af131SPoul-Henning Kamp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 189c0af131SPoul-Henning Kamp * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 199c0af131SPoul-Henning Kamp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 209c0af131SPoul-Henning Kamp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 219c0af131SPoul-Henning Kamp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 229c0af131SPoul-Henning Kamp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 239c0af131SPoul-Henning Kamp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 249c0af131SPoul-Henning Kamp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 259c0af131SPoul-Henning Kamp * SUCH DAMAGE. 269c0af131SPoul-Henning Kamp */ 279c0af131SPoul-Henning Kamp 289c0af131SPoul-Henning Kamp /* 299c0af131SPoul-Henning Kamp * This file documents a private interface and it SHALL only be used 309c0af131SPoul-Henning Kamp * by kern/kern_conf.c and fs/devfs/... 319c0af131SPoul-Henning Kamp */ 329c0af131SPoul-Henning Kamp 339c0af131SPoul-Henning Kamp #ifndef _FS_DEVFS_DEVFS_INT_H_ 349c0af131SPoul-Henning Kamp #define _FS_DEVFS_DEVFS_INT_H_ 359c0af131SPoul-Henning Kamp 369c0af131SPoul-Henning Kamp #include <sys/queue.h> 379c0af131SPoul-Henning Kamp 38e606a3c6SPoul-Henning Kamp struct devfs_dirent; 39d318c565SJaakko Heinonen struct devfs_mount; 40e606a3c6SPoul-Henning Kamp 4182f4d640SKonstantin Belousov struct cdev_privdata { 4282f4d640SKonstantin Belousov struct file *cdpd_fp; 4382f4d640SKonstantin Belousov void *cdpd_data; 4482f4d640SKonstantin Belousov void (*cdpd_dtr)(void *); 4582f4d640SKonstantin Belousov LIST_ENTRY(cdev_privdata) cdpd_list; 4682f4d640SKonstantin Belousov }; 4782f4d640SKonstantin Belousov 48e606a3c6SPoul-Henning Kamp struct cdev_priv { 49e606a3c6SPoul-Henning Kamp struct cdev cdp_c; 50e606a3c6SPoul-Henning Kamp TAILQ_ENTRY(cdev_priv) cdp_list; 51e606a3c6SPoul-Henning Kamp 52e606a3c6SPoul-Henning Kamp u_int cdp_inode; 53e606a3c6SPoul-Henning Kamp 54e606a3c6SPoul-Henning Kamp u_int cdp_flags; 55e606a3c6SPoul-Henning Kamp #define CDP_ACTIVE (1 << 0) 56de10ffa5SKonstantin Belousov #define CDP_SCHED_DTR (1 << 1) 573b50dff5SKonstantin Belousov #define CDP_UNREF_DTR (1 << 2) 58*67864268SJason A. Harmening #define CDP_ON_ACTIVE_LIST (1 << 3) 59e606a3c6SPoul-Henning Kamp 60e606a3c6SPoul-Henning Kamp u_int cdp_inuse; 61e606a3c6SPoul-Henning Kamp u_int cdp_maxdirent; 62e606a3c6SPoul-Henning Kamp struct devfs_dirent **cdp_dirents; 63e606a3c6SPoul-Henning Kamp struct devfs_dirent *cdp_dirent0; 64de10ffa5SKonstantin Belousov 65de10ffa5SKonstantin Belousov TAILQ_ENTRY(cdev_priv) cdp_dtr_list; 66de10ffa5SKonstantin Belousov void (*cdp_dtr_cb)(void *); 67de10ffa5SKonstantin Belousov void *cdp_dtr_cb_arg; 6882f4d640SKonstantin Belousov 6982f4d640SKonstantin Belousov LIST_HEAD(, cdev_privdata) cdp_fdpriv; 70a02cab33SMateusz Guzik 71a02cab33SMateusz Guzik struct mtx cdp_threadlock; 72e606a3c6SPoul-Henning Kamp }; 73e606a3c6SPoul-Henning Kamp 747cbef24eSEd Schouten #define cdev2priv(c) __containerof(c, struct cdev_priv, cdp_c) 7505427aafSKonstantin Belousov 76d485c77fSKonstantin Belousov #ifdef _KERNEL 77d485c77fSKonstantin Belousov 78d2ba618aSKonstantin Belousov struct cdev *devfs_alloc(int); 7947bcfb64SJaakko Heinonen int devfs_dev_exists(const char *); 80e606a3c6SPoul-Henning Kamp void devfs_free(struct cdev *); 8127877c99SJaakko Heinonen void devfs_create(struct cdev *); 8227877c99SJaakko Heinonen void devfs_destroy(struct cdev *); 8327877c99SJaakko Heinonen void devfs_destroy_cdevpriv(struct cdev_privdata *); 849c0af131SPoul-Henning Kamp 85d318c565SJaakko Heinonen int devfs_dir_find(const char *); 86d318c565SJaakko Heinonen void devfs_dir_ref_de(struct devfs_mount *, struct devfs_dirent *); 87d318c565SJaakko Heinonen void devfs_dir_unref_de(struct devfs_mount *, struct devfs_dirent *); 88d318c565SJaakko Heinonen int devfs_pathpath(const char *, const char *); 89d318c565SJaakko Heinonen 90e606a3c6SPoul-Henning Kamp extern struct unrhdr *devfs_inos; 91e606a3c6SPoul-Henning Kamp extern struct mtx devmtx; 92828d6d12SKonstantin Belousov extern struct mtx devfs_de_interlock; 9382f4d640SKonstantin Belousov extern struct mtx cdevpriv_mtx; 94828d6d12SKonstantin Belousov extern TAILQ_HEAD(cdev_priv_list, cdev_priv) cdevp_list; 95e606a3c6SPoul-Henning Kamp 960ac9e27bSConrad Meyer #define dev_lock_assert_locked() mtx_assert(&devmtx, MA_OWNED) 970ac9e27bSConrad Meyer #define dev_lock_assert_unlocked() mtx_assert(&devmtx, MA_NOTOWNED) 980ac9e27bSConrad Meyer 999c0af131SPoul-Henning Kamp #endif /* _KERNEL */ 1009c0af131SPoul-Henning Kamp 1019c0af131SPoul-Henning Kamp #endif /* !_FS_DEVFS_DEVFS_INT_H_ */ 102