Ignore:
Timestamp:
Mar 12, 2019, 1:37:38 PM (5 years ago)
Author:
alain
Message:

Fix several bugs to use the instruction MMU in kernel mode
in replacement of the instruction address extension register,
and remove the "kentry" segment.

This version is running on the tsar_generic_iob" platform.

One interesting bug: the cp0_ebase defining the kernel entry point
(for interrupts, exceptions and syscalls) must be initialized
early in kernel_init(), because the VFS initialisation done by
kernel_ini() uses RPCs, and RPCs uses Inter-Processor-Interrup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/kernel_init.c

    r623 r624  
    9797process_t            process_zero                            CONFIG_CACHE_LINE_ALIGNED;
    9898
    99 // This variable defines extended pointers on the distributed chdevs
     99// This variable defines a set of extended pointers on the distributed chdevs
    100100__attribute__((section(".kdata")))
    101101chdev_directory_t    chdev_dir                               CONFIG_CACHE_LINE_ALIGNED;
     
    125125vfs_ctx_t            fs_context[FS_TYPES_NR]                 CONFIG_CACHE_LINE_ALIGNED;
    126126
    127 // kernel_init is the entry point defined in hal/tsar_mips32/kernel.ld
    128 // It is used by the bootloader to tranfer control to kernel.
    129 extern void kernel_init( boot_info_t * info );
    130 
    131127// This array is used for debug, and describes the kernel locks usage,
    132128// It must be kept consistent with the defines in kernel_config.h file.
     129__attribute__((section(".kdata")))
    133130char * lock_type_str[] =
    134131{
     
    229226
    230227// intrumentation variables : cumulated costs per syscall type in cluster
     228
     229#if CONFIG_INSTRUMENTATION_SYSCALLS
     230__attribute__((section(".kdata")))
    231231uint32_t   syscalls_cumul_cost[SYSCALLS_NR];
    232232
    233 // intrumentation variables : number of syscalls per syscal type in cluster
     233__attribute__((section(".kdata")))
    234234uint32_t   syscalls_occurences[SYSCALLS_NR];
     235#endif
    235236
    236237///////////////////////////////////////////////////////////////////////////////////////////
     
    978979#if DEBUG_KERNEL_INIT
    979980if( (core_lid ==  0) & (local_cxy == 0) )
    980 printk("\n[%s] : exit barrier 1 : TXT0 initialized / cycle %d\n",
     981printk("\n[%s] exit barrier 1 : TXT0 initialized / cycle %d\n",
    981982__FUNCTION__, (uint32_t)hal_get_cycles() );
    982983#endif
     
    10111012#if DEBUG_KERNEL_INIT
    10121013if( (core_lid ==  0) & (local_cxy == 0) )
    1013 printk("\n[%s] : exit barrier 2 : cluster manager initialized / cycle %d\n",
     1014printk("\n[%s] exit barrier 2 : cluster manager initialized / cycle %d\n",
    10141015__FUNCTION__, (uint32_t)hal_get_cycles() );
    10151016#endif
    10161017
    10171018    /////////////////////////////////////////////////////////////////////////////////
    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,
    10191021    //          including the kernel VMM (both GPT and VSL)
    10201022    /////////////////////////////////////////////////////////////////////////////////
     
    10241026    core    = &cluster->core_tbl[core_lid];
    10251027
     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
    10261041    // core[0] initializes the process_zero descriptor,
    10271042    if( core_lid == 0 ) process_zero_create( &process_zero , info );
     
    10351050#if DEBUG_KERNEL_INIT
    10361051if( (core_lid ==  0) & (local_cxy == 0) )
    1037 printk("\n[%s] : exit barrier 3 : kernel processs initialized / cycle %d\n",
     1052printk("\n[%s] exit barrier 3 : kernel processs initialized / cycle %d\n",
    10381053__FUNCTION__, (uint32_t)hal_get_cycles() );
    10391054#endif
     
    10581073#if DEBUG_KERNEL_INIT
    10591074if( (core_lid ==  0) & (local_cxy == 0) )
    1060 printk("\n[%s] : exit barrier 4 : MMU and IOPIC initialized / cycle %d\n",
     1075printk("\n[%s] exit barrier 4 : MMU and IOPIC initialized / cycle %d\n",
    10611076__FUNCTION__, (uint32_t)hal_get_cycles() );
    10621077#endif
     
    10911106#if DEBUG_KERNEL_INIT
    10921107if( (core_lid ==  0) & (local_cxy == 0) )
    1093 printk("\n[%s] : exit barrier 5 : all chdevs initialised / cycle %d\n",
     1108printk("\n[%s] exit barrier 5 : chdevs initialised / cycle %d\n",
    10941109__FUNCTION__, (uint32_t)hal_get_cycles() );
    10951110#endif
     
    11011116   
    11021117    /////////////////////////////////////////////////////////////////////////////////
    1103     // STEP 6 : All cores enable IPI (Inter Procesor Interrupt),
    1104     //          Alh cores initialize IDLE thread.
    1105     //          Only core[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.
    11061121    //          It access the boot device to initialize the file system context.
    11071122    /////////////////////////////////////////////////////////////////////////////////
     
    11111126    hal_enable_irq( &status );
    11121127
    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
    11211129    thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_GLOBAL );
    11221130    core->scheduler.idle = thread;
     
    11711179            cxy_t         vfs_root_cxy = GET_CXY( vfs_root_inode_xp );
    11721180            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 );
    11741182            hal_remote_spt( XPTR( vfs_root_cxy , &vfs_root_ptr->extend ),
    11751183                            (void*)(intptr_t)root_dir_cluster );
     
    12081216#if DEBUG_KERNEL_INIT
    12091217if( (core_lid ==  0) & (local_cxy == 0) )
    1210 printk("\n[%s] : exit barrier 6 : VFS root (%x,%x) in cluster 0 / cycle %d\n",
     1218printk("\n[%s] exit barrier 6 : VFS root (%x,%x) in cluster 0 / cycle %d\n",
    12111219__FUNCTION__, GET_CXY(process_zero.vfs_root_xp),
    12121220GET_PTR(process_zero.vfs_root_xp), (uint32_t)hal_get_cycles() );
     
    12781286#if DEBUG_KERNEL_INIT
    12791287if( (core_lid ==  0) & (local_cxy == 1) )
    1280 printk("\n[%s] : exit barrier 7 : VFS root (%x,%x) in cluster 1 / cycle %d\n",
     1288printk("\n[%s] exit barrier 7 : VFS root (%x,%x) in cluster 1 / cycle %d\n",
    12811289__FUNCTION__, GET_CXY(process_zero.vfs_root_xp),
    12821290GET_PTR(process_zero.vfs_root_xp), (uint32_t)hal_get_cycles() );
     
    13281336#if DEBUG_KERNEL_INIT
    13291337if( (core_lid ==  0) & (local_cxy == 0) )
    1330 printk("\n[%s] : exit barrier 8 : DEVFS root initialized in cluster 0 / cycle %d\n",
     1338printk("\n[%s] exit barrier 8 : DEVFS root initialized in cluster 0 / cycle %d\n",
    13311339__FUNCTION__, (uint32_t)hal_get_cycles() );
    13321340#endif
    13331341
    13341342    /////////////////////////////////////////////////////////////////////////////////
    1335     // STEP 9 : All core[0]s complete in parallel the DEVFS initialization.
     1343    // STEP 9 : In all clusters in parallel, core[0] completes DEVFS initialization.
    13361344    //          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.
    13401347    /////////////////////////////////////////////////////////////////////////////////
    13411348
     
    13651372#if DEBUG_KERNEL_INIT
    13661373if( (core_lid ==  0) & (local_cxy == 0) )
    1367 printk("\n[%s] : exit barrier 9 : DEVFS initialized in cluster 0 / cycle %d\n",
     1374printk("\n[%s] exit barrier 9 : DEVFS initialized in cluster 0 / cycle %d\n",
    13681375__FUNCTION__, (uint32_t)hal_get_cycles() );
    13691376#endif
     
    13841391       process_init_create();
    13851392    }
     1393
     1394#if DEBUG_KERNEL_INIT
     1395if( (core_lid ==  0) & (local_cxy == 0) )
     1396printk("\n[%s] exit barrier 10 : process_init created in cluster 0 / cycle %d\n",
     1397__FUNCTION__, (uint32_t)hal_get_cycles() );
     1398#endif
    13861399
    13871400#if (DEBUG_KERNEL_INIT & 1)
     
    14441457#endif
    14451458
    1446     // each core updates the register(s) definig the kernel
    1447     // entry points for interrupts, exceptions and syscalls...
    1448     hal_set_kentry();
    1449 
    14501459    // each core activates its private TICK IRQ
    14511460    dev_pic_enable_timer( CONFIG_SCHED_TICK_MS_PERIOD );
Note: See TracChangeset for help on using the changeset viewer.