OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_43/] [or1ksim/] [peripheral/] [dma.h] - Blame information for rev 212

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 212 erez
/* dma.h -- Definition of types and structures for DMA
2
   Copyright (C) 2001 by Erez Volk, erez@mailandnews.com
3
 
4
   This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 2 of the License, or
9
   (at your option) any later version.
10
 
11
   This program is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
 
16
   You should have received a copy of the GNU General Public License
17
   along with this program; if not, write to the Free Software
18
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
   */
20
 
21
/* Exported function prototypes */
22
void dma_reset( void );
23
void dma_clock( void );
24
void dma_write( unsigned long addr, unsigned long value );
25
unsigned long dma_read( unsigned long addr );
26
 
27
void set_dma_req_i( unsigned dma_controller, unsigned channel );
28
void clear_dma_req_i( unsigned dma_controller, unsigned channel );
29
void set_dma_nd_i( unsigned dma_controller, unsigned channel );
30
void clear_dma_nd_i( unsigned dma_controller, unsigned channel );
31
unsigned check_dma_acq_o( unsigned dma_controller, unsigned channel );
32
 
33
/* Number of channel per DMA controller */
34
#define DMA_NUM_CHANNELS 31
35
 
36
 
37
/* Address space required by one DMA controller */
38
#define DMA_ADDR_SPACE 0x400
39
 
40
/* Relative Register Addresses */
41
#define DMA_CSR       0x00
42
#define DMA_INT_MSK_A 0x04
43
#define DMA_INT_MSK_B 0x08
44
#define DMA_INT_SRC_A 0x0C
45
#define DMA_INT_SRC_B 0x10
46
 
47
/* Channel registers definitions */
48
#define DMA_CH_BASE 0x20 /* Offset of first channel registers */
49
#define DMA_CH_SIZE 0x20 /* Per-channel address space */
50
 
51
/* Per-channel Register Addresses, relative to channel start */
52
#define DMA_CH_CSR   0x00
53
#define DMA_CH_SZ    0x04
54
#define DMA_CH_A0    0x08
55
#define DMA_CH_AM0   0x0C
56
#define DMA_CH_A1    0x10
57
#define DMA_CH_AM1   0x14
58
#define DMA_CH_DESC  0x18
59
#define DMA_CH_SWPTR 0x1C
60
 
61
/* Field Definitions for the Main CSR */
62
#define DMA_CSR_PAUSE_OFFSET             0
63
 
64
/* Field Definitions for the Channel CSR(s) */
65
#define DMA_CH_CSR_CH_EN_OFFSET          0
66
#define DMA_CH_CSR_DST_SEL_OFFSET        1
67
#define DMA_CH_CSR_SRC_SEL_OFFSET        2
68
#define DMA_CH_CSR_INC_DST_OFFSET        3
69
#define DMA_CH_CSR_INC_SRC_OFFSET        4
70
#define DMA_CH_CSR_MODE_OFFSET           5
71
#define DMA_CH_CSR_ARS_OFFSET            6
72
#define DMA_CH_CSR_USE_ED_OFFSET         7
73
#define DMA_CH_CSR_SZ_WB_OFFSET          8
74
#define DMA_CH_CSR_STOP_OFFSET           9
75
#define DMA_CH_CSR_BUSY_OFFSET           10  
76
#define DMA_CH_CSR_DONE_OFFSET           11
77
#define DMA_CH_CSR_ERR_OFFSET            12
78
#define DMA_CH_CSR_PRIORITY_OFFSET       13
79
#define DMA_CH_CSR_PRIORITY_WIDTH        3
80
#define DMA_CH_CSR_REST_EN_OFFSET        16
81
#define DMA_CH_CSR_INE_ERR_OFFSET        17
82
#define DMA_CH_CSR_INE_DONE_OFFSET       18
83
#define DMA_CH_CSR_INE_CHK_DONE_OFFSET   19 
84
#define DMA_CH_CSR_INT_ERR_OFFSET        20
85
#define DMA_CH_CSR_INT_DONE_OFFSET       21
86
#define DMA_CH_CSR_INT_CHUNK_DONE_OFFSET 22
87
#define DMA_CH_CSR_RESERVED_OFFSET       23
88
#define DMA_CH_CSR_RESERVED_WIDTH        9
89
 
90
/* Masks -- Writable and readonly parts of the register */
91
#define DMA_CH_CSR_WRITE_MASK            0x000FE3FF
92
 
93
/* Field definitions for Channel Size Registers */
94
#define DMA_CH_SZ_TOT_SZ_OFFSET          0
95
#define DMA_CH_SZ_TOT_SZ_WIDTH           12
96
#define DMA_CH_SZ_CHK_SZ_OFFSET          16
97
#define DMA_CH_SZ_CHK_SZ_WIDTH           9
98
 
99
/* Field definitions for Channel Address Registers CHn_Am */
100
#define DMA_CH_A0_ADDR_OFFSET            2
101
#define DMA_CH_A0_ADDR_WIDTH             30
102
#define DMA_CH_A1_ADDR_OFFSET            2
103
#define DMA_CH_A1_ADDR_WIDTH             30
104
 
105
/* Field definitions for Channel Address Mask Registers CHn_AMm */
106
#define DMA_CH_AM0_MASK_OFFSET           4
107
#define DMA_CH_AM0_MASK_WIDTH            28
108
#define DMA_CH_AM1_MASK_OFFSET           4
109
#define DMA_CH_AM1_MASK_WIDTH            28
110
 
111
/* Field definitions for Channel Linked List descriptor Pointer CHn_DESC */
112
#define DMA_CH_DESC_ADDR_OFFSET          2
113
#define DMA_CH_DESC_ADDR_WIDTH           30
114
 
115
/* Field definitions for Channel Software Pointer */
116
#define DMA_CH_SWPTR_PTR_OFFSET          2
117
#define DMA_CH_SWPTR_PTR_WIDTH           29
118
#define DMA_CH_SWPTR_EN_OFFSET           31
119
 
120
 
121
/* Structure of linked list descriptors (offsets of elements)  */
122
#define DMA_DESC_CSR                     0x00
123
#define DMA_DESC_ADR0                    0x04
124
#define DMA_DESC_ADR1                    0x08
125
#define DMA_DESC_NEXT                    0x0C
126
 
127
/* Field definitions for linked list descriptor DESC_CSR */
128
#define DMA_DESC_CSR_EOL_OFFSET          20
129
#define DMA_DESC_CSR_INC_SRC_OFFSET      19
130
#define DMA_DESC_CSR_INC_DST_OFFSET      18
131
#define DMA_DESC_CSR_SRC_SEL_OFFSET      17
132
#define DMA_DESC_CSR_DST_SEL_OFFSET      16
133
#define DMA_DESC_CSR_TOT_SZ_OFFSET       0
134
#define DMA_DESC_CSR_TOT_SZ_WIDTH        12
135
 
136
 
137
/* Implementation of DMA Channel Registers and State */
138
struct dma_channel
139
{
140
    /* The controller we belong to */
141
    struct dma_controller *controller;
142
 
143
    /* Our channel number and bit mask */
144
    unsigned channel_number;
145
    unsigned long channel_mask;
146
 
147
    /* Used for dump, to save dumping all 32 channels */
148
    unsigned referenced;
149
 
150
    /* Inner state of transfer etc. */
151
    unsigned load_next_descriptor_when_done;
152
    unsigned long current_descriptor;
153
    unsigned long source, destination, source_mask, destination_mask;
154
    unsigned long chunk_size, total_size, words_transferred;
155
 
156
    /* The interface registers */
157
    struct
158
    {
159
        unsigned long csr;
160
        unsigned long sz;
161
        unsigned long a0;
162
        unsigned long am0;
163
        unsigned long a1;
164
        unsigned long am1;
165
        unsigned long desc;
166
        unsigned long swptr;
167
    } regs;
168
 
169
    /* Some control signals */
170
    unsigned dma_req_i;
171
    unsigned dma_acq_o;
172
    unsigned dma_nd_i;
173
};
174
 
175
 
176
/* Implementation of DMA Controller Registers and State */
177
struct dma_controller
178
{
179
    /* Base address in memory */
180
    unsigned long baseaddr;
181
 
182
    /* Controller Registers */
183
    struct
184
    {
185
        unsigned long csr;
186
        unsigned long int_msk_a;
187
        unsigned long int_msk_b;
188
        unsigned long int_src_a;
189
        unsigned long int_src_b;
190
    } regs;
191
 
192
    /* Channels */
193
    struct dma_channel ch[DMA_NUM_CHANNELS];
194
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.