Home | History | Annotate | Line # | Download | only in include
bus_defs.h revision 1.5.8.1
      1  1.5.8.1  thorpej /*	$NetBSD: bus_defs.h,v 1.5.8.1 2021/04/03 22:28:41 thorpej Exp $	*/
      2      1.1   dyoung 
      3      1.1   dyoung /*-
      4      1.1   dyoung  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
      5      1.1   dyoung  * All rights reserved.
      6      1.1   dyoung  *
      7      1.1   dyoung  * This code is derived from software contributed to The NetBSD Foundation
      8      1.1   dyoung  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9      1.1   dyoung  * NASA Ames Research Center.
     10      1.1   dyoung  *
     11      1.1   dyoung  * Redistribution and use in source and binary forms, with or without
     12      1.1   dyoung  * modification, are permitted provided that the following conditions
     13      1.1   dyoung  * are met:
     14      1.1   dyoung  * 1. Redistributions of source code must retain the above copyright
     15      1.1   dyoung  *    notice, this list of conditions and the following disclaimer.
     16      1.1   dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     17      1.1   dyoung  *    notice, this list of conditions and the following disclaimer in the
     18      1.1   dyoung  *    documentation and/or other materials provided with the distribution.
     19      1.1   dyoung  *
     20      1.1   dyoung  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21      1.1   dyoung  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22      1.1   dyoung  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23      1.1   dyoung  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24      1.1   dyoung  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25      1.1   dyoung  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26      1.1   dyoung  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27      1.1   dyoung  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28      1.1   dyoung  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29      1.1   dyoung  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30      1.1   dyoung  * POSSIBILITY OF SUCH DAMAGE.
     31      1.1   dyoung  */
     32      1.1   dyoung 
     33      1.1   dyoung /*
     34      1.1   dyoung  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
     35      1.1   dyoung  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
     36      1.1   dyoung  *
     37      1.1   dyoung  * Redistribution and use in source and binary forms, with or without
     38      1.1   dyoung  * modification, are permitted provided that the following conditions
     39      1.1   dyoung  * are met:
     40      1.1   dyoung  * 1. Redistributions of source code must retain the above copyright
     41      1.1   dyoung  *    notice, this list of conditions and the following disclaimer.
     42      1.1   dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     43      1.1   dyoung  *    notice, this list of conditions and the following disclaimer in the
     44      1.1   dyoung  *    documentation and/or other materials provided with the distribution.
     45      1.1   dyoung  * 3. All advertising materials mentioning features or use of this software
     46      1.1   dyoung  *    must display the following acknowledgement:
     47      1.1   dyoung  *      This product includes software developed by Christopher G. Demetriou
     48      1.1   dyoung  *	for the NetBSD Project.
     49      1.1   dyoung  * 4. The name of the author may not be used to endorse or promote products
     50      1.1   dyoung  *    derived from this software without specific prior written permission
     51      1.1   dyoung  *
     52      1.1   dyoung  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     53      1.1   dyoung  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     54      1.1   dyoung  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     55      1.1   dyoung  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     56      1.1   dyoung  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     57      1.1   dyoung  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     58      1.1   dyoung  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     59      1.1   dyoung  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     60      1.1   dyoung  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     61      1.1   dyoung  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     62      1.1   dyoung  */
     63      1.1   dyoung 
     64      1.1   dyoung #ifndef _X86_BUS_H_
     65      1.1   dyoung #define _X86_BUS_H_
     66      1.1   dyoung 
     67      1.4     maxv #ifdef _KERNEL_OPT
     68      1.4     maxv #include "opt_kasan.h"
     69      1.5     maxv #include "opt_kmsan.h"
     70      1.4     maxv #endif
     71      1.4     maxv 
     72      1.1   dyoung #include <x86/busdefs.h>
     73      1.1   dyoung 
     74      1.1   dyoung #ifdef BUS_SPACE_DEBUG
     75      1.1   dyoung #define	BUS_SPACE_ALIGNED_ADDRESS(p, t)				\
     76      1.1   dyoung 	((((u_long)(p)) & (sizeof(t)-1)) == 0)
     77      1.1   dyoung #define BUS_SPACE_ALIGNED_POINTER(p, t) BUS_SPACE_ALIGNED_ADDRESS(p, t)
     78      1.1   dyoung #else
     79      1.1   dyoung #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
     80      1.1   dyoung #endif /* BUS_SPACE_DEBUG */
     81      1.1   dyoung 
     82      1.1   dyoung /*
     83      1.1   dyoung  * Bus address and size types
     84      1.1   dyoung  */
     85      1.1   dyoung typedef paddr_t bus_addr_t;
     86      1.1   dyoung typedef size_t bus_size_t;
     87      1.1   dyoung 
     88      1.3    skrll #define PRIxBUSADDR	PRIxPADDR
     89  1.5.8.1  thorpej #define PRIxBUSSIZE	"zx"
     90  1.5.8.1  thorpej #define PRIuBUSSIZE	"zu"
     91      1.3    skrll 
     92      1.1   dyoung struct bus_space_tag;
     93      1.1   dyoung typedef	struct bus_space_tag *bus_space_tag_t;
     94      1.1   dyoung 
     95      1.1   dyoung struct bus_space_tag {
     96      1.1   dyoung 	int					bst_type;
     97      1.1   dyoung 	bus_space_tag_t				bst_super;
     98      1.2   dyoung 	/* bst_present: bitmap indicating overrides present (1) in *this* tag,
     99      1.2   dyoung 	 * bst_exists: bitmap indicating overrides present (1) in *this* tag
    100      1.2   dyoung 	 * or in an ancestor's tag (follow bst_super to ancestors)
    101      1.2   dyoung 	 */
    102      1.1   dyoung 	uint64_t				bst_present;
    103      1.2   dyoung 	uint64_t				bst_exists;
    104      1.1   dyoung 	const struct bus_space_overrides	*bst_ov;
    105      1.1   dyoung 	void					*bst_ctx;
    106      1.1   dyoung };
    107      1.1   dyoung 
    108      1.1   dyoung typedef	vaddr_t bus_space_handle_t;
    109      1.1   dyoung 
    110      1.3    skrll #define PRIxBSH		PRIxVADDR
    111      1.3    skrll 
    112      1.1   dyoung typedef struct x86_bus_dma_tag		*bus_dma_tag_t;
    113      1.1   dyoung typedef struct x86_bus_dmamap		*bus_dmamap_t;
    114      1.1   dyoung 
    115      1.1   dyoung #define BUS_DMA_TAG_VALID(__t)    ((__t) != NULL)
    116      1.1   dyoung 
    117      1.1   dyoung /*
    118      1.1   dyoung  *	bus_dma_segment_t
    119      1.1   dyoung  *
    120      1.1   dyoung  *	Describes a single contiguous DMA transaction.  Values
    121      1.1   dyoung  *	are suitable for programming into DMA registers.
    122      1.1   dyoung  */
    123      1.1   dyoung typedef struct x86_bus_dma_segment {
    124      1.1   dyoung 	bus_addr_t	ds_addr;	/* DMA address */
    125      1.1   dyoung 	bus_size_t	ds_len;		/* length of transfer */
    126      1.1   dyoung } bus_dma_segment_t;
    127      1.1   dyoung 
    128      1.1   dyoung /*
    129      1.1   dyoung  *	bus_dmamap_t
    130      1.1   dyoung  *
    131      1.1   dyoung  *	Describes a DMA mapping.  XXX exposing structure to LKM.
    132      1.1   dyoung  */
    133      1.1   dyoung struct x86_bus_dmamap {
    134      1.1   dyoung 	/*
    135      1.1   dyoung 	 * PRIVATE MEMBERS: not for use by machine-independent code.
    136      1.1   dyoung 	 */
    137      1.1   dyoung 	bus_size_t	_dm_size;	/* largest DMA transfer mappable */
    138      1.1   dyoung 	int		_dm_segcnt;	/* number of segs this map can map */
    139      1.1   dyoung 	bus_size_t	_dm_maxmaxsegsz; /* fixed largest possible segment */
    140      1.1   dyoung 	bus_size_t	_dm_boundary;	/* don't cross this */
    141      1.1   dyoung 	bus_addr_t	_dm_bounce_thresh; /* bounce threshold; see tag */
    142      1.1   dyoung 	int		_dm_flags;	/* misc. flags */
    143      1.1   dyoung 
    144      1.1   dyoung 	void		*_dm_cookie;	/* cookie for bus-specific functions */
    145      1.1   dyoung 
    146      1.1   dyoung 	/*
    147      1.1   dyoung 	 * PUBLIC MEMBERS: these are used by machine-independent code.
    148      1.1   dyoung 	 */
    149      1.5     maxv #if defined(KASAN) || defined(KMSAN)
    150      1.4     maxv 	void		*dm_buf;
    151      1.4     maxv 	bus_size_t	dm_buflen;
    152      1.4     maxv 	int		dm_buftype;
    153      1.4     maxv #endif
    154      1.1   dyoung 	bus_size_t	dm_maxsegsz;	/* largest possible segment */
    155      1.1   dyoung 	bus_size_t	dm_mapsize;	/* size of the mapping */
    156      1.1   dyoung 	int		dm_nsegs;	/* # valid segments in mapping */
    157      1.1   dyoung 	bus_dma_segment_t dm_segs[1];	/* segments; variable length */
    158      1.1   dyoung };
    159      1.1   dyoung 
    160      1.1   dyoung #endif /* _X86_BUS_H_ */
    161