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

Last change on this file since 645 was 640, checked in by alain, 4 years ago

Remove all RPCs in page-fault handling.

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