X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FSource%2Fportable%2FRenesas%2FRX600%2Fport.c;h=637f7f9e52b293d5b535aec65ab0178d485947f0;hb=3feb84fee1840c0a8a3ea50810fb5f3e7527c6ce;hp=4c9e14ecfd96f383ac84b493a69f7bfa3f1c217d;hpb=90f4c3885b2e63f57a7172c148f67b96cf44eca2;p=freertos diff --git a/FreeRTOS/Source/portable/Renesas/RX600/port.c b/FreeRTOS/Source/portable/Renesas/RX600/port.c index 4c9e14ecf..637f7f9e5 100644 --- a/FreeRTOS/Source/portable/Renesas/RX600/port.c +++ b/FreeRTOS/Source/portable/Renesas/RX600/port.c @@ -1,71 +1,32 @@ /* - FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd. - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS 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 and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - *************************************************************************** - * * - * Having a problem? Start by reading the FAQ "My application does * - * not run, what could be wrong? * - * * - * http://www.FreeRTOS.org/FAQHelp.html * - * * - *************************************************************************** - - - http://www.FreeRTOS.org - Documentation, training, latest information, - license and contact details. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool. - - Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell - the code with commercial support, indemnification, and middleware, under - the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also - provide a safety engineered and independently SIL3 certified version under - the SafeRTOS brand: http://www.SafeRTOS.com. -*/ + * FreeRTOS Kernel V10.0.1 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /*----------------------------------------------------------- - * Implementation of functions defined in portable.h for the SH2A port. + * Implementation of functions defined in portable.h for the RX600 port. *----------------------------------------------------------*/ /* Scheduler includes. */ @@ -80,24 +41,24 @@ /*-----------------------------------------------------------*/ -/* Tasks should start with interrupts enabled and in Supervisor mode, therefore +/* Tasks should start with interrupts enabled and in Supervisor mode, therefore PSW is set with U and I set, and PM and IPL clear. */ -#define portINITIAL_PSW ( ( portSTACK_TYPE ) 0x00030000 ) -#define portINITIAL_FPSW ( ( portSTACK_TYPE ) 0x00000100 ) +#define portINITIAL_PSW ( ( StackType_t ) 0x00030000 ) +#define portINITIAL_FPSW ( ( StackType_t ) 0x00000100 ) /*-----------------------------------------------------------*/ /* The following lines are to ensure vSoftwareInterruptEntry can be referenced, and therefore installed in the vector table, when the FreeRTOS code is built as a library. */ -extern portBASE_TYPE vSoftwareInterruptEntry; -const portBASE_TYPE * p_vSoftwareInterruptEntry = &vSoftwareInterruptEntry; +extern BaseType_t vSoftwareInterruptEntry; +const BaseType_t * p_vSoftwareInterruptEntry = &vSoftwareInterruptEntry; /*-----------------------------------------------------------*/ /* * Function to start the first task executing - written in asm code as direct - * access to registers is required. + * access to registers is required. */ static void prvStartFirstTask( void ); @@ -110,7 +71,7 @@ static void prvYieldHandler( void ); /* * The entry point for the software interrupt handler. This is the function - * that calls the inline asm function prvYieldHandler(). It is installed in + * that calls the inline asm function prvYieldHandler(). It is installed in * the vector table, but the code that installs it is in prvYieldHandler rather * than using a #pragma. */ @@ -125,19 +86,19 @@ extern void vTaskSwitchContext( void ); /*-----------------------------------------------------------*/ -/* - * See header file for description. +/* + * See header file for description. */ -portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters ) +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) { /* R0 is not included as it is the stack pointer. */ - + *pxTopOfStack = 0x00; pxTopOfStack--; *pxTopOfStack = portINITIAL_PSW; pxTopOfStack--; - *pxTopOfStack = ( portSTACK_TYPE ) pxCode; - + *pxTopOfStack = ( StackType_t ) pxCode; + /* When debugging it can be useful if every register is set to a known value. Otherwise code space can be saved by just setting the registers that need to be set. */ @@ -178,9 +139,9 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxTopOfStack -= 15; } #endif - - *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R1 */ - pxTopOfStack--; + + *pxTopOfStack = ( StackType_t ) pvParameters; /* R1 */ + pxTopOfStack--; *pxTopOfStack = portINITIAL_FPSW; pxTopOfStack--; *pxTopOfStack = 0x12345678; /* Accumulator. */ @@ -191,7 +152,7 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE } /*-----------------------------------------------------------*/ -portBASE_TYPE xPortStartScheduler( void ) +BaseType_t xPortStartScheduler( void ) { extern void vApplicationSetupTimerInterrupt( void ); @@ -199,19 +160,19 @@ extern void vApplicationSetupTimerInterrupt( void ); if( pxCurrentTCB != NULL ) { /* Call an application function to set up the timer that will generate the - tick interrupt. This way the application can decide which peripheral to + tick interrupt. This way the application can decide which peripheral to use. A demo application is provided to show a suitable example. */ vApplicationSetupTimerInterrupt(); - /* Enable the software interrupt. */ + /* Enable the software interrupt. */ _IEN( _ICU_SWINT ) = 1; - + /* Ensure the software interrupt is clear. */ _IR( _ICU_SWINT ) = 0; - + /* Ensure the software interrupt is set to the kernel priority. */ _IPR( _ICU_SWINT ) = configKERNEL_INTERRUPT_PRIORITY; - + /* Start the first task. */ prvStartFirstTask(); } @@ -232,13 +193,13 @@ static void prvStartFirstTask( void ) Just ensure the current stack is the user stack. */ SETPSW U - /* Obtain the location of the stack associated with which ever task + /* Obtain the location of the stack associated with which ever task pxCurrentTCB is currently pointing to. */ MOV.L #_pxCurrentTCB, R15 MOV.L [R15], R15 MOV.L [R15], R0 - /* Restore the registers from the stack of the task pointed to by + /* Restore the registers from the stack of the task pointed to by pxCurrentTCB. */ POP R15 MVTACLO R15 /* Accumulator low 32 bits. */ @@ -260,14 +221,12 @@ void vTickISR( void ) necessitates. */ set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY ); { - vTaskIncrementTick(); + if( xTaskIncrementTick() != pdFALSE ) + { + taskYIELD(); + } } set_ipl( configKERNEL_INTERRUPT_PRIORITY ); - - /* Only select a new task if the preemptive scheduler is being used. */ - #if( configUSE_PREEMPTION == 1 ) - taskYIELD(); - #endif } /*-----------------------------------------------------------*/ @@ -284,18 +243,18 @@ static void prvYieldHandler( void ) SETPSW I /* Move the data that was automatically pushed onto the interrupt stack when - the interrupt occurred from the interrupt stack to the user stack. - + the interrupt occurred from the interrupt stack to the user stack. + R15 is saved before it is clobbered. */ PUSH.L R15 - + /* Read the user stack pointer. */ MVFC USP, R15 - + /* Move the address down to the data being moved. */ SUB #12, R15 MVTC R15, USP - + /* Copy the data across. */ MOV.L [ R0 ], [ R15 ] ; R15 MOV.L 4[ R0 ], 4[ R15 ] ; PC @@ -303,13 +262,13 @@ static void prvYieldHandler( void ) /* Move the interrupt stack pointer to its new correct position. */ ADD #12, R0 - + /* All the rest of the registers are saved directly to the user stack. */ SETPSW U /* Save the rest of the general registers (R15 has been saved already). */ PUSHM R1-R14 - + /* Save the FPSW and accumulator. */ MVFC FPSW, R15 PUSH.L R15 @@ -323,7 +282,7 @@ static void prvYieldHandler( void ) MOV.L #_pxCurrentTCB, R15 MOV.L [ R15 ], R15 MOV.L R0, [ R15 ] - + /* Ensure the interrupt mask is set to the syscall priority while the kernel structures are being accessed. */ MVTIPL #configMAX_SYSCALL_INTERRUPT_PRIORITY @@ -357,8 +316,10 @@ static void prvYieldHandler( void ) void vPortEndScheduler( void ) { - /* Not implemented as there is nothing to return to. */ - + /* Not implemented in ports where there is nothing to return to. + Artificially force an assert. */ + configASSERT( pxCurrentTCB == NULL ); + /* The following line is just to prevent the symbol getting optimised away. */ ( void ) vTaskSwitchContext(); }