]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/main_ns.c
Add support for running FreeRTOS on Secure Side only in Cortex M33 port. Also, change...
[freertos] / FreeRTOS / Demo / CORTEX_MPU_M33F_Simulator_Keil_GCC / NonSecure / main_ns.c
index 288767330b51bf08206ac803157854afcdeac182..faffb007dadfebeffbb48eb26cfc0ccdc124ae38 100644 (file)
 /* Externs needed by the MPU setup code. These must match the memory map as\r
  * specified in Scatter-Loading description file (FreeRTOSDemo_ns.sct). */\r
 /* Privileged flash. */\r
-const uint32_t * __privileged_functions_start__     = ( uint32_t * ) ( 0x00200000 );\r
-const uint32_t * __privileged_functions_end__       = ( uint32_t * ) ( 0x00208000 - 0x1 );  /* Last address in privileged Flash region. */\r
+const uint32_t * __privileged_functions_start__                = ( uint32_t * ) ( 0x00200000 );\r
+const uint32_t * __privileged_functions_end__          = ( uint32_t * ) ( 0x00208000 - 0x1 );  /* Last address in privileged Flash region. */\r
 \r
 /* Flash containing system calls. */\r
-const uint32_t * __syscalls_flash_start__           = ( uint32_t * ) ( 0x00208000 );\r
-const uint32_t * __syscalls_flash_end__             = ( uint32_t * ) ( 0x00209000 - 0x1 );  /* Last address in Flash region containing system calls. */\r
+const uint32_t * __syscalls_flash_start__                      = ( uint32_t * ) ( 0x00208000 );\r
+const uint32_t * __syscalls_flash_end__                                = ( uint32_t * ) ( 0x00209000 - 0x1 );  /* Last address in Flash region containing system calls. */\r
 \r
 /* Unprivileged flash. Note that the section containing\r
  * system calls is unprivilged so that unprivleged tasks\r
  * can make system calls. */\r
-const uint32_t * __unprivileged_flash_start__       = ( uint32_t * ) ( 0x00209000 );\r
-const uint32_t * __unprivileged_flash_end__         = ( uint32_t * ) ( 0x00400000 - 0x1 );  /* Last address in un-privileged Flash region. */\r
+const uint32_t * __unprivileged_flash_start__          = ( uint32_t * ) ( 0x00209000 );\r
+const uint32_t * __unprivileged_flash_end__                    = ( uint32_t * ) ( 0x00400000 - 0x1 );  /* Last address in un-privileged Flash region. */\r
 \r
 /* 512 bytes (0x200) of RAM starting at 0x30008000 is\r
  * priviledged access only. This contains kernel data. */\r
-const uint32_t * __privileged_sram_start__          = ( uint32_t * ) ( 0x20200000 );\r
-const uint32_t * __privileged_sram_end__            = ( uint32_t * ) ( 0x20201000 - 0x1 ); /* Last address in privileged RAM. */\r
+const uint32_t * __privileged_sram_start__                     = ( uint32_t * ) ( 0x20200000 );\r
+const uint32_t * __privileged_sram_end__                       = ( uint32_t * ) ( 0x20201000 - 0x1 ); /* Last address in privileged RAM. */\r
 ;\r
 /* Unprivileged RAM. */\r
-const uint32_t * __unprivileged_sram_start__        = ( uint32_t * ) ( 0x20201000 );\r
-const uint32_t * __unprivileged_sram_end__          = ( uint32_t * ) ( 0x20220000 - 0x1 ); /* Last address in un-privileged RAM. */\r
+const uint32_t * __unprivileged_sram_start__           = ( uint32_t * ) ( 0x20201000 );\r
+const uint32_t * __unprivileged_sram_end__                     = ( uint32_t * ) ( 0x20220000 - 0x1 ); /* Last address in un-privileged RAM. */\r
 /*-----------------------------------------------------------*/\r
 \r
 /**\r
@@ -67,11 +67,11 @@ static void prvCreateTasks( void );
 \r
 static void prvCreateTasks( void )\r
 {\r
-    /* Create tasks for the MPU Demo. */\r
-    vStartMPUDemo();\r
+       /* Create tasks for the MPU Demo. */\r
+       vStartMPUDemo();\r
 \r
-    /* Create tasks for the TZ Demo. */\r
-    vStartTZDemo();\r
+       /* Create tasks for the TZ Demo. */\r
+       vStartTZDemo();\r
 \r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -79,51 +79,51 @@ static void prvCreateTasks( void )
 /* Stack overflow hook. */\r
 void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName )\r
 {\r
-    /* Force an assert. */\r
-    configASSERT( pcTaskName == 0 );\r
+       /* Force an assert. */\r
+       configASSERT( pcTaskName == 0 );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 /* Non-Secure main. */\r
 int main( void )\r
 {\r
-    /* Create tasks. */\r
-    prvCreateTasks();\r
+       /* Create tasks. */\r
+       prvCreateTasks();\r
 \r
-    /* Start scheduler. */\r
-    vTaskStartScheduler();\r
+       /* Start scheduler. */\r
+       vTaskStartScheduler();\r
 \r
-    /* Should not reach here as the schedular is already started. */\r
-    for( ; ; )\r
-    {\r
-    }\r
+       /* Should not reach here as the schedular is already started. */\r
+       for( ; ; )\r
+       {\r
+       }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 /* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an\r
  * implementation of vApplicationGetIdleTaskMemory() to provide the memory that\r
  * is used by the Idle task. */\r
-void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,\r
-                                    StackType_t ** ppxIdleTaskStackBuffer,\r
-                                    uint32_t * pulIdleTaskStackSize )\r
+void vApplicationGetIdleTaskMemory(    StaticTask_t ** ppxIdleTaskTCBBuffer,\r
+                                                                       StackType_t ** ppxIdleTaskStackBuffer,\r
+                                                                       uint32_t * pulIdleTaskStackSize )\r
 {\r
-    /* If the buffers to be provided to the Idle task are declared inside this\r
-     * function then they must be declared static - otherwise they will be\r
-     * allocated on the stack and so not exists after this function exits. */\r
-    static StaticTask_t xIdleTaskTCB;\r
-    static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__((aligned(32)));\r
-\r
-    /* Pass out a pointer to the StaticTask_t structure in which the Idle\r
-     * task's state will be stored. */\r
-    *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;\r
-\r
-    /* Pass out the array that will be used as the Idle task's stack. */\r
-    *ppxIdleTaskStackBuffer = uxIdleTaskStack;\r
-\r
-    /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.\r
-     * Note that, as the array is necessarily of type StackType_t,\r
-     * configMINIMAL_STACK_SIZE is specified in words, not bytes. */\r
-    *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;\r
+       /* If the buffers to be provided to the Idle task are declared inside this\r
+        * function then they must be declared static - otherwise they will be\r
+        * allocated on the stack and so not exists after this function exits. */\r
+       static StaticTask_t xIdleTaskTCB;\r
+       static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__((aligned(32)));\r
+\r
+       /* Pass out a pointer to the StaticTask_t structure in which the Idle\r
+        * task's state will be stored. */\r
+       *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;\r
+\r
+       /* Pass out the array that will be used as the Idle task's stack. */\r
+       *ppxIdleTaskStackBuffer = uxIdleTaskStack;\r
+\r
+       /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.\r
+        * Note that, as the array is necessarily of type StackType_t,\r
+        * configMINIMAL_STACK_SIZE is specified in words, not bytes. */\r
+       *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -131,26 +131,26 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
  * application must provide an implementation of vApplicationGetTimerTaskMemory()\r
  * to provide the memory that is used by the Timer service task. */\r
 void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,\r
-                                     StackType_t ** ppxTimerTaskStackBuffer,\r
-                                     uint32_t * pulTimerTaskStackSize )\r
+                                                                        StackType_t ** ppxTimerTaskStackBuffer,\r
+                                                                        uint32_t * pulTimerTaskStackSize )\r
 {\r
-    /* If the buffers to be provided to the Timer task are declared inside this\r
-     * function then they must be declared static - otherwise they will be\r
-     * allocated on the stack and so not exists after this function exits. */\r
-    static StaticTask_t xTimerTaskTCB;\r
-    static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ] __attribute__((aligned(32)));\r
-\r
-    /* Pass out a pointer to the StaticTask_t structure in which the Timer\r
-     * task's state will be stored. */\r
-    *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;\r
-\r
-    /* Pass out the array that will be used as the Timer task's stack. */\r
-    *ppxTimerTaskStackBuffer = uxTimerTaskStack;\r
-\r
-    /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.\r
-     * Note that, as the array is necessarily of type StackType_t,\r
-     * configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */\r
-    *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;\r
+       /* If the buffers to be provided to the Timer task are declared inside this\r
+        * function then they must be declared static - otherwise they will be\r
+        * allocated on the stack and so not exists after this function exits. */\r
+       static StaticTask_t xTimerTaskTCB;\r
+       static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ] __attribute__((aligned(32)));\r
+\r
+       /* Pass out a pointer to the StaticTask_t structure in which the Timer\r
+        * task's state will be stored. */\r
+       *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;\r
+\r
+       /* Pass out the array that will be used as the Timer task's stack. */\r
+       *ppxTimerTaskStackBuffer = uxTimerTaskStack;\r
+\r
+       /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.\r
+        * Note that, as the array is necessarily of type StackType_t,\r
+        * configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */\r
+       *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -160,16 +160,16 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
  */\r
 void MemManage_Handler( void )\r
 {\r
-    __asm volatile\r
-    (\r
-        " tst lr, #4                                        \n"\r
-        " ite eq                                            \n"\r
-        " mrseq r0, msp                                     \n"\r
-        " mrsne r0, psp                                     \n"\r
-        " ldr r1, handler_address_const                     \n"\r
-        " bx r1                                             \n"\r
-        "                                                   \n"\r
-        " handler_address_const: .word vHandleMemoryFault   \n"\r
-    );\r
+       __asm volatile\r
+       (\r
+               " tst lr, #4                                                                            \n"\r
+               " ite eq                                                                                        \n"\r
+               " mrseq r0, msp                                                                         \n"\r
+               " mrsne r0, psp                                                                         \n"\r
+               " ldr r1, handler_address_const                                         \n"\r
+               " bx r1                                                                                         \n"\r
+               "                                                                                                       \n"\r
+               " handler_address_const: .word vHandleMemoryFault       \n"\r
+       );\r
 }\r
 /*-----------------------------------------------------------*/\r