Changeset 602 for trunk/kernel/fs/devfs.c
- Timestamp:
- Dec 3, 2018, 12:15:53 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/devfs.c
r598 r602 86 86 87 87 ///////////////////////////////////////////////// 88 void devfs_global_init( xptr_t parent_inode_xp,88 void devfs_global_init( xptr_t root_inode_xp, 89 89 xptr_t * devfs_dev_inode_xp, 90 90 xptr_t * devfs_external_inode_xp ) 91 91 { 92 92 error_t error; 93 xptr_t unused_xp; // required by vfs_add_child_in_parent() 93 94 94 95 // creates DEVFS "dev" inode in cluster 0 … … 96 97 INODE_TYPE_DIR, 97 98 FS_TYPE_DEVFS, 98 parent_inode_xp,99 root_inode_xp, 99 100 "dev", 100 NULL,101 devfs_dev_inode_xp ); 101 &unused_xp, 102 devfs_dev_inode_xp ); 102 103 103 104 assert( (error == 0) , "cannot create <dev>\n" ); … … 117 118 *devfs_dev_inode_xp, 118 119 "external", 119 NULL,120 devfs_external_inode_xp ); 120 &unused_xp, 121 devfs_external_inode_xp ); 121 122 122 123 assert( (error == 0) , "cannot create <external>\n" ); … … 129 130 #endif 130 131 131 } 132 } // end devfs_global_init() 132 133 133 134 /////////////////////////////////////////////////// … … 141 142 chdev_t * chdev_ptr; 142 143 xptr_t inode_xp; 144 cxy_t inode_cxy; 145 vfs_inode_t * inode_ptr; 143 146 uint32_t channel; 147 xptr_t unused_xp; // required by add_child_in_parent() 144 148 145 149 // create "internal" directory … … 150 154 devfs_dev_inode_xp, 151 155 node_name, 152 NULL,156 &unused_xp, 153 157 devfs_internal_inode_xp ); 154 158 #if DEBUG_DEVFS_INIT … … 164 168 if( chdev_xp != XPTR_NULL) 165 169 { 166 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );170 chdev_ptr = GET_PTR( chdev_xp ); 167 171 vfs_add_child_in_parent( local_cxy, 168 172 INODE_TYPE_DEV, … … 170 174 *devfs_internal_inode_xp, 171 175 chdev_ptr->name, 172 GET_PTR( chdev_xp ),176 &unused_xp, 173 177 &inode_xp ); 178 179 // update child inode "extend" field 180 inode_cxy = GET_CXY( inode_xp ); 181 inode_ptr = GET_PTR( inode_xp ); 182 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr ); 183 174 184 #if DEBUG_DEVFS_INIT 175 185 cycle = (uint32_t)hal_get_cycles(); … … 184 194 for( channel = 0 ; channel < LOCAL_CLUSTER->cores_nr ; channel++ ) 185 195 { 186 chdev_xp = chdev_dir.dma[channel];196 chdev_xp = chdev_dir.dma[channel]; 187 197 if( chdev_xp != XPTR_NULL) 188 198 { 189 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );199 chdev_ptr = GET_PTR( chdev_xp ); 190 200 vfs_add_child_in_parent( local_cxy, 191 201 INODE_TYPE_DEV, … … 193 203 *devfs_internal_inode_xp, 194 204 chdev_ptr->name, 195 GET_PTR( chdev_xp ),205 &unused_xp, 196 206 &inode_xp ); 207 208 // update child inode "extend" field 209 inode_cxy = GET_CXY( inode_xp ); 210 inode_ptr = GET_PTR( inode_xp ); 211 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr ); 212 197 213 #if DEBUG_DEVFS_INIT 198 214 cycle = (uint32_t)hal_get_cycles(); … … 209 225 { 210 226 chdev_cxy = GET_CXY( chdev_xp ); 211 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );227 chdev_ptr = GET_PTR( chdev_xp ); 212 228 if( chdev_cxy == local_cxy ) 213 229 { … … 217 233 devfs_external_inode_xp, 218 234 chdev_ptr->name, 219 GET_PTR( chdev_xp ),235 &unused_xp, 220 236 &inode_xp ); 237 238 // update child inode "extend" field 239 inode_cxy = GET_CXY( inode_xp ); 240 inode_ptr = GET_PTR( inode_xp ); 241 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr ); 242 221 243 #if DEBUG_DEVFS_INIT 222 244 cycle = (uint32_t)hal_get_cycles(); … … 233 255 { 234 256 chdev_cxy = GET_CXY( chdev_xp ); 235 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );257 chdev_ptr = GET_PTR( chdev_xp ); 236 258 if( chdev_cxy == local_cxy ) 237 259 { … … 241 263 devfs_external_inode_xp, 242 264 chdev_ptr->name, 243 GET_PTR( chdev_xp ),265 &unused_xp, 244 266 &inode_xp ); 267 268 // update child inode "extend" field 269 inode_cxy = GET_CXY( inode_xp ); 270 inode_ptr = GET_PTR( inode_xp ); 271 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr ); 272 245 273 #if DEBUG_DEVFS_INIT 246 274 cycle = (uint32_t)hal_get_cycles(); … … 256 284 { 257 285 chdev_xp = chdev_dir.txt_rx[channel]; 286 if( chdev_xp != XPTR_NULL ) 287 { 288 chdev_cxy = GET_CXY( chdev_xp ); 289 chdev_ptr = GET_PTR( chdev_xp ); 290 if( chdev_cxy == local_cxy ) 291 { 292 vfs_add_child_in_parent( local_cxy, 293 INODE_TYPE_DEV, 294 FS_TYPE_DEVFS, 295 devfs_external_inode_xp, 296 chdev_ptr->name, 297 &unused_xp, 298 &inode_xp ); 299 300 // update child inode "extend" field 301 inode_cxy = GET_CXY( inode_xp ); 302 inode_ptr = GET_PTR( inode_xp ); 303 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr ); 304 305 #if DEBUG_DEVFS_INIT 306 cycle = (uint32_t)hal_get_cycles(); 307 if( DEBUG_DEVFS_INIT < cycle ) 308 printk("\n[%s] thread[%x,%x] created <txt_rx[%d]> inode in cluster %x\n", 309 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 310 #endif 311 } 312 } 313 } 314 315 // create a TXT_TX inode in each cluster containing a TXT_TX chdev 316 for( channel = 0 ; channel < CONFIG_MAX_TXT_CHANNELS ; channel++ ) 317 { 318 chdev_xp = chdev_dir.txt_tx[channel]; 319 if( chdev_xp != XPTR_NULL ) 320 { 321 chdev_cxy = GET_CXY( chdev_xp ); 322 chdev_ptr = GET_PTR( chdev_xp ); 323 if( chdev_cxy == local_cxy ) 324 { 325 vfs_add_child_in_parent( local_cxy, 326 INODE_TYPE_DEV, 327 FS_TYPE_DEVFS, 328 devfs_external_inode_xp, 329 chdev_ptr->name, 330 &unused_xp, 331 &inode_xp ); 332 333 // update child inode "extend" field 334 inode_cxy = GET_CXY( inode_xp ); 335 inode_ptr = GET_PTR( inode_xp ); 336 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr ); 337 338 #if DEBUG_DEVFS_INIT 339 cycle = (uint32_t)hal_get_cycles(); 340 if( DEBUG_DEVFS_INIT < cycle ) 341 printk("\n[%s] thread[%x,%x] created <txt_tx[%d]> inode in cluster %x\n", 342 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 343 #endif 344 } 345 } 346 } 347 348 // create an IOC inode in each cluster containing an IOC chdev 349 for( channel = 0 ; channel < CONFIG_MAX_IOC_CHANNELS ; channel++ ) 350 { 351 chdev_xp = chdev_dir.ioc[channel]; 352 if( chdev_xp != XPTR_NULL ) 353 { 354 chdev_cxy = GET_CXY( chdev_xp ); 355 chdev_ptr = GET_PTR( chdev_xp ); 356 if( chdev_cxy == local_cxy ) 357 { 358 vfs_add_child_in_parent( local_cxy, 359 INODE_TYPE_DEV, 360 FS_TYPE_DEVFS, 361 devfs_external_inode_xp, 362 chdev_ptr->name, 363 &unused_xp, 364 &inode_xp ); 365 366 // update child inode "extend" field 367 inode_cxy = GET_CXY( inode_xp ); 368 inode_ptr = GET_PTR( inode_xp ); 369 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr ); 370 371 #if DEBUG_DEVFS_INIT 372 cycle = (uint32_t)hal_get_cycles(); 373 if( DEBUG_DEVFS_INIT < cycle ) 374 printk("\n[%s] thread[%x,%x] created <ioc[%d]> inode in cluster %x\n", 375 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 376 #endif 377 } 378 } 379 } 380 381 // create a FBF inode in each cluster containing a FBF chdev 382 for( channel = 0 ; channel < CONFIG_MAX_FBF_CHANNELS ; channel++ ) 383 { 384 chdev_xp = chdev_dir.fbf[channel]; 385 if( chdev_xp != XPTR_NULL ) 386 { 387 chdev_cxy = GET_CXY( chdev_xp ); 388 chdev_ptr = GET_PTR( chdev_xp ); 389 if( chdev_cxy == local_cxy ) 390 { 391 vfs_add_child_in_parent( local_cxy, 392 INODE_TYPE_DEV, 393 FS_TYPE_DEVFS, 394 devfs_external_inode_xp, 395 chdev_ptr->name, 396 &unused_xp, 397 &inode_xp ); 398 399 // update child inode "extend" field 400 inode_cxy = GET_CXY( inode_xp ); 401 inode_ptr = GET_PTR( inode_xp ); 402 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr ); 403 404 #if DEBUG_DEVFS_INIT 405 cycle = (uint32_t)hal_get_cycles(); 406 if( DEBUG_DEVFS_INIT < cycle ) 407 printk("\n[%s] thread[%x,%x] created <fbf[%d]> inode in cluster %x\n", 408 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 409 #endif 410 } 411 } 412 } 413 414 // create a NIC_RX inode in each cluster containing a NIC_RX chdev 415 for( channel = 0 ; channel < CONFIG_MAX_NIC_CHANNELS ; channel++ ) 416 { 417 chdev_xp = chdev_dir.nic_rx[channel]; 258 418 if( chdev_xp != XPTR_NULL ) 259 419 { … … 267 427 devfs_external_inode_xp, 268 428 chdev_ptr->name, 269 GET_PTR( chdev_xp ),429 &unused_xp, 270 430 &inode_xp ); 271 431 #if DEBUG_DEVFS_INIT 272 432 cycle = (uint32_t)hal_get_cycles(); 273 433 if( DEBUG_DEVFS_INIT < cycle ) 274 printk("\n[%s] thread[%x,%x] created < txt_rx[%d]> inode in cluster %x\n",434 printk("\n[%s] thread[%x,%x] created <nic_rx[%d]> inode in cluster %x\n", 275 435 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 276 436 #endif … … 279 439 } 280 440 281 // create a TXT_TX inode in each cluster containing a TXT_TX chdev282 for( channel = 0 ; channel < CONFIG_MAX_ TXT_CHANNELS ; channel++ )283 { 284 chdev_xp = chdev_dir. txt_tx[channel];441 // create a NIC_TX inode in each cluster containing a NIC_TX chdev 442 for( channel = 0 ; channel < CONFIG_MAX_NIC_CHANNELS ; channel++ ) 443 { 444 chdev_xp = chdev_dir.nic_tx[channel]; 285 445 if( chdev_xp != XPTR_NULL ) 286 446 { 287 447 chdev_cxy = GET_CXY( chdev_xp ); 288 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );448 chdev_ptr = GET_PTR( chdev_xp ); 289 449 if( chdev_cxy == local_cxy ) 290 450 { … … 294 454 devfs_external_inode_xp, 295 455 chdev_ptr->name, 296 GET_PTR( chdev_xp ),456 &unused_xp, 297 457 &inode_xp ); 298 #if DEBUG_DEVFS_INIT 299 cycle = (uint32_t)hal_get_cycles(); 300 if( DEBUG_DEVFS_INIT < cycle ) 301 printk("\n[%s] thread[%x,%x] created <txt_tx[%d]> inode in cluster %x\n", 302 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 303 #endif 304 } 305 } 306 } 307 308 // create an IOC inode in each cluster containing an IOC chdev 309 for( channel = 0 ; channel < CONFIG_MAX_IOC_CHANNELS ; channel++ ) 310 { 311 chdev_xp = chdev_dir.ioc[channel]; 312 if( chdev_xp != XPTR_NULL ) 313 { 314 chdev_cxy = GET_CXY( chdev_xp ); 315 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp ); 316 if( chdev_cxy == local_cxy ) 317 { 318 vfs_add_child_in_parent( local_cxy, 319 INODE_TYPE_DEV, 320 FS_TYPE_DEVFS, 321 devfs_external_inode_xp, 322 chdev_ptr->name, 323 GET_PTR( chdev_xp ), 324 &inode_xp ); 325 #if DEBUG_DEVFS_INIT 326 cycle = (uint32_t)hal_get_cycles(); 327 if( DEBUG_DEVFS_INIT < cycle ) 328 printk("\n[%s] thread[%x,%x] created <ioc[%d]> inode in cluster %x\n", 329 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 330 #endif 331 } 332 } 333 } 334 335 // create a FBF inode in each cluster containing a FBF chdev 336 for( channel = 0 ; channel < CONFIG_MAX_FBF_CHANNELS ; channel++ ) 337 { 338 chdev_xp = chdev_dir.fbf[channel]; 339 if( chdev_xp != XPTR_NULL ) 340 { 341 chdev_cxy = GET_CXY( chdev_xp ); 342 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp ); 343 if( chdev_cxy == local_cxy ) 344 { 345 vfs_add_child_in_parent( local_cxy, 346 INODE_TYPE_DEV, 347 FS_TYPE_DEVFS, 348 devfs_external_inode_xp, 349 chdev_ptr->name, 350 GET_PTR( chdev_xp ), 351 &inode_xp ); 352 #if DEBUG_DEVFS_INIT 353 cycle = (uint32_t)hal_get_cycles(); 354 if( DEBUG_DEVFS_INIT < cycle ) 355 printk("\n[%s] thread[%x,%x] created <fbf[%d]> inode in cluster %x\n", 356 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 357 #endif 358 } 359 } 360 } 361 362 // create a NIC_RX inode in each cluster containing a NIC_RX chdev 363 for( channel = 0 ; channel < CONFIG_MAX_NIC_CHANNELS ; channel++ ) 364 { 365 chdev_xp = chdev_dir.nic_rx[channel]; 366 if( chdev_xp != XPTR_NULL ) 367 { 368 chdev_cxy = GET_CXY( chdev_xp ); 369 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp ); 370 if( chdev_cxy == local_cxy ) 371 { 372 vfs_add_child_in_parent( local_cxy, 373 INODE_TYPE_DEV, 374 FS_TYPE_DEVFS, 375 devfs_external_inode_xp, 376 chdev_ptr->name, 377 GET_PTR( chdev_xp ), 378 &inode_xp ); 379 #if DEBUG_DEVFS_INIT 380 cycle = (uint32_t)hal_get_cycles(); 381 if( DEBUG_DEVFS_INIT < cycle ) 382 printk("\n[%s] thread[%x,%x] created <nic_rx[%d]> inode in cluster %x\n", 383 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 384 #endif 385 } 386 } 387 } 388 389 // create a NIC_TX inode in each cluster containing a NIC_TX chdev 390 for( channel = 0 ; channel < CONFIG_MAX_NIC_CHANNELS ; channel++ ) 391 { 392 chdev_xp = chdev_dir.nic_tx[channel]; 393 if( chdev_xp != XPTR_NULL ) 394 { 395 chdev_cxy = GET_CXY( chdev_xp ); 396 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp ); 397 if( chdev_cxy == local_cxy ) 398 { 399 vfs_add_child_in_parent( local_cxy, 400 INODE_TYPE_DEV, 401 FS_TYPE_DEVFS, 402 devfs_external_inode_xp, 403 chdev_ptr->name, 404 GET_PTR( chdev_xp ), 405 &inode_xp ); 458 459 // update child inode "extend" field 460 inode_cxy = GET_CXY( inode_xp ); 461 inode_ptr = GET_PTR( inode_xp ); 462 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr ); 463 406 464 #if DEBUG_DEVFS_INIT 407 465 cycle = (uint32_t)hal_get_cycles(); … … 462 520 channel = hal_remote_l32( XPTR( chdev_cxy , &chdev_ptr->channel ) ); 463 521 522 // Only TXT devices are associated to a pseudo-file 464 523 assert( ( func == DEV_FUNC_TXT ) , __FUNCTION__, "illegal device func_type"); 465 524
Note: See TracChangeset
for help on using the changeset viewer.