source: soft/giet_vm/giet_drivers/dma_driver.h @ 665

Last change on this file since 665 was 529, checked in by alain, 10 years ago

1) Removing the IOC driver (integrated in the FAT library).
2) Simplifying the BDV, HBA, SDC, RDK drivers: they support
only two modes (synchronous => polling / descheduling => IRQ),
and only one access function (for both read/write).

File size: 7.0 KB
Line 
1//////////////////////////////////////////////////////////////////////////////////
2// File     : dma_driver.h
3// Date     : 01/11/2013
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6//////////////////////////////////////////////////////////////////////////////////
7// The dma_driver.c and dma_driver.h files are part ot the GIET-VM nano-kernel.
8// This driver supports the SoCLib vci_multi_dma component.
9//
10// It can exist several DMA controlers in the architecture (one per cluster),
11// and each controller can contain several channels.
12//
13// There is  (NB_CLUSTERS * NB_DMA_CHANNELS) channels, indexed by a global index:
14//        dma_id = cluster_xy * NB_DMA_CHANNELS + loc_id
15//
16// A DMA channel is a private ressource allocated to a given processor.
17// It is exclusively used by the kernel to speedup data transfers, and
18// there is no lock protecting exclusive access to the channel.
19// As the kernel uses a polling policy on the DMA_STATUS register to detect
20// transfer completion, the DMA IRQ is not used.
21//
22// The virtual base address of the segment associated to a channel is:
23//    SEG_DMA_BASE + cluster_xy * PERI_CLUSTER_INCREMENT + DMA_SPAN * channel_id
24//
25// The SEG_DMA_BASE virtual address must be defined in the hard_config.h file.
26//////////////////////////////////////////////////////////////////////////////////
27
28#ifndef _GIET_DMA_DRIVER_H_
29#define _GIET_DMA_DRIVER_H_
30
31//////////////////////////////////////////////////////////////////////////////////
32// Multi DMA registers offset
33//////////////////////////////////////////////////////////////////////////////////
34
35enum DMA_registers
36{
37    DMA_SRC         = 0,
38    DMA_DST         = 1,
39    DMA_LEN         = 2,
40    DMA_RESET       = 3,
41    DMA_IRQ_DISABLE = 4,
42    DMA_SRC_EXT     = 5,
43    DMA_DST_EXT     = 6,
44    /**/
45    DMA_END         = 7,
46    DMA_SPAN        = 8,
47};
48
49enum SoclibDmaStatus
50{
51    DMA_SUCCESS      = 0,
52    DMA_READ_ERROR   = 1,
53    DMA_IDLE         = 2,
54    DMA_WRITE_ERROR  = 3,
55    DMA_BUSY         = 4,
56};
57
58
59//////////////////////////////////////////////////////////////////////////////////
60//                  low-level access functions 
61//////////////////////////////////////////////////////////////////////////////////
62
63//////////////////////////////////////////////////////////////////////////////////
64// This function disables interrupts for one DMA channel in one cluster.
65// In case of error (illegal DMA channel), an error
66// message is displayed on TTY0, and system crash.
67//////////////////////////////////////////////////////////////////////////////////
68extern void _dma_disable_irq( unsigned int cluster_xy,
69                              unsigned int channel_id );
70
71//////////////////////////////////////////////////////////////////////////////////
72// This function re-initialises one DMA channel in one cluster after transfer
73// completion. It actually forces the channel to return in IDLE state.
74// In case of error (illegal DMA channel), an error
75// message is displayed on TTY0, and system crash.
76//////////////////////////////////////////////////////////////////////////////////
77extern void _dma_reset_channel( unsigned int  cluster_xy, 
78                                unsigned int  channel_id );
79
80//////////////////////////////////////////////////////////////////////////////////
81// This function returns the status of a DMA channel in a given cluster.
82// In case of error (illegal DMA channel), an error
83// message is displayed on TTY0, and system crash.
84//////////////////////////////////////////////////////////////////////////////////
85extern void _dma_get_status( unsigned int  cluster_xy, 
86                             unsigned int  channel_id,
87                             unsigned int* status );
88
89//////////////////////////////////////////////////////////////////////////////////
90// This function sets the physical address (including 64 bits extension)
91// for the source and destination buffers in a DMA channel in a given cluster
92// and sets the transfer size to lauch the transfer.
93// In case of error (illegal DMA channel), an error
94// message is displayed on TTY0, and system crash.
95//////////////////////////////////////////////////////////////////////////////////
96extern void _dma_start_transfer( unsigned int       cluster_xy,
97                                 unsigned int       channel_id,
98                                 unsigned long long dst_paddr,
99                                 unsigned long long src_paddr,
100                                 unsigned int       size );
101
102//////////////////////////////////////////////////////////////////////////////////
103//                     higher level access function
104//////////////////////////////////////////////////////////////////////////////////
105
106//////////////////////////////////////////////////////////////////////////////////
107// This function copies a source memory buffer to a destination memory buffer,
108// using directly physical addresses.
109// This blocking function is supposed to be used by the kernel only,
110// and uses a polling policy on DMA_STATUS register to detect completion.
111// Therefore, the DMA_IRQ is NOT used.
112// The source and destination buffers base addresses must be word aligned,
113// and the buffer's size must be multiple of 4.
114// In case of error (buffer unmapped, unaligned, or DMA_STATUS error), an error
115// message is displayed on TTY0, and system crash.
116//////////////////////////////////////////////////////////////////////////////////
117extern void _dma_physical_copy( unsigned int       cluster_xy,
118                                unsigned int       channel_id,
119                                unsigned long long dst_paddr,
120                                unsigned long long src_paddr,
121                                unsigned int       size ); 
122
123//////////////////////////////////////////////////////////////////////////////////
124// This function copies a source memory buffer to a destination memory buffer,
125// making virtual to physical address translation: the MMU should be activated.
126// The source and destination buffers base addresses must be word aligned,
127// and the buffer's size must be multiple of 4.
128// In case of error (buffer unmapped, unaligned, or DMA_STATUS error), an error
129// message is displayed on TTY0, and system crash.
130//////////////////////////////////////////////////////////////////////////////////
131extern void _dma_copy(  unsigned int cluster_xy,
132                        unsigned int channel_id,
133                        unsigned int dst_vaddr,
134                        unsigned int src_vaddr,
135                        unsigned int size ); 
136
137//////////////////////////////////////////////////////////////////////////////////
138// Interrupt Service Routine.
139//////////////////////////////////////////////////////////////////////////////////
140extern void _dma_isr( unsigned int irq_type,
141                      unsigned int irq_id,
142                      unsigned int channel );
143
144
145#endif
146
147// Local Variables:
148// tab-width: 4
149// c-basic-offset: 4
150// c-file-offsets:((innamespace . 0)(inline-open . 0))
151// indent-tabs-mode: nil
152// End:
153// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
154
Note: See TracBrowser for help on using the repository browser.