Changeset 505


Ignore:
Timestamp:
Feb 10, 2015, 5:39:42 PM (10 years ago)
Author:
alain
Message:

Fixing a bug in _sys_fbf_cma_start() function.

Location:
soft/giet_vm/giet_kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_kernel/sys_handler.c

    r494 r505  
    198198    // get a new TTY terminal index
    199199    unsigned int channel = _atomic_increment( &_tty_channel_allocator, 1 );
    200     unsigned int thread  = _get_context_slot( CTX_TRDID_ID );
    201     unsigned int vspace  = _get_context_slot( CTX_VSID_ID );
    202200
    203201    if ( channel >= NB_TTY_CHANNELS )
     
    208206    else
    209207    {
    210         _printf("\n[GIET WARNING] TTY channel %d allocated "
    211                 " to thread %d in vspace %d\n", channel, thread, vspace );
    212208        _set_context_slot( CTX_TTY_ID, channel );
    213209        return 0;
     
    298294    // get a new timer index
    299295    unsigned int channel = _atomic_increment( &_tim_channel_allocator, 1 );
    300     unsigned int thread  = _get_context_slot( CTX_TRDID_ID );
    301     unsigned int vspace  = _get_context_slot( CTX_VSID_ID );
    302296
    303297    if ( channel >= NB_TIM_CHANNELS )
     
    308302    else
    309303    {
    310         _printf("\n[GIET WARNING] TIM channel %d allocated "
    311                 " to thread %d in vspace %d\n", channel, thread, vspace );
    312304        _set_context_slot( CTX_TIM_ID, channel );
    313305        return 0;
     
    577569    // start CMA transfer
    578570    _cma_set_register( cma_channel, CHBUF_BUF_SIZE , NIC_CONTAINER_SIZE );
    579     _cma_set_register( cma_channel, CHBUF_PERIOD   , 0 );                   // OUT_OF_ORDER mode
     571    _cma_set_register( cma_channel, CHBUF_PERIOD   , 0 );     // OUT_OF_ORDER
    580572    _cma_set_register( cma_channel, CHBUF_RUN      , 1 );
    581573
     
    589581
    590582    return 0;
    591 }  // end sys_nic_start()
     583}  // end _sys_nic_start()
    592584
    593585
     
    790782
    791783    // desactivates the CMA channel
    792     _cma_channel_stop( cma_channel );
     784    _cma_set_register( cma_channel, CHBUF_RUN , 0 );
    793785
    794786    return 0;
     
    938930   // get a new CMA channel index
    939931    unsigned int channel = _atomic_increment( &_cma_channel_allocator, 1 );
    940     unsigned int thread  = _get_context_slot( CTX_TRDID_ID );
    941     unsigned int vspace  = _get_context_slot( CTX_VSID_ID );
    942932
    943933    if ( channel >= NB_CMA_CHANNELS )
     
    948938    else
    949939    {
    950         _printf("\n[GIET WARNING] FBF_CMA channel %d allocated "
    951                 " to thread %d in vspace %d\n", channel, thread, vspace );
    952940        _set_context_slot( CTX_CMA_FB_ID, channel );
    953941        return 0;
     
    966954    unsigned int       flags;           // protection flags
    967955    unsigned int       ppn;             // physical page number
    968     unsigned long long chbuf_paddr;     // physical address of source chbuf descriptor
    969956
    970957    // get channel index
     
    10391026    _fbf_chbuf[channel].length = length;
    10401027
    1041     // Compute and register physical adress of the chbuf descriptor
     1028    // Compute and register physical adress of the fbf_chbuf descriptor
    10421029    vaddr = (unsigned int)(&_fbf_chbuf[channel]);
    10431030    _v2p_translate( (page_table_t*) ptab,
     
    10461033                    &flags );
    10471034 
    1048     chbuf_paddr = (((paddr_t)ppn) << 12) | (vaddr & 0x00000FFF);
    1049 
    1050     _fbf_chbuf_paddr[channel] = chbuf_paddr;
    1051 
     1035    _fbf_chbuf_paddr[channel] = (((paddr_t)ppn) << 12) | (vaddr & 0x00000FFF);
    10521036
    10531037    if ( USE_IOB )
    10541038    {
    1055         // SYNC request for channel descriptor
    1056         _mmc_sync( chbuf_paddr, 32 );
     1039        // SYNC request for fbf_chbuf descriptor
     1040        _mmc_sync( _fbf_chbuf_paddr[channel] , sizeof( fbf_chbuf_t ) );
    10571041    }
    10581042
     
    10651049        _fbf_chbuf[channel].buf0.desc,
    10661050        _fbf_chbuf[channel].buf1.desc,
    1067         chbuf_paddr );
    1068 #endif
    1069 
    1070     // call CMA driver to start transfer
    1071     _cma_channel_start( channel,
    1072                         chbuf_paddr,
    1073                         2,
    1074                         chbuf_paddr + 128,
    1075                         1,
    1076                         length );
     1051        _fbf_chbuf_paddr[channel] );
     1052#endif
     1053
     1054    // start CMA transfer
     1055    unsigned long long paddr = _fbf_chbuf_paddr[channel];
     1056    unsigned int src_chbuf_paddr_lsb = (unsigned int)(paddr & 0xFFFFFFFF);
     1057    unsigned int src_chbuf_paddr_ext = (unsigned int)(paddr >> 32);
     1058    unsigned int dst_chbuf_paddr_lsb = src_chbuf_paddr_lsb + 128;
     1059    unsigned int dst_chbuf_paddr_ext = src_chbuf_paddr_ext;
     1060
     1061    _cma_set_register( channel, CHBUF_SRC_DESC , src_chbuf_paddr_lsb );
     1062    _cma_set_register( channel, CHBUF_SRC_EXT  , src_chbuf_paddr_ext );
     1063    _cma_set_register( channel, CHBUF_SRC_NBUFS, 2 );
     1064    _cma_set_register( channel, CHBUF_DST_DESC , dst_chbuf_paddr_lsb );
     1065    _cma_set_register( channel, CHBUF_DST_EXT  , dst_chbuf_paddr_ext );
     1066    _cma_set_register( channel, CHBUF_DST_NBUFS, 1 );
     1067    _cma_set_register( channel, CHBUF_BUF_SIZE , length );
     1068    _cma_set_register( channel, CHBUF_PERIOD   , 300 );
     1069    _cma_set_register( channel, CHBUF_RUN      , 1 );
     1070
    10771071    return 0;
    10781072
     
    10901084#if NB_CMA_CHANNELS > 0
    10911085
    1092     volatile unsigned int long long user_buffer_desc;
    1093     volatile unsigned int           full = 1;
     1086    volatile unsigned int full = 1;
    10941087
    10951088    // get channel index
     
    10981091    if ( channel >= NB_CMA_CHANNELS )
    10991092    {
    1100         _printf("\n[GIET ERROR] in _sys_fbf_cma_display() : CMA channel index too large\n");
    1101         return -1;
    1102     }
     1093        _printf("\n[GIET ERROR] in _sys_fbf_cma_display() : "
     1094                "CMA channel index too large\n");
     1095        return -1;
     1096    }
     1097
     1098    // get fbf_chbuf descriptor pointer
     1099    fbf_chbuf_t* pdesc = &_fbf_chbuf[channel];     
    11031100
    11041101#if GIET_DEBUG_FBF_CMA
    11051102_printf("\n[FBF_CMA DEBUG] enters _sys_fb_cma_display()\n"
    1106         " - channel      = %d\n"
    1107         " - buffer       = %d\n",
    1108         channel, buffer_index );
     1103        " - cma channel     = %d\n"
     1104        " - buffer index    = %d\n"
     1105        " - buf0_desc value = %l\n"
     1106        " - buf1_desc value = %l\n"
     1107        " - fbf_desc  value = %l\n",
     1108        channel , buffer_index,
     1109        _fbf_chbuf[channel].buf0.desc,
     1110        _fbf_chbuf[channel].buf1.desc,
     1111        _fbf_chbuf[channel].fbf.desc );
    11091112#endif
    11101113
    11111114    if ( buffer_index == 0 )    // user buffer 0
    11121115    {
     1116        // INVAL L1 and L2 cache copies of user buffer descriptor,
     1117        // because it has been modified in RAM by the CMA component
     1118        _dcache_buf_invalidate( (unsigned int)pdesc , sizeof(buffer_descriptor_t) );
     1119        _mmc_inval( _fbf_chbuf_paddr[channel] , sizeof(buffer_descriptor_t) );
     1120
    11131121        // waiting user buffer released by the CMA component)
    11141122        while ( full )
    11151123        { 
    1116             // INVAL L1 and L2 cache copies of user buffer descriptor, because
    1117             // it has been modified in RAM by the CMA component
    1118             _dcache_buf_invalidate( (unsigned int)&_fbf_chbuf[channel].buf0.desc , 8 );
    1119             _mmc_inval( _fbf_chbuf_paddr[channel] , 8 );
    1120 
    1121             // get user buffer descriptor
    1122             user_buffer_desc = _fbf_chbuf[channel].buf0.desc;
    1123 
    1124             // get user buffer descriptor status
    1125             full = ( (unsigned int)(user_buffer_desc>>63) );
     1124            full = (unsigned int)(pdesc->buf0.desc >> 63);
    11261125        }
    11271126
    11281127        // SYNC request for the user buffer, because
    11291128        // it will be read from XRAM by the CMA component
    1130         _mmc_sync( user_buffer_desc, _fbf_chbuf[channel].length );
    1131 
    1132         // set user buffer status, and SYNC request, because this buffer
    1133         // descriptor will be read from XRAM by the CMA component
    1134         _fbf_chbuf[channel].buf0.desc = user_buffer_desc | 0x8000000000000000ULL;
    1135         _mmc_sync( _fbf_chbuf_paddr[channel] , 8 );
    1136 
    1137         // reset fbf buffer status, and SYNC request, because this buffer
    1138         // descriptor will be read from XRAM by the CMA component
    1139         _fbf_chbuf[channel].fbf.desc  = _fbf_chbuf[channel].fbf.desc & 0x7FFFFFFFFFFFFFFFULL;
    1140         _mmc_sync( _fbf_chbuf_paddr[channel] + 128 , 8 );
     1129        _mmc_sync( pdesc->buf0.desc , pdesc->length );
     1130
     1131        // set user buffer status
     1132        pdesc->buf0.desc = pdesc->buf0.desc | 0x8000000000000000ULL;
     1133
     1134        // reset fbf buffer status
     1135        pdesc->fbf.desc  = pdesc->fbf.desc  & 0x7FFFFFFFFFFFFFFFULL;
     1136
     1137        // SYNC request, because these buffer descriptors
     1138        // will be read from XRAM by the CMA component
     1139        _mmc_sync( _fbf_chbuf_paddr[channel] , sizeof(fbf_chbuf_t) );
    11411140    }
    11421141    else                        // user buffer 1
    11431142    {
     1143        // INVAL L1 and L2 cache copies of user buffer descriptor,
     1144        // because it has been modified in RAM by the CMA component
     1145        _dcache_buf_invalidate( (unsigned int)pdesc + 64, sizeof(buffer_descriptor_t) );
     1146        _mmc_inval( _fbf_chbuf_paddr[channel] + 64, sizeof(buffer_descriptor_t) );
     1147
    11441148        // waiting user buffer released by the CMA component)
    11451149        while ( full )
    11461150        { 
    1147             // INVAL L1 and L2 cache copies of user buffer descriptor, because
    1148             // it has been modified in RAM by the CMA component
    1149             _dcache_buf_invalidate( (unsigned int)&_fbf_chbuf[channel].buf1.desc , 8 );
    1150             _mmc_inval( _fbf_chbuf_paddr[channel] + 64 , 8 );
    1151 
    1152             // get user buffer descriptor
    1153             user_buffer_desc = _fbf_chbuf[channel].buf1.desc;
    1154 
    1155             // get user buffer descriptor status
    1156             full = ( (unsigned int)(user_buffer_desc>>63) );
     1151            full = (unsigned int)(pdesc->buf1.desc >> 63);
    11571152        }
    11581153
    11591154        // SYNC request for the user buffer, because
    11601155        // it will be read from XRAM by the CMA component
    1161         _mmc_sync( user_buffer_desc, _fbf_chbuf[channel].length );
    1162 
    1163         // set user buffer status, and SYNC request, because this buffer
    1164         // descriptor will be read from XRAM by the CMA component
    1165         _fbf_chbuf[channel].buf1.desc = user_buffer_desc | 0x8000000000000000ULL;
    1166         _mmc_sync( _fbf_chbuf_paddr[channel] , 8 );
    1167 
    1168         // reset fbf buffer status, and SYNC request, because this buffer
    1169         // descriptor will be read from XRAM by the CMA component
    1170         _fbf_chbuf[channel].fbf.desc  = _fbf_chbuf[channel].fbf.desc & 0x7FFFFFFFFFFFFFFFULL;
    1171         _mmc_sync( _fbf_chbuf_paddr[channel] + 128 , 8 );
     1156        _mmc_sync( pdesc->buf1.desc , pdesc->length );
     1157
     1158        // set user buffer status
     1159        pdesc->buf1.desc = pdesc->buf1.desc | 0x8000000000000000ULL;
     1160
     1161        // reset fbf buffer status
     1162        pdesc->fbf.desc  = pdesc->fbf.desc  & 0x7FFFFFFFFFFFFFFFULL;
     1163
     1164        // SYNC request, because these buffer descriptors
     1165        // will be read from XRAM by the CMA component
     1166        _mmc_sync( _fbf_chbuf_paddr[channel] , sizeof(fbf_chbuf_t) );
    11721167    }
    11731168
    11741169#if GIET_DEBUG_FBF_CMA
    1175 _printf(" - fbf    desc = %l\n"
    1176         " - buf0   desc = %l\n"
    1177         " - buf1   desc = %l\n",
    1178         _fbf_chbuf[channel].fbf.desc,
     1170_printf("\n[FBF_CMA DEBUG] exit _sys_fb_cma_display()\n"
     1171        " - buf0_desc value = %l\n"
     1172        " - buf1_desc value = %l\n"
     1173        " - fbf_desc  value = %l\n",
    11791174        _fbf_chbuf[channel].buf0.desc,
    1180         _fbf_chbuf[channel].buf1.desc );
     1175        _fbf_chbuf[channel].buf1.desc,
     1176        _fbf_chbuf[channel].fbf.desc );
    11811177#endif
    11821178
     
    12071203
    12081204    // Desactivate CMA channel
    1209     _cma_channel_stop( channel );
     1205    _cma_set_register( channel, CHBUF_RUN, 0 );
    12101206
    12111207    return 0;
  • soft/giet_vm/giet_kernel/sys_handler.h

    r494 r505  
    1616#include "kernel_locks.h"
    1717
    18 ///////////////////////////////////////////////////////////////////////////////////
     18///////////////////////////////////////////////////////////////////////////////
    1919//     Syscall Vector Table (indexed by syscall index)
    20 ///////////////////////////////////////////////////////////////////////////////////
     20///////////////////////////////////////////////////////////////////////////////
    2121
    2222extern const void * _syscall_vector[64];
    2323
    24 ///////////////////////////////////////////////////////////////////////////////////
     24///////////////////////////////////////////////////////////////////////////////
    2525// This structure is used by the nic_chbuf_t and fbf_chbuf_t structures.
    26 // It describes a single buffer descriptor. The useful information is contained
    27 // in one single 64 bits word (desc field):
     26// It describes a single buffer descriptor. The useful information is
     27// contained in one single 64 bits word (desc field):
    2828// - the 48 LSB bits contain the buffer physical address
    2929// - the MSB bit 63 indicates the buffer state (empty if 0)
    3030// This descriptor must be aligned on a cache line (64 bytes) to simplify
    3131// the software L2/L3 cache coherence when the IO bridge is used.
    32 ///////////////////////////////////////////////////////////////////////////////////
     32///////////////////////////////////////////////////////////////////////////////
    3333
    3434typedef struct buffer_descriptor_s
     
    3838} buffer_descriptor_t;
    3939 
    40 ///////////////////////////////////////////////////////////////////////////////////
     40///////////////////////////////////////////////////////////////////////////////
    4141// This structure is used by the CMA component to move a stream
    4242// of images from two user buffers to the frame buffer in kernel space.
     
    4646// - The length field define the buffer size (bytes)
    4747// This structure must be 64 bytes aligned.
    48 ///////////////////////////////////////////////////////////////////////////////////
     48///////////////////////////////////////////////////////////////////////////////
    4949
    5050typedef struct fbf_chbuf_s
     
    5757} fbf_chbuf_t;   
    5858
    59 //////////////////////////////////////////////////////////////////////////////////
     59///////////////////////////////////////////////////////////////////////////////
    6060// This structure is used by the CMA component to move a stream of containers
    6161// between the NIC chbuf containing 2 buffers, and a kernel chbuf
     
    6565// The actual number of buffers used in the chbuf is defined by (xmax * ymax).
    6666// This structure must be 64 bytes aligned.
    67 //////////////////////////////////////////////////////////////////////////////////
     67///////////////////////////////////////////////////////////////////////////////
    6868
    6969typedef struct nic_chbuf_s
     
    7474} nic_chbuf_t;
    7575
    76 //////////////////////////////////////////////////////////////////////////////////
     76///////////////////////////////////////////////////////////////////////////////
    7777//    TTY related syscall handlers
    78 //////////////////////////////////////////////////////////////////////////////////
     78///////////////////////////////////////////////////////////////////////////////
    7979
    8080int _sys_tty_alloc();
Note: See TracChangeset for help on using the changeset viewer.