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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_34/] [or1ksim/] [peripheral/] [dma.h] - Blame information for rev 1308

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

powered by: WebSVN 2.1.0

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