Ignore:
Timestamp:
Dec 5, 2014, 3:38:31 PM (10 years ago)
Author:
alain
Message:

Defining the NIC and CMA drivers (validated by the classif application).
Updating other drivers to comply with the new tty0 common file.

Location:
soft/giet_vm/giet_drivers
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_drivers/bdv_driver.c

    r437 r456  
    2020#include <ioc_driver.h>
    2121#include <utils.h>
    22 #include <tty_driver.h>
     22#include <tty0.h>
    2323#include <ctx_handler.h>
    2424
    25 #if !defined(GIET_NO_HARD_CC)
    26 # error: You must define GIET_NO_HARD_CC in the giet_config.h file
    27 #endif
    28 
    2925///////////////////////////////////////////////////////////////////////////////
    3026// BDV global variables
    3127///////////////////////////////////////////////////////////////////////////////
    3228
    33 #define in_unckdata __attribute__((section (".unckdata")))
    34 #define in_kdata __attribute__((section (".kdata")))
    35 
    36 #if GIET_NO_HARD_CC
    37 in_unckdata giet_lock_t           _bdv_lock __attribute__((aligned(64)));
    38 in_unckdata volatile unsigned int _bdv_status;
    39 in_unckdata volatile unsigned int _bdv_gtid;
    40 #else
    41 in_kdata giet_lock_t           _bdv_lock __attribute__((aligned(64)));
    42 in_kdata volatile unsigned int _bdv_status;
    43 in_kdata volatile unsigned int _bdv_gtid;
    44 #endif
     29spin_lock_t  _bdv_lock __attribute__((aligned(64)));
     30unsigned int _bdv_status;
     31unsigned int _bdv_gtid;
    4532
    4633///////////////////////////////////////////////////////////////////////////////
     
    11097
    11198    // get the lock protecting BDV
    112     _get_lock(&_bdv_lock);
    113 
    114 #if GIET_DEBUG_IOC_DRIVER
    115 _puts("\n[BDV DEBUG] _bdv_access() : P[");
    116 _putd( x );
    117 _puts(",");
    118 _putd( y );
    119 _puts(",");
    120 _putd( p );
    121 _puts("] get bdv_lock at cycle ");
    122 _pud( _get_proctime() );
     99    _lock_acquire( &_bdv_lock );
     100
     101#if GIET_DEBUG_IOC_DRIVER
     102_puts("\n[BDV DEBUG] _bdv_access() : P[");
     103_putd( x );
     104_puts(",");
     105_putd( y );
     106_puts(",");
     107_putd( p );
     108_puts("] get _bdv_lock at cycle ");
     109_putd( _get_proctime() );
    123110_puts("\n");
    124111#endif
     
    172159
    173160        // release lock
    174         _release_lock(&_bdv_lock);     
     161        _lock_release( &_bdv_lock );     
    175162    }
    176163    // in USER or KERNEL mode, we deschedule the task.
     
    233220        // reset _bdv_status and release lock
    234221        _bdv_status = BLOCK_DEVICE_IDLE;
    235         _release_lock(&_bdv_lock);     
     222        _lock_release( &_bdv_lock );     
    236223    }
    237224
     
    246233_putd( _get_proctime() );
    247234_puts(" / error = ");
    248 _putd( error )
     235_putd( error );
    249236_puts("\n");
    250237#endif
  • soft/giet_vm/giet_drivers/bdv_driver.h

    r437 r456  
    4848#define _GIET_BDV_DRIVER_H_
    4949
    50 #include "utils.h"
    51 
    52 ///////////////////////////////////////////////////////////////////////////////////
    53 // BDV global variables
    54 ///////////////////////////////////////////////////////////////////////////////////
    55 
    56 extern giet_lock_t           _bdv_lock;    // BDV is a shared ressource
    57 extern volatile unsigned int _bdv_status;  // required for IRQ signaling
    58 extern volatile unsigned int _bdv_gtid;    // descheduled task id = gpid<<16 + ltid
     50#include "locks.h"
    5951
    6052///////////////////////////////////////////////////////////////////////////////////
     
    9284    BLOCK_DEVICE_ERROR,
    9385};
     86
     87///////////////////////////////////////////////////////////////////////////////
     88// BDV global variables
     89///////////////////////////////////////////////////////////////////////////////
     90
     91extern spin_lock_t  _bdv_lock;
     92extern unsigned int _bdv_status;
     93extern unsigned int _bdv_gtid;
    9494
    9595///////////////////////////////////////////////////////////////////////////////////
  • soft/giet_vm/giet_drivers/cma_driver.c

    r448 r456  
    99#include <hard_config.h>         
    1010#include <utils.h>
     11#include <tty0.h>
    1112
    1213#if !defined(SEG_CMA_BASE)
     
    6667    unsigned int status = _cma_get_register( channel, CHBUF_STATUS );
    6768
     69    _puts("\n[CMA WARNING] IRQ received for CMA channel ");
     70    _putd( channel );
     71    _puts(" blocked at cycle ");
     72    _putd( _get_proctime() );
     73    _puts("\nreset the CMA channel : ");
     74
    6875    if (status == CHANNEL_SRC_DESC_ERROR )
    69         _printf("\n[CMA WARNING] CMA channel %d blocked at cycle %d : "
    70                 "impossible access to source chbuf descriptor\n",
    71                 channel, _get_proctime() );
     76        _puts("impossible access to source chbuf descriptor\n");
    7277
    7378    else if (status == CHANNEL_SRC_DATA_ERROR )
    74         _printf("\n[CMA WARNING] CMA channel %d blocked at cycle %d : "
    75                 "impossible access to source data buffer\n",
    76                 channel, _get_proctime() );
     79        _puts("impossible access to source data buffer\n");
    7780
    7881    else if (status == CHANNEL_DST_DESC_ERROR )
    79         _printf("\n[CMA WARNING] CMA channel %d blocked at cycle %d : "
    80                 "impossible access to destination chbuf descriptor\n",
    81                 channel, _get_proctime() );
     82        _puts("impossible access to destination chbuf descriptor\n");
    8283
    8384    else if (status == CHANNEL_DST_DATA_ERROR )
    84         _printf("\n[CMA WARNING] CMA channel %d blocked at cycle %d : "
    85                 "impossible access to destination data buffer\n",
    86                 channel, _get_proctime() );
     85        _puts("impossible access to destination data buffer\n");
    8786
    8887    else
    89         _printf("\n[CMA WARNING] CMA channel %d : "
    90                 "... strange IRQ received, but channel not blocked...",
    91                 channel, _get_proctime() );
     88        _puts("strange, because channel is not blocked...");
    9289   
    93     // acknowledge IRQ
     90    // acknowledge IRQ and desactivates channel
    9491    _cma_set_register( channel, CHBUF_RUN, 0 );
    9592}
  • soft/giet_vm/giet_drivers/dma_driver.c

    r437 r456  
    99#include <hard_config.h>
    1010#include <dma_driver.h>
    11 #include <tty_driver.h>
     11#include <tty0.h>
    1212#include <vmem.h>
    1313#include <utils.h>
  • soft/giet_vm/giet_drivers/hba_driver.c

    r437 r456  
    1616#include <ioc_driver.h>
    1717#include <utils.h>
    18 #include <tty_driver.h>
     18#include <tty0.h>
    1919#include <iob_driver.h>
    2020#include <ctx_handler.h>
  • soft/giet_vm/giet_drivers/ioc_driver.c

    r437 r456  
    2525#include <rdk_driver.h>
    2626#include <utils.h>
    27 #include <tty_driver.h>
     27#include <tty0.h>
    2828#include <iob_driver.h>
    2929#include <ctx_handler.h>
  • soft/giet_vm/giet_drivers/mmc_driver.c

    r437 r456  
    88#include <giet_config.h>
    99#include <mmc_driver.h>
    10 #include <tty_driver.h>
     10#include <tty0.h>
    1111#include <utils.h>
    1212#include <io.h>
     
    3737
    3838///////////////////////////////////////////////////////////////////////////////
    39 // This low level function returns the value contained in register "index"
     39// This low level function returns the value contained in register
     40// defined by the ("func" / "index") arguments,
    4041// in the MMC component contained in cluster "cluster_xy"
    4142///////////////////////////////////////////////////////////////////////////////
     
    5455
    5556///////////////////////////////////////////////////////////////////////////////
    56 // This low level function sets a new value in register "index"
     57// This low level function sets a new value in register
     58// defined by the ("func" / "index") arguments,
    5759// in the MMC component contained in cluster "cluster_xy"
    5860///////////////////////////////////////////////////////////////////////////////
  • soft/giet_vm/giet_drivers/mwr_driver.c

    r437 r456  
    2020#include <mwr_driver.h>
    2121#include <utils.h>
     22#include <tty0.h>
    2223
    2324#if !defined(X_SIZE)
  • soft/giet_vm/giet_drivers/nic_driver.c

    r448 r456  
    1010#include <cma_driver.h>
    1111#include <utils.h>
     12#include <tty0.h>
    1213#include <ctx_handler.h>
    1314#include <vmem.h>
     
    4950#endif
    5051
    51 #if !defined( GIET_NIC_CHBUF_NBUFS )
    52 # error: You must define GIET_NIC_CHBUF_NBUFS in the giet_config.h file
    53 #endif
    54 
    55 #if !defined( GIET_NIC_CHBUF_SIZE )
    56 # error: You must define GIET_NIC_CHBUF_SIZE in the giet_config.h file
    57 #endif
    58 
    59 #if !defined( GIET_NIC_CHBUF_TIMEOUT )
    60 # error: You must define GIET_NIC_CHBUF_TIMEOUT in the giet_config.h file
     52#if !defined( GIET_NIC_NBUFS )
     53# error: You must define GIET_NIC_NBUFS in the giet_config.h file
     54#endif
     55
     56#if !defined( GIET_NIC_BUFSIZE )
     57# error: You must define GIET_NIC_BUFSIZE in the giet_config.h file
     58#endif
     59
     60#if !defined( GIET_NIC_TIMEOUT )
     61# error: You must define GIET_NIC_TIMEOUT in the giet_config.h file
    6162#endif
    6263
     
    7071{
    7172    unsigned int* vaddr = (unsigned int*)SEG_NIC_BASE +
    72                            NIC_CHANNEL_SPAN * channel + index;
     73                           NIC_CHANNEL_SPAN * channel + 0x1000 + index;
    7374    return _io_extended_read( vaddr );
    7475}
     
    8283{
    8384    unsigned int* vaddr = (unsigned int*)SEG_NIC_BASE +
    84                            NIC_CHANNEL_SPAN * channel + index;
     85                           NIC_CHANNEL_SPAN * channel + 0x1000 + index;
    8586    _io_extended_write( vaddr, value );
    8687}
     
    9293{
    9394    unsigned int* vaddr = (unsigned int*)SEG_NIC_BASE +
    94                            NIC_CHANNEL_SPAN * NB_NIC_CHANNELS + index;
     95                           NIC_CHANNEL_SPAN * 8 + index;
    9596    return _io_extended_read( vaddr );
    9697}
     
    103104{
    104105    unsigned int* vaddr = (unsigned int*)SEG_NIC_BASE +
    105                            NIC_CHANNEL_SPAN * NB_NIC_CHANNELS + index;
     106                           NIC_CHANNEL_SPAN * 8 + index;
    106107    _io_extended_write( vaddr, value );
    107108}
    108109
    109110////////////////////////////////////////////
    110 int _nic_global_init( unsigned int channels,
    111                       unsigned int vis,
    112                       unsigned int bc_enable,
    113                       unsigned int bypass_enable )
    114 {
    115     _nic_set_global_register( NIC_G_VIS          , vis );
    116     _nic_set_global_register( NIC_G_NB_CHAN      , channels );
     111int _nic_global_init( unsigned int bc_enable,
     112                      unsigned int bypass_enable,
     113                      unsigned int tdm_enable,
     114                      unsigned int tdm_period )
     115{
    117116    _nic_set_global_register( NIC_G_BC_ENABLE    , bc_enable );
    118117    _nic_set_global_register( NIC_G_BYPASS_ENABLE, bypass_enable );
    119     _nic_set_global_register( NIC_G_ON           , 1 );
     118    _nic_set_global_register( NIC_G_TDM_ENABLE   , tdm_enable );
     119    _nic_set_global_register( NIC_G_TDM_PERIOD   , tdm_period );
     120    _nic_set_global_register( NIC_G_VIS          , 0 );     // channels activated later
     121    _nic_set_global_register( NIC_G_ON           , 1 );   
    120122
    121123    return 0;
     
    128130                        unsigned int mac2 )
    129131{
     132    unsigned int vis = _nic_get_global_register( NIC_G_VIS );
     133    vis |= (0x1 << channel );
     134
     135    _nic_set_global_register( NIC_G_MAC_4 + channel, mac4 );
     136    _nic_set_global_register( NIC_G_MAC_2 + channel, mac2 );
     137    _nic_set_global_register( NIC_G_VIS            , vis );
     138   
    130139    unsigned int base     = SEG_NIC_BASE;
    131140    unsigned int extend   = (X_IO << Y_WIDTH) + Y_IO;
     
    133142    if ( is_rx )
    134143    {
    135         _nic_set_channel_register( channel, NIC_RX_DESC_LO_0 + 4096, base );
    136         _nic_set_channel_register( channel, NIC_RX_DESC_LO_1 + 4096, base + 0x1000 );
    137         _nic_set_channel_register( channel, NIC_RX_DESC_HI_0       , extend );
    138         _nic_set_channel_register( channel, NIC_RX_DESC_HI_1       , extend );
    139         _nic_set_channel_register( channel, NIC_RX_RUN             , 1 );
     144        _nic_set_channel_register( channel, NIC_RX_DESC_LO_0, base          );
     145        _nic_set_channel_register( channel, NIC_RX_DESC_LO_1, base + 0x1000 );
     146        _nic_set_channel_register( channel, NIC_RX_DESC_HI_0, extend        );
     147        _nic_set_channel_register( channel, NIC_RX_DESC_HI_1, extend        );
     148        _nic_set_channel_register( channel, NIC_RX_RUN      , 1            );
    140149    }
    141150    else
    142151    {
    143         _nic_set_channel_register( channel, NIC_TX_DESC_LO_0 + 4096, base + 0x2000 );
    144         _nic_set_channel_register( channel, NIC_TX_DESC_LO_1 + 4096, base + 0x3000 );
    145         _nic_set_channel_register( channel, NIC_TX_DESC_HI_0       , extend );
    146         _nic_set_channel_register( channel, NIC_TX_DESC_HI_1       , extend );
    147         _nic_set_channel_register( channel, NIC_TX_RUN             , 1 );
     152        _nic_set_channel_register( channel, NIC_TX_DESC_LO_0, base + 0x2000 );
     153        _nic_set_channel_register( channel, NIC_TX_DESC_LO_1, base + 0x3000 );
     154        _nic_set_channel_register( channel, NIC_TX_DESC_HI_0, extend        );
     155        _nic_set_channel_register( channel, NIC_TX_DESC_HI_1, extend        );
     156        _nic_set_channel_register( channel, NIC_TX_RUN      , 1            );
    148157    }
    149158
    150     _nic_set_channel_register( channel, NIC_MAC_4              , mac4 );
    151     _nic_set_channel_register( channel, NIC_MAC_2              , mac2 );
    152    
    153159    return 0;
    154160}
  • soft/giet_vm/giet_drivers/nic_driver.h

    r448 r456  
    3939///////////////////////////////////////////////////////////////////////////////////
    4040
    41 enum SoclibMultiNicHyperviseurRegisters {
     41enum SoclibMultiNicHyperRegisters {
    4242    NIC_G_VIS                        = 0,   // bitfield : bit N = 0 -> channel N disabled
    4343    NIC_G_ON                         = 1,   // boolean : NIC component activated
    44     NIC_G_NB_CHAN                    = 2,   // Number of channels present in this NIC (read only)
     44    NIC_G_NB_CHAN                    = 2,   // Number of channels (read only)
    4545    NIC_G_BC_ENABLE                  = 3,   // boolean : Enable Broadcast if non zero
    4646    NIC_G_TDM_ENABLE                 = 4,   // boolean : TDM Scheduler if non zero
     
    5757    NIC_G_NPKT_RX_DES_TOO_SMALL      = 35,  // number of discarded too small RX packets (<60B)
    5858    NIC_G_NPKT_RX_DES_TOO_BIG        = 36,  // number of discarded too big RX packets (>1514B)
    59     NIC_G_NPKT_RX_DES_MFIFO_FULL     = 37,  // number of discarded RX packets because fifo full
    60     NIC_G_NPKT_RX_DES_CRC_FAIL       = 38,  // number of discarded RX packets because CRC32 failure
     59    NIC_G_NPKT_RX_DES_MFIFO_FULL     = 37,  // number of discarded RX packets fifo full
     60    NIC_G_NPKT_RX_DES_CRC_FAIL       = 38,  // number of discarded RX packets CRC32 failure
    6161
    6262    NIC_G_NPKT_RX_DISPATCH_RECEIVED  = 39,  // number of packets received by RX_DISPATCH FSM
    6363    NIC_G_NPKT_RX_DISPATCH_BROADCAST = 40,  // number of broadcast RX packets received
    64     NIC_G_NPKT_RX_DISPATCH_DST_FAIL  = 41,  // number of discarded RX packets for DST MAC not found
     64    NIC_G_NPKT_RX_DISPATCH_DST_FAIL  = 41,  // number of discarded RX packets DST MAC not found
    6565    NIC_G_NPKT_RX_DISPATCH_CH_FULL   = 42,  // number of discarded RX packets for channel full
    6666
     
    6868    NIC_G_NPKT_TX_DISPATCH_TOO_SMALL = 44,  // number of discarded too small TX packets (<60B)
    6969    NIC_G_NPKT_TX_DISPATCH_TOO_BIG   = 45,  // number of discarded too big TX packets (>1514B)
    70     NIC_G_NPKT_TX_DISPATCH_SRC_FAIL  = 46,  // number of discarded TX packets for SRC MAC failed
     70    NIC_G_NPKT_TX_DISPATCH_SRC_FAIL  = 46,  // number of discarded TX packets SRC MAC failed
    7171    NIC_G_NPKT_TX_DISPATCH_BROADCAST = 47,  // number of broadcast TX packets received
    7272    NIC_G_NPKT_TX_DISPATCH_BYPASS    = 48,  // number of bypassed TX->RX packets
     
    103103///////////////////////////////////////////////////////////////////////////////////
    104104
    105 extern int _nic_global_init( unsigned int channels,
    106                              unsigned int vis,
    107                              unsigned int bc_enable,
    108                              unsigned int bypass_enable );
     105extern unsigned int _nic_get_channel_register( unsigned int channel,
     106                                               unsigned int index );
     107
     108extern void _nic_set_channel_register( unsigned int channel,
     109                                       unsigned int index,
     110                                       unsigned int value );
     111
     112extern unsigned int _nic_get_global_register( unsigned int index );
     113
     114extern void _nic_set_global_register( unsigned int index,
     115                                      unsigned int value );
     116
     117extern int _nic_global_init( unsigned int bc_enable,
     118                             unsigned int bypass_enable,
     119                             unsigned int tdm_enable,
     120                             unsigned int tdm_period );
    109121
    110122extern int _nic_channel_start( unsigned int channel,
  • soft/giet_vm/giet_drivers/rdk_driver.c

    r437 r456  
    1111#include <rdk_driver.h>
    1212#include <utils.h>
     13#include <tty0.h>
    1314
    1415#if !defined(SEG_RDK_BASE)
  • soft/giet_vm/giet_drivers/sdc_driver.c

    r437 r456  
    88#include <hard_config.h>
    99#include <sdc_driver.h>
    10 #include <tty_driver.h>
     10#include <tty0.h>
    1111#include <utils.h>
    1212
  • soft/giet_vm/giet_drivers/spi_driver.c

    r437 r456  
    55// Copyright (c) UPMC-LIP6
    66///////////////////////////////////////////////////////////////////////////////////
     7
    78#include <spi_driver.h>
    89#include <utils.h>
     10#include <tty0.h>
    911
    1012///////////////////////////////////////////////////////////////////////////////
  • soft/giet_vm/giet_drivers/tim_driver.c

    r437 r456  
    1010#include <tim_driver.h>
    1111#include <utils.h>
     12#include <tty0.h>
    1213
    1314#if !defined(SEG_TIM_BASE)
  • soft/giet_vm/giet_drivers/tty_driver.c

    r437 r456  
    1212#include <ctx_handler.h>
    1313#include <utils.h>
     14#include <tty0.h>
    1415
    1516#if !defined(SEG_TTY_BASE)
     
    2122#endif
    2223
    23 #if !defined(GIET_NO_HARD_CC)
    24 # error: You must define GIET_NO_HARD_CC in the giet_config.h file
     24#if (NB_TTY_CHANNELS == 0)
     25# error: The NB_TTY_CHANNELS in the hard_config.h file cannot be 0
    2526#endif
    2627
    27 #if (NB_TTY_CHANNELS < 1)
    28 # error: NB_TTY_CHANNELS cannot be smaller than 1!
    29 #endif
     28////////////////////////////////////////////////////////////////////////////////////
     29//               global variables
     30////////////////////////////////////////////////////////////////////////////////////
    3031
    31 //////////////////////////////////////////////////////////////////////////////
    32 //                global variables
    33 //////////////////////////////////////////////////////////////////////////////
     32simple_lock_t  _tty_tx_lock[NB_TTY_CHANNELS] __attribute__((aligned(64)));
    3433
    35 #define in_unckdata __attribute__((section (".unckdata")))
    36 #define in_kdata    __attribute__((section (".kdata")))
     34unsigned int   _tty_rx_buf[NB_TTY_CHANNELS];
     35unsigned int   _tty_rx_full[NB_TTY_CHANNELS];
    3736
    38 #if GIET_NO_HARD_CC
    39 in_unckdata volatile unsigned int _tty_rx_buf[NB_TTY_CHANNELS];
    40 in_unckdata volatile unsigned int _tty_rx_full[NB_TTY_CHANNELS];
    41 in_unckdata giet_lock_t _tty_lock[NB_TTY_CHANNELS] __attribute__((aligned(64)));
    42 #else
    43 in_kdata volatile unsigned int _tty_rx_buf[NB_TTY_CHANNELS];
    44 in_kdata volatile unsigned int _tty_rx_full[NB_TTY_CHANNELS];
    45 in_kdata giet_lock_t _tty_lock[NB_TTY_CHANNELS] __attribute__((aligned(64)));
    46 #endif
    47 
    48 //////////////////////////////////////////////////////////////////////////////
     37////////////////////////////////////////////////////////////////////////////////////
    4938//               access functions
    50 //////////////////////////////////////////////////////////////////////////////
     39////////////////////////////////////////////////////////////////////////////////////
    5140
    5241/////////////////////////////////////////////////////
     
    6756}
    6857
     58//////////////////////////////////////
     59void _tty_init( unsigned int channel )
     60{
     61    _tty_rx_full[channel] = 0;
     62}
    6963
    7064////////////////////////////////////////
  • soft/giet_vm/giet_drivers/tty_driver.h

    r437 r456  
    2424#define _GIET_TTY_DRIVERS_H_
    2525
    26 #include <utils.h>
     26#include "locks.h"
    2727
    2828///////////////////////////////////////////////////////////////////////////////////
     
    4040};
    4141
    42 ///////////////////////////////////////////////////////////////////////////////////
    43 //                   external variables
    44 ///////////////////////////////////////////////////////////////////////////////////
     42////////////////////////////////////////////////////////////////////////////////////
     43//               global variables
     44////////////////////////////////////////////////////////////////////////////////////
    4545
    46 extern volatile unsigned int _tty_rx_buf[];
     46extern simple_lock_t  _tty_tx_lock[];
    4747
    48 extern volatile unsigned int _tty_rx_full[];
    49 
    50 extern giet_lock_t _tty_lock[];
     48extern unsigned int   _tty_rx_buf[];
     49extern unsigned int   _tty_rx_full[];
    5150
    5251//////////////////////////////////////////////////////////////////////////////////
     
    6160                               unsigned int value );
    6261
    63 ///////////////////////////////////////////////////////////////////////////////////
     62extern void _tty_init( unsigned int channel );
     63
     64//////////////////////////////////////////////////////////////////////////////////
    6465//                 Interrupt Service Routine
    6566///////////////////////////////////////////////////////////////////////////////////
  • soft/giet_vm/giet_drivers/xcu_driver.c

    r437 r456  
    99#include <giet_config.h>
    1010#include <xcu_driver.h>
    11 #include <tty_driver.h>
     11#include <tty0.h>
    1212#include <mapping_info.h>
    1313#include <utils.h>
Note: See TracChangeset for help on using the changeset viewer.