source: soft/giet_vm/giet_drivers/cma_driver.c @ 396

Last change on this file since 396 was 320, checked in by alain, 10 years ago

All drivers have been modified to use only the information
contained in the hard_config.h file

File size: 3.0 KB
RevLine 
[298]1///////////////////////////////////////////////////////////////////////////////////
2// File      : cma_driver.c
3// Date      : 01/03/2014
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// both RX and TX packets between NIC and memory buffers.
[320]14//
15// The SEG_DMA_BASE address must be defined in the hard_config.h file
16////////////////////////////////////////////////////////////////////////////////////
[298]17// Implementation notes:
18// 1. The higher level access functions can be found in the fbf_driver and
19//    nic_driver files.
20// 2. All accesses to CMA registers are done by the two
21//    _cma_set_register() and _cma_get_register() low-level functions,
22//    that are handling virtual / physical extended addressing.
23///////////////////////////////////////////////////////////////////////////////////
24
25#include <cma_driver.h>
[320]26#include <hard_config.h>        
27#include <utils.h>
[298]28
[320]29#if !defined(SEG_CMA_BASE)
30# error: You must define SEG_CMA_BASE in the hard_config.h file
31#endif
32
[298]33///////////////////////////////////////////////////////////////////////////////
34// This low_level function returns the value contained in register (index).
35///////////////////////////////////////////////////////////////////////////////
36unsigned int _cma_get_register( unsigned int channel,
37                                unsigned int index )
38{
[320]39    unsigned int* vaddr = (unsigned int*)SEG_CMA_BASE + 
[298]40                           CHBUF_CHANNEL_SPAN*channel + index;
41    return _io_extended_read( vaddr );
42}
43
44///////////////////////////////////////////////////////////////////////////////
45// This low-level function set a new value in register (index).
46///////////////////////////////////////////////////////////////////////////////
47void _cma_set_register( unsigned int channel,
48                        unsigned int index,
49                        unsigned int value ) 
50{
[320]51    unsigned int* vaddr = (unsigned int*)SEG_CMA_BASE + 
[298]52                           CHBUF_CHANNEL_SPAN*channel + index;
53    _io_extended_write( vaddr, value );
54}
55
56///////////////////////////////////////////////////////////////////////////////
57// This ISR handles the IRQ generated by a CMA channel.
58///////////////////////////////////////////////////////////////////////////////
59void _cma_isr( unsigned int irq_type,
60               unsigned int irq_id,
61               unsigned int channel )
62{
[320]63    _printf("\n[GIET ERROR] _cma_isr() not implemented\n");
[298]64    _exit();
65}
66
67// Local Variables:
68// tab-width: 4
69// c-basic-offset: 4
70// c-file-offsets:((innamespace . 0)(inline-open . 0))
71// indent-tabs-mode: nil
72// End:
73// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
74
Note: See TracBrowser for help on using the repository browser.