Changeset 204 for trunk/kernel/kern
- Timestamp:
- Jul 17, 2017, 8:42:59 AM (7 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/chdev.h
r188 r204 48 48 * Therefore a given I/O operation involve generally three clusters: 49 49 * - the client cluster, containing the client thread, 50 * - the server cluster, containing the chdev and the clientthread,51 * - the I/O cluster containing the physical device.50 * - the server cluster, containing the chdev and the server thread, 51 * - the I/O cluster, containing the physical device. 52 52 *****************************************************************************************/ 53 53 … … 66 66 67 67 /****************************************************************************************** 68 * This define the generic prototypes for the t hreefunctions that must be defined68 * This define the generic prototypes for the two functions that must be defined 69 69 * by all drivers implementing a generic device: 70 * - "init" : device initialisation.71 70 * - "cmd" : start an I/O operation. 72 71 * - "isr" : complete an I/O operation. 73 * The "init" function is called by kernel_init() to initialise the hardware device. 74 * The "cmd" and "isr" are registered in the generic chdev descriptor by kernel_init(), 72 * The "cmd" and "isr" are registered in the generic chdev descriptor at kernel init, 75 73 * and are called to start and complete an I/O operation. 76 74 *****************************************************************************************/ … … 85 83 * provide the same set of operations and the same driver API. 86 84 * This enum must be consistent with the enum in files arch_info.h, and arch_class.py. 85 * 86 * WARNING : The ICU device exist in boot_info to specify the base address of the 87 * distributed LAPIC controler, but it does not exist as a chdev in the kernel, 88 * as it is hidden in the driver associated to the PIC device. 87 89 *****************************************************************************************/ 88 90 … … 99 101 DEV_FUNC_TIM = 8, 100 102 DEV_FUNC_TXT = 9, 101 DEV_FUNC_ICU = 10, 103 DEV_FUNC_ICU = 10, 102 104 DEV_FUNC_PIC = 11, 103 105 -
trunk/kernel/kern/kernel_init.c
r188 r204 33 33 #include <list.h> 34 34 #include <xlist.h> 35 #include <xhtab.h> 35 36 #include <thread.h> 36 37 #include <scheduler.h> … … 245 246 func = FUNC_FROM_TYPE( dev_tbl[i].type ); 246 247 impl = IMPL_FROM_TYPE( dev_tbl[i].type ); 247 248 248 249 ////////////////////////// 249 250 if( func == DEV_FUNC_MMC ) … … 553 554 } 554 555 555 kinit_dmsg("\n[INFO] %s created IOPIC chdev in cluster %x at cycle %d\n",556 kinit_dmsg("\n[INFO] %s created PIC chdev in cluster %x at cycle %d\n", 556 557 __FUNCTION__ , local_cxy , (uint32_t)hal_time_stamp() ); 557 558 … … 672 673 void kernel_init( boot_info_t * info ) 673 674 { 674 lid_t core_lid = -1; // running core local index 675 cxy_t core_cxy = -1; // running core cluster identifier 676 gid_t core_gid; // running core hardware identifier 677 cluster_t * cluster; // pointer on local cluster manager 678 core_t * core; // pointer on running core descriptor 679 thread_t * thread; // pointer on idle thread descriptor 680 xptr_t vfs_root_inode_xp; // extended pointer on VFS root inode 681 // xptr_t devfs_root_inode_xp; // extended pointer on DEVFS root inode 675 lid_t core_lid = -1; // running core local index 676 cxy_t core_cxy = -1; // running core cluster identifier 677 gid_t core_gid; // running core hardware identifier 678 cluster_t * cluster; // pointer on local cluster manager 679 core_t * core; // pointer on running core descriptor 680 thread_t * thread; // pointer on idle thread descriptor 681 682 xptr_t vfs_root_inode_xp; // extended pointer on VFS root inode 683 xptr_t devfs_dev_inode_xp; // extended pointer on DEVFS dev inode 684 xptr_t devfs_external_inode_xp; // extended pointer on DEVFS external inode 685 xptr_t devfs_internal_inode_xp; // extended pointer on DEVFS internal inode 686 682 687 error_t error; 683 688 … … 958 963 959 964 ///////////////////////////////////////////////////////////////////////////////// 960 // global &local synchro to protect File System initialisation961 965 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), 962 966 (info->x_size * info->y_size) ); 963 967 barrier_wait( &local_barrier , info->cores_nr ); 968 ///////////////////////////////////////////////////////////////////////////////// 964 969 965 970 if( (core_lid == 0) && (local_cxy == 0) ) … … 970 975 ///////////////////////////////////////////////////////////////////////////////// 971 976 // STEP 6 : CP0 in cluster IO makes the global DEVFS tree initialisation: 972 // It creates the DEVFS root directoryand the DEVFS "external"973 // dire tory in cluster IO and mount these inodes into VFS.977 // It creates the DEVFS directory "dev", and the DEVFS "external" 978 // directory in cluster IO and mount these inodes into VFS. 974 979 ///////////////////////////////////////////////////////////////////////////////// 975 980 976 981 if( (core_lid == 0) && (local_cxy == io_cxy) ) 977 982 { 978 xptr_t devfs_root_inode_xp; // extended pointer on DEVFS root directory979 xptr_t devfs_external_inode_xp; // extended pointer on DEVFS external directory980 981 983 // create "dev" and "external" directories. 982 984 devfs_global_init( process_zero.vfs_root_xp, 983 &devfs_ root_inode_xp,985 &devfs_dev_inode_xp, 984 986 &devfs_external_inode_xp ); 985 987 … … 991 993 992 994 // register DEVFS root and external directories 993 devfs_ctx_init( devfs_ctx, devfs_ root_inode_xp, devfs_external_inode_xp );995 devfs_ctx_init( devfs_ctx, devfs_dev_inode_xp, devfs_external_inode_xp ); 994 996 } 995 997 996 998 ///////////////////////////////////////////////////////////////////////////////// 997 // global &local synchro to protect File System initialisation998 999 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), 999 1000 (info->x_size * info->y_size) ); 1000 1001 barrier_wait( &local_barrier , info->cores_nr ); 1002 ///////////////////////////////////////////////////////////////////////////////// 1001 1003 1002 1004 if( (core_lid == 0) && (local_cxy == 0) ) … … 1007 1009 // STEP 7 : All CP0s complete in parallel the DEVFS tree initialization. 1008 1010 // Each CP0 get the "dev" and "external" extended pointers from 1009 // values stor red in cluster IO. Then CP0 in cluster(i) creates the1010 // DEVFS "internal directory, and creates the pseudo-files for all1011 // chdevs containedin cluster (i).1011 // values stored in cluster IO. 1012 // Then CP0 in cluster(i) creates the DEVFS "internal directory, 1013 // and creates the pseudo-files for all chdevs in cluster (i). 1012 1014 ///////////////////////////////////////////////////////////////////////////////// 1013 1015 1014 1016 if( core_lid == 0 ) 1015 1017 { 1016 xptr_t root_inode_xp; // extended pointer on DEVFS root directory1017 xptr_t external_inode_xp; // extended pointer on DEVFS external directory1018 1019 1018 // get extended pointer on "extend" field of VFS context for DEVFS in cluster IO 1020 1019 xptr_t extend_xp = XPTR( io_cxy , &fs_context[FS_TYPE_DEVFS].extend ); … … 1023 1022 devfs_ctx_t * devfs_ctx = hal_remote_lpt( extend_xp ); 1024 1023 1025 root_inode_xp = hal_remote_lwd( XPTR( io_cxy , &devfs_ctx->root_inode_xp ) ); 1026 external_inode_xp = hal_remote_lwd( XPTR( io_cxy , &devfs_ctx->external_inode_xp ) ); 1027 1028 devfs_local_init( root_inode_xp, 1029 external_inode_xp ); 1030 } 1031 1032 ///////////////////////////////////////////////////////////////////////////////// 1033 // global &local synchro to protect File System initialisation 1024 devfs_dev_inode_xp = hal_remote_lwd( XPTR( io_cxy , 1025 &devfs_ctx->dev_inode_xp ) ); 1026 devfs_external_inode_xp = hal_remote_lwd( XPTR( io_cxy , 1027 &devfs_ctx->external_inode_xp ) ); 1028 1029 // populate DEVFS in all clusters 1030 devfs_local_init( devfs_dev_inode_xp, 1031 devfs_external_inode_xp, 1032 &devfs_internal_inode_xp ); 1033 } 1034 1035 ///////////////////////////////////////////////////////////////////////////////// 1034 1036 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), 1035 1037 (info->x_size * info->y_size) ); 1036 1038 barrier_wait( &local_barrier , info->cores_nr ); 1039 ///////////////////////////////////////////////////////////////////////////////// 1037 1040 1038 1041 if( (core_lid == 0) && (local_cxy == 0) ) … … 1040 1043 __FUNCTION__, (uint32_t)hal_time_stamp()); 1041 1044 1042 ///////////////////////////////////////////////////////////////////////////////// 1043 // STEP 8 : CP0 in I/O cluster creates the process_init and print banner. 1045 #if CONFIG_KINIT_DEBUG 1046 vfs_display( vfs_root_inode_xp ); 1047 #endif 1048 1049 ///////////////////////////////////////////////////////////////////////////////// 1050 // STEP 8 : CP0 in I/O cluster creates the first user process (process_init) 1044 1051 ///////////////////////////////////////////////////////////////////////////////// 1045 1052 … … 1050 1057 1051 1058 ///////////////////////////////////////////////////////////////////////////////// 1052 // global syncho to protect access to File System1053 1059 if( core_lid == 0 ) remote_barrier( XPTR( info->io_cxy , &global_barrier ), 1054 1060 (info->x_size * info->y_size) ); 1055 1061 barrier_wait( &local_barrier , info->cores_nr ); 1062 ///////////////////////////////////////////////////////////////////////////////// 1056 1063 1057 1064 if( (core_lid == 0) && (local_cxy == 0) ) -
trunk/kernel/kern/process.c
r188 r204 112 112 } 113 113 114 // initialize PID and PPID 115 process->pid = pid; 116 process->ppid = parent_pid; 117 114 118 // reset reference process vmm (not for kernel process) 115 119 if( pid ) vmm_init( process ); … … 152 156 spinlock_init( &process->th_lock ); 153 157 154 // initialize PID and PPID155 process->pid = pid;156 process->ppid = parent_pid;157 158 158 // set ref_xp field 159 159 process->ref_xp = XPTR( local_cxy , process ); … … 171 171 process_dmsg("\n[INFO] %s : exit for process %x in cluster %x\n", 172 172 __FUNCTION__ , pid ); 173 } 173 174 } // process_reference init() 174 175 175 176 ///////////////////////////////////////////////////// … … 230 231 231 232 return 0; 232 } 233 234 } // end process_copy_init() 233 235 234 236 /////////////////////////////////////////// … … 578 580 579 581 return (found) ? 0 : ENOMEM; 580 } 582 583 } // end process_register_thread() 584 581 585 /////////////////////////////////////////////// 582 586 void process_remove_thread( thread_t * thread ) … … 596 600 process->th_tbl[ltid] = NULL; 597 601 process->th_nr--; 598 } 602 603 } // process_remove_thread() 599 604 600 605 ///////////////////////////////////////////////////// … … 623 628 parent_pid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) ); 624 629 625 exec_dmsg("\n[INFO] %s enters in cluster %x for path = %s\n",630 exec_dmsg("\n[INFO] %s : enters in cluster %x for path = %s\n", 626 631 __FUNCTION__ , local_cxy , path ); 627 632 … … 650 655 process_reference_init( process , pid , parent_xp ); 651 656 652 exec_dmsg("\n[INFO] %s created process %xcluster %x / path = %s\n",653 __FUNCTION__, p arent_pid , local_cxy , path );657 exec_dmsg("\n[INFO] %s : created process %x in cluster %x / path = %s\n", 658 __FUNCTION__, pid , local_cxy , path ); 654 659 655 660 // initialize vfs_root and vfs_cwd from parent process … … 663 668 664 669 // initialize embedded fd_array from parent process 665 process_fd_remote_copy( XPTR( local_cxy , &process->fd_array ),670 process_fd_remote_copy( XPTR( local_cxy , &process->fd_array ), 666 671 XPTR( parent_cxy , &parent_ptr->fd_array) ); 672 673 exec_dmsg("\n[INFO] %s : fd_array copied from process %x to process %x\n", 674 __FUNCTION__, parent_pid , pid ); 667 675 668 676 // initialize signal manager TODO ??? [AG] 669 677 // signal_manager_init( process ); 670 671 // initialize process VMM672 vmm_init( process );673 674 exec_dmsg("\n[INFO] %s initialized VMM in cluster %x for process %x / path = %s\n",675 __FUNCTION__ , local_cxy , pid , path );676 678 677 679 // register "code" and "data" vsegs as well as the process entry-point in VMM, … … 687 689 } 688 690 689 // register "heap" vseg descriptor in VMM 690 vseg_t * heap_vseg = vmm_create_vseg( process, 691 CONFIG_VMM_HEAP_BASE, 692 CONFIG_VMM_HEAP_SIZE, 693 VSEG_TYPE_HEAP ); 694 if( heap_vseg == NULL ) 695 { 696 printk("\n[ERROR] in %s : cannot create heap vseg for process %x / path = %s\n", 697 __FUNCTION__, pid , path ); 698 process_destroy( process ); 699 return error; 700 } 691 exec_dmsg("\n[INFO] %s : code and data vsegs from <%s> registered for process %x\n", 692 __FUNCTION__ , path , pid ); 701 693 702 694 // select a core in cluster … … 718 710 { 719 711 printk("\n[ERROR] in %s : cannot create thread for process %x / path = %s\n", 720 __FUNCTION__, pid , path);712 __FUNCTION__, pid ); 721 713 process_destroy( process ); 722 714 return error; 723 715 } 716 717 exec_dmsg("\n[INFO] %s : thread created for process %x on core %d in cluster %x\n", 718 __FUNCTION__ , pid , core->lid , local_cxy ); 724 719 725 720 // update children list in parent process … … 731 726 sched_register_thread( core , thread ); 732 727 733 exec_dmsg("\n[INFO] %s created thread for process %x on core %d in cluster %x\n",734 __FUNCTION__ , pid , core->lid , local_cxy );735 736 728 // activate new thread 737 729 thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_GLOBAL ); 738 730 731 exec_dmsg("\n[INFO] %s : exit for process %x\n", 732 __FUNCTION__, process->pid ); 733 739 734 return 0; 740 } 735 736 } // end proces_make_exec() 741 737 742 738 ////////////////////////// … … 755 751 uint32_t stderr_id; 756 752 757 process_dmsg("\n[INFO] %s enters in cluster %x\n", __FUNCTION__ , local_cxy );753 process_dmsg("\n[INFO] %s : enters in cluster %x\n", __FUNCTION__ , local_cxy ); 758 754 759 755 // open stdin / stdout / stderr pseudo-files … … 762 758 error3 = vfs_open( XPTR_NULL, CONFIG_DEV_STDERR, O_WRONLY, 0, &stderr_xp, &stderr_id ); 763 759 764 if( error1 || error2 || error3 ) 765 { 766 if( !error1 ) vfs_close( stdin_xp , stdin_id ); 767 if( !error2 ) vfs_close( stdout_xp , stdout_id ); 768 if( !error3 ) vfs_close( stderr_xp , stderr_id ); 769 printk("\n[PANIC] in %s : cannot open stdin/stdout/stderr in cluster %x\n", 770 __FUNCTION__ , local_cxy ); 771 hal_core_sleep(); 772 } 773 774 // check stdin / stdout / stderr indexes 775 if( (stdin_id != 0) || (stdout_id != 1) || (stderr_id != 2) ) 776 { 777 vfs_close( stdin_xp , stdin_id ); 778 vfs_close( stdout_xp , stdout_id ); 779 vfs_close( stderr_xp , stderr_id ); 780 printk("\n[PANIC] in %s : bad indexes for stdin/stdout/stderr in cluster %x\n", 781 __FUNCTION__ , local_cxy ); 782 hal_core_sleep(); 783 } 760 assert( ((error1 == 0) && (error2 == 0) && (error3 == 0)) , __FUNCTION__ , 761 "cannot open stdin/stdout/stderr pseudo files\n"); 762 763 assert( ((stdin_id == 0) && (stdout_id == 1) && (stderr_id == 2)) , __FUNCTION__ , 764 "bad indexes for stdin/stdout/stderr\n"); 784 765 785 766 // initialize the exec_info structure … … 792 773 error1 = process_make_exec( &exec_info ); 793 774 794 if( error1 ) 795 { 796 printk("\n[PANIC] in %s : cannot create main thread in cluster %x\n", 797 __FUNCTION__ , local_cxy ); 798 hal_core_sleep(); 799 } 800 801 process_dmsg("\n[INFO] %s successfully exit in cluster %x\n", __FUNCTION__ , local_cxy ); 775 assert( (error1 == 0) , __FUNCTION__ , "cannot create process_init\n"); 776 777 process_dmsg("\n[INFO] %s : exit in cluster %x\n", __FUNCTION__ , local_cxy ); 802 778 803 779 hal_fence(); 804 } 805 780 781 } // end process_init_create() 782 -
trunk/kernel/kern/process.h
r173 r204 144 144 xptr_t parent_xp; /*! extended pointer on parent process descriptor */ 145 145 146 xptr_t stdin_xp; /*! extended pointer on stdin pseudo-file */147 146 char path[CONFIG_VFS_MAX_PATH_LENGTH]; /*! .elf file path */ 148 147
Note: See TracChangeset
for help on using the changeset viewer.