Changeset 101 for trunk/kernel


Ignore:
Timestamp:
Jun 29, 2017, 4:44:52 PM (5 years ago)
Author:
alain
Message:

euh...

Location:
trunk/kernel
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/devices/dev_ioc.c

    r68 r101  
    126126             " for lba = %x / buffer = %x / at cycle %d\n",
    127127             __FUNCTION__ , this->trdid , this->process->pid ,
    128              lba , (intptr_t)buffer , hal_time_stamp() );
     128             lba , (intptr_t)buffer , hal_get_cycles() );
    129129
    130130    // software L2/L3 cache coherence for memory buffer
     
    155155             " completes / error = %d / at cycle %d\n",
    156156             __FUNCTION__ , this->trdid , this->process->pid ,
    157              this->command.ioc.error , hal_time_stamp() );
     157             this->command.ioc.error , hal_get_cycles() );
    158158
    159159    // return I/O operation status
  • trunk/kernel/devices/dev_txt.c

    r77 r101  
    3030#include <printk.h>
    3131#include <dev_txt.h>
     32#include <soclib_tty.h>
    3233
    3334/////////////////////////////////////////////////////////////////////////////////////////
     
    5758    if( impl == IMPL_TXT_TTY )
    5859    {
    59         hal_drivers_txt_init( chdev );
     60        chdev->cmd = &soclib_tty_cmd;
     61        chdev->isr = &soclib_tty_isr;
     62        soclib_tty_init( chdev );
    6063    }
    6164    else
  • trunk/kernel/kern/cluster.c

    r50 r101  
    103103
    104104    cluster_dmsg("\n[INFO] %s : PPM initialized in cluster %x at cycle %d\n",
    105                  __FUNCTION__ , local_cxy , hal_time_stamp() );
     105                 __FUNCTION__ , local_cxy , hal_get_cycles() );
    106106
    107107    // initialises embedded KHM
     
    109109
    110110    cluster_dmsg("\n[INFO] %s : KHM initialized in cluster %x at cycle %d\n",
    111                  __FUNCTION__ , local_cxy , hal_time_stamp() );
     111                 __FUNCTION__ , local_cxy , hal_get_cycles() );
    112112
    113113    // initialises embedded KCM
     
    115115
    116116    cluster_dmsg("\n[INFO] %s : KCM initialized in cluster %x at cycle %d\n",
    117                  __FUNCTION__ , local_cxy , hal_time_stamp() );
     117                 __FUNCTION__ , local_cxy , hal_get_cycles() );
    118118
    119119    // initialises all cores descriptors
     
    126126
    127127    cluster_dmsg("\n[INFO] %s : cores initialized in cluster %x at cycle %d\n",
    128                  __FUNCTION__ , local_cxy , hal_time_stamp() );
     128                 __FUNCTION__ , local_cxy , hal_get_cycles() );
    129129
    130130    // initialises RPC fifo
     
    132132
    133133    cluster_dmsg("\n[INFO] %s : RPC fifo inialized in cluster %x at cycle %d\n",
    134                  __FUNCTION__ , local_cxy , hal_time_stamp() );
     134                 __FUNCTION__ , local_cxy , hal_get_cycles() );
    135135
    136136    // initialise pref_tbl[] in process manager
     
    149149
    150150    // initialise copies_lists in process manager
    151     for( lpid = 1 ; lpid < CONFIG_MAX_PROCESS_PER_CLUSTER ; lpid++ )
     151    for( lpid = 0 ; lpid < CONFIG_MAX_PROCESS_PER_CLUSTER ; lpid++ )
    152152    {
    153153            remote_spinlock_init( XPTR( local_cxy , &cluster->pmgr.copies_lock[lpid] ) );
     
    157157
    158158    cluster_dmsg("\n[INFO] %s Process Manager initialized in cluster %x at cycle %d\n",
    159                  __FUNCTION__ , local_cxy , hal_time_stamp() );
     159                 __FUNCTION__ , local_cxy , hal_get_cycles() );
    160160
    161161    hal_wbflush();
  • trunk/kernel/kern/cluster.h

    r50 r101  
    187187/******************************************************************************************
    188188 * This function returns an extended pointer on the reference process descriptor
    189  * from the process PID. This PID can be be different from the calling thread process.
     189 * from the process PID. This PID can be be different from the calling process PID.
    190190 * It can be called by any thread running in any cluster,
    191191 ******************************************************************************************
  • trunk/kernel/kern/core.c

    r68 r101  
    5757        core->thread_idle       = NULL;
    5858        core->fpu_owner         = NULL;
    59         core->rand_last         =  hal_time_stamp() & 0xFFF;
     59        core->rand_last         =  hal_get_cycles() & 0xFFF;
    6060
    6161        sched_init( core );
     
    6666{
    6767        uint32_t value  = ((core->rand_last * CONFIG_RDNG_PARAM_A) +
    68                             CONFIG_RDNG_PARAM_C) ^ (hal_time_stamp() & 0xFFF);
     68                            CONFIG_RDNG_PARAM_C) ^ (hal_get_cycles() & 0xFFF);
    6969        core->rand_last = value;
    7070        return value;
    71 }
    72 
    73 ////////////////////////////////////////////////
    74 inline uint64_t core_get_cycles( core_t * core )
    75 {
    76         uint32_t elapsed;
    77         uint64_t cycles;
    78         uint32_t time_stamp = core->time_stamp;
    79         uint32_t time_now   = hal_time_stamp();
    80 
    81         // compute number of elapsed cycles, taking into account 32 bits register wrap
    82         if(time_now < time_stamp) elapsed = (0xFFFFFFFF - time_stamp) + time_now;
    83         else                      elapsed = (time_now - time_stamp);
    84 
    85         cycles = core->cycles + elapsed;
    86 
    87         // update core time
    88         core->time_stamp = time_now;
    89         core->cycles     = cycles;
    90         hal_wbflush();
    91 
    92         return cycles;
    9371}
    9472
     
    9876                    uint32_t * tm_us )
    9977{
    100         // uint64_t cycles = core_get_cycles( core );
     78        uint64_t cycles = hal_get_cycles();
    10179
    102         // TODO ces deux ligne ne compilent pas : "undefined referenc to __udivdi3"
    103 
    104         // *tm_ms = (cycles / CONFIG_CYCLES_PER_MS);
    105         // *tm_us = (cycles % CONFIG_CYCLES_PER_MS) / (CONFIG_CYCLES_PER_MS / 1000000);
    106 
    107         printk("\n[PANIC] in %s : not implemented yet\n", __FUNCTION__ );
     80        *tm_s  = (cycles / CONFIG_CYCLES_PER_MS);
     81        *tm_us = (cycles % CONFIG_CYCLES_PER_MS) / (CONFIG_CYCLES_PER_MS / 1000000);
    10882}
    10983
     
    11589        uint64_t cycles     = core->cycles;
    11690        uint32_t time_stamp = core->time_stamp;
    117         uint32_t time_now   = hal_time_stamp();
     91        uint32_t time_now   = hal_get_cycles();
    11892
    11993        // compute number of elapsed cycles taking into account 32 bits register wrap
  • trunk/kernel/kern/core.h

    r68 r101  
    100100
    101101/***************************************************************************************
    102  * This function returns the current date (cycles) from both
    103  * the hardware 32 bits cycles counter and the core descriptor cycles counter,
    104  * taking into account the 32 bits hardware register overflow.
    105  * The core descriptor time is updated.
    106  ***************************************************************************************
    107  * @ core       : pointer on core descriptor.
    108  * @ returns the number of cycles.
    109  **************************************************************************************/
    110 inline uint64_t core_get_cycles( core_t * core );
    111 
    112 /***************************************************************************************
    113  * This function returns the current date (seconds & micro-seconds) from both
    114  * the hardware 32 bits cycles counter and the core descriptor cycles counter,
    115  * taking into account the 32 bits hardware register overflow.
    116  * The core descriptor time is updated.
     102 * This function returns the current date (seconds & micro-seconds) from
     103 * the 64 bits calling core cycles counter.
    117104 ***************************************************************************************
    118105 * @ core      : pointer on core descriptor.
  • trunk/kernel/kern/do_exception.c

    r16 r101  
    8484        vmm         = &process->vmm;
    8585
    86         vmm_dmsg("\n[INFO] %s : enters for thread %x / process %x"
    87              " / bad_vaddr = %x / excep_code = %x\n",
    88                      __FUNCTION__, this->trdid , process->pid , bad_vaddr , excep_code );
    89 
    9086    // get relevant values from MMU
    9187        hal_get_mmu_excp( &mmu_ins_excp_code,
     
    110106    }
    111107
     108        vmm_dmsg("\n[INFO] %s : enters for thread %x / process %x"
     109             " / bad_vaddr = %x / excep_code = %x\n",
     110                     __FUNCTION__, this->trdid , process->pid , bad_vaddr , excp_code );
    112111
    113112    // a kernel thread should not rise an MMU exception
     
    179178    }
    180179
    181         vmm_dmsg("\n[INFO] %s : found vseg for thread %x / vseg_base = %x / vseg_size = %x\n",
    182                          __FUNCTION__ , this->trdid , vseg->begin , vseg->size );
     180        vmm_dmsg("\n[INFO] %s : found vseg for thread %x / vseg_min = %x / vseg_max = %x\n",
     181                         __FUNCTION__ , this->trdid , vseg->min , vseg->max );
    183182
    184183    // analyse exception code
  • trunk/kernel/kern/kernel_init.c

    r77 r101  
    5656#include <devfs.h>
    5757#include <mapper.h>
    58 
     58#include <soclib_tty.h>
    5959
    6060#define KERNEL_INIT_SYNCHRO  0xA5A5B5B5
     
    189189            remote_spinlock_init( XPTR( local_cxy , &txt0_chdev.wait_lock ) );
    190190
    191             // complete TXT-specific initialization
    192             hal_drivers_txt_init( &txt0_chdev );
     191            // TODO use generic device initialisation
     192            // hal_drivers_txt_init( &txt0_chdev );
     193
     194            if( impl == IMPL_TXT_TTY )
     195            {
     196                txt0_chdev.cmd = &soclib_tty_cmd;
     197                txt0_chdev.isr = &soclib_tty_isr;
     198                soclib_tty_init( &txt0_chdev );
     199            }
    193200
    194201            // initialize the replicated chdev_dir[x][y] structures
     
    206213                       " / paddr = %l at cycle %d\n",
    207214                       __FUNCTION__ , local_cxy , chdev_func_str( func ),
    208                        XPTR(local_cxy , &txt0_chdev) , hal_time_stamp() );
     215                       XPTR(local_cxy , &txt0_chdev) , hal_get_cycles() );
    209216        }
    210217
     
    295302
    296303    kinit_dmsg("\n[INFO] %s : core[%x][0] created ICU chdev at cycle %d\n",
    297                __FUNCTION__ , local_cxy , hal_time_stamp() );
     304               __FUNCTION__ , local_cxy , hal_get_cycles() );
    298305
    299306    /////////// MMC internal chdev /////////// 
     
    337344
    338345        kinit_dmsg("\n[INFO] %s : core[%x][0] created MMC chdev at cycle %d\n",
    339                    __FUNCTION__ , local_cxy , hal_time_stamp() );
     346                   __FUNCTION__ , local_cxy , hal_get_cycles() );
    340347    }
    341348
     
    372379
    373380            kinit_dmsg("\n[INFO] %s : core[%x][0] created DMA[%d] chdev at cycle %d\n",
    374                        __FUNCTION__ , local_cxy , channel , hal_time_stamp() );
     381                       __FUNCTION__ , local_cxy , channel , hal_get_cycles() );
    375382        }
    376383    }
     
    530537                            kinit_dmsg("\n[INFO] %s : core[%x][0] create chdev %s[%d] at cycle %d\n",
    531538                               __FUNCTION__ , local_cxy , chdev_func_str( func ),
    532                                channel , hal_time_stamp() );
     539                               channel , hal_get_cycles() );
    533540
    534541                }  // end if match
     
    677684
    678685    kinit_dmsg("\n[INFO] %s : core[%x][%d] exit barrier 0 at cycle %d\n",
    679                __FUNCTION__ , core_cxy , core_lid , hal_time_stamp() );
     686               __FUNCTION__ , core_cxy , core_lid , hal_get_cycles() );
    680687
    681688    // all cores check core identifiers
     
    709716
    710717    kinit_dmsg("\n[INFO] %s : core[%x][%d] exit barrier 1 at cycle %d\n",
    711                __FUNCTION__ , core_cxy , core_lid , hal_time_stamp() );
     718               __FUNCTION__ , core_cxy , core_lid , hal_get_cycles() );
    712719
    713720    // all cores get pointer on local cluster manager and on core descriptor
     
    716723
    717724    // CP0 initializes the process_zero descriptor
    718     if( core_lid == 0 ) process_zero_init( info );
     725    if( core_lid == 0 ) process_reference_init( &process_zero , 0 , XPTR_NULL );
    719726
    720727    // CP0 allocates and initialises the internal peripheral chdev descriptors.
     
    727734    // external devices initialisation to enforce the rule :
    728735    // "The WTI index for the IPI routed to core[lid] is lid"
    729     if( core_lid == 0 )
     736    if( core_lid == 1 )
    730737    {
    731738        uint32_t  wti_id;
     
    760767
    761768    kinit_dmsg("\n[INFO] %s : core[%x][%d] exit barrier 2 at cycle %d\n",
    762                __FUNCTION__ , core_cxy , core_lid , hal_time_stamp() );
     769               __FUNCTION__ , core_cxy , core_lid , hal_get_cycles() );
    763770
    764771
     
    783790
    784791        kinit_dmsg("\n[INFO] %s : core[%x][%d] created idle thread %x at cycle %d\n",
    785                    __FUNCTION__ , core_cxy , core_lid , thread , hal_time_stamp());
     792                   __FUNCTION__ , core_cxy , core_lid , thread , hal_get_cycles());
    786793    }
    787794
     
    809816        }
    810817
     818        // register VFS root inode in process_zero
     819        process_zero.vfs_root_xp = root_inode_xp;
     820        process_zero.vfs_cwd_xp  = root_inode_xp;
     821
    811822        // mount the DEVFS File system
    812823            devfs_mount( root_inode_xp , "dev" );
    813824    }
    814825
    815     // CP0 in I/O cluster print banner
     826
     827    // CP0 in I/O cluster creates the process_init and print banner
    816828    if( (core_lid ==  0) && (local_cxy == info->io_cxy) )
    817829    {
     830        process_init_create();
     831
    818832        print_banner( (info->x_size * info->y_size) , info->cores_nr );
    819833
     
    869883
    870884    kinit_dmsg("\n[INFO] %s : core[%x][%d] exit barrier 3 at cycle %d\n",
    871                __FUNCTION__ , core_cxy , core_lid , hal_time_stamp() );
     885               __FUNCTION__ , core_cxy , core_lid , hal_get_cycles() );
    872886
    873887    // each core activates its private PTI IRQ
     
    875889    dev_icu_enable_irq( core_lid , PTI_TYPE , core_lid , NULL );
    876890
    877     // each core get its private IRQ masks values and
     891    // each core get its private IRQ masks values
    878892    uint32_t hwi_mask;
    879893    uint32_t wti_mask;
     
    883897    thread_dmsg("\n[INFO] %s : core[%x][%d] activates scheduler at cycle %d\n"
    884898                "   hwi_mask = %x / wti_mask = %x / pti_mask = %x\n",
    885                     __FUNCTION__ , local_cxy , core_lid , hal_time_stamp() ,
     899                    __FUNCTION__ , local_cxy , core_lid , hal_get_cycles() ,
    886900                    hwi_mask , wti_mask , pti_mask );
    887901
  • trunk/kernel/kern/process.c

    r23 r101  
    8181}
    8282
    83 ////////////////////////////////////////////
    84 void process_zero_init( boot_info_t * info )
    85 {
    86     // reset process descriptor
    87         memset( &process_zero , 0 , sizeof(process_t) );
    88 
    89     // initialize kernel code & data vsegs base addresses
    90         process_zero.vmm.code_vpn_base = (vpn_t)(info->kernel_code_start >> CONFIG_PPM_PAGE_SHIFT);
    91         process_zero.vmm.data_vpn_base = (vpn_t)(info->kernel_data_start >> CONFIG_PPM_PAGE_SHIFT);
    92 
    93     // reset threads and childs number
    94         process_zero.th_nr       = 0;
    95         process_zero.children_nr = 0;
    96 
    97     // set PID
    98         process_zero.pid            = 0;
    99 }
    100 
    10183/////////////////////////////////////////////////
    10284void process_reference_init( process_t * process,
    10385                             pid_t       pid,
    104                              pid_t       ppid )
    105 {
    106     // reset reference process vmm
    107     vmm_init( process );
     86                             xptr_t      parent_xp )
     87{
     88    cxy_t       parent_cxy;
     89    process_t * parent_ptr;
     90    pid_t       parent_pid;
     91
     92    process_dmsg("\n[INFO] %s : enters for process %x in cluster %x / parent_xp = %l\n",
     93                 __FUNCTION__ , pid , parent_xp );
     94
     95    // get parent process cluster, local pointer, and pid
     96    // for all processes other than process_zero
     97    if( process == &process_zero )
     98    {
     99        assert( (pid == 0) , __FUNCTION__ , "process_zero must have PID = 0\n");
     100
     101        parent_pid = 0;  // process_zero is its own parent...
     102    }
     103    else
     104    {
     105        assert( (parent_xp != XPTR_NULL) , __FUNCTION__ , "parent_xp cannot be NULL\n");
     106
     107        parent_cxy = GET_CXY( parent_xp );
     108        parent_ptr = (process_t *)GET_PTR( parent_xp );
     109        parent_pid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) );
     110    }
     111
     112    // reset reference process vmm (not for kernel process)
     113    if( pid ) vmm_init( process );
    108114
    109115    // reset reference process file descriptors array
    110116        process_fd_init( process );
    111117
    112     // reset reference process files structures and cd_lock
     118    // reset reference process files structures and cwd_lock
    113119        process->vfs_root_xp     = XPTR_NULL;
    114120        process->vfs_bin_xp      = XPTR_NULL;
     
    127133    remote_spinlock_init( XPTR( local_cxy , &process->sync_lock ) );
    128134
    129     // register new process in the parent children list
    130     xptr_t entry = XPTR( local_cxy , &process->brothers_list );
    131     xptr_t root  = XPTR( local_cxy , &process->children_root );
    132     xlist_add_first( root , entry );
     135    // register new process in the parent children list (not for kernel process)
     136    if( pid )
     137    {
     138        xptr_t entry = XPTR( local_cxy  , &process->brothers_list );
     139        xptr_t root  = XPTR( parent_cxy , &parent_ptr->children_root );
     140        xlist_add_first( root , entry );
     141    }
    133142   
    134143    // reset th_tbl[] array as empty
     
    143152    // initialize PID and PPID
    144153        process->pid   = pid;
    145     process->ppid  = ppid;
     154    process->ppid  = parent_pid;
    146155
    147156    // set ref_xp field
     
    157166
    158167        hal_wbflush();
     168
     169    process_dmsg("\n[INFO] %s : exit for process %x in cluster %x\n",
     170                 __FUNCTION__ , pid );
    159171
    160172} // end process_reference_init()
     
    576588
    577589    return (found) ? 0 : ENOMEM;
    578 }
     590
     591}  // process_register_thread()
    579592   
    580593///////////////////////////////////////////////
     
    595608    process->th_tbl[ltid] = NULL;
    596609    process->th_nr--;
    597 }
     610
     611}  // process_remove_thread()
     612
    598613
    599614/////////////////////////////////////////////////////
     
    601616{
    602617    char           * path;                            // pathname to .elf file
    603     process_t      * process;                         // pointer on new process
     618    process_t      * process;                         // local pointer on new process
    604619    pid_t            pid;                             // new process pid
     620    xptr_t           parent_xp;                       // extended pointer on parent process
     621    cxy_t            parent_cxy;
     622    process_t      * parent_ptr;
     623    uint32_t         parent_pid;
    605624    thread_t       * thread;                          // pointer on new thread
    606625    pthread_attr_t   attr;                            // main thread attributes
     
    609628        error_t          error;
    610629
    611         // get pid and pathname to .elf file 
    612         path  = exec_info->path;
    613     pid   = exec_info->pid;
     630        // get parent and .elf pathname from exec_info
     631        path      = exec_info->path;
     632    parent_xp = exec_info->parent_xp;
     633
     634    // get parent process cluster and local pointer
     635    parent_cxy = GET_CXY( parent_xp );
     636    parent_ptr = (process_t *)GET_PTR( parent_xp );
     637    parent_pid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) );
    614638   
    615     assert( (CXY_FROM_PID( pid ) == local_cxy) , __FUNCTION__ , "illegal PID\n" );
    616 
    617     exec_dmsg("\n[INFO] %s enters in cluster %x for process %x / path = %s\n",
    618                 __FUNCTION__ , local_cxy , pid , path );
     639    exec_dmsg("\n[INFO] %s enters in cluster %x for path = %s\n",
     640                __FUNCTION__ , local_cxy , path );
    619641
    620642    // create new process descriptor
     
    623645    if( process == NULL )
    624646    {
    625         printk("\n[ERROR] in %s : no memory in cluster %x for process %x / path = %s\n",
    626                __FUNCTION__ , local_cxy , pid , path );
     647        printk("\n[ERROR] in %s : no memory / cluster = %x / ppid = %x / path = %s\n",
     648               __FUNCTION__ , local_cxy , parent_pid , path );
    627649        return ENOMEM;
    628650    }
    629651
     652    // get a pid from the local cluster
     653    error = cluster_pid_alloc( XPTR( local_cxy , process ) , &pid );
     654
     655    if( error )
     656    {
     657        printk("\n[ERROR] in %s : cannot get PID / cluster = %x / ppid = %x / path = %s\n",
     658               __FUNCTION__ , local_cxy , parent_pid , path );
     659                return ENOMEM;
     660    }
     661 
    630662    // initialize the process descriptor as the reference
    631     process_reference_init( process , pid , exec_info->ppid );
     663    process_reference_init( process , pid , parent_xp );
    632664                               
    633     // restore from exec_info the extended pointer on vfs root, cwd, and bin
    634     process->vfs_root_xp = exec_info->vfs_root_xp;
    635     process->vfs_cwd_xp  = exec_info->vfs_cwd_xp;
    636     process->vfs_bin_xp  = exec_info->vfs_bin_xp;
    637 
    638     // restore from exec_info the embedded fd_array
    639     process_fd_remote_copy( XPTR( local_cxy , &process->fd_array ), exec_info->fd_array_xp );
    640                            
    641     exec_dmsg("\n[INFO] %s restaured fd-array in cluster %x for process %x / path = %s\n",
    642                 __FUNCTION__, local_cxy , pid , path );
     665    exec_dmsg("\n[INFO] %s created process %x cluster %x / path = %s\n",
     666                __FUNCTION__, parent_pid , local_cxy , path );
     667
     668    // initializes vfs_root and vfs_cwd from parent process
     669    xptr_t  vfs_root_xp = hal_remote_lwd( XPTR( parent_cxy , &parent_ptr->vfs_root_xp ) );
     670        vfs_file_count_up( vfs_root_xp );
     671        process->vfs_root_xp = vfs_root_xp;
     672
     673    xptr_t  vfs_cwd_xp = hal_remote_lwd( XPTR( parent_cxy , &parent_ptr->vfs_cwd_xp ) );
     674        vfs_file_count_up( vfs_cwd_xp );
     675        process->vfs_cwd_xp = vfs_cwd_xp;
     676
     677    // initialize embedded fd_array from parent process
     678    process_fd_remote_copy( XPTR( local_cxy , &process->fd_array ),
     679                            XPTR( parent_cxy , &parent_ptr->fd_array) );
    643680
    644681        // initialize signal manager TODO ??? [AG]
     
    663700        }
    664701
    665     // create "heap" vseg descriptor
     702    // register "heap" vseg descriptor in VMM
    666703    vseg_t * heap_vseg = vmm_create_vseg( process,
    667704                                          CONFIG_VMM_HEAP_BASE,
     
    699736        }
    700737
     738    // update children list in parent process
     739        xlist_add_last( XPTR( parent_cxy , &parent_ptr->children_root ),
     740                    XPTR( local_cxy  , &process->brothers_list ) );
     741        hal_remote_atomic_add( XPTR( parent_cxy , &parent_ptr->children_nr) , 1 );
     742
    701743        // Register thread in scheduler
    702744        sched_register_thread( core , thread );
    703745
    704746        exec_dmsg("\n[INFO] %s created thread for process %x on core %d in cluster %x\n",
    705                __FUNCTION__ , process->pid , core->lid , local_cxy );
     747               __FUNCTION__ , pid , core->lid , local_cxy );
    706748
    707749    // activate new thread
     
    715757void process_init_create()
    716758{
    717         process_t   * process_init;  // process_init descriptor
    718     pid_t         init_pid;      // process_init pid
    719759    exec_info_t   exec_info;     // structure to be passed to process_make_exec()
    720760
    721         error_t error1 = 0;
    722         error_t error2 = 0;
    723         error_t error3 = 0;
    724 
    725         process_dmsg("\n[INFO] %s enters in cluster %x\n", __FUNCTION__ , local_cxy );
    726 
    727     // allocate memory for process descriptor
    728     process_init = process_alloc();
    729     if( process_init == NULL )
    730     {
    731         printk("\n[PANIC] in %s : no memory for process descriptor in cluster %x\n",
    732                __FUNCTION__ , local_cxy );
    733         hal_core_sleep();
    734     }
    735 
    736     // get a pid from the local cluster
    737     xptr_t xp_process = XPTR( local_cxy , process_init );
    738     error1 = cluster_pid_alloc( xp_process , &init_pid );
    739     if( error1 )
    740     {
    741         printk("\n[PANIC] in %s : cannot get PID in cluster %x\n",
    742                __FUNCTION__ , local_cxy );
    743                 hal_core_sleep();
    744     }
    745  
    746     // initializes process_init descriptor as the reference
    747         process_reference_init( process_init , init_pid , process_zero.pid );
    748 
    749     // initialize process_init VMM
    750         vmm_init( process_init );
    751 
    752     // initializes vfs_root and vfs_cwd from process_zero
    753         vfs_file_count_up( process_zero.vfs_root_xp );
    754         process_init->vfs_root_xp = process_zero.vfs_root_xp;
    755 
    756         vfs_file_count_up( process_zero.vfs_cwd_xp );
    757         process_init->vfs_cwd_xp  = process_zero.vfs_cwd_xp;
    758 
    759     // update children list in process_zero
    760         xlist_add_last( XPTR( local_cxy , &process_zero.children_root ),
    761                     XPTR( local_cxy , &process_init->brothers_list ) );
    762         process_zero.children_nr = 1;
    763 
    764     // TODO create inodes for stdin / stdout / stderr pseudo-files
    765     // these inodes should be created in the cluster containing the relevant TXT chdev
    766 
    767     // open stdin / stdout / stderr pseudo-files
     761        error_t   error1;
     762        error_t   error2;
     763        error_t   error3;
    768764    xptr_t    stdin_xp;
    769765    xptr_t    stdout_xp;
     
    773769    uint32_t  stderr_id;
    774770
     771        process_dmsg("\n[INFO] %s enters in cluster %x\n", __FUNCTION__ , local_cxy );
     772
     773    // open stdin / stdout / stderr pseudo-files
    775774        error1 = vfs_open( XPTR_NULL, CONFIG_DEV_STDIN , O_RDONLY, 0, &stdin_xp , &stdin_id  );
    776775        error2 = vfs_open( XPTR_NULL, CONFIG_DEV_STDOUT, O_WRONLY, 0, &stdout_xp, &stdout_id );
     
    782781                if( !error2 ) vfs_close( stdout_xp , stdout_id );
    783782                if( !error3 ) vfs_close( stderr_xp , stderr_id );
    784    
    785783                printk("\n[PANIC] in %s : cannot open stdin/stdout/stderr in cluster %x\n",
    786784               __FUNCTION__ , local_cxy );
     
    791789    if( (stdin_id != 0) || (stdout_id != 1) || (stderr_id != 2) )
    792790    {
     791                vfs_close( stdin_xp  , stdin_id );
     792                vfs_close( stdout_xp , stdout_id );
     793                vfs_close( stderr_xp , stderr_id );
    793794                printk("\n[PANIC] in %s : bad indexes for stdin/stdout/stderr in cluster %x\n",
    794795            __FUNCTION__ , local_cxy );
     
    797798
    798799    // initialize the exec_info structure
    799     exec_info.pid          = process_init->pid;
    800     exec_info.ppid         = process_init->ppid;
    801     exec_info.fd_array_xp  = XPTR( local_cxy , &process_init->fd_array );
    802     exec_info.vfs_root_xp  = process_init->vfs_root_xp;
    803     exec_info.vfs_cwd_xp   = process_init->vfs_cwd_xp;
    804     exec_info.vfs_bin_xp   = process_init->vfs_bin_xp;
    805 
    806     // TODO thread_init ???
    807     // exec_info.args_nr      = 1;
    808     // exec_info.envs_nr      = 1;
    809     // strcpy( exec_info.args[0] , "init" );
    810     // strcpy( exec_info.envs[0] , "ALMOS-MKH.CONFIG = "CONFIG_ALMOS_VERSION );
    811     // strcpy( exec_info.path    , INIT_PATHNAME );
     800    exec_info.parent_xp    = XPTR( local_cxy , &process_zero );
     801    strcpy( exec_info.path , CONFIG_PROCESS_INIT_PATH );
     802    exec_info.args_nr      = 0;
     803    exec_info.envs_nr      = 0;
    812804
    813805    // create process_init and thread_init
    814806        error1 = process_make_exec( &exec_info );
     807
    815808        if( error1 )
    816809        {
  • trunk/kernel/kern/process.h

    r23 r101  
    6565typedef struct fd_array_s
    6666{
    67         remote_spinlock_t lock;             /*! lock protecting fd_array[] change.              */
    68     uint32_t          current;          /*! current number of open files                    */
    69         xptr_t            array[CONFIG_PROCESS_FILE_MAX_NR]; 
     67        remote_spinlock_t lock;                               /*! lock protecting fd_array      */
     68    uint32_t          current;                            /*! current number of open files  */
     69        xptr_t            array[CONFIG_PROCESS_FILE_MAX_NR];  /*! xptr on open file descriptors */
    7070}
    7171fd_array_t;
     
    136136
    137137/*********************************************************************************************
    138  * This structure defines the minimal information required by the process_make_exec()
    139  * function to build a new reference process descriptor, and the associated main thread.
     138 * This structure defines the information required by the process_make_exec() function
     139 * to create a new reference process descriptor, and the associated main thread.
    140140 ********************************************************************************************/
    141141
    142142typedef struct exec_info_s
    143143{
    144     pid_t              pid;            /*! process identifier                               */
    145     pid_t              ppid;           /*! parent process identifier                        */
    146 
    147     xptr_t             fd_array_xp;    /*! extended pointer on parent process fd_array      */
    148 
    149     xptr_t             vfs_root_xp;    /*! extended pointer on file system root             */
    150     xptr_t             vfs_cwd_xp;     /*! extended pointer on current working directory    */
    151     xptr_t             vfs_bin_xp;     /*! extended pointer on process .elf file            */
    152 
     144    xptr_t             parent_xp;      /*! extended pointer on parent process descriptor    */
     145
     146    xptr_t             stdin_xp;       /*! extended pointer on stdin  pseudo-file           */
    153147    char               path[CONFIG_VFS_MAX_PATH_LENGTH];   /*!  .elf file path              */
    154148
     
    180174void process_free( process_t * process );
    181175
    182 /*********************************************************************************************
    183  * This function initializes the kernel process_zero descriptor (global variable) from
    184  * informations found in the boot_info.
    185  *********************************************************************************************
    186  * @ info      : pointer on local boot_info_t structure.
    187  ********************************************************************************************/
    188 void process_zero_init( boot_info_t * info );
    189 
    190176/*********************************************************************************************
    191177 * This function allocates memory and initialises the "process_init" descriptor and the
    192  * associated thread descriptor from information found in the "process_zero" descriptor.
    193  *********************************************************************************************
    194  * Any error gives a kernel panic.
    195  ********************************************************************************************/
     178 * associated "thread_init" descriptor. It should be called once at the end of the kernel
     179 * initialisation procedure, by the kernel "process_zero".
     180 * The "process_init" is the first user process, and all other user process will be forked
     181 * from this process. The code executed by "process_init" is stored in a .elf file, whose
     182 * pathname is defined by the CONFIG_PROCESS_INIT_PATH argument. It use fork/exec syscalls
     183 * to create the "shell" user process, and various other user daemon processes.
     184 * Practically, it build the exec_info structure, register the stdin / stdout / stderr
     185 * pseudo-file descriptors and the vfs_root and vfs_cwd in parent process_zero, and call
     186 * the generic process_make_exec() function, that makes the real job.
     187 ********************************************************************************************/
    196188void process_init_create();
    197189
     
    202194 * It set the pid / ppid / ref_xp fields.
    203195 * It registers this process descriptor in three lists:
    204  * - the children_list in the parent process descriptor.
     196 * - the children_list in the parent reference process descriptor.
    205197 * - the local_list, rooted in the reference cluster manager.
    206198 * - the copies_list, rooted in the owner cluster manager.
     
    209201 * @ process      : [in] pointer on process descriptor to initialize.
    210202 * @ pid          : [in] process identifier defined by owner cluster.
    211  * @ ppid         : [in] parent process identifier.
     203 * @ parent_xp    : [in] extended pointer on parent process.
    212204 ********************************************************************************************/
    213205void process_reference_init( process_t * process,
    214206                             pid_t       pid,
    215                              pid_t       ppid );
     207                             xptr_t      parent_xp );
    216208
    217209/*********************************************************************************************
     
    259251
    260252/*********************************************************************************************
    261  * This function builds a new reference process descriptor and associated main thread.
     253 * This function allocates memory and initializes a new user process descriptor,
     254 * and the associated main thread, from informationd found in the <exec_info> structure
     255 * (defined in the process.h file), that must be build by the caller.
     256 * The new process inherit from the parent process (i) the open file descriptors, (ii) the
     257 * vfs_root and the vfs_cwd inodes.
     258 * It access to the .elf file to get the size of the code and data segments, and initialize
     259 * the vsegs list in the VMM.
    262260 * It is executed in the local cluster, that becomes both "owner" and "reference".
    263  * The new process descriptor and the main_thread are initialised using only informations
    264  * found in the local exec_info structure, that must be build by the caller.
    265261 * - It can be called by the process_init_create() function to build the "init" process.
    266262 * - It can be called directly by the sys_exec() function in case of local exec.
  • trunk/kernel/kern/rpc.c

    r68 r101  
    14511451
    14521452        rpc_dmsg("\n[INFO] %s creates RPC thread %x on core %x in cluster %x at cycle %d\n",
    1453                           __FUNCTION__ , thread , core->gid , local_cxy , hal_time_stamp() );
     1453                          __FUNCTION__ , thread , core->gid , local_cxy , hal_get_cycles() );
    14541454
    14551455        // update core descriptor counter 
     
    14611461
    14621462    rpc_dmsg ("\n[INFO] %s activates RPC thread %x on core %x in cluster %x at cycle %d\n",
    1463                       __FUNCTION__ , thread , core->gid , local_cxy , hal_time_stamp() );
     1463                      __FUNCTION__ , thread , core->gid , local_cxy , hal_get_cycles() );
    14641464
    14651465    // current thread deschedules / RPC thread start execution
     
    15211521
    15221522    rpc_dmsg("\n[INFO] RPC thread %x created on core %d in cluster %x at cycle %d\n",
    1523              this->trdid , this->core->lid , local_cxy , hal_time_stamp() );
     1523             this->trdid , this->core->lid , local_cxy , hal_get_cycles() );
    15241524
    15251525    // this infinite loop is not preemptable
     
    15461546                {
    15471547            rpc_dmsg("\n[INFO] RPC thread %x suicide on core %d in cluster %x at cycle %d\n",
    1548                              this->trdid , this->core->lid , local_cxy , hal_time_stamp() );
     1548                             this->trdid , this->core->lid , local_cxy , hal_get_cycles() );
    15491549
    15501550            // update core descriptor counter
     
    15571557        // block and deschedule
    15581558        rpc_dmsg("\n[INFO] RPC thread %x deschedule on core %d in cluster %x at cycle %d\n",
    1559                               this->trdid , this->core->lid , local_cxy , hal_time_stamp() );
     1559                              this->trdid , this->core->lid , local_cxy , hal_get_cycles() );
    15601560
    15611561                thread_block( this , THREAD_BLOCKED_IDLE );
     
    15631563
    15641564                rpc_dmsg("\n[INFO] RPC thread %x wake up on core %d in cluster %x at cycle %d\n",
    1565                               this->trdid , this->core->lid , local_cxy , hal_time_stamp() );
     1565                              this->trdid , this->core->lid , local_cxy , hal_get_cycles() );
    15661566        }
    15671567} // end rpc_thread_func()
  • trunk/kernel/kern/scheduler.c

    r60 r101  
    240240               " has not released all locks at cycle %d\n",
    241241               __FUNCTION__, current->trdid, current->process->pid,
    242                local_cxy , core->lid , hal_time_stamp() );
     242               local_cxy , core->lid , hal_get_cycles() );
    243243        hal_core_sleep();
    244244    }
  • trunk/kernel/kern/thread.c

    r68 r101  
    514514    assert( (thread->remote_locks == 0) , __FUNCTION__ , "all remote locks not released" );
    515515
    516         tm_start = hal_time_stamp();
     516        tm_start = hal_get_cycles();
    517517
    518518    // update intrumentation values
     
    557557    thread_release( thread );
    558558
    559         tm_end = hal_time_stamp();
     559        tm_end = hal_get_cycles();
    560560
    561561        thread_dmsg("\n[INFO] %s : exit for thread %x in process %x / duration = %d\n",
     
    655655    // compute elapsed time, taking into account 32 bits register wrap
    656656    uint32_t elapsed;
    657     uint32_t time_now   = hal_time_stamp();
     657    uint32_t time_now   = hal_get_cycles();
    658658    uint32_t time_last  = this->time_last_check;
    659659    if( time_now < time_last ) elapsed = (0xFFFFFFFF - time_last) + time_now;
     
    753753    {
    754754        idle_dmsg("\n[INFO] %s : core[%x][%d] goes to sleep at cycle %d\n",
    755                     __FUNCTION__ , local_cxy , lid , hal_time_stamp() );
     755                    __FUNCTION__ , local_cxy , lid , hal_get_cycles() );
    756756
    757757        // force core to sleeping state
     
    759759
    760760        idle_dmsg("\n[INFO] %s : core[%x][%d] wake up at cycle %d\n",
    761                     __FUNCTION__ , local_cxy , lid , hal_time_stamp() );
     761                    __FUNCTION__ , local_cxy , lid , hal_get_cycles() );
    762762
    763763                // acknowledge IRQ
  • trunk/kernel/libk/remote_spinlock.c

    r93 r101  
    162162        cxy_t               lock_cxy = GET_CXY( lock_xp );
    163163
    164         // get cluster and local pointer on local thread
    165         cxy_t               thread_cxy = local_cxy;
    166         thread_t          * thread_ptr = CURRENT_THREAD;
     164    // get cluster and local pointer on calling thread
     165    cxy_t               thread_cxy = local_cxy;
     166    thread_t          * thread_ptr = CURRENT_THREAD;
    167167
    168168        // disable interrupts
     
    219219}
    220220
     221//////////////////////////////////////////////
     222xptr_t remote_spinlock_owner( xptr_t lock_xp )
     223{
     224    // get cluster and local pointer on remote_spinlock
     225    remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
     226    cxy_t               lock_cxy = GET_CXY( lock_xp );
     227
     228    return hal_remote_lw( XPTR( lock_cxy , &lock_ptr->owner ) );
     229}
  • trunk/kernel/libk/remote_spinlock.h

    r14 r101  
    100100void remote_spinlock_unlock( xptr_t  lock_xp );
    101101
     102/***************************************************************************************
     103 * This debug function returns the current owner of a remote spinlock.
     104 ***************************************************************************************
     105 * @ lock_xp    : extended pointer on the remote spinlock
     106 * @ return XPTR_NULL if not taken / return owner thread if lock already taken
     107 **************************************************************************************/
     108xptr_t remote_spinlock_owner( xptr_t  lock_xp );
     109
     110
    102111#endif
  • trunk/kernel/mm/kcm.c

    r65 r101  
    302302
    303303        kcm_dmsg("\n[INFO] %s : enters for type %s at cycle %d / new page = %x / count = %d\n",
    304                          __FUNCTION__ , kmem_type_str( kcm->type ) , hal_time_stamp() ,
     304                         __FUNCTION__ , kmem_type_str( kcm->type ) , hal_get_cycles() ,
    305305                 (intptr_t)kcm_page , kcm_page->count );
    306306
     
    312312
    313313                kcm_dmsg("\n[INFO] %s : enters for type %s at cycle %d / page = %x / count = %d\n",
    314                          __FUNCTION__ , kmem_type_str( kcm->type ) , hal_time_stamp() , 
     314                         __FUNCTION__ , kmem_type_str( kcm->type ) , hal_get_cycles() , 
    315315                 (intptr_t)kcm_page , kcm_page->count );
    316316        }
  • trunk/kernel/mm/vmm.c

    r68 r101  
    482482
    483483        vmm_dmsg("\n[INFO] %s enter for process %x / base = %x / size = %x / type = %s\n",
    484                      __FUNCTION__ , process->pid , base , size , vseg_type_name[type] );
     484                     __FUNCTION__ , process->pid , base , size , vseg_type_str(type) );
    485485
    486486    // compute base, size, vpn_base, vpn_size, depending on type
  • trunk/kernel/mm/vseg.c

    r18 r101  
    4646////////////////////////////////////////////////////////////////////////////////////////
    4747
    48 const char* vseg_type_name[VSEG_TYPES_NR] =
    49 {
    50         "CODE",
    51         "DATA",
    52     "HEAP",
    53     "STACK",
    54     "ANON",
    55     "FILE",
    56     "REMOTE",
    57     "KCODE",
    58     "KDATA",
    59     "KDEV",
    60 };
    61 
     48
     49//////////////////////////////////////////
     50char * vseg_type_str( uint32_t vseg_type )
     51{
     52        if     ( vseg_type == VSEG_TYPE_CODE   ) return "CODE";
     53        else if( vseg_type == VSEG_TYPE_DATA   ) return "DATA";
     54        else if( vseg_type == VSEG_TYPE_HEAP   ) return "HEAP";
     55        else if( vseg_type == VSEG_TYPE_STACK  ) return "STACK";
     56        else if( vseg_type == VSEG_TYPE_ANON   ) return "ANON";
     57        else if( vseg_type == VSEG_TYPE_FILE   ) return "FILE";
     58        else if( vseg_type == VSEG_TYPE_REMOTE ) return "REMOTE";
     59        else if( vseg_type == VSEG_TYPE_KCODE  ) return "KCODE";
     60        else if( vseg_type == VSEG_TYPE_KDATA  ) return "KDATA";
     61        else if( vseg_type == VSEG_TYPE_KDEV   ) return "KDEV";
     62    else                                     return "undefined";
     63}
    6264
    6365/////////////////////
  • trunk/kernel/mm/vseg.h

    r18 r101  
    8989
    9090/**********************************************************************************************
     91 * This function returns a printable string for the vseg type.
     92 **********************************************************************************************
     93 * @ vseg_type  : type of vseg
     94 * @ return pointer on string
     95 *********************************************************************************************/
     96char * vseg_type_str( uint32_t vseg_type );
     97
     98/**********************************************************************************************
    9199 * This function allocates physical memory for a new vseg descriptor from the local cluster
    92100 * physical memory allocator.
  • trunk/kernel/syscalls/sys_clock.c

    r23 r101  
    2424#include <hal_types.h>
    2525#include <hal_uspace.h>
     26#include <hal_special.h>
    2627#include <errno.h>
    2728#include <core.h>
     
    5354
    5455    // call relevant core function
    55         k_cycles = core_get_cycles( this->core );
     56        k_cycles = hal_get_cycles();
    5657
    5758    // copy to user space
  • trunk/kernel/syscalls/sys_exec.c

    r53 r101  
    225225                 " / target_cluster = %x / cycle %d\n",
    226226                 __FUNCTION__, process->pid , CURRENT_CORE->lid,
    227                  cxy_client, cxy_server, hal_time_stamp());
    228 
    229     // initialize exec_info structure
    230     exec_info.pid         = process->pid;
    231     exec_info.ppid        = process->ppid;
    232     exec_info.fd_array_xp = XPTR( local_cxy , &process->fd_array );
    233     exec_info.vfs_root_xp = process->vfs_root_xp;
    234     exec_info.vfs_cwd_xp  = process->vfs_cwd_xp;
    235     exec_info.vfs_bin_xp  = process->vfs_bin_xp;
     227                 cxy_client, cxy_server, hal_get_cycles());
     228
     229    // register reference parent process in exec_info
     230    exec_info.parent_xp   = process->ref_xp;
    236231
    237232        // check pathname and store it in exec_info structure
     
    266261       
    267262    exec_dmsg("\n[INFO] %s starts exec for process %x at cycle %d\n",
    268               __FUNCTION__, process->pid, hal_time_stamp() );
     263              __FUNCTION__, process->pid, hal_get_cycles() );
    269264
    270265    if( is_local )  error = process_make_exec( &exec_info );
     
    280275
    281276    exec_dmsg("\n[INFO] %s completes exec for process %x at cycle %d\n",
    282               __FUNCTION__, process->pid , hal_time_stamp() );
     277              __FUNCTION__, process->pid , hal_get_cycles() );
    283278
    284279    // delete the calling thread an process
  • trunk/kernel/syscalls/sys_fork.c

    r23 r101  
    6464
    6565        fork_dmsg("\n[INFO] %s : enters for process %d at cycle [%d]\n",
    66                   __FUNCTION__, parent_process->pid, hal_time_stamp());
     66                  __FUNCTION__, parent_process->pid, hal_get_cycles());
    6767
    6868    // save FPU state in fpu_context if parent process is FPU owner
     
    214214
    215215        fork_dmsg("\n[INFO] %s : completed / parent pid = %x / child pid = %x / at cycle [%d]\n",
    216                   __FUNCTION__, parent_process->pid, child_process->pid, hal_time_stamp() );
     216                  __FUNCTION__, parent_process->pid, child_process->pid, hal_get_cycles() );
    217217
    218218        return child_process->pid;
  • trunk/kernel/syscalls/sys_thread_create.c

    r23 r101  
    6161        uint32_t         tm_end;
    6262
    63         tm_start = hal_time_stamp();
     63        tm_start = hal_get_cycles();
    6464
    6565    // get parent thead pointer, extended pointer, and process pointer
     
    160160        thread_child_parent_link( parent_xp , child_xp );
    161161
    162         tm_end = hal_time_stamp();
     162        tm_end = hal_get_cycles();
    163163
    164164        thread_dmsg("\n[INFO] %s created thread %x for process %x in cluster %x\n"
  • trunk/kernel/syscalls/sys_thread_sleep.c

    r50 r101  
    3131{
    3232    thread_dmsg("\n[INFO] %s : thread %x in process %x goes to sleep at cycle %d\n",
    33                 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_PROCESS->pid, hal_time_stamp() );
     33                __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_PROCESS->pid, hal_get_cycles() );
    3434
    3535    thread_block( CURRENT_THREAD , THREAD_BLOCKED_GLOBAL );
     
    3737
    3838    thread_dmsg("\n[INFO] %s : thread %x in process %x resume at cycle\n",
    39                 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_PROCESS->pid, hal_time_stamp() );
     39                __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_PROCESS->pid, hal_get_cycles() );
    4040
    4141        return 0;
  • trunk/kernel/vfs/fatfs.c

    r68 r101  
    319319    uint32_t   line;
    320320    uint32_t   byte = 0;
    321     printk("\n*** boot record at cycle %d ***\n", hal_time_stamp() );
     321    printk("\n*** boot record at cycle %d ***\n", hal_get_cycles() );
    322322    for ( line = 0 ; line < 32 ; line++ )
    323323    {
  • trunk/kernel/vfs/vfs.c

    r50 r101  
    246246}
    247247
    248 /////////////////////////////////////////////////
    249 void vfs_inode_size_set_size( xptr_t    inode_xp,
     248////////////////////////////////////////////
     249void vfs_inode_set_size( xptr_t    inode_xp,
    250250                              uint32_t  size )
    251251{
     
    260260}
    261261
    262 ///////////////////////////////////////////////
    263 void vfs_inode_remote_unlock( xptr_t inode_xp )
     262////////////////////////////////////////
     263void vfs_inode_unlock( xptr_t inode_xp )
    264264{
    265265    // get inode cluster and local pointer
     
    271271}
    272272
    273 /////////////////////////////////////////////
    274 void vfs_inode_remote_lock( xptr_t inode_xp )
     273//////////////////////////////////////
     274void vfs_inode_lock( xptr_t inode_xp )
    275275{
    276276    // get inode cluster and local pointer
     
    280280    // get the main lock
    281281    remote_spinlock_lock( XPTR( cxy , &ptr->main_lock ) );
     282}
     283
     284/////////////////////////////////////////
     285xptr_t vfs_inode_owner( xptr_t inode_xp )
     286{
     287    // get inode cluster and local pointer
     288    cxy_t         cxy = GET_CXY( inode_xp );
     289    vfs_inode_t * ptr = (vfs_inode_t *)GET_PTR( inode_xp );
     290
     291    // get the main lock
     292    return remote_spinlock_owner( XPTR( cxy , &ptr->main_lock ) );
    282293}
    283294
     
    459470    xptr_t        file_xp;      // extended pointer on created file descriptor
    460471    uint32_t      file_id;      // created file descriptor index in reference fd_array
     472
     473    vfs_dmsg("\n[INFO] %s : enters for <%s> at cycle %d\n",
     474             __FUNCTION__ , path , hal_get_cycles() );
    461475
    462476    // compute lookup working mode
     
    476490    // get extended pointer on target inode
    477491    error = vfs_lookup( cwd_xp , path , lookup_mode , &inode_xp );
     492
     493    vfs_dmsg("\n[INFO] %s : get inode_xp = %l for <%s> at cycle %d\n",
     494             __FUNCTION__ , inode_xp , path , hal_get_cycles() );
    478495
    479496    if( error ) return error;
     
    848865
    849866    // return child inode
    850     *child_xp = (xptr_t)hal_remote_lwd( XPTR( dentry_cxy , &dentry_ptr->parent ) );
     867    *child_xp = (xptr_t)hal_remote_lwd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) );
    851868    return true;
    852869}
     
    903920                                        xptr_t           * inode_xp )
    904921{
    905     char          name[CONFIG_VFS_MAX_NAME_LENGTH];   // one name in path
     922    char               name[CONFIG_VFS_MAX_NAME_LENGTH];   // one name in path
    906923
    907924    xptr_t             parent_xp;    // extended pointer on parent inode
     
    922939    error_t            error;
    923940
     941    vfs_dmsg("\n[INFO] %s : enters for <%s>\n",
     942             __FUNCTION__ , pathname );
     943
    924944    this    = CURRENT_THREAD;
    925945    process = this->process;
     
    929949    else                     parent_xp = cwd_xp;
    930950
    931     // initialise loop variables
     951    // initialise other loop variables
    932952    current  = pathname;
    933953    next     = NULL;
     
    936956
    937957    // take lock on parent inode
    938     vfs_inode_remote_lock( parent_xp );
    939 
    940     // break : if one intermediate name not found
    941     // exit  : when last name found (i.e. last == true)
     958    vfs_inode_lock( parent_xp );
     959
     960    // load from device if one intermediate node not found
     961    // exit  when last name found (i.e. last == true)
    942962    do
    943963    {
    944         // get one name from path and the last flag
     964        // get one name from path, and the "last" flag
    945965        vfs_get_name_from_path( current , name , &next , &last );
     966
     967        vfs_dmsg("\n[INFO] %s : looking for node <%s> / last = %d\n",
     968                 __FUNCTION__ , name , last );
    946969
    947970        // search a child dentry matching name for parent inode
     
    952975        if( found == false ) // child inode not found in inode tree => try to load it
    953976        {
     977            vfs_dmsg("\n[INFO] %s : node <%s> not found, try to load it\n",
     978                     __FUNCTION__ , name );
     979
    954980            // release lock on parent inode
    955             vfs_inode_remote_unlock( parent_xp );
     981            vfs_inode_unlock( parent_xp );
    956982
    957983            // get cluster and local pointer on parent inode
     
    9821008
    9831009            // take lock on parent inode
    984             vfs_inode_remote_lock( parent_xp );
     1010            vfs_inode_lock( parent_xp );
    9851011        }
    9861012
    987         // check access rights
     1013        vfs_dmsg("\n[INFO] %s : node <%s> found / parent = %l / child = %l / last = %d\n",
     1014                 __FUNCTION__ , name , parent_xp , child_xp , last );
     1015
     1016        // TODO check access rights
    9881017        // error = vfs_access_denied( child_xp,
    9891018        //                            client_uid,
     
    9951024        // }
    9961025
     1026printk("\n@@@ bloup 0 : parent lock owner = %l / child lock owner = %l\n",
     1027       vfs_inode_owner( parent_xp ) , vfs_inode_owner( child_xp ) );
     1028
    9971029        // take lock on child inode if not last
    998         if( last == false ) vfs_inode_remote_lock( child_xp );
     1030        if( last == false ) vfs_inode_lock( child_xp );
     1031
     1032printk("\n@@@ bloup 1\n");
    9991033
    10001034        // release lock on parent inode
    1001         vfs_inode_remote_unlock( parent_xp );
     1035        vfs_inode_unlock( parent_xp );
     1036
     1037printk("\n@@@ bloup 2\n");
    10021038
    10031039        // update loop variables
    10041040        parent_xp = child_xp;
    10051041        current   = next;
     1042
     1043        vfs_dmsg("\n[INFO] %s : complete node <%s> / last = %d\n",
     1044                 __FUNCTION__ , name , last );
     1045
    10061046    }
    10071047    while( last == false );
     
    11421182    uint32_t  y_size    = LOCAL_CLUSTER->y_size;
    11431183    uint32_t  y_width   = LOCAL_CLUSTER->y_width;
    1144     uint32_t  index     = ( hal_time_stamp() + hal_get_gid() ) % (x_size * y_size);
     1184    uint32_t  index     = ( hal_get_cycles() + hal_get_gid() ) % (x_size * y_size);
    11451185    uint32_t  x         = index / y_size;   
    11461186    uint32_t  y         = index % y_size;
  • trunk/kernel/vfs/vfs.h

    r23 r101  
    414414 * @ inode_xp  : extended pointer on the remote inode.
    415415 *****************************************************************************************/
    416 void vfs_inode_remote_lock( xptr_t inode_xp );
     416void vfs_inode_lock( xptr_t inode_xp );
    417417
    418418/******************************************************************************************
     
    422422 * @ inode_xp  : extended pointer on the remote inode.
    423423 *****************************************************************************************/
    424 void vfs_inode_remote_unlock( xptr_t inode_xp );
    425 
    426 
    427 
    428 
    429 /******************************************************************************************
    430  * This function TODO                                                         
    431  *****************************************************************************************/
    432 error_t vfs_inode_hold( vfs_inode_t * inode,
    433                         uint32_t      gc );
     424void vfs_inode_unlock( xptr_t inode_xp );
     425
     426/******************************************************************************************
     427 * This debug function returns the current owner of the inode main lock.
     428 *****************************************************************************************
     429 * @ inode_xp  : extended pointer on the remote inode.
     430 * @ return extended pointer on owner thread / return XPTR_NULL if lock not taken.
     431 *****************************************************************************************/
     432xptr_t vfs_inode_owner( xptr_t inode_xp );
    434433
    435434/******************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.