Index: trunk/hal/generic/hal_switch.h
===================================================================
--- trunk/hal/tsar_mips32/core/hal_switch.h	(revision 367)
+++ trunk/hal/generic/hal_switch.h	(revision 407)
@@ -1,15 +1,16 @@
 /*
- * hal_switch.h - TSAR architecture context switch function
+ * hal_switch.h - Generic architecture context switch function
  * 
- * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
- * Copyright (c) 2011,2012 UPMC Sorbonne Universites
+ * Authorg   Alain Greiner  (2017)
+ *
+ * Copyright (c) UPMC Sorbonne Universites
  * 
- * This file is part of ALMOS-kernel.
+ * This file is part of ALMOS-MKH.
  *
- * ALMOS-kernel is free software; you can redistribute it and/or modify it
+ * ALMOS-MKH is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by
  * the Free Software Foundation; version 2.0 of the License.
  *
- * ALMOS-kernel is distributed in the hope that it will be useful, but
+ * ALMOS-MKH is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
@@ -17,5 +18,5 @@
  *
  * You should have received a copy of the GNU General Public License
- * along with ALMOS-kernel; if not, write to the Free Software Foundation,
+ * along with ALMOS-MKH; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
@@ -24,23 +25,43 @@
 #define _HAL_SWITCH_H_
 
+struct thread_s;
+
 /*************************************************************************************
- * The hal_do_switch() function is an assembly level code called by the
- * hal_cpu_context_switch() function to make the actual context swich.
- * The hal_cpu_context_t structure used to store a core context is defined
- * in the TSAR specific hal_context.c file.
- * The following core registers are saved in the old context & and restored
- * from the new context:
- * - GPR : all, but (zero, k0, k1), plus (hi, lo)
- * - CP0 : c0_th , c0_sr 
- * - CP2 : c2_ptpr , C2_mode, C2_epc
- * When the switch is completed, it jumps to address contained in register $31
- * of the new context.
+ * The hal_do_cpu_switch() function is an assembly level function, called by the
+ * sched_yield() function, to make a CPU context switch. 
+ * The current thread CPU context is identified by the <ctx_current> pointer.
+ * The new thread CPU context is identified by the <ctx_next> pointer.
+ * The architecture specific hal_cpu_context_t structure used to store a CPU context
+ * is defined in the architecture specific hal_context.c file.
+ * This function does NOT modify any register before saving values into context.
+ * When the switch is completed, it jumps to address contained in the relevant
+ * register of the new thread CPU context.
  *************************************************************************************
- * @ ctx_old  : local pointer on the old thread context.
- * @ ctx_new  : local pointer on the new thread context.
+ * @ ctx_current  : local pointer on current thread CPU context.
+ * @ ctx_next     : local pointer on new thread CPU context.
  ************************************************************************************/
-void hal_do_switch( void * ctx_old,
-                    void * ctx_new );
+void hal_do_cpu_switch( void * ctx_old,
+                        void * ctx_new );
 
+/*************************************************************************************
+ * The hal_do_cpu_save() function is an assembly level function, called by the
+ * sys_fork() system call to save the parent thread register values to a child
+ * CPU context identified by the <ctx> pointer.
+ * This function does NOT modify any register before saving values into context.
+ * The architecture specific hal_cpu_context_t structure used to store a CPU context
+ * is defined in the architecture specific hal_context.c file.
+ * Two context slots are not saved from the calling thread registers values :
+ * - the "current_thread" slot is set from the value defined by the <thread> argument.
+ * - the "stack_pointer" slot is set by adding the value defined by the <offset>
+ *   argument to the current sp register value.
+ * When the save is completed, it simply returns to the calling function.
+ *************************************************************************************
+ * @ ctx     : local pointer on target thread CPU context.
+ * @ thread  : local pointer on target thread descriptor.
+ * @ offset  : kernel stack pointer offset (&child - &parent).
+ ************************************************************************************/
+void hal_do_cpu_save( void * ctx,
+                      void * thread,
+                      int    offset );
 
 #endif	/* _HAL_SWITCH_H_ */
