Changeset 699 for soft


Ignore:
Timestamp:
Aug 7, 2015, 5:42:07 PM (9 years ago)
Author:
guerin
Message:

kernel: use non-trivial CMA allocator

File:
1 edited

Legend:

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

    r698 r699  
    9696
    9797__attribute__((section(".kdata")))
    98 unsigned int _cma_channel_allocator    = 0;
     98unsigned int _cma_channel[NB_CMA_CHANNELS]  = {0};
    9999
    100100__attribute__((section(".kdata")))
     
    819819    if ( channel == -1 )
    820820    {
    821         _printf("\n[GIET_ERROR] in _sys_tty_alloc() : TTY channel already released\n");
     821        _printf("\n[GIET_ERROR] in _sys_tty_release() : TTY channel already released\n");
    822822        return -1;
    823823    }
     
    10391039
    10401040    // get a CMA channel index
    1041     cma_channel = _atomic_increment( &_cma_channel_allocator, 1 );
     1041    for ( cma_channel = 0 ; cma_channel < NB_CMA_CHANNELS ; cma_channel++ )
     1042    {
     1043        if ( !_cma_channel[cma_channel] )
     1044        {
     1045            _cma_channel[cma_channel] = 1;
     1046            break;
     1047        }
     1048    }
    10421049
    10431050    if ( cma_channel >= NB_CMA_CHANNELS )
     
    16491656int _sys_fbf_cma_alloc()
    16501657{
    1651    // get a new CMA channel index
    1652     unsigned int channel = _atomic_increment( &_cma_channel_allocator, 1 );
     1658    if ( _get_context_slot( CTX_CMA_FB_ID ) < NB_CMA_CHANNELS )
     1659    {
     1660        _printf("\n[GIET ERROR] in _sys_fbf_cma_alloc() : CMA channel already allocated\n");
     1661        return 0;
     1662    }
     1663
     1664    // get a new CMA channel index
     1665    unsigned int channel;
     1666
     1667    for ( channel = 0 ; channel < NB_CMA_CHANNELS ; channel++ )
     1668    {
     1669        if ( !_cma_channel[channel] )
     1670        {
     1671            _cma_channel[channel] = 1;
     1672            break;
     1673        }
     1674    }
    16531675
    16541676    if ( channel >= NB_CMA_CHANNELS )
    16551677    {
    1656         _printf("\n[GIET ERROR] in _sys_fbf_cma_alloc() : not enough CMA channels\n");
     1678        _printf("\n[GIET ERROR] in _sys_fbf_cma_alloc() : no CMA channel available\n");
    16571679        return -1;
    16581680    }
Note: See TracChangeset for help on using the changeset viewer.