--- src/sys/sys/conf.h 2006/02/17 19:18:07 1.10 +++ src/sys/sys/conf.h 2006/07/28 02:17:41 1.11 @@ -52,7 +52,7 @@ struct tty; struct disk; struct vnode; -struct lwkt_port; +struct dev_ops; struct specinfo { u_int si_flags; @@ -62,8 +62,7 @@ struct specinfo { char si_name[SPECNAMELEN + 1]; void *si_drv1; void *si_drv2; - struct cdevsw *si_devsw; /* direct device switch */ - struct lwkt_port *si_port; /* direct port dispatch */ + struct dev_ops *si_ops; /* device operations vector */ int si_iosize_max; /* maximum I/O size (for physio &al) */ int si_refs; union { @@ -110,115 +109,21 @@ struct bio; struct proc; struct uio; struct knote; - -/* - * Note: d_thread_t is provided as a transition aid for those drivers - * that treat struct proc/struct thread as an opaque data type and - * exist in substantially the same form in both 4.x and 5.x. Writers - * of drivers that dips into the d_thread_t structure should use - * struct thread or struct proc as appropriate for the version of the - * OS they are using. It is provided in lieu of each device driver - * inventing its own way of doing this. While it does violate style(9) - * in a number of ways, this violation is deemed to be less - * important than the benefits that a uniform API between releases - * gives. - * - * Users of struct thread/struct proc that aren't device drivers should - * not use d_thread_t. - */ +struct ucred; struct thread; -struct lwkt_port; - -typedef struct thread d_thread_t; -typedef int d_clone_t (dev_t dev); -typedef int d_open_t (dev_t dev, int oflags, int devtype, d_thread_t *td); -typedef int d_close_t (dev_t dev, int fflag, int devtype, d_thread_t *td); -typedef void d_strategy_t (dev_t dev, struct bio *bio); -typedef int d_ioctl_t (dev_t dev, u_long cmd, caddr_t data, - int fflag, d_thread_t *td); -typedef int d_dump_t (dev_t dev, u_int count, u_int blkno, u_int secsize); -typedef int d_psize_t (dev_t dev); - -typedef int d_read_t (dev_t dev, struct uio *uio, int ioflag); -typedef int d_write_t (dev_t dev, struct uio *uio, int ioflag); -typedef int d_poll_t (dev_t dev, int events, d_thread_t *td); -typedef int d_kqfilter_t (dev_t dev, struct knote *kn); -typedef int d_mmap_t (dev_t dev, vm_offset_t offset, int nprot); typedef int l_open_t (dev_t dev, struct tty *tp); typedef int l_close_t (struct tty *tp, int flag); typedef int l_read_t (struct tty *tp, struct uio *uio, int flag); typedef int l_write_t (struct tty *tp, struct uio *uio, int flag); -typedef int l_ioctl_t (struct tty *tp, u_long cmd, caddr_t data, - int flag, d_thread_t *td); +typedef int l_ioctl_t (struct tty *tp, u_long cmd, caddr_t data, int flag, + struct ucred *cred); typedef int l_rint_t (int c, struct tty *tp); typedef int l_start_t (struct tty *tp); typedef int l_modem_t (struct tty *tp, int flag); /* - * Types for d_flags. - */ -#define D_TAPE 0x0001 -#define D_DISK 0x0002 -#define D_TTY 0x0004 -#define D_MEM 0x0008 - -#define D_TYPEMASK 0xffff - -/* - * Flags for d_flags. - */ -#define D_MEMDISK 0x00010000 /* memory type disk */ -#define D_NAGGED 0x00020000 /* nagged about missing make_dev() */ -#define D_CANFREE 0x00040000 /* can free blocks */ -#define D_TRACKCLOSE 0x00080000 /* track all closes */ -#define D_MASTER 0x00100000 /* used by pty/tty code */ -#define D_KQFILTER 0x00200000 /* has kqfilter entry */ - -/* - * Character device switch table. - * - * NOTE: positions are hard coded for static structure initialization. - */ -struct cdevsw { - const char *d_name; /* base device name, e.g. 'vn' */ - int d_maj; /* major (char) device number */ - u_int d_flags; /* D_ flags */ - struct lwkt_port *d_port; /* port (template only) */ - d_clone_t *d_clone; /* clone from base cdevsw */ - - /* - * Old style vectors are used only if d_port is NULL when the cdevsw - * is added to the system. They have been renamed to prevent misuse. - */ - d_open_t *old_open; - d_close_t *old_close; - d_read_t *old_read; - d_write_t *old_write; - d_ioctl_t *old_ioctl; - d_poll_t *old_poll; - d_mmap_t *old_mmap; - d_strategy_t *old_strategy; - d_dump_t *old_dump; - d_psize_t *old_psize; - d_kqfilter_t *old_kqfilter; - void (*old_dummy1)(void); /* expansion space */ - void (*old_dummy2)(void); - void (*old_dummy3)(void); - void (*old_dummy4)(void); - int d_refs; /* ref count */ - void *d_data; /* custom driver data */ -}; - -struct cdevlink { - struct cdevlink *next; - u_int mask; - u_int match; - struct cdevsw *devsw; -}; - -/* * Line discipline switch table */ struct linesw { @@ -257,24 +162,9 @@ struct swdevt { #define sw_freed sw_flags /* XXX compat */ #ifdef _KERNEL -d_open_t noopen; -d_close_t noclose; -d_read_t noread; -d_write_t nowrite; -d_ioctl_t noioctl; -d_clone_t noclone; -d_mmap_t nommap; -d_kqfilter_t nokqfilter; -d_strategy_t nostrategy; -d_poll_t nopoll; -d_psize_t nopsize; -d_dump_t nodump; #define NUMCDEVSW 256 -d_open_t nullopen; -d_close_t nullclose; - l_ioctl_t l_nullioctl; l_read_t l_noread; l_write_t l_nowrite; @@ -295,28 +185,16 @@ static moduledata_t name##_mod = { \ }; \ DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE) -extern struct cdevsw dead_cdevsw; - -void compile_devsw(struct cdevsw *); -int cdevsw_add (struct cdevsw *, u_int mask, u_int match); -struct cdevsw *cdevsw_add_override (dev_t, u_int mask, u_int match); -struct lwkt_port *cdevsw_dev_override(dev_t dev, struct lwkt_port *port); - -int cdevsw_remove (struct cdevsw *, u_int mask, u_int match); -struct cdevsw *cdevsw_get (int x, int y); -void cdevsw_release (struct cdevsw *); int count_dev (dev_t dev); int count_udev (udev_t dev); void destroy_dev (dev_t dev); -void destroy_all_dev (struct cdevsw *, u_int mask, u_int match); void release_dev (dev_t dev); dev_t reference_dev (dev_t dev); -struct cdevsw *devsw (dev_t dev); +struct dev_ops *devsw (dev_t dev); const char *devtoname (dev_t dev); void freedev (dev_t dev); int iszerodev (dev_t dev); -dev_t make_dev (struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, const char *fmt, ...) __printflike(6, 7); -dev_t make_adhoc_dev (struct cdevsw *devsw, int minor); + dev_t make_sub_dev (dev_t dev, int minor); int lminor (dev_t dev); void setconf (void);