Changeset 407 for trunk/kernel/mm/vseg.c


Ignore:
Timestamp:
Nov 7, 2017, 3:08:12 PM (6 years ago)
Author:
alain
Message:

First implementation of fork/exec.

File:
1 edited

Legend:

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

    r406 r407  
    5252        if     ( vseg_type == VSEG_TYPE_CODE   ) return "CODE";
    5353        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";
     54        else if( vseg_type == VSEG_TYPE_STACK  ) return "STAK";
    5655        else if( vseg_type == VSEG_TYPE_ANON   ) return "ANON";
    5756        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";
     57        else if( vseg_type == VSEG_TYPE_REMOTE ) return "REMO";
    6258    else                                     return "undefined";
    6359}
     
    8783///////////////////////////////////
    8884void vseg_init( vseg_t      * vseg,
     85                vseg_type_t   type,
    8986                    intptr_t      base,
    90                 intptr_t      size,
     87                uint32_t      size,
    9188                vpn_t         vpn_base,
    9289                vpn_t         vpn_size,
    93                         uint32_t      type,
     90                        uint32_t      file_offset,
     91                uint32_t      file_size,
     92                xptr_t        mapper_xp,
    9493                cxy_t         cxy )
    9594{
    96     vseg->type      = type;
    97         vseg->min       = base;
    98         vseg->max       = base + size;
    99     vseg->vpn_base  = vpn_base;
    100         vseg->vpn_size  = vpn_size;
    101         vseg->mapper_xp = XPTR_NULL;
    102     vseg->cxy       = cxy;
     95    vseg->type        = type;
     96        vseg->min         = base;
     97        vseg->max         = base + size;
     98    vseg->vpn_base    = vpn_base;
     99        vseg->vpn_size    = vpn_size;
     100    vseg->file_offset = file_offset;
     101    vseg->file_size   = file_size;
     102        vseg->mapper_xp   = mapper_xp;
     103    vseg->cxy         = cxy;
    103104
    104105    // set vseg flags depending on type
     
    124125                      VSEG_DISTRIB ;
    125126    }
    126     else if( type == VSEG_TYPE_HEAP )
    127     {
    128         vseg->flags = VSEG_USER    |
    129                       VSEG_WRITE   |
    130                       VSEG_CACHE   |
    131                       VSEG_DISTRIB ;
    132     }
    133127    else if( type == VSEG_TYPE_REMOTE )
    134128    {
     
    141135        vseg->flags = VSEG_USER    |
    142136                      VSEG_WRITE   |
    143                       VSEG_CACHE   |
    144                       VSEG_DISTRIB ;
     137                      VSEG_CACHE;
    145138    }
    146139    else if( type == VSEG_TYPE_FILE )
     
    161154                      VSEG_CACHE   |
    162155                      VSEG_PRIVATE ;
     156    }
     157    else if( type == VSEG_TYPE_KDEV )
     158    {
     159        vseg->flags = VSEG_WRITE   ;
    163160    }
    164161    else
     
    171168//////////////////////////////////////////
    172169void vseg_init_from_ref( vseg_t    * vseg,
    173                          xptr_t      ref )
     170                         xptr_t      ref_xp )
    174171{
    175172    // get remote vseg cluster and pointer
    176     cxy_t    cxy = (cxy_t   )GET_CXY( ref );
    177     vseg_t * ptr = (vseg_t *)GET_PTR( ref );
     173    cxy_t    cxy = (cxy_t   )GET_CXY( ref_xp );
     174    vseg_t * ptr = (vseg_t *)GET_PTR( ref_xp );
    178175
    179176    // initialize vseg with remote_read access
    180     vseg->type       =           hal_remote_lw ( XPTR( cxy , &ptr->type      ) );
    181     vseg->min        = (intptr_t)hal_remote_lpt( XPTR( cxy , &ptr->min       ) );
    182     vseg->max        = (intptr_t)hal_remote_lpt( XPTR( cxy , &ptr->max       ) );
    183     vseg->vpn_base   =           hal_remote_lw ( XPTR( cxy , &ptr->vpn_base  ) );
    184     vseg->vpn_size   =           hal_remote_lw ( XPTR( cxy , &ptr->vpn_size  ) );
    185     vseg->flags      =           hal_remote_lw ( XPTR( cxy , &ptr->flags     ) );
    186         vseg->mapper_xp  = (xptr_t)  hal_remote_lwd( XPTR( cxy , &ptr->mapper_xp ) );
     177    vseg->type        =           hal_remote_lw ( XPTR( cxy , &ptr->type        ) );
     178    vseg->min         = (intptr_t)hal_remote_lpt( XPTR( cxy , &ptr->min         ) );
     179    vseg->max         = (intptr_t)hal_remote_lpt( XPTR( cxy , &ptr->max         ) );
     180    vseg->vpn_base    =           hal_remote_lw ( XPTR( cxy , &ptr->vpn_base    ) );
     181    vseg->vpn_size    =           hal_remote_lw ( XPTR( cxy , &ptr->vpn_size    ) );
     182    vseg->flags       =           hal_remote_lw ( XPTR( cxy , &ptr->flags       ) );
     183    vseg->file_offset =           hal_remote_lw ( XPTR( cxy , &ptr->file_offset ) );
     184    vseg->file_size   =           hal_remote_lw ( XPTR( cxy , &ptr->file_size   ) );
     185        vseg->mapper_xp   = (xptr_t)  hal_remote_lwd( XPTR( cxy , &ptr->mapper_xp   ) );
    187186}
    188187
Note: See TracChangeset for help on using the changeset viewer.