source: soft/giet_vm/giet_drivers/cma_driver.h @ 478

Last change on this file since 478 was 448, checked in by alain, 10 years ago

Simplifying the NIC and CMA drivers.
Complex functionnalities have been moved to the sys_handler.c file.

File size: 4.5 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : cma_driver.h
3// Date     : 01/11/2013
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The cma_driver.c and cma_driver.h files are part ot the GIET-VM kernel.
8// This driver supports the SocLib vci_chbuf_dma component, that is
9// a multi channels, chained buffer DMA controller.
10//
11// This component can be used in conjonction with the SocLib vci_frame_buffer
12// to display images, or with the SocLib vci_multi_nic controller to tranfer
13// RX or TX packets between NIC and memory buffers.
14//
15// The SEG_CMA_BASE address must be defined in the hard_config.h file
16//
17// All accesses to CMA registers are done by the two _cma_set_register()
18// and _cma_get_register() low-level functions, that are handling virtual
19// to physical extended addressing.
20//
21// The higher level access functions are defined in the fbf_driver
22// and nic_driver files.
23///////////////////////////////////////////////////////////////////////////////////
24
25#ifndef _GIET_CMA_DRIVERS_H_
26#define _GIET_CMA_DRIVERS_H_
27
28///////////////////////////////////////////////////////////////////////////////////
29//  CMA channel registers offsets
30///////////////////////////////////////////////////////////////////////////////////
31
32enum CMA_registers_e
33{
34    CHBUF_RUN           = 0,    // write-only : channel activated
35    CHBUF_STATUS        = 1,    // read-only  : channel fsm state
36    CHBUF_SRC_DESC      = 2,    // read/write : source chbuf : descriptor base address
37    CHBUF_DST_DESC      = 3,    // read/write : destination chbuf : descriptor base address,
38    CHBUF_SRC_NBUFS     = 4,    // read/write : source chbuf : number of buffers,
39    CHBUF_DST_NBUFS     = 5,    // read/write : destination chbuf : number of buffers,
40    CHBUF_BUF_SIZE      = 6,    // read/write : buffer size for both source & destination 
41    CHBUF_PERIOD        = 7,    // read/write : period for status polling
42    CHBUF_SRC_EXT       = 8,    // read/write : source chbuf : descriptor base address
43    CHBUF_DST_EXT       = 9,    // read/write : destination chbuf : descriptor base address,
44    /****/
45    CHBUF_CHANNEL_SPAN  = 1024,
46};
47
48///////////////////////////////////////////////////////////////////////////////////
49//  CMA channel status values
50///////////////////////////////////////////////////////////////////////////////////
51
52enum CMA_status_e
53{
54    CHANNEL_IDLE,
55
56    CHANNEL_SRC_DATA_ERROR,
57    CHANNEL_DST_DATA_ERROR,
58    CHANNEL_SRC_DESC_ERROR,
59    CHANNEL_DST_DESC_ERROR,
60
61    CHANNEL_READ_SRC_STATUS,
62    CHANNEL_READ_SRC_STATUS_WAIT,
63    CHANNEL_READ_SRC_STATUS_DELAY,
64    CHANNEL_READ_SRC_BUFADDR,
65    CHANNEL_READ_SRC_BUFADDR_WAIT,
66
67    CHANNEL_READ_DST_STATUS,
68    CHANNEL_READ_DST_STATUS_WAIT,
69    CHANNEL_READ_DST_STATUS_DELAY,
70    CHANNEL_READ_DST_BUFADDR,
71    CHANNEL_READ_DST_BUFADDR_WAIT,
72
73    CHANNEL_READ_BURST,
74    CHANNEL_READ_REQ_FIRST,
75    CHANNEL_READ_WAIT_FIRST,
76    CHANNEL_READ_REQ_SECOND,
77    CHANNEL_READ_WAIT_SECOND,
78
79    CHANNEL_WRITE_BURST,
80    CHANNEL_WRITE_REQ_FIRST,
81    CHANNEL_WRITE_WAIT_FIRST,
82    CHANNEL_WRITE_REQ_SECOND,
83    CHANNEL_WRITE_WAIT_SECOND,
84
85    CHANNEL_SRC_STATUS_WRITE,
86    CHANNEL_SRC_STATUS_WRITE_WAIT,
87    CHANNEL_DST_STATUS_WRITE,
88    CHANNEL_DST_STATUS_WRITE_WAIT,
89    CHANNEL_SRC_NEXT_BUFFER,
90    CHANNEL_DST_NEXT_BUFFER,
91};
92
93///////////////////////////////////////////////////////////////////////////////////
94//    access functions
95///////////////////////////////////////////////////////////////////////////////////
96
97extern unsigned int _cma_get_register( unsigned int channel,
98                                       unsigned int index );
99
100extern void _cma_set_register( unsigned int channel,
101                               unsigned int index,
102                               unsigned int value );
103
104void _cma_channel_start( unsigned int       channel,
105                         unsigned long long src_paddr,
106                         unsigned int       src_nbufs,
107                         unsigned long long dst_paddr,
108                         unsigned int       dst_nbufs,
109                         unsigned int       buf_length );
110
111void _cma_channel_stop( unsigned int channel );
112
113extern void _cma_isr( unsigned int irq_type,
114                      unsigned int irq_id,
115                      unsigned int channel );
116
117#endif
118
119// Local Variables:
120// tab-width: 4
121// c-basic-offset: 4
122// c-file-offsets:((innamespace . 0)(inline-open . 0))
123// indent-tabs-mode: nil
124// End:
125// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
126
Note: See TracBrowser for help on using the repository browser.