Changeset 565


Ignore:
Timestamp:
Oct 4, 2018, 11:48:51 PM (5 years ago)
Author:
alain
Message:

Complete restructuration of kernel locks.

Location:
trunk/kernel/devices
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/devices/dev_dma.c

    r492 r565  
    2929#include <printk.h>
    3030#include <memcpy.h>
    31 #include <spinlock.h>
    3231#include <dev_dma.h>
    3332#include <hal_drivers.h>
  • trunk/kernel/devices/dev_dma.h

    r457 r565  
    2727#include <kernel_config.h>
    2828#include <hal_kernel_types.h>
    29 #include <spinlock.h>
    3029
    3130/*****************************************************************************************
  • trunk/kernel/devices/dev_fbf.c

    r492 r565  
    5555    if( impl == IMPL_FBF_SCL )
    5656    {
    57         // TODO
     57        printk("\n[WARNING] Soclib FBF driver not implemented yet\n");
    5858    }
    5959    else
     
    7878
    7979    // return values
    80     *width  = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->ext.fbf.width ) );
    81     *height = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->ext.fbf.height ) );
     80    *width  = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->ext.fbf.width ) );
     81    *height = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->ext.fbf.height ) );
    8282
    8383}  // end dev_fbf_get_size()
    8484
    85 ///////////////////////
     85/////////////////////////////
    8686error_t dev_fbf_alloc( void )
    8787{
    8888    // get extended pointer on FBF chdev descriptor
    89     xptr_t  dev_xp = chdev_dir.fbf[0];
    90 
    91     assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );
    92 
    93     // get FBF chdev cluster and local pointer
    94     cxy_t     dev_cxy = GET_CXY( dev_xp );
    95     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     89    // xptr_t  dev_xp = chdev_dir.fbf[0];
     90
     91    // assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );
     92
     93    // get FBF chdev cluster and local pointer
     94    // cxy_t     dev_cxy = GET_CXY( dev_xp );
     95    // chdev_t * dev_ptr = GET_PTR( dev_xp );
    9696
    9797    // try to get FBF ownership
    98     return remote_spinlock_trylock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     98
     99assert( false , "not implemented yet" );
    99100
    100101}  // end dev_fbf_alloc()
    101102
    102 ///////////////////
     103/////////////////////////
    103104void dev_fbf_free( void )
    104105{
    105106    // get extended pointer on FBF chdev descriptor
    106     xptr_t  dev_xp = chdev_dir.fbf[0];
    107 
    108     assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );
    109 
    110     // get FBF chdev cluster and local pointer
    111     cxy_t     dev_cxy = GET_CXY( dev_xp );
    112     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     107    // xptr_t  dev_xp = chdev_dir.fbf[0];
     108
     109    // assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );
     110
     111    // get FBF chdev cluster and local pointer
     112    // cxy_t     dev_cxy = GET_CXY( dev_xp );
     113    // chdev_t * dev_ptr = (GET_PTR( dev_xp );
    113114
    114115    // release FBF ownership
    115     remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     116
     117assert( false , "not implemented yet" );
    116118
    117119}  // end dev_fbf_free()
     
    139141
    140142    // get frame buffer base address, width and height
    141     xptr_t   base   = hal_remote_lwd( XPTR( fbf_cxy , &fbf_ptr->base ) );
    142     uint32_t width  = hal_remote_lw ( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.width ) );
    143     uint32_t height = hal_remote_lw ( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.height ) );
     143    xptr_t   base   = hal_remote_l64( XPTR( fbf_cxy , &fbf_ptr->base ) );
     144    uint32_t width  = hal_remote_l32 ( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.width ) );
     145    uint32_t height = hal_remote_l32 ( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.height ) );
    144146
    145147    // check offset and length versus FBF size
  • trunk/kernel/devices/dev_iob.c

    r457 r565  
    22 * dev_iob.c - IOB (bridge to external I/O) generic device API implementation.
    33 *
    4  * Authors   Alain Greiner  (2017)
     4 * Authors   Alain Greiner  (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2525#include <hal_kernel_types.h>
    2626#include <hal_special.h>
    27 #include <remote_spinlock.h>
     27#include <remote_busylock.h>
    2828#include <chdev.h>
    2929#include <printk.h>
     
    5050    // get IOB chdev descriptor cluster and local pointer
    5151    cxy_t     dev_cxy = GET_CXY( dev_xp );
    52     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     52    chdev_t * dev_ptr = GET_PTR( dev_xp );
    5353
    5454    // get pointer on set_active function
     
    5656
    5757    // call relevant driver function
    58     remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     58    remote_busylock_acquire( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    5959    f( dev_xp , 1 );
    60     remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     60    remote_busylock_release( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    6161}
    6262
     
    6666    // get IOB chdev descriptor cluster and local pointer
    6767    cxy_t     dev_cxy = GET_CXY( dev_xp );
    68     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     68    chdev_t * dev_ptr = GET_PTR( dev_xp );
    6969
    7070    // get pointer on set_active function
     
    7272
    7373    // call driver function
    74     remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     74    remote_busylock_acquire( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    7575    f( dev_xp , 0 );
    76     remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     76    remote_busylock_release( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    7777}
    7878
     
    8383    // get IOB chdev descriptor cluster and local pointer
    8484    cxy_t     dev_cxy = GET_CXY( dev_xp );
    85     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     85    chdev_t * dev_ptr = GET_PTR( dev_xp );
    8686
    8787    // get pointer on set_ptpr function
     
    8989
    9090    // call driver function
    91     remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     91    remote_busylock_acquire( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    9292    f( dev_xp , wdata );
    93     remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     93    remote_busylock_release( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    9494
    9595}
     
    101101    // get IOB chdev descriptor cluster and local pointer
    102102    cxy_t     dev_cxy = GET_CXY( dev_xp );
    103     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     103    chdev_t * dev_ptr = GET_PTR( dev_xp );
    104104
    105105    // get pointer on inval_page function
     
    107107
    108108    // call driver function
    109     remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     109    remote_busylock_acquire( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    110110    f( dev_xp , vpn );
    111     remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     111    remote_busylock_release( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    112112}
    113113
     
    120120    // get IOB chdev descriptor cluster and local pointer
    121121    cxy_t     dev_cxy = GET_CXY( dev_xp );
    122     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     122    chdev_t * dev_ptr = GET_PTR( dev_xp );
    123123
    124124    // get pointer on the functions
     
    128128
    129129    // call driver function
    130     remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     130    remote_busylock_acquire( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    131131    *error = f_get_error( dev_xp );
    132132    *srcid = f_get_srcid( dev_xp );
    133133    *bvar  = f_get_bvar( dev_xp );
    134     remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     134    remote_busylock_release( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    135135}
    136136
  • trunk/kernel/devices/dev_iob.h

    r457 r565  
    2727#include <kernel_config.h>
    2828#include <hal_kernel_types.h>
    29 #include <spinlock.h>
    3029
    3130/*****************************************************************************************
  • trunk/kernel/devices/dev_ioc.c

    r492 r565  
    216216    thread_t * server = (thread_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->server ) );
    217217    core_t   * core   = (core_t *)hal_remote_lpt( XPTR( ioc_cxy , &server->core ) );
    218     lid_t      lid    = (lid_t)hal_remote_lw( XPTR( ioc_cxy , &core->lid ) );
     218    lid_t      lid    = (lid_t)hal_remote_l32( XPTR( ioc_cxy , &core->lid ) );
    219219
    220220    // mask the IRQ
  • trunk/kernel/devices/dev_mmc.c

    r492 r565  
    2828#include <chdev.h>
    2929#include <thread.h>
     30#include <remote_busylock.h>
    3031#include <dev_mmc.h>
    3132
     
    7677    dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->cmd ) );
    7778
    78     // get the MMC device remote spinlock
    79     remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 
     79    // get the MMC device remote busylock
     80    remote_busylock_acquire( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 
    8081
    8182    // call driver command
    8283    cmd( XPTR( local_cxy , this ) );
    8384   
    84     // release the MMC device remote spinlock
    85     remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 
     85    // release the MMC device remote busylock
     86    remote_busylock_release( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 
    8687
    8788    // return operation status
  • trunk/kernel/devices/dev_mmc.h

    r457 r565  
    2727#include <kernel_config.h>
    2828#include <hal_kernel_types.h>
    29 #include <spinlock.h>
    3029
    3130/*****************************************************************************************
     
    4645 * As these operations consume few cycles, and access conflicts are expected to be
    4746 * rare events, the calling threads use a busy waiting strategy to get the device
    48  * spinlock, but do not register in the device waiting queue, and no server thread
     47 * busylock, but do not register in the device waiting queue, and no server thread
    4948 * is used for this device.
    5049 ****************************************************************************************/
  • trunk/kernel/devices/dev_nic.c

    r492 r565  
    9999    core_t * core = thread_ptr->core;
    100100
     101// check thread can yield
     102assert( (thread_ptr->busylocks == 0),
     103"cannot yield : busylocks = %d\n", thread_ptr->busylocks );
     104
    101105#if DEBUG_DEV_NIC_RX
    102106uint32_t cycle = (uint32_t)hal_get_cycles();
     
    133137        dev_pic_enable_irq( core->lid , dev_xp );
    134138
    135         // block on THREAD_BLOCKED_IO condition and deschedule
     139        // block client thread on THREAD_BLOCKED_IO
    136140        thread_block( XPTR( local_cxy , thread_ptr ) , THREAD_BLOCKED_IO );
     141
     142        // deschedule client thread
    137143        sched_yield("client blocked on I/O");
    138144
     
    176182    // get local pointer on core running this kernel thead
    177183    core_t * core = thread_ptr->core;
     184
     185// check thread can yield
     186assert( (thread_ptr->busylocks == 0),
     187"cannot yield : busylocks = %d\n", thread_ptr->busylocks );
    178188
    179189#if DEBUG_DEV_NIC_RX
     
    211221        dev_pic_enable_irq( core->lid ,dev_xp );
    212222
    213         // block on THREAD_BLOCKED I/O condition and deschedule
     223        // block client thread on THREAD_BLOCKED I/O condition
    214224        thread_block( XPTR( local_cxy , thread_ptr ) , THREAD_BLOCKED_IO );
     225
     226        // deschedule client thread
    215227        sched_yield("client blocked on I/O");
    216228
  • trunk/kernel/devices/dev_pic.c

    r483 r565  
    2828#include <string.h>
    2929#include <thread.h>
     30#include <remote_busylock.h>
    3031#include <hal_drivers.h>
    3132#include <dev_pic.h>
     
    216217}
    217218
    218 /////////////////////////////
     219///////////////////////////////////
    219220void dev_pic_inputs_display( void )
    220221{
    221222    uint32_t k;
    222     uint32_t save_sr;
    223223
    224224    // get pointers on TXT0 chdev
     
    231231
    232232    // get TXT0 lock in busy waiting mode
    233     remote_spinlock_lock_busy( lock_xp , &save_sr );
     233    remote_busylock_acquire( lock_xp );
    234234
    235235    nolock_printk("\n***** iopic_inputs\n");
     
    253253
    254254    // release TXT0 lock
    255     remote_spinlock_unlock_busy( lock_xp , save_sr );
    256 }
    257 
    258 
     255    remote_busylock_release( lock_xp );
     256}
     257
     258
  • trunk/kernel/devices/dev_txt.c

    r540 r565  
    22 * dev_txt.c - TXT (Text Terminal) generic device API implementation.
    33 *
    4  * Author  Alain Greiner    (2016)
     4 * Author  Alain Greiner    (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2727#include <hal_drivers.h>
    2828#include <thread.h>
     29#include <remote_busylock.h>
    2930#include <chdev.h>
    3031#include <rpc.h>
     
    3839extern chdev_directory_t  chdev_dir;         // allocated in kernel_init.c
    3940
     41
    4042#if (DEBUG_SYS_READ & 1)
    4143extern uint32_t enter_txt_read;
     
    4850#endif
    4951
    50 ////////////////////////////////////////
     52///////////////////////////////////////////////////
    5153const char * dev_txt_type_str( dev_txt_cmd_t type )
    5254{
     
    8183    txt->ext.txt.owner_xp = XPTR_NULL;
    8284    xlist_root_init( XPTR( local_cxy, &txt->ext.txt.root ) );
    83     remote_spinlock_init( XPTR( local_cxy , &txt->ext.txt.lock ) );
     85    remote_busylock_init( XPTR( local_cxy , &txt->ext.txt.lock ), LOCK_CHDEV_TXTLIST );
    8486   
    8587    // call driver init function
     
    257259}
    258260
    259 //////////////////////////////////////////////
    260 error_t dev_txt_sync_write( char    * buffer,
    261                             uint32_t   count )
     261////////////////////////////////////////////////
     262error_t dev_txt_sync_write( const char * buffer,
     263                            uint32_t     count )
    262264{
    263265    // get extended pointer on TXT[0] chdev
     
    269271    // get TXTO chdev cluster and local pointer
    270272    cxy_t    dev_cxy  = GET_CXY( dev_xp );
    271     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     273    chdev_t * dev_ptr = GET_PTR( dev_xp );
    272274
    273275    // get driver command function
  • trunk/kernel/devices/dev_txt.h

    r539 r565  
    2828#include <hal_kernel_types.h>
    2929#include <xlist.h>
    30 #include <remote_spinlock.h>
     30#include <remote_busylock.h>
    3131
    3232/****  Forward declarations  ****/
     
    5757{
    5858    xptr_t            owner_xp;  /*! ext. pointer on current process owner (reference)   */
    59     xlist_entry_t     root;      /*! root of list of processes attached to   same TXT    */
    60     remote_spinlock_t lock;      /*! lock protecting this list                           */
     59    xlist_entry_t     root;      /*! root of list of processes attached to same TXT      */
     60    remote_busylock_t lock;      /*! lock protecting this list                           */
    6161}
    6262txt_extend_t;
     
    103103typedef struct txt_sync_args_s
    104104{
    105     xptr_t      dev_xp;    /*! extended pointer on the TXT0_TX device descriptor            */
    106     char      * buffer;    /*! local pointer on characters array                         */
    107     uint32_t    count;     /*! number of characters in buffer                            */
     105    xptr_t       dev_xp;    /*! extended pointer on the TXT0_TX device descriptor        */
     106    const char * buffer;    /*! local pointer on characters array                        */
     107    uint32_t     count;     /*! number of characters in buffer                           */
    108108    uint32_t    channel;   /*! channel, aka which tty to write to                        */
    109109}
     
    172172 * @ returns 0 if success / returns EINVAL if error.
    173173 ***************************************************************************************/
    174 error_t dev_txt_sync_write( char     * buffer,
    175                             uint32_t   count );
     174error_t dev_txt_sync_write( const char     * buffer,
     175                            uint32_t         count );
    176176
    177177#endif  /* _DEV_TXT_H_ */
Note: See TracChangeset for help on using the changeset viewer.