/*
 * $Header: /smsa/bsd:include/sys/conf.h:bsd  1.16  $
 * $Source: /smsa/bsd:include/sys/conf.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 *
 */
/* @(#)conf.h	1.3 87/05/15 3.2/4.3NFSSRC */
/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 *
 *	@(#)conf.h	7.1 (Berkeley) 6/4/86
 */

#ifndef	__sys_conf_h
#define	__sys_conf_h


/*
 * Declaration of block device
 * switch. Each entry (row) is
 * the only link between the
 * main unix code and the driver.
 * The initialization of the
 * device switches is in the
 * file conf.c.
 */
struct bdevsw
{
	int	(*d_open)();
	int	(*d_close)();
	int	(*d_strategy)();
	int	(*d_dump)();
	int	(*d_psize)();
	int	d_flags;
	char	d_name[2+1];
	u_char	d_drive_shift;
};
#ifdef	_KERNEL
extern struct bdevsw bdevsw[];
extern const struct bdevsw no_bdev;	/* non-configured entry values */
extern int nblkdev;
#endif	_KERNEL

/*
 * Character device switch.
 */
struct cdevsw
{
	int	(*d_open)();
	int	(*d_close)();
	int	(*d_read)();
	int	(*d_write)();
	int	(*d_ioctl)();
	int	(*d_stop)();
	int	(*d_reset)();
	struct tty *d_ttys;
	int	(*d_select)();
	int	(*d_mmap)();
	int	(*d_sectorsize)();
};
#ifdef	_KERNEL
extern struct cdevsw cdevsw[];
extern const struct cdevsw no_cdev;	/* non-configured entry values */
extern int nchrdev;
#endif	_KERNEL

/*
 * The following declarations are dummies to ensure that structure tags "tty"
 * and "uio" are visible at the top level BEFORE the compiler sees these tags
 * in the function prototypes within the linesw structure.
 */
typedef struct tty *__tty__p;
typedef struct uio *__uio__p;

/*
 * tty line control switch.
 */
struct linesw
{
	int	(*l_open)(int, struct tty *, int);
	int	(*l_close)(struct tty *);
	int	(*l_read)(struct tty *, struct uio *);
	int	(*l_write)(struct tty *, struct uio *);
	int	(*l_ioctl)(struct tty *, int, caddr_t, int);
	int	(*l_rint)(int, struct tty *);
	int	(*l_rend)();
	int	(*l_meta)();
	int	(*l_start)(struct tty *);
	int	(*l_modem)(struct tty *, int);
};
#ifdef	_KERNEL
struct	linesw linesw[];
#endif	_KERNEL

/*
 * Structure used in reclamation of code/data space from drivers which are
 * not in use in a particular configuration.  The areas between code_base
 * and code_end, and data_base and data_end are released back to the
 * memory chunk manager.  If any pointer is NULL, no release will happen
 * for the associated segment; hence by having data_end NULL, a module
 * with no reclaimable data will not have problems.  Code_base should
 * therefore be the first declared function in the module and code_end the
 * last: normally code_end will be a trivial function which does nothing;
 * if a module has a large amount of data and no significant amount of
 * code, code_end could be NULL.  Code_base is overloaded in use and is
 * also called by the scavenging code before memory is released. It must
 * return non-zero to allow the driver code and data to be deleted: this
 * permits correct handling of drivers which support both xcb and internal
 * devices (e.g. ST506), for which the routine is called by the xcb
 * manager scavenge routine when there are no xcb cards for it to drive,
 * but must check whether there is an internal device to handle.  The
 * data_base pointer is also overloaded and should point at a static char
 * array (i.e.  char[], NOT a literal string or pointer thereto)
 * containing a suitable short name to be printed for diagnostic purposes.
 * Each of the open_chr and open_blk fields is either NULL or contains the
 * address of the open function for the module as used in the respective
 * character or block device switch table: when a driver is to be
 * scavenged, any entry in those tables whose open function matches the
 * given address will be overwritten by a suitable entry for a
 * non-configured device.  The "next" field allows for multiple modules to
 * be scavenged without requiring multiple entries in the global
 * structures.  If the field is not NULL, the pointer will be followed,
 * and any code and/or data described by subsequent records will be
 * reclaimed unconditionally (i.e. no call on (*code_base), no use of
 * data_base as a string, etc), and any device entries will be deleted:
 * the (rare) situation of having multiple variant open routines in the
 * device switches can be handled using this next-field chain, even for
 * just one module.
 */
struct scavenge
{
    int (*code_base)(), (*code_end)();
    char *data_base, *data_end;
    int (*open_chr)(), (*open_blk)();
    struct scavenge *next;	/* for multi-module drivers */
};
    

#endif/*__sys_conf_h*/

/* EOF conf.h */
