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

Last change on this file since 665 was 657, checked in by alain, 5 years ago

Introduce remote_buf.c/.h & socket.c/.h files.
Update dev_nic.c/.h files.

File size: 7.3 KB
Line 
1/*
2 * vseg.h - virtual segment (vseg) related operations
3 *
4 * Authors  Alain Greiner (2016,2017,2018,2019,2020)
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
27#include <hal_kernel_types.h>
28#include <vfs.h>
29
30/****  Forward declarations  ****/
31
32struct vmm_s;
33
34/*******************************************************************************************
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].
39 ******************************************************************************************/
40
41typedef enum
42{
43    VSEG_TYPE_CODE   = 1,          /*! executable user code     / private / localized     */
44    VSEG_TYPE_DATA   = 2,          /*! initialized user data    / public  / distributed   */
45    VSEG_TYPE_STACK  = 3,          /*! execution user stack     / private / localized     */
46    VSEG_TYPE_ANON   = 4,          /*! anonymous mmap           / public  / localized     */
47    VSEG_TYPE_FILE   = 5,          /*! file mmap                / public  / localized     */
48    VSEG_TYPE_REMOTE = 6,          /*! remote mmap              / public  / localized     */
49
50    VSEG_TYPE_KCODE  = 7,          /*! executable kernel code   / private / localized     */
51    VSEG_TYPE_KDATA  = 8,          /*! initialized kernel data  / private / localized     */
52    VSEG_TYPE_KDEV   = 9,          /*! kernel peripheral device / public  / localized     */
53}
54vseg_type_t;
55
56
57/*******************************************************************************************
58 * These masks define the vseg generic (hardware independent) flags.
59 ******************************************************************************************/
60
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             */
67
68/*******************************************************************************************
69 * This structure defines a virtual segment descriptor.
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.
73 ******************************************************************************************/
74
75typedef struct vseg_s
76{
77    xlist_entry_t     xlist;        /*! all vsegs in same VSL                             */
78    struct vmm_s    * vmm;          /*! pointer on associated VM manager                  */
79    uint32_t          type;         /*! vseg type                                         */
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)    */
87    intptr_t          file_size;    /*! max segment size in mapper (for type CODE/DATA)   */
88    cxy_t             cxy;          /*! physical mapping (for non distributed vseg)       */ 
89}
90vseg_t;
91
92/*******************************************************************************************
93 * This function returns a printable string for the vseg type.
94 *******************************************************************************************
95 * @ vseg_type  : type of vseg
96 * @ return pointer on string
97 ******************************************************************************************/
98char * vseg_type_str( uint32_t vseg_type );
99
100/*******************************************************************************************
101 * This function allocates physical memory for a new vseg descriptor from the local cluster
102 * physical memory allocator.
103 *******************************************************************************************
104 * @ return pointer on allocated vseg descriptor if success / return NULL if failure.
105 ******************************************************************************************/
106vseg_t * vseg_alloc( void );
107
108/*******************************************************************************************
109 * This function releases the physical memory allocated for a vseg descriptor
110 * to the local cluster physical memory allocator.
111 *******************************************************************************************
112 * @ vseg   : local pointer on released vseg descriptor.
113 ******************************************************************************************/
114void vseg_free( vseg_t * vseg );
115
116/*******************************************************************************************
117 * This function initializes the "flags" field for a local <vseg> descriptor,
118 * depending on the vseg <type>.
119 *******************************************************************************************
120 * @ vseg      : pointer on the vseg descriptor.
121 * @ type      : vseg type.
122 ******************************************************************************************/
123void vseg_init_flags( vseg_t      * vseg,
124                          vseg_type_t   type );
125
126/*******************************************************************************************
127 * This function initializes a local vseg descriptor from values contained in a reference
128 * remote vseg descriptor. It does NOT register the vseg in the local VMM.
129 *******************************************************************************************
130 * @ vseg      : pointer on the vseg descriptor.
131 * @ ref_xp    : extended pointer on the reference vseg descriptor.
132 ******************************************************************************************/
133void vseg_init_from_ref( vseg_t * vseg,
134                         xptr_t   ref_xp );
135
136
137#endif /* _VSEG_H_ */
Note: See TracBrowser for help on using the repository browser.