Changeset 346 for trunk/kernel/devices/dev_iob.c
- Timestamp:
- Aug 9, 2017, 10:24:06 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_iob.c
r23 r346 28 28 #include <chdev.h> 29 29 #include <printk.h> 30 #include < soclib_iob.h>30 #include <hal_drivers.h> 31 31 #include <dev_iob.h> 32 32 … … 34 34 void dev_iob_init( chdev_t * chdev ) 35 35 { 36 // get implementation 36 // get implementation 37 37 uint32_t impl = chdev->impl; 38 38 … … 41 41 42 42 // 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 ); 51 44 } 52 45 … … 58 51 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 59 52 60 // get implementation from chdev descriptor61 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 ) ); 62 55 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 ) ); 75 60 } 76 61 … … 82 67 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 83 68 84 // get implementation from chdev descriptor85 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 ) ); 86 71 87 72 // 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 ) ); 99 76 } 100 77 … … 107 84 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 108 85 109 // get implementation from chdev descriptor110 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 ) ); 111 88 112 89 // 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 124 94 } 125 95 126 96 //////////////////////////////////////// 127 97 void dev_iob_inval_page( xptr_t dev_xp, … … 132 102 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 133 103 134 // get implementation from chdev descriptor135 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 ) ); 136 106 137 107 // 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 ) ); 149 111 } 150 112 … … 159 121 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 160 122 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 ) ); 163 127 164 128 // 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 ) ); 178 134 } 179 135
Note: See TracChangeset
for help on using the changeset viewer.