Ignore:
Timestamp:
Nov 7, 2017, 3:08:12 PM (6 years ago)
Author:
alain
Message:

First implementation of fork/exec.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/hal/generic/hal_switch.h

    r405 r407  
    11/*
    2  * hal_switch.h - TSAR architecture context switch function
     2 * hal_switch.h - Generic architecture context switch function
    33 *
    4  * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
    5  * Copyright (c) 2011,2012 UPMC Sorbonne Universites
     4 * Authorg   Alain Greiner  (2017)
     5 *
     6 * Copyright (c) UPMC Sorbonne Universites
    67 *
    7  * This file is part of ALMOS-kernel.
     8 * This file is part of ALMOS-MKH.
    89 *
    9  * ALMOS-kernel is free software; you can redistribute it and/or modify it
     10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
    1011 * under the terms of the GNU General Public License as published by
    1112 * the Free Software Foundation; version 2.0 of the License.
    1213 *
    13  * ALMOS-kernel is distributed in the hope that it will be useful, but
     14 * ALMOS-MKH is distributed in the hope that it will be useful, but
    1415 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1516 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    1718 *
    1819 * You should have received a copy of the GNU General Public License
    19  * along with ALMOS-kernel; if not, write to the Free Software Foundation,
     20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
    2021 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    2122 */
     
    2425#define _HAL_SWITCH_H_
    2526
     27struct thread_s;
     28
    2629/*************************************************************************************
    27  * The hal_do_switch() function is an assembly level code called by the
    28  * hal_cpu_context_switch() function to make the actual context swich.
    29  * The hal_cpu_context_t structure used to store a core context is defined
    30  * in the TSAR specific hal_context.c file.
    31  * The following core registers are saved in the old context & and restored
    32  * from the new context:
    33  * - GPR : all, but (zero, k0, k1), plus (hi, lo)
    34  * - CP0 : c0_th , c0_sr
    35  * - CP2 : c2_ptpr , C2_mode, C2_epc
    36  * When the switch is completed, it jumps to address contained in register $31
    37  * of the new context.
     30 * The hal_do_cpu_switch() function is an assembly level function, called by the
     31 * sched_yield() function, to make a CPU context switch.
     32 * The current thread CPU context is identified by the <ctx_current> pointer.
     33 * The new thread CPU context is identified by the <ctx_next> pointer.
     34 * The architecture specific hal_cpu_context_t structure used to store a CPU context
     35 * is defined in the architecture specific hal_context.c file.
     36 * This function does NOT modify any register before saving values into context.
     37 * When the switch is completed, it jumps to address contained in the relevant
     38 * register of the new thread CPU context.
    3839 *************************************************************************************
    39  * @ ctx_old  : local pointer on the old thread context.
    40  * @ ctx_new  : local pointer on the new thread context.
     40 * @ ctx_current  : local pointer on current thread CPU context.
     41 * @ ctx_next     : local pointer on new thread CPU context.
    4142 ************************************************************************************/
    42 void hal_do_switch( void * ctx_old,
    43                     void * ctx_new );
     43void hal_do_cpu_switch( void * ctx_old,
     44                        void * ctx_new );
    4445
     46/*************************************************************************************
     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 child
     49 * CPU context identified by the <ctx> pointer.
     50 * This function does NOT modify any register before saving values into context.
     51 * The architecture specific hal_cpu_context_t structure used to store a CPU context
     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 * When the save is completed, it simply returns to the calling function.
     58 *************************************************************************************
     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).
     62 ************************************************************************************/
     63void hal_do_cpu_save( void * ctx,
     64                      void * thread,
     65                      int    offset );
    4566
    4667#endif  /* _HAL_SWITCH_H_ */
Note: See TracChangeset for help on using the changeset viewer.