From da4c0dbaa0a453af6b1903554ccff1df7b98825c Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Wed, 18 Nov 2015 09:39:41 +0000 Subject: Improvements to the e200 RT port. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8507 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/rt/ports/e200/chcore.c | 57 +----------------- os/rt/ports/e200/chcore.h | 2 +- os/rt/ports/e200/compilers/GCC/chcoreasm.s | 97 ++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 56 deletions(-) create mode 100644 os/rt/ports/e200/compilers/GCC/chcoreasm.s (limited to 'os/rt') diff --git a/os/rt/ports/e200/chcore.c b/os/rt/ports/e200/chcore.c index 28fb8926b..5f410b88f 100644 --- a/os/rt/ports/e200/chcore.c +++ b/os/rt/ports/e200/chcore.c @@ -18,8 +18,8 @@ */ /** - * @file PPC/chcore.c - * @brief PowerPC architecture port code. + * @file e200/chcore.c + * @brief Power e200 port code. * * @addtogroup PPC_CORE * @{ @@ -51,57 +51,4 @@ /* Module exported functions. */ /*===========================================================================*/ -/** - * @brief Performs a context switch between two threads. - * @details This is the most critical code in any port, this function - * is responsible for the context switch between 2 threads. - * @note The implementation of this code affects directly the context - * switch performance so optimize here as much as you can. - */ -#if !defined(__DOXYGEN__) -__attribute__((naked)) -#endif -void port_dummy1(void) { - - asm (".global _port_switch"); - asm ("_port_switch:"); - asm ("subi %sp, %sp, 80"); /* Size of the intctx structure. */ - asm ("mflr %r0"); - asm ("stw %r0, 84(%sp)"); /* LR into the caller frame. */ - asm ("mfcr %r0"); - asm ("stw %r0, 0(%sp)"); /* CR. */ - asm ("stmw %r14, 4(%sp)"); /* GPR14...GPR31. */ - - asm ("stw %sp, 12(%r4)"); /* Store swapped-out stack. */ - asm ("lwz %sp, 12(%r3)"); /* Load swapped-in stack. */ - - asm ("lmw %r14, 4(%sp)"); /* GPR14...GPR31. */ - asm ("lwz %r0, 0(%sp)"); /* CR. */ - asm ("mtcr %r0"); - asm ("lwz %r0, 84(%sp)"); /* LR from the caller frame. */ - asm ("mtlr %r0"); - asm ("addi %sp, %sp, 80"); /* Size of the intctx structure. */ - asm ("blr"); -} - -/** - * @brief Start a thread by invoking its work function. - * @details If the work function returns @p chThdExit() is automatically - * invoked. - */ -#if !defined(__DOXYGEN__) -__attribute__((naked)) -#endif -void port_dummy2(void) { - - asm (".global _port_thread_start"); - asm ("_port_thread_start:"); - chSysUnlock(); - asm ("mr %r3, %r31"); /* Thread parameter. */ - asm ("mtctr %r30"); - asm ("bctrl"); /* Invoke thread function. */ - asm ("li %r0, 0"); /* MSG_OK. */ - asm ("bl chThdExit"); /* Thread termination on exit. */ -} - /** @} */ diff --git a/os/rt/ports/e200/chcore.h b/os/rt/ports/e200/chcore.h index 56c30fb57..67da6c67d 100644 --- a/os/rt/ports/e200/chcore.h +++ b/os/rt/ports/e200/chcore.h @@ -19,7 +19,7 @@ /** * @file PPC/chcore.h - * @brief PowerPC architecture port macros and structures. + * @brief Power e200 port macros and structures. * * @addtogroup PPC_CORE * @{ diff --git a/os/rt/ports/e200/compilers/GCC/chcoreasm.s b/os/rt/ports/e200/compilers/GCC/chcoreasm.s new file mode 100644 index 000000000..624c0b7a4 --- /dev/null +++ b/os/rt/ports/e200/compilers/GCC/chcoreasm.s @@ -0,0 +1,97 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio. + + This file is part of ChibiOS. + + ChibiOS 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; either version 3 of the License, or + (at your option) any later version. + + ChibiOS 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file e200/compilers/GCC/chcoreasm.s + * @brief Power Architecture port low level code. + * + * @addtogroup PPC_GCC_CORE + * @{ + */ + +/*===========================================================================*/ +/* Module constants. */ +/*===========================================================================*/ + +#if !defined(FALSE) || defined(__DOXYGEN__) +#define FALSE 0 +#endif + +#if !defined(TRUE) || defined(__DOXYGEN__) +#define TRUE 1 +#endif + +/*===========================================================================*/ +/* Code section. */ +/*===========================================================================*/ + +#define _FROM_ASM_ +#include "chconf.h" +#include "chcore.h" + +#if !defined(__DOXYGEN__) + +#if PPC_USE_VLE == TRUE + .section .text_vle, "ax" +#else + .section .text, "ax" +#endif + + .align 2 + .globl _port_switch + .type _port_switch, @function +_port_switch: + subi %sp, %sp, 80 + mflr %r0 + stw %r0, 84(%sp) + mfcr %r0 + stw %r0, 0(%sp) + stmw %r14, 4(%sp) + + stw %sp, 12(%r4) + lwz %sp, 12(%r3) + + lmw %r14, 4(%sp) + lwz %r0, 0(%sp) + mtcr %r0 + lwz %r0, 84(%sp) + mtlr %r0 + addi %sp, %sp, 80 + blr + + .align 2 + .globl _port_thread_start + .type _port_thread_start, @function +_port_thread_start: +#if CH_DBG_SYSTEM_STATE_CHECK + bl _dbg_check_unlock +#endif +#if CH_DBG_STATISTICS + bl _stats_stop_measure_crit_thd +#endif + wrteei 1 + mr %r3, %r31 + mtctr %r30 + bctrl + li %r0, 0 + bl chThdExit + +#endif /* !defined(__DOXYGEN__) */ + +/** @} */ -- cgit v1.2.3