Changeset 629 for trunk/hal/generic
- Timestamp:
- May 17, 2019, 9:27:04 AM (6 years ago)
- Location:
- trunk/hal/generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/generic/hal_gpt.h
r625 r629 61 61 #define GPT_COW 0x0400 /*! PTE must be copied on write */ 62 62 #define GPT_SWAP 0x0800 /*! PTE swapped on disk (not implemented yet) */ 63 #define GPT_LOCKED 0x1000 /*! PTE is protected against concurrent access*/63 #define GPT_LOCKED 0x1000 /*! PTE is currently accessed by a thread */ 64 64 65 65 /**************************************************************************************** … … 76 76 77 77 /**************************************************************************************** 78 * This function allocates physical memory for first level page table (PT1),78 * This function allocates physical memory for a local GPT, 79 79 * and initializes the GPT descriptor, creating an empty GPT. 80 80 **************************************************************************************** … … 87 87 * This function releases all memory dynamically allocated for a generic page table. 88 88 * For a multi-levels radix tree implementation, it includes all nodes in the tree. 89 * If the calling thread is running in the reference cluster, it checks that user PTE90 * entries are unmapped, and releases the mapped physical pages.91 * The kernel pages are not released.92 89 **************************************************************************************** 93 90 * @ gpt : pointer on generic page table descriptor. … … 96 93 97 94 /**************************************************************************************** 98 * This function prints on the kernel terminal the content of a generic page table. 99 **************************************************************************************** 100 * @ process : pointer on local process descriptor. 101 ***************************************************************************************/ 102 void hal_gpt_display( struct process_s * process ); 103 104 /**************************************************************************************** 105 * This blocking function gets a lock on a PTE (Page Table Entry) identified 106 * by its VPN, and returns only when the PTE has been successfully locked. 107 * If the target PTE is not present, it allocates and maps a physical page. 108 * A big page cannot be locked. 109 **************************************************************************************** 110 * @ gpt : pointer on the generic page table 95 * This blocking function atomically set the GPT_LOCKED attribute in a target PTE 96 * of a remote GPT identified by the <gpt_xp> and <vpn> arguments, after checking 97 * (in a busy waiting loop) that this attribute has been reset. 98 * Then, it returns in the <attr> and <ppn> buffers the current value of the PTE. 99 * It allocates memory required by the GPT implementation to register this lock 100 * in the PTE when required. 101 * WARNING : Only small pages can be locked. 102 **************************************************************************************** 103 * @ gpt_xp : [in] extended pointer on the generic page table. 104 * @ vpn : [in] virtual page number of the target PTE. 105 * @ attr : [out] local buffer for GPT attributes. 106 * @ ppn : [out] local buffer for physical page number. 107 * @ returns 0 if success / return -1 if error (no memory or big page). 108 ***************************************************************************************/ 109 error_t hal_gpt_lock_pte( xptr_t gpt_xp, 110 vpn_t vpn, 111 uint32_t * attr, 112 ppn_t * ppn ); 113 114 /**************************************************************************************** 115 * This function atomically reset the GPT_LOCKED attribute in a target PTE in a 116 * remote GPT identified by the <gpt_xp> and <vpn> arguments. 117 **************************************************************************************** 118 * @ gpt_xp : pointer on the generic page table 111 119 * @ vpn : virtual page number of the target PTE. 112 * @ returns 0 if success / return ENOMEM or EINVAL if error. 113 ***************************************************************************************/ 114 error_t hal_gpt_lock_pte( gpt_t * gpt, 115 vpn_t vpn ); 116 117 /**************************************************************************************** 118 * This function releases the lock on a PTE identified by its VPN. 119 **************************************************************************************** 120 * @ gpt : pointer on the generic page table 121 * @ vpn : virtual page number of the target PTE. 122 * @ returns 0 if success / returns EINVAL if error. 123 ***************************************************************************************/ 124 error_t hal_gpt_unlock_pte( gpt_t * gpt, 125 vpn_t vpn ); 126 127 /**************************************************************************************** 128 * This function maps in a - local or remote - GPT identified by the <gpt_xp> argument 129 * an entry identified by the <vpn> argument, as defined by <ppn> and <attr> arguments. 130 * It allocates physical memory for the GPT PT2, using a RPC_PMEM_GET_PAGES if required. 131 **************************************************************************************** 132 * @ gpt_xp : [in] pointer on the page table 120 ***************************************************************************************/ 121 void hal_gpt_unlock_pte( xptr_t gpt_xp, 122 vpn_t vpn ); 123 124 /**************************************************************************************** 125 * This low level function maps a new PTE or modifies an existing PTE in a remote GPT 126 * identified by the <gpt_xp> and <vpn> arguments, as defined by <ppn> and <attr> args. 127 * This function can be used for both a small page (PTE2), and a big page (PTE1). 128 * 129 * WARNING : For a small page, it checks that the GPT_LOCKED attribute has been 130 * previously set, to prevent concurrent accesses. 131 **************************************************************************************** 132 * @ gpt_xp : [in] extended pointer on the page table 133 133 * @ vpn : [in] virtual page number 134 * @ attr : [in] genericattributes134 * @ attr : [in] GPT attributes 135 135 * @ ppn : [in] physical page number 136 * @ returns 0 if success / returns ENOMEM if error 137 ***************************************************************************************/ 138 error_t hal_gpt_set_pte( xptr_t gpt_xp, 139 vpn_t vpn, 140 uint32_t attr, 141 ppn_t ppn ); 142 143 /**************************************************************************************** 144 * This function unmaps all pages identified by the <vpn> argument from the local GPT 145 * identified by the <gpt> argument. 146 * It does NOT release the physical memory allocated for the unmapped pages. 147 **************************************************************************************** 148 * @ gpt : [in] pointer on the local page table 149 * @ vpn : [in] page index in virtual space 150 ***************************************************************************************/ 151 void hal_gpt_reset_pte( gpt_t * gpt, 136 ***************************************************************************************/ 137 void hal_gpt_set_pte( xptr_t gpt_xp, 138 vpn_t vpn, 139 uint32_t attr, 140 ppn_t ppn ); 141 142 /**************************************************************************************** 143 * This low level function unmaps and unlocks a PTE from a remote GPT identified by the 144 * <gpt_xp> and <vpn> arguments. It does NOT release the allocated physical memory. 145 * This function can be used for both a small page (PTE2), and a big page (PTE1). 146 **************************************************************************************** 147 * @ gpt_xp : [in] extended pointer on the page table 148 * @ vpn : [in] virtual page number. 149 ***************************************************************************************/ 150 void hal_gpt_reset_pte( xptr_t gpt_xp, 152 151 vpn_t vpn ); 153 152 154 153 /**************************************************************************************** 155 * This function returns in the <attr> and <ppn> arguments the current values stored 156 * in a - local or remote - GPT entry, identified by the <gpt> and <vpn> arguments. 157 **************************************************************************************** 158 * @ gpt_xp : [in] extended pointer on the page table 159 * @ vpn : [in] virtual page number 160 * @ attr : [out] generic attributes 161 * @ ppn : [out] physical page number 154 * This low level function returns in the <attr> and <ppn> arguments the current values 155 * of a PTE in a a remote GPT, identified by the <gpt> and <vpn> arguments. 156 * This function can be used for both a small page (PTE2), and a big page (PTE1). 157 **************************************************************************************** 158 * @ gpt_xp : [in] extended pointer on the page table. 159 * @ vpn : [in] virtual page number. 160 * @ attr : [out] local buffer for generic attributes. 161 * @ ppn : [out] local buffer for physical page number. 162 162 ***************************************************************************************/ 163 163 void hal_gpt_get_pte( xptr_t gpt_xp, … … 195 195 196 196 /**************************************************************************************** 197 * This function returns true if the MAPPED and SMALL flags are both set198 * for a PTE defined by <gpt> and <vpn> arguments.199 ****************************************************************************************200 * @ gpt : [in] pointer on the page table201 * @ vpn : [in] virtual page number202 * @ returns true if MAPPED is set.203 ***************************************************************************************/204 bool_t hal_gpt_pte_is_mapped( gpt_t * gpt,205 vpn_t vpn );206 207 /****************************************************************************************208 * This function returns true if the MAPPED, SMALL, and COW flags are all set209 * for a PTE defined by <gpt> and <vpn> arguments.210 ****************************************************************************************211 * @ gpt : [in] pointer on the page table212 * @ vpn : [in] virtual page number213 * @ returns true if COW is set.214 ***************************************************************************************/215 bool_t hal_gpt_pte_is_cow( gpt_t * gpt,216 vpn_t vpn );217 218 /****************************************************************************************219 197 * This function atomically set the COW flag and reset the WRITABLE flag for all PTEs 220 198 * of a remote GPT identified by the <gpt_xp>, <vpn_base>, and <vpn_size arguments. 221 * It does nothing if the remote PTE is not MAPPED and SMALL. 199 * It does NOT require the GPT_LOCKED attribute to be set in the target PTE. 200 * It does nothing if the PTE is not MAPPED and SMALL. 222 201 **************************************************************************************** 223 202 * @ gpt_xp : [in] extended pointer on the remote GPT. … … 233 212 * It modifies an existing entry identified by the <vpn> argument in a remote GPT 234 213 * identified by the <gpt_xp> argument, using remote accesses. 214 * It does NOT require the GPT_LOCKED attribute to be set in the target PTE. 235 215 * It cannot fail, because only MAPPED & SMALL entries are modified. 236 216 **************************************************************************************** -
trunk/hal/generic/hal_remote.h
r619 r629 2 2 * hal_remote.h - Generic Remote Access API definition. 3 3 * 4 * Authors Mohamed Karaoui (2015) 5 * Alain Greiner (2016) 4 * Authors Alain Greiner (2016,2017,2018,2019) 6 5 * 7 6 * Copyright (c) UPMC Sorbonne Universites
Note: See TracChangeset
for help on using the changeset viewer.