Ignore:
Timestamp:
Aug 2, 2018, 11:47:13 AM (6 years ago)
Author:
alain
Message:

This version modifies the exec syscall and fixes a large number of small bugs.
The version number has been updated (0.1)

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

Legend:

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

    r451 r457  
    137137#endif
    138138
    139     // analyse status and handle up to 3 pending IRQ (one WTI, one HWI, one PTI)
     139    // analyse status and handle up to 3 pending IRQs (one WTI, one HWI, one PTI)
    140140
    141141    if( wti_status )          // pending WTI
     
    150150#if DEBUG_HAL_IRQS
    151151if (DEBUG_HAL_IRQS < cycle )
    152 printk("\n[DBG] %s : core[%x,%d] received an IPI\n", __FUNCTION__ , local_cxy , core->lid );
     152printk("\n[DBG] %s : core[%x,%d] handling IPI\n", __FUNCTION__ , local_cxy , core->lid );
    153153#endif
    154154            // acknowledge IRQ (this require an XCU read)
     
    156156
    157157            // check RPC FIFO,  and activate or create a RPC thread
    158             // condition is always true, but we must use the ack value
     158            // condition is always true, but we use the ack value
     159            // to avoid a GCC warning
    159160            if( ack + 1 ) rpc_check();
    160161        }
     
    182183#if DEBUG_HAL_IRQS
    183184if (DEBUG_HAL_IRQS < cycle )
    184 printk("\n[DBG] %s : core[%x,%d] received external WTI %d\n",
     185printk("\n[DBG] %s : core[%x,%d] handling external WTI %d\n",
    185186__FUNCTION__ , local_cxy , core->lid , index );
    186187#endif
     
    216217#if DEBUG_HAL_IRQS
    217218if (DEBUG_HAL_IRQS < cycle )
    218 printk("\n[DBG] %s : core[%x,%d] received HWI %d\n",
     219printk("\n[DBG] %s : core[%x,%d] handling HWI %d\n",
    219220__FUNCTION__ , local_cxy , core->lid , index );
    220221#endif
     
    232233#if DEBUG_HAL_IRQS
    233234if (DEBUG_HAL_IRQS < cycle )
    234 printk("\n[DBG] %s : core[%x,%d] received PTI %d\n",
     235printk("\n[DBG] %s : core[%x,%d] handling PTI %d\n",
    235236__FUNCTION__ , core->lid , local_cxy , index );
    236237#endif
     
    239240
    240241        // execute all actions related to TICK event
    241         // condition is always true, but we must use the ack value
     242        // condition is always true, but we use the ack value
     243        // to avoid a GCC warning
    242244        if( ack + 1 ) core_clock( core );
    243245        }
     
    515517{
    516518    // calling core local index
    517     lid_t  lid = CURRENT_CORE->lid;
     519    lid_t  lid = CURRENT_THREAD->core->lid;
    518520
    519521    // get XCU segment base
     
    533535{
    534536    // calling core local index
    535     lid_t  lid = CURRENT_CORE->lid;
     537    lid_t  lid = CURRENT_THREAD->core->lid;
    536538
    537539    // get XCU segment base
  • trunk/hal/tsar_mips32/drivers/soclib_tty.c

    r451 r457  
    272272    xptr_t       parent_main_xp;    // local pointer on parent process main thread
    273273
    274     // get TXT chdev channel, direction and server thread
     274    // get TXT chdev channel, direction, server thread, and server core
    275275    channel    = chdev->channel;
    276276    is_rx      = chdev->is_rx;
     
    455455                thread_unblock( XPTR( local_cxy , server ) , THREAD_BLOCKED_ISR );
    456456
    457                 // send IPI to core running server thread
    458                 dev_pic_send_ipi( local_cxy , server_lid );
     457                // send IPI to core running server thread if required
     458                if( server_lid != CURRENT_THREAD->core->lid )
     459                {
     460                    dev_pic_send_ipi( local_cxy , server_lid );
     461                }
    459462            }
    460463            else
     
    501504        thread_unblock( XPTR( local_cxy , server ) , THREAD_BLOCKED_ISR );
    502505
    503         // send IPI to core running server thread
    504         dev_pic_send_ipi( local_cxy , server_lid );
     506        // send IPI to core running server thread if required
     507        if( server_lid != CURRENT_THREAD->core->lid )
     508        {
     509            dev_pic_send_ipi( local_cxy , server_lid );
     510        }
    505511
    506512    }  // end TX
  • trunk/hal/tsar_mips32/drivers/soclib_tty.h

    r436 r457  
    22 * soclib_tty.c - soclib tty driver definition.
    33 *
    4  * Author  Alain Greiner (2016)
     4 * Author  Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c)  UPMC Sorbonne Universites
     
    2929/****************************************************************************************
    3030 * This driver supports the vci_tty_tsar component.
    31  * It implements the generic TXT device API:
     31 * Regarding read/write request, it implements the generic TXT device API:
    3232 * - transfer one single character from TTY to command "buffer" if to_mem is non-zero.
    3333 * - transfer "count" characters from command "buffer" to TTY if "to_mem is zero.
     34 * It handles asynchronous control characters (^C / ^Z), that are translated to signals
     35 * transmited to the TXT owner process (foreground process).
    3436 ***************************************************************************************/
    3537
     
    101103/****************************************************************************************
    102104 * This ISR is executed to handle both the TTY_TX_IRQ and the TTY_RX_IRQ, even if
    103  *   The RX_IRQ is activated as soon as the TTY_STATUS_RX_FULL bit is 1 in the
     105 * there is two different channel devices for TX and RX transfers.
     106 *
     107 * As the <chdev> argument is a local pointer, this ISR is always executed by a core
     108 * that is in the same cluster as the core running the DEV server thread.
     109 *
     110 * - The RX_IRQ is activated as soon as the TTY_STATUS_RX_FULL bit is 1 in the
    104111 *   TTY_STATUS register, when the TTY_RX_IRQ_ENABLE is non zero, indicating that
    105112 *   the TTY_READ buffer is full and can be read.
    106  *   The TX_IRQ is activated as soon as the TTY_STATUS_TX_FULL bit is 0 in the
     113 * - The TX_IRQ is activated as soon as the TTY_STATUS_TX_FULL bit is 0 in the
    107114 *   TTY_STATUS register, when the TTY_TX_IRQ_ENABLE is non zero, indicating that
    108115 *   the TTY_WRITE buffer is empty, and can be written.
    109  * WARNING : In ALMOS-MKH, the RX_IRQ is always enabled to catch the control signals,
     116 *
     117 * The RX_IRQ is always enabled to catch the control characters (^Z / ^C),
    110118 * but the TX_IRQ is dynamically enabled by the TXT_WRITE command, and disabled when
    111119 * the command is completed.
    112120 *
    113  * 1) The ISR first read the TTY_STATUS to get the current state of the TTY_READ and
    114  *   the TTY_WRITE buffers.
     121 * For normal characters The ISR uses two private TTY_RX and TTY_TX software FIFOs
     122 * (two FIFOs per channel) to communicates with the DEV server thread executing the
     123 * soclib_tty_cmd() function.
     124
     125 * For an RX transfer, this ISR executes a while loop moving bytes until the source
     126 * TTY_READ buffer is empty:
     127 *   1) The ISR read one byte from the TTY_READ register and acknowledge the RX_IRQ.
     128 *   2) if the byte is a ^Z character, it uses a multicast RPC to block all treads of
     129 *      the TXT owner process, and transfer TXT ownership to another process of the group.
     130 *   3) if the byte is a ^C character, it removes the process from the TXT group, and send
     131 *      a multicast RPC to delete all threads of the TXT owner process.
     132 *   4) if the byte is a normal character and the destination TTY_RX_FIFO is not full,
     133 *      it writes the byte to this FIFO, unblock the TXT_RX server thread, and send an IPI
     134 *      to this server thread (only if it is running on another core than the ISR).
     135 *   5) It discards the byte if the TTY_RX_FIFO is full, with a warning message on TXT0.
    115136 *
    116  * 2) It try to read the first command registered in the server thread queue associated
    117  *    to the TTY channel
    118  *
    119  * 2) The ISR handles the RX when the TTY_READ buffer is full :
    120  *   . it read the available character from the TTY_READ buffer, and this
    121  *     acknowledges the RX_IRQ.
    122  *   . if it is a control character ( ^C / ^D / ^Z ) it translate it to the proper
    123  *     signal and execute the relevant sigaction for the foreground process.
    124  *   . if it is a normal character, it try to get the first command registered in the
    125  *     server thread queue. If it is a TXT_READ, it returns this character to the
    126  *     command buffer in the client thread.
    127  *
    128  * 3) The ISR handles the TX when the TTY_WRITE buffer is empty and a TXT_WRITE
    129  *   . it try to get it copies the
    130  *     character to the command buffer, acknowledges the TTY_RX_IRQ, and unblock the
    131  *     associated server thread.
    132      
    133  *   . the control characters ^C / ^D / ^Z  are directly handled by the ISR and
    134  *     translated to the foreground process.
    135 
    136  * - the
    137  the TXT_READ and TXT_WRITE commands.
    138  * It gets the command arguments from the first client thread in the TXT chdev queue:
    139  * - if TXT_READ, it transfers one byte from the TTY_READ_REG to the command buffer.
    140  *   It simply returns for retry if TTY_READ_REG is empty.
    141  * - if TXT_WRITE, it tries to transfer several bytes from the command buffer to the
    142  *   TTY_WRITE_REG. If the TTY_WRITE_REG is full, it updates the "count" and "buffer"
    143  *   command arguments and returns for retry.
    144  * When the I/O operation is completed, it sets the status field in the command, unblocks
    145  * the server thread, and unblocks the client thread.
     137 * For a TX transfer, this ISR executes a while loop moving bytes until the source
     138 * TTY_TX_FIFO is empty:
     139 *   1) if the destination TTY_WRITE register is not full, it moves the byte from the
     140 *      TTY_TX_FIFO to the TTY_WRITE register.
     141 *   2) if the TTY_WRITE register is full, it polls (busy waiting) the TTY_STATUS register,
     142 *      until the TTY_WRITE register is empty.
     143 *   3) when the source TTY_TX_FIFO is empty, this ISR disable the TTY_TX_IRQ, unblock
     144 *      the TXT_TX server thread, and send an IPI to this server thread (only if it is
     145 *      running on another core than the ISR).
    146146 ****************************************************************************************
    147147 * @ chdev     : local pointer on TXT chdev descriptor.
Note: See TracChangeset for help on using the changeset viewer.