Home | History | Annotate | Line # | Download | only in linux
      1 /*	$NetBSD: io-mapping.h,v 1.13 2021/12/19 12:28:04 riastradh Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2013 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Taylor R. Campbell.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef _LINUX_IO_MAPPING_H_
     33 #define _LINUX_IO_MAPPING_H_
     34 
     35 #include <sys/types.h>
     36 
     37 #include <sys/bus.h>
     38 
     39 #define	bus_space_io_mapping_init_wc	linux_bus_space_io_mapping_init_wc
     40 #define	bus_space_io_mapping_create_wc	linux_bus_space_io_mapping_create_wc
     41 #define	io_mapping_fini			linux_io_mapping_fini
     42 #define	io_mapping_free			linux_io_mapping_free
     43 #define	io_mapping_map_wc		linux_io_mapping_map_wc
     44 #define	io_mapping_unmap		linux_io_mapping_unmap
     45 #define	io_mapping_map_atomic_wc	linux_io_mapping_map_atomic_wc
     46 #define	io_mapping_unmap_atomic		linux_io_mapping_unmap_atomic
     47 
     48 struct io_mapping {
     49 	bus_space_tag_t		diom_bst;
     50 	bus_addr_t		base; /* Linux API */
     51 	bus_size_t		size; /* Linux API */
     52 	vaddr_t			diom_va;
     53 	bool			diom_atomic;
     54 };
     55 
     56 bool bus_space_io_mapping_init_wc(bus_space_tag_t, struct io_mapping *,
     57     bus_addr_t, bus_size_t);
     58 void io_mapping_fini(struct io_mapping *);
     59 
     60 struct io_mapping *bus_space_io_mapping_create_wc(bus_space_tag_t, bus_addr_t,
     61     bus_size_t);
     62 void io_mapping_free(struct io_mapping *);
     63 
     64 void *io_mapping_map_wc(struct io_mapping *, bus_addr_t, bus_size_t);
     65 void io_mapping_unmap(struct io_mapping *, void *, bus_size_t);
     66 
     67 void *io_mapping_map_atomic_wc(struct io_mapping *, bus_addr_t);
     68 void io_mapping_unmap_atomic(struct io_mapping *, void *);
     69 
     70 #endif  /* _LINUX_IO_MAPPING_H_ */
     71