Ignore:
Timestamp:
Oct 5, 2018, 12:08:35 AM (4 years ago)
Author:
alain
Message:

Introduction of the soclib_mty driver for the TSAR-LETI architecture.

File:
1 edited

Legend:

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

    r492 r570  
    66 * Copyright (c)  UPMC Sorbonne Universites
    77 *
    8  * This file is part of ALMOS-MKH..
     8 * This file is part of ALMOS-MKH.
    99 *
    1010 * ALMOS-MKH. is free software; you can redistribute it and/or modify it
     
    1212 * the Free Software Foundation; version 2.0 of the License.
    1313 *
    14  * ALMOS-MKH. is distributed in the hope that it will be useful, but
     14 * ALMOS-MKH is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1616 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    1818 *
    1919 * You should have received a copy of the GNU General Public License
    20  * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
     20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
    2121 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    2222 */
     
    2727#include <chdev.h>
    2828#include <soclib_tty.h>
    29 #include <remote_spinlock.h>
    3029#include <thread.h>
    3130#include <printk.h>
     
    5049////////////////////////////////////////////////////////////////////////////////////
    5150// These global variables implement the TTY_RX  FIFOs (one per channel)
     51////////////////////////////////////////////////////////////////////////////////////
     52// Implementation note:
     53// We allocate - in each cluster - two arrays of FIFOs containing as many entries
     54// as the total number of TXT channels, but all entries are not used in all
     55// clusters: for a given cluster K, a given entry corresponding to a given channel
     56// and a given direction is only used if the associated chdev is in cluster K.
     57// With this policy, the driver can ignore the actual placement of chdevs.
    5258////////////////////////////////////////////////////////////////////////////////////
    5359
     
    7985    // set TTY_RX_IRQ_ENABLE
    8086    reg_xp = XPTR( tty_cxy , tty_ptr + (channel * TTY_SPAN) + TTY_RX_IRQ_ENABLE );
    81     hal_remote_sw( reg_xp , 1 );
     87    hal_remote_s32( reg_xp , 1 );
    8288
    8389    // reset TTY_TX_IRQ_ENABLE
    8490    reg_xp = XPTR( tty_cxy , tty_ptr + (channel * TTY_SPAN) + TTY_TX_IRQ_ENABLE );
    85     hal_remote_sw( reg_xp , 0 );
     91    hal_remote_s32( reg_xp , 0 );
    8692
    8793    // reset relevant FIFO
     
    112118
    113119    // get command arguments
    114     uint32_t type     = hal_remote_lw ( XPTR( th_cxy , &th_ptr->txt_cmd.type   ) );
    115     xptr_t   buf_xp   = hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.buf_xp ) );
    116     uint32_t count    = hal_remote_lw ( XPTR( th_cxy , &th_ptr->txt_cmd.count  ) );
     120    uint32_t type     = hal_remote_l32 ( XPTR( th_cxy , &th_ptr->txt_cmd.type   ) );
     121    xptr_t   buf_xp   = hal_remote_l64( XPTR( th_cxy , &th_ptr->txt_cmd.buf_xp ) );
     122    uint32_t count    = hal_remote_l32 ( XPTR( th_cxy , &th_ptr->txt_cmd.count  ) );
    117123    xptr_t   error_xp = XPTR( th_cxy , &th_ptr->txt_cmd.error );
    118124
     
    126132
    127133    // get TXT device cluster and pointers
    128     xptr_t     dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) );
     134    xptr_t     dev_xp = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) );
    129135    cxy_t      dev_cxy = GET_CXY( dev_xp );
    130136    chdev_t  * dev_ptr = GET_PTR( dev_xp );
    131137
    132138    // get cluster and pointers for SOCLIB_TTY peripheral base segment
    133     xptr_t     tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
     139    xptr_t     tty_xp = (xptr_t)hal_remote_l64( XPTR( dev_cxy , &dev_ptr->base ) );
    134140    cxy_t      tty_cxy = GET_CXY( tty_xp );
    135141    uint32_t * tty_ptr = GET_PTR( tty_xp );
    136142
    137143    // get TTY channel index and channel base address
    138     uint32_t   channel = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->channel ) );
     144    uint32_t   channel = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->channel ) );
    139145    uint32_t * base    = tty_ptr + TTY_SPAN * channel;
    140146
     
    173179
    174180                // enable TX_IRQ
    175                 hal_remote_sw( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 1 );
     181                hal_remote_s32( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 1 );
    176182            }
    177183            else                                // block & deschedule if TX_FIFO full
     
    186192
    187193        // set error status in command and return
    188         hal_remote_sw( error_xp , 0 );
     194        hal_remote_s32( error_xp , 0 );
    189195    }
    190196    ///////////////////////////
     
    229235
    230236        // set error status in command
    231         hal_remote_sw( error_xp , 0 );
     237        hal_remote_s32( error_xp , 0 );
    232238    }
    233239    else
     
    268274    cxy_t        parent_cxy;        // parent process cluster
    269275    process_t  * parent_ptr;        // local pointer on parent process
    270     xptr_t       children_lock_xp;  // extended pointer on children processes lock
    271276    thread_t   * parent_main_ptr;   // extended pointer on parent process main thread
    272277    xptr_t       parent_main_xp;    // local pointer on parent process main thread
     
    312317
    313318        // try to move bytes until TTY_READ register empty
    314         while( hal_remote_lw( status_xp ) & TTY_STATUS_RX_FULL )   
     319        while( hal_remote_l32( status_xp ) & TTY_STATUS_RX_FULL )   
    315320        {
    316321            // get one byte from TTY_READ register & acknowledge RX_IRQ
     
    335340                owner_cxy = GET_CXY( owner_xp );
    336341                owner_ptr = GET_PTR( owner_xp );
    337                 owner_pid = hal_remote_lw( XPTR( owner_cxy , &owner_ptr->pid ) );
     342                owner_pid = hal_remote_l32( XPTR( owner_cxy , &owner_ptr->pid ) );
    338343
    339344                // block TXT owner process only if it is not the INIT process
     
    341346                {
    342347                    // get parent process descriptor pointers
    343                     parent_xp  = hal_remote_lwd( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
     348                    parent_xp  = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
    344349                    parent_cxy = GET_CXY( parent_xp );
    345350                    parent_ptr = GET_PTR( parent_xp );
    346 
    347                     // get extended pointer on lock protecting children list in parent process
    348                     children_lock_xp = XPTR( parent_cxy , &parent_ptr->children_lock );
    349351
    350352                    // get pointers on the parent process main thread
     
    366368                                          PROCESS_TERM_STOP );
    367369
    368                     // take the children lock and unblock the parent process main thread
    369                     remote_spinlock_lock( children_lock_xp );
     370                    // unblock the parent process main thread
    370371                    thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
    371                     remote_spinlock_unlock( children_lock_xp );
    372372
    373373                    return;
     
    393393                owner_cxy = GET_CXY( owner_xp );
    394394                owner_ptr = GET_PTR( owner_xp );
    395                 owner_pid = hal_remote_lw( XPTR( owner_cxy , &owner_ptr->pid ) );
     395                owner_pid = hal_remote_l32( XPTR( owner_cxy , &owner_ptr->pid ) );
    396396
    397397                // kill TXT owner process only if it is not the INIT process
     
    399399                {
    400400                    // get parent process descriptor pointers
    401                     parent_xp  = hal_remote_lwd( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
     401                    parent_xp  = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
    402402                    parent_cxy = GET_CXY( parent_xp );
    403403                    parent_ptr = GET_PTR( parent_xp );
    404 
    405                     // get extended pointer on lock protecting children list in parent process
    406                     children_lock_xp = XPTR( parent_cxy , &parent_ptr->children_lock );
    407404
    408405                    // get pointers on the parent process main thread
     
    424421                                          PROCESS_TERM_KILL );
    425422
    426                     // take the children lock and unblock the parent process main thread
    427                     remote_spinlock_lock( children_lock_xp );
     423                    // unblock the parent process main thread
    428424                    thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
    429                     remote_spinlock_unlock( children_lock_xp );
    430425
    431426                    return;
     
    479474        {
    480475            // write one byte to TTY_WRITE register if empty / exit loop if full
    481             if( (hal_remote_lw( status_xp ) & TTY_STATUS_TX_FULL) == 0 )
     476            if( (hal_remote_l32( status_xp ) & TTY_STATUS_TX_FULL) == 0 )
    482477            {
    483478                // get one byte from TX_FIFO
     
    499494
    500495        // disable TX_IRQ
    501         hal_remote_sw( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 0 );
     496        hal_remote_s32( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 0 );
    502497
    503498        // unblock TXT_TX server thread
     
    531526    uint32_t   i;
    532527
    533     xptr_t     dev_xp = ((txt_sync_args_t *)args)->dev_xp;
    534     char    * buffer = ((txt_sync_args_t *)args)->buffer;
    535     uint32_t   count  = ((txt_sync_args_t *)args)->count;
     528    xptr_t       dev_xp = ((txt_sync_args_t *)args)->dev_xp;
     529    const char * buffer = ((txt_sync_args_t *)args)->buffer;
     530    uint32_t     count  = ((txt_sync_args_t *)args)->count;
    536531   
    537     // get TXT0 chdev cluster and local pointer
     532    // get chdev cluster and local pointer
    538533    cxy_t     dev_cxy = GET_CXY( dev_xp );
    539     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     534    chdev_t * dev_ptr = GET_PTR( dev_xp );
    540535
    541536    // get extended pointer on TTY channel base address
    542     xptr_t tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
     537    xptr_t tty_xp = (xptr_t)hal_remote_l64( XPTR( dev_cxy , &dev_ptr->base ) );
    543538
    544539    // get TTY channel segment cluster and local pointer
    545540    cxy_t      tty_cxy = GET_CXY( tty_xp );
    546     uint32_t * tty_ptr = (uint32_t *)GET_PTR( tty_xp );
     541    uint32_t * tty_ptr = GET_PTR( tty_xp );
    547542
    548543    // get extended pointers on TTY_WRITE & TTY_STATUS registers
     
    550545    xptr_t status_xp = XPTR( tty_cxy , tty_ptr + TTY_STATUS );
    551546
    552     // loop on characters (busy waiting policy)
     547    // loop on characters
    553548    for( i = 0 ; i < count ; i++ )
    554549    {
     550        // busy waiting policy on TTY_STATUS register
    555551        do
    556552        {
    557553            // get TTY_STATUS
    558             status = hal_remote_lw( status_xp );
     554            status = hal_remote_l32( status_xp );
    559555            empty  = ( (status & TTY_STATUS_TX_FULL) == 0 );
    560556
Note: See TracChangeset for help on using the changeset viewer.