Changeset 625 for trunk/hal/generic/hal_context.h
- Timestamp:
- Apr 10, 2019, 10:09:39 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/generic/hal_context.h
r457 r625 2 2 * hal_context.h - Generic Thread Context Access API definition. 3 3 * 4 * Author Alain Greiner (2016 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 31 31 // and hal_fpu_context_t, defined in hal_context.c file, that are accessed with generic 32 32 // void* pointers stored in the thread descriptor. 33 // - the "hal_c ontext_t" struct is used forthe CPU registers values at context switch.34 // - the "hal_fpu_context_t" struct is used for the FPU registers when required.33 // - the "hal_cpu_context_t" struct saves the CPU registers values at context switch. 34 // - the "hal_fpu_context_t" struct saves the FPU registers values at FPU switch. 35 35 ////////////////////////////////////////////////////////////////////////////////////////// 36 36 … … 56 56 57 57 /**************************************************************************************** 58 * This function is used to implement the fork() system call. 59 * 1) It saves in a remote (child) thread CPU context the current CPU registers values. 60 * Three slots are not simple copies of the parent registers values : 61 * - the thread pointer is set to the child thread local pointer. 62 * - the stack pointer is set to parrent SP + (child_base - parent_base). 63 * - the status register is set to kernel mode with IRQ disabled. 64 * 2) It copies the content of the calling (parent) thread kernel_stack, 65 * to the remote (child) thread kernel_stack. 58 * This function is called the sys_fork() function to complete the fork mechanism. 59 * It is called by th local parent thread to initialize the CPU context of the remote 60 * child thread, identified by the <thread_xp> argument. 61 * It makes three actions: 62 * 1) It copies the current values of the CPU registers of the core running the parent 63 * thread to the remote child CPU context. 64 * 2) It patches four slots of this remote child CPU context: 65 * - the c0_th slot is set to the child thread descriptor pointer. 66 * - the sp_29 slot is set to the child kernel stack pointer. 67 * - the c0_sr slot is set to kernel mode with IRQ disabled. 68 * - the c2_ptpr slot is set to the child process GPT value. 69 * 3) It copies the content of the parent thread kernel_stack, to the child thread 70 * kernel_stack, because the COW mechanism is not available on architectures where 71 * the data MMU is de-activated in kernel mode. 66 72 **************************************************************************************** 67 * @ thread_xp : extended pointer on the remotethread descriptor.73 * @ thread_xp : extended pointer on the child thread descriptor. 68 74 ***************************************************************************************/ 69 75 void hal_cpu_context_fork( xptr_t thread_xp );
Note: See TracChangeset
for help on using the changeset viewer.