1 /* $OpenBSD: pci_machdep.h,v 1.5 2009/08/22 02:54:50 mk 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)(struct device *, 44 struct device *, 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)(struct pci_attach_args *, 53 pci_intr_handle_t *); 54 const char *(*pc_intr_string)(void *, pci_intr_handle_t); 55 void *(*pc_intr_establish)(void *, pci_intr_handle_t, 56 int, int (*)(void *), void *, const char *); 57 void (*pc_intr_disestablish)(void *, void *); 58 59 void *(*pc_alloc_parent)(struct device *, 60 struct pci_attach_args *, int); 61 }; 62 63 /* 64 * Functions provided to machine-independent PCI code. 65 */ 66 #define pci_attach_hook(p, s, pba) \ 67 (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba)) 68 #define pci_bus_maxdevs(c, b) \ 69 (*(c)->pc_bus_maxdevs)((c)->_cookie, (b)) 70 #define pci_make_tag(c, b, d, f) \ 71 (*(c)->pc_make_tag)((c)->_cookie, (b), (d), (f)) 72 #define pci_decompose_tag(c, t, bp, dp, fp) \ 73 (*(c)->pc_decompose_tag)((c)->_cookie, (t), (bp), (dp), (fp)) 74 #define pci_conf_read(c, t, r) \ 75 (*(c)->pc_conf_read)((c)->_cookie, (t), (r)) 76 #define pci_conf_write(c, t, r, v) \ 77 (*(c)->pc_conf_write)((c)->_cookie, (t), (r), (v)) 78 #define pci_intr_map(p, ihp) \ 79 (*(p)->pa_pc->pc_intr_map)((p), (ihp)) 80 #define pci_intr_line(c, ih) (ih) 81 #define pci_intr_string(c, ih) \ 82 (*(c)->pc_intr_string)((c)->_cookie, (ih)) 83 #define pci_intr_establish(c, ih, l, h, a, nm) \ 84 (*(c)->pc_intr_establish)((c)->_cookie, (ih), (l), (h), (a), (nm)) 85 #define pci_intr_disestablish(c, iv) \ 86 (*(c)->pc_intr_disestablish)((c)->_cookie, (iv)) 87 88 #define pciide_machdep_compat_intr_establish(a, b, c, d, e) (NULL) 89 #define pciide_machdep_compat_intr_disestablish(a, b) ((void)(a), (void)(b)) 90 91 #endif /* _MACHINE_PCI_MACHDEP_H_ */ 92