Changeset 672 for trunk/kernel/mm/vmm.c


Ignore:
Timestamp:
Nov 19, 2020, 11:49:01 PM (4 years ago)
Author:
alain
Message:

1) Introduce up to 4 command lines arguments in the KSH "load" command.
These arguments are transfered to the user process through the
argc/argv mechanism, using the user space "args" vseg.

2) Introduce the named and anonymous "pipes", for inter-process communication
through the pipe() and mkfifo() syscalls.

3) Introduce the "chat" application to validate the two above mechanisms.

4) Improve printk() and assert() fonctions in printk.c.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/mm/vmm.c

    r665 r672  
    22 * vmm.c - virtual memory manager related operations definition.
    33 *
    4  * Authors   Ghassan Almaless (2008,2009,2010,2011, 2012)
    5  *           Alain Greiner (2016,2017,2018,2019,2020)
     4 * Authors   Ghassan Almaless (2008,2009,2010,2011,2012)
     5 *           Alain Greiner    (2016,2017,2018,2019,2020)
    66 *
    77 * Copyright (c) UPMC Sorbonne Universites
     
    6363
    6464// check STACK zone
    65 assert( ((CONFIG_VMM_STACK_SIZE * CONFIG_THREADS_MAX_PER_CLUSTER) <=
     65assert( __FUNCTION__, ((CONFIG_VMM_STACK_SIZE * CONFIG_THREADS_MAX_PER_CLUSTER) <=
    6666(CONFIG_VMM_VSPACE_SIZE - CONFIG_VMM_STACK_BASE)) , "STACK zone too small\n");
    6767
     
    8989
    9090// check ltid argument
    91 assert( (ltid <= ((CONFIG_VMM_VSPACE_SIZE - CONFIG_VMM_STACK_BASE) / CONFIG_VMM_STACK_SIZE)),
     91assert( __FUNCTION__, (ltid <= ((CONFIG_VMM_VSPACE_SIZE - CONFIG_VMM_STACK_BASE) / CONFIG_VMM_STACK_SIZE)),
    9292"slot index %d too large for an user stack vseg", ltid );
    9393
     
    9999
    100100// check requested slot is available
    101 assert( (bitmap_state( &mgr->bitmap , ltid ) == false),
     101assert( __FUNCTION__, (bitmap_state( &mgr->bitmap , ltid ) == false),
    102102"slot index %d already allocated", ltid );
    103103
     
    149149
    150150// check index
    151 assert( (index <= ((CONFIG_VMM_VSPACE_SIZE - CONFIG_VMM_STACK_BASE) / CONFIG_VMM_STACK_SIZE)),
     151assert( __FUNCTION__, (index <= ((CONFIG_VMM_VSPACE_SIZE - CONFIG_VMM_STACK_BASE) / CONFIG_VMM_STACK_SIZE)),
    152152"slot index %d too large for an user stack vseg", index );
    153153
    154154// check released slot is allocated
    155 assert( (bitmap_state( &mgr->bitmap , index ) == true),
     155assert( __FUNCTION__, (bitmap_state( &mgr->bitmap , index ) == true),
    156156"released slot index %d non allocated", index );
    157157
     
    226226
    227227// check HEAP base and size
    228 assert( (CONFIG_VMM_HEAP_BASE == 0x40000) & (CONFIG_VMM_STACK_BASE == 0xc0000),
     228assert( __FUNCTION__, (CONFIG_VMM_HEAP_BASE == 0x40000) & (CONFIG_VMM_STACK_BASE == 0xc0000),
    229229"CONFIG_VMM_HEAP_BASE != 0x40000 or CONFIG_VMM_STACK_BASE != 0xc0000" );
    230230
    231231// check  MMAP vseg max order
    232 assert( (CONFIG_VMM_HEAP_MAX_ORDER == 18), "max mmap vseg size is 256K pages" );
     232assert( __FUNCTION__, (CONFIG_VMM_HEAP_MAX_ORDER == 18), "max mmap vseg size is 256K pages" );
    233233
    234234    // get pointer on MMAP allocator
     
    252252    vseg_t * vseg0 = vseg_alloc();
    253253
    254 assert( (vseg0 != NULL) , "cannot allocate vseg" );
     254assert( __FUNCTION__, (vseg0 != NULL) , "cannot allocate vseg" );
    255255
    256256    vseg0->vpn_base = CONFIG_VMM_HEAP_BASE;
     
    263263    vseg_t * vseg1 = vseg_alloc();
    264264
    265 assert( (vseg1 != NULL) , "cannot allocate vseg" );
     265assert( __FUNCTION__, (vseg1 != NULL) , "cannot allocate vseg" );
    266266
    267267    vseg1->vpn_base = CONFIG_VMM_HEAP_BASE << 1;
     
    555555
    556556// check UTILS zone
    557 assert( ((CONFIG_VMM_ARGS_SIZE + CONFIG_VMM_ENVS_SIZE) <=
    558          (CONFIG_VMM_ELF_BASE - CONFIG_VMM_UTILS_BASE)) ,
    559          "UTILS zone too small\n" );
     557assert( __FUNCTION__ , ((CONFIG_VMM_ARGS_SIZE + CONFIG_VMM_ENVS_SIZE) <=
     558(CONFIG_VMM_ELF_BASE - CONFIG_VMM_UTILS_BASE)) , "UTILS zone too small\n" );
    560559
    561560    // initialize lock protecting the VSL
    562561        remote_queuelock_init( XPTR( local_cxy , &vmm->vsl_lock ) , LOCK_VMM_VSL );
    563 
    564562
    565563    // initialize STACK allocator
     
    577575        vmm->global_pgfault_cost = 0;
    578576
    579 /*
    580     // register "args" vseg in VSL
    581     base = CONFIG_VMM_UTILS_BASE << CONFIG_PPM_PAGE_SHIFT;
    582     size = CONFIG_VMM_ARGS_SIZE << CONFIG_PPM_PAGE_SHIFT;
    583 
    584     vseg_args = vmm_create_vseg( process,
    585                                  VSEG_TYPE_DATA,
    586                                  base,
    587                                  size,
    588                                  0,             // file_offset unused
    589                                  0,             // file_size unused
    590                                  XPTR_NULL,     // mapper_xp unused
    591                                  local_cxy );
    592     if( vseg_args == NULL )
    593     {
    594         printk("\n[ERROR] in %s : cannot register args vseg\n", __FUNCTION__ );
    595         return -1;
    596     }
    597 
    598     vmm->args_vpn_base = base;
    599 
    600     // register "envs" vseg in VSL
    601     base = (CONFIG_VMM_UTILS_BASE + CONFIG_VMM_ARGS_SIZE) << CONFIG_PPM_PAGE_SHIFT;
    602     size = CONFIG_VMM_ENVS_SIZE << CONFIG_PPM_PAGE_SHIFT;
    603 
    604     vseg_envs = vmm_create_vseg( process,
    605                                  VSEG_TYPE_DATA,
    606                                  base,
    607                                  size,
    608                                  0,             // file_offset unused
    609                                  0,             // file_size unused
    610                                  XPTR_NULL,     // mapper_xp unused
    611                                  local_cxy );
    612     if( vseg_envs == NULL )
    613     {
    614         printk("\n[ERROR] in %s : cannot register envs vseg\n", __FUNCTION__ );
    615         return -1;
    616     }
    617 
    618     vmm->envs_vpn_base = base;
    619 */
    620577    hal_fence();
    621578
     
    716673// FIXME il faut gérer les process copies...
    717674
     675    // re-initialise VMM
     676    vmm_user_init( process );
     677
    718678#if DEBUG_VMM_USER_RESET
    719679cycle = (uint32_t)hal_get_cycles();
     
    11331093
    11341094// check cluster is reference
    1135 assert( (XPTR( local_cxy , process ) == process->ref_xp),
     1095assert( __FUNCTION__, (XPTR( local_cxy , process ) == process->ref_xp),
    11361096"local cluster must be process reference cluster\n");
    11371097
     
    18691829
    18701830// check arguments
    1871 assert( (process != NULL), "process argument is NULL" );
    1872 assert( (vseg    != NULL), "vseg argument is NULL" );
     1831assert( __FUNCTION__, (process != NULL), "process argument is NULL" );
     1832assert( __FUNCTION__, (vseg    != NULL), "vseg argument is NULL" );
    18731833
    18741834    // get pointers on local process VMM
     
    19601920
    19611921// check arguments
    1962 assert( (process != NULL), "process argument is NULL" );
    1963 assert( (vseg    != NULL), "vseg argument is NULL" );
     1922assert( __FUNCTION__, (process != NULL), "process argument is NULL" );
     1923assert( __FUNCTION__, (vseg    != NULL), "vseg argument is NULL" );
    19641924
    19651925#if DEBUG_VMM_RESIZE_VSEG
     
    22282188
    22292189// check vseg type
    2230 assert( ( type != VSEG_TYPE_FILE ) , "illegal vseg type\n" );
     2190assert( __FUNCTION__, ( type != VSEG_TYPE_FILE ) , "illegal vseg type\n" );
    22312191
    22322192    // compute target cluster identifier
     
    23022262        xptr_t mapper_xp = vseg->mapper_xp;
    23032263
    2304 assert( (mapper_xp != XPTR_NULL),
     2264assert( __FUNCTION__, (mapper_xp != XPTR_NULL),
    23052265"mapper not defined for a FILE vseg\n" );
    23062266       
     
    23272287            xptr_t     mapper_xp = vseg->mapper_xp;
    23282288
    2329 assert( (mapper_xp != XPTR_NULL),
     2289assert( __FUNCTION__, (mapper_xp != XPTR_NULL),
    23302290"mapper not defined for a CODE or DATA vseg\n" );
    23312291       
Note: See TracChangeset for help on using the changeset viewer.