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/process.c

    r623 r624  
    12091209
    12101210// check th_nr value
    1211 assert( (count > 0) , "process th_nr cannot be 0\n" );
     1211assert( (count > 0) , "process th_nr cannot be 0" );
    12121212
    12131213    // remove thread from th_tbl[]
     
    12491249// check parent process is the reference process
    12501250assert( (parent_process_xp == ref_xp ) ,
    1251 "parent process must be the reference process\n" );
     1251"parent process must be the reference process" );
    12521252
    12531253#if DEBUG_PROCESS_MAKE_FORK
     
    13521352// check main thread LTID
    13531353assert( (LTID_FROM_TRDID(thread->trdid) == 0) ,
    1354 "main thread must have LTID == 0\n" );
     1354"main thread must have LTID == 0" );
    13551355
    13561356#if( DEBUG_PROCESS_MAKE_FORK & 1 )
     
    15521552#endif
    15531553
     1554    // get pointer on VMM
     1555    vmm_t * vmm = &process->vmm;
     1556
    15541557    // get PID from local cluster manager for this kernel process
    15551558    error = cluster_pid_alloc( process , &pid );
     
    15711574    process->term_state = 0;
    15721575
    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    }
    15751601
    15761602    // reset th_tbl[] array and associated fields
     
    16291655// check memory allocator
    16301656assert( (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  );
    16321658
    16331659    // set the CWD and VFS_ROOT fields in process descriptor
     
    16401666// check PID allocator
    16411667assert( (error == 0),
    1642 "cannot allocate PID in cluster %x\n", local_cxy );
     1668"cannot allocate PID in cluster %x", local_cxy );
    16431669
    16441670// check PID value
    16451671assert( (pid == 1) ,
    1646 "process INIT must be first process in cluster 0\n" );
     1672"process INIT must be first process in cluster 0" );
    16471673
    16481674    // initialize process descriptor / parent is local process_zero
     
    16691695
    16701696assert( (error == 0),
    1671 "failed to open file <%s>\n", CONFIG_PROCESS_INIT_PATH );
     1697"failed to open file <%s>", CONFIG_PROCESS_INIT_PATH );
    16721698
    16731699#if(DEBUG_PROCESS_INIT_CREATE & 1)
     
    16821708
    16831709assert( (error == 0),
    1684 "cannot access .elf file <%s>\n", CONFIG_PROCESS_INIT_PATH );
     1710"cannot access .elf file <%s>", CONFIG_PROCESS_INIT_PATH );
    16851711
    16861712#if(DEBUG_PROCESS_INIT_CREATE & 1)
     
    17261752
    17271753assert( (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 );
    17291755
    17301756assert( (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 );
    17321758
    17331759#if(DEBUG_PROCESS_INIT_CREATE & 1)
     
    18161842
    18171843        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" );
    18191845
    18201846        // get TXT_RX chdev pointers
     
    20122038    // check owner cluster
    20132039    assert( (process_cxy == CXY_FROM_PID( process_pid )) ,
    2014     "process descriptor not in owner cluster\n" );
     2040    "process descriptor not in owner cluster" );
    20152041
    20162042    // get extended pointer on stdin pseudo file
     
    20672093    // check owner cluster
    20682094    assert( (process_cxy == CXY_FROM_PID( process_pid )) ,
    2069     "process descriptor not in owner cluster\n" );
     2095    "process descriptor not in owner cluster" );
    20702096
    20712097    // get extended pointer on stdin pseudo file
     
    21982224pid_t process_pid = hal_remote_l32( XPTR( process_cxy , &process_ptr->pid ) );
    21992225assert( (process_cxy == CXY_FROM_PID( process_pid )) ,
    2200 "process descriptor not in owner cluster\n" );
     2226"process descriptor not in owner cluster" );
    22012227
    22022228    // get extended pointer on stdin pseudo file
Note: See TracChangeset for help on using the changeset viewer.