Ignore:
Timestamp:
Feb 4, 2014, 2:16:37 AM (11 years ago)
Author:
cfuguet
Message:

Modifications on GIET-VM IOC driver:

  • Introducing new layer on the IOC driver. Every call to ioc_read, ioc_write, ioc_get_block_size or ioc_init

functions will call the specific driver of the used IOC
controller. Supported IOC controllers are (for now) :

  1. BDV (Soclib Block Device)
  2. HBA
  3. SPI (SDCARD - SPI controller)
  • All functions of IOC controllers drivers respect the same interface.
  • To specify the used IOC controller of the platform, a subtype field has been introduced on the map.xml file. This subtype field must be declared on the IOC periph instantiation. Available subtypes (for now) : BDV, HBA or SPI.
File:
1 edited

Legend:

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

    r258 r289  
    7777#include <ctx_handler.h>
    7878#include <mmc_driver.h>
     79#include <hba_driver.h>
    7980#include <vmem.h>
    8081
     
    124125{
    125126    volatile unsigned int* hba_address;
    126     hba_address = (unsigned int*)(&seg_hba_base) + (HBA_SPAN*channel);
     127    hba_address = (unsigned int*)(&seg_ioc_base) + (HBA_SPAN*channel);
    127128
    128129    if( channel >= NB_HBA_CHANNELS )
    129130    {
    130         _get_lock(&_tty_put_lock);
     131        _tty_get_lock( 0 );
    131132        _puts("\n[GIET ERROR] in _hba_get_status() : illegal channel\n");
    132         _release_lock(&_tty_put_lock);
     133        _tty_release_lock( 0 );
    133134        return 1;
    134135    }
     
    146147{
    147148    volatile unsigned int* hba_address;
    148     hba_address = (unsigned int*)(&seg_hba_base) + (HBA_SPAN*channel);
     149    hba_address = (unsigned int*)(&seg_ioc_base) + (HBA_SPAN*channel);
    149150
    150151    if( channel >= NB_HBA_CHANNELS )
    151152    {   
    152         _get_lock(&_tty_put_lock);
     153        _tty_get_lock( 0 );
    153154        _puts("\n[GIET ERROR] in _hba_reset_status() : illegal channel\n");
    154         _release_lock(&_tty_put_lock);
     155        _tty_release_lock( 0 );
    155156        return 1;
    156157    }
     
    191192    hba_cmd_table_t*   cmd_table;      // command table pointer
    192193
    193     // TODO The block size must be obtained from the hardware...
    194     block_size = 512;
     194    block_size = _hba_get_block_size();
    195195
    196196    // check buffer alignment
    197197    if( buf_vaddr & (block_size-1) )
    198198    {
    199         _get_lock(&_tty_put_lock);
     199        _tty_get_lock( 0 );
    200200        _puts("\n[GIET ERROR] in _hba_set_cmd() : user buffer not block aligned\n");
    201         _release_lock(&_tty_put_lock);
     201        _tty_release_lock( 0 );
    202202        return 1;
    203203    }
     
    207207    if ( channel_id == 0xFFFFFFFF )
    208208    {
    209         _get_lock(&_tty_put_lock);
     209        _tty_get_lock( 0 );
    210210        _puts("\n[GIET ERROR] in _hba_set_cmd() : no HBA channel allocated\n");
    211         _release_lock(&_tty_put_lock);
     211        _tty_release_lock( 0 );
    212212        return 1;
    213213    }
    214214
    215215    // get hba device address
    216     hba_address = (unsigned int*)(&seg_hba_base) + (HBA_SPAN * channel_id);
     216    hba_address = (unsigned int*)(&seg_ioc_base) + (HBA_SPAN * channel_id);
    217217
    218218    // get command list status
     
    223223    if( pxci & (1<<cmd_id ) )
    224224    {
    225         _get_lock(&_tty_put_lock);
     225        _tty_get_lock( 0 );
    226226        _puts("\n[GIET ERROR] in _hba_set_cmd() : command list full in channel \n");
    227227        _putd( channel_id );
    228228        _puts("\n");
    229         _release_lock(&_tty_put_lock);
     229        _tty_release_lock( 0 );
    230230        return 1;
    231231    }
     
    262262        if ( ko )
    263263        {
    264             _get_lock(&_tty_put_lock);
     264            _tty_get_lock( 0 );
    265265            _puts("[GIET ERROR] in _hba_set_cmd() : user buffer unmapped\n");
    266             _release_lock(&_tty_put_lock);
     266            _tty_release_lock( 0 );
    267267            return 1;
    268268        }
    269269        if ((flags & PTE_U) == 0)
    270270        {
    271             _get_lock(&_tty_put_lock);
     271            _tty_get_lock( 0 );
    272272            _puts("[GIET ERROR] in _hba_set_cmd() : user buffer not in user space\n");
    273             _release_lock(&_tty_put_lock);
     273            _tty_release_lock( 0 );
    274274            return 1;
    275275        }
    276276        if (((flags & PTE_W) == 0 ) && (is_read == 0) )
    277277        {
    278             _get_lock(&_tty_put_lock);
     278            _tty_get_lock( 0 );
    279279            _puts("[GIET ERROR] in _hba_set_cmd() : user buffer not writable\n");
    280             _release_lock(&_tty_put_lock);
     280            _tty_release_lock( 0 );
    281281            return 1;
    282282        }
     
    285285        if( buf_id > 245 )
    286286        {
    287             _get_lock(&_tty_put_lock);
     287            _tty_get_lock( 0 );
    288288            _puts("[GIET ERROR] in _hba_set_cmd() : max number of buffers is 248\n");
    289             _release_lock(&_tty_put_lock);
     289            _tty_release_lock( 0 );
    290290            return 1;
    291291        }
     
    415415// Returns 0 if success, > 0 if error.
    416416///////////////////////////////////////////////////////////////////
    417 unsigned int _hba_write( unsigned int  lba,
     417unsigned int _hba_write( unsigned int  mode,
     418                         unsigned int  lba,
    418419                         void*         buffer,
    419420                         unsigned int  count )
     
    427428// Returns 0 if success, > 0 if error.
    428429///////////////////////////////////////////////////////////////////
    429 unsigned int _hba_read( unsigned int  lba,
     430unsigned int _hba_read( unsigned int  mode,
     431                        unsigned int  lba,
    430432                        void*         buffer,
    431433                        unsigned int  count )
     
    434436}
    435437//////////////////////////////////////////////////////////////////
    436 // This function initializes for a given channel (k)
     438// This function initializes for a given channel
    437439// - the HBA hardware registers,
    438440// - the command list pointer,
     
    440442// - the command tables physical addresses array,
    441443//////////////////////////////////////////////////////////////////
    442 void _hba_init( unsigned int k )  // k == channel_index
     444unsigned int _hba_init( unsigned int channel )
    443445{
    444446    unsigned int ppn;
     
    452454
    453455    // HBA registers
    454     unsigned int*  hba_address = (unsigned int*)(&seg_hba_base) + (HBA_SPAN*k);
    455     hba_address = (unsigned int*)&seg_hba_base + HBA_SPAN * k;
    456 
    457     hba_address[HBA_PXCLB]  = (unsigned int)(&hba_cmd_list[k]);
     456    unsigned int*  hba_address;
     457    hba_address = (unsigned int*)&seg_ioc_base + HBA_SPAN * channel;
     458
     459    hba_address[HBA_PXCLB]  = (unsigned int)(&hba_cmd_list[channel]);
    458460    hba_address[HBA_PXCLBU] = 0;
    459461    hba_address[HBA_PXIE]   = 0x40000001;
     
    463465
    464466    // command list pointer       
    465     hba_cmd_slot[k] = 0;
     467    hba_cmd_slot[channel] = 0;
    466468
    467469    // Command list physical addresse
    468     vbase = (unsigned int)(&hba_cmd_list[k]);
     470    vbase = (unsigned int)(&hba_cmd_list[channel]);
    469471    fail = _v2p_translate( (page_table_t*)pt,
    470472                           vbase>>12,
     
    473475    if ( fail )
    474476    {
    475         _get_lock(&_tty_put_lock);
     477        _tty_get_lock( 0 );
    476478        _puts("[GIET ERROR] in _hba_init() : command list unmapped\n");
    477         _release_lock(&_tty_put_lock);
    478         _exit();
    479     }
    480     hba_cmd_list_paddr[k] = ((paddr_t)ppn) | (vbase & 0xFFF);
     479        _tty_release_lock( 0 );
     480        return 1;
     481    }
     482    hba_cmd_list_paddr[channel] = ((paddr_t)ppn) | (vbase & 0xFFF);
    481483
    482484    // Command tables physical addresses
    483485    for( c=0 ; c<32 ; c++ )
    484486    {
    485         vbase = (unsigned int)(&hba_cmd_table[k][c]);
     487        vbase = (unsigned int)(&hba_cmd_table[channel][c]);
    486488        fail = _v2p_translate( (page_table_t*)pt,
    487489                               vbase>>12,
     
    490492        if ( fail )
    491493        {
    492             _get_lock(&_tty_put_lock);
     494            _tty_get_lock( 0 );
    493495            _puts("[GIET ERROR] in _hba_init() : command table unmapped\n");
    494             _release_lock(&_tty_put_lock);
    495             _exit();
    496         }
    497         hba_cmd_table_paddr[k][c] = ((paddr_t)ppn) | (vbase & 0xFFF);
    498     }
     496            _tty_release_lock( 0 );
     497            return 1;
     498        }
     499        hba_cmd_table_paddr[channel][c] = ((paddr_t)ppn) | (vbase & 0xFFF);
     500    }
     501
     502    return 0;
    499503}
    500504
     505///////////////////////////////////////////////////////////////////////////////
     506//     _hba_get_block_size()
     507// This function returns the block_size of HBA controller
     508///////////////////////////////////////////////////////////////////////////////
     509unsigned int _hba_get_block_size()
     510{
     511    // TODO The block size must be obtained from the hardware...
     512    return 512;
     513}
    501514
    502515
Note: See TracChangeset for help on using the changeset viewer.