source: trunk/hal/generic/hal_switch.h @ 660

Last change on this file since 660 was 654, checked in by alain, 5 years ago

euh...

File size: 3.7 KB
RevLine 
[367]1/*
[407]2 * hal_switch.h - Generic architecture context switch function
[367]3 *
[407]4 * Authorg   Alain Greiner  (2017)
5 *
6 * Copyright (c) UPMC Sorbonne Universites
[367]7 *
[407]8 * This file is part of ALMOS-MKH.
[367]9 *
[407]10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
[367]11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
[407]14 * ALMOS-MKH is distributed in the hope that it will be useful, but
[367]15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
[407]20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
[367]21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef _HAL_SWITCH_H_
25#define _HAL_SWITCH_H_
26
[407]27struct thread_s;
28
[367]29/*************************************************************************************
[457]30 * This assembly level function is called by the sched_yield() function,
31 * to make a CPU context switch.
32 * The current thread CPU context is identified by the <ctx_old> pointer.
33 * The new thread CPU context is identified by the <ctx_new> pointer.
[407]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.
[367]39 *************************************************************************************
[407]40 * @ ctx_current  : local pointer on current thread CPU context.
41 * @ ctx_next     : local pointer on new thread CPU context.
[367]42 ************************************************************************************/
[407]43void hal_do_cpu_switch( void * ctx_old,
44                        void * ctx_new );
[367]45
[407]46/*************************************************************************************
[457]47 * This assembly level function is called by the hal_cpu_context_fork() function.
48 * It save the calling CPU register values to a CPU context identified by <ctx>.
[407]49 * This function does NOT modify any register before saving values into context.
50 * The architecture specific hal_cpu_context_t structure used to store a CPU context
51 * is defined in the architecture specific hal_context.c file.
52 * When the save is completed, it simply returns to the calling function.
53 *************************************************************************************
[408]54 * @ ctx     : local pointer on CPU context.
[407]55 ************************************************************************************/
[408]56void hal_do_cpu_save( void * ctx );
[367]57
[457]58/*************************************************************************************
59 * This assembly level function, is called by the hal_cpu_context_exec() function.
60 * It restore the calling CPU register values from a CPU context identified by <ctx>.
61 * The architecture specific hal_cpu_context_t structure used to store a CPU context
[654]62 * is defined in the architecture specific hal_context.c file. When the restore is
63 * completed, it jumps to the entry point of the new process main thread.
64 *
65 * Implementation Note :
66 * - on the TSAR architecture, register ra_31 must contain a pointer on the
67 *   eret() function, and register c0_epc  must contain the new thread entry point.
68 * - on I86 architecture TODO...
[457]69 *************************************************************************************
70 * @ ctx     : local pointer on CPU context.
71 ************************************************************************************/
72void hal_do_cpu_restore( void * ctx );
73
[367]74#endif  /* _HAL_SWITCH_H_ */
Note: See TracBrowser for help on using the repository browser.