Ignore:
Timestamp:
Mar 28, 2018, 2:40:29 PM (6 years ago)
Author:
alain
Message:

Fix various bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/chdev.c

    r436 r437  
    140140    thread_t * this = CURRENT_THREAD;
    141141
    142 #if CONFIG_DEBUG_CHDEV_REGISTER_COMMAND
    143 uint32_t cycle = (uint32_t)hal_get_cycles();
    144 if( CONFIG_DEBUG_CHDEV_REGISTER_COMMAND < cycle )
    145 printk("\n[DBG] %s : client_thread %x (%s) enter / cycle %d\n",
    146 __FUNCTION__, this, thread_type_str(this->type) , cycle );
    147 #endif
    148 
    149142    // get device descriptor cluster and local pointer
    150143    cxy_t     chdev_cxy = GET_CXY( chdev_xp );
    151144    chdev_t * chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
     145
     146#if (CONFIG_DEBUG_CHDEV_CMD_RX || CONFIG_DEBUG_CHDEV_CMD_TX)
     147bool_t is_rx = hal_remote_lw( XPTR( chdev_cxy , &chdev_ptr->is_rx ) );
     148#endif
     149   
     150#if CONFIG_DEBUG_CHDEV_CMD_RX
     151uint32_t rx_cycle = (uint32_t)hal_get_cycles();
     152if( (is_rx) && (CONFIG_DEBUG_CHDEV_CMD_RX < rx_cycle) )
     153printk("\n[DBG] %s : client_thread %x (%s) enter for RX / cycle %d\n",
     154__FUNCTION__, this, thread_type_str(this->type) , rx_cycle );
     155#endif
     156
     157#if CONFIG_DEBUG_CHDEV_CMD_TX
     158uint32_t tx_cycle = (uint32_t)hal_get_cycles();
     159if( (is_rx == 0) && (CONFIG_DEBUG_CHDEV_CMD_TX < tx_cycle) )
     160printk("\n[DBG] %s : client_thread %x (%s) enter for TX / cycle %d\n",
     161__FUNCTION__, this, thread_type_str(this->type) , tx_cycle );
     162#endif
    152163
    153164    // build extended pointers on client thread xlist and device root
     
    196207    hal_restore_irq( save_sr );
    197208
    198 #if CONFIG_DEBUG_CHDEV_REGISTER_COMMAND
    199 cycle = (uint32_t)hal_get_cycles();
    200 if( CONFIG_DEBUG_CHDEV_REGISTER_COMMAND < cycle )
    201 printk("\n[DBG] %s : client_thread %x (%s) exit / cycle %d\n",
    202 __FUNCTION__, this, thread_type_str(this->type) , cycle );
     209#if CONFIG_DEBUG_CHDEV_CMD_RX
     210rx_cycle = (uint32_t)hal_get_cycles();
     211if( (is_rx) && (CONFIG_DEBUG_CHDEV_CMD_RX < rx_cycle) )
     212printk("\n[DBG] %s : client_thread %x (%s) exit for RX / cycle %d\n",
     213__FUNCTION__, this, thread_type_str(this->type) , rx_cycle );
     214#endif
     215
     216#if CONFIG_DEBUG_CHDEV_CMD_TX
     217tx_cycle = (uint32_t)hal_get_cycles();
     218if( (is_rx == 0) && (CONFIG_DEBUG_CHDEV_CMD_TX < tx_cycle) )
     219printk("\n[DBG] %s : client_thread %x (%s) exit for TX / cycle %d\n",
     220__FUNCTION__, this, thread_type_str(this->type) , tx_cycle );
    203221#endif
    204222
     
    225243    server = CURRENT_THREAD;
    226244
    227 #if CONFIG_DEBUG_CHDEV_SEQUENCIAL_SERVER
    228 uint32_t cycle = (uint32_t)hal_get_cycles();
    229 if( CONFIG_DEBUG_CHDEV_SEQUENCIAL_SERVER < cycle )
    230 printk("\n[DBG] %s : server_thread %x enter / chdev = %x / cycle %d\n",
    231 __FUNCTION__ , server , chdev , cycle );
    232 #endif
    233 
     245    // get root and lock on command queue
    234246    root_xp = XPTR( local_cxy , &chdev->wait_root );
    235247    lock_xp = XPTR( local_cxy , &chdev->wait_lock );
     
    253265        else                            // waiting queue not empty
    254266        {
    255 
    256 #if (CONFIG_DEBUG_SYS_READ & 1)
    257 enter_chdev_server_read = (uint32_t)hal_get_cycles();
    258 #endif
    259 
    260 #if (CONFIG_DEBUG_SYS_WRITE & 1)
    261 enter_chdev_server_write = (uint32_t)hal_get_cycles();
    262 #endif
    263 
    264267            // release lock
    265268            remote_spinlock_unlock( lock_xp );
     
    271274            client_cxy = GET_CXY( client_xp );
    272275            client_ptr = (thread_t *)GET_PTR( client_xp );
     276
     277#if CONFIG_DEBUG_CHDEV_SERVER_RX
     278uint32_t rx_cycle = (uint32_t)hal_get_cycles();
     279if( (chdev->is_rx) && (CONFIG_DEBUG_CHDEV_SERVER_RX < rx_cycle) )
     280printk("\n[DBG] %s : server_thread %x start RX / client %x / cycle %d\n",
     281__FUNCTION__ , server , client_ptr , rx_cycle );
     282#endif
     283
     284#if CONFIG_DEBUG_CHDEV_SERVER_TX
     285uint32_t tx_cycle = (uint32_t)hal_get_cycles();
     286if( (chdev->is_rx == 0) && (CONFIG_DEBUG_CHDEV_SERVER_TX < tx_cycle) )
     287printk("\n[DBG] %s : server_thread %x start TX / client %x / cycle %d\n",
     288__FUNCTION__ , server , client_ptr , tx_cycle );
     289#endif
     290
     291#if (CONFIG_DEBUG_SYS_READ & 1)
     292enter_chdev_server_read = (uint32_t)hal_get_cycles();
     293#endif
     294
     295#if (CONFIG_DEBUG_SYS_WRITE & 1)
     296enter_chdev_server_write = (uint32_t)hal_get_cycles();
     297#endif
    273298
    274299            // call driver command function to execute I/O operation
     
    283308            thread_unblock( client_xp , THREAD_BLOCKED_IO );
    284309
    285 #if CONFIG_DEBUG_CHDEV_SEQUENCIAL_SERVER
    286 cycle = (uint32_t)hal_get_cycles();
    287 if( CONFIG_DEBUG_CHDEV_SEQUENCIAL_SERVER < cycle )
    288 printk("\n[DBG] %s : server_thread %x complete operation for client %x / cycle %d\n",
    289 __FUNCTION__ , server , client_ptr , cycle );
     310#if CONFIG_DEBUG_CHDEV_SERVER_RX
     311rx_cycle = (uint32_t)hal_get_cycles();
     312if( (chdev->is_rx) && (CONFIG_DEBUG_CHDEV_SERVER_RX < rx_cycle) )
     313printk("\n[DBG] %s : server_thread %x completes RX / client %x / cycle %d\n",
     314__FUNCTION__ , server , client_ptr , rx_cycle );
     315#endif
     316
     317#if CONFIG_DEBUG_CHDEV_SERVER_TX
     318tx_cycle = (uint32_t)hal_get_cycles();
     319if( (chdev->is_rx == 0) && (CONFIG_DEBUG_CHDEV_SERVER_TX < tx_cycle) )
     320printk("\n[DBG] %s : server_thread %x completes TX / client %x / cycle %d\n",
     321__FUNCTION__ , server , client_ptr , tx_cycle );
    290322#endif
    291323
Note: See TracChangeset for help on using the changeset viewer.