pcib_if.m revision 145019
1249259Sdim#-
2249259Sdim# Copyright (c) 2000 Doug Rabson
3249259Sdim# All rights reserved.
4249259Sdim#
5249259Sdim# Redistribution and use in source and binary forms, with or without
6249259Sdim# modification, are permitted provided that the following conditions
7249259Sdim# are met:
8249259Sdim# 1. Redistributions of source code must retain the above copyright
9249259Sdim#    notice, this list of conditions and the following disclaimer.
10249259Sdim# 2. Redistributions in binary form must reproduce the above copyright
11249259Sdim#    notice, this list of conditions and the following disclaimer in the
12249259Sdim#    documentation and/or other materials provided with the distribution.
13249259Sdim#
14249259Sdim# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15249259Sdim# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16249259Sdim# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17249259Sdim# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18249259Sdim# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19249259Sdim# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20249259Sdim# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21249259Sdim# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22249259Sdim# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23249259Sdim# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24249259Sdim# SUCH DAMAGE.
25249259Sdim#
26249259Sdim# $FreeBSD: head/sys/dev/pci/pcib_if.m 145019 2005-04-13 16:30:30Z imp $
27249259Sdim#
28249259Sdim
29249259Sdim#include <sys/bus.h>
30249259Sdim
31249259SdimINTERFACE pcib;
32249259Sdim
33249259SdimCODE {
34249259Sdim	static int
35249259Sdim	null_route_interrupt(device_t pcib, device_t dev, int pin)
36249259Sdim	{
37249259Sdim		return (PCI_INVALID_IRQ);
38249259Sdim	}
39249259Sdim};
40249259Sdim
41249259Sdim#
42249259Sdim# Return the number of slots on the attached PCI bus.
43249259Sdim#
44249259SdimMETHOD int maxslots {
45249259Sdim	device_t	dev;
46249259Sdim};
47249259Sdim
48249259Sdim#
49249259Sdim# Read configuration space on the PCI bus. The bus, slot and func
50249259Sdim# arguments determine the device which is being read and the reg
51249259Sdim# argument is a byte offset into configuration space for that
52249259Sdim# device. The width argument (which should be 1, 2 or 4) specifies how
53249259Sdim# many byte of configuration space to read from that offset.
54249259Sdim#
55249259SdimMETHOD u_int32_t read_config {
56249259Sdim	device_t	dev;
57249259Sdim	u_int		bus;
58249259Sdim	u_int		slot;
59249259Sdim	u_int		func;
60249259Sdim	u_int		reg;
61249259Sdim	int		width;
62249259Sdim};
63249259Sdim
64249259Sdim#
65249259Sdim# Write configuration space on the PCI bus. The bus, slot and func
66249259Sdim# arguments determine the device which is being written and the reg
67249259Sdim# argument is a byte offset into configuration space for that
68249259Sdim# device. The value field is written to the configuration space, with
69249259Sdim# the number of bytes written depending on the width argument.
70249259Sdim#
71249259SdimMETHOD void write_config {
72249259Sdim	device_t	dev;
73249259Sdim	u_int		bus;
74249259Sdim	u_int		slot;
75249259Sdim	u_int		func;
76249259Sdim	u_int		reg;
77249259Sdim	u_int32_t	value;
78249259Sdim	int		width;
79249259Sdim};
80249259Sdim
81249259Sdim#
82249259Sdim# Route an interrupt.  Returns a value suitable for stuffing into 
83249259Sdim# a device's interrupt register.
84249259Sdim#
85249259SdimMETHOD int route_interrupt {
86249259Sdim	device_t pcib;
87249259Sdim	device_t dev;
88249259Sdim	int pin;
89249259Sdim} default null_route_interrupt;
90249259Sdim