Ignore:
Timestamp:
Nov 3, 2014, 10:53:00 AM (10 years ago)
Author:
alain
Message:

Introducing dynamic allocation of peripheral channel(TTY, NIC, TIM, CMA)
Removint the ICU driver : ICU component not supported anymore.
Removing the FBF driver.

File:
1 edited

Legend:

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

    r320 r437  
    55// Copyright (c) UPMC-LIP6
    66///////////////////////////////////////////////////////////////////////////////////
    7 // The hba_driver.c and hba_driver.h files are part ot the GIET-VM kernel.
    8 // This driver supports the SocLib VciMultiAhci component, that is a multi-channels,
    9 // block oriented, external storage contrÃŽler, respecting the AHCI standard.
    10 //
    11 // The SEG_IOC_BASE virtual address must be defined in the hard_config.h file.
    12 //////////////////////////////////////////////////////////////////////////////////
    137// Implementation notes:
    14 //
    158// 1. In order to share code, the two _hba_read() and _hba_write() functions
    169//    call the same _hba_set_cmd() function.
    17 //
    1810// 2. All accesses to HBA registers are done by the two
    1911//    _hba_set_register() and _hba_get_register() low-level functions,
     
    4234
    4335//////////////////////////////////////////////////////////////////
    44 //  Global variables
     36//               Global variables
    4537//////////////////////////////////////////////////////////////////
    4638
     
    8981// buffer must be an integer number of blocks entirely contained in a single
    9082// page frame.
    91 // return 0 if success, > 0 if error
     83// return 0 if success, -1 if error
    9284///////////////////////////////////////////////////////////////////////////////
    9385unsigned int _hba_cmd_set( unsigned int  channel,     // channel index
     
    109101    if( buffer & (block_size-1) )
    110102    {
    111         _printf("\n[GIET ERROR] in _hba_set_cmd() : user buffer not block aligned\n");
    112         return 1;
     103        _puts("\n[GIET ERROR] in _hba_set_cmd() : user buffer not block aligned\n");
     104        return -1;
    113105    }
    114106
     
    120112    if( pxci & (1<<cmd_id ) )
    121113    {
    122         _printf("\n[GIET ERROR] in _hba_set_cmd() : command list full for channel %d\n",
    123                 channel );
    124         return 1;
     114        _puts("\n[GIET ERROR] in _hba_set_cmd() : command list full for channel ");
     115        _putd( channel );
     116        _puts("\n");
     117        return -1;
    125118    }
    126119
     
    188181        if ( ko )
    189182        {
    190             _printf("[GIET ERROR] in _hba_set_cmd() : user buffer unmapped\n");
    191             return 1;
     183            _puts("[GIET ERROR] in _hba_set_cmd() : user buffer unmapped\n");
     184            return -1;
    192185        }
    193186        if ((flags & PTE_U) == 0)
    194187        {
    195             _printf("[GIET ERROR] in _hba_set_cmd() : user buffer not in user space\n");
    196             return 1;
     188            _puts("[GIET ERROR] in _hba_set_cmd() : user buffer not in user space\n");
     189            return -1;
    197190        }
    198191        if (((flags & PTE_W) == 0 ) && (is_read == 0) )
    199192        {
    200             _printf("[GIET ERROR] in _hba_set_cmd() : user buffer not writable\n");
    201             return 1;
     193            _puts("[GIET ERROR] in _hba_set_cmd() : user buffer not writable\n");
     194            return -1;
    202195        }
    203196
     
    205198        if( buf_id > 245 )
    206199        {
    207             _printf("[GIET ERROR] in _hba_set_cmd() : max number of buffers is 248\n");
    208             return 1;
     200            _puts("[GIET ERROR] in _hba_set_cmd() : max number of buffers is 248\n");
     201            return -1;   
    209202        }
    210203
     
    218211            cmd_table->entry[buf_id].dbc  = count;
    219212
    220 #if GIET_DEBUG_HBA_DRIVER
    221 _printf("\n- buf_index = ");
    222 _putd( buf_id );
    223 _printf(" / paddr = ");
    224 _putl( paddr );
    225 _printf(" / count = ");
    226 _putd( count );
    227 _printf("\n");
    228 #endif
    229213            buf_id++;
    230214        }
     
    237221            cmd_table->entry[buf_id].dbc  = count;
    238222
    239 #if GIET_DEBUG_HBA_DRIVER
    240 _printf("\n- buf_index = ");
    241 _putd( buf_id );
    242 _printf(" / paddr = ");
    243 _putl( paddr );
    244 _printf(" / count = ");
    245 _putd( count );
    246 _printf("\n");
    247 #endif
    248223            buf_id++;
    249224        }
     
    257232            cmd_table->entry[buf_id].dbc  = count;
    258233
    259 #if GIET_DEBUG_HBA_DRIVER
    260 _printf("\n- buf_index = ");
    261 _putd( buf_id );
    262 _printf(" / paddr = ");
    263 _putl( paddr );
    264 _printf(" / count = ");
    265 _putd( count );
    266 _printf("\n");
    267 #endif
    268234            buf_id++;
    269235
     
    274240            cmd_table->entry[buf_id].dbc  = count;
    275241
    276 #if GIET_DEBUG_HBA_DRIVER
    277 _printf("\n- buf_index = ");
    278 _putd( buf_id );
    279 _printf(" / paddr = ");
    280 _putl( paddr );
    281 _printf(" / count = ");
    282 _putd( count );
    283 _printf("\n");
    284 #endif
    285242            buf_id++;
    286243        }
     
    293250            cmd_table->entry[buf_id].dbc  = count;
    294251
    295 #if GIET_DEBUG_HBA_DRIVER
    296 _printf("\n- buf_index = ");
    297 _putd( buf_id );
    298 _printf(" / paddr = ");
    299 _putl( paddr );
    300 _printf(" / count = ");
    301 _putd( count );
    302 _printf("\n");
    303 #endif
    304252            buf_id++;
    305253        }
     
    308256
    309257
    310 ///////////////////////////////////////////////////////////////////
    311 // Register a write command in Command List and Command Table
    312 // for a single physical buffer.
    313 // Returns 0 if success, > 0 if error.
    314 ///////////////////////////////////////////////////////////////////
    315 unsigned int _hba_write( unsigned int  channel,
    316                          unsigned int  mode,
    317                          unsigned int  lba,
    318                          paddr_t       buffer,
    319                          unsigned int  count )
    320 {
    321     return _hba_cmd_set( channel,
    322                          0,         // write
    323                          lba,
    324                          buffer,
    325                          count );
    326 }
    327 
    328 ///////////////////////////////////////////////////////////////////
    329 // Register a read command in Command List and Command Table
    330 // for a single physical buffer.
    331 // Returns 0 if success, > 0 if error.
    332 ///////////////////////////////////////////////////////////////////
    333 unsigned int _hba_read( unsigned int  channel,
    334                         unsigned int  mode,
    335                         unsigned int  lba,
    336                         paddr_t       buffer,
    337                         unsigned int  count )
    338 {
    339     return _hba_cmd_set( channel,
    340                          1,          // read
    341                          lba,
    342                          buffer,
    343                          count );
    344 }
    345 
    346 //////////////////////////////////////////////////////////////////
    347 // This function initializes for a given channel
    348 // - the HBA hardware registers,
    349 // - the command list pointer,
    350 // - the command lists physical addresse,
    351 // - the command tables physical addresses array,
    352 //////////////////////////////////////////////////////////////////
     258//////////////////////////////////////////////
    353259unsigned int _hba_init( unsigned int channel )
    354260{
     
    381287    if ( fail )
    382288    {
    383         _printf("[GIET ERROR] in _hba_init() : command list unmapped\n");
    384         return 1;
     289        _puts("[GIET ERROR] in _hba_init() : command list unmapped\n");
     290        return -1;
    385291    }
    386292    hba_cmd_list_paddr[channel] = ((paddr_t)ppn) | (vbase & 0xFFF);
     
    396302        if ( fail )
    397303        {
    398             _printf("[GIET ERROR] in _hba_init() : command table unmapped\n");
    399             return 1;
     304            _puts("[GIET ERROR] in _hba_init() : command table unmapped\n");
     305            return -1;
    400306        }
    401307        hba_cmd_table_paddr[channel][c] = ((paddr_t)ppn) | (vbase & 0xFFF);
     
    405311}
    406312
    407 ///////////////////////////////////////////////////////////////////////////////
    408 //     _hba_get_block_size()
    409 // This function returns the block_size of HBA controller
    410 ///////////////////////////////////////////////////////////////////////////////
     313///////////////////////////////////////////////
     314unsigned int _hba_write( unsigned int  channel,
     315                         unsigned int  mode,
     316                         unsigned int  lba,
     317                         paddr_t       buffer,
     318                         unsigned int  count )
     319{
     320    return _hba_cmd_set( channel,
     321                         0,         // write
     322                         lba,
     323                         buffer,
     324                         count );
     325}
     326
     327//////////////////////////////////////////////
     328unsigned int _hba_read( unsigned int  channel,
     329                        unsigned int  mode,
     330                        unsigned int  lba,
     331                        paddr_t       buffer,
     332                        unsigned int  count )
     333{
     334    return _hba_cmd_set( channel,
     335                         1,          // read
     336                         lba,
     337                         buffer,
     338                         count );
     339}
     340
     341//////////////////////////////////
    411342unsigned int _hba_get_block_size()
    412343{
     
    415346}
    416347
    417 /////////////////////////////////////////////////////////////////////////////////////
    418 // This function returns the content of the HBA_PXIS register for a given channel,
    419 // and reset this register to acknoledge IRQ.
    420 // return 0 if success, > 0 if error
    421 /////////////////////////////////////////////////////////////////////////////////////
     348////////////////////////////////////////////////////
    422349unsigned int _hba_get_status( unsigned int channel )
    423350{
     
    425352    if( channel >= NB_IOC_CHANNELS )
    426353    {
    427         _printf("\n[GIET ERROR] in _hba_get_status() : illegal channel\n");
     354        _puts("\n[GIET ERROR] in _hba_get_status() : illegal channel\n");
    428355        _exit();
    429356    }
Note: See TracChangeset for help on using the changeset viewer.