Changeset 279 for trunk/kernel/kern/kernel_init.c
- Timestamp:
- Jul 27, 2017, 12:23:29 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/kernel_init.c
r265 r279 28 28 #include <hal_special.h> 29 29 #include <hal_context.h> 30 #include <hal_irqmask.h> 30 31 #include <barrier.h> 31 32 #include <remote_barrier.h> … … 59 60 60 61 /////////////////////////////////////////////////////////////////////////////////////////// 61 // All the seglobal variables are replicated in all clusters.62 // All the following global variables are replicated in all clusters. 62 63 // They are initialised by the kernel_init() function. 63 64 // … … 135 136 " /_/ \\_\\ |______| |_| |_| \\_____/ |______/ |_| |_| |_| \\_\\ |_| |_| \n" 136 137 "\n\n\t\t Advanced Locality Management Operating System / Multi Kernel Hybrid\n" 137 "\n\n\t\t\t Version 0.0 : %d clusters / %d coresper cluster\n\n", nclusters , ncores );138 "\n\n\t\t\t Version 0.0 : %d cluster(s) / %d core(s) per cluster\n\n", nclusters , ncores ); 138 139 } 139 140 … … 274 275 } 275 276 276 if( local_cxy == 0 ) 277 kinit_dmsg("\n[INFO] %s created MMC chdev in cluster 0 at cycle %d\n", 278 __FUNCTION__ , local_cxy , (uint32_t)hal_time_stamp() ); 277 kinit_dmsg("\n[INFO] %s created MMC in cluster %x / chdev = %x\n", 278 __FUNCTION__ , channel , local_cxy , chdev_ptr ); 279 279 } 280 280 /////////////////////////////// … … 301 301 chdev_dir.dma[channel] = XPTR( local_cxy , chdev_ptr ); 302 302 303 kinit_dmsg("\n[INFO] %s created DMA[%d] chdev in cluster 0 at cycle %d\n",304 __FUNCTION__ , channel , (uint32_t)hal_time_stamp());303 kinit_dmsg("\n[INFO] %s created DMA[%d] in cluster %x / chdev = %x\n", 304 __FUNCTION__ , channel , local_cxy , chdev_ptr ); 305 305 } 306 306 } … … 433 433 } 434 434 435 kinit_dmsg("\n[INFO] %s create chdev %s[%d] in cluster %x at cycle %d\n", 436 __FUNCTION__ , chdev_func_str( func ), channel, 437 local_cxy , (uint32_t)hal_time_stamp() ); 435 kinit_dmsg("\n[INFO] %s create chdev %s[%d] in cluster %x / chdev = %x\n", 436 __FUNCTION__ , chdev_func_str( func ), channel , local_cxy , chdev ); 438 437 439 438 } // end if match … … 658 657 } 659 658 659 //////////////////////////////////////////////////////////////////////////////////////////// 660 // This function display on TXT0 the content of the external chdev directory, 661 // in the local cluster. 662 //////////////////////////////////////////////////////////////////////////////////////////// 663 static void chdev_dir_display( ) 664 { 665 cxy_t iob_cxy = GET_CXY( chdev_dir.iob ); 666 chdev_t * iob_ptr = (chdev_t *)GET_PTR( chdev_dir.iob ); 667 xptr_t iob_base = hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); 668 669 cxy_t pic_cxy = GET_CXY( chdev_dir.pic ); 670 chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic ); 671 xptr_t pic_base = hal_remote_lwd( XPTR( pic_cxy , &pic_ptr->base ) ); 672 673 cxy_t txt0_cxy = GET_CXY( chdev_dir.txt[0] ); 674 chdev_t * txt0_ptr = (chdev_t *)GET_PTR( chdev_dir.txt[0] ); 675 xptr_t txt0_base = hal_remote_lwd( XPTR( txt0_cxy , &txt0_ptr->base ) ); 676 677 cxy_t txt1_cxy = GET_CXY( chdev_dir.txt[1] ); 678 chdev_t * txt1_ptr = (chdev_t *)GET_PTR( chdev_dir.txt[1] ); 679 xptr_t txt1_base = hal_remote_lwd( XPTR( txt1_cxy , &txt1_ptr->base ) ); 680 681 cxy_t txt2_cxy = GET_CXY( chdev_dir.txt[2] ); 682 chdev_t * txt2_ptr = (chdev_t *)GET_PTR( chdev_dir.txt[2] ); 683 xptr_t txt2_base = hal_remote_lwd( XPTR( txt2_cxy , &txt2_ptr->base ) ); 684 685 cxy_t ioc_cxy = GET_CXY( chdev_dir.ioc[0] ); 686 chdev_t * ioc_ptr = (chdev_t *)GET_PTR( chdev_dir.ioc[0] ); 687 xptr_t ioc_base = hal_remote_lwd( XPTR( ioc_cxy , &ioc_ptr->base ) ); 688 689 cxy_t fbf_cxy = GET_CXY( chdev_dir.fbf[0] ); 690 chdev_t * fbf_ptr = (chdev_t *)GET_PTR( chdev_dir.fbf[0] ); 691 xptr_t fbf_base = hal_remote_lwd( XPTR( fbf_cxy , &fbf_ptr->base ) ); 692 693 cxy_t nic_rx_cxy = GET_CXY( chdev_dir.nic_rx[0] ); 694 chdev_t * nic_rx_ptr = (chdev_t *)GET_PTR( chdev_dir.nic_rx[0] ); 695 xptr_t nic_rx_base = hal_remote_lwd( XPTR( nic_rx_cxy , &nic_rx_ptr->base ) ); 696 697 cxy_t nic_tx_cxy = GET_CXY( chdev_dir.nic_tx[0] ); 698 chdev_t * nic_tx_ptr = (chdev_t *)GET_PTR( chdev_dir.nic_tx[0] ); 699 xptr_t nic_tx_base = hal_remote_lwd( XPTR( nic_tx_cxy , &nic_tx_ptr->base ) ); 700 701 printk("\n*** external chdev directory in cluster %x\n" 702 " - iob = %l / base = %l\n" 703 " - pic = %l / base = %l\n" 704 " - txt[0] = %l / base = %l\n" 705 " - txt[1] = %l / base = %l\n" 706 " - txt[2] = %l / base = %l\n" 707 " - ioc[0] = %l / base = %l\n" 708 " - fbf[0] = %l / base = %l\n" 709 " - nic_rx[0] = %l / base = %l\n" 710 " - nic_tx[0] = %l / base = %l\n", 711 local_cxy, 712 chdev_dir.iob, iob_base, 713 chdev_dir.pic, pic_base, 714 chdev_dir.txt[0], txt0_base, 715 chdev_dir.txt[1], txt1_base, 716 chdev_dir.txt[2], txt2_base, 717 chdev_dir.ioc[0], ioc_base, 718 chdev_dir.fbf[0], fbf_base, 719 chdev_dir.nic_rx[0], nic_rx_base, 720 chdev_dir.nic_tx[0], nic_tx_base ); 721 } 722 660 723 /////////////////////////////////////////////////////////////////////////////////////////// 661 724 // This function is the entry point for the kernel initialisation. … … 683 746 684 747 error_t error; 748 uint32_t status; // running core status register 685 749 686 750 cxy_t io_cxy = info->io_cxy; … … 732 796 if( error ) 733 797 { 734 nolock_printk("\n[PANIC] in %s : illegal core identifiers"798 printk("\n[PANIC] in %s : illegal core identifiers" 735 799 " gid = %x / cxy = %x / lid = %d\n", 736 800 __FUNCTION__ , core_lid , core_cxy , core_lid ); … … 745 809 if( error ) 746 810 { 747 nolock_printk("\n[PANIC] in %s : cannot initialise cluster %x",811 printk("\n[PANIC] in %s : cannot initialise cluster %x", 748 812 __FUNCTION__ , local_cxy ); 749 813 hal_core_sleep(); … … 764 828 // STEP 2 : all CP0s initialize the process_zero descriptor. 765 829 // CP0 in cluster 0 initialises the IOPIC device. 766 // all CP0s complete the distibuted LAPIC initialization.767 830 ///////////////////////////////////////////////////////////////////////////////// 768 831 … … 777 840 if( (core_lid == 0) && (local_cxy == 0) ) iopic_init( info ); 778 841 779 // all CP0s initialize their local LAPIC extension,780 if( core_lid == 0 ) lapic_init( info );781 782 842 //////////////////////////////////////////////////////////////////////////////// 783 843 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), … … 791 851 792 852 //////////////////////////////////////////////////////////////////////////////// 793 // STEP 3 : all CP0s initialize their local chdev descriptors 794 // (both internal devices and external devices). 853 // STEP 3 : all CP0s complete the distibuted LAPIC initialization. 854 // all CP0s initialize their internal chdev descriptors 855 // all CP0s initialize their local external chdev descriptors 795 856 //////////////////////////////////////////////////////////////////////////////// 857 858 // all CP0s initialize their local LAPIC extension, 859 if( core_lid == 0 ) lapic_init( info ); 796 860 797 861 // CP0 scan the internal (private) peripherals, … … 818 882 819 883 ///////////////////////////////////////////////////////////////////////////////// 820 // STEP 4 : Alls cores initialize their private IDLE thread. 884 // STEP 4 : All cores enable IPI (Inter Procesor Interrupt), 885 // Alh cores initialize IDLE thread. 821 886 // Only CP0 in cluster 0 creates the VFS root inode. 822 887 // It access the boot device to initialize the file system context. 823 888 ///////////////////////////////////////////////////////////////////////////////// 824 889 825 // all cores create idle thread descriptor 890 if( CONFIG_KINIT_DEBUG ) chdev_dir_display(); 891 892 // All cores enable the shared IPI channel 893 894 // @@@ 895 hal_set_ebase( 0x1000 ); 896 // @@@ 897 898 dev_pic_enable_ipi(); 899 hal_enable_irq( &status ); 900 901 kinit_dmsg("\n[INFO] %s : IRQs enabled for core[%x,%d] / SR = %x\n", 902 __FUNCTION__ , local_cxy , core_lid , hal_get_sr() ); 903 904 // all cores create the idle thread descriptor 826 905 error = thread_kernel_init( thread, 827 906 THREAD_IDLE, … … 831 910 if( error ) 832 911 { 833 nolock_printk("\n[PANIC] in %s : core[%x][%d] cannot initialize idle thread\n",912 printk("\n[PANIC] in %s : core[%x][%d] cannot initialize idle thread\n", 834 913 __FUNCTION__ , local_cxy , core_lid ); 835 914 hal_core_sleep(); … … 860 939 fatfs_ctx_t * fatfs_ctx = fatfs_ctx_alloc(); 861 940 862 nolock_assert( (fatfs_ctx != NULL) , __FUNCTION__ ,863 941 assert( (fatfs_ctx != NULL) , __FUNCTION__ , 942 "cannot create FATFS context in cluster 0\n" ); 864 943 865 944 // 2. access boot device to initialize FATFS context … … 883 962 &vfs_root_inode_xp ); // return 884 963 885 nolock_assert( (error == 0) , __FUNCTION__ ,886 964 assert( (error == 0) , __FUNCTION__ , 965 "cannot create VFS root inode\n" ); 887 966 888 967 // 5. initialize VFS context for FAT in cluster 0 … … 896 975 else 897 976 { 898 nolock_printk("\n[PANIC] in %s : root FS must be FATFS\n", __FUNCTION__ );977 printk("\n[PANIC] in %s : root FS must be FATFS\n", __FUNCTION__ ); 899 978 hal_core_sleep(); 900 979 } … … 931 1010 fatfs_ctx_t * fatfs_ctx = fatfs_ctx_alloc(); 932 1011 933 nolock_assert( (fatfs_ctx != NULL) , __FUNCTION__ ,934 1012 assert( (fatfs_ctx != NULL) , __FUNCTION__ , 1013 "cannot create FATFS context\n" ); 935 1014 936 1015 // get local pointer on VFS context for FATFS … … 965 1044 ///////////////////////////////////////////////////////////////////////////////// 966 1045 967 if( (core_lid == 0) && (local_cxy == 0) )1046 // if( (core_lid == 0) && (local_cxy == 0) ) 968 1047 kinit_dmsg("\n[INFO] %s exit barrier 5 at cycle %d : VFS OK in all clusters\n", 969 1048 __FUNCTION__, (uint32_t)hal_time_stamp()); … … 986 1065 devfs_ctx_t * devfs_ctx = devfs_ctx_alloc(); 987 1066 988 nolock_assert( (devfs_ctx != NULL) , __FUNCTION__ ,989 1067 assert( (devfs_ctx != NULL) , __FUNCTION__ , 1068 "cannot create DEVFS context in cluster IO\n"); 990 1069 991 1070 // register DEVFS root and external directories … … 993 1072 } 994 1073 1074 printk("\n@@@ %s : cluster %x reach barrier 6\n", __FUNCTION__ , local_cxy ); 1075 995 1076 ///////////////////////////////////////////////////////////////////////////////// 996 1077 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), … … 999 1080 ///////////////////////////////////////////////////////////////////////////////// 1000 1081 1001 if( (core_lid == 0) && (local_cxy == 0) )1082 // if( (core_lid == 0) && (local_cxy == 0) ) 1002 1083 kinit_dmsg("\n[INFO] %s exit barrier 6 at cycle %d : DEVFS OK in cluster IO\n", 1003 1084 __FUNCTION__, (uint32_t)hal_time_stamp()); … … 1071 1152 print_banner( (info->x_size * info->y_size) , info->cores_nr ); 1072 1153 1073 kinit_dmsg("\n\n*** memory fooprint of main kernet objects ***\n"1154 kinit_dmsg("\n\n*** memory fooprint for main kernet objects ***\n\n" 1074 1155 " - thread descriptor : %d bytes\n" 1075 1156 " - process descriptor : %d bytes\n" … … 1114 1195 } 1115 1196 1116 // each core activates its private PTIIRQ1197 // each core activates its private TICK IRQ 1117 1198 dev_pic_enable_timer( CONFIG_SCHED_TICK_PERIOD ); 1118 1199
Note: See TracChangeset
for help on using the changeset viewer.