serdev_if.m revision 157299
1249268Sglebius#-
2249268Sglebius# Copyright (c) 2006 Marcel Moolenaar
3249268Sglebius# All rights reserved.
4249268Sglebius#
5249268Sglebius# Redistribution and use in source and binary forms, with or without
6249268Sglebius# modification, are permitted provided that the following conditions
7249268Sglebius# are met:
8249268Sglebius# 1. Redistributions of source code must retain the above copyright
9249268Sglebius#    notice, this list of conditions and the following disclaimer.
10249268Sglebius# 2. Redistributions in binary form must reproduce the above copyright
11249268Sglebius#    notice, this list of conditions and the following disclaimer in the
12249268Sglebius#    documentation and/or other materials provided with the distribution.
13249268Sglebius#
14249268Sglebius# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15249268Sglebius# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16249268Sglebius# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17249268Sglebius# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18249268Sglebius# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19249268Sglebius# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20249268Sglebius# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21249268Sglebius# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22249268Sglebius# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23249268Sglebius# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24249268Sglebius# SUCH DAMAGE.
25249268Sglebius#
26249268Sglebius# $FreeBSD: head/sys/kern/serdev_if.m 157299 2006-03-30 18:33:22Z marcel $
27249268Sglebius#
28249268Sglebius
29249268Sglebius#include <sys/bus.h>
30249268Sglebius#include <sys/serial.h>
31249268Sglebius
32249268Sglebius# The serdev interface is used by umbrella drivers and children thereof to
33249268Sglebius# establish a more intimate relationship, necessary for efficient handling
34249268Sglebius# of multiple (concurrent) serial communication channels.  Examples include
35249268Sglebius# serial communications controller (SCC) drivers, multi-I/O adapter drivers
36249268Sglebius# and intelligent multi-port serial drivers.  Methods specifically deal
37249268Sglebius# with interrupt handling and configuration.  Conceptually, the umbrella
38249268Sglebius# driver is responsible for the overall operation of the hardware and uses
39249268Sglebius# child drivers to handle each individual channel.
40252434Skib# The serdev interface is intended to inherit the device interface.
41252434Skib
42252434SkibINTERFACE serdev;
43252434Skib
44252434Skib# Default implementations of some methods.
45252434SkibCODE {
46252434Skib	static serdev_intr_t *
47252434Skib	default_ihand(device_t dev, int ipend)
48252434Skib	{
49252434Skib		return (NULL);
50252434Skib	}
51252434Skib
52252434Skib	static int
53252434Skib	default_sysdev(device_t dev)
54252434Skib	{
55252434Skib		return (0);
56252434Skib	}
57252434Skib};
58252434Skib
59252434Skib# ihand() - Query serial device interrupt handler.
60252434Skib# This method is called by the umbrella driver to obtain function pointers
61252434Skib# to interrupt handlers for each individual interrupt source. This allows
62252434Skib# the umbralla driver to control the servicing of interrupts between the
63252434Skib# different channels in the most flexible way.
64252434SkibMETHOD serdev_intr_t* ihand {
65252434Skib	device_t dev;
66252434Skib	int ipend;
67252434Skib} DEFAULT default_ihand;
68252434Skib
69252434Skib# sysdev() - Query system device status 
70252434Skib# This method may be called by the umbrella driver for each child driver
71252434Skib# to establish if a particular channel and mode is currently being used
72252434Skib# for system specific usage. If this is the case, the hardware is not
73252434Skib# reset and the channel will not change its operation mode.
74252434Skib# The return value is !0 if the channel and mode are used for a system
75252434Skib# device and 0 otherwise.
76252434SkibMETHOD int sysdev {
77252434Skib	device_t dev;
78252434Skib} DEFAULT default_sysdev;
79249268Sglebius
80249268Sglebius