Changeset 493


Ignore:
Timestamp:
Aug 22, 2018, 11:56:33 PM (6 years ago)
Author:
viala@…
Message:

[hal/drivers] Use asserts and fix a bad call.

We called hal_core_sleep with arguments, the function takes no one.
Now we use an assert.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/drivers/soclib_nic.c

    r492 r493  
    127127            cont_id = chbuf->cont_id;
    128128           
    129             if( chbuf->full[cont_id] == 0 )  // container empty
    130             {
    131                 printk("PANIC in %s : read an empty container\n", __FUNCTION__ );
    132                 hal_core_sleep();
    133             }
     129            assert( chbuf->full[cont_id] == 0 , "Read an empty container\n" );
    134130
    135131            // get pointer on container and header
     
    145141            npackets  = header[0];
    146142
    147             if( pkt_id >= npackets )  // packet index too large
    148             {
    149                 printk("PANIC in %s : read a non readable container\n", __FUNCTION__ );
    150                 hal_core_sleep();
    151             }
     143            assert( pkt_id >= npackets,
     144                "Read a non readable container, packet index too large\n");
    152145
    153146            // move the packet from container to buffer
     
    169162            word_id = chbuf->word_id;
    170163
    171             if( chbuf->full[cont_id] != 0 )  // container full
    172             {
    173                 printk("PANIC in %s : write to a full container\n", __FUNCTION__ );
    174                 hal_core_sleep();
    175             }
     164            assert( chbuf->full[cont_id] != 0, "Write to a full container\n" );
    176165
    177166            // get pointer on container and header
     
    179168            header    = (uint16_t *)container;
    180169
    181             if( length > ((1024 - word_id)<<2) )  // packet length too large
    182             {
    183                 printk("PANIC in %s : write to a non writable container\n", __FUNCTION__ );
    184                 hal_core_sleep();
    185             }
     170            assert( length > ((1024 - word_id) << 2),
     171                "Write to a non writable container, packet length too large\n");
    186172
    187173            // update packet length in container header
     
    309295    uint32_t status = hal_remote_lw( XPTR( cxy_nic , offset ) );
    310296
    311     if( status != 0 ) hal_core_sleep("%s : illegal address\n", __FUNCTION__ );
    312    
     297    assert( status != 0, "Illegal address: \n" );
     298
    313299    // unblock server thread
    314300    thread_t * server = chdev->server;
Note: See TracChangeset for help on using the changeset viewer.