pcib_if.m revision 67222
165176Sdfr#
265176Sdfr# Copyright (c) 2000 Doug Rabson
365176Sdfr# All rights reserved.
465176Sdfr#
565176Sdfr# Redistribution and use in source and binary forms, with or without
665176Sdfr# modification, are permitted provided that the following conditions
765176Sdfr# are met:
865176Sdfr# 1. Redistributions of source code must retain the above copyright
965176Sdfr#    notice, this list of conditions and the following disclaimer.
1065176Sdfr# 2. Redistributions in binary form must reproduce the above copyright
1165176Sdfr#    notice, this list of conditions and the following disclaimer in the
1265176Sdfr#    documentation and/or other materials provided with the distribution.
1365176Sdfr#
1465176Sdfr# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1565176Sdfr# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1665176Sdfr# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1765176Sdfr# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1865176Sdfr# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1965176Sdfr# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2065176Sdfr# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2165176Sdfr# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2265176Sdfr# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2365176Sdfr# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2465176Sdfr# SUCH DAMAGE.
2565176Sdfr#
2665176Sdfr# $FreeBSD: head/sys/dev/pci/pcib_if.m 67222 2000-10-16 19:43:44Z imp $
2765176Sdfr#
2865176Sdfr
2965176Sdfr#include <sys/bus.h>
3065176Sdfr
3165176SdfrINTERFACE pcib;
3265176Sdfr
3365176Sdfr#
3465176Sdfr# Return the number of slots on the attached PCI bus.
3565176Sdfr#
3665176SdfrMETHOD int maxslots {
3765176Sdfr	device_t	dev;
3865176Sdfr};
3965176Sdfr
4065176Sdfr#
4165176Sdfr# Read configuration space on the PCI bus. The bus, slot and func
4265176Sdfr# arguments determine the device which is being read and the reg
4365176Sdfr# argument is a byte offset into configuration space for that
4465176Sdfr# device. The width argument (which should be 1, 2 or 4) specifies how
4565176Sdfr# many byte of configuration space to read from that offset.
4665176Sdfr#
4765176SdfrMETHOD u_int32_t read_config {
4865176Sdfr	device_t	dev;
4965176Sdfr	int		bus;
5065176Sdfr	int		slot;
5165176Sdfr	int		func;
5265176Sdfr	int		reg;
5365176Sdfr	int		width;
5465176Sdfr};
5565176Sdfr
5665176Sdfr#
5765176Sdfr# Write configuration space on the PCI bus. The bus, slot and func
5865176Sdfr# arguments determine the device which is being written and the reg
5965176Sdfr# argument is a byte offset into configuration space for that
6065176Sdfr# device. The value field is written to the configuration space, with
6165176Sdfr# the number of bytes written depending on the width argument.
6265176Sdfr#
6365176SdfrMETHOD void write_config {
6465176Sdfr	device_t	dev;
6565176Sdfr	int		bus;
6665176Sdfr	int		slot;
6765176Sdfr	int		func;
6865176Sdfr	int		reg;
6965176Sdfr	u_int32_t	value;
7065176Sdfr	int		width;
7165176Sdfr};
7267222Simp
7367222Simp#
7467222Simp# Route an interrupt.  Returns a value suitable for stuffing into 
7567222Simp# a device's interrupt register.
7667222Simp#
7767222SimpMETHOD int route_interrupt {
7867222Simp	device_t dev;
7967222Simp	int device;
8067222Simp	int pin;
8167222Simp};
82