xref: /freebsd/sys/dev/scc/scc_if.m (revision d1bdc2821fcd416ab9b238580386eb605a6128d0)
1#-
2# Copyright (c) 2004-2006 Marcel Moolenaar
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25#
26
27#include <sys/param.h>
28#include <sys/bus.h>
29#include <machine/bus.h>
30#include <sys/lock.h>
31#include <sys/mutex.h>
32#include <sys/rman.h>
33#include <dev/scc/scc_bfe.h>
34
35# The SCC hardware interface. The core SCC code is hardware independent.
36# The details of the hardware are abstracted by the SCC hardware interface.
37
38INTERFACE scc;
39
40# Default implementations of some methods.
41CODE {
42	static int
43	default_enabled(struct scc_softc *this, struct scc_chan *ch)
44	{
45		return (1);
46	}
47}
48
49# attach() - attach hardware.
50# This method is called when the device is being attached. All resources
51# have been allocated. The intend of this method is to setup the hardware
52# for normal operation.
53# The reset parameter informs the hardware driver whether a full device
54# reset is allowed or not. This is important when one of the channels can
55# be used as system console and a hardware reset would disrupt output.
56METHOD int attach {
57	struct scc_softc *this;
58	int reset;
59};
60
61# enabled()
62METHOD int enabled {
63	struct scc_softc *this;
64	struct scc_chan *chan;
65} DEFAULT default_enabled;
66
67# iclear()
68METHOD int iclear {
69	struct scc_softc *this;
70	struct scc_chan *chan;
71};
72
73# ipend() - query SCC for pending interrupts.
74# When an interrupt is signalled, the handler will call this method to find
75# out which of the interrupt sources needs attention. The handler will use
76# this information to dispatch service routines that deal with each of the
77# interrupt sources. An advantage of this approach is that it allows multi-
78# port drivers (like puc(4)) to query multiple devices concurrently and
79# service them on an interrupt priority basis. If the hardware cannot provide
80# the information reliably, it is free to service the interrupt and return 0,
81# meaning that no attention is required.
82METHOD int ipend {
83	struct scc_softc *this;
84}
85
86# probe() - detect hardware.
87# This method is called as part of the bus probe to make sure the
88# hardware exists. This function should also set the device description
89# to something that represents the hardware.
90METHOD int probe {
91	struct scc_softc *this;
92};
93