Home | History | Annotate | Line # | Download | only in include
      1 /*	$NetBSD: pci_machdep.h,v 1.9 2014/03/29 19:28:28 christos Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2001 Enami Tsugutomo.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  * SUCH DAMAGE.
     27  */
     28 
     29 /*
     30  * Machine-specific definitions for PCI autoconfiguration.
     31  */
     32 
     33 /*
     34  * Types provided to machine-independent PCI code
     35  */
     36 typedef struct hpcmips_pci_chipset *pci_chipset_tag_t;
     37 typedef u_long pcitag_t;
     38 typedef u_long pci_intr_handle_t;
     39 
     40 /*
     41  * Forward declarations.
     42  */
     43 struct pci_attach_args;
     44 
     45 /*
     46  * hpcmips-specific PCI structure and type definitions.
     47  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
     48  */
     49 struct hpcmips_pci_chipset {
     50 	device_t pc_dev;
     51 
     52 	void (*pc_attach_hook)(device_t, device_t,
     53 	    struct pcibus_attach_args *);
     54 	int (*pc_bus_maxdevs)(pci_chipset_tag_t, int);
     55 	int (*pc_bus_devorder)(pci_chipset_tag_t, int, uint8_t *, int);
     56 	pcitag_t (*pc_make_tag)(pci_chipset_tag_t, int, int, int);
     57 	void (*pc_decompose_tag)(pci_chipset_tag_t, pcitag_t, int *, int *,
     58 	    int *);
     59 	pcireg_t (*pc_conf_read)(pci_chipset_tag_t, pcitag_t, int);
     60 	void (*pc_conf_write)(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
     61 	int (*pc_intr_map)(const struct pci_attach_args *, pci_intr_handle_t *);
     62 	const char *(*pc_intr_string)(pci_chipset_tag_t, pci_intr_handle_t,
     63 	    char *, size_t);
     64 	const struct evcnt *(*pc_intr_evcnt)(pci_chipset_tag_t,
     65 	    pci_intr_handle_t);
     66 	void *(*pc_intr_establish)(pci_chipset_tag_t, pci_intr_handle_t, int,
     67 	    int (*)(void *), void *);
     68 	void (*pc_intr_disestablish)(pci_chipset_tag_t, void *);
     69 };
     70 
     71 /*
     72  * Functions provided to machine-independent PCI code.
     73  */
     74 #define	pci_attach_hook(p, s, pba)					\
     75     (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
     76 #define	pci_bus_maxdevs(c, b)						\
     77     (*(c)->pc_bus_maxdevs)((c), (b))
     78 #define	pci_make_tag(c, b, d, f)					\
     79     (*(c)->pc_make_tag)((c), (b), (d), (f))
     80 #define	pci_decompose_tag(c, t, bp, dp, fp)				\
     81     (*(c)->pc_decompose_tag)((c), (t), (bp), (dp), (fp))
     82 #define	pci_conf_read(c, t, r)						\
     83     (*(c)->pc_conf_read)((c), (t), (r))
     84 #define	pci_conf_write(c, t, r, v)					\
     85     (*(c)->pc_conf_write)((c), (t), (r), (v))
     86 #define	pci_intr_map(pa, ihp)						\
     87     (*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
     88 #define	pci_intr_string(c, ih, buf, len)				\
     89     (*(c)->pc_intr_string)((c), (ih), (buf), (len))
     90 #define	pci_intr_evcnt(c, ih)						\
     91     (*(c)->pc_intr_evcnt)((c), (ih))
     92 #define	pci_intr_establish(c, ih, l, h, a)				\
     93     (*(c)->pc_intr_establish)((c), (ih), (l), (h), (a))
     94 #define	pci_intr_disestablish(c, iv)					\
     95     (*(c)->pc_intr_disestablish)((c), (iv))
     96