• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HPMicro
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "los_tick.h"
17 #include "los_task.h"
18 #include "los_config.h"
19 #include "los_interrupt.h"
20 #include "los_debug.h"
21 #include "uart.h"
22 #include "board.h"
23 #include "hpm_mchtmr_drv.h"
24 #include <ohos_init.h>
25 #include "hiview_log.h"
26 #include "los_debug.h"
27 #include "adapter.h"
28 #include "riscv_hal.h"
29 #include "hiview_output_log.h"
30 #include "hpm_littlefs.h"
31 #include "show.h"
32 
33 int DeviceManagerStart(void);
34 void OHOS_SystemInit(void);
35 UINT32 LosShellInit(VOID);
36 
_init(void)37 void _init(void) {}
_fini(void)38 void _fini(void) {}
39 extern void __libc_fini_array (void);
40 extern void __libc_init_array(void);
41 
42 /*****************************************************************************
43  Function    : main
44  Description : Main function entry
45  Input       : None
46  Output      : None
47  Return      : None
48  *****************************************************************************/
main(VOID)49 LITE_OS_SEC_TEXT_INIT INT32 main(VOID)
50 {
51     UINT32 ret;
52     board_init();
53     UartInit();
54     board_print_banner();
55     board_print_clock_freq();
56 
57     printf("OHOS start...\n\r");
58 
59     ret = LOS_KernelInit();
60     if (ret != LOS_OK) {
61         PRINT_ERR("LiteOS kernel init failed! ERROR: 0x%x\n", ret);
62         goto START_FAILED;
63     }
64 
65     HalPlicInit();
66     Uart0RxIrqRegister();
67 
68 #if defined(LOSCFG_SUPPORT_LITTLEFS)
69     HpmLittlefsInit();
70 #endif
71 
72     printf("\nDeviceManagerStart start ...\n");
73     if (DeviceManagerStart()) {
74         printf("No drivers need load by hdf manager!");
75     }
76 
77     OHOS_SystemInit();
78 
79 #if (LOSCFG_USE_SHELL == 1)
80     ret = LosShellInit();
81     (VOID)OsShellInit();
82     if (ret != LOS_OK) {
83         printf("LosShellInit failed! ERROR: 0x%x\n", ret);
84     }
85 #endif
86 
87     LOS_Start();
88 
89 START_FAILED:
90     while (1) {
91         __asm volatile("wfi");
92     }
93 }
94