[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 | |
---|
| 32 | struct 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] | 41 | typedef enum |
---|
[1] | 42 | { |
---|
[651] | 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 */ |
---|
[623] | 49 | |
---|
[651] | 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 */ |
---|
[407] | 53 | } |
---|
| 54 | vseg_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 | |
---|
| 75 | typedef 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 | } |
---|
| 90 | vseg_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] | 98 | char * 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] | 106 | vseg_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] | 114 | void vseg_free( vseg_t * vseg ); |
---|
| 115 | |
---|
[409] | 116 | /******************************************************************************************* |
---|
[651] | 117 | * This function initializes the "flags" field for a local <vseg> descriptor, |
---|
| 118 | * depending on the vseg <type>. |
---|
[409] | 119 | ******************************************************************************************* |
---|
[1] | 120 | * @ vseg : pointer on the vseg descriptor. |
---|
| 121 | * @ type : vseg type. |
---|
[409] | 122 | ******************************************************************************************/ |
---|
[651] | 123 | void vseg_init_flags( vseg_t * vseg, |
---|
| 124 | vseg_type_t type ); |
---|
[1] | 125 | |
---|
[409] | 126 | /******************************************************************************************* |
---|
[1] | 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. |
---|
[409] | 129 | ******************************************************************************************* |
---|
[1] | 130 | * @ vseg : pointer on the vseg descriptor. |
---|
[16] | 131 | * @ ref_xp : extended pointer on the reference vseg descriptor. |
---|
[409] | 132 | ******************************************************************************************/ |
---|
[1] | 133 | void vseg_init_from_ref( vseg_t * vseg, |
---|
[16] | 134 | xptr_t ref_xp ); |
---|
[1] | 135 | |
---|
| 136 | |
---|
| 137 | #endif /* _VSEG_H_ */ |
---|