Changeset 424 for trunk/hal


Ignore:
Timestamp:
Jan 29, 2018, 5:57:05 PM (4 years ago)
Author:
alain
Message:

cosmetic.

Location:
trunk/hal/tsar_mips32/drivers
Files:
3 edited

Legend:

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

    r407 r424  
    549549
    550550    // we must make a fake use for ack value to avoid a warning
    551     if( (ack + 1) == 0 ) panic("this should never happen");
     551    if( (ack + 1) == 0 ) asm volatile( "nop" );
    552552}
    553553   
  • trunk/hal/tsar_mips32/drivers/soclib_tty.c

    r418 r424  
    180180    uint32_t   i;
    181181
    182 #if CONFIG_READ_DEBUG
     182#if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)
    183183enter_tty_isr = hal_time_stamp();
    184184#endif
     
    279279__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );
    280280
    281 #if CONFIG_READ_DEBUG
     281#if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)
    282282exit_tty_isr = hal_time_stamp();
    283283#endif
     
    285285}  // end soclib_tty_isr()
    286286
     287/*
     288/////////////////////////////////////////////////////////////////
     289void __attribute__ ((noinline)) soclib_tty_isr( chdev_t * chdev )
     290{
     291    xptr_t     root_xp;      // extended pointer on command list root
     292    xptr_t     client_xp;    // extended pointer on client thread
     293    cxy_t      client_cxy;   // client thread cluster
     294    thread_t * client_ptr;   // client_thread local pointer
     295    uint32_t   type;         // command type
     296    uint32_t   count;        // number of bytes in buffer
     297    xptr_t     buf_xp;       // extended pointer on buffer
     298    xptr_t     status_xp;    // extended pointer on TTY_STATUS register
     299    xptr_t     write_xp;     // extended pointer on TTY_WRITE register
     300    xptr_t     read_xp;      // extended pointer on TTY_READ register
     301    uint32_t   status;       // TTY terminal status
     302    char       byte;         // read byte
     303    uint32_t   i;
     304
     305#if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)
     306enter_tty_isr = hal_time_stamp();
     307#endif
     308
     309txt_dmsg("\n[DBG] %s : core[%x,%d] enter / cycle %d\n",
     310__FUNCTION__ , local_cxy, CURRENT_THREAD->core->lid , hal_time_stamp() );
     311
     312    // get SOCLIB_TTY peripheral cluster and local pointer
     313    cxy_t      tty_cxy = GET_CXY( chdev->base );
     314    uint32_t * tty_ptr = (uint32_t *)GET_PTR( chdev->base );
     315
     316    // get channel base address
     317    uint32_t * base = tty_ptr + TTY_SPAN * chdev->channel;
     318
     319    // get extended pointer on TTY registers
     320    status_xp = XPTR( tty_cxy , base + TTY_STATUS );
     321    write_xp  = XPTR( tty_cxy , base + TTY_WRITE );
     322    read_xp   = XPTR( tty_cxy , base + TTY_READ );
     323
     324    // get TTY_STATUS
     325    status = hal_remote_lw( status_xp );
     326
     327    // get extended pointer on the command list root
     328    root_xp = XPTR( local_cxy , &chdev->wait_root );
     329
     330    // get extended pointer on client thread
     331    if(xlist_is_empty(root_xp)) client_xp = XLIST_FIRST_ELEMENT(root, thread_t, wait_list);
     332    else                        client_xp = XPTR_NULL;
     333
     334    if( client_xp )
     335    {
     336        // get client thread cluster and local pointer
     337        client_cxy = GET_CXY( client_xp );
     338        client_ptr = (thread_t *)GET_PTR( client_xp );
     339
     340        // get command arguments
     341        type    = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.type   ) );
     342        count   = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.count  ) );
     343        buf_xp  = hal_remote_lwd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ) );
     344    }
     345
     346    ///////////// handle RX if TTY_RX full
     347    if( status & TTY_STATUS_RX_FULL )   
     348    {
     349        // get a byte from TTY_READ, and acknowledge RX_IRQ
     350        byte = (char)hal_remote_lb( read_xp );
     351
     352        // FIXME The RX_IRQ must be always enabled !!! 
     353        // xptr_t reg_xp = XPTR( tty_cxy , base + TTY_RX_IRQ_ENABLE );
     354        // hal_remote_sw( reg_xp , 0 );
     355
     356        // analyse received character
     357        switch( byte )
     358        {
     359            case CONTROL_C:          // SIGINT to process
     360            case CONTROL_D:
     361            {
     362                // TODO SIGINT
     363                return
     364            }
     365            break;
     366            default:                 
     367            {
     368                if( (type == TXT_READ) && (client_xp != XPTR_NULL) ) 
     369                {
     370                    // write byte to command buffer
     371                    hal_remote_sb( buf_xp , byte );
     372
     373                    // set status in command
     374                    hal_remote_sw( XPTR( client_cxy , &client_ptr->txt_cmd.error ) , 0 );
     375
     376                    hal_fence();
     377
     378                    // unblock server thread
     379                    thread_unblock( XPTR(local_cxy,chdev->server), THREAD_BLOCKED_DEV_ISR );
     380                }
     381                else                    // discard byte
     382                {
     383                    // TODO WARNING
     384                    return
     385                }
     386            }
     387        }
     388    } // end RX handling
     389
     390    //////////////// handle TX if WRITE command pending
     391    if( (type == TXT_WRITE) && (client_xp != XPTR_NULL) )
     392    {
     393        // loop on characters
     394        for( i = 0 ; i < count ; i++ )
     395        {
     396            // get TTY_STATUS
     397            status = hal_remote_lw( status_xp );
     398
     399            if( (status & TTY_STATUS_TX_FULL) == 0 ) // TTY_TX empty => move one byte
     400            {
     401                // get one byte from command buffer
     402                byte = (char)hal_remote_lb( buf_xp + i );
     403
     404                // write byte to TTY_WRITE, and acknowledge TX_IRQ
     405                hal_remote_sb( write_xp , byte );
     406            }
     407            else         // TTY_TX full => update command arguments and exit ISR for retry
     408            {
     409                hal_remote_sw ( XPTR( client_cxy , &client_ptr->txt_cmd.count ), count-i );
     410                hal_remote_swd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ), buf_xp+i );
     411                return;
     412            }
     413        }
     414
     415        // disable TX_IRQ
     416        xptr_t reg_xp = XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE );
     417        hal_remote_sw( reg_xp , 0 );
     418
     419        // set I/O operation status in command
     420        hal_remote_sw( XPTR( client_cxy , &client_ptr->txt_cmd.error ) , 0 );
     421
     422        hal_fence();
     423
     424        // unblock server thread
     425        thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR );
     426
     427    }  // end TX handling
     428
     429txt_dmsg("\n[DBG] %s : core[%x,%d] exit / cycle %d\n",
     430__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );
     431
     432#if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)
     433exit_tty_isr = hal_time_stamp();
     434#endif
     435
     436}  // end soclib_tty_isr()
     437
     438*/
  • trunk/hal/tsar_mips32/drivers/soclib_tty.h

    r407 r424  
    8383
    8484/****************************************************************************************
    85  * This ISR should be executed only for the TXT_READ and TXT_WRITE commands.
     85 * This ISR is executed to handle both the TTY_TX_IRQ and the TTY_RX_IRQ.
     86 * - the TTY_RX_IRQ is activated as soon as the TTY_STATUS_RX_FULL bit is set in the
     87 *   TTY status register, indicating a character registered in the TTY_READ register.
     88 *
     89 *   . if it exist a TXT_READ command registered in the command queue, and thit copies the
     90 *     character to the command buffer, acknowledges the TTY_RX_IRQ, and unblock the
     91 *     associated server thread.
     92     
     93 *   . the control characters are directly handled by the txt ^C / ^D /  and the this IRQ ca
     94 *
     95 the TXT_READ and TXT_WRITE commands.
    8696 * It gets the command arguments from the first client thread in the TXT chdev queue:
    8797 * - if TXT_READ, it transfers one byte from the TTY_READ_REG to the command buffer.
Note: See TracChangeset for help on using the changeset viewer.