serdev_if.m revision 157299
1157299Smarcel#- 2157299Smarcel# Copyright (c) 2006 Marcel Moolenaar 3157299Smarcel# All rights reserved. 4157299Smarcel# 5157299Smarcel# Redistribution and use in source and binary forms, with or without 6157299Smarcel# modification, are permitted provided that the following conditions 7157299Smarcel# are met: 8157299Smarcel# 1. Redistributions of source code must retain the above copyright 9157299Smarcel# notice, this list of conditions and the following disclaimer. 10157299Smarcel# 2. Redistributions in binary form must reproduce the above copyright 11157299Smarcel# notice, this list of conditions and the following disclaimer in the 12157299Smarcel# documentation and/or other materials provided with the distribution. 13157299Smarcel# 14157299Smarcel# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15157299Smarcel# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16157299Smarcel# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17157299Smarcel# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18157299Smarcel# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19157299Smarcel# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20157299Smarcel# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21157299Smarcel# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22157299Smarcel# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23157299Smarcel# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24157299Smarcel# SUCH DAMAGE. 25157299Smarcel# 26157299Smarcel# $FreeBSD: head/sys/kern/serdev_if.m 157299 2006-03-30 18:33:22Z marcel $ 27157299Smarcel# 28157299Smarcel 29157299Smarcel#include <sys/bus.h> 30157299Smarcel#include <sys/serial.h> 31157299Smarcel 32157299Smarcel# The serdev interface is used by umbrella drivers and children thereof to 33157299Smarcel# establish a more intimate relationship, necessary for efficient handling 34157299Smarcel# of multiple (concurrent) serial communication channels. Examples include 35157299Smarcel# serial communications controller (SCC) drivers, multi-I/O adapter drivers 36157299Smarcel# and intelligent multi-port serial drivers. Methods specifically deal 37157299Smarcel# with interrupt handling and configuration. Conceptually, the umbrella 38157299Smarcel# driver is responsible for the overall operation of the hardware and uses 39157299Smarcel# child drivers to handle each individual channel. 40157299Smarcel# The serdev interface is intended to inherit the device interface. 41157299Smarcel 42157299SmarcelINTERFACE serdev; 43157299Smarcel 44157299Smarcel# Default implementations of some methods. 45157299SmarcelCODE { 46157299Smarcel static serdev_intr_t * 47157299Smarcel default_ihand(device_t dev, int ipend) 48157299Smarcel { 49157299Smarcel return (NULL); 50157299Smarcel } 51157299Smarcel 52157299Smarcel static int 53157299Smarcel default_sysdev(device_t dev) 54157299Smarcel { 55157299Smarcel return (0); 56157299Smarcel } 57157299Smarcel}; 58157299Smarcel 59157299Smarcel# ihand() - Query serial device interrupt handler. 60157299Smarcel# This method is called by the umbrella driver to obtain function pointers 61157299Smarcel# to interrupt handlers for each individual interrupt source. This allows 62157299Smarcel# the umbralla driver to control the servicing of interrupts between the 63157299Smarcel# different channels in the most flexible way. 64157299SmarcelMETHOD serdev_intr_t* ihand { 65157299Smarcel device_t dev; 66157299Smarcel int ipend; 67157299Smarcel} DEFAULT default_ihand; 68157299Smarcel 69157299Smarcel# sysdev() - Query system device status 70157299Smarcel# This method may be called by the umbrella driver for each child driver 71157299Smarcel# to establish if a particular channel and mode is currently being used 72157299Smarcel# for system specific usage. If this is the case, the hardware is not 73157299Smarcel# reset and the channel will not change its operation mode. 74157299Smarcel# The return value is !0 if the channel and mode are used for a system 75157299Smarcel# device and 0 otherwise. 76157299SmarcelMETHOD int sysdev { 77157299Smarcel device_t dev; 78157299Smarcel} DEFAULT default_sysdev; 79157299Smarcel 80