]> git.sur5r.net Git - freertos/commitdiff
Allow auto switching between creating tasks in ARM mode and THUMB mode.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 29 Sep 2009 20:03:55 +0000 (20:03 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 29 Sep 2009 20:03:55 +0000 (20:03 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@882 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/portable/IAR/STR71x/port.c

index 5b007e4547736b484afeb8546b846baa532b5949..5d46c44e93b585eb4a24f130f1d68fdbf2c6e085 100644 (file)
@@ -3,14 +3,14 @@
 \r
        This file is part of the FreeRTOS distribution.\r
 \r
 \r
        This file is part of the FreeRTOS distribution.\r
 \r
-       FreeRTOS is free software; you can redistribute it and/or modify it     under \r
-       the terms of the GNU General Public License (version 2) as published by the \r
+       FreeRTOS is free software; you can redistribute it and/or modify it     under\r
+       the terms of the GNU General Public License (version 2) as published by the\r
        Free Software Foundation and modified by the FreeRTOS exception.\r
        **NOTE** The exception to the GPL is included to allow you to distribute a\r
        Free Software Foundation and modified by the FreeRTOS exception.\r
        **NOTE** The exception to the GPL is included to allow you to distribute a\r
-       combined work that includes FreeRTOS without being obliged to provide the \r
-       source code for proprietary components outside of the FreeRTOS kernel.  \r
-       Alternative commercial license and support terms are also available upon \r
-       request.  See the licensing section of http://www.FreeRTOS.org for full \r
+       combined work that includes FreeRTOS without being obliged to provide the\r
+       source code for proprietary components outside of the FreeRTOS kernel.\r
+       Alternative commercial license and support terms are also available upon\r
+       request.  See the licensing section of http://www.FreeRTOS.org for full\r
        license details.\r
 \r
        FreeRTOS is distributed in the hope that it will be useful,     but WITHOUT\r
        license details.\r
 \r
        FreeRTOS is distributed in the hope that it will be useful,     but WITHOUT\r
@@ -46,7 +46,7 @@
 */\r
 \r
 /*-----------------------------------------------------------\r
 */\r
 \r
 /*-----------------------------------------------------------\r
- * Implementation of functions defined in portable.h for the ST STR71x ARM7 \r
+ * Implementation of functions defined in portable.h for the ST STR71x ARM7\r
  * port.\r
  *----------------------------------------------------------*/\r
 \r
  * port.\r
  *----------------------------------------------------------*/\r
 \r
@@ -62,7 +62,8 @@
 #include "task.h"\r
 \r
 /* Constants required to setup the initial stack. */\r
 #include "task.h"\r
 \r
 /* Constants required to setup the initial stack. */\r
-#define portINITIAL_SPSR                               ( ( portSTACK_TYPE ) 0x3f ) /* System mode, THUMB mode, interrupts enabled. */\r
+#define portINITIAL_SPSR                               ( ( portSTACK_TYPE ) 0x1f ) /* System mode, ARM mode, interrupts enabled. */\r
+#define portTHUMB_MODE_BIT                             ( ( portSTACK_TYPE ) 0x20 )\r
 #define portINSTRUCTION_SIZE                   ( ( portSTACK_TYPE ) 4 )\r
 \r
 /* Constants required to handle critical sections. */\r
 #define portINSTRUCTION_SIZE                   ( ( portSTACK_TYPE ) 4 )\r
 \r
 /* Constants required to handle critical sections. */\r
@@ -80,7 +81,7 @@ cannot be initialised to 0 as this will cause interrupts to be enabled
 during the kernel initialisation process. */\r
 unsigned portLONG ulCriticalNesting = ( unsigned portLONG ) 9999;\r
 \r
 during the kernel initialisation process. */\r
 unsigned portLONG ulCriticalNesting = ( unsigned portLONG ) 9999;\r
 \r
-/* Tick interrupt routines for cooperative and preemptive operation \r
+/* Tick interrupt routines for cooperative and preemptive operation\r
 respectively.  The preemptive version is not defined as __irq as it is called\r
 from an asm wrapper function. */\r
 __arm __irq void vPortNonPreemptiveTick( void );\r
 respectively.  The preemptive version is not defined as __irq as it is called\r
 from an asm wrapper function. */\r
 __arm __irq void vPortNonPreemptiveTick( void );\r
@@ -145,6 +146,13 @@ portSTACK_TYPE *pxOriginalTOS;
 \r
        /* The status register is set for system mode, with interrupts enabled. */\r
        *pxTopOfStack = ( portSTACK_TYPE ) portINITIAL_SPSR;\r
 \r
        /* The status register is set for system mode, with interrupts enabled. */\r
        *pxTopOfStack = ( portSTACK_TYPE ) portINITIAL_SPSR;\r
+       \r
+       if( ( ( unsigned long ) pxCode & 0x01UL ) != 0x00UL )\r
+       {\r
+               /* We want the task to start in thumb mode. */\r
+               *pxTopOfStack |= portTHUMB_MODE_BIT;\r
+       }               \r
+       \r
        pxTopOfStack--;\r
 \r
        /* Interrupt flags cannot always be stored on the stack and will\r
        pxTopOfStack--;\r
 \r
        /* Interrupt flags cannot always be stored on the stack and will\r
@@ -202,7 +210,7 @@ void vPortPreemptiveTick( void )
        vTaskIncrementTick();\r
 \r
        /* The new tick value might unblock a task.  Ensure the highest task that\r
        vTaskIncrementTick();\r
 \r
        /* The new tick value might unblock a task.  Ensure the highest task that\r
-       is ready to execute is the task that will execute when the tick ISR \r
+       is ready to execute is the task that will execute when the tick ISR\r
        exits. */\r
        vTaskSwitchContext();\r
 \r
        exits. */\r
        vTaskSwitchContext();\r
 \r