nextdmavar.h revision 1.17 1 /* $NetBSD: nextdmavar.h,v 1.17 2014/03/25 19:41:32 christos Exp $ */
2 /*
3 * Copyright (c) 1998 Darrin B. Jewell
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 BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27
28 struct nextdma_channel {
29 const char *nd_name;
30 int nd_base;
31 int nd_size;
32 u_long nd_intr;
33 int (*nd_intrfunc)(void *);
34 };
35
36 struct nextdma_config {
37 /* This is called to get another map to dma */
38 bus_dmamap_t (*nd_continue_cb)(void *);
39 /* This is called when a map has completed dma */
40 void (*nd_completed_cb)(bus_dmamap_t, void *);
41 /* This is called when dma shuts down */
42 void (*nd_shutdown_cb) (void *);
43 /* callback argument */
44 void *nd_cb_arg;
45 };
46
47 struct nextdma_status {
48 bus_dmamap_t nd_map; /* map currently in dd_next */
49 int nd_idx; /* idx of segment currently in dd_next */
50 bus_dmamap_t nd_map_cont; /* map needed to continue DMA */
51 int nd_idx_cont; /* segment index to continue DMA */
52 int nd_exception;
53 };
54
55 struct nextdma_softc {
56 device_t sc_dev;
57 struct nextdma_channel *sc_chan;
58 bus_space_handle_t sc_bsh; /* bus space handle */
59 bus_space_tag_t sc_bst; /* bus space tag */
60 bus_dma_tag_t sc_dmat;
61 struct nextdma_config sc_conf;
62 struct nextdma_status sc_stat;
63 struct evcnt sc_intrcnt;
64 };
65
66 #define nextdma_setconf(nsc, elem, val) nsc->sc_conf.nd_##elem = (val)
67
68 /* Configure the interface & initialize private structure vars */
69 void nextdma_config(struct nextdma_softc *);
70 void nextdma_init(struct nextdma_softc *);
71 void nextdma_start(struct nextdma_softc *, u_long);
72
73 /* query to see if nextdma is finished */
74 int nextdma_finished(struct nextdma_softc *);
75 void nextdma_reset(struct nextdma_softc *);
76
77 void nextdma_print(struct nextdma_softc *);
78
79 struct nextdma_softc *nextdma_findchannel(const char *);
80
81 void ndtrace_printf(const char *fmt, ...) __printflike(1, 2);
82 int ndtrace_empty(void);
83 void ndtrace_reset(void);
84 void ndtrace_addc(int);
85 const char *ndtrace_get(void);
86