1d6aed566Sopenharmony_ci/* 2d6aed566Sopenharmony_ci * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved. 3d6aed566Sopenharmony_ci * 4d6aed566Sopenharmony_ci * Redistribution and use in source and binary forms, with or without modification, 5d6aed566Sopenharmony_ci * are permitted provided that the following conditions are met: 6d6aed566Sopenharmony_ci * 7d6aed566Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, this list of 8d6aed566Sopenharmony_ci * conditions and the following disclaimer. 9d6aed566Sopenharmony_ci * 10d6aed566Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11d6aed566Sopenharmony_ci * of conditions and the following disclaimer in the documentation and/or other materials 12d6aed566Sopenharmony_ci * provided with the distribution. 13d6aed566Sopenharmony_ci * 14d6aed566Sopenharmony_ci * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15d6aed566Sopenharmony_ci * to endorse or promote products derived from this software without specific prior written 16d6aed566Sopenharmony_ci * permission. 17d6aed566Sopenharmony_ci * 18d6aed566Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19d6aed566Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20d6aed566Sopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21d6aed566Sopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22d6aed566Sopenharmony_ci * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23d6aed566Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24d6aed566Sopenharmony_ci * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25d6aed566Sopenharmony_ci * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26d6aed566Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27d6aed566Sopenharmony_ci * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28d6aed566Sopenharmony_ci * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29d6aed566Sopenharmony_ci */ 30d6aed566Sopenharmony_ci 31d6aed566Sopenharmony_ci#include "los_config.h" 32d6aed566Sopenharmony_ci#include "uart.h" 33d6aed566Sopenharmony_ci 34d6aed566Sopenharmony_ciunsigned int LosAppInit(VOID); 35d6aed566Sopenharmony_ciunsigned int LosShellInit(void); 36d6aed566Sopenharmony_ci 37d6aed566Sopenharmony_ci// Enable EPU 38d6aed566Sopenharmony_cistatic void EPUInit(void) 39d6aed566Sopenharmony_ci{ 40d6aed566Sopenharmony_ci#if ((__FPU_PRESENT == 1U) && (__FPU_USED == 1U)) 41d6aed566Sopenharmony_ci __asm volatile 42d6aed566Sopenharmony_ci ( 43d6aed566Sopenharmony_ci " .equ CPACR, 0xE000ED88 \n" 44d6aed566Sopenharmony_ci " \n" 45d6aed566Sopenharmony_ci " ldr r0, =CPACR \n" 46d6aed566Sopenharmony_ci " ldr r1, [r0] \n" 47d6aed566Sopenharmony_ci " orr r1, r1, #(0xf << 20) \n" 48d6aed566Sopenharmony_ci " str r1, [r0] \n" 49d6aed566Sopenharmony_ci " dsb \n" 50d6aed566Sopenharmony_ci " isb \n" 51d6aed566Sopenharmony_ci " \n" 52d6aed566Sopenharmony_ci " .align 4 \n" 53d6aed566Sopenharmony_ci ); 54d6aed566Sopenharmony_ci#endif 55d6aed566Sopenharmony_ci} 56d6aed566Sopenharmony_ci 57d6aed566Sopenharmony_ciLITE_OS_SEC_TEXT_INIT int main(void) 58d6aed566Sopenharmony_ci{ 59d6aed566Sopenharmony_ci unsigned int ret; 60d6aed566Sopenharmony_ci 61d6aed566Sopenharmony_ci EPUInit(); 62d6aed566Sopenharmony_ci UartInit(); 63d6aed566Sopenharmony_ci 64d6aed566Sopenharmony_ci ret = LOS_KernelInit(); 65d6aed566Sopenharmony_ci if (ret != LOS_OK) { 66d6aed566Sopenharmony_ci printf("LiteOS kernel init failed! ERROR: %u\n", ret); 67d6aed566Sopenharmony_ci goto EXIT; 68d6aed566Sopenharmony_ci } 69d6aed566Sopenharmony_ci 70d6aed566Sopenharmony_ci Uart0RxIrqRegister(); 71d6aed566Sopenharmony_ci 72d6aed566Sopenharmony_ci#if (LOSCFG_USE_SHELL == 1) 73d6aed566Sopenharmony_ci ret = LosShellInit(); 74d6aed566Sopenharmony_ci if (ret != LOS_OK) { 75d6aed566Sopenharmony_ci printf("LosAppInit failed! ERROR: %u\n", ret); 76d6aed566Sopenharmony_ci } 77d6aed566Sopenharmony_ci#endif 78d6aed566Sopenharmony_ci 79d6aed566Sopenharmony_ci ret = LosAppInit(); 80d6aed566Sopenharmony_ci if (ret != LOS_OK) { 81d6aed566Sopenharmony_ci printf("LosAppInit failed! ERROR: %u\n", ret); 82d6aed566Sopenharmony_ci } 83d6aed566Sopenharmony_ci 84d6aed566Sopenharmony_ci LOS_Start(); 85d6aed566Sopenharmony_ci 86d6aed566Sopenharmony_ciEXIT: 87d6aed566Sopenharmony_ci while (1) { 88d6aed566Sopenharmony_ci __asm volatile("wfi"); 89d6aed566Sopenharmony_ci } 90d6aed566Sopenharmony_ci} 91d6aed566Sopenharmony_ci 92