Changeset 346 for trunk/kernel
- Timestamp:
- Aug 9, 2017, 10:24:06 AM (7 years ago)
- Location:
- trunk/kernel
- Files:
-
- 3 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 -
trunk/kernel/devices/dev_iob.h
r279 r346 44 44 45 45 struct chdev_s; 46 47 /***************************************************************************************** 48 * This defines the specific extension for the IOB chdev descriptor. 49 ****************************************************************************************/ 50 51 typedef void (iob_set_active_t) ( xptr_t iob_xp, uint32_t value ); 52 typedef void (iob_set_ptpr_t) ( xptr_t iob_xp, uint32_t value ); 53 typedef void (iob_inval_page_t) ( xptr_t iob_xp, vpn_t vpn ); 54 typedef uint32_t (iob_get_bvar_t) ( xptr_t iob_xp ); 55 typedef uint32_t (iob_get_srcid_t) ( xptr_t iob_xp ); 56 typedef uint32_t (iob_get_error_t) ( xptr_t iob_xp ); 57 58 typedef struct iob_extend_s 59 { 60 iob_set_active_t * set_active; 61 iob_set_ptpr_t * set_ptpr; 62 iob_inval_page_t * inval_page; 63 iob_get_bvar_t * get_bvar; 64 iob_get_srcid_t * get_srcid; 65 iob_get_error_t * get_error; 66 } 67 iob_extend_t; 46 68 47 69 /***************************************************************************************** -
trunk/kernel/kern/chdev.h
r317 r346 30 30 #include <metafs.h> 31 31 #include <remote_spinlock.h> 32 #include <dev_iob.h> 32 33 #include <dev_ioc.h> 33 34 #include <dev_nic.h> … … 138 139 union 139 140 { 141 iob_extend_t iob; /*! IOB specific extension */ 140 142 ioc_extend_t ioc; /*! IOC specific extension */ 141 143 nic_extend_t nic; /*! NIC specific extension */
Note: See TracChangeset
for help on using the changeset viewer.