xref: /freebsd/sys/kern/bus_if.m (revision 31a7daae9ea748ebba75ea790fc0a3607929fb6a)
1b1bf6610SDoug Rabson#
2b1bf6610SDoug Rabson# Copyright (c) 1998 Doug Rabson
3b1bf6610SDoug Rabson# All rights reserved.
4b1bf6610SDoug Rabson#
5b1bf6610SDoug Rabson# Redistribution and use in source and binary forms, with or without
6b1bf6610SDoug Rabson# modification, are permitted provided that the following conditions
7b1bf6610SDoug Rabson# are met:
8b1bf6610SDoug Rabson# 1. Redistributions of source code must retain the above copyright
9b1bf6610SDoug Rabson#    notice, this list of conditions and the following disclaimer.
10b1bf6610SDoug Rabson# 2. Redistributions in binary form must reproduce the above copyright
11b1bf6610SDoug Rabson#    notice, this list of conditions and the following disclaimer in the
12b1bf6610SDoug Rabson#    documentation and/or other materials provided with the distribution.
13b1bf6610SDoug Rabson#
14b1bf6610SDoug Rabson# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15b1bf6610SDoug Rabson# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16b1bf6610SDoug Rabson# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17b1bf6610SDoug Rabson# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18b1bf6610SDoug Rabson# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19b1bf6610SDoug Rabson# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20b1bf6610SDoug Rabson# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21b1bf6610SDoug Rabson# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22b1bf6610SDoug Rabson# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23b1bf6610SDoug Rabson# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24b1bf6610SDoug Rabson# SUCH DAMAGE.
25b1bf6610SDoug Rabson#
2631a7daaeSNicolas Souchu#	$Id: bus_if.m,v 1.3 1998/09/16 08:25:56 dfr Exp $
27b1bf6610SDoug Rabson#
28b1bf6610SDoug Rabson
2931a7daaeSNicolas SouchuINTERFACE bus;
30b1bf6610SDoug Rabson
31b1bf6610SDoug Rabson#
32b1bf6610SDoug Rabson# This is called from system code which prints out a description of a
33b1bf6610SDoug Rabson# device.  It should describe the attachment that the child has with
34b1bf6610SDoug Rabson# the parent.  For instance the TurboLaser bus prints which node the
35b1bf6610SDoug Rabson# device is attached to.
36b1bf6610SDoug Rabson#
37b1bf6610SDoug RabsonMETHOD void print_child {
38b1bf6610SDoug Rabson	device_t dev;
39b1bf6610SDoug Rabson	device_t child;
40b1bf6610SDoug Rabson};
41b1bf6610SDoug Rabson
42b1bf6610SDoug Rabson#
43b1bf6610SDoug Rabson# These two methods manage a bus specific set of instance variables of
44b1bf6610SDoug Rabson# a child device.  The intention is that each different type of bus
45b1bf6610SDoug Rabson# defines a set of appropriate instance variables (such as ports and
46b1bf6610SDoug Rabson# irqs for ISA bus etc.)
47b1bf6610SDoug Rabson#
48b1bf6610SDoug Rabson# This information could be given to the child device as a struct but
49b1bf6610SDoug Rabson# that makes it hard for a bus to add or remove variables without
50b1bf6610SDoug Rabson# forcing an edit and recompile for all drivers which may not be
51b1bf6610SDoug Rabson# possible for vendor supplied binary drivers.
52b1bf6610SDoug Rabson
53b1bf6610SDoug Rabson#
54b1bf6610SDoug Rabson# Read an instance variable.  Return 0 on success.
55b1bf6610SDoug Rabson#
56b1bf6610SDoug RabsonMETHOD int read_ivar {
57b1bf6610SDoug Rabson	device_t dev;
58b1bf6610SDoug Rabson	device_t child;
59b1bf6610SDoug Rabson	int index;
60b1bf6610SDoug Rabson	u_long *result;
61b1bf6610SDoug Rabson};
62b1bf6610SDoug Rabson
63b1bf6610SDoug Rabson#
64b1bf6610SDoug Rabson# Write an instance variable.  Return 0 on success.
65b1bf6610SDoug Rabson#
66b1bf6610SDoug RabsonMETHOD int write_ivar {
67b1bf6610SDoug Rabson	device_t dev;
68b1bf6610SDoug Rabson	device_t child;
69b1bf6610SDoug Rabson	int index;
70b1bf6610SDoug Rabson	u_long value;
71b1bf6610SDoug Rabson};
72b1bf6610SDoug Rabson
73b1bf6610SDoug Rabson#
746e4fb915SDoug Rabson# Create an interrupt handler for the child device.  The handler will
756e4fb915SDoug Rabson# be called with the value 'arg' as its only argument.  This method
766e4fb915SDoug Rabson# does not activate the handler.
77b1bf6610SDoug Rabson#
7845c95fa1SDoug RabsonMETHOD void* create_intr {
79b1bf6610SDoug Rabson	device_t dev;
80b1bf6610SDoug Rabson	device_t child;
8145c95fa1SDoug Rabson	int irq;
82b1bf6610SDoug Rabson	driver_intr_t *intr;
83b1bf6610SDoug Rabson	void *arg;
84b1bf6610SDoug Rabson};
8545c95fa1SDoug Rabson
866e4fb915SDoug Rabson#
876e4fb915SDoug Rabson# Activate an interrupt handler previously created with
886e4fb915SDoug Rabson# BUS_CREATE_INTR.
896e4fb915SDoug Rabson#
9045c95fa1SDoug RabsonMETHOD int connect_intr {
9145c95fa1SDoug Rabson	device_t dev;
9245c95fa1SDoug Rabson	void *ih;
9345c95fa1SDoug Rabson};
94