xref: /netbsd-src/sys/arch/vax/include/sgmap.h (revision 37abeb738dac8242f97c75f07b0a4b02e113888c)
1 /* $NetBSD: sgmap.h,v 1.8 2023/12/03 00:49:46 thorpej Exp $ */
2 
3 /*-
4  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9  * NASA Ames Research Center.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef	_VAX_SGMAP_H
34 #define	_VAX_SGMAP_H
35 
36 #include <sys/vmem.h>
37 #include <machine/bus.h>
38 #include <machine/pte.h>
39 
40 /*
41  * A VAX SGMAP's state information.  Nothing in the sgmap requires
42  * locking[*], with the exception of the vmem arena, which takes care
43  * of it on its own.
44  *
45  * [*] While the page table is a `global' resource, access to it is
46  * controlled by the arena; once a region has been allocated from
47  * the arena, that region is effectively `locked'.
48  */
49 struct vax_sgmap {
50 	vmem_t     *aps_arena;		/* arena to manage sgva space */
51 	struct pte *aps_pt;		/* page table */
52 	bus_addr_t aps_sgvabase;	/* base of the sgva space */
53 	bus_size_t aps_sgvasize;	/* size of the sgva space */
54 	bus_addr_t aps_pa;		/* Address in region */
55 	unsigned int aps_flags;		/* flags */
56 };
57 
58 void	vax_sgmap_dmatag_init(bus_dma_tag_t, void *, size_t);
59 
60 void	vax_sgmap_init(bus_dma_tag_t, struct vax_sgmap *, const char *,
61 	    bus_addr_t, bus_size_t, struct pte *, bus_size_t);
62 
63 int	vax_sgmap_alloc(bus_dmamap_t, bus_size_t, struct vax_sgmap *, int);
64 void	vax_sgmap_free(bus_dmamap_t, struct vax_sgmap *);
65 
66 int	vax_sgmap_reserve(bus_addr_t, bus_size_t, struct vax_sgmap *);
67 
68 int     vax_sgmap_load(bus_dma_tag_t, bus_dmamap_t, void *, bus_size_t,
69 	    struct proc *, int, struct vax_sgmap *);
70 
71 int	vax_sgmap_load_mbuf(bus_dma_tag_t, bus_dmamap_t, struct mbuf *, int,
72 	    struct vax_sgmap *);
73 
74 int     vax_sgmap_load_uio(bus_dma_tag_t, bus_dmamap_t, struct uio *, int,
75 	    struct vax_sgmap *);
76 
77 int	vax_sgmap_load_raw(bus_dma_tag_t, bus_dmamap_t, bus_dma_segment_t *,
78 	    int, bus_size_t, int, struct vax_sgmap *);
79 
80 void	vax_sgmap_unload(bus_dma_tag_t, bus_dmamap_t, struct vax_sgmap *);
81 
82 #endif	/* _VAX_SGMAP_H */
83