source: trunk/kernel/mm/vseg.h @ 570

Last change on this file since 570 was 567, checked in by alain, 6 years ago

Complete restructuration of kernel locks.

File size: 7.6 KB
RevLine 
[1]1/*
2 * vseg.h - virtual segment (vseg) related operations
3 *
4 * Authors   Ghassan Almaless (2008,2009,2010,2011, 2012)
5 *           Mohamed Lamine Karaoui (2015)
6 *           Alain Greiner (2016)
7 *
8 * Copyright (c) UPMC Sorbonne Universites
9 *
10 * This file is part of ALMOS-MKH.
11 *
12 * ALMOS-MKH is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2.0 of the License.
15 *
16 * ALMOS-MKH is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
23 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26#ifndef _VSEG_H_
27#define _VSEG_H_
28
[457]29#include <hal_kernel_types.h>
[1]30#include <vfs.h>
31
32/****  Forward declarations  ****/
33
34struct vmm_s;
35
[409]36/*******************************************************************************************
[407]37 * This enum defines the vseg types for an user process.
[409]38 ***********************************************************************************VSEG*******/
[1]39
[407]40typedef enum
[1]41{
[409]42    VSEG_TYPE_CODE   = 0,          /*! executable user code   / private / localized       */
43    VSEG_TYPE_DATA   = 1,          /*! initialized user data  / public  / distributed     */
44    VSEG_TYPE_STACK  = 2,          /*! execution user stack   / private / localized       */
45    VSEG_TYPE_ANON   = 3,          /*! anonymous mmap         / public  / localized       */
46    VSEG_TYPE_FILE   = 4,          /*! file mmap              / public  / localized       */
47    VSEG_TYPE_REMOTE = 5,          /*! remote mmap            / public  / localized       */
[407]48}
49vseg_type_t;
[1]50
51
[409]52/*******************************************************************************************
[18]53 * These masks define the vseg generic (hardware independent) flags.
[409]54 ******************************************************************************************/
[1]55
[409]56#define VSEG_USER     0x0001       /*! user accessible                                    */
57#define VSEG_WRITE    0x0002       /*! writeable                                          */
58#define VSEG_EXEC     0x0004       /*! executable                                         */
59#define VSEG_CACHE    0x0008       /*! cachable                                           */
60#define VSEG_PRIVATE  0x0010       /*! should not be accessed from another cluster        */
61#define VSEG_DISTRIB  0x0020       /*! physically distributed on all clusters             */
62#define VSEG_IDENT    0x0040       /*! identity mapping                                   */
[1]63
[409]64/*******************************************************************************************
[1]65 * This structure defines a virtual segment descriptor.
[408]66 * - The VSL contains only local vsegs, but is implemented as an xlist, because it can be
67 *   accessed by thread running in a remote cluster.
68 * - The zombi list is used by the local MMAP allocator. It is implemented as a local list.
[409]69 ******************************************************************************************/
[1]70
71typedef struct vseg_s
72{
[454]73    xlist_entry_t     xlist;        /*! all vsegs in same VSL (or same zombi list)        */
74    list_entry_t      zlist;        /*! all vsegs in same zombi list                      */
75    struct vmm_s    * vmm;          /*! pointer on associated VM manager                  */
[409]76    uint32_t          type;         /*! vseg type                                         */
[454]77    intptr_t          min;          /*! segment min virtual address                       */
78    intptr_t          max;          /*! segment max virtual address (excluded)            */
79    vpn_t             vpn_base;     /*! first page of vseg                                */
80    vpn_t             vpn_size;     /*! number of pages occupied                          */
81    uint32_t          flags;        /*! vseg attributes                                   */
82    xptr_t            mapper_xp;    /*! xptr on remote mapper (for types CODE/DATA/FILE)  */
83    intptr_t          file_offset;  /*! vseg offset in file (for types CODE/DATA/FILE)    */
[409]84    intptr_t          file_size;    /*! max segment size in mapper (for type CODE/DATA)   */
85    cxy_t             cxy;          /*! physical mapping (for non distributed vseg)       */ 
[1]86}
87vseg_t;
88
[409]89/*******************************************************************************************
[101]90 * This function returns a printable string for the vseg type.
[409]91 *******************************************************************************************
[101]92 * @ vseg_type  : type of vseg
93 * @ return pointer on string
[409]94 ******************************************************************************************/
[101]95char * vseg_type_str( uint32_t vseg_type );
96
[409]97/*******************************************************************************************
[1]98 * This function allocates physical memory for a new vseg descriptor from the local cluster
99 * physical memory allocator.
[409]100 *******************************************************************************************
[1]101 * @ return pointer on allocated vseg descriptor if success / return NULL if failure.
[409]102 ******************************************************************************************/
[503]103vseg_t * vseg_alloc( void );
[1]104
[409]105/*******************************************************************************************
106 * This function releases the physical memory allocated for a vseg descriptor
107 * to the local cluster physical memory allocator.
108 *******************************************************************************************
[1]109 * @ vseg   : local pointer on released vseg descriptor.
[409]110 ******************************************************************************************/
[1]111void vseg_free( vseg_t * vseg );
112
[409]113/*******************************************************************************************
[1]114 * This function initializes a local vseg descriptor, from the arguments values.
115 * It does NOT register the vseg in the local VMM.
[409]116 *******************************************************************************************
[1]117 * @ vseg      : pointer on the vseg descriptor.
118 * @ base      : vseg base address.
119 * @ size      : vseg size (bytes).
120 * @ vpn_base  : first page index.
121 * @ vpn_size  : number of pages.
122 * @ type      : vseg type.
123 * @ cxy       : target cluster for physical mapping.
[409]124 ******************************************************************************************/
[1]125void vseg_init( vseg_t      * vseg,
[407]126                    vseg_type_t   type,
[18]127                intptr_t      base,
[407]128                    uint32_t      size,
[1]129                vpn_t         vpn_base,
130                vpn_t         vpn_size,
[407]131                uint32_t      file_offset,
132                uint32_t      file_size,
133                xptr_t        mapper_xp,
[315]134                cxy_t         cxy );
[1]135
[409]136/*******************************************************************************************
[1]137 * This function initializes a local vseg descriptor from values contained in a reference
138 * remote vseg descriptor. It does NOT register the vseg in the local VMM.
[409]139 *******************************************************************************************
[1]140 * @ vseg      : pointer on the vseg descriptor.
[16]141 * @ ref_xp    : extended pointer on the reference vseg descriptor.
[409]142 ******************************************************************************************/
[1]143void vseg_init_from_ref( vseg_t * vseg,
[16]144                         xptr_t   ref_xp );
[1]145
146
147#endif /* _VSEG_H_ */
Note: See TracBrowser for help on using the repository browser.