Changeset 23 for trunk/kernel/devices/dev_ioc.c
- Timestamp:
- Jun 18, 2017, 10:06:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_ioc.c
r14 r23 55 55 uint32_t channel = chdev->channel; 56 56 57 // set chdev name 58 strcpy( chdev->name , "ioc" ); 59 57 60 // set driver specific fields in chdev descriptor and call driver init function 58 61 if( impl == IMPL_IOC_BDV ) … … 64 67 else if( impl == IMPL_IOC_HBA ) 65 68 { 66 chdev->cmd = &soclib_hba_c ommand;69 chdev->cmd = &soclib_hba_cmd; 67 70 chdev->isr = &soclib_hba_isr; 68 71 soclib_hba_init( chdev ); … … 109 112 ////////////////////////////////////////////////////////////////////////////////// 110 113 // This static function is called by dev_ioc_read() & dev_ioc_write() functions. 111 // It builds and registers the command in the calling thread descriptor, after 112 // translation of buffer virtual address to physical address. 114 // It builds and registers the command in the calling thread descriptor. 113 115 // Then, it registers the calling thead in chdev waiting queue. 114 116 // Finally it blocks on the THREAD_BLOCKED_DEV condition and deschedule. 115 117 ////////////////////////////////////i///////////////////////////////////////////// 116 static error_t dev_ioc_access( bool_t to_mem,117 char* buffer,118 uint32_t lba,119 uint32_t count )118 static error_t dev_ioc_access( uint32_t cmd_type, 119 uint8_t * buffer, 120 uint32_t lba, 121 uint32_t count ) 120 122 { 121 123 thread_t * this = CURRENT_THREAD; // pointer on client thread 122 124 123 error_t error;124 paddr_t buf_paddr;125 126 // Get buffer physical address127 error = vmm_v2p_translate( CONFIG_KERNEL_IDENTITY , buffer , &buf_paddr );128 129 if( error ) return EINVAL;130 131 125 ioc_dmsg("\n[INFO] in %s : thread %x in process %x" 132 " for lba = %x / vaddr = %x / paddr = %l/ at cycle %d\n",126 " for lba = %x / buffer = %x / at cycle %d\n", 133 127 __FUNCTION__ , this->trdid , this->process->pid , 134 lba , ( uint32_t)buffer , buf_paddr , hal_time_stamp() );128 lba , (intptr_t)buffer , hal_time_stamp() ); 135 129 136 130 #if USE_IOB // software L2/L3 cache coherence for memory buffer 137 131 138 if ( t o_mem ) dev_mmc_inval( buf_paddr, count<<9 );139 else dev_mmc_sync( buf_paddr, count<<9 );132 if ( type == IOC_READ ) dev_mmc_inval( XPTR( local_cxy , buffer ) , count<<9 ); 133 else dev_mmc_sync ( XPTR( local_cxy , buffer ) , count<<9 ); 140 134 141 135 #endif // end software L2/L3 cache coherence … … 148 142 // register command in calling thread descriptor 149 143 this->command.ioc.dev_xp = dev_xp; 150 this->command.ioc.t o_mem = to_mem;144 this->command.ioc.type = cmd_type; 151 145 this->command.ioc.buf_xp = XPTR( local_cxy , buffer ); 152 146 this->command.ioc.lba = lba; … … 169 163 170 164 //////////////////////////////////////////// 171 error_t dev_ioc_read( char* buffer,165 error_t dev_ioc_read( uint8_t * buffer, 172 166 uint32_t lba, 173 167 uint32_t count ) 174 168 { 175 return dev_ioc_access( true, buffer , lba , count );169 return dev_ioc_access( IOC_READ , buffer , lba , count ); 176 170 } 177 171 178 172 //////////////////////////////////////////// 179 error_t dev_ioc_write( char* buffer,180 uint32_t 181 uint32_t 182 { 183 return dev_ioc_access( false, buffer , lba , count );173 error_t dev_ioc_write( uint8_t * buffer, 174 uint32_t lba, 175 uint32_t count ) 176 { 177 return dev_ioc_access( IOC_WRITE , buffer , lba , count ); 184 178 } 179 180 ///////////////////////////////////////////// 181 error_t dev_ioc_sync_read( uint8_t * buffer, 182 uint32_t lba, 183 uint32_t count ) 184 { 185 // get pointer on calling thread 186 thread_t * this = CURRENT_THREAD; 187 188 #if USE_IOB // software L2/L3 cache coherence for memory buffer 189 190 dev_mmc_inval( XPTR( local_cxy , buffer ) , count<<9 ); 191 192 #endif // end software L2/L3 cache coherence 193 194 // get extended pointer on IOC[0] chdev 195 xptr_t dev_xp = chdev_dir.ioc[0]; 196 197 assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , "undefined IOC chdev descriptor" ); 198 199 // register command in calling thread descriptor 200 this->command.ioc.dev_xp = dev_xp; 201 this->command.ioc.type = IOC_SYNC_READ; 202 this->command.ioc.buf_xp = XPTR( local_cxy , buffer ); 203 this->command.ioc.lba = lba; 204 this->command.ioc.count = count; 205 206 // get driver command function 207 cxy_t dev_cxy = GET_CXY( dev_xp ); 208 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 209 dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->cmd ) ); 210 211 // call directly driver command 212 cmd( XPTR( local_cxy , this ) ); 213 214 // return I/O operation status from calling thread descriptor 215 return this->command.ioc.error; 216 } 217
Note: See TracChangeset
for help on using the changeset viewer.