1 1.15 skrll /* $NetBSD: pci_machdep.h,v 1.15 2022/08/16 14:00:03 skrll Exp $ */ 2 1.1 soda /* NetBSD: pci_machdep.h,v 1.3 1999/03/19 03:40:46 cgd Exp */ 3 1.1 soda 4 1.1 soda /* 5 1.1 soda * Copyright (c) 1996 Carnegie-Mellon University. 6 1.1 soda * All rights reserved. 7 1.1 soda * 8 1.1 soda * Author: Chris G. Demetriou 9 1.1 soda * 10 1.1 soda * Permission to use, copy, modify and distribute this software and 11 1.1 soda * its documentation is hereby granted, provided that both the copyright 12 1.1 soda * notice and this permission notice appear in all copies of the 13 1.1 soda * software, derivative works or modified versions, and any portions 14 1.1 soda * thereof, and that both notices appear in supporting documentation. 15 1.1 soda * 16 1.1 soda * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 17 1.1 soda * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 18 1.1 soda * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 19 1.1 soda * 20 1.1 soda * Carnegie Mellon requests users of this software to return to 21 1.1 soda * 22 1.1 soda * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU 23 1.1 soda * School of Computer Science 24 1.1 soda * Carnegie Mellon University 25 1.1 soda * Pittsburgh PA 15213-3890 26 1.1 soda * 27 1.1 soda * any improvements or extensions that they make and grant Carnegie the 28 1.1 soda * rights to redistribute these changes. 29 1.1 soda */ 30 1.1 soda 31 1.14 skrll #ifndef _MACHINE_PCI_MACHDEP_H_ 32 1.14 skrll #define _MACHINE_PCI_MACHDEP_H_ 33 1.14 skrll 34 1.1 soda /* 35 1.1 soda * Machine-specific definitions for PCI autoconfiguration. 36 1.1 soda */ 37 1.8 tsutsui #define __HAVE_PCI_CONF_HOOK 38 1.1 soda 39 1.1 soda /* 40 1.2 ur * Forward declarations. 41 1.2 ur */ 42 1.2 ur struct pci_attach_args; 43 1.2 ur 44 1.2 ur /* 45 1.1 soda * Types provided to machine-independent PCI code 46 1.1 soda */ 47 1.1 soda typedef struct arc_pci_chipset *pci_chipset_tag_t; 48 1.1 soda typedef u_long pcitag_t; 49 1.1 soda typedef u_long pci_intr_handle_t; 50 1.1 soda 51 1.1 soda /* 52 1.1 soda * arc-specific PCI structure and type definitions. 53 1.1 soda * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE. 54 1.1 soda */ 55 1.1 soda struct arc_pci_chipset { 56 1.10 chs void (*pc_attach_hook)(device_t, device_t, 57 1.10 chs struct pcibus_attach_args *); 58 1.6 tsutsui int (*pc_bus_maxdevs)(pci_chipset_tag_t, int); 59 1.6 tsutsui pcitag_t (*pc_make_tag)(pci_chipset_tag_t, int, int, int); 60 1.6 tsutsui void (*pc_decompose_tag)(pci_chipset_tag_t, pcitag_t, 61 1.6 tsutsui int *, int *, int *); 62 1.6 tsutsui pcireg_t (*pc_conf_read)(pci_chipset_tag_t, pcitag_t, int); 63 1.6 tsutsui void (*pc_conf_write)(pci_chipset_tag_t, pcitag_t, int, 64 1.6 tsutsui pcireg_t); 65 1.9 dyoung int (*pc_intr_map)(const struct pci_attach_args *, 66 1.6 tsutsui pci_intr_handle_t *); 67 1.6 tsutsui const char *(*pc_intr_string)(pci_chipset_tag_t, 68 1.11 christos pci_intr_handle_t, char *, size_t); 69 1.15 skrll int (*pc_intr_setattr)(void *, pci_intr_handle_t *, 70 1.15 skrll int, uint64_t); 71 1.6 tsutsui void *(*pc_intr_establish)(pci_chipset_tag_t, 72 1.6 tsutsui pci_intr_handle_t, int, int (*)(void *), void *); 73 1.6 tsutsui void (*pc_intr_disestablish)(pci_chipset_tag_t, void *); 74 1.8 tsutsui void (*pc_conf_interrupt)(pci_chipset_tag_t, int, int, int, 75 1.8 tsutsui int, int *); 76 1.8 tsutsui int (*pc_conf_hook)(pci_chipset_tag_t, int, int, int, 77 1.8 tsutsui pcireg_t); 78 1.1 soda }; 79 1.1 soda 80 1.1 soda /* 81 1.1 soda * Functions provided to machine-independent PCI code. 82 1.1 soda */ 83 1.1 soda #define pci_attach_hook(p, s, pba) \ 84 1.1 soda (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba)) 85 1.1 soda #define pci_bus_maxdevs(c, b) \ 86 1.1 soda (*(c)->pc_bus_maxdevs)((c), (b)) 87 1.1 soda #define pci_make_tag(c, b, d, f) \ 88 1.1 soda (*(c)->pc_make_tag)((c), (b), (d), (f)) 89 1.3 thorpej #define pci_decompose_tag(c, t, bp, dp, fp) \ 90 1.3 thorpej (*(c)->pc_decompose_tag)((c), (t), (bp), (dp), (fp)) 91 1.1 soda #define pci_conf_read(c, t, r) \ 92 1.1 soda (*(c)->pc_conf_read)((c), (t), (r)) 93 1.1 soda #define pci_conf_write(c, t, r, v) \ 94 1.1 soda (*(c)->pc_conf_write)((c), (t), (r), (v)) 95 1.2 ur #define pci_intr_map(pa, ihp) \ 96 1.2 ur (*(pa)->pa_pc->pc_intr_map)((pa), (ihp)) 97 1.11 christos #define pci_intr_string(c, ih, buf, len) \ 98 1.11 christos (*(c)->pc_intr_string)((c), (ih), (buf), (len)) 99 1.1 soda #define pci_intr_establish(c, ih, l, h, a) \ 100 1.1 soda (*(c)->pc_intr_establish)((c), (ih), (l), (h), (a)) 101 1.1 soda #define pci_intr_disestablish(c, iv) \ 102 1.1 soda (*(c)->pc_intr_disestablish)((c), (iv)) 103 1.8 tsutsui #define pci_conf_interrupt(c, b, d, f, s, i) \ 104 1.8 tsutsui (*(c)->pc_conf_interrupt)((c), (b), (d), (f), (s), (i)) 105 1.13 skrll #define pci_conf_hook(c, b, d, f, i) \ 106 1.8 tsutsui (*(c)->pc_conf_hook)((c), (b), (d), (f), (i)) 107 1.14 skrll 108 1.15 skrll static inline int 109 1.15 skrll pci_intr_setattr(pci_chipset_tag_t pc, pci_intr_handle_t *ihp, 110 1.15 skrll int attr, uint64_t data) 111 1.15 skrll { 112 1.15 skrll if (!pc->pc_intr_setattr) 113 1.15 skrll return ENODEV; 114 1.15 skrll return pc->pc_intr_setattr(pc, ihp, attr, data); 115 1.15 skrll } 116 1.15 skrll 117 1.14 skrll #endif /* _MACHINE_PCI_MACHDEP_H_ */ 118