Home | History | Annotate | Line # | Download | only in include
      1 /*	$OpenBSD: pci_machdep.h,v 1.1 2003/09/29 19:23:02 mickey Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2003 Michael Shalayeff
      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 AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
     20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     22  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     24  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     25  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     26  * THE POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 #ifndef	_MACHINE_PCI_MACHDEP_H_
     30 #define	_MACHINE_PCI_MACHDEP_H_
     31 
     32 /*
     33  * Types provided to machine-independent PCI code
     34  */
     35 typedef struct hppa_pci_chipset_tag *pci_chipset_tag_t;
     36 typedef u_long pcitag_t;
     37 typedef u_long pci_intr_handle_t;
     38 
     39 struct pci_attach_args;
     40 
     41 struct hppa_pci_chipset_tag {
     42 	void		*_cookie;
     43 	void		(*pc_attach_hook)(device_t,
     44 			    device_t, struct pcibus_attach_args *);
     45 	int		(*pc_bus_maxdevs)(void *, int);
     46 	pcitag_t	(*pc_make_tag)(void *, int, int, int);
     47 	void		(*pc_decompose_tag)(void *, pcitag_t, int *,
     48 			    int *, int *);
     49 	pcireg_t	(*pc_conf_read)(void *, pcitag_t, int);
     50 	void		(*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
     51 
     52 	int		(*pc_intr_map)(const struct pci_attach_args *,
     53 			    pci_intr_handle_t *);
     54 	const char	*(*pc_intr_string)(void *, pci_intr_handle_t,
     55 			    char *, size_t);
     56 	int		(*pc_intr_setattr)(void *, pci_intr_handle_t *,
     57 			    int, uint64_t);
     58 	void		*(*pc_intr_establish)(void *, pci_intr_handle_t,
     59 			    int, int (*)(void *), void *);
     60 	void		(*pc_intr_disestablish)(void *, void *);
     61 
     62 	void		*(*pc_alloc_parent)(device_t,
     63 			    struct pci_attach_args *, int);
     64 };
     65 
     66 /*
     67  * Functions provided to machine-independent PCI code.
     68  */
     69 #define	pci_attach_hook(p, s, pba)					\
     70     (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
     71 #define	pci_bus_maxdevs(c, b)						\
     72     (*(c)->pc_bus_maxdevs)((c)->_cookie, (b))
     73 #define	pci_make_tag(c, b, d, f)					\
     74     (*(c)->pc_make_tag)((c)->_cookie, (b), (d), (f))
     75 #define	pci_decompose_tag(c, t, bp, dp, fp)				\
     76     (*(c)->pc_decompose_tag)((c)->_cookie, (t), (bp), (dp), (fp))
     77 #define	pci_conf_read(c, t, r)						\
     78     (*(c)->pc_conf_read)((c)->_cookie, (t), (r))
     79 #define	pci_conf_write(c, t, r, v)					\
     80     (*(c)->pc_conf_write)((c)->_cookie, (t), (r), (v))
     81 #define	pci_intr_map(p, ihp)						\
     82     (*(p)->pa_pc->pc_intr_map)((p), (ihp))
     83 #define	pci_intr_line(ih)	(ih)
     84 #define	pci_intr_string(c, ih, buf, len)				\
     85     (*(c)->pc_intr_string)((c)->_cookie, (ih), (buf), (len))
     86 #define	pci_intr_establish(c, ih, l, h, a)				\
     87     (*(c)->pc_intr_establish)((c)->_cookie, (ih), (l), (h), (a))
     88 #define	pci_intr_disestablish(c, iv)					\
     89     (*(c)->pc_intr_disestablish)((c)->_cookie, (iv))
     90 
     91 static inline int
     92 pci_intr_setattr(pci_chipset_tag_t pc, pci_intr_handle_t *ihp,
     93     int attr, uint64_t data)
     94 {
     95 	if (!pc->pc_intr_setattr)
     96 		return ENODEV;
     97 	return pc->pc_intr_setattr(pc, ihp, attr, data);
     98 }
     99 
    100 #define	pciide_machdep_compat_intr_establish(a, b, c, d, e)	(NULL)
    101 #define	pciide_machdep_compat_intr_disestablish(a, b)	((void)(a), (void)(b))
    102 
    103 #define	pci_intr_evcnt(a, b) (NULL)
    104 
    105 #endif /* _MACHINE_PCI_MACHDEP_H_ */
    106