Changeset 407 for trunk/kernel/kern/kernel_init.c
- Timestamp:
- Nov 7, 2017, 3:08:12 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/kernel_init.c
r406 r407 32 32 #include <barrier.h> 33 33 #include <remote_barrier.h> 34 #include <remote_fifo.h> 34 35 #include <core.h> 35 36 #include <list.h> … … 85 86 cluster_t cluster_manager CONFIG_CACHE_LINE_ALIGNED; 86 87 87 // This variable defines the TXT0 kernel terminal 88 // This variable defines the TXT0 kernel terminal (TX only) 88 89 __attribute__((section(".kdata"))) 89 90 chdev_t txt0_chdev CONFIG_CACHE_LINE_ALIGNED; … … 121 122 vfs_ctx_t fs_context[FS_TYPES_NR] CONFIG_CACHE_LINE_ALIGNED; 122 123 124 // These variables are used by the sched_yield function to save SR value 125 __attribute__((section(".kdata"))) 126 uint32_t switch_save_sr[CONFIG_MAX_LOCAL_CORES] CONFIG_CACHE_LINE_ALIGNED; 127 128 #if CONFIG_READ_DEBUG 129 uint32_t enter_sys_read; 130 uint32_t exit_sys_read; 131 132 uint32_t enter_devfs_move; 133 uint32_t exit_devfs_move; 134 135 uint32_t enter_txt_read; 136 uint32_t exit_txt_read; 137 138 uint32_t enter_chdev_cmd; 139 uint32_t exit_chdev_cmd; 140 141 uint32_t enter_chdev_server; 142 uint32_t exit_chdev_server; 143 144 uint32_t enter_tty_cmd; 145 uint32_t exit_tty_cmd; 146 147 uint32_t enter_tty_isr; 148 uint32_t exit_tty_isr; 149 #endif 123 150 124 151 /////////////////////////////////////////////////////////////////////////////////////////// … … 137 164 " /_/ \\_\\ |______| |_| |_| \\_____/ |______/ |_| |_| |_| \\_\\ |_| |_| \n" 138 165 "\n\n\t\t Advanced Locality Management Operating System / Multi Kernel Hybrid\n" 139 "\n\n\t\t\t Version 0.0 / %d cluster(s) / %d core(s) per cluster\n\n", nclusters , ncores ); 166 "\n\n\t\t Version 0.0 / %d cluster(s) / %d core(s) per cluster / cycle %d\n\n", 167 nclusters , ncores , hal_time_stamp() ); 140 168 } 141 169 … … 201 229 { 202 230 cxy_t cxy = (x<<info->y_width) + y; 203 hal_remote_swd( XPTR( cxy , &chdev_dir.txt [0] ) ,231 hal_remote_swd( XPTR( cxy , &chdev_dir.txt_tx[0] ) , 204 232 XPTR( local_cxy , &txt0_chdev ) ); 205 233 } … … 273 301 } 274 302 275 #if( CONFIG_KINIT_DEBUG > 1 ) 276 printk("\n[DMSG] %s : created MMC in cluster %x / chdev = %x\n", 277 __FUNCTION__ , channel , local_cxy , chdev_ptr ); 303 #if( CONFIG_KINIT_DEBUG & 0x1 ) 304 if( hal_time_stamp() > CONFIG_KINIT_DEBUG ) 305 printk("\n[DBG] %s : created MMC in cluster %x / chdev = %x\n", 306 __FUNCTION__ , local_cxy , chdev_ptr ); 278 307 #endif 279 308 } … … 301 330 chdev_dir.dma[channel] = XPTR( local_cxy , chdev_ptr ); 302 331 303 #if( CONFIG_KINIT_DEBUG > 1 ) 304 printk("\n[DMSG] %s : created DMA[%d] in cluster %x / chdev = %x\n", 332 #if( CONFIG_KINIT_DEBUG & 0x1 ) 333 if( hal_time_stamp() > CONFIG_KINIT_DEBUG ) 334 printk("\n[DBG] %s : created DMA[%d] in cluster %x / chdev = %x\n", 305 335 __FUNCTION__ , channel , local_cxy , chdev_ptr ); 306 336 #endif … … 355 385 impl = IMPL_FROM_TYPE( dev_tbl[i].type ); 356 386 357 // There is one chdev per direction for NIC 358 if (func == DEV_FUNC_NIC) directions = 2;359 else directions = 1;387 // There is one chdev per direction for NIC and for TXT 388 if((func == DEV_FUNC_NIC) || (func == DEV_FUNC_TXT)) directions = 2; 389 else directions = 1; 360 390 361 391 // The TXT0 chdev has already been created … … 363 393 else first_channel = 0; 364 394 365 // do nothing for RO , that does not require a device descriptor.395 // do nothing for ROM, that does not require a device descriptor. 366 396 if( func == DEV_FUNC_ROM ) continue; 367 397 … … 394 424 395 425 // allocate and initialize a local chdev 396 // iflocal cluster matches target cluster426 // when local cluster matches target cluster 397 427 if( target_cxy == local_cxy ) 398 428 { … … 420 450 if(func==DEV_FUNC_IOB ) entry = &chdev_dir.iob; 421 451 if(func==DEV_FUNC_IOC ) entry = &chdev_dir.ioc[channel]; 422 if(func==DEV_FUNC_TXT ) entry = &chdev_dir.txt[channel];423 452 if(func==DEV_FUNC_FBF ) entry = &chdev_dir.fbf[channel]; 453 if((func==DEV_FUNC_TXT) && (rx==0)) entry = &chdev_dir.txt_tx[channel]; 454 if((func==DEV_FUNC_TXT) && (rx==1)) entry = &chdev_dir.txt_rx[channel]; 424 455 if((func==DEV_FUNC_NIC) && (rx==0)) entry = &chdev_dir.nic_tx[channel]; 425 456 if((func==DEV_FUNC_NIC) && (rx==1)) entry = &chdev_dir.nic_rx[channel]; … … 435 466 } 436 467 437 #if( CONFIG_KINIT_DEBUG > 1 ) 438 printk("\n[DMSG] %s : create chdev %s[%d] in cluster %x / chdev = %x\n", 439 __FUNCTION__ , chdev_func_str( func ), channel , local_cxy , chdev ); 468 #if( CONFIG_KINIT_DEBUG & 0x1 ) 469 if( hal_time_stamp() > CONFIG_KINIT_DEBUG ) 470 printk("\n[DBG] %s : create chdev %s / channel = %d / rx = %d / cluster %x / chdev = %x\n", 471 __FUNCTION__ , chdev_func_str( func ), channel , rx , local_cxy , chdev ); 440 472 #endif 441 473 } // end if match … … 451 483 /////////////////////////////////////////////////////////////////////////////////////////// 452 484 // This function is called by CP0 in cluster 0 to allocate memory and initialize the PIC 453 // device, namely the informations attached to the external IOPIC controller. 485 // device, namely the informations attached to the external IOPIC controller, that 486 // must be replicated in all clusters (struct iopic_input). 454 487 // This initialisation must be done before other devices initialisation because the IRQ 455 // routing infrastructure is required for internal and external devices initialisation.488 // routing infrastructure is required for both internal and external devices init. 456 489 /////////////////////////////////////////////////////////////////////////////////////////// 457 490 // @ info : pointer on the local boot-info structure. … … 490 523 assert( found , __FUNCTION__ , "PIC device not found\n" ); 491 524 492 // allocate and initialize the PIC chdev in local cluster493 chdev = chdev_create( func,525 // allocate and initialize the PIC chdev in cluster 0 526 chdev = chdev_create( DEV_FUNC_PIC, 494 527 impl, 495 528 0, // channel … … 502 535 dev_pic_init( chdev ); 503 536 504 // register extended pointer on PIC chdev in "chdev_dir" array in all clusters 537 // register, in all clusters, the extended pointer 538 // on PIC chdev in "chdev_dir" array 505 539 xptr_t * entry = &chdev_dir.pic; 506 540 … … 515 549 } 516 550 517 // initialize the "iopic_input" structure551 // initialize, in all clusters, the "iopic_input" structure 518 552 // defining how external IRQs are connected to IOPIC 519 uint32_t id; 520 uint8_t valid; 521 uint32_t type; 522 uint8_t channel; 523 uint8_t is_rx; 553 554 // register default value for unused inputs 555 for( x = 0 ; x < info->x_size ; x++ ) 556 { 557 for( y = 0 ; y < info->y_size ; y++ ) 558 { 559 cxy_t cxy = (x<<info->y_width) + y; 560 hal_remote_memset( XPTR( cxy , &iopic_input ) , 0xFF , sizeof(iopic_input_t) ); 561 } 562 } 563 564 // register input IRQ index for valid inputs 565 uint32_t id; // input IRQ index 566 uint8_t valid; // input IRQ is connected 567 uint32_t type; // source device type 568 uint8_t channel; // source device channel 569 uint8_t is_rx; // source device direction 570 uint32_t * ptr; // local pointer on one field in iopic_input stucture 524 571 525 572 for( id = 0 ; id < CONFIG_MAX_EXTERNAL_IRQS ; id++ ) … … 529 576 channel = dev_tbl[i].irq[id].channel; 530 577 is_rx = dev_tbl[i].irq[id].is_rx; 531 532 if( valid ) // only valid inputs are registered 533 { 534 uint32_t * index; // local pointer on one entry 535 uint16_t func = FUNC_FROM_TYPE( type ); 536 537 if ( func == DEV_FUNC_TXT ) 538 index = &iopic_input.txt[channel]; 539 else if( func == DEV_FUNC_IOC ) 540 index = &iopic_input.ioc[channel]; 541 else if( (func == DEV_FUNC_NIC) && (is_rx == 0) ) 542 index = &iopic_input.nic_tx[channel]; 543 else if( (func == DEV_FUNC_NIC) && (is_rx != 0) ) 544 index = &iopic_input.nic_rx[channel]; 545 else if( func == DEV_FUNC_IOB ) 546 index = &iopic_input.iob; 547 else 548 assert( false , __FUNCTION__ , "illegal source device for IOPIC input" ); 549 550 // set entry in local structure 551 *index = id; 578 func = FUNC_FROM_TYPE( type ); 579 580 // get pointer on relevant field in iopic_input 581 if( valid ) 582 { 583 if ( func == DEV_FUNC_IOC ) ptr = &iopic_input.ioc[channel]; 584 else if((func == DEV_FUNC_TXT) && (is_rx == 0)) ptr = &iopic_input.txt_tx[channel]; 585 else if((func == DEV_FUNC_TXT) && (is_rx != 0)) ptr = &iopic_input.txt_rx[channel]; 586 else if((func == DEV_FUNC_NIC) && (is_rx == 0)) ptr = &iopic_input.nic_tx[channel]; 587 else if((func == DEV_FUNC_NIC) && (is_rx != 0)) ptr = &iopic_input.nic_rx[channel]; 588 else if( func == DEV_FUNC_IOB ) ptr = &iopic_input.iob; 589 else panic( "illegal source device for IOPIC input" ); 590 591 // set one entry in all "iopic_input" structures 592 for( x = 0 ; x < info->x_size ; x++ ) 593 { 594 for( y = 0 ; y < info->y_size ; y++ ) 595 { 596 cxy_t cxy = (x<<info->y_width) + y; 597 hal_remote_swd( XPTR( cxy , ptr ) , id ); 598 } 599 } 552 600 } 553 601 } 554 602 555 #if( CONFIG_KINIT_DEBUG > 1 ) 556 printk("\n[DMSG] %s created PIC chdev in cluster %x at cycle %d\n", 557 __FUNCTION__ , local_cxy , (uint32_t)hal_time_stamp() ); 603 #if( CONFIG_KINIT_DEBUG & 0x1 ) 604 if( hal_time_stamp() > CONFIG_KINIT_DEBUG ) 605 { 606 printk("\n[DBG] %s created PIC chdev in cluster %x at cycle %d\n", 607 __FUNCTION__ , local_cxy , (uint32_t)hal_time_stamp() ); 608 dev_pic_inputs_display(); 609 } 558 610 #endif 559 611 … … 715 767 hal_set_current_thread( thread ); 716 768 717 // each core initializes the idle thread "locks_root" and "xlocks_root" fields 769 // each core register core descriptor pointer in idle thread descriptor 770 thread->core = &LOCAL_CLUSTER->core_tbl[core_lid]; 771 772 // each core initializes locks_root" and "xlocks_root" in idle thread descriptor 718 773 list_root_init( &thread->locks_root ); 719 774 xlist_root_init( XPTR( local_cxy , &thread->xlocks_root ) ); … … 728 783 729 784 if( (core_lid == 0) && (local_cxy == 0) ) 730 printk("\n[KINIT] %s : exit barrier 0 : TXT0 initialized / cycle %d\n",785 kinit_dmsg("\n[DBG] %s : exit barrier 0 : TXT0 initialized / cycle %d\n", 731 786 __FUNCTION__, hal_time_stamp() ); 732 787 733 788 ///////////////////////////////////////////////////////////////////////////// 734 // STEP 1 : all cores check itscore identifier.789 // STEP 1 : all cores check core identifier. 735 790 // CP0 initializes the local cluster manager. 736 791 // This includes the memory allocators. … … 762 817 763 818 if( (core_lid == 0) && (local_cxy == 0) ) 764 printk("\n[KINIT] %s : exit barrier 1 : clusters initialised / cycle %d\n",819 kinit_dmsg("\n[DBG] %s : exit barrier 1 : clusters initialised / cycle %d\n", 765 820 __FUNCTION__, hal_time_stamp() ); 766 821 767 822 ///////////////////////////////////////////////////////////////////////////////// 768 // STEP 2 : all CP0s initializethe process_zero descriptor.823 // STEP 2 : CP0 initializes the process_zero descriptor. 769 824 // CP0 in cluster 0 initializes the IOPIC device. 770 825 ///////////////////////////////////////////////////////////////////////////////// … … 787 842 788 843 if( (core_lid == 0) && (local_cxy == 0) ) 789 printk("\n[KINIT] %s : exit barrier 2 : PIC initialised / cycle %d\n",844 kinit_dmsg("\n[DBG] %s : exit barrier 2 : PIC initialised / cycle %d\n", 790 845 __FUNCTION__, hal_time_stamp() ); 791 846 792 847 //////////////////////////////////////////////////////////////////////////////// 793 // STEP 3 : all CP0s initializethe distibuted LAPIC descriptor.794 // all CP0s initializethe internal chdev descriptors795 // all CP0sinitialize the local external chdev descriptors848 // STEP 3 : CP0 initializes the distibuted LAPIC descriptor. 849 // CP0 initializes the internal chdev descriptors 850 // CP0 initialize the local external chdev descriptors 796 851 //////////////////////////////////////////////////////////////////////////////// 797 852 … … 818 873 819 874 if( (core_lid == 0) && (local_cxy == 0) ) 820 printk("\n[KINIT] %s : exit barrier 3 : all chdev initialised / cycle %d\n",875 kinit_dmsg("\n[DBG] %s : exit barrier 3 : all chdev initialised / cycle %d\n", 821 876 __FUNCTION__, hal_time_stamp()); 822 877 823 878 ///////////////////////////////////////////////////////////////////////////////// 824 879 // STEP 4 : All cores enable IPI (Inter Procesor Interrupt), 825 // All cores initialise specific core registers826 880 // Alh cores initialize IDLE thread. 827 881 // Only CP0 in cluster 0 creates the VFS root inode. … … 837 891 hal_enable_irq( &status ); 838 892 839 // All cores initialize specific core registers840 hal_core_init( info );841 842 893 // all cores initialize the idle thread descriptor 843 894 error = thread_kernel_init( thread, … … 857 908 858 909 #if CONFIG_KINIT_DEBUG 859 sched_display( );910 sched_display( core_lid ); 860 911 #endif 861 912 … … 928 979 929 980 if( (core_lid == 0) && (local_cxy == 0) ) 930 printk("\n[KINIT] %s : exit barrier 4 : VFS_root = %l in cluster 0 / cycle %d\n",981 kinit_dmsg("\n[DBG] %s : exit barrier 4 : VFS_root = %l in cluster 0 / cycle %d\n", 931 982 __FUNCTION__, vfs_root_inode_xp , hal_time_stamp()); 932 983 … … 987 1038 988 1039 if( (core_lid == 0) && (local_cxy == 0) ) 989 printk("\n[KINIT] %s : exit barrier 5 : VFS_root = %l in cluster IO / cycle %d\n",1040 kinit_dmsg("\n[DBG] %s : exit barrier 5 : VFS_root = %l in cluster IO / cycle %d\n", 990 1041 __FUNCTION__, vfs_root_inode_xp , hal_time_stamp() ); 991 1042 … … 1020 1071 1021 1072 if( (core_lid == 0) && (local_cxy == 0) ) 1022 printk("\n[KINIT] %s : exit barrier 6 : dev_root = %l in cluster IO / cycle %d\n",1073 kinit_dmsg("\n[DBG] %s : exit barrier 6 : dev_root = %l in cluster IO / cycle %d\n", 1023 1074 __FUNCTION__, devfs_dev_inode_xp , hal_time_stamp() ); 1024 1075 … … 1057 1108 1058 1109 if( (core_lid == 0) && (local_cxy == 0) ) 1059 printk("\n[KINIT] %s : exit barrier 7 : dev_root = %l in cluster 0 / cycle %d\n",1110 kinit_dmsg("\n[DBG] %s : exit barrier 7 : dev_root = %l in cluster 0 / cycle %d\n", 1060 1111 __FUNCTION__, devfs_dev_inode_xp , hal_time_stamp() ); 1061 1112 … … 1075 1126 ///////////////////////////////////////////////////////////////////////////////// 1076 1127 1128 #if CONFIG_KINIT_DEBUG 1129 sched_display( core_lid ); 1130 #endif 1131 1077 1132 if( (core_lid == 0) && (local_cxy == 0) ) 1078 printk("\n[KINIT] %s : exit barrier 8 : process init created / cycle %d\n",1133 kinit_dmsg("\n[DBG] %s : exit barrier 8 : process init created / cycle %d\n", 1079 1134 __FUNCTION__ , hal_time_stamp() ); 1080 1135 … … 1118 1173 sizeof( core_t ), 1119 1174 sizeof( scheduler_t ), 1120 sizeof( r pc_fifo_t),1175 sizeof( remote_fifo_t ), 1121 1176 sizeof( page_t ), 1122 1177 sizeof( mapper_t ), … … 1139 1194 dev_pic_enable_timer( CONFIG_SCHED_TICK_MS_PERIOD ); 1140 1195 1141 // each core jump to idle thread1196 // each core jump to thread_idle_func 1142 1197 thread_idle_func(); 1143 1198 }
Note: See TracChangeset
for help on using the changeset viewer.