| 1 | /* |
|---|
| 2 | * hal_switch.h - Generic architecture context switch function |
|---|
| 3 | * |
|---|
| 4 | * Authorg Alain Greiner (2017) |
|---|
| 5 | * |
|---|
| 6 | * Copyright (c) UPMC Sorbonne Universites |
|---|
| 7 | * |
|---|
| 8 | * This file is part of ALMOS-MKH. |
|---|
| 9 | * |
|---|
| 10 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
|---|
| 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 | * |
|---|
| 14 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
|---|
| 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 |
|---|
| 20 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
|---|
| 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 | |
|---|
| 27 | struct thread_s; |
|---|
| 28 | |
|---|
| 29 | /************************************************************************************* |
|---|
| 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. |
|---|
| 39 | ************************************************************************************* |
|---|
| 40 | * @ ctx_current : local pointer on current thread CPU context. |
|---|
| 41 | * @ ctx_next : local pointer on new thread CPU context. |
|---|
| 42 | ************************************************************************************/ |
|---|
| 43 | void hal_do_cpu_switch( void * ctx_old, |
|---|
| 44 | void * ctx_new ); |
|---|
| 45 | |
|---|
| 46 | /************************************************************************************* |
|---|
| 47 | * The hal_do_cpu_save() function is an assembly level function, called by the |
|---|
| 48 | * hal_cpu_context_save() functio to save the calling CPU register values to a |
|---|
| 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 | * When the save is completed, it simply returns to the calling function. |
|---|
| 54 | ************************************************************************************* |
|---|
| 55 | * @ ctx : local pointer on CPU context. |
|---|
| 56 | ************************************************************************************/ |
|---|
| 57 | void hal_do_cpu_save( void * ctx ); |
|---|
| 58 | |
|---|
| 59 | #endif /* _HAL_SWITCH_H_ */ |
|---|