yang.li | 5664bb3 | 2022-01-12 15:50:17 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | */ |
Xiaohu.Huang | 90570a3 | 2022-03-12 22:55:20 +0800 | [diff] [blame] | 6 | #include <stdio.h> |
Xiaohu.Huang | ed89677 | 2021-11-18 13:57:56 +0800 | [diff] [blame] | 7 | #include "FreeRTOS.h" |
| 8 | #include "task.h" |
bangzheng.liu | 8718cc1 | 2024-06-27 16:37:47 +0800 | [diff] [blame] | 9 | #include "soc_business.h" |
Xiaohu.Huang | ed89677 | 2021-11-18 13:57:56 +0800 | [diff] [blame] | 10 | #include "hw_business.h" |
| 11 | #include "sw_business.h" |
benlong.zhou | bda63b1 | 2022-11-25 02:56:52 +0000 | [diff] [blame] | 12 | #include "gcc_compiler_attributes.h" |
bangzheng.liu | b7fedec | 2023-05-08 20:04:38 +0800 | [diff] [blame] | 13 | #include "board_version.h" |
benlong.zhou | bda63b1 | 2022-11-25 02:56:52 +0000 | [diff] [blame] | 14 | |
| 15 | void __weak aocpu_bringup_finished(void) |
| 16 | { |
| 17 | } |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 18 | |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 19 | int main(void) |
| 20 | { |
Xiaohu.Huang | ed89677 | 2021-11-18 13:57:56 +0800 | [diff] [blame] | 21 | printf("Starting AOCPU FreeRTOS\n"); |
bangzheng.liu | b7fedec | 2023-05-08 20:04:38 +0800 | [diff] [blame] | 22 | output_aocpu_info(); |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 23 | |
bangzheng.liu | 8718cc1 | 2024-06-27 16:37:47 +0800 | [diff] [blame] | 24 | soc_business_process(); |
Xiaohu.Huang | ed89677 | 2021-11-18 13:57:56 +0800 | [diff] [blame] | 25 | hw_business_process(); |
| 26 | sw_business_process(); |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 27 | |
bangzheng.liu | b7fedec | 2023-05-08 20:04:38 +0800 | [diff] [blame] | 28 | #ifdef CONFIG_BL30_VERSION_SAVE |
| 29 | bl30_plat_save_version(); |
| 30 | #endif |
| 31 | |
Xiaohu.Huang | ed89677 | 2021-11-18 13:57:56 +0800 | [diff] [blame] | 32 | printf("Starting task scheduler ...\n"); |
benlong.zhou | bda63b1 | 2022-11-25 02:56:52 +0000 | [diff] [blame] | 33 | aocpu_bringup_finished(); |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 34 | vTaskStartScheduler(); |
fugui.zhang | e2b1181 | 2024-06-06 13:22:42 +0800 | [diff] [blame] | 35 | /* |
| 36 | * The Coverity tool think that the for loop is a structurally dead code, so it's |
| 37 | * flagged as such. But the for loop is necessary for ordering the |
| 38 | * FreeRTOS's format rules. |
| 39 | */ |
| 40 | /* coverity[340441:SUPPRESS] */ |
| 41 | for ( ; ; ) |
| 42 | ; |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 43 | |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | void vApplicationIdleHook( void ) |
| 48 | { |
Shunzhou Jiang | de73ea9 | 2024-11-21 17:41:39 +0800 | [diff] [blame] | 49 | //printf("enter idle task\n"); |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 50 | |
Shunzhou Jiang | de73ea9 | 2024-11-21 17:41:39 +0800 | [diff] [blame] | 51 | //write_csr(mie, 1); // open mstatue.mie |
| 52 | asm volatile ("wfi"); // enter low power mode |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 53 | } |
| 54 | /*-----------------------------------------------------------*/ |
bangzheng.liu | 7930439 | 2024-11-15 18:44:39 +0800 | [diff] [blame] | 55 | void vApplicationMallocFailedHook(void); |
| 56 | void vApplicationMallocFailedHook(void) |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 57 | { |
bangzheng.liu | 7930439 | 2024-11-15 18:44:39 +0800 | [diff] [blame] | 58 | /* The malloc failed hook is enabled by setting |
| 59 | * configUSE_MALLOC_FAILED_HOOK to 1 in FreeRTOSConfig.h. |
| 60 | * |
| 61 | * Called if a call to pvPortMalloc() fails because there is insufficient |
| 62 | * free memory available in the FreeRTOS heap. pvPortMalloc() is called |
| 63 | * internally by FreeRTOS API functions that create tasks, queues, software |
| 64 | * timers, and semaphores. The size of the FreeRTOS heap is set by the |
| 65 | * configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. |
| 66 | */ |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 67 | |
bangzheng.liu | 7930439 | 2024-11-15 18:44:39 +0800 | [diff] [blame] | 68 | printf("bl30 task %s malloc failed\n", pcTaskGetName(xTaskGetCurrentTaskHandle())); |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 69 | vPrintFreeListAfterMallocFail(); |
bangzheng.liu | 7930439 | 2024-11-15 18:44:39 +0800 | [diff] [blame] | 70 | for ( ;; ) |
| 71 | ; |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 72 | } |
| 73 | /*-----------------------------------------------------------*/ |
| 74 | |
xiaohu.huang | d302fe8 | 2022-04-02 19:24:19 +0800 | [diff] [blame] | 75 | void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName) |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 76 | { |
bangzheng.liu | 2919632 | 2024-12-02 11:36:41 +0800 | [diff] [blame^] | 77 | (void)xTask; |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 78 | |
bangzheng.liu | 2919632 | 2024-12-02 11:36:41 +0800 | [diff] [blame^] | 79 | /* Run time stack overflow checking is performed if |
| 80 | * configconfigCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook |
| 81 | * function is called if a stack overflow is detected. pxCurrentTCB can be |
| 82 | * inspected in the debugger if the task name passed into this function is |
| 83 | * corrupt. |
| 84 | */ |
| 85 | printf("bl30 task %s stack overflow\n", pcTaskName); |
bangzheng.liu | 1ab4122 | 2023-05-22 14:47:03 +0800 | [diff] [blame] | 86 | vTaskDumpStack(NULL); |
bangzheng.liu | 2919632 | 2024-12-02 11:36:41 +0800 | [diff] [blame^] | 87 | for ( ;; ) |
| 88 | ; |
Xiaohu.Huang | 9696cbe | 2021-10-15 11:33:44 +0800 | [diff] [blame] | 89 | } |
| 90 | /*-----------------------------------------------------------*/ |
xiaohu.huang | 1860c3a | 2024-09-03 13:51:24 +0800 | [diff] [blame] | 91 | |
| 92 | #ifdef CONFIG_STACK_PROTECTOR_STRONG |
| 93 | void additional_message_hook(void *address) |
| 94 | { |
bangzheng.liu | 2919632 | 2024-12-02 11:36:41 +0800 | [diff] [blame^] | 95 | printf("bl30 stack smashing func last addr: 0x%x, stop!\n", address); |
xiaohu.huang | 1860c3a | 2024-09-03 13:51:24 +0800 | [diff] [blame] | 96 | } |
| 97 | #endif |