Changeset 624 for trunk/kernel/kern
- Timestamp:
- Mar 12, 2019, 1:37:38 PM (6 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/kernel_init.c
r623 r624 97 97 process_t process_zero CONFIG_CACHE_LINE_ALIGNED; 98 98 99 // This variable defines extended pointers on the distributed chdevs99 // This variable defines a set of extended pointers on the distributed chdevs 100 100 __attribute__((section(".kdata"))) 101 101 chdev_directory_t chdev_dir CONFIG_CACHE_LINE_ALIGNED; … … 125 125 vfs_ctx_t fs_context[FS_TYPES_NR] CONFIG_CACHE_LINE_ALIGNED; 126 126 127 // kernel_init is the entry point defined in hal/tsar_mips32/kernel.ld128 // It is used by the bootloader to tranfer control to kernel.129 extern void kernel_init( boot_info_t * info );130 131 127 // This array is used for debug, and describes the kernel locks usage, 132 128 // It must be kept consistent with the defines in kernel_config.h file. 129 __attribute__((section(".kdata"))) 133 130 char * lock_type_str[] = 134 131 { … … 229 226 230 227 // intrumentation variables : cumulated costs per syscall type in cluster 228 229 #if CONFIG_INSTRUMENTATION_SYSCALLS 230 __attribute__((section(".kdata"))) 231 231 uint32_t syscalls_cumul_cost[SYSCALLS_NR]; 232 232 233 // intrumentation variables : number of syscalls per syscal type in cluster 233 __attribute__((section(".kdata"))) 234 234 uint32_t syscalls_occurences[SYSCALLS_NR]; 235 #endif 235 236 236 237 /////////////////////////////////////////////////////////////////////////////////////////// … … 978 979 #if DEBUG_KERNEL_INIT 979 980 if( (core_lid == 0) & (local_cxy == 0) ) 980 printk("\n[%s] :exit barrier 1 : TXT0 initialized / cycle %d\n",981 printk("\n[%s] exit barrier 1 : TXT0 initialized / cycle %d\n", 981 982 __FUNCTION__, (uint32_t)hal_get_cycles() ); 982 983 #endif … … 1011 1012 #if DEBUG_KERNEL_INIT 1012 1013 if( (core_lid == 0) & (local_cxy == 0) ) 1013 printk("\n[%s] :exit barrier 2 : cluster manager initialized / cycle %d\n",1014 printk("\n[%s] exit barrier 2 : cluster manager initialized / cycle %d\n", 1014 1015 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1015 1016 #endif 1016 1017 1017 1018 ///////////////////////////////////////////////////////////////////////////////// 1018 // STEP 3 : core[0] initializes the process_zero descriptor, 1019 // STEP 3 : all cores initialize the idle thread descriptor. 1020 // core[0] initializes the process_zero descriptor, 1019 1021 // including the kernel VMM (both GPT and VSL) 1020 1022 ///////////////////////////////////////////////////////////////////////////////// … … 1024 1026 core = &cluster->core_tbl[core_lid]; 1025 1027 1028 // all cores update the register(s) defining the kernel 1029 // entry points for interrupts, exceptions and syscalls, 1030 // this must be done before VFS initialisation, because 1031 // kernel_init() uses RPCs requiring IPIs... 1032 hal_set_kentry(); 1033 1034 // all cores initialize the idle thread descriptor 1035 thread_idle_init( thread, 1036 THREAD_IDLE, 1037 &thread_idle_func, 1038 NULL, 1039 core_lid ); 1040 1026 1041 // core[0] initializes the process_zero descriptor, 1027 1042 if( core_lid == 0 ) process_zero_create( &process_zero , info ); … … 1035 1050 #if DEBUG_KERNEL_INIT 1036 1051 if( (core_lid == 0) & (local_cxy == 0) ) 1037 printk("\n[%s] :exit barrier 3 : kernel processs initialized / cycle %d\n",1052 printk("\n[%s] exit barrier 3 : kernel processs initialized / cycle %d\n", 1038 1053 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1039 1054 #endif … … 1058 1073 #if DEBUG_KERNEL_INIT 1059 1074 if( (core_lid == 0) & (local_cxy == 0) ) 1060 printk("\n[%s] :exit barrier 4 : MMU and IOPIC initialized / cycle %d\n",1075 printk("\n[%s] exit barrier 4 : MMU and IOPIC initialized / cycle %d\n", 1061 1076 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1062 1077 #endif … … 1091 1106 #if DEBUG_KERNEL_INIT 1092 1107 if( (core_lid == 0) & (local_cxy == 0) ) 1093 printk("\n[%s] : exit barrier 5 : allchdevs initialised / cycle %d\n",1108 printk("\n[%s] exit barrier 5 : chdevs initialised / cycle %d\n", 1094 1109 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1095 1110 #endif … … 1101 1116 1102 1117 ///////////////////////////////////////////////////////////////////////////////// 1103 // STEP 6 : All cores enable IPI (Inter Procesor Interrupt),1104 // Alh cores initialize IDLE thread.1105 // Onlycore[0] in cluster[0] creates the VFS root inode.1118 // STEP 6 : all cores enable IPI (Inter Procesor Interrupt), 1119 // all cores unblock the idle thread, and register it in scheduler. 1120 // core[0] in cluster[0] creates the VFS root inode. 1106 1121 // It access the boot device to initialize the file system context. 1107 1122 ///////////////////////////////////////////////////////////////////////////////// … … 1111 1126 hal_enable_irq( &status ); 1112 1127 1113 // all cores initialize the idle thread descriptor 1114 thread_idle_init( thread, 1115 THREAD_IDLE, 1116 &thread_idle_func, 1117 NULL, 1118 core_lid ); 1119 1120 // all cores unblock idle thread, and register it in scheduler 1128 // all cores unblock the idle thread, and register it in scheduler 1121 1129 thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_GLOBAL ); 1122 1130 core->scheduler.idle = thread; … … 1171 1179 cxy_t vfs_root_cxy = GET_CXY( vfs_root_inode_xp ); 1172 1180 vfs_inode_t * vfs_root_ptr = GET_PTR( vfs_root_inode_xp ); 1173 hal_remote_s32( XPTR( vfs_root_cxy , &vfs_root_ptr-> extend), INODE_TYPE_DIR );1181 hal_remote_s32( XPTR( vfs_root_cxy , &vfs_root_ptr->type ), INODE_TYPE_DIR ); 1174 1182 hal_remote_spt( XPTR( vfs_root_cxy , &vfs_root_ptr->extend ), 1175 1183 (void*)(intptr_t)root_dir_cluster ); … … 1208 1216 #if DEBUG_KERNEL_INIT 1209 1217 if( (core_lid == 0) & (local_cxy == 0) ) 1210 printk("\n[%s] :exit barrier 6 : VFS root (%x,%x) in cluster 0 / cycle %d\n",1218 printk("\n[%s] exit barrier 6 : VFS root (%x,%x) in cluster 0 / cycle %d\n", 1211 1219 __FUNCTION__, GET_CXY(process_zero.vfs_root_xp), 1212 1220 GET_PTR(process_zero.vfs_root_xp), (uint32_t)hal_get_cycles() ); … … 1278 1286 #if DEBUG_KERNEL_INIT 1279 1287 if( (core_lid == 0) & (local_cxy == 1) ) 1280 printk("\n[%s] :exit barrier 7 : VFS root (%x,%x) in cluster 1 / cycle %d\n",1288 printk("\n[%s] exit barrier 7 : VFS root (%x,%x) in cluster 1 / cycle %d\n", 1281 1289 __FUNCTION__, GET_CXY(process_zero.vfs_root_xp), 1282 1290 GET_PTR(process_zero.vfs_root_xp), (uint32_t)hal_get_cycles() ); … … 1328 1336 #if DEBUG_KERNEL_INIT 1329 1337 if( (core_lid == 0) & (local_cxy == 0) ) 1330 printk("\n[%s] :exit barrier 8 : DEVFS root initialized in cluster 0 / cycle %d\n",1338 printk("\n[%s] exit barrier 8 : DEVFS root initialized in cluster 0 / cycle %d\n", 1331 1339 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1332 1340 #endif 1333 1341 1334 1342 ///////////////////////////////////////////////////////////////////////////////// 1335 // STEP 9 : All core[0]s complete in parallel theDEVFS initialization.1343 // STEP 9 : In all clusters in parallel, core[0] completes DEVFS initialization. 1336 1344 // Each core[0] get the "dev" and "external" extended pointers from 1337 // values stored in cluster 0. 1338 // Then each core[0] in cluster(i) creates the DEVFS "internal" directory, 1339 // and creates the pseudo-files for all chdevs in cluster (i). 1345 // values stored in cluster(0), creates the DEVFS "internal" directory, 1346 // and creates the pseudo-files for all chdevs in local cluster. 1340 1347 ///////////////////////////////////////////////////////////////////////////////// 1341 1348 … … 1365 1372 #if DEBUG_KERNEL_INIT 1366 1373 if( (core_lid == 0) & (local_cxy == 0) ) 1367 printk("\n[%s] :exit barrier 9 : DEVFS initialized in cluster 0 / cycle %d\n",1374 printk("\n[%s] exit barrier 9 : DEVFS initialized in cluster 0 / cycle %d\n", 1368 1375 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1369 1376 #endif … … 1384 1391 process_init_create(); 1385 1392 } 1393 1394 #if DEBUG_KERNEL_INIT 1395 if( (core_lid == 0) & (local_cxy == 0) ) 1396 printk("\n[%s] exit barrier 10 : process_init created in cluster 0 / cycle %d\n", 1397 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1398 #endif 1386 1399 1387 1400 #if (DEBUG_KERNEL_INIT & 1) … … 1444 1457 #endif 1445 1458 1446 // each core updates the register(s) definig the kernel1447 // entry points for interrupts, exceptions and syscalls...1448 hal_set_kentry();1449 1450 1459 // each core activates its private TICK IRQ 1451 1460 dev_pic_enable_timer( CONFIG_SCHED_TICK_MS_PERIOD ); -
trunk/kernel/kern/process.c
r623 r624 1209 1209 1210 1210 // check th_nr value 1211 assert( (count > 0) , "process th_nr cannot be 0 \n" );1211 assert( (count > 0) , "process th_nr cannot be 0" ); 1212 1212 1213 1213 // remove thread from th_tbl[] … … 1249 1249 // check parent process is the reference process 1250 1250 assert( (parent_process_xp == ref_xp ) , 1251 "parent process must be the reference process \n" );1251 "parent process must be the reference process" ); 1252 1252 1253 1253 #if DEBUG_PROCESS_MAKE_FORK … … 1352 1352 // check main thread LTID 1353 1353 assert( (LTID_FROM_TRDID(thread->trdid) == 0) , 1354 "main thread must have LTID == 0 \n" );1354 "main thread must have LTID == 0" ); 1355 1355 1356 1356 #if( DEBUG_PROCESS_MAKE_FORK & 1 ) … … 1552 1552 #endif 1553 1553 1554 // get pointer on VMM 1555 vmm_t * vmm = &process->vmm; 1556 1554 1557 // get PID from local cluster manager for this kernel process 1555 1558 error = cluster_pid_alloc( process , &pid ); … … 1571 1574 process->term_state = 0; 1572 1575 1573 // initialise kernel GPT and VSL, depending on architecture 1574 hal_vmm_kernel_init( info ); 1576 // initilise VSL as empty 1577 vmm->vsegs_nr = 0; 1578 xlist_root_init( XPTR( local_cxy , &vmm->vsegs_root ) ); 1579 remote_rwlock_init( XPTR( local_cxy , &vmm->vsegs_lock ) , LOCK_VMM_VSL ); 1580 1581 // initialise GPT as empty 1582 error = hal_gpt_create( &vmm->gpt ); 1583 1584 if( error ) 1585 { 1586 printk("\n[PANIC] in %s : cannot create empty GPT\n", __FUNCTION__ ); 1587 hal_core_sleep(); 1588 } 1589 1590 // initialize GPT lock 1591 remote_rwlock_init( XPTR( local_cxy , &vmm->gpt_lock ) , LOCK_VMM_GPT ); 1592 1593 // create kernel vsegs in GPT and VSL, as required by the hardware architecture 1594 error = hal_vmm_kernel_init( info ); 1595 1596 if( error ) 1597 { 1598 printk("\n[PANIC] in %s : cannot create kernel vsegs in VMM\n", __FUNCTION__ ); 1599 hal_core_sleep(); 1600 } 1575 1601 1576 1602 // reset th_tbl[] array and associated fields … … 1629 1655 // check memory allocator 1630 1656 assert( (process != NULL), 1631 "no memory for process descriptor in cluster %x \n", local_cxy );1657 "no memory for process descriptor in cluster %x", local_cxy ); 1632 1658 1633 1659 // set the CWD and VFS_ROOT fields in process descriptor … … 1640 1666 // check PID allocator 1641 1667 assert( (error == 0), 1642 "cannot allocate PID in cluster %x \n", local_cxy );1668 "cannot allocate PID in cluster %x", local_cxy ); 1643 1669 1644 1670 // check PID value 1645 1671 assert( (pid == 1) , 1646 "process INIT must be first process in cluster 0 \n" );1672 "process INIT must be first process in cluster 0" ); 1647 1673 1648 1674 // initialize process descriptor / parent is local process_zero … … 1669 1695 1670 1696 assert( (error == 0), 1671 "failed to open file <%s> \n", CONFIG_PROCESS_INIT_PATH );1697 "failed to open file <%s>", CONFIG_PROCESS_INIT_PATH ); 1672 1698 1673 1699 #if(DEBUG_PROCESS_INIT_CREATE & 1) … … 1682 1708 1683 1709 assert( (error == 0), 1684 "cannot access .elf file <%s> \n", CONFIG_PROCESS_INIT_PATH );1710 "cannot access .elf file <%s>", CONFIG_PROCESS_INIT_PATH ); 1685 1711 1686 1712 #if(DEBUG_PROCESS_INIT_CREATE & 1) … … 1726 1752 1727 1753 assert( (error == 0), 1728 "cannot create main thread for <%s> \n", CONFIG_PROCESS_INIT_PATH );1754 "cannot create main thread for <%s>", CONFIG_PROCESS_INIT_PATH ); 1729 1755 1730 1756 assert( (thread->trdid == 0), 1731 "main thread must have index 0 for <%s> \n", CONFIG_PROCESS_INIT_PATH );1757 "main thread must have index 0 for <%s>", CONFIG_PROCESS_INIT_PATH ); 1732 1758 1733 1759 #if(DEBUG_PROCESS_INIT_CREATE & 1) … … 1816 1842 1817 1843 assert( (txt_file_xp != XPTR_NULL) , 1818 "process must be attached to one TXT terminal \n" );1844 "process must be attached to one TXT terminal" ); 1819 1845 1820 1846 // get TXT_RX chdev pointers … … 2012 2038 // check owner cluster 2013 2039 assert( (process_cxy == CXY_FROM_PID( process_pid )) , 2014 "process descriptor not in owner cluster \n" );2040 "process descriptor not in owner cluster" ); 2015 2041 2016 2042 // get extended pointer on stdin pseudo file … … 2067 2093 // check owner cluster 2068 2094 assert( (process_cxy == CXY_FROM_PID( process_pid )) , 2069 "process descriptor not in owner cluster \n" );2095 "process descriptor not in owner cluster" ); 2070 2096 2071 2097 // get extended pointer on stdin pseudo file … … 2198 2224 pid_t process_pid = hal_remote_l32( XPTR( process_cxy , &process_ptr->pid ) ); 2199 2225 assert( (process_cxy == CXY_FROM_PID( process_pid )) , 2200 "process descriptor not in owner cluster \n" );2226 "process descriptor not in owner cluster" ); 2201 2227 2202 2228 // get extended pointer on stdin pseudo file -
trunk/kernel/kern/rpc.c
r623 r624 81 81 &rpc_vmm_create_vseg_server, // 27 82 82 &rpc_vmm_set_cow_server, // 28 83 &rpc_ vmm_display_server, // 2983 &rpc_hal_vmm_display_server, // 29 84 84 }; 85 85 … … 2729 2729 2730 2730 ///////////////////////////////////////////// 2731 void rpc_ vmm_display_client( cxy_t cxy,2731 void rpc_hal_vmm_display_client( cxy_t cxy, 2732 2732 process_t * process, 2733 2733 bool_t detailed ) … … 2765 2765 2766 2766 //////////////////////////////////////// 2767 void rpc_ vmm_display_server( xptr_t xp )2767 void rpc_hal_vmm_display_server( xptr_t xp ) 2768 2768 { 2769 2769 #if DEBUG_RPC_VMM_DISPLAY … … 2787 2787 2788 2788 // call local kernel function 2789 vmm_display( process , detailed );2789 hal_vmm_display( process , detailed ); 2790 2790 2791 2791 #if DEBUG_RPC_VMM_DISPLAY -
trunk/kernel/kern/rpc.h
r623 r624 683 683 * @ detailed : [in] detailed display if true. 684 684 **********************************************************************************/ 685 void rpc_ vmm_display_client( cxy_t cxy,685 void rpc_hal_vmm_display_client( cxy_t cxy, 686 686 struct process_s * process, 687 687 bool_t detailed ); 688 688 689 void rpc_ vmm_display_server( xptr_t xp );689 void rpc_hal_vmm_display_server( xptr_t xp ); 690 690 691 691 -
trunk/kernel/kern/scheduler.c
r619 r624 488 488 489 489 #if (DEBUG_SCHED_YIELD & 0x1) 490 if( sched->trace ) 490 // if( sched->trace ) 491 if( (uint32_t)hal_get_cycles() > DEBUG_SCHED_YIELD ) 491 492 sched_display( lid ); 492 493 #endif … … 541 542 542 543 #if DEBUG_SCHED_YIELD 543 if( sched->trace ) 544 // if( sched->trace ) 545 if( (uint32_t)hal_get_cycles() > DEBUG_SCHED_YIELD ) 544 546 printk("\n[%s] core[%x,%d] / cause = %s\n" 545 547 " thread %x (%s) (%x,%x) => thread %x (%s) (%x,%x) / cycle %d\n", … … 558 560 559 561 #if (DEBUG_SCHED_YIELD & 1) 560 if( sched->trace ) 562 // if( sched->trace ) 563 if(uint32_t)hal_get_cycles() > DEBUG_SCHED_YIELD ) 561 564 printk("\n[%s] core[%x,%d] / cause = %s\n" 562 565 " thread %x (%s) (%x,%x) continue / cycle %d\n", … … 601 604 602 605 nolock_printk("\n***** threads on core[%x,%d] / current %x / rpc_threads %d / cycle %d\n", 603 local_cxy , core->lid, sched->current, LOCAL_CLUSTER->rpc_threads[lid],606 local_cxy , lid, sched->current, LOCAL_CLUSTER->rpc_threads[lid], 604 607 (uint32_t)hal_get_cycles() ); 605 608 -
trunk/kernel/kern/thread.c
r623 r624 389 389 printk("\n[%s] CPU & FPU contexts created\n", 390 390 __FUNCTION__, thread->trdid ); 391 vmm_display( process , true );391 hal_vmm_display( process , true ); 392 392 #endif 393 393 … … 689 689 printk("\n[%s] thread[%x,%x] set CPU context & jump to user code / cycle %d\n", 690 690 __FUNCTION__, process->pid, thread->trdid, cycle ); 691 vmm_display( process , true );691 hal_vmm_display( process , true ); 692 692 #endif 693 693 … … 1352 1352 "hold %d busylock(s) / cycle %d\n", 1353 1353 func_str, thread->process->pid, thread->trdid, 1354 thread->busylocks , (uint32_t)hal_get_cycles() );1354 thread->busylocks - 1, (uint32_t)hal_get_cycles() ); 1355 1355 1356 1356 #if DEBUG_BUSYLOCK
Note: See TracChangeset
for help on using the changeset viewer.