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

Last change on this file since 577 was 506, checked in by alain, 10 years ago

Simplifying the CMA driver.

File size: 2.4 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File      : cma_driver.c
3// Date      : 01/03/2014
4// Author    : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7
8#include <cma_driver.h>
9#include <hard_config.h>        
10#include <utils.h>
11#include <tty0.h>
12
13#if !defined(SEG_CMA_BASE)
14# error: You must define SEG_CMA_BASE in the hard_config.h file
15#endif
16
17/////////////////////////////////////////////////////
18unsigned int _cma_get_register( unsigned int channel,
19                                unsigned int index )
20{
21    unsigned int* vaddr = (unsigned int*)SEG_CMA_BASE + 
22                           CHBUF_CHANNEL_SPAN*channel + index;
23    return _io_extended_read( vaddr );
24}
25
26/////////////////////////////////////////////
27void _cma_set_register( unsigned int channel,
28                        unsigned int index,
29                        unsigned int value ) 
30{
31    unsigned int* vaddr = (unsigned int*)SEG_CMA_BASE + 
32                           CHBUF_CHANNEL_SPAN*channel + index;
33    _io_extended_write( vaddr, value );
34}
35
36
37//////////////////////////////////////
38void _cma_isr( unsigned int irq_type,
39               unsigned int irq_id,
40               unsigned int channel )
41{
42    // get CMA channel status
43    unsigned int status = _cma_get_register( channel, CHBUF_STATUS );
44
45    _puts("\n[CMA WARNING] IRQ received for CMA channel ");
46    _putd( channel );
47    _puts(" blocked at cycle ");
48    _putd( _get_proctime() );
49    _puts("\nreset the CMA channel : ");
50
51    if (status == CHANNEL_SRC_DESC_ERROR )
52        _puts("impossible access to source chbuf descriptor\n");
53
54    else if (status == CHANNEL_SRC_DATA_ERROR )
55        _puts("impossible access to source data buffer\n");
56
57    else if (status == CHANNEL_DST_DESC_ERROR )
58        _puts("impossible access to destination chbuf descriptor\n");
59
60    else if (status == CHANNEL_DST_DATA_ERROR )
61        _puts("impossible access to destination data buffer\n");
62
63    else
64        _puts("strange, because channel is not blocked...");
65   
66    // acknowledge IRQ and desactivates channel
67    _cma_set_register( channel, CHBUF_RUN, 0 );
68}
69
70// Local Variables:
71// tab-width: 4
72// c-basic-offset: 4
73// c-file-offsets:((innamespace . 0)(inline-open . 0))
74// indent-tabs-mode: nil
75// End:
76// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
77
Note: See TracBrowser for help on using the repository browser.