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