| [298] | 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> | 
|---|
| [320] | 9 | #include <hard_config.h> | 
|---|
|  | 10 | #include <utils.h> | 
|---|
| [456] | 11 | #include <tty0.h> | 
|---|
| [298] | 12 |  | 
|---|
| [320] | 13 | #if !defined(SEG_CMA_BASE) | 
|---|
|  | 14 | # error: You must define SEG_CMA_BASE in the hard_config.h file | 
|---|
|  | 15 | #endif | 
|---|
|  | 16 |  | 
|---|
| [437] | 17 | ///////////////////////////////////////////////////// | 
|---|
| [298] | 18 | unsigned int _cma_get_register( unsigned int channel, | 
|---|
|  | 19 | unsigned int index ) | 
|---|
|  | 20 | { | 
|---|
| [320] | 21 | unsigned int* vaddr = (unsigned int*)SEG_CMA_BASE + | 
|---|
| [298] | 22 | CHBUF_CHANNEL_SPAN*channel + index; | 
|---|
|  | 23 | return _io_extended_read( vaddr ); | 
|---|
|  | 24 | } | 
|---|
|  | 25 |  | 
|---|
| [437] | 26 | ///////////////////////////////////////////// | 
|---|
| [298] | 27 | void _cma_set_register( unsigned int channel, | 
|---|
|  | 28 | unsigned int index, | 
|---|
|  | 29 | unsigned int value ) | 
|---|
|  | 30 | { | 
|---|
| [320] | 31 | unsigned int* vaddr = (unsigned int*)SEG_CMA_BASE + | 
|---|
| [298] | 32 | CHBUF_CHANNEL_SPAN*channel + index; | 
|---|
|  | 33 | _io_extended_write( vaddr, value ); | 
|---|
|  | 34 | } | 
|---|
|  | 35 |  | 
|---|
| [437] | 36 |  | 
|---|
|  | 37 | ////////////////////////////////////// | 
|---|
| [298] | 38 | void _cma_isr( unsigned int irq_type, | 
|---|
|  | 39 | unsigned int irq_id, | 
|---|
|  | 40 | unsigned int channel ) | 
|---|
|  | 41 | { | 
|---|
| [448] | 42 | // get CMA channel status | 
|---|
|  | 43 | unsigned int status = _cma_get_register( channel, CHBUF_STATUS ); | 
|---|
|  | 44 |  | 
|---|
| [456] | 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 |  | 
|---|
| [448] | 51 | if (status == CHANNEL_SRC_DESC_ERROR ) | 
|---|
| [456] | 52 | _puts("impossible access to source chbuf descriptor\n"); | 
|---|
| [448] | 53 |  | 
|---|
|  | 54 | else if (status == CHANNEL_SRC_DATA_ERROR ) | 
|---|
| [456] | 55 | _puts("impossible access to source data buffer\n"); | 
|---|
| [448] | 56 |  | 
|---|
|  | 57 | else if (status == CHANNEL_DST_DESC_ERROR ) | 
|---|
| [456] | 58 | _puts("impossible access to destination chbuf descriptor\n"); | 
|---|
| [448] | 59 |  | 
|---|
|  | 60 | else if (status == CHANNEL_DST_DATA_ERROR ) | 
|---|
| [456] | 61 | _puts("impossible access to destination data buffer\n"); | 
|---|
| [448] | 62 |  | 
|---|
|  | 63 | else | 
|---|
| [456] | 64 | _puts("strange, because channel is not blocked..."); | 
|---|
| [448] | 65 |  | 
|---|
| [456] | 66 | // acknowledge IRQ and desactivates channel | 
|---|
| [448] | 67 | _cma_set_register( channel, CHBUF_RUN, 0 ); | 
|---|
| [298] | 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 |  | 
|---|