1*0a6a1f1dSLionel Sambuc /* $NetBSD: pciio.h,v 1.4 2014/07/25 01:38:26 mrg Exp $ */ 27eb99bdaSLionel Sambuc 37eb99bdaSLionel Sambuc /* 47eb99bdaSLionel Sambuc * Copyright 2001 Wasabi Systems, Inc. 57eb99bdaSLionel Sambuc * All rights reserved. 67eb99bdaSLionel Sambuc * 77eb99bdaSLionel Sambuc * Written by Jason R. Thorpe for Wasabi Systems, Inc. 87eb99bdaSLionel Sambuc * 97eb99bdaSLionel Sambuc * Redistribution and use in source and binary forms, with or without 107eb99bdaSLionel Sambuc * modification, are permitted provided that the following conditions 117eb99bdaSLionel Sambuc * are met: 127eb99bdaSLionel Sambuc * 1. Redistributions of source code must retain the above copyright 137eb99bdaSLionel Sambuc * notice, this list of conditions and the following disclaimer. 147eb99bdaSLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright 157eb99bdaSLionel Sambuc * notice, this list of conditions and the following disclaimer in the 167eb99bdaSLionel Sambuc * documentation and/or other materials provided with the distribution. 177eb99bdaSLionel Sambuc * 3. All advertising materials mentioning features or use of this software 187eb99bdaSLionel Sambuc * must display the following acknowledgement: 197eb99bdaSLionel Sambuc * This product includes software developed for the NetBSD Project by 207eb99bdaSLionel Sambuc * Wasabi Systems, Inc. 217eb99bdaSLionel Sambuc * 4. The name of Wasabi Systems, Inc. may not be used to endorse 227eb99bdaSLionel Sambuc * or promote products derived from this software without specific prior 237eb99bdaSLionel Sambuc * written permission. 247eb99bdaSLionel Sambuc * 257eb99bdaSLionel Sambuc * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 267eb99bdaSLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 277eb99bdaSLionel Sambuc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 287eb99bdaSLionel Sambuc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 297eb99bdaSLionel Sambuc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 307eb99bdaSLionel Sambuc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 317eb99bdaSLionel Sambuc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 327eb99bdaSLionel Sambuc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 337eb99bdaSLionel Sambuc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 347eb99bdaSLionel Sambuc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 357eb99bdaSLionel Sambuc * POSSIBILITY OF SUCH DAMAGE. 367eb99bdaSLionel Sambuc */ 377eb99bdaSLionel Sambuc 387eb99bdaSLionel Sambuc #ifndef _DEV_PCI_PCIIO_H_ 397eb99bdaSLionel Sambuc #define _DEV_PCI_PCIIO_H_ 407eb99bdaSLionel Sambuc 417eb99bdaSLionel Sambuc /* 427eb99bdaSLionel Sambuc * User -> kernel interface for PCI bus access. 437eb99bdaSLionel Sambuc */ 447eb99bdaSLionel Sambuc 457eb99bdaSLionel Sambuc #include <sys/ioccom.h> 467eb99bdaSLionel Sambuc 477eb99bdaSLionel Sambuc /* 487eb99bdaSLionel Sambuc * pciio_cfgreg: 497eb99bdaSLionel Sambuc * 507eb99bdaSLionel Sambuc * Representation of a PCI config space register. 517eb99bdaSLionel Sambuc */ 527eb99bdaSLionel Sambuc struct pciio_cfgreg { 537eb99bdaSLionel Sambuc u_int reg; /* offset into PCI configuration space */ 547eb99bdaSLionel Sambuc uint32_t val; /* value of the register */ 557eb99bdaSLionel Sambuc }; 567eb99bdaSLionel Sambuc 577eb99bdaSLionel Sambuc /* 587eb99bdaSLionel Sambuc * Read and write PCI configuration space registers on a 597eb99bdaSLionel Sambuc * specific device. 607eb99bdaSLionel Sambuc */ 617eb99bdaSLionel Sambuc #define PCI_IOC_CFGREAD _IOWR('P', 0, struct pciio_cfgreg) 627eb99bdaSLionel Sambuc #define PCI_IOC_CFGWRITE _IOW('P', 1, struct pciio_cfgreg) 637eb99bdaSLionel Sambuc 647eb99bdaSLionel Sambuc /* 657eb99bdaSLionel Sambuc * pciio_bdf_cfgreg: 667eb99bdaSLionel Sambuc * 677eb99bdaSLionel Sambuc * Like pciio_cfgreg, except for any bus/dev/func within 687eb99bdaSLionel Sambuc * a given PCI domain. 697eb99bdaSLionel Sambuc */ 707eb99bdaSLionel Sambuc struct pciio_bdf_cfgreg { 717eb99bdaSLionel Sambuc u_int bus; 727eb99bdaSLionel Sambuc u_int device; 737eb99bdaSLionel Sambuc u_int function; 747eb99bdaSLionel Sambuc struct pciio_cfgreg cfgreg; 757eb99bdaSLionel Sambuc }; 767eb99bdaSLionel Sambuc 777eb99bdaSLionel Sambuc /* 787eb99bdaSLionel Sambuc * Read and write PCI configuration space registers on any 797eb99bdaSLionel Sambuc * device within a given PCI domain. 807eb99bdaSLionel Sambuc */ 817eb99bdaSLionel Sambuc #define PCI_IOC_BDF_CFGREAD _IOWR('P', 2, struct pciio_bdf_cfgreg) 827eb99bdaSLionel Sambuc #define PCI_IOC_BDF_CFGWRITE _IOW('P', 3, struct pciio_bdf_cfgreg) 837eb99bdaSLionel Sambuc 847eb99bdaSLionel Sambuc /* 857eb99bdaSLionel Sambuc * pciio_businfo: 867eb99bdaSLionel Sambuc * 877eb99bdaSLionel Sambuc * Information for a PCI bus (autoconfiguration node) instance. 887eb99bdaSLionel Sambuc */ 897eb99bdaSLionel Sambuc struct pciio_businfo { 907eb99bdaSLionel Sambuc u_int busno; /* bus number */ 917eb99bdaSLionel Sambuc u_int maxdevs; /* max devices on bus */ 927eb99bdaSLionel Sambuc }; 937eb99bdaSLionel Sambuc 947eb99bdaSLionel Sambuc #define PCI_IOC_BUSINFO _IOR('P', 4, struct pciio_businfo) 957eb99bdaSLionel Sambuc 96*0a6a1f1dSLionel Sambuc /* 97*0a6a1f1dSLionel Sambuc * pciio_drvname: 98*0a6a1f1dSLionel Sambuc * 99*0a6a1f1dSLionel Sambuc * Driver info for a PCI device (autoconfiguration node) instance. 100*0a6a1f1dSLionel Sambuc * Must be run on the correct bus. 101*0a6a1f1dSLionel Sambuc */ 102*0a6a1f1dSLionel Sambuc 103*0a6a1f1dSLionel Sambuc #define PCI_IO_DRVNAME_LEN 16 104*0a6a1f1dSLionel Sambuc struct pciio_drvname { 105*0a6a1f1dSLionel Sambuc u_int device; /* in: device number */ 106*0a6a1f1dSLionel Sambuc u_int function; /* in: function number */ 107*0a6a1f1dSLionel Sambuc char name[PCI_IO_DRVNAME_LEN]; 108*0a6a1f1dSLionel Sambuc }; 109*0a6a1f1dSLionel Sambuc 110*0a6a1f1dSLionel Sambuc #define PCI_IOC_DRVNAME _IOWR('P', 5, struct pciio_drvname) 111*0a6a1f1dSLionel Sambuc 112*0a6a1f1dSLionel Sambuc 1135d831176SLionel Sambuc #if defined(__minix) 1145d831176SLionel Sambuc struct pciio_map { 1155d831176SLionel Sambuc int flags; /* reserved, must be 0 */ 1165d831176SLionel Sambuc u_int phys_offset; 1175d831176SLionel Sambuc size_t size; 1185d831176SLionel Sambuc int readonly; 1195d831176SLionel Sambuc char reserved[36]; /* reserved, must be 0 */ 1205d831176SLionel Sambuc void *vaddr; 1215d831176SLionel Sambuc void *vaddr_ret; 1225d831176SLionel Sambuc }; 1235d831176SLionel Sambuc 1245d831176SLionel Sambuc #define PCI_IOC_MAP _IOWR('P', 100, struct pciio_map) 1255d831176SLionel Sambuc #define PCI_IOC_UNMAP _IOW('P', 101, struct pciio_map) 1265d831176SLionel Sambuc 1275d831176SLionel Sambuc struct pciio_acl { 1285d831176SLionel Sambuc u_int domain; 1295d831176SLionel Sambuc u_int bus; 1305d831176SLionel Sambuc u_int device; 1315d831176SLionel Sambuc u_int function; 1325d831176SLionel Sambuc }; 1335d831176SLionel Sambuc 1345d831176SLionel Sambuc #define PCI_IOC_RESERVE _IOW('P', 102, struct pciio_acl) 1355d831176SLionel Sambuc #define PCI_IOC_RELEASE _IOW('P', 103, struct pciio_acl) 1365d831176SLionel Sambuc #endif /* defined(__minix) */ 1377eb99bdaSLionel Sambuc #endif /* _DEV_PCI_PCIIO_H_ */ 138