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

Last change on this file since 481 was 437, checked in by alain, 10 years ago

Introducing dynamic allocation of peripheral channel(TTY, NIC, TIM, CMA)
Removint the ICU driver : ICU component not supported anymore.
Removing the FBF driver.

File size: 7.1 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 kernet 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 mus 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// AS the GIET-VM uses a polling policy to detect DMA transfer completion,
66// the DMA component initialisation must disable interrupts.
67// Returns 0 if success, returns > 0 if error.
68//////////////////////////////////////////////////////////////////////////////////
69extern unsigned int _dma_init( unsigned int cluster_xy,
70                               unsigned int channel_id );
71
72//////////////////////////////////////////////////////////////////////////////////
73// This function re-initialises one DMA channel in one cluster after transfer
74// completion. It actually forces the channel to return in IDLE state.
75//////////////////////////////////////////////////////////////////////////////////
76extern unsigned int _dma_reset( unsigned int  cluster_xy, 
77                                unsigned int  channel_id );
78
79//////////////////////////////////////////////////////////////////////////////////
80// This function returns the status of a DMA channel in a given cluster
81//////////////////////////////////////////////////////////////////////////////////
82extern unsigned int _dma_get_status( unsigned int  cluster_xy, 
83                                     unsigned int  channel_id );
84
85//////////////////////////////////////////////////////////////////////////////////
86// This function sets the physical address (including 64 bits extension)
87// for the source and destination buffers in a DMA channel in a given cluster
88// and sets the transfer size to lauch the transfer.
89//////////////////////////////////////////////////////////////////////////////////
90extern void _dma_start_transfer( unsigned int       cluster_xy,
91                                 unsigned int       channel_id,
92                                 unsigned long long dst_paddr,
93                                 unsigned long long src_paddr,
94                                 unsigned int       size );
95
96//////////////////////////////////////////////////////////////////////////////////
97//                     higher level access function
98//////////////////////////////////////////////////////////////////////////////////
99
100///////////////////////////////////////////////////////////////////////////////////
101// This function copies a source memory buffer to a destination memory buffer,
102// using directly physical addresses.
103// This blocking function is supposed to be used by the kernel only,
104// and uses a polling policy on DMA_STATUS register to detect completion.
105// Therefore, the DMA_IRQ is NOT used.
106// The source and destination buffers base addresses must be word aligned,
107// and the buffer's size must be multiple of 4.
108// In case of error (buffer unmapped, unaligned, or DMA_STATUS error), an error
109// message is displayed on TTY0, and system crash.
110///////////////////////////////////////////////////////////////////////////////////
111extern void _dma_physical_copy( unsigned int       cluster_xy,
112                                unsigned int       channel_id,
113                                unsigned long long dst_paddr,
114                                unsigned long long src_paddr,
115                                unsigned int       size ); 
116
117///////////////////////////////////////////////////////////////////////////////////
118// This function copies a source memory buffer to a destination memory buffer,
119// making virtual to physical address translation: the MMU should be activated.
120// This blocking function is supposed to be used by the kernel only,
121// and uses a polling policy on DMA_STATUS register to detect completion.
122// Therefore, the DMA_IRQ is NOT used.
123// The source and destination buffers base addresses must be word aligned,
124// and the buffer's size must be multiple of 4.
125// In case of error (buffer unmapped, unaligned, or DMA_STATUS error), an error
126// message is displayed on TTY0, and system crash.
127///////////////////////////////////////////////////////////////////////////////////
128extern void _dma_copy(  unsigned int cluster_xy,
129                        unsigned int channel_id,
130                        unsigned int vspace_id,
131                        unsigned int dst_vaddr,
132                        unsigned int src_vaddr,
133                        unsigned int size ); 
134
135///////////////////////////////////////////////////////////////////////////////
136// This ISR should not be used by the GIET_VM, because the DMA is only
137// used by the kernel in the boot phase, with a polling strategy.
138///////////////////////////////////////////////////////////////////////////////
139extern void _dma_isr( unsigned int irq_type,
140                      unsigned int irq_id,
141                      unsigned int channel );
142
143
144#endif
145
146// Local Variables:
147// tab-width: 4
148// c-basic-offset: 4
149// c-file-offsets:((innamespace . 0)(inline-open . 0))
150// indent-tabs-mode: nil
151// End:
152// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
153
Note: See TracBrowser for help on using the repository browser.