1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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 #include "target_config.h" 16 #include "los_typedef.h" 17 18 #include "stdlib.h" 19 #include "stdio.h" 20 #include "los_process_pri.h" 21 #ifdef LOSCFG_FS_VFS 22 #include "disk.h" 23 #endif 24 #include "los_bootargs.h" 25 #include "los_rootfs.h" 26 #ifdef LOSCFG_SHELL 27 #include "shell.h" 28 #include "shcmd.h" 29 #endif 30 31 #ifdef LOSCFG_DRIVERS_RANDOM 32 #include "los_random.h" 33 #include "soc/random.h" 34 #endif 35 36 #ifdef LOSCFG_DRIVERS_MEM 37 #include "los_dev_mem.h" 38 #endif 39 40 #ifdef LOSCFG_DRIVERS_HDF_PLATFORM_UART 41 #include "console.h" 42 #include "soc/uart.h" 43 #endif 44 45 #ifdef LOSCFG_DRIVERS_HDF 46 #include "devmgr_service_start.h" 47 #endif 48 49 #ifdef LOSCFG_DRIVERS_NETDEV 50 #include "lwip/tcpip.h" net_init(void)51void net_init(void) 52 { 53 tcpip_init(NULL, NULL); 54 } 55 #endif 56 57 #ifdef LOSCFG_DRIVERS_MEM mem_dev_register(void)58int mem_dev_register(void) 59 { 60 return DevMemRegister(); 61 } 62 #endif 63 SystemInit(void)64void SystemInit(void) 65 { 66 #ifdef LOSCFG_DRIVERS_RANDOM 67 dprintf("dev random init ...\n"); 68 (void)DevRandomRegister(); 69 #ifdef LOSCFG_HW_RANDOM_ENABLE 70 VirtrngInit(); 71 #endif 72 #endif 73 74 #ifdef LOSCFG_DRIVERS_MEM 75 dprintf("mem dev init ...\n"); 76 extern int mem_dev_register(void); 77 mem_dev_register(); 78 #endif 79 80 #ifdef LOSCFG_DRIVERS_MMZ_CHAR_DEVICE 81 dprintf("DevMmzRegister...\n"); 82 extern int DevMmzRegister(void); 83 DevMmzRegister(); 84 #endif 85 86 dprintf("Date:%s.\n", __DATE__); 87 dprintf("Time:%s.\n", __TIME__); 88 89 #ifdef LOSCFG_DRIVERS_NETDEV 90 dprintf("net init ...\n"); 91 net_init(); 92 dprintf("\n************************************************************\n"); 93 #endif 94 95 #ifdef LOSCFG_DRIVERS_HDF 96 dprintf("DeviceManagerStart start ...\n"); 97 if (DeviceManagerStart()) { 98 PRINT_ERR("No drivers need load by hdf manager!"); 99 } 100 dprintf("DeviceManagerStart end ...\n"); 101 #endif 102 103 #ifdef LOSCFG_PLATFORM_ROOTFS 104 dprintf("OsMountRootfs start ...\n"); 105 if (LOS_GetCmdLine()) { 106 PRINT_ERR("get cmdline error!\n"); 107 } 108 if (LOS_ParseBootargs()) { 109 PRINT_ERR("parse bootargs error!\n"); 110 } 111 if (OsMountRootfs()) { 112 PRINT_ERR("mount rootfs error!\n"); 113 } 114 dprintf("OsMountRootfs end ...\n"); 115 #endif 116 117 #ifdef LOSCFG_DRIVERS_HDF_PLATFORM_UART 118 dprintf("virtual_serial_init start ...\n"); 119 if (virtual_serial_init(TTY_DEVICE) != 0) { 120 PRINT_ERR("virtual_serial_init failed"); 121 } 122 dprintf("virtual_serial_init end ...\n"); 123 dprintf("system_console_init start ...\n"); 124 if (system_console_init(SERIAL) != 0) { 125 PRINT_ERR("system_console_init failed\n"); 126 } 127 dprintf("system_console_init end ...\n"); 128 #endif 129 dprintf("OsUserInitProcess start ...\n"); 130 if (OsUserInitProcess()) { 131 PRINT_ERR("Create user init process failed!\n"); 132 return; 133 } 134 dprintf("OsUserInitProcess end ...\n"); 135 return; 136 } 137