]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/sun4v/include/bus_private.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / sun4v / include / bus_private.h
1 /*-
2  * Copyright (c) 1997, 1998 Justin T. Gibbs.
3  * Copyright (c) 2002 by Thomas Moestl <tmm@FreeBSD.org>.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
24  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  *      from: FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.25 2002/01/05
27  *
28  * $FreeBSD$
29  */
30
31 #ifndef _MACHINE_BUS_PRIVATE_H_
32 #define _MACHINE_BUS_PRIVATE_H_
33
34 #include <sys/queue.h>
35
36 /*
37  * Helpers
38  */
39 int sparc64_bus_mem_map(bus_space_tag_t, bus_space_handle_t, bus_size_t,
40     int, vm_offset_t, void **);
41 int sparc64_bus_mem_unmap(void *, bus_size_t);
42 bus_space_handle_t sparc64_fake_bustag(int, bus_addr_t, struct bus_space_tag *);
43
44 struct bus_dmamap_res {
45         struct resource         *dr_res;
46         bus_size_t              dr_used;
47         bus_size_t              dr_offset;
48         SLIST_ENTRY(bus_dmamap_res)     dr_link;
49 };
50
51 /*
52  * Callers of the bus_dma interfaces must always protect their tags and maps
53  * appropriately against concurrent access. However, when a map is on a LRU
54  * queue, there is a second access path to it; for this case, the locking rules
55  * are given in the parenthesized comments below:
56  *      q - locked by the mutex protecting the queue.
57  *      p - private to the owner of the map, no access through the queue.
58  *      * - comment refers to pointer target.
59  * Only the owner of the map is allowed to insert the map into a queue. Removal
60  * and repositioning (i.e. temporal removal and reinsertion) is allowed to all
61  * if the queue lock is held.
62  */
63 struct bus_dmamap {
64         TAILQ_ENTRY(bus_dmamap) dm_maplruq;             /* (q) */
65         SLIST_HEAD(, bus_dmamap_res)    dm_reslist;     /* (q, *q) */
66         int                     dm_onq;                 /* (q) */
67         int                     dm_flags;               /* (p) */
68 };
69
70 /* Flag values. */
71 #define DMF_LOADED      1       /* Map is loaded */
72 #define DMF_COHERENT    2       /* Coherent mapping requested */
73
74 int sparc64_dma_alloc_map(bus_dma_tag_t dmat, bus_dmamap_t *mapp);
75 void sparc64_dma_free_map(bus_dma_tag_t dmat, bus_dmamap_t map);
76
77 /*
78  * XXX: This is a kluge. It would be better to handle dma tags in a hierarchical
79  * way, and have a BUS_GET_DMA_TAG(); however, since this is not currently the
80  * case, save a root tag in the relevant bus attach function and use that.
81  */
82 extern bus_dma_tag_t sparc64_root_dma_tag;
83
84 #endif /* !_MACHINE_BUS_PRIVATE_H_ */