Changeset 407 for trunk/kernel/devices/dev_txt.c
- Timestamp:
- Nov 7, 2017, 3:08:12 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_txt.c
r406 r407 27 27 #include <hal_drivers.h> 28 28 #include <thread.h> 29 #include <chdev.h> 29 30 #include <rpc.h> 30 31 #include <printk.h> … … 36 37 37 38 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 39 40 #if CONFIG_READ_DEBUG 41 extern uint32_t enter_txt_read; 42 extern uint32_t exit_txt_read; 43 #endif 38 44 39 45 ////////////////////////////////// … … 47 53 uint32_t channel = txt->channel; 48 54 uint32_t impl = txt->impl; 55 bool_t is_rx = txt->is_rx; 49 56 50 57 assert( (pic_xp != XPTR_NULL) || (channel == 0) , __FUNCTION__ , … … 52 59 53 60 // set chdev name 54 snprintf( txt->name , 16 , "txt_%d" , channel ); 61 if( is_rx ) snprintf( txt->name , 16 , "txt%d_rx" , channel ); 62 else snprintf( txt->name , 16 , "txt%d_tx" , channel ); 55 63 56 64 // call driver init function … … 61 69 if( channel != 0 && impl != IMPL_TXT_RS2 ) 62 70 { 63 // select a core to execute the TXTserver thread71 // select a core to execute the server thread 64 72 lid_t lid = cluster_select_local_core(); 65 73 66 // bind TXTIRQ to the selected core74 // bind IRQ to the selected core 67 75 dev_pic_bind_irq( lid , txt ); 68 76 69 // enable TXTIRQ77 // enable IRQ 70 78 dev_pic_enable_irq( lid , XPTR( local_cxy , txt ) ); 71 79 … … 99 107 uint32_t count ) 100 108 { 109 xptr_t dev_xp; 101 110 thread_t * this = CURRENT_THREAD; 102 111 103 txt_dmsg("\n[DMSG] in %s : thread %x in process %x enters\n",104 __FUNCTION__ , this->trdid , this->process->pid);112 txt_dmsg("\n[DBG] %s : core[%x,%d] (thread %s) enters / cycle %d\n", 113 __FUNCTION__, local_cxy, this->core->lid, thread_type_str(this->type), hal_time_stamp() ); 105 114 106 115 // check channel argument … … 108 117 109 118 // get extended pointer on remote TXT chdev descriptor 110 xptr_t dev_xp = chdev_dir.txt[channel]; 119 if( type == TXT_WRITE ) dev_xp = chdev_dir.txt_tx[channel]; 120 else dev_xp = chdev_dir.txt_rx[channel]; 111 121 112 122 assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , "undefined TXT chdev descriptor" ); … … 121 131 // block client thread on THREAD_BLOCKED_IO and deschedule. 122 132 // it is re-activated by the ISR signaling IO operation completion. 123 chdev_register_command( dev_xp , this);133 chdev_register_command( dev_xp ); 124 134 125 txt_dmsg("\n[DMSG] in %s : thread %x in process %x completes / error =%d\n",126 __FUNCTION__ , this->trdid , this->process->pid , this->txt_cmd.error);135 txt_dmsg("\n[DBG] %s : core[%x,%d] (thread %s) exit / cycle %d\n", 136 __FUNCTION__, local_cxy, this->core->lid, thread_type_str(this->type), hal_time_stamp() ); 127 137 128 138 // return I/O operation status from calling thread descriptor … … 135 145 uint32_t count ) 136 146 { 137 return dev_txt_access( TXT_WRITE , channel , buffer , count ); 147 error_t error = dev_txt_access( TXT_WRITE , channel , buffer , count ); 148 return error; 138 149 } 139 150 … … 142 153 char * buffer ) 143 154 { 144 return dev_txt_access( TXT_READ , channel , buffer , 1 ); 155 156 #if CONFIG_READ_DEBUG 157 enter_txt_read = hal_time_stamp(); 158 #endif 159 160 error_t error = dev_txt_access( TXT_READ , channel , buffer , 1 ); 161 162 #if CONFIG_READ_DEBUG 163 exit_txt_read = hal_time_stamp(); 164 #endif 165 166 return error; 167 145 168 } 146 169 147 /////////////////////////////////////////////// 148 error_t dev_txt_sync_write( uint32_t channel, 149 char * buffer, 170 ////////////////////////////////////////////// 171 error_t dev_txt_sync_write( char * buffer, 150 172 uint32_t count ) 151 173 { 152 // get pointer on calling thread153 thread_t * this = CURRENT_THREAD;174 // get extended pointer on TXT[0] chdev 175 xptr_t dev_xp = chdev_dir.txt_tx[0]; 154 176 155 // get extended pointer on TXT[0] chdev156 xptr_t dev_xp = chdev_dir.txt[channel];177 assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , 178 "undefined TXT0 chdev descriptor" ); 157 179 158 assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , "undefined TXT0 chdev descriptor" ); 159 160 // register command in calling thread descriptor 161 this->txt_cmd.dev_xp = dev_xp; 162 this->txt_cmd.type = TXT_SYNC_WRITE; 163 this->txt_cmd.buf_xp = XPTR( local_cxy , buffer ); 164 this->txt_cmd.count = count; 180 // get TXTO chdev cluster and local pointer 181 cxy_t dev_cxy = GET_CXY( dev_xp ); 182 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 165 183 166 184 // get driver command function 167 cxy_t dev_cxy = GET_CXY( dev_xp ); 168 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 169 dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->cmd ) ); 185 dev_aux_t * aux = (dev_aux_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->aux ) ); 186 187 // build arguments structure 188 txt_aux_t args; 189 args.dev_xp = dev_xp; 190 args.buffer = buffer; 191 args.count = count; 170 192 171 193 // call driver function 172 cmd( XPTR( local_cxy , this ));194 aux( &args ); 173 195 174 // return I/O operation status from calling thread descriptor 175 return this->txt_cmd.error; 196 return 0; 176 197 } 177 198
Note: See TracChangeset
for help on using the changeset viewer.