1995-02-01 22:56:55 +00:00
|
|
|
/**************************************************************************
|
|
|
|
**
|
1996-09-08 10:44:18 +00:00
|
|
|
** $Id: pcivar.h,v 1.11 1996/09/06 23:09:01 phk Exp $
|
1995-02-01 22:56:55 +00:00
|
|
|
**
|
|
|
|
** Declarations for pci device drivers.
|
|
|
|
**
|
1995-03-21 23:01:06 +00:00
|
|
|
** FreeBSD
|
1995-02-01 22:56:55 +00:00
|
|
|
**
|
|
|
|
**-------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**
|
|
|
|
***************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PCI_VAR_H__
|
1995-03-21 23:01:06 +00:00
|
|
|
#define __PCI_VAR_H__ "pl2 95/03/21"
|
1995-02-27 17:17:14 +00:00
|
|
|
|
1995-02-01 22:56:55 +00:00
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** main pci initialization function.
|
|
|
|
** called at boot time from autoconf.c
|
|
|
|
**
|
|
|
|
**-----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
void pci_configure (void);
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** The pci configuration id describes a pci device on the bus.
|
|
|
|
** It is constructed from: bus, device & function numbers.
|
|
|
|
**
|
|
|
|
**-----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
u_long cfg1;
|
1995-03-21 23:01:06 +00:00
|
|
|
struct {
|
1995-02-01 22:56:55 +00:00
|
|
|
u_char enable;
|
|
|
|
u_char forward;
|
|
|
|
u_short port;
|
|
|
|
} cfg2;
|
1995-03-21 23:01:06 +00:00
|
|
|
unsigned tag;
|
1995-02-01 22:56:55 +00:00
|
|
|
} pcici_t;
|
|
|
|
|
1995-03-21 23:01:06 +00:00
|
|
|
#define sametag(x,y) ((x).tag == (y).tag)
|
|
|
|
|
1995-02-01 22:56:55 +00:00
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** Each pci device has an unique device id.
|
|
|
|
** It is used to find a matching driver.
|
|
|
|
**
|
|
|
|
**-----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef u_long pcidi_t;
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** The following functions are provided for the device driver
|
|
|
|
** to read/write the configuration space.
|
|
|
|
**
|
|
|
|
** pci_conf_read():
|
|
|
|
** Read a long word from the pci configuration space.
|
|
|
|
** Requires a tag (from pcitag) and the register
|
|
|
|
** number (should be a long word alligned one).
|
|
|
|
**
|
|
|
|
** pci_conf_write():
|
|
|
|
** Writes a long word to the pci configuration space.
|
|
|
|
** Requires a tag (from pcitag), the register number
|
|
|
|
** (should be a long word alligned one), and a value.
|
|
|
|
**
|
|
|
|
**-----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
u_long pci_conf_read (pcici_t tag, u_long reg );
|
|
|
|
|
|
|
|
void pci_conf_write (pcici_t tag, u_long reg, u_long data);
|
1995-03-21 23:01:06 +00:00
|
|
|
|
1995-02-01 22:56:55 +00:00
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** The pci driver structure.
|
|
|
|
**
|
|
|
|
** name: The short device name.
|
|
|
|
**
|
|
|
|
** probe: Checks if the driver can support a device
|
|
|
|
** with this type. The tag may be used to get
|
|
|
|
** more info with pci_read_conf(). See below.
|
|
|
|
** It returns a string with the devices name,
|
|
|
|
** or a NULL pointer, if the driver cannot
|
|
|
|
** support this device.
|
|
|
|
**
|
|
|
|
** attach: Allocate a control structure and prepare
|
|
|
|
** it. This function may use the pci mapping
|
|
|
|
** functions. See below.
|
|
|
|
** (configuration id) or type.
|
|
|
|
**
|
|
|
|
** count: A pointer to a unit counter.
|
|
|
|
** It's used by the pci configurator to
|
|
|
|
** allocate unit numbers.
|
|
|
|
**
|
|
|
|
**-----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct pci_device {
|
|
|
|
char* pd_name;
|
|
|
|
char* (*pd_probe ) (pcici_t tag, pcidi_t type);
|
|
|
|
void (*pd_attach) (pcici_t tag, int unit);
|
|
|
|
u_long *pd_count;
|
1996-09-06 23:09:20 +00:00
|
|
|
int (*pd_shutdown) (int, int);
|
1995-02-01 22:56:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** This table includes pointers to all pci device drivers.
|
|
|
|
** It should be generated by the linker.
|
|
|
|
**
|
|
|
|
**-----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern struct linker_set pcidevice_set;
|
1995-03-21 23:01:06 +00:00
|
|
|
|
|
|
|
extern unsigned pci_max_burst_len; /* log2 of safe burst transfer length */
|
|
|
|
extern unsigned pci_mechanism;
|
|
|
|
extern unsigned pci_maxdevice;
|
|
|
|
|
1995-02-01 22:56:55 +00:00
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** The pci-devconf interface.
|
|
|
|
**
|
|
|
|
**-----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct pci_info {
|
1996-01-25 18:32:00 +00:00
|
|
|
u_char pi_bus;
|
|
|
|
u_char pi_device;
|
|
|
|
u_char pi_func;
|
|
|
|
u_char pi_dummy;
|
1996-09-06 23:09:20 +00:00
|
|
|
u_char pi_unit;
|
1995-05-30 08:16:23 +00:00
|
|
|
};
|
|
|
|
|
1995-02-01 22:56:55 +00:00
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** Map a pci device to physical and virtual memory.
|
|
|
|
**
|
1995-03-21 23:01:06 +00:00
|
|
|
** Entry selects the register in the pci configuration
|
1995-02-01 22:56:55 +00:00
|
|
|
** space, which supplies the size of the region, and
|
|
|
|
** receives the physical address.
|
|
|
|
**
|
1995-03-21 23:01:06 +00:00
|
|
|
** In case of success the function sets the addresses
|
|
|
|
** in *va and *pa, and returns 1.
|
|
|
|
** In case of errors a message is written,
|
|
|
|
** and the function returns 0.
|
1995-02-01 22:56:55 +00:00
|
|
|
**
|
|
|
|
**-----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
1996-03-19 15:03:00 +00:00
|
|
|
int pci_map_mem (pcici_t tag, u_long entry, vm_offset_t *va, vm_offset_t *pa);
|
1995-02-01 22:56:55 +00:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** Map a pci device to an io port area.
|
|
|
|
**
|
|
|
|
** Entry selects the register in the pci configuration
|
|
|
|
** space, which supplies the size of the region, and
|
|
|
|
** receives the port number.
|
|
|
|
**
|
1995-03-21 23:01:06 +00:00
|
|
|
** In case of success the function sets the port number in pa,
|
|
|
|
** and returns 1.
|
|
|
|
** In case of errors a message is written,
|
|
|
|
** and the function returns 0.
|
1995-02-01 22:56:55 +00:00
|
|
|
**
|
|
|
|
**-----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
1995-03-21 23:01:06 +00:00
|
|
|
int pci_map_port (pcici_t tag, u_long entry, u_short * pa);
|
|
|
|
|
1995-02-01 22:56:55 +00:00
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
**
|
1995-03-21 23:01:06 +00:00
|
|
|
** Map a pci interrupt to an isa irq line, and enable the interrupt.
|
1995-02-01 22:56:55 +00:00
|
|
|
**
|
1995-03-21 23:01:06 +00:00
|
|
|
** -----------------
|
1995-02-01 22:56:55 +00:00
|
|
|
**
|
1995-03-21 23:01:06 +00:00
|
|
|
** func is the interrupt handler, arg is the argument
|
|
|
|
** to the handler (usually a pointer to a softc).
|
1995-02-01 22:56:55 +00:00
|
|
|
**
|
1995-03-21 23:01:06 +00:00
|
|
|
** The maskptr argument should be &bio_imask,
|
|
|
|
** &net_imask etc. or NULL.
|
1995-02-01 22:56:55 +00:00
|
|
|
**
|
1995-03-21 23:01:06 +00:00
|
|
|
** If there is any error, a message is written, and
|
|
|
|
** the function returns with zero.
|
|
|
|
** Else it returns with a value different to zero.
|
1995-02-01 22:56:55 +00:00
|
|
|
**
|
1995-03-21 23:01:06 +00:00
|
|
|
** -----------------
|
1995-02-01 22:56:55 +00:00
|
|
|
**
|
1995-03-21 23:01:06 +00:00
|
|
|
** The irq number is read from the configuration space.
|
|
|
|
** (Should have been set by the bios).
|
1995-02-01 22:56:55 +00:00
|
|
|
**
|
1995-03-21 23:01:06 +00:00
|
|
|
** Supports multiple handlers per irq (shared interrupts).
|
1995-02-01 22:56:55 +00:00
|
|
|
**
|
|
|
|
**-----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
1996-01-23 21:48:28 +00:00
|
|
|
typedef void pci_inthand_t(void *arg);
|
1995-11-21 12:55:26 +00:00
|
|
|
|
1995-03-21 23:01:06 +00:00
|
|
|
struct pci_int_desc {
|
|
|
|
struct pci_int_desc * pcid_next;
|
|
|
|
pcici_t pcid_tag;
|
1995-11-21 12:55:26 +00:00
|
|
|
pci_inthand_t *pcid_handler;
|
1995-03-21 23:01:06 +00:00
|
|
|
void* pcid_argument;
|
|
|
|
unsigned * pcid_maskptr;
|
|
|
|
unsigned pcid_tally;
|
|
|
|
unsigned pcid_mask;
|
|
|
|
};
|
|
|
|
|
1995-11-21 12:55:26 +00:00
|
|
|
int pci_map_int (pcici_t tag, pci_inthand_t *func, void *arg,
|
|
|
|
unsigned *maskptr);
|
1995-02-01 22:56:55 +00:00
|
|
|
|
1995-03-21 23:01:06 +00:00
|
|
|
int pci_unmap_int (pcici_t tag);
|
|
|
|
|
1995-02-01 22:56:55 +00:00
|
|
|
#endif
|