Changeset 204 for trunk/kernel
- Timestamp:
- Jul 17, 2017, 8:42:59 AM (7 years ago)
- Location:
- trunk/kernel
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_pic.c
r201 r204 26 26 #include <chdev.h> 27 27 #include <printk.h> 28 #include < hal_drivers.h>28 #include <soclib_pic.h> 29 29 #include <dev_pic.h> 30 30 #include <cluster.h> … … 50 50 { 51 51 // call the PIC SOCLIB driver 52 hal_drivers_pic_init( pic ); 52 soclib_pic_init( pic ); 53 54 // update the PIC chdev extension 55 pic->ext.pic.enable_timer = &soclib_pic_enable_timer; 56 pic->ext.pic.enable_irq = &soclib_pic_enable_irq; 57 pic->ext.pic.disable_irq = &soclib_pic_disable_irq; 58 pic->ext.pic.bind_irq = &soclib_pic_bind_irq; 59 pic->ext.pic.send_ipi = &soclib_pic_send_ipi; 60 pic->ext.pic.extend_init = &soclib_pic_extend_init; 53 61 } 54 62 else if( impl == IMPL_PIC_I86 ) … … 70 78 71 79 // get pointer on extend_init function 72 pic_init_t * f = hal_remote_lpt( XPTR( pic_cxy , &pic_ptr->ext.pic.extend_init ) ); 80 pic_init_t * f = hal_remote_lpt( XPTR( pic_cxy , &pic_ptr->ext.pic.extend_init ) ); 73 81 74 82 // call relevant driver function -
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 -
trunk/kernel/libk/bits.h
r23 r204 30 30 31 31 /********************************************************************************************* 32 * These macros are NOT used by the bitma t, but can be useful in other contexts... [AG]32 * These macros are NOT used by the bitmap, but can be useful in other contexts... [AG] 33 33 *********************************************************************************************/ 34 34 -
trunk/kernel/libk/elf.c
r157 r204 75 75 /////////////////////////////////////////////////////////////////////////////////////// 76 76 // This function loads the .elf header in the buffer allocated by the caller. 77 /////////////////////////////////////////////////////////////////////////////////////// 77 78 // @ file : extended pointer on the remote file descriptor. 78 79 // @ buffer : pointer on buffer allocated by the caller. 79 80 // @ size : number of bytes to read. 80 81 /////////////////////////////////////////////////////////////////////////////////////// 81 static error_t elf_header_ read( xptr_t file_xp,82 static error_t elf_header_load( xptr_t file_xp, 82 83 void * buffer, 83 84 uint32_t size ) … … 114 115 } 115 116 return 0; 116 } 117 118 } // end elf_header_load() 117 119 118 120 /////////////////////////////////////////////////////////////////////////////////////// 119 121 // This function registers in the process VMM the CODE and DATA segments. 122 /////////////////////////////////////////////////////////////////////////////////////// 120 123 // @ file : extended pointer on the remote file descriptor. 121 124 // @ segs_base : local pointer on buffer containing the segments descriptors array … … 212 215 213 216 return 0; 214 } 217 218 } // end elf_segments_load() 215 219 216 220 /////////////////////////////////////////////// … … 218 222 process_t * process) 219 223 { 220 char path_copy[CONFIG_VFS_MAX_PATH_LENGTH];221 224 kmem_req_t req; // kmem request for program header 222 uint32_t length; // actual path length223 225 Elf32_Ehdr header; // local buffer for .elf header 224 226 void * segs_base; // pointer on buffer for segment descriptors array … … 229 231 error_t error; 230 232 231 // get path length from user space 232 length = hal_strlen_from_uspace( pathname ); 233 234 if( length >= CONFIG_VFS_MAX_PATH_LENGTH ) 235 { 236 printk("\n[ERROR] in %s : pathname length too long\n", __FUNCTION__ ); 237 return -1; 238 } 239 240 // make a local copy for pathname 241 hal_copy_from_uspace( path_copy , pathname , length+1 ); 233 elf_dmsg("\n[INFO] %s : enter for %s\n", __FUNCTION__ , pathname ); 234 235 // avoid GCC warning 236 file_xp = XPTR_NULL; 237 file_id = -1; 242 238 243 239 // open file 244 file_xp = XPTR_NULL; // avoid GCC warning245 file_id = -1;246 247 240 error = vfs_open( process->vfs_cwd_xp, 248 path _copy,241 pathname, 249 242 O_RDONLY, 250 243 0, … … 253 246 if( error ) 254 247 { 255 printk("\n[ERROR] in %s : failed to open executable file %s\n", 256 __FUNCTION__ , path_copy ); 257 return -1; 258 } 248 printk("\n[ERROR] in %s : failed to open file %s\n", __FUNCTION__ , pathname ); 249 return -1; 250 } 251 252 elf_dmsg("\n[INFO] %s : file %s open\n", __FUNCTION__ , pathname ); 259 253 260 254 // load header in local buffer 261 error = elf_header_ read( file_xp ,255 error = elf_header_load( file_xp , 262 256 &header, 263 257 sizeof(Elf32_Ehdr) ); 264 258 if( error ) 265 259 { 266 vfs_close( file_xp , file_id ); 267 return -1; 268 } 269 270 elf_dmsg("\n[INFO] %s loaded elf header for %s\n", __FUNCTION__ , path_copy ); 260 printk("\n[ERROR] in %s : cannot get header file %s\n", __FUNCTION__ , pathname ); 261 vfs_close( file_xp , file_id ); 262 return -1; 263 } 264 265 elf_dmsg("\n[INFO] %s : loaded elf header for %s\n", __FUNCTION__ , pathname ); 271 266 272 267 if( header.e_phnum == 0 ) … … 320 315 } 321 316 322 elf_dmsg("\n[INFO] %s loaded segments descriptors for %s \n", __FUNCTION__ , path _copy);317 elf_dmsg("\n[INFO] %s loaded segments descriptors for %s \n", __FUNCTION__ , pathname ); 323 318 324 319 // register loadable segments in process VMM … … 346 341 347 342 elf_dmsg("\n[INFO] %s successfully completed / entry point = %x for %s]\n", 348 __FUNCTION__, (uint32_t) header.e_entry , path _copy);343 __FUNCTION__, (uint32_t) header.e_entry , pathname ); 349 344 350 345 return 0; 351 } 352 346 347 } // end elf_load_process() 348 -
trunk/kernel/libk/elf.h
r158 r204 182 182 * It also registers the process entry point in VMM. 183 183 **************************************************************************************** 184 * @ pathname : .elf file pathname (in user space => must use hal_uspace API).184 * @ pathname : local pointer on .elf file pathname (in kernel space). 185 185 * @ process : local pointer on target process descriptor. 186 186 ***************************************************************************************/ -
trunk/kernel/libk/xhtab.c
r188 r204 76 76 // returns true if given name matches directory entry name. 77 77 //////////////////////////////////////////////////////////////////////////////////////////// 78 static bool_t xhtab_dentry_item_match_key( xptr_t item_xp,78 static bool_t xhtab_dentry_item_match_key( xptr_t item_xp, 79 79 void * key ) 80 80 { 81 vfs_dentry_t * dentry_ptr; 82 cxy_t dentry_cxy; 83 84 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 81 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 85 82 86 83 // get dentry cluster and local pointer 87 dentry_cxy = GET_CXY( item_xp );88 dentry_ptr = (vfs_dentry_t *)GET_PTR( item_xp );84 cxy_t dentry_cxy = GET_CXY( item_xp ); 85 vfs_dentry_t * dentry_ptr = (vfs_dentry_t *)GET_PTR( item_xp ); 89 86 90 87 // make a local copy of directory entry name … … 94 91 return( strcmp( name , (char*)key ) == 0 ); 95 92 } 96 93 94 //////////////////////////////////////////////////////////////////////////////////////////// 95 // This function print the item key, that is the name for a vfs_entry_t, 96 //////////////////////////////////////////////////////////////////////////////////////////// 97 // @ item_xp : extended pointer on item. 98 //////////////////////////////////////////////////////////////////////////////////////////// 99 static void xhtab_dentry_item_print_key( xptr_t item_xp ) 100 { 101 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 102 103 // get dentry cluster and local pointer 104 cxy_t dentry_cxy = GET_CXY( item_xp ); 105 vfs_dentry_t * dentry_ptr = (vfs_dentry_t *)GET_PTR( item_xp ); 106 107 // make a local copy of directory entry name 108 hal_remote_strcpy( XPTR( local_cxy , name ) , 109 XPTR( dentry_cxy , &dentry_ptr->name ) ); 110 111 // print dentry name 112 printk("%s , ", name ); 113 } 114 97 115 //////////////////////////////////////////////////////////////////////////////////////// 98 116 // Generic access functions … … 108 126 remote_rwlock_init( XPTR( local_cxy , &xhtab->lock) ); 109 127 110 xhtab->items = 0; 128 xhtab->items = 0; 129 xhtab->current_index = 0; 130 xhtab->current_xlist_xp = XPTR_NULL; 111 131 112 132 if( type == XHTAB_DENTRY_TYPE ) … … 115 135 xhtab->index_from_key = &xhtab_dentry_index_from_key; 116 136 xhtab->item_from_xlist = &xhtab_dentry_item_from_xlist; 137 xhtab->item_print_key = &xhtab_dentry_item_print_key; 117 138 } 118 139 else … … 134 155 void * key ) 135 156 { 136 xptr_t xlist_xp; // xlist_entry_t (iterator) 137 xptr_t item_xp; // associated item 138 xhtab_t * xhtab_ptr; // hash table local pointer 139 cxy_t xhtab_cxy; // hash table cluster 157 xptr_t xlist_xp; // xlist_entry_t (iterator) 158 xptr_t item_xp; // associated item 159 xhtab_t * xhtab_ptr; // hash table local pointer 160 cxy_t xhtab_cxy; // hash table cluster 161 item_from_xlist_t * item_from_xlist; // function pointer 162 item_match_key_t * item_match_key; // function pointer 140 163 141 164 // get hash table cluster and local pointer 142 165 xhtab_cxy = GET_CXY( xhtab_xp ); 143 166 xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp ); 167 168 // get pointer on "item_from_xlist" function 169 item_from_xlist = (item_from_xlist_t *)hal_remote_lpt( XPTR( xhtab_cxy , 170 &xhtab_ptr->item_from_xlist ) ); 171 // get pointer on "item_match_key" function 172 item_match_key = (item_match_key_t *)hal_remote_lpt( XPTR( xhtab_cxy , 173 &xhtab_ptr->item_match_key ) ); 144 174 145 175 // scan sub-list[index] … … 147 177 { 148 178 // get extended pointer on item containing the xlist entry 149 item_xp = xhtab_ptr->item_from_xlist( xlist_xp );179 item_xp = item_from_xlist( xlist_xp ); 150 180 151 181 // check matching 152 if( xhtab_ptr->item_match_key( item_xp , key ) ) return item_xp;182 if( item_match_key( item_xp , key ) ) return item_xp; 153 183 } 154 184 155 185 // No matching item found 156 186 return XPTR_NULL; 157 } 187 188 } // end xhtab_scan() 158 189 159 190 /////////////////////////////////////// … … 162 193 xptr_t xlist_xp ) 163 194 { 164 // get xhtab cluster and local pointer 165 cxy_t xhtab_cxy = GET_CXY( xhtab_xp ); 166 xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp ); 167 195 xptr_t item_xp; 196 uint32_t index; 197 cxy_t xhtab_cxy; 198 xhtab_t * xhtab_ptr; 199 index_from_key_t * index_from_key; // function pointer 200 201 // get xhtab cluster and local pointer 202 xhtab_cxy = GET_CXY( xhtab_xp ); 203 xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp ); 204 205 // get pointer on "index_from_key" function 206 index_from_key = (index_from_key_t *)hal_remote_lpt( XPTR( xhtab_cxy , 207 &xhtab_ptr->index_from_key ) ); 168 208 // compute index from key 169 uint32_t index = xhtab_ptr->index_from_key( key );209 index = index_from_key( key ); 170 210 171 211 // take the lock protecting hash table … … 173 213 174 214 // search a matching item 175 xptr_titem_xp = xhtab_scan( xhtab_xp , index , key );215 item_xp = xhtab_scan( xhtab_xp , index , key ); 176 216 177 217 if( item_xp != XPTR_NULL ) // error if found … … 202 242 xptr_t xlist_entry_xp ) 203 243 { 204 // get xhtab cluster and local pointer 205 cxy_t xhtab_cxy = GET_CXY( xhtab_xp ); 206 xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp ); 207 244 xptr_t item_xp; 245 uint32_t index; 246 cxy_t xhtab_cxy; 247 xhtab_t * xhtab_ptr; 248 index_from_key_t * index_from_key; // function pointer 249 250 // get xhtab cluster and local pointer 251 xhtab_cxy = GET_CXY( xhtab_xp ); 252 xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp ); 253 254 // get pointer on "index_from_key" function 255 index_from_key = (index_from_key_t *)hal_remote_lpt( XPTR( xhtab_cxy , 256 &xhtab_ptr->index_from_key ) ); 208 257 // compute index from key 209 uint32_t index = xhtab_ptr->index_from_key( key );258 index = index_from_key( key ); 210 259 211 260 // take the lock protecting hash table … … 213 262 214 263 // get extended pointer on item to remove 215 xptr_titem_xp = xhtab_scan( xhtab_xp , index , key );264 item_xp = xhtab_scan( xhtab_xp , index , key ); 216 265 217 266 if( item_xp == XPTR_NULL ) // error if not found … … 241 290 void * key ) 242 291 { 243 xptr_t item_xp; 244 245 // get xhtab cluster and local pointer 246 cxy_t xhtab_cxy = GET_CXY( xhtab_xp ); 247 xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp ); 248 292 xptr_t item_xp; 293 uint32_t index; 294 cxy_t xhtab_cxy; 295 xhtab_t * xhtab_ptr; 296 index_from_key_t * index_from_key; // function pointer 297 298 // get xhtab cluster and local pointer 299 xhtab_cxy = GET_CXY( xhtab_xp ); 300 xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp ); 301 302 // get pointer on "index_from_key" function 303 index_from_key = (index_from_key_t *)hal_remote_lpt( XPTR( xhtab_cxy , 304 &xhtab_ptr->index_from_key ) ); 249 305 // compute index from key 250 uint32_t index = xhtab_ptr->index_from_key( key );306 index = index_from_key( key ); 251 307 252 308 // take the lock protecting hash table … … 288 344 xptr_t xhtab_get_first( xptr_t xhtab_xp ) 289 345 { 290 uint32_t index; 291 xptr_t xlist_xp; 292 xptr_t item_xp; 293 xptr_t root_xp; 294 295 // get xhtab cluster and local pointer 296 cxy_t xhtab_cxy = GET_CXY( xhtab_xp ); 297 xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp ); 298 346 uint32_t index; 347 cxy_t xhtab_cxy; 348 xhtab_t * xhtab_ptr; 349 xptr_t xlist_xp; 350 xptr_t item_xp; 351 xptr_t root_xp; 352 item_from_xlist_t * item_from_xlist; // function pointer 353 354 // get xhtab cluster and local pointer 355 xhtab_cxy = GET_CXY( xhtab_xp ); 356 xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp ); 357 358 // get pointer on "item_from_xlist" function 359 item_from_xlist = (item_from_xlist_t *)hal_remote_lpt( XPTR( xhtab_cxy , 360 &xhtab_ptr->item_from_xlist ) ); 299 361 //loop on subsets 300 362 for( index = 0 ; index < XHASHTAB_SIZE ; index++ ) … … 309 371 { 310 372 // get extended pointer on item containing the xlist entry 311 item_xp = xhtab_ptr->item_from_xlist( xlist_xp );373 item_xp = item_from_xlist( xlist_xp ); 312 374 313 375 // register item in hash table header … … 327 389 xptr_t xhtab_get_next( xptr_t xhtab_xp ) 328 390 { 329 uint32_t index; 330 xptr_t xlist_xp; 331 xptr_t item_xp; 332 xptr_t root_xp; 391 uint32_t index; 392 cxy_t xhtab_cxy; 393 xhtab_t * xhtab_ptr; 394 xptr_t xlist_xp; 395 xptr_t item_xp; 396 xptr_t root_xp; 397 item_from_xlist_t * item_from_xlist; // function pointer 333 398 334 399 uint32_t current_index; … … 336 401 337 402 // get xhtab cluster and local pointer 338 cxy_txhtab_cxy = GET_CXY( xhtab_xp );339 xhtab_ t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );403 xhtab_cxy = GET_CXY( xhtab_xp ); 404 xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp ); 340 405 341 406 // get current item pointers … … 343 408 current_xlist_xp = hal_remote_lwd( XPTR( xhtab_cxy , &xhtab_ptr->current_xlist_xp ) ); 344 409 410 // get pointer on "item_from_xlist" function 411 item_from_xlist = (item_from_xlist_t *)hal_remote_lpt( XPTR( xhtab_cxy , 412 &xhtab_ptr->item_from_xlist ) ); 345 413 //loop on subsets 346 414 for( index = current_index ; index < XHASHTAB_SIZE ; index++ ) … … 350 418 351 419 // get next item 352 xlist_xp = xlist_next( root_xp , current_xlist_xp ); 420 if( index == current_index ) xlist_xp = xlist_next( root_xp , current_xlist_xp ); 421 else xlist_xp = xlist_next( root_xp , root_xp ); 353 422 354 423 if( xlist_xp != XPTR_NULL ) // next item found 355 424 { 356 425 // get extended pointer on item containing the xlist entry 357 item_xp = xhtab_ptr->item_from_xlist( xlist_xp );426 item_xp = item_from_xlist( xlist_xp ); 358 427 359 428 // register item in hash table header … … 370 439 } // end xhtab_get_next() 371 440 372 441 ///////////////////////////////////// 442 void xhtab_display( xptr_t xhtab_xp ) 443 { 444 uint32_t index; 445 cxy_t xhtab_cxy; 446 xhtab_t * xhtab_ptr; 447 xptr_t root_xp; 448 xptr_t iter_xp; 449 xptr_t item_xp; 450 item_from_xlist_t * item_from_xlist; // function pointer 451 item_print_key_t * item_print_key; // function pointer 452 453 // get xhtab cluster and local pointer 454 xhtab_cxy = GET_CXY( xhtab_xp ); 455 xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp ); 456 457 // get pointer on "item_from_xlist" function 458 item_from_xlist = (item_from_xlist_t *)hal_remote_lpt( XPTR( xhtab_cxy , 459 &xhtab_ptr->item_from_xlist ) ); 460 // get pointer on "item_print_key" function 461 item_print_key = (item_print_key_t *)hal_remote_lpt( XPTR( xhtab_cxy , 462 &xhtab_ptr->item_print_key ) ); 463 //loop on subsets 464 for( index = 0 ; index < XHASHTAB_SIZE ; index++ ) 465 { 466 printk(" index = %d : ", index ); 467 468 // get root of subset 469 root_xp = XPTR( xhtab_cxy , &xhtab_ptr->roots[index] ); 470 471 // loop on xlist 472 XLIST_FOREACH( root_xp , iter_xp ) 473 { 474 // get item from xlist 475 item_xp = item_from_xlist( iter_xp ); 476 477 // print item identifier 478 item_print_key( item_xp ); 479 } 480 481 printk("\n"); 482 } 483 } // end xhtab_display() -
trunk/kernel/libk/xhtab.h
r188 r204 36 36 // It can be accessed by any thread, running in any cluster. 37 37 // It is generic as it can be used to register various types of items. 38 // The main goal is to speedup search by key fora large number of items of same type.38 // The main goal is to speedup search by key in a large number of items of same type. 39 39 // For this purpose the set of all registered items is split in several subsets. 40 40 // Each subset is organised as an embedded double linked lists. 41 41 // - an item is uniquely identified by a <key>, that is a single uint32_t value. 42 // - From the <key> value, the hash table uses an item type specific xhtab_index() function,43 // to compute an <index> value, defining a subset of registered items.42 // - From the <key> value, the hash table uses an item type specific xhtab_index() 43 // function, to compute an <index> value, defining a subset of registered items. 44 44 // - to discriminate between items that have the same <index>, the hash table makes 45 // an associative search in subset.45 // an associative search on the key in subset. 46 46 // - Each registered item is a structure, that must contain an embedded xlist_entry, 47 47 // that is part of the xlist implementing the subset. 48 48 // 49 // A total order is defined for all registered itemsby the increasing index values,50 // and for each index value by the position in the partial xlist.49 // For all registered items, a total order is defined by the increasing index values, 50 // and for each index value, by the position in the partial xlist. 51 51 // This order is used by the two functions xhtab_get_first() and xhtab_get_next(), that 52 52 // are used to scan all registered items. The two "current_index" and "current_xlist_xp" … … 54 54 // 55 55 // Implementation Note: 56 // For each supported item type ***, you must define the threeitem-type-specific56 // For each supported item type ***, you must define four item-type-specific 57 57 // functions specified below, and you must update the xhtab_init() function 58 58 // and the xhtab_item_type_t. 59 59 /////////////////////////////////////////////////////////////////////////////////////////// 60 60 61 #define XHASHTAB_SIZE 64// number of subsets61 #define XHASHTAB_SIZE 8 // number of subsets 62 62 63 63 /****************************************************************************************** 64 * This define the three item type specific function prototypes. 64 * This define the four item_type_specific function prototypes that must be defined 65 * for each item type. 65 66 *****************************************************************************************/ 66 67 67 typedef bool_t xhtab_match_t ( xptr_t item_xp , void * key ); 68 typedef xptr_t xhtab_item_t ( xptr_t xlist_xp ); 69 typedef uint32_t xhtab_index_t ( void * key ); 68 typedef bool_t (item_match_key_t) ( xptr_t item_xp , void * key ); 69 typedef xptr_t (item_from_xlist_t) ( xptr_t xlist_xp ); 70 typedef uint32_t (index_from_key_t) ( void * key ); 71 typedef void (item_print_key_t) ( xptr_t item_xp ); 70 72 71 73 /****************************************************************************************** … … 85 87 typedef struct xhtab_s 86 88 { 87 xlist_entry_t roots[XHASHTAB_SIZE]; /*! array of roots of xlist */ 88 xhtab_index_t * index_from_key; /*! item specific function */ 89 xhtab_match_t * item_match_key; /*! item specific function */ 90 xhtab_item_t * item_from_xlist; /*! item specific function */ 91 uint32_t items; /*! number of registered items */ 92 remote_rwlock_t lock; /*! lock protecting hash table accesses */ 93 uint32_t current_index; /*! current item subset index */ 94 xptr_t * current_xlist_xp; /*! xptr on current item xlist entry */ 89 xlist_entry_t roots[XHASHTAB_SIZE]; /*! array of roots of xlist */ 90 index_from_key_t * index_from_key; /*! item specific function pointer */ 91 item_match_key_t * item_match_key; /*! item specific function pointer */ 92 item_from_xlist_t * item_from_xlist; /*! item specific function pointer */ 93 item_print_key_t * item_print_key; /*! item specific function pointer */ 94 uint32_t items; /*! number of registered items */ 95 remote_rwlock_t lock; /*! lock protecting hash table accesses */ 96 uint32_t current_index; /*! current item subset index */ 97 xptr_t current_xlist_xp; /*! xptr on current item xlist entry */ 95 98 } 96 99 xhtab_t; … … 100 103 * The initialisation must be done by a thread running in cluster containing the table. 101 104 ****************************************************************************************** 102 * @ xhtab : local pointer on local xhtab to be initialized.103 * @ type : item type (see above).105 * @ xhtab : local pointer on local xhtab to be initialized. 106 * @ type : item type (see above). 104 107 *****************************************************************************************/ 105 108 void xhtab_init( xhtab_t * xhtab, … … 176 179 xptr_t xhtab_get_next( xptr_t xhtab_xp ); 177 180 178 181 /****************************************************************************************** 182 * This function displays the full content of an xhtab. 183 ****************************************************************************************** 184 * @ xhtab_xp : extended pointer on hash table. 185 *****************************************************************************************/ 186 void xhtab_display( xptr_t xhtab_xp ); 179 187 180 188 #endif /* _XHTAB_H_ */ -
trunk/kernel/mm/mapper.c
r183 r204 88 88 89 89 return mapper; 90 } 90 91 } // end mapper_create() 91 92 92 93 /////////////////////////////////////////// … … 127 128 128 129 return 0; 129 } 130 131 } // end mapper_destroy() 130 132 131 133 //////////////////////////////////////////// … … 137 139 error_t error; 138 140 141 mapper_dmsg("\n[INFO] %s : enter for page %d / mapper = %x\n", 142 __FUNCTION__ , index , mapper ); 143 139 144 thread_t * this = CURRENT_THREAD; 140 145 … … 148 153 if( ( page == NULL) || page_is_flag( page , PG_INLOAD ) ) // page not available 149 154 { 155 150 156 // release the lock in READ_MODE and take it in WRITE_MODE 151 157 rwlock_rd_unlock( &mapper->lock ); … … 160 166 if ( page == NULL ) // missing page => load it from file system 161 167 { 168 mapper_dmsg("\n[INFO] %s : missing page => load from FS\n", __FUNCTION__ ); 169 162 170 // allocate one page from PPM 163 171 req.type = KMEM_PAGE; … … 237 245 sched_yield(); 238 246 } 239 240 } 241 242 return page; 243 } 244 else 245 { 246 // release lock from READ_MODE 247 rwlock_rd_unlock( &mapper->lock ); 248 249 return page; 250 } 251 } 247 } 248 } 249 else // page available in mapper 250 { 251 252 rwlock_rd_unlock( &mapper->lock ); 253 } 254 255 mapper_dmsg("\n[INFO] %s : exit for page %d / page desc = %x\n", 256 __FUNCTION__ , index , page ); 257 258 return page; 259 260 } // end mapper_get_page() 252 261 253 262 /////////////////////////////////////////////// … … 282 291 283 292 return 0; 284 } 293 294 } // end mapper_release_page() 285 295 286 296 ///////////////////////////////////////// … … 298 308 uint8_t * map_ptr; // current mapper address 299 309 uint8_t * buf_ptr; // current buffer address 310 311 mapper_dmsg("\n[INFO] %s : enter / to_buf = %d / buffer = %x\n", 312 __FUNCTION__ , to_buffer , buffer ); 300 313 301 314 // compute offsets of first and last bytes in file … … 347 360 } 348 361 362 mapper_dmsg("\n[INFO] %s : exit for buffer %x\n", 363 __FUNCTION__, buffer ); 364 349 365 return 0; 350 } 351 366 367 } // end mapper_move() 368 -
trunk/kernel/mm/mapper.h
r23 r204 50 50 * readers, and only one writer. This lock implement a busy waiting policy. 51 51 * - The two functions vfs_move_page_to_mapper() and vfs_move_page_from_mapper() define 52 * the generic API used to move pages to or from the relevant file system on IOC device.52 * the generic API used to move pages to or from the relevant file system. 53 53 * - the mapper_move() function is used to move data to or from a, possibly distributed 54 54 * user buffer in user space. … … 122 122 * The offset in the file descriptor is not modified by this function. 123 123 ******************************************************************************************* 124 * @ mapper : extendedpointer on local mapper.124 * @ mapper : local pointer on local mapper. 125 125 * @ to_buffer : move data from mapper to buffer if true. 126 126 * @ file_offset : first byte to move in file. -
trunk/kernel/mm/vmm.c
r179 r204 62 62 intptr_t size; 63 63 64 vmm_dmsg("\n[INFO] %s : enter for process %x\n", __FUNCTION__ , process->pid ); 65 64 66 // get pointer on VMM 65 67 vmm_t * vmm = &process->vmm; 66 68 67 // check UTILS zone size 68 if( (CONFIG_VMM_KENTRY_SIZE + CONFIG_VMM_ARGS_SIZE + CONFIG_VMM_ENVS_SIZE ) > 69 CONFIG_VMM_ELF_BASE ) 70 { 71 printk("\n[PANIC] in %s : UTILS zone too small for process %x\n", 72 __FUNCTION__ , process->pid ); 73 hal_core_sleep(); 74 } 75 76 // check max number of stacks slots 77 if( CONFIG_THREAD_MAX_PER_CLUSTER > 32 ) 78 { 79 printk("\n[PANIC] in %s : max number of threads per cluster for a single process" 80 " cannot be larger than 32\n", __FUNCTION__ ); 81 hal_core_sleep(); 82 } 83 84 // check STACK zone size 85 if( (CONFIG_VMM_STACK_SIZE * CONFIG_THREAD_MAX_PER_CLUSTER) > 86 (CONFIG_VMM_VSPACE_SIZE - CONFIG_VMM_STACK_BASE) ) 87 { 88 printk("\n[PANIC] in %s : STACK zone too small for process %x\n", 89 __FUNCTION__ , process->pid ); 90 hal_core_sleep(); 91 } 69 assert( ((CONFIG_VMM_KENTRY_SIZE + CONFIG_VMM_ARGS_SIZE + CONFIG_VMM_ENVS_SIZE) 70 <= CONFIG_VMM_ELF_BASE) , __FUNCTION__ , "UTILS zone too small\n" ); 71 72 assert( (CONFIG_THREAD_MAX_PER_CLUSTER <= 32) , __FUNCTION__ , 73 "no more than 32 threads per cluster for a single process\n"); 74 75 assert( ((CONFIG_VMM_STACK_SIZE * CONFIG_THREAD_MAX_PER_CLUSTER) <= 76 (CONFIG_VMM_VSPACE_SIZE - CONFIG_VMM_STACK_BASE)) , __FUNCTION__ , 77 "STACK zone too small\n"); 92 78 93 79 // initialize the rwlock protecting the vsegs list … … 101 87 CONFIG_VMM_GRDXT_W2, 102 88 CONFIG_VMM_GRDXT_W3 ); 103 if( error ) 104 { 105 printk("\n[PANIC] in %s : cannot initialize radix tree for process %x\n", 106 __FUNCTION__ , process->pid ); 107 hal_core_sleep(); 108 } 89 90 assert( (error == 0) , __FUNCTION__ , "cannot initialize radix tree\n" ); 109 91 110 92 // register kentry vseg in VMM … … 112 94 size = CONFIG_VMM_KENTRY_SIZE << CONFIG_PPM_PAGE_SHIFT; 113 95 vseg_kentry = vmm_create_vseg( process , base , size , VSEG_TYPE_CODE ); 114 if( vseg_kentry == NULL ) 115 { 116 printk("\n[PANIC] in %s : cannot register kent vseg for process %x\n", 117 __FUNCTION__ , process->pid ); 118 hal_core_sleep(); 119 } 96 97 assert( (vseg_kentry != NULL) , __FUNCTION__ , "cannot register kentry vseg\n" ); 98 120 99 vmm->kent_vpn_base = 1; 121 100 … … 124 103 size = CONFIG_VMM_ARGS_SIZE << CONFIG_PPM_PAGE_SHIFT; 125 104 vseg_args = vmm_create_vseg( process , base , size , VSEG_TYPE_DATA ); 126 if( vseg_args == NULL ) 127 { 128 printk("\n[PANIC] in %s : cannot register args vseg for process %x\n", 129 __FUNCTION__ , process->pid ); 130 hal_core_sleep(); 131 } 105 106 assert( (vseg_args != NULL) , __FUNCTION__ , "cannot register args vseg\n" ); 107 132 108 vmm->args_vpn_base = CONFIG_VMM_KENTRY_SIZE + 1; 133 109 … … 136 112 size = CONFIG_VMM_ENVS_SIZE << CONFIG_PPM_PAGE_SHIFT; 137 113 vseg_envs = vmm_create_vseg( process , base , size , VSEG_TYPE_DATA ); 138 if( vseg_envs == NULL ) 139 { 140 printk("\n[PANIC] in %s : cannot register envs vseg for process %x\n", 141 __FUNCTION__ , process->pid ); 142 hal_core_sleep(); 143 } 114 115 assert( (vseg_envs != NULL) , __FUNCTION__ , "cannot register envs vseg\n" ); 116 144 117 vmm->envs_vpn_base = CONFIG_VMM_KENTRY_SIZE + CONFIG_VMM_ARGS_SIZE + 1; 145 118 … … 148 121 size = (CONFIG_VMM_MMAP_BASE-CONFIG_VMM_HEAP_BASE) << CONFIG_PPM_PAGE_SHIFT; 149 122 vseg_heap = vmm_create_vseg( process , base , size , VSEG_TYPE_HEAP ); 150 if( vseg_heap == NULL ) 151 { 152 printk("\n[PANIC] in %s : cannot register heap vseg in for process %x\n", 153 __FUNCTION__ , process->pid ); 154 hal_core_sleep(); 155 } 123 124 assert( (vseg_heap != NULL) , __FUNCTION__ , "cannot register heap vseg\n" ); 125 156 126 vmm->heap_vpn_base = CONFIG_VMM_HEAP_BASE; 157 127 158 128 // initialize generic page table 159 129 error = hal_gpt_create( &vmm->gpt ); 160 if( error ) 161 { 162 printk("PANIC in %s : cannot initialize page table\n", __FUNCTION__ ); 163 hal_core_sleep(); 164 } 130 131 assert( (error == 0) , __FUNCTION__ , "cannot initialize page table\n"); 165 132 166 133 // initialize STACK allocator … … 181 148 182 149 hal_fence(); 183 } 150 151 vmm_dmsg("\n[INFO] %s : exit for process %x\n", __FUNCTION__ , process->pid ); 152 153 } // end vmm_init() 184 154 185 155 ////////////////////////////////////////// … … 301 271 302 272 return 0; 303 } 273 274 } // vmm_copy() 304 275 305 276 /////////////////////////////////////// … … 342 313 // release memory allocated to the local page table 343 314 hal_gpt_destroy( &vmm->gpt ); 344 } 315 316 } // end vmm_destroy() 345 317 346 318 ///////////////////////////////////////////////// … … 357 329 { 358 330 vseg = LIST_ELEMENT( iter , vseg_t , list ); 331 359 332 if( ((vpn_base + vpn_size) > vseg->vpn_base) && 360 333 (vpn_base < (vseg->vpn_base + vseg->vpn_size)) ) return vseg; 361 334 } 362 335 return NULL; 363 } 336 337 } // end vmm_check_conflict() 364 338 365 339 //////////////////////////////////////////////////////////////////////////////////////////// … … 399 373 *vpn_size = CONFIG_VMM_STACK_SIZE - 1; 400 374 return 0; 401 } 375 376 } // end vmm_stack_alloc() 402 377 403 378 //////////////////////////////////////////////////////////////////////////////////////////// … … 464 439 *vpn_size = size; 465 440 return 0; 466 } 441 442 } // end vmm_mmap_alloc() 467 443 468 444 ////////////////////////////////////////////// … … 473 449 { 474 450 vseg_t * vseg; // created vseg pointer 475 vpn_t vpn_base; // vseg first page451 vpn_t vpn_base; // first page index 476 452 vpn_t vpn_size; // number of pages 477 453 error_t error; … … 480 456 vmm_t * vmm = &process->vmm; 481 457 482 vmm_dmsg("\n[INFO] %s enter for process %x / base = %x / size = %x / type = %s\n",458 vmm_dmsg("\n[INFO] %s : enter for process %x / base = %x / size = %x / type = %s\n", 483 459 __FUNCTION__ , process->pid , base , size , vseg_type_str(type) ); 484 460 485 // compute base, size, vpn_base, vpn_size, depending on type461 // compute base, size, vpn_base, vpn_size, depending on vseg type 486 462 // we use the VMM specific allocators for STACK and MMAP vsegs 487 463 if( type == VSEG_TYPE_STACK ) … … 520 496 else 521 497 { 522 vpn_base = ARROUND_DOWN( base , CONFIG_PPM_PAGE_SIZE ) >> CONFIG_PPM_PAGE_SHIFT; 523 vpn_size = ARROUND_UP( base + size , CONFIG_PPM_PAGE_SIZE ) >> CONFIG_PPM_PAGE_SHIFT; 498 uint32_t vpn_min = base >> CONFIG_PPM_PAGE_SHIFT; 499 uint32_t vpn_max = (base + size - 1) >> CONFIG_PPM_PAGE_SHIFT; 500 501 vpn_base = vpn_min; 502 vpn_size = vpn_max - vpn_min + 1; 524 503 } 525 504 … … 555 534 rwlock_wr_unlock( &vmm->vsegs_lock ); 556 535 557 vmm_dmsg("\n[INFO] : %s exit for process %x,vseg [%x, %x] has been mapped\n",536 vmm_dmsg("\n[INFO] %s : exit for process %x / vseg [%x, %x] has been mapped\n", 558 537 __FUNCTION__ , process->pid , vseg->min , vseg->max ); 559 538 -
trunk/kernel/vfs/devfs.c
r188 r204 53 53 ///////////////////////////////////////////// 54 54 void devfs_ctx_init( devfs_ctx_t * devfs_ctx, 55 xptr_t devfs_ root_inode_xp,55 xptr_t devfs_dev_inode_xp, 56 56 xptr_t devfs_external_inode_xp ) 57 57 { 58 devfs_ctx-> root_inode_xp = devfs_root_inode_xp;58 devfs_ctx->dev_inode_xp = devfs_dev_inode_xp; 59 59 devfs_ctx->external_inode_xp = devfs_external_inode_xp; 60 60 … … 74 74 /////////////////////////////////////////////////// 75 75 void devfs_global_init( xptr_t parent_inode_xp, 76 xptr_t * devfs_ root_inode_xp,76 xptr_t * devfs_dev_inode_xp, 77 77 xptr_t * devfs_external_inode_xp ) 78 78 { … … 86 86 "dev", 87 87 NULL, 88 devfs_ root_inode_xp );88 devfs_dev_inode_xp ); 89 89 90 90 nolock_assert( (error == 0) , __FUNCTION__ , "cannot create <dev>\n" ); … … 94 94 INODE_TYPE_DIR, 95 95 FS_TYPE_DEVFS, 96 *devfs_ root_inode_xp,97 " dev",96 *devfs_dev_inode_xp, 97 "external", 98 98 NULL, 99 99 devfs_external_inode_xp ); … … 102 102 } 103 103 104 ////////////////////////////////////////////////// 105 void devfs_local_init( xptr_t devfs_root_inode_xp, 106 xptr_t devfs_external_inode_xp ) 104 /////////////////////////////////////////////////// 105 void devfs_local_init( xptr_t devfs_dev_inode_xp, 106 xptr_t devfs_external_inode_xp, 107 xptr_t * devfs_internal_inode_xp ) 107 108 { 108 109 char node_name[16]; … … 110 111 cxy_t chdev_cxy; 111 112 xptr_t inode_xp; 112 xptr_t internal_inode_xp;113 113 uint32_t channel; 114 114 … … 118 118 INODE_TYPE_DIR, 119 119 FS_TYPE_DEVFS, 120 devfs_ root_inode_xp,120 devfs_dev_inode_xp, 121 121 node_name, 122 122 NULL, 123 &internal_inode_xp );124 125 // create ICUchdev inode126 chdev_xp = chdev_dir. icu[local_cxy];127 if( chdev_xp != XPTR_NULL) 123 devfs_internal_inode_xp ); 124 125 // create MMC chdev inode 126 chdev_xp = chdev_dir.mmc[local_cxy]; 127 if( chdev_xp != XPTR_NULL) 128 128 { 129 129 vfs_add_child_in_parent( local_cxy, 130 130 INODE_TYPE_DEV, 131 131 FS_TYPE_DEVFS, 132 internal_inode_xp, 133 "icu", 134 GET_PTR( chdev_xp ), 135 &inode_xp ); 136 } 137 138 // create MMC chdev inode 139 chdev_xp = chdev_dir.mmc[local_cxy]; 140 if( chdev_xp != XPTR_NULL) 141 { 142 vfs_add_child_in_parent( local_cxy, 143 INODE_TYPE_DEV, 144 FS_TYPE_DEVFS, 145 internal_inode_xp, 132 *devfs_internal_inode_xp, 146 133 "mmc", 147 134 GET_PTR( chdev_xp ), … … 159 146 INODE_TYPE_DEV, 160 147 FS_TYPE_DEVFS, 161 internal_inode_xp,148 *devfs_internal_inode_xp, 162 149 node_name, 163 150 GET_PTR( chdev_xp ), -
trunk/kernel/vfs/devfs.h
r188 r204 51 51 typedef struct devfs_ctx_s 52 52 { 53 xptr_t root_inode_xp;/*! extended pointer on DEVFS root inode */53 xptr_t dev_inode_xp; /*! extended pointer on DEVFS root inode */ 54 54 xptr_t external_inode_xp; /*! extended pointer on DEVFS external inode */ 55 55 } … … 69 69 ***************************************************************************************** 70 70 * @ devfs_ctx : local pointer on DEVFS context. 71 * @ devfs_ root_inode_xp : [out] extended pointer on created<dev> inode.72 * @ devfs_external_inode_xp : [out] extended pointer on created<external> inode.71 * @ devfs_dev_inode_xp : [out] extended pointer on <dev> inode. 72 * @ devfs_external_inode_xp : [out] extended pointer on <external> inode. 73 73 ****************************************************************************************/ 74 74 void devfs_ctx_init( devfs_ctx_t * devfs_ctx, 75 xptr_t devfs_ root_inode_xp,75 xptr_t devfs_dev_inode_xp, 76 76 xptr_t devfs_external_inode_xp ); 77 77 … … 91 91 ***************************************************************************************** 92 92 * @ parent_inode_xp : extended pointer on the parent VFS inode. 93 * @ devfs_ root_inode_xp: [out] extended pointer on created <dev> inode.93 * @ devfs_dev_inode_xp : [out] extended pointer on created <dev> inode. 94 94 * @ devfs_external_inode_xp : [out] extended pointer on created <external> inode. 95 95 ****************************************************************************************/ 96 96 void devfs_global_init( xptr_t parent_inode_xp, 97 xptr_t * devfs_ root_inode_xp,97 xptr_t * devfs_dev_inode_xp, 98 98 xptr_t * devfs_external_inode_xp ); 99 99 … … 108 108 * a pseudo-file, linked to the DEVFS "internal" parent directory. 109 109 ***************************************************************************************** 110 * @ devfs_ root_inode_xp: extended pointer on DEVFS root inode.110 * @ devfs_dev_inode_xp : extended pointer on DEVFS root inode. 111 111 * @ devfs_external_inode_xp : extended pointer on DEVFS external inode. 112 * @ devfs_internal_inode_xp : [out] extended pointer on created <internal> inode. 112 113 ****************************************************************************************/ 113 void devfs_local_init( xptr_t devfs_root_inode_xp, 114 xptr_t devfs_external_inode_xp ); 114 void devfs_local_init( xptr_t devfs_dev_inode_xp, 115 xptr_t devfs_external_inode_xp, 116 xptr_t * devfs_internal_inode_xp ); 115 117 116 118 #endif /* _DEVFS_H_ */ -
trunk/kernel/vfs/vfs.c
r188 r204 215 215 xlist_root_init( XPTR( local_cxy , &inode->wait_root ) ); 216 216 217 // initialize dentries hash table , if new inode is a directory218 if( inode_type == INODE_TYPE_DIR )xhtab_init( &inode->children , XHTAB_DENTRY_TYPE );217 // initialize dentries hash table 218 xhtab_init( &inode->children , XHTAB_DENTRY_TYPE ); 219 219 220 220 // initialize inode locks … … 329 329 } 330 330 331 ////////////////////////////////////////////////////////////////////////////////////////// 331 ///////////////////////////////////////// 332 void vfs_inode_display( xptr_t inode_xp ) 333 { 334 cxy_t inode_cxy; 335 vfs_inode_t * inode_ptr; 336 xptr_t dentry_xp; 337 cxy_t dentry_cxy; 338 vfs_dentry_t * dentry_ptr; 339 340 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 341 342 // get inode cluster and local pointer 343 inode_cxy = GET_CXY( inode_xp ); 344 inode_ptr = (vfs_inode_t *)GET_PTR( inode_xp ); 345 346 // get parent dentry 347 dentry_xp = hal_remote_lwd( XPTR( inode_cxy , &inode_ptr->parent_xp ) ); 348 349 // get local copy of name 350 if( dentry_xp == XPTR_NULL ) // it is the VFS root 351 { 352 strcpy( name , "/" ); 353 } 354 else // not the VFS root 355 { 356 dentry_cxy = GET_CXY( dentry_xp ); 357 dentry_ptr = (vfs_dentry_t *)GET_PTR( dentry_xp ); 358 359 hal_remote_strcpy( XPTR( local_cxy , name ) , 360 XPTR( dentry_cxy , &dentry_ptr->name ) ); 361 } 362 363 // display inode header 364 printk("\n*** inode <%s> / inode_xp = %l / dentry_xp = %l ***\n", 365 name , inode_xp , dentry_xp ); 366 367 // display children from xhtab 368 xhtab_display( XPTR( inode_cxy , &inode_ptr->children ) ); 369 370 } // end vfs_inode_display() 371 372 //////////////////////////////////////////////////////////////////////////////////////////// 332 373 // Dentry related functions 333 374 ////////////////////////////////////////////////////////////////////////////////////////// … … 509 550 510 551 vfs_dmsg("\n[INFO] %s : enters for <%s> at cycle %d\n", 511 __FUNCTION__ , path , hal_get_cycles() );552 __FUNCTION__ , path , (uint32_t)hal_time_stamp() ); 512 553 513 554 // compute lookup working mode … … 619 660 else if (inode_type == INODE_TYPE_DEV ) 620 661 { 621 // TODO 662 // TODO [AG] 622 663 return 0; 623 664 } … … 628 669 return -1; 629 670 } 630 } // end vfs_ access()671 } // end vfs_move() 631 672 632 673 ////////////////////////////////////// … … 857 898 static void vfs_recursive_display( xptr_t inode_xp, 858 899 xptr_t name_xp, 900 xptr_t dentry_xp, 859 901 uint32_t indent ) 860 902 { … … 862 904 vfs_inode_t * inode_ptr; 863 905 vfs_inode_type_t inode_type; 864 xptr_t inode_children_xp; // extended pointer on children xhtab 865 866 xptr_t dentry_xp; 867 cxy_t dentry_cxy; 868 vfs_dentry_t * dentry_ptr; 906 xptr_t children_xp; // extended pointer on children xhtab 907 908 xptr_t child_dentry_xp; 909 cxy_t child_dentry_cxy; 910 vfs_dentry_t * child_dentry_ptr; 911 xptr_t child_inode_xp; 912 xptr_t child_dentry_name_xp; 869 913 870 914 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 871 872 xptr_t child_inode_xp;873 xptr_t dentry_name_xp;874 915 875 916 char * indent_str[] = { "", // level 0 … … 905 946 906 947 // display inode 907 printk(" %s %s : %s\n", indent_str[indent], vfs_inode_type_str( inode_type ), name ); 948 printk("%s%s <%s> inode_xp = %l / dentry_xp = %l\n", 949 indent_str[indent], vfs_inode_type_str( inode_type ), 950 name , inode_xp , dentry_xp ); 908 951 909 952 // scan directory entries … … 911 954 { 912 955 // get extended pointer on directory entries xhtab 913 inode_children_xp = hal_remote_lwd( XPTR( inode_cxy , &inode_ptr->children ));956 children_xp = XPTR( inode_cxy , &inode_ptr->children ); 914 957 915 958 // get xhtab lock 916 xhtab_read_lock( inode_children_xp );959 xhtab_read_lock( children_xp ); 917 960 918 961 // get first dentry from xhtab 919 dentry_xp = xhtab_get_first( inode_children_xp );920 921 while( dentry_xp != XPTR_NULL )962 child_dentry_xp = xhtab_get_first( children_xp ); 963 964 while( child_dentry_xp != XPTR_NULL ) 922 965 { 923 966 // get dentry cluster and local pointer 924 dentry_cxy = GET_CXY(dentry_xp );925 dentry_ptr = (vfs_dentry_t *)GET_PTR(dentry_xp );967 child_dentry_cxy = GET_CXY( child_dentry_xp ); 968 child_dentry_ptr = (vfs_dentry_t *)GET_PTR( child_dentry_xp ); 926 969 927 970 // get extended pointer on child inode 928 child_inode_xp = hal_remote_lwd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) ); 971 child_inode_xp = hal_remote_lwd( XPTR( child_dentry_cxy, 972 &child_dentry_ptr->child_xp ) ); 929 973 930 974 // get extended pointer on dentry name 931 dentry_name_xp = XPTR( dentry_cxy , &dentry_ptr->name );975 child_dentry_name_xp = XPTR( child_dentry_cxy , &child_dentry_ptr->name ); 932 976 933 977 // recursive call on child inode 934 vfs_recursive_display( child_inode_xp , dentry_name_xp , indent+1 ); 978 vfs_recursive_display( child_inode_xp, 979 child_dentry_name_xp, 980 child_dentry_xp, 981 indent+1 ); 935 982 936 983 // get next dentry 937 dentry_xp = xhtab_get_next( inode_children_xp );984 child_dentry_xp = xhtab_get_next( children_xp ); 938 985 } 939 986 940 987 // release xhtab lock 941 xhtab_read_unlock( inode_children_xp );988 xhtab_read_unlock( children_xp ); 942 989 } 943 990 } // end vfs_recursive_display() … … 946 993 void vfs_display( xptr_t inode_xp ) 947 994 { 948 xptr_t name_xp; // extended pointer on string containing the inode name995 xptr_t name_xp; 949 996 xptr_t dentry_xp; 950 997 cxy_t dentry_cxy; 951 998 vfs_dentry_t * dentry_ptr; 952 999 953 printk("\n@@@ %s enters\n", __FUNCTION__ );954 955 1000 // get target inode cluster and local pointer 956 1001 cxy_t inode_cxy = GET_CXY( inode_xp ); … … 977 1022 978 1023 // print header 979 printk("\n*** Current VFS content***\n");1024 printk("\n*** VFS ***\n"); 980 1025 981 1026 // call recursive function 982 vfs_recursive_display( inode_xp , name_xp , 0 );983 984 } // end vfs_di play()1027 vfs_recursive_display( inode_xp , name_xp , dentry_xp , 0 ); 1028 1029 } // end vfs_display() 985 1030 986 1031 ////////////////////////////////////////////////////////////////////////////////////////// … … 1015 1060 ////////////////////////////////////////////////////////////////////////////////////////// 1016 1061 // This static function is used by the vfs_lookup() function. 1017 // It takes an extended pointer on a remote inode (parent directory inode), a directory1062 // It takes an extended pointer on a remote parent directory inode, a directory 1018 1063 // entry name, and returns an extended pointer on the child inode. 1019 1064 // It can be used by any thread running in any cluster. … … 1050 1095 *child_xp = (xptr_t)hal_remote_lwd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) ); 1051 1096 return true; 1052 } 1097 1098 } // end vfs_get_child() 1053 1099 1054 1100 ////////////////////////////////////////////////////////////////////////////////////////// … … 1083 1129 while( (*ptr != 0) && (*ptr !='/') ) *(name++) = *(ptr++); 1084 1130 1131 // set NUL terminating character in name buffer 1132 *(name++) = 0; 1133 1085 1134 // return last an next 1086 1135 if( *ptr == 0 ) // last found character is NUL => last name in path … … 1095 1144 1096 1145 return 0; 1097 } 1146 1147 } // end vfs_get name_from_path() 1098 1148 1099 1149 ////////////////////////////////////////////// … … 1122 1172 error_t error; 1123 1173 1124 vfs_dmsg("\n[INFO] %s : enters for <%s> \n",1125 __FUNCTION__ , pathname );1174 vfs_dmsg("\n[INFO] %s : enters for <%s> at cycle %d\n", 1175 __FUNCTION__ , pathname , (uint32_t)hal_time_stamp() ); 1126 1176 1127 1177 this = CURRENT_THREAD; … … 1142 1192 1143 1193 // load from device if one intermediate node not found 1144 // exit when last name found (i.e. last == true)1194 // exit while loop when last name found (i.e. last == true) 1145 1195 do 1146 1196 { … … 1148 1198 vfs_get_name_from_path( current , name , &next , &last ); 1149 1199 1150 vfs_dmsg("\n[INFO] %s : looking for node<%s> / last = %d\n",1200 vfs_dmsg("\n[INFO] %s : looking for <%s> / last = %d\n", 1151 1201 __FUNCTION__ , name , last ); 1152 1202 1153 // search a child dentry matching name forparent inode1203 // search a child dentry matching name in parent inode 1154 1204 found = vfs_get_child( parent_xp, 1155 1205 name, … … 1158 1208 if( found == false ) // child inode not found in inode tree => try to load it 1159 1209 { 1160 vfs_dmsg("\n[INFO] %s : node<%s> not found, try to load it\n",1210 vfs_dmsg("\n[INFO] %s : <%s> not found, try to load it\n", 1161 1211 __FUNCTION__ , name ); 1162 1212 … … 1168 1218 parent_ptr = (vfs_inode_t *)GET_PTR( parent_xp ); 1169 1219 1220 // get local pointer on parent inode context 1221 ctx_ptr = (vfs_ctx_t *)hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->ctx ) ); 1222 1170 1223 // get parent inode FS type 1171 ctx_ptr = (vfs_ctx_t *)hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->ctx ) ); 1172 fs_type = ctx_ptr->type; 1224 fs_type = hal_remote_lw( XPTR( parent_cxy , &ctx_ptr->type ) ); 1173 1225 1174 1226 // get child inode type … … 1179 1231 cxy_t child_cxy = vfs_cluster_random_select(); 1180 1232 1233 printk("\n@@@ name not found : <%s>\n", name ); 1234 1181 1235 // insert a new child dentry/inode in parent inode 1182 1236 error = vfs_add_child_in_parent( child_cxy, … … 1187 1241 name, 1188 1242 &child_xp ); 1189 1190 1243 if( error ) 1191 1244 { … … 1199 1252 } 1200 1253 1201 vfs_dmsg("\n[INFO] %s : node <%s> found / parent = %l / child = %l / last = %d\n", 1254 vfs_inode_display( child_xp ); 1255 1256 vfs_display( parent_xp ); 1257 1258 vfs_dmsg("\n[INFO] %s : found <%s> / parent = %l / child = %l / last = %d\n", 1202 1259 __FUNCTION__ , name , parent_xp , child_xp , last ); 1203 1260 … … 1334 1391 parent_ptr = (vfs_inode_t *)GET_PTR( parent_xp ); 1335 1392 1336 // get parent inode context local pointer 1337 parent_ctx = (vfs_ctx_t *)hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->ctx ) ); 1338 1339 // create dentry 1393 // 1. create dentry 1340 1394 if( parent_cxy == local_cxy ) // parent cluster is the local cluster 1341 1395 { … … 1359 1413 printk("\n[ERROR] in %s : cannot create dentry in cluster %x\n", 1360 1414 __FUNCTION__ , parent_cxy ); 1361 return error;1362 } 1363 1364 // create child inode TODO : define attr / mode / uid / gid1415 return ENOMEM; 1416 } 1417 1418 // 2. create child inode TODO : define attr / mode / uid / gid 1365 1419 uint32_t attr = 0; 1366 1420 uint32_t mode = 0; … … 1403 1457 if( parent_cxy == local_cxy ) vfs_dentry_destroy( dentry ); 1404 1458 else rpc_vfs_dentry_destroy_client( parent_cxy , dentry ); 1405 return error; 1406 } 1459 return ENOMEM; 1460 } 1461 1462 // 3. update extended pointer on inode in dentry 1463 cxy_t dentry_cxy = GET_CXY( dentry_xp ); 1464 vfs_dentry_t * dentry_ptr = (vfs_dentry_t *)GET_PTR( dentry_xp ); 1465 hal_remote_swd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) , inode_xp ); 1407 1466 1408 1467 // success : return extended pointer on child inode … … 1422 1481 error_t vfs_move_page_to_mapper( page_t * page ) 1423 1482 { 1424 error_t 1483 error_t error = 0; 1425 1484 1426 1485 assert( (page != NULL) , __FUNCTION__ , "page pointer is NULL\n" ); -
trunk/kernel/vfs/vfs.h
r188 r204 450 450 451 451 /****************************************************************************************** 452 * This debug function diplays the name of the inode identified by the <inode_xp> 453 * argument, and all children names for a directory. 454 ***************************************************************************************** 455 * @ inode_xp : extended pointer on the remote inode. 456 *****************************************************************************************/ 457 void vfs_inode_display( xptr_t inode_xp ); 458 459 460 461 462 463 464 /****************************************************************************************** 452 465 * This function TODO 453 466 *****************************************************************************************/ … … 617 630 * It can be executed by any thread running in any cluster, as this function 618 631 * uses the rpc_dentry_create_client() and rpc_inode_create client() if required. 619 * - The dentry is created in the cluster containing the existing <parent_xp> inode. 620 * - the inode and its associated mapper are created in cluster identified by <child_cxy>. 621 * - The new dentry name is defined by the <name> argument. 622 * - The new inode and the parent inode can have different FS types. 632 * This is done in three steps: 633 * 1) The dentry is created in the cluster containing the existing <parent_xp> inode. 634 * The new dentry name is defined by the <name> argument. 635 * 2) The inode and its associated mapper are created in cluster identified by <child_cxy>. 636 * The new inode and the parent inode can have different FS types. 637 * 3) The "child_xp" field in created dentry (pointing on thecreated inode) is updated. 623 638 ****************************************************************************************** 624 639 * @ child_cxy : target cluster for child inode. … … 629 644 * @ extend : fs_type_specific inode extension. 630 645 * @ child_xp : [out] buffer for extended pointer on child inode. 631 * @ return 0 if success / ENO ENT if entry not found in parent directory646 * @ return 0 if success / ENOMEM if dentry or inode cannot be created. 632 647 *****************************************************************************************/ 633 648 error_t vfs_add_child_in_parent( cxy_t child_cxy,
Note: See TracChangeset
for help on using the changeset viewer.