Ignore:
Timestamp:
Aug 9, 2017, 10:24:06 AM (7 years ago)
Author:
max@…
Message:

Hide soclib_iob.

File:
1 edited

Legend:

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

    r23 r346  
    2828#include <chdev.h>
    2929#include <printk.h>
    30 #include <soclib_iob.h>
     30#include <hal_drivers.h>
    3131#include <dev_iob.h>
    3232
     
    3434void dev_iob_init( chdev_t * chdev )
    3535{
    36     // get implementation 
     36    // get implementation
    3737    uint32_t  impl = chdev->impl;
    3838
     
    4141
    4242    // call driver init function
    43     if( impl == IMPL_IOB_TSR )
    44     {
    45         soclib_iob_init( chdev );
    46     }
    47     else
    48     {
    49         assert( false , __FUNCTION__ , "undefined IOB device implementation\n" );
    50     }
     43    hal_drivers_iob_init( chdev , impl );
    5144}
    5245
     
    5851    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
    5952
    60     // get implementation from chdev descriptor
    61     uint32_t  impl = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) );
     53    // get pointer on set_active function
     54    iob_set_active_t * f = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.set_active ) );
    6255
    63     // call driver function
    64     if( impl == IMPL_IOB_TSR )
    65     {
    66         remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    67         soclib_iob_set_active( dev_xp , 1 );
    68         remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    69     }
    70     else
    71     {
    72         printk("\n[PANIC] in %s: undefined IOB device implementation\n", __FUNCTION__ );
    73         hal_core_sleep();
    74     }
     56    // call relevant driver function
     57    remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     58    f( dev_xp , 1 );
     59    remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    7560}
    7661
     
    8267    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
    8368
    84     // get implementation from chdev descriptor
    85     uint32_t  impl = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) );
     69    // get pointer on set_active function
     70    iob_set_active_t * f = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.set_active ) );
    8671
    8772    // call driver function
    88     if( impl == IMPL_IOB_TSR )
    89     {
    90         remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    91         soclib_iob_set_active( dev_xp , 0 );
    92         remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    93     }
    94     else
    95     {
    96         printk("\n[PANIC] in %s: undefined IOB device implementation\n", __FUNCTION__ );
    97         hal_core_sleep();
    98     }
     73    remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     74    f( dev_xp , 0 );
     75    remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    9976}
    10077
     
    10784    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
    10885
    109     // get implementation from chdev descriptor
    110     uint32_t  impl = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) );
     86    // get pointer on set_ptpr function
     87    iob_set_ptpr_t * f = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.set_ptpr ) );
    11188
    11289    // call driver function
    113     if( impl == IMPL_IOB_TSR )
    114     {
    115         remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    116         soclib_iob_set_ptpr( dev_xp , wdata );
    117         remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    118     }
    119     else
    120     {
    121         printk("\n[PANIC] in %s: undefined IOB device implementation\n", __FUNCTION__ );
    122         hal_core_sleep();
    123     }
     90    remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     91    f( dev_xp , wdata );
     92    remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     93
    12494}
    125                        
     95
    12696////////////////////////////////////////
    12797void dev_iob_inval_page( xptr_t  dev_xp,
     
    132102    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
    133103
    134     // get implementation from chdev descriptor
    135     uint32_t  impl = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) );
     104    // get pointer on inval_page function
     105    iob_inval_page_t * f = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.inval_page ) );
    136106
    137107    // call driver function
    138     if( impl == IMPL_IOB_TSR )
    139     {
    140         remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    141         soclib_iob_inval_page( dev_xp , vpn );
    142         remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    143     }
    144     else
    145     {
    146         printk("\n[PANIC] in %s: undefined IOB device implementation\n", __FUNCTION__ );
    147         hal_core_sleep();
    148     }
     108    remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     109    f( dev_xp , vpn );
     110    remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    149111}
    150112
     
    159121    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
    160122
    161     // get implementation from chdev descriptor
    162     uint32_t  impl = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) );
     123    // get pointer on the functions
     124    iob_get_error_t * f_get_error = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.get_error ) );
     125    iob_get_srcid_t * f_get_srcid = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.get_srcid ) );
     126    iob_get_bvar_t  * f_get_bvar  = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.get_bvar  ) );
    163127
    164128    // call driver function
    165     if( impl == IMPL_IOB_TSR )
    166     {
    167         remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    168         *error = soclib_iob_get_error( dev_xp );
    169         *srcid = soclib_iob_get_srcid( dev_xp );
    170         *bvar  = soclib_iob_get_bvar( dev_xp );
    171         remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    172     }
    173     else
    174     {
    175         printk("\n[PANIC] in %s: undefined IOB device implementation\n", __FUNCTION__ );
    176         hal_core_sleep();
    177     }
     129    remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     130    *error = f_get_error( dev_xp );
     131    *srcid = f_get_srcid( dev_xp );
     132    *bvar  = f_get_bvar( dev_xp );
     133    remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    178134}
    179135
Note: See TracChangeset for help on using the changeset viewer.