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

Last change on this file since 808 was 612, checked in by bellefin, 9 years ago

CMA driver: update the channel status values of the CMA component

File size: 2.5 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_STATUS_ERROR )
55        _puts("impossible access to source buffer status\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_STATUS_ERROR )
61        _puts("impossible access to destination buffer status\n");
62
63    else if (status == CHANNEL_DATA_ERROR )
64        _puts("impossible access to source or destination data buffer\n");
65
66    else
67        _puts("strange, because channel is not blocked...");
68   
69    // acknowledge IRQ and desactivates channel
70    _cma_set_register( channel, CHBUF_RUN, 0 );
71}
72
73// Local Variables:
74// tab-width: 4
75// c-basic-offset: 4
76// c-file-offsets:((innamespace . 0)(inline-open . 0))
77// indent-tabs-mode: nil
78// End:
79// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
80
Note: See TracBrowser for help on using the repository browser.