Changeset 626 for trunk/kernel/devices
- Timestamp:
- Apr 29, 2019, 7:25:09 PM (6 years ago)
- Location:
- trunk/kernel/devices
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_ioc.c
r619 r626 2 2 * dev_ioc.c - IOC (Block Device Controler) generic device API implementation. 3 3 * 4 * Author Alain Greiner (2016,2017,2018 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 36 36 37 37 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 38 39 //////////////////////////////////////// 40 char * dev_ioc_cmd_str( cmd_type_t cmd ) 41 { 42 if ( cmd == IOC_READ ) return "READ"; 43 else if( cmd == IOC_WRITE ) return "WRITE"; 44 else if( cmd == IOC_SYNC_READ ) return "SYNC_READ"; 45 else if( cmd == IOC_SYNC_WRITE ) return "SYNC_WRITE"; 46 else return "undefined"; 47 } 38 48 39 49 ////////////////////////////////// … … 192 202 ////////////////////////////////////i///////////////////////////////////////////// 193 203 error_t dev_ioc_sync_access( uint32_t cmd_type, 194 uint8_t * buffer,204 xptr_t buffer_xp, 195 205 uint32_t lba, 196 206 uint32_t count ) … … 202 212 if( chdev_dir.iob ) 203 213 { 204 if (cmd_type == IOC_SYNC_READ) dev_mmc_inval( XPTR(local_cxy,buffer), count<<9 );205 else dev_mmc_sync ( XPTR(local_cxy,buffer), count<<9 );214 if (cmd_type == IOC_SYNC_READ) dev_mmc_inval( buffer_xp , count<<9 ); 215 else dev_mmc_sync ( buffer_xp , count<<9 ); 206 216 } 207 217 … … 215 225 this->ioc_cmd.dev_xp = ioc_xp; 216 226 this->ioc_cmd.type = cmd_type; 217 this->ioc_cmd.buf_xp = XPTR( local_cxy , buffer );227 this->ioc_cmd.buf_xp = buffer_xp; 218 228 this->ioc_cmd.lba = lba; 219 229 this->ioc_cmd.count = count; … … 241 251 return this->ioc_cmd.error; 242 252 243 } // end ioc_sync_access()244 245 ///////////////////////////////////////////// 246 error_t dev_ioc_sync_read( uint8_t * buffer,253 } // end dev_ioc_sync_access() 254 255 //////////////////////////////////////////////// 256 error_t dev_ioc_sync_read( xptr_t buffer_xp, 247 257 uint32_t lba, 248 258 uint32_t count ) … … 253 263 uint32_t cycle = (uint32_t)hal_get_cycles(); 254 264 if( DEBUG_DEV_IOC_RX < cycle ) 255 printk("\n[%s] thread[%x,%x] : lba %x / buffer %x / cycle %d\n", 256 __FUNCTION__ , this->process->pid, this->trdid, lba, buffer, cycle ); 257 #endif 258 259 return dev_ioc_sync_access( IOC_SYNC_READ , buffer , lba , count ); 265 printk("\n[%s] thread[%x,%x] : lba %x / buffer(%x,%x) / count %d / cycle %d\n", 266 __FUNCTION__ , this->process->pid, this->trdid, 267 lba, GET_CXY(buffer_xp), GET_PTR(buffer_xp), count, cycle ); 268 #endif 269 270 return dev_ioc_sync_access( IOC_SYNC_READ , buffer_xp , lba , count ); 260 271 } 261 272 262 ////////////////////////////////////////////// 263 error_t dev_ioc_sync_write( uint8_t * buffer,273 ///////////////////////////////////////////////// 274 error_t dev_ioc_sync_write( xptr_t buffer_xp, 264 275 uint32_t lba, 265 276 uint32_t count ) 266 277 { 267 278 268 #if DEBUG_DEV_IOC_RX 269 thread_t * this = CURRENT_THREAD; 270 uint32_t cycle = (uint32_t)hal_get_cycles(); 271 if( DEBUG_DEV_IOC_RX < cycle ) 272 printk("\n[%s] thread[%x,%x] enters / lba %x / buffer %x / cycle %d\n", 273 __FUNCTION__ , this->process->pid, this->trdid, lba, buffer, cycle ); 274 #endif 275 276 return dev_ioc_sync_access( IOC_SYNC_WRITE , buffer , lba , count ); 279 #if DEBUG_DEV_IOC_TX 280 thread_t * this = CURRENT_THREAD; 281 uint32_t cycle = (uint32_t)hal_get_cycles(); 282 if( DEBUG_DEV_IOC_TX < cycle ) 283 printk("\n[%s] thread[%x,%x] : lba %x / buffer(%x,%x) / count %d / cycle %d\n", 284 __FUNCTION__ , this->process->pid, this->trdid, 285 lba, GET_CXY(buffer_xp), GET_PTR(buffer_xp), count, cycle ); 286 #endif 287 288 return dev_ioc_sync_access( IOC_SYNC_WRITE , buffer_xp , lba , count ); 277 289 } 278 290 -
trunk/kernel/devices/dev_ioc.h
r614 r626 2 2 * dev_ioc.h - IOC (Block Device Controler) generic device API definition. 3 3 * 4 * Author Alain Greiner (2016,2017,2018 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 44 44 * - SYNC_WRITE : move blocks from memory to device, with a busy waiting policy. 45 45 46 * A READ or WRITE operation requiresdynamic ressource allocation. The calling thread46 * The READ or WRITE operations require dynamic ressource allocation. The calling thread 47 47 * is descheduled, and the work is done by the server thread associated to IOC device. 48 48 * The general scenario is detailed below. … … 66 66 * 67 67 * The SYNC_READ and SYNC_WRITE operations are used by the kernel in the initialisation 68 * phase. These operations do not not use the IOC device waiting queue, the server thread, 69 * and the IOC IRQ, but implement a busy-waiting policy for the calling thread. 68 * phase, to update the FAT (both the FAT mapper and the FAT on IOC device), or to update 69 * a directory on IOC device when a new file is created. 70 * - These synchronous operations do not not use the IOC device waiting queue, 71 * the server thread, and the IOC IRQ, but implement a busy-waiting policy 72 * for the calling thread. 73 * - As the work 70 74 *****************************************************************************************/ 71 75 … … 119 123 } 120 124 ioc_command_t; 125 126 /****************************************************************************************** 127 * This function returns a printable string for a IOC command type. 128 ****************************************************************************************** 129 * @ cmd : command type. 130 * @ return pointer on string. 131 *****************************************************************************************/ 132 char * dev_ioc_cmd_str( cmd_type_t cmd ); 121 133 122 134 /****************************************************************************************** … … 138 150 * registered in the device pending request queue, and the calling thread is descheduled, 139 151 * waiting on transfer completion. It will be resumed by the IRQ signaling completion. 140 * It must be called in the client cluster.152 * It must be called by a local thread. 141 153 ****************************************************************************************** 142 154 * @ buffer : local pointer on target buffer in memory (must be block aligned). 143 155 * @ lba : first block index on device. 144 156 * @ count : number of blocks to transfer. 145 * @ returns 0 if success / returns EINVALif error.157 * @ returns 0 if success / returns -1 if error. 146 158 *****************************************************************************************/ 147 159 error_t dev_ioc_read( uint8_t * buffer, … … 154 166 * registered in the device pending request queue, and the calling thread is descheduled, 155 167 * waiting on transfer completion. It will be resumed by the IRQ signaling completion. 156 * It must be called in the client cluster.168 * It must be called by a local thread. 157 169 ****************************************************************************************** 158 170 * @ buffer : local pointer on source buffer in memory (must be block aligned). 159 171 * @ lba : first block index on device. 160 172 * @ count : number of blocks to transfer. 161 * @ returns 0 if success / returns EINVALif error.173 * @ returns 0 if success / returns -1 if error. 162 174 *****************************************************************************************/ 163 175 error_t dev_ioc_write( uint8_t * buffer, … … 167 179 /****************************************************************************************** 168 180 * This blocking function moves one or several contiguous blocks of data 169 * from the block device to a localmemory buffer.181 * from the block device to a - possibly remote - memory buffer. 170 182 * It does not uses the IOC device waiting queue and server thread, and does not use 171 183 * the IOC IRQ, but call directly the relevant IOC driver, implementing a busy-waiting 172 184 * policy for the calling thread. 173 * It must be called in the clientcluster.174 ****************************************************************************************** 175 * @ buffer : localpointer on target buffer in memory (must be block aligned).176 * @ lba : first block index on device. 177 * @ count : number of blocks to transfer. 178 * @ returns 0 if success / returns EINVALif error.179 *****************************************************************************************/ 180 error_t dev_ioc_sync_read( uint8_t * buffer,185 * It can be called by a thread running in any cluster. 186 ****************************************************************************************** 187 * @ buffer_xp : extended pointer on target buffer in memory (must be block aligned). 188 * @ lba : first block index on device. 189 * @ count : number of blocks to transfer. 190 * @ returns 0 if success / returns -1 if error. 191 *****************************************************************************************/ 192 error_t dev_ioc_sync_read( xptr_t buffer_xp, 181 193 uint32_t lba, 182 194 uint32_t count ); … … 184 196 /****************************************************************************************** 185 197 * This blocking function moves one or several contiguous blocks of data 186 * from a localmemory buffer to the block device.198 * from a - possibly remote - memory buffer to the block device. 187 199 * It does not uses the IOC device waiting queue and server thread, and does not use 188 200 * the IOC IRQ, but call directly the relevant IOC driver, implementing a busy-waiting 189 201 * policy for the calling thread. 190 * It must be called in the clientcluster.191 ****************************************************************************************** 192 * @ buffer : localpointer on source buffer in memory (must be block aligned).193 * @ lba : first block index on device. 194 * @ count : number of blocks to transfer. 195 * @ returns 0 if success / returns EINVALif error.196 *****************************************************************************************/ 197 error_t dev_ioc_sync_write( uint8_t * buffer,202 * It can be called by a thread running in any cluster. 203 ****************************************************************************************** 204 * @ buffer_xp : extended pointer on source buffer in memory (must be block aligned). 205 * @ lba : first block index on device. 206 * @ count : number of blocks to transfer. 207 * @ returns 0 if success / returns -1 if error. 208 *****************************************************************************************/ 209 error_t dev_ioc_sync_write( xptr_t buffer_xp, 198 210 uint32_t lba, 199 211 uint32_t count ); -
trunk/kernel/devices/dev_mmc.c
r605 r626 108 108 109 109 // get buffer cluster and local pointer 110 cxy_t buf_cxy = GET_CXY( buf_xp );111 void* buf_ptr = GET_PTR( buf_xp );110 cxy_t buf_cxy = GET_CXY( buf_xp ); 111 uint8_t * buf_ptr = GET_PTR( buf_xp ); 112 112 113 assert( (((intptr_t)buf_ptr & (CONFIG_CACHE_LINE_SIZE -1)) == 0) , 114 "buffer not aligned on cache line" ); 113 // force buffer align 114 uint32_t delta = (uint32_t)buf_ptr & (CONFIG_CACHE_LINE_SIZE - 1); 115 uint8_t * base = buf_ptr - delta; 116 uint32_t size = buf_size + delta; 115 117 116 118 // store command arguments in thread descriptor 117 119 this->mmc_cmd.dev_xp = chdev_dir.mmc[buf_cxy]; 118 120 this->mmc_cmd.type = MMC_CC_INVAL; 119 this->mmc_cmd.buf_ptr = b uf_ptr;120 this->mmc_cmd.buf_size = buf_size;121 this->mmc_cmd.buf_ptr = base; 122 this->mmc_cmd.buf_size = size; 121 123 122 124 // call MMC driver … … 152 154 void * buf_ptr = GET_PTR( buf_xp ); 153 155 154 assert( (((intptr_t)buf_ptr & (CONFIG_CACHE_LINE_SIZE -1)) == 0) , 155 "buffer not aligned on cache line" ); 156 // force buffer align 157 uint32_t delta = (uint32_t)buf_ptr & (CONFIG_CACHE_LINE_SIZE - 1); 158 uint8_t * base = buf_ptr - delta; 159 uint32_t size = buf_size + delta; 156 160 157 161 // store command arguments in thread descriptor 158 162 this->mmc_cmd.dev_xp = chdev_dir.mmc[buf_cxy]; 159 163 this->mmc_cmd.type = MMC_CC_SYNC; 160 this->mmc_cmd.buf_ptr = b uf_ptr;161 this->mmc_cmd.buf_size = buf_size;164 this->mmc_cmd.buf_ptr = base; 165 this->mmc_cmd.buf_size = size; 162 166 163 167 // call MMC driver -
trunk/kernel/devices/dev_txt.c
r619 r626 2 2 * dev_txt.c - TXT (Text Terminal) generic device API implementation. 3 3 * 4 * Author Alain Greiner (2016,2017,2018 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites -
trunk/kernel/devices/dev_txt.h
r565 r626 2 2 * dev_txt.h - TXT (Text Terminal) generic device API definition. 3 3 * 4 * Author Alain Greiner (2016 )4 * Author Alain Greiner (2016,2017,2018,2019)) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 106 106 const char * buffer; /*! local pointer on characters array */ 107 107 uint32_t count; /*! number of characters in buffer */ 108 uint32_t channel; /*! channel, aka which tty to write to*/108 uint32_t channel; /*! channel, aka which tty to write to */ 109 109 } 110 110 txt_sync_args_t; 111 111 112 112 /****************************************************************************************** 113 * This function returns a printable string for the comman type.113 * This function returns a printable string for the command type. 114 114 ****************************************************************************************** 115 115 * @ type : command type (TXT_READ / TXT_WRITE / TXT_SYNC_WRITE) … … 166 166 * interfering with another possible TXT access to another terminal. 167 167 * As it is used for debug, the command arguments <buffer> and <count> are registerd 168 * in a specific " dbg_cmd" field of the calling thread.168 * in a specific "txt_syc_args_t" structure passed to the driver "aux" function. 169 169 **************************************************************************************** 170 170 * @ buffer : local pointer on source buffer containing the string.
Note: See TracChangeset
for help on using the changeset viewer.