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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [peripheral/] [dma.h] - Blame information for rev 235

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 235 erez
   Copyright (C) 2001 by Erez Volk, erez@opencores.org
3 212 erez
 
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 235 erez
*/
20 212 erez
 
21
/* Exported function prototypes */
22
void dma_reset( void );
23
void dma_clock( void );
24
 
25
void set_dma_req_i( unsigned dma_controller, unsigned channel );
26
void clear_dma_req_i( unsigned dma_controller, unsigned channel );
27
void set_dma_nd_i( unsigned dma_controller, unsigned channel );
28
void clear_dma_nd_i( unsigned dma_controller, unsigned channel );
29 235 erez
unsigned check_dma_ack_o( unsigned dma_controller, unsigned channel );
30 212 erez
 
31
/* Number of channel per DMA controller */
32
#define DMA_NUM_CHANNELS 31
33
 
34
 
35
/* Address space required by one DMA controller */
36
#define DMA_ADDR_SPACE 0x400
37
 
38
/* Relative Register Addresses */
39
#define DMA_CSR       0x00
40
#define DMA_INT_MSK_A 0x04
41
#define DMA_INT_MSK_B 0x08
42
#define DMA_INT_SRC_A 0x0C
43
#define DMA_INT_SRC_B 0x10
44
 
45
/* Channel registers definitions */
46
#define DMA_CH_BASE 0x20 /* Offset of first channel registers */
47
#define DMA_CH_SIZE 0x20 /* Per-channel address space */
48
 
49
/* Per-channel Register Addresses, relative to channel start */
50
#define DMA_CH_CSR   0x00
51
#define DMA_CH_SZ    0x04
52
#define DMA_CH_A0    0x08
53
#define DMA_CH_AM0   0x0C
54
#define DMA_CH_A1    0x10
55
#define DMA_CH_AM1   0x14
56
#define DMA_CH_DESC  0x18
57
#define DMA_CH_SWPTR 0x1C
58
 
59
/* Field Definitions for the Main CSR */
60
#define DMA_CSR_PAUSE_OFFSET             0
61
 
62
/* Field Definitions for the Channel CSR(s) */
63
#define DMA_CH_CSR_CH_EN_OFFSET          0
64
#define DMA_CH_CSR_DST_SEL_OFFSET        1
65
#define DMA_CH_CSR_SRC_SEL_OFFSET        2
66
#define DMA_CH_CSR_INC_DST_OFFSET        3
67
#define DMA_CH_CSR_INC_SRC_OFFSET        4
68
#define DMA_CH_CSR_MODE_OFFSET           5
69
#define DMA_CH_CSR_ARS_OFFSET            6
70
#define DMA_CH_CSR_USE_ED_OFFSET         7
71
#define DMA_CH_CSR_SZ_WB_OFFSET          8
72
#define DMA_CH_CSR_STOP_OFFSET           9
73
#define DMA_CH_CSR_BUSY_OFFSET           10  
74
#define DMA_CH_CSR_DONE_OFFSET           11
75
#define DMA_CH_CSR_ERR_OFFSET            12
76
#define DMA_CH_CSR_PRIORITY_OFFSET       13
77
#define DMA_CH_CSR_PRIORITY_WIDTH        3
78
#define DMA_CH_CSR_REST_EN_OFFSET        16
79
#define DMA_CH_CSR_INE_ERR_OFFSET        17
80
#define DMA_CH_CSR_INE_DONE_OFFSET       18
81
#define DMA_CH_CSR_INE_CHK_DONE_OFFSET   19 
82
#define DMA_CH_CSR_INT_ERR_OFFSET        20
83
#define DMA_CH_CSR_INT_DONE_OFFSET       21
84
#define DMA_CH_CSR_INT_CHUNK_DONE_OFFSET 22
85
#define DMA_CH_CSR_RESERVED_OFFSET       23
86
#define DMA_CH_CSR_RESERVED_WIDTH        9
87
 
88
/* Masks -- Writable and readonly parts of the register */
89
#define DMA_CH_CSR_WRITE_MASK            0x000FE3FF
90
 
91
/* Field definitions for Channel Size Registers */
92
#define DMA_CH_SZ_TOT_SZ_OFFSET          0
93
#define DMA_CH_SZ_TOT_SZ_WIDTH           12
94
#define DMA_CH_SZ_CHK_SZ_OFFSET          16
95
#define DMA_CH_SZ_CHK_SZ_WIDTH           9
96
 
97
/* Field definitions for Channel Address Registers CHn_Am */
98
#define DMA_CH_A0_ADDR_OFFSET            2
99
#define DMA_CH_A0_ADDR_WIDTH             30
100
#define DMA_CH_A1_ADDR_OFFSET            2
101
#define DMA_CH_A1_ADDR_WIDTH             30
102
 
103
/* Field definitions for Channel Address Mask Registers CHn_AMm */
104
#define DMA_CH_AM0_MASK_OFFSET           4
105
#define DMA_CH_AM0_MASK_WIDTH            28
106
#define DMA_CH_AM1_MASK_OFFSET           4
107
#define DMA_CH_AM1_MASK_WIDTH            28
108
 
109
/* Field definitions for Channel Linked List descriptor Pointer CHn_DESC */
110
#define DMA_CH_DESC_ADDR_OFFSET          2
111
#define DMA_CH_DESC_ADDR_WIDTH           30
112
 
113
/* Field definitions for Channel Software Pointer */
114
#define DMA_CH_SWPTR_PTR_OFFSET          2
115
#define DMA_CH_SWPTR_PTR_WIDTH           29
116
#define DMA_CH_SWPTR_EN_OFFSET           31
117
 
118
 
119
/* Structure of linked list descriptors (offsets of elements)  */
120
#define DMA_DESC_CSR                     0x00
121
#define DMA_DESC_ADR0                    0x04
122
#define DMA_DESC_ADR1                    0x08
123
#define DMA_DESC_NEXT                    0x0C
124
 
125
/* Field definitions for linked list descriptor DESC_CSR */
126
#define DMA_DESC_CSR_EOL_OFFSET          20
127
#define DMA_DESC_CSR_INC_SRC_OFFSET      19
128
#define DMA_DESC_CSR_INC_DST_OFFSET      18
129
#define DMA_DESC_CSR_SRC_SEL_OFFSET      17
130
#define DMA_DESC_CSR_DST_SEL_OFFSET      16
131
#define DMA_DESC_CSR_TOT_SZ_OFFSET       0
132
#define DMA_DESC_CSR_TOT_SZ_WIDTH        12
133
 
134
 
135
/* Implementation of DMA Channel Registers and State */
136
struct dma_channel
137
{
138 235 erez
  /* The controller we belong to */
139
  struct dma_controller *controller;
140 212 erez
 
141 235 erez
  /* Our channel number and bit mask */
142
  unsigned channel_number;
143
  unsigned long channel_mask;
144 212 erez
 
145 235 erez
  /* Used for dump, to save dumping all 32 channels */
146
  unsigned referenced;
147 212 erez
 
148 235 erez
  /* Inner state of transfer etc. */
149
  unsigned load_next_descriptor_when_done;
150
  unsigned long current_descriptor;
151
  unsigned long source, destination, source_mask, destination_mask;
152
  unsigned long chunk_size, total_size, words_transferred;
153 212 erez
 
154 235 erez
  /* The interface registers */
155
  struct
156
  {
157
    unsigned long csr;
158
    unsigned long sz;
159
    unsigned long a0;
160
    unsigned long am0;
161
    unsigned long a1;
162
    unsigned long am1;
163
    unsigned long desc;
164
    unsigned long swptr;
165
  } regs;
166 212 erez
 
167 235 erez
  /* Some control signals */
168
  unsigned dma_req_i;
169
  unsigned dma_ack_o;
170
  unsigned dma_nd_i;
171 212 erez
};
172
 
173
 
174
/* Implementation of DMA Controller Registers and State */
175
struct dma_controller
176
{
177 235 erez
  /* Base address in memory */
178
  unsigned long baseaddr;
179 212 erez
 
180 235 erez
  /* Which interrupt number we generate */
181
  unsigned irq;
182 212 erez
 
183 235 erez
  /* Controller Registers */
184
  struct
185
  {
186
    unsigned long csr;
187
    unsigned long int_msk_a;
188
    unsigned long int_msk_b;
189
    unsigned long int_src_a;
190
    unsigned long int_src_b;
191
  } regs;
192
 
193
  /* Channels */
194
  struct dma_channel ch[DMA_NUM_CHANNELS];
195 212 erez
};

powered by: WebSVN 2.1.0

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