Changeset 408 for trunk/hal/generic
- Timestamp:
- Dec 5, 2017, 4:20:07 PM (7 years ago)
- Location:
- trunk/hal/generic
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/generic/hal_atomic.h
r108 r408 68 68 /***************************************************************************************** 69 69 * This NON blocking function makes an atomic Compare-And-Swap on a 32 bits unsigned int 70 * shared variable, returning a Boolean to indicate both success and atomicity.70 * shared variable, returning a Boolean to indicate success. 71 71 ***************************************************************************************** 72 72 * @ ptr : pointer on the shared variable 73 73 * @ old : expected value for the shared variable 74 74 * @ new : value to be written if success 75 * @ return true if (current == old) and (access is atomic)75 * @ return true if success. 76 76 ****************************************************************************************/ 77 77 bool_t hal_atomic_cas( uint32_t * ptr, -
trunk/hal/generic/hal_context.h
r407 r408 57 57 58 58 /**************************************************************************************** 59 * This function display the following slots of a thread CPU context: 60 * - GPR : gp_28 , sp_29 , ra_31 61 * - CP0 : c0_sr , c0_th , c0_epc 62 * - CP2 : c2_ptpr , c2-mode 59 * This function is used to implement the fork() system call. 60 * 1) It saves in a remote (child) thread CPU context the current CPU registers values. 61 * Three slots are not simple copies of the parent registers values : 62 * - the thread pointer is set to the child thread local pointer. 63 * - the stack pointer is set to parrent SP + (child_base - parent_base). 64 * - the status register is set to kernel mode with IRQ disabled. 65 * 2) It copies the content of the calling (parent) thread kernel_stack, 66 * to the remote (child) thread kernel_stack. 63 67 **************************************************************************************** 64 * @ thread : local pointer on the thread descriptor.68 * @ thread_xp : extended pointer on the remote thread descriptor. 65 69 ***************************************************************************************/ 66 void hal_cpu_context_display( struct thread_s * thread ); 70 void hal_cpu_context_fork( xptr_t thread_xp ); 71 72 /**************************************************************************************** 73 * This function display some slots of the CPU context. 74 * - For the MIPS32 : 75 * . GPR : gp_28 , sp_29 , ra_31 76 * . CP0 : c0_sr , c0_th , c0_epc 77 * . CP2 : c2_ptpr , c2-mode 78 * - For X86 TODO : 79 **************************************************************************************** 80 * @ thread_xp : extended pointer on the thread descriptor. 81 ***************************************************************************************/ 82 void hal_cpu_context_display( xptr_t thread_xp ); 67 83 68 84 /**************************************************************************************** … … 106 122 107 123 /**************************************************************************************** 108 * This function saves in the thread uzone the FPU registers values. 124 * This function is used to implement the fork() system call. 125 * It saves in a remote thread FPU context the current FPU registers values. 109 126 **************************************************************************************** 110 * @ thread : pointer on the thread descriptor.127 * @ thread_xp : extended pointer on the remote thread descriptor. 111 128 ***************************************************************************************/ 112 void hal_fpu_context_save( struct thread_s * thread);129 void hal_fpu_context_save( xptr_t thread_xp ); 113 130 114 131 /**************************************************************************************** 115 * This function restores from the thread uzonethe FPU registers values.132 * This function restores from the calling thread FPU context the FPU registers values. 116 133 **************************************************************************************** 117 134 * @ thread : pointer on the thread descriptor. -
trunk/hal/generic/hal_exception.h
r380 r408 45 45 // a message on TXT0, disable IRQs and call the hal_core_sleep() function. 46 46 // 47 // For all exceptions, the faulty core context has been saved in a registers array 48 // stored in the user thread descriptor (for a core in user mode), and in the 49 // kernel stack (for a core in kernel mode). 50 // 51 // Any architecture specific implementation must implement this API. 47 // For all exceptions, the faulty core registers have been saved in the "uzone" 48 // that can be accessed through the "uzone" pointer stored in thread descriptor. 52 49 ////////////////////////////////////////////////////////////////////////////////////////// 53 50 54 /**** forward declaration ****/55 56 struct thread_s;57 51 58 52 /***************************************************************************************** 59 53 * This function is called by the hal_kentry() function when an exception is detected by 60 54 * the hardware for a given thread running on a given core. 61 *****************************************************************************************62 * @ this : pointer on the faulty thread descriptor.63 * @ regs_tbl : array containing the core registers values saved by hal_kentry().64 55 ****************************************************************************************/ 65 void hal_do_exception( struct thread_s * this, 66 reg_t * regs_tbl ); 56 void hal_do_exception(); 67 57 68 58 #endif // _HAL_EXCEPTION_H_ -
trunk/hal/generic/hal_gpt.h
r407 r408 35 35 // dependent, and is defined as (CONFIG_USER_SPACE_SIZE / CONFIG_PPM_PAGE_SIZE). 36 36 // - Each entry contains a Physical Page Number (ppn_t type), and a set of attributes, 37 // defined as masks ona 32 bits-vector.37 // defined as a 32 bits-vector. 38 38 // 39 39 // Any arch-specific implementation must implement this API. … … 126 126 127 127 /**************************************************************************************** 128 * This function map s a page tableentry identified by its VPN, from values defined128 * This function map a local GPT entry identified by its VPN, from values defined 129 129 * by the ppn and attr arguments. It allocates physical memory for the local generic 130 130 * page table itself if required. … … 132 132 * @ gpt : [in] pointer on the page table 133 133 * @ vpn : [in] virtual page number 134 * @ attr : [in] generic attributes 134 135 * @ ppn : [in] physical page number 135 * @ attr : [in] generic attributes136 136 * @ returns 0 if success / returns ENOMEM if error 137 137 ***************************************************************************************/ 138 138 error_t hal_gpt_set_pte( gpt_t * gpt, 139 139 vpn_t vpn, 140 ppn_t ppn,141 uint32_t attr);140 uint32_t attr, 141 ppn_t ppn ); 142 142 143 143 /**************************************************************************************** … … 153 153 154 154 /**************************************************************************************** 155 * This function returns in the ppn and attr arguments the value of a page table156 * entry identified by its VPN. It returns attr == 0 if the page is not mapped.157 **************************************************************************************** 158 * @ gpt 155 * This function returns in the <attr> and <ppn> arguments the current values 156 * stored in a GPT entry, identified by the <gpt> and <vpn> arguments. 157 **************************************************************************************** 158 * @ gpt_xp : [in] pointer on the page table 159 159 * @ vpn : [in] virtual page number 160 160 * @ attr : [out] generic attributes … … 167 167 168 168 /**************************************************************************************** 169 * This function is used to implement the "fork" system call: It copies all valid GPT170 * entries for a given vseg identified by the <vpn_base> and <vpn_size> arguments,171 * from the source <src_gpt> to the <dst_gpt>.169 * This function is used to implement the "fork" system call: It copies one GPT entry 170 * identified by the <vpn> argument, from a remote <src_gpt_xp> to a local <dst_gpt>. 171 * It does nothing if the source PTE is not MAPPED and SMALL. 172 172 * It optionnally activates the "Copy on Write" mechanism: when the <cow> argument is 173 * true, the GPT_WRITABLE flag is reset, and the GPT_COW flag is set for each valid 174 * entry in the destination GPT (The data page will be dynamically allocated an copied 175 * when a write access is detected). 176 **************************************************************************************** 177 * @ dst_gpt : [in] pointer on the destination GPT. 178 * @ src_gpt : [in] pointer on the source GPT. 179 * @ vpn_base : [in] first vpn in vseg. 180 * @ vpn_size : [in] number of pages in vseg. 181 * @ cow : [in] activate the COPY-On-Write mechanism if true. 182 ***************************************************************************************/ 183 error_t hal_gpt_copy( gpt_t * dst_gpt, 184 gpt_t * src_gpt, 185 vpn_t vpn_base, 186 vpn_t vpn_size, 187 bool_t cow ); 188 189 /**************************************************************************************** 190 * This function returns GPT_COW flag for a PTE defined by <gpt> and <vpn> arguments. 173 * true: the GPT_WRITABLE flag is reset, and the GPT_COW flag is set. 174 * A new second level PT2(s) is allocated for destination GPT if required. 175 * It returns in the <ppn> and <mapped> arguments the PPN value for the copied PTE, 176 * and a boolean indicating if the PTE is mapped and small, and was actually copied. 177 **************************************************************************************** 178 * @ dst_gpt : [in] local pointer on the local destination GPT. 179 * @ src_gpt_xp : [in] extended pointer on the remote source GPT. 180 * @ vpn_base : [in] vpn defining the PTE to be copied. 181 * @ cow : [in] activate the COPY-On-Write mechanism if true. 182 * @ ppn : [out] PPN value (only if mapped is true). 183 * @ mapped : [out] true if src_gpt[vpn] actually copied to dst_gpt[vpn]. 184 * @ return 0 if success / return -1 if no memory for a new PT2. 185 ***************************************************************************************/ 186 error_t hal_gpt_pte_copy( gpt_t * dst_gpt, 187 xptr_t src_gpt_xp, 188 vpn_t vpn, 189 bool_t cow, 190 ppn_t * ppn, 191 bool_t * mapped ); 192 193 /**************************************************************************************** 194 * This function returns true if the MAPPED and SMALL flags are both set 195 * for a PTE defined by <gpt> and <vpn> arguments. 191 196 **************************************************************************************** 192 197 * @ gpt : [in] pointer on the page table 193 198 * @ vpn : [in] virtual page number 194 * @ returns true if GPT_COW is set. 199 * @ returns true if MAPPED is set. 200 ***************************************************************************************/ 201 bool_t hal_gpt_pte_is_mapped( gpt_t * gpt, 202 vpn_t vpn ); 203 204 /**************************************************************************************** 205 * This function returns true if the MAPPED, SMALL, and COW flags are all set 206 * for a PTE defined by <gpt> and <vpn> arguments. 207 **************************************************************************************** 208 * @ gpt : [in] pointer on the page table 209 * @ vpn : [in] virtual page number 210 * @ returns true if COW is set. 195 211 ***************************************************************************************/ 196 212 bool_t hal_gpt_pte_is_cow( gpt_t * gpt, 197 213 vpn_t vpn ); 198 214 215 /**************************************************************************************** 216 * This function atomically flip the COW flag and WRITABLE flag for all PTEs 217 * of a remote GPT identified by the <gpt_xp>, <vpn_base>, and <vpn_size arguments. 218 * - it set COW and reset WRITABLE when <set_cow> argument is true and PTE is WRITABLE. 219 * - it set WRITABLE and reset COW when <set_cow> is false and PTE is COW. 220 * It does nothing if the remote PTE is not MAPPED and SMALL. 221 * It is called when a fork is executed, or when a COW must be resolved. 222 **************************************************************************************** 223 * @ set_cow : [in] set COW & reset WRITABLE if true / do the opposite if false. 224 * @ gpt_xp : [in] extended pointer on the remote GPT. 225 * @ vpn_base : [in] first virtual page. 226 * @ vpn_size : [in] number of pages. 227 ***************************************************************************************/ 228 void hal_gpt_flip_cow( bool_t set_cow, 229 xptr_t gpt_xp, 230 vpn_t vpn_base, 231 vpn_t vpn_size ); 232 233 /**************************************************************************************** 234 * This function is used to maintain coherence amongst the multiple GPT copies. 235 * It modifies an existing entry identified by the <vpn> argument in a remote GPT 236 * identified by the <gpt_xp> argument, using remote accesses. 237 * It cannot fail, because only MAPPED & SMALL entries are modified. 238 **************************************************************************************** 239 * @ gpt_xp : [in] extended pointer on the page table 240 * @ vpn : [in] virtual page number 241 * @ attr : [in] generic attributes 242 * @ ppn : [in] physical page number 243 ***************************************************************************************/ 244 void hal_gpt_update_pte( xptr_t gpt_xp, 245 vpn_t vpn, 246 uint32_t attr, 247 ppn_t ppn ); 248 199 249 200 250 #endif /* _GPT_H_ */ 251 -
trunk/hal/generic/hal_interrupt.h
r17 r408 27 27 #include <hal_types.h> 28 28 29 /////////////////////////////////////////////////////////////////////////////////////// ///29 /////////////////////////////////////////////////////////////////////////////////////// 30 30 // Architecture specific interrupt handler API 31 31 // 32 // The interrupted thread context (core registers) has been saved by the hal_kentry 33 // function, in the cpu_uzone array stored in the user thread descriptor (for a core in 34 // user mode), or in the kernel stack (for a core in kernel mode). 35 // This array can be used (or not) by the specific interrupt handler. 36 // 37 // Any architecture specific implementation must implement this API. 38 ////////////////////////////////////////////////////////////////////////////////////////// 32 // The interrupted thread context (CPU registers) has been saved by the hal_kentry 33 // function, in the uzone array, that can be accessed through the "uzone" pointer 34 // stored in the thread descriptor. 35 /////////////////////////////////////////////////////////////////////////////////////// 39 36 40 /**** forward declaration ****/41 37 42 struct thread_s; 43 44 /****************************************************************************************** 38 /************************************************************************************** 45 39 * This function implements the TSAR_MIPS32 specific interrupt handler. 46 ****************************************************************************************** 47 * @ this : pointer on the interrupted thread. 48 * @ regs_tbl : array containing the core registers values, saved by hal_kentry. 49 *****************************************************************************************/ 50 void hal_do_interrupt( struct thread_s * this, 51 reg_t * regs_tbl ); 40 *************************************************************************************/ 41 void hal_do_interrupt(); 52 42 53 43 -
trunk/hal/generic/hal_special.h
r407 r408 49 49 /***************************************************************************************** 50 50 * This function returns the current value of the hardware cycles counter. 51 * This cycle counter is reset when the core is initialised (at each boot). 51 52 ****************************************************************************************/ 52 53 inline reg_t hal_time_stamp(); -
trunk/hal/generic/hal_switch.h
r407 r408 46 46 /************************************************************************************* 47 47 * The hal_do_cpu_save() function is an assembly level function, called by the 48 * sys_fork() system call to save the parent thread register values to a child48 * hal_cpu_context_save() functio to save the calling CPU register values to a 49 49 * CPU context identified by the <ctx> pointer. 50 50 * This function does NOT modify any register before saving values into context. 51 51 * The architecture specific hal_cpu_context_t structure used to store a CPU context 52 52 * is defined in the architecture specific hal_context.c file. 53 * Two context slots are not saved from the calling thread registers values :54 * - the "current_thread" slot is set from the value defined by the <thread> argument.55 * - the "stack_pointer" slot is set by adding the value defined by the <offset>56 * argument to the current sp register value.57 53 * When the save is completed, it simply returns to the calling function. 58 54 ************************************************************************************* 59 * @ ctx : local pointer on target thread CPU context. 60 * @ thread : local pointer on target thread descriptor. 61 * @ offset : kernel stack pointer offset (&child - &parent). 55 * @ ctx : local pointer on CPU context. 62 56 ************************************************************************************/ 63 void hal_do_cpu_save( void * ctx, 64 void * thread, 65 int offset ); 57 void hal_do_cpu_save( void * ctx ); 66 58 67 59 #endif /* _HAL_SWITCH_H_ */ -
trunk/hal/generic/hal_syscall.h
r407 r408 27 27 #include <hal_types.h> 28 28 29 /////////////////////////////////////////////////////////////////////////////////////// ///29 /////////////////////////////////////////////////////////////////////////////////////// 30 30 // Kernel-side syscall handler API 31 31 // 32 // This hal_do_syscall() function extract from the regs_tbl[] array the syscall index, 33 // and the four syscall arguments. Then it calls the generic do_syscall() kernel function, 34 // that call itself the relevant kernel function, depending on the syscall index. 32 // This hal_do_syscall() function extract from the calling thread uzone array 33 // the syscall index, and the four syscall arguments. 34 // Then it calls the generic do_syscall() function, 35 // that calls itself the relevant kernel function, depending on the syscall index. 35 36 // 36 // Any architecture specific implementation must implement this API.37 // ////////////////////////////////////////////////////////////////////////////////////////38 39 / **** forward declaration ****/40 41 struct thread_s; 37 // When the generic do_syscall function returns, it saves the return value 38 // in the UZ_VO slot of the returning thread uzone, and update the UZ_EPC slot. 39 // 40 // WARNING: The returning thread can be different from the entering thread 41 // in the case of a sys_fork() system call. 42 /////////////////////////////////////////////////////////////////////////////////////// 42 43 43 44 44 /***************************************************************************************** 45 * This function implements the ALMOS-MKH kernel_side syscall handler. 46 ***************************************************************************************** 47 * @ this : pointer on the calling thread. 48 * @ regs_tbl : array containing the core registers values, saved by hal_kentry. 49 ****************************************************************************************/ 50 void hal_do_syscall( struct thread_s * this, 51 reg_t * regs_tbl ); 45 /************************************************************************************** 46 * This function implements the syscall handler for the TSAR architecture. 47 *************************************************************************************/ 48 void hal_do_syscall(); 52 49 53 50
Note: See TracChangeset
for help on using the changeset viewer.