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