当前位置:   article > 正文

003——移植鸿蒙

003——移植鸿蒙

目录

一、顶层Make分析

二、添加一个新的单板

2.1 Kconfig

2.2 Makefile

2.2.1 顶层Makefile 

2.2.2 platform下的Makefile

2.2.3 platform下的bsp.mk文件

2.3 编译与调试

2.4 解决链接错误

三、内核启动流程的学习

3.1 韦东山老师总结的启动四步

3.2 启动文件分析

3.3 main函数分析

3.4 OSmain函数分析

3.5 SystemInit函数分析


 

一、顶层Make分析

整体的编译框架和linux内核的一样都是分层的各自编译后由链接器来汇总

  1. # Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
  2. # Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without modification,
  5. # are permitted provided that the following conditions are met:
  6. #
  7. # 1. Redistributions of source code must retain the above copyright notice, this list of
  8. # conditions and the following disclaimer.
  9. #
  10. # 2. Redistributions in binary form must reproduce the above copyright notice, this list
  11. # of conditions and the following disclaimer in the documentation and/or other materials
  12. # provided with the distribution.
  13. #
  14. # 3. Neither the name of the copyright holder nor the names of its contributors may be used
  15. # to endorse or promote products derived from this software without specific prior written
  16. # permission.
  17. #
  18. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  20. # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  21. # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  22. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  25. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  26. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  27. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  28. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. LITEOSTOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
  30. export OS=$(shell uname -s)
  31. ifneq ($(OS), Linux)
  32. LITEOSTOPDIR := $(shell dirname $(subst \,/,$(LITEOSTOPDIR))/./)
  33. endif
  34. LITEOSTHIRDPARTY := $(LITEOSTOPDIR)/../../third_party
  35. export LITEOSTOPDIR
  36. export LITEOSTHIRDPARTY
  37. -include $(LITEOSTOPDIR)/tools/build/config.mk
  38. RM = -rm -rf
  39. MAKE = make
  40. __LIBS = libs
  41. APPS = apps
  42. ROOTFSDIR = rootfsdir
  43. ROOTFS = rootfs
  44. LITEOS_TARGET = liteos
  45. LITEOS_LIBS_TARGET = libs_target
  46. LITEOS_MENUCONFIG_H = $(LITEOSTOPDIR)/include/generated/autoconf.h
  47. LITEOS_PLATFORM_BASE = $(LITEOSTOPDIR)/platform
  48. LITEOS_PLATFORM_MENUCONFIG_H = $(LITEOS_PLATFORM_BASE)/include/menuconfig.h
  49. ifeq ($(LOSCFG_PLATFORM_HI3518EV300), y)
  50. FSTYPE = jffs2
  51. endif
  52. ifeq ($(LOSCFG_PLATFORM_HI3516DV300), y)
  53. FSTYPE = vfat
  54. endif
  55. ifeq ($(LOSCFG_PLATFORM_IMX6ULL), y)
  56. FSTYPE = jffs2
  57. endif
  58. ifeq ($(LOSCFG_PLATFORM_STM32MP157), y)
  59. FSTYPE = jffs2
  60. ROOTFS_SIZE = 0xA00000
  61. endif
  62. ROOTFS_DIR = $(OUT)/rootfs
  63. ROOTFS_ZIP = $(OUT)/rootfs.zip
  64. VERSION =
  65. all: $(OUT) $(BUILD) $(LITEOS_TARGET) $(APPS)
  66. lib: $(OUT) $(BUILD) $(LITEOS_LIBS_TARGET)
  67. help:
  68. $(HIDE)echo "-------------------------------------------------------"
  69. $(HIDE)echo "1.====make help: get help infomation of make"
  70. $(HIDE)echo "2.====make: make a debug version based the .config"
  71. $(HIDE)echo "3.====make debug: make a debug version based the .config"
  72. $(HIDE)echo "4.====make release: make a release version for all platform"
  73. $(HIDE)echo "5.====make release PLATFORM=xxx: make a release version only for platform xxx"
  74. $(HIDE)echo "6.====make rootfsdir: make a original rootfs dir"
  75. $(HIDE)echo "7.====make rootfs FSTYPE=***: make a original rootfs img"
  76. $(HIDE)echo "8.====make test: make the testsuits_app and put it into the rootfs dir"
  77. $(HIDE)echo "9.====make test_apps FSTYPE=***: make a rootfs img with the testsuits_app in it"
  78. $(HIDE)echo "xxx should be one of (hi3516cv300 hi3516ev200 hi3556av100/cortex-a53_aarch32 hi3559av100/cortex-a53_aarch64)"
  79. $(HIDE)echo "*** should be one of (jffs2)"
  80. $(HIDE)echo "-------------------------------------------------------"
  81. debug:
  82. $(HIDE)echo "=============== make a debug version ==============="
  83. $(HIDE) $(MAKE) all
  84. release:
  85. ifneq ($(PLATFORM),)
  86. $(HIDE)echo "=============== make a release version for platform $(PLATFORM) ==============="
  87. $(HIDE)$(SCRIPTS_PATH)/mklibversion.sh $(PLATFORM)
  88. else
  89. $(HIDE)echo "================make a release version for all platform ==============="
  90. $(HIDE)$(SCRIPTS_PATH)/mklibversion.sh
  91. endif
  92. ##### make dynload #####
  93. -include $(LITEOS_MK_PATH)/dynload.mk
  94. #-----need move when make version-----#
  95. ##### make lib #####
  96. $(__LIBS): $(OUT) $(CXX_INCLUDE)
  97. ifeq ($(LOSCFG_PLATFORM_IMX6ULL),y)
  98. BOARD_INCLUDE_DIR := $(LITEOSTOPDIR)/../../vendor/nxp/imx6ull/board
  99. else ifeq ($(LOSCFG_PLATFORM_STM32MP157), y)
  100. BOARD_INCLUDE_DIR := $(LITEOSTOPDIR)/../../vendor/st/stm32mp157/board
  101. else
  102. BOARD_INCLUDE_DIR := $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board
  103. endif
  104. $(OUT): $(LITEOS_MENUCONFIG_H)
  105. $(HIDE)mkdir -p $(OUT)/lib
  106. $(HIDE)$(CC) -I$(LITEOS_PLATFORM_BASE)/include -I$(BOARD_INCLUDE_DIR) \
  107. -E $(LITEOS_PLATFORM_BASE)/board.ld.S \
  108. -o $(LITEOS_PLATFORM_BASE)/board.ld -P
  109. $(BUILD):
  110. $(HIDE)mkdir -p $(BUILD)
  111. $(LITEOS_LIBS_TARGET): $(__LIBS)
  112. $(HIDE)for dir in $(LIB_SUBDIRS); \
  113. do $(MAKE) -C $$dir all || exit 1; \
  114. done
  115. $(HIDE)echo "=============== make lib done ==============="
  116. ##### make menuconfig #####
  117. export CONFIG_=LOSCFG_
  118. MENUCONFIG_PATH = $(LITEOSTOPDIR)/tools/menuconfig
  119. KCONFIG_FILE_PATH = $(LITEOSTOPDIR)/Kconfig
  120. menuconfig:$(MENUCONFIG_PATH)/mconf
  121. $< $(KCONFIG_FILE_PATH)
  122. genconfig:$(MENUCONFIG_PATH)/conf
  123. $(HIDE)mkdir -p include/config include/generated
  124. $< --silentoldconfig $(KCONFIG_FILE_PATH)
  125. -mv -f $(LITEOS_MENUCONFIG_H) $(LITEOS_PLATFORM_MENUCONFIG_H)
  126. ##### menuconfig end #######
  127. $(LITEOS_MENUCONFIG_H):
  128. ifneq ($(LITEOS_PLATFORM_MENUCONFIG_H), $(wildcard $(LITEOS_PLATFORM_MENUCONFIG_H)))
  129. $(HIDE)$(MAKE) genconfig
  130. endif
  131. $(LITEOS_TARGET): $(__LIBS)
  132. $(HIDE)touch $(LOSCFG_ENTRY_SRC)
  133. $(HIDE)for dir in $(LITEOS_SUBDIRS); \
  134. do $(MAKE) -C $$dir all || exit 1; \
  135. done
  136. $(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) $(LITEOS_DYNLDFLAGS) -Map=$(OUT)/$@.map -o $(OUT)/$@ --start-group $(LITEOS_LIBDEP) --end-group
  137. # $(SIZE) -t --common $(OUT)/lib/*.a >$(OUT)/$@.objsize
  138. $(OBJCOPY) -O binary $(OUT)/$@ $(LITEOS_TARGET_DIR)/$@.bin
  139. ifeq ($(LOSCFG_PLATFORM_STM32MP157), y)
  140. mkimage.stm32 -T stm32image -a 0xC0100000 -e 0xC0100000 -d $(LITEOS_TARGET_DIR)/$@.bin $(LITEOS_TARGET_DIR)/liteos.stm32
  141. mkimage.stm32 -A arm -O linux -T kernel -C none -a 0xC0100000 -e 0xC0100000 -n liteos-a -d $(LITEOS_TARGET_DIR)/$@.bin $(LITEOS_TARGET_DIR)/liteos_with_uboot_header.bin
  142. endif
  143. $(OBJDUMP) -t $(OUT)/$@ |sort >$(OUT)/$@.sym.sorted
  144. $(OBJDUMP) -d $(OUT)/$@ >$(OUT)/$@.asm
  145. # $(NM) -S --size-sort $(OUT)/$@ >$(OUT)/$@.size
  146. $(APPS): $(LITEOS_TARGET)
  147. $(HIDE)$(MAKE) -C apps all
  148. prepare:
  149. $(HIDE)mkdir -p $(OUT)/musl
  150. ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
  151. $(HIDE)cp -f $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/usr/lib/$(LLVM_TARGET)/a7_softfp_neon-vfpv4/libc.so $(OUT)/musl
  152. $(HIDE)cp -f $(LITEOS_COMPILER_PATH)/lib/$(LLVM_TARGET)/c++/a7_softfp_neon-vfpv4/libc++.so $(OUT)/musl
  153. else
  154. $(HIDE)cp -f $(LITEOS_COMPILER_PATH)/target/usr/lib/libc.so $(OUT)/musl
  155. $(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libstdc++.so.6 $(OUT)/musl
  156. $(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libgcc_s.so.1 $(OUT)/musl
  157. $(STRIP) $(OUT)/musl/*
  158. endif
  159. $(ROOTFSDIR): prepare $(APPS)
  160. $(HIDE)$(MAKE) clean -C apps
  161. $(HIDE)$(shell $(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT)/bin $(OUT)/musl $(ROOTFS_DIR))
  162. ifneq ($(VERSION),)
  163. $(HIDE)$(shell $(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR))
  164. endif
  165. $(ROOTFS): $(ROOTFSDIR)
  166. $(HIDE)$(shell $(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE) ${ROOTFS_SIZE})
  167. $(HIDE)cd $(ROOTFS_DIR)/.. && zip -r $(ROOTFS_ZIP) $(ROOTFS)
  168. ifneq ($(OUT), $(LITEOS_TARGET_DIR))
  169. $(HIDE)mv $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)rootfs
  170. endif
  171. clean:
  172. $(HIDE)for dir in $(LITEOS_SUBDIRS); \
  173. do $(MAKE) -C $$dir clean|| exit 1; \
  174. done
  175. $(HIDE)$(MAKE) -C apps clean
  176. $(HIDE)$(RM) $(__OBJS) $(LITEOS_TARGET) $(OUT) $(BUILD) $(LITEOS_MENUCONFIG_H) *.bak *~
  177. $(HIDE)$(RM) $(LITEOS_PLATFORM_MENUCONFIG_H)
  178. $(HIDE)$(RM) include
  179. $(HIDE)$(MAKE) cleanrootfs
  180. $(HIDE)echo "clean $(LITEOS_PLATFORM) finish"
  181. cleanall:
  182. $(HIDE)$(RM) $(LITEOSTOPDIR)/out
  183. $(HIDE)find $(LITEOS_PLATFORM_BASE)/ -name board.ld -exec rm -rf {} \;
  184. $(HIDE)cd sample/sample_osdrv;make clean;cd ../..;
  185. $(HIDE)echo "clean all"
  186. cleanrootfs:
  187. $(HIDE)$(RM) $(OUT)/rootfs
  188. $(HIDE)$(RM) $(OUT)/rootfs.zip
  189. $(HIDE)$(RM) $(OUT)/rootfs.img
  190. .PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help

下面是apps目录的make

  1. include ../.config
  2. include ./module.mk
  3. HIDE := @
  4. APPS := app
  5. all: $(APPS)
  6. # Make
  7. $(APPS):
  8. ifneq ($(APP_SUBDIRS), )
  9. $(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir ; done
  10. endif
  11. clean:
  12. ifneq ($(APP_SUBDIRS), )
  13. $(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir clean; done
  14. endif
  15. .PHONY: all $(APPS) clean

其它的也类似每一层make都有两个配套的mk文件来描述资源

如果这个APP_SUBDIRS不是空的就会遍历每个目录去make

        最底层的make和源码放一起的这些就会去真正的进行编译操作。里面放了对应的编译规则

好处就是整个软件的最终结果被按功能分别编译,我们可以针对性的开启对应功能的编译,都编译后统一链接。 

        其实随着不断学习,感觉理解起来变得越来越容易了,以前觉得大型工程中的makefile是座山,现在充其量就是个小土包。有这种感觉的前提是我自己从0到1做了一次编译框架。然后现在再来看就有这种感觉了。

二、添加一个新的单板

        这个地方要感谢韦东山老师了,因为鸿蒙只适配海思的芯片,别人想移植就得知道全部源码才行。但是为了不泄露机密,核心的代码是不开源的。我们没法直接移植。韦老师接触过这部分做个一个补丁文件可以根据这个文件不断拓展新单板。按老师的话说留下了一个火种。

        既然这样我想试试能不能移植到我的另一块单板exynos4412上。不一定会成功如果耗时过多的话我就放到毕业后再去做。下面记录一下移植过程。

2.1 Kconfig

vi platform/Kconfig

        仿照韦东山老师添加的两个我也添加了一个exynos4412.

        现在其实有个问题,大家看图应该可以看出来,其它是四个都是ARM Cotex-A7的我加的这个是A9的。在鸿蒙的官网上没说是不是支持A9,(不排除我没找到的情况)。在老师的技术交流群里也没有人能回答我,咱们就当他支持先试试好啦。

现在就有这个咯

为什么缺了一块内容

        因为当前Kconfig里只有A7的配置。没办法了或许能改但是要改的地方还是有点多的暂时先不弄了。

再来看看makefile

2.2 Makefile

2.2.1 顶层Makefile 

指定文件系统的类型和大小

然后指定我们取board资源的目录

这里也有修改,但是不清楚改了啥,后面看下源码对比一手

        然后是这里看样子是对bin文件的一些处理这里只有stm32mp157的,老师说我们的可以放到后面做接着往下看。

这里也有改动,看样子是跟文件系统的修改

顶层的makefile就改完了

2.2.2 platform下的Makefile

        这里是一个匹配规则如果这里的某个芯片i型号被选择了就把对应的源码加到编译的对象里

我们来添加一下。

2.2.3 platform下的bsp.mk文件

  1. HWI_TYPE := arm/interrupt/gic

    • HWI_TYPE 可能是指硬件中断(HWI)的类型或使用的硬件中断控制器(GIC)。arm/interrupt/gic 表示使用ARM架构下的GIC(Generic Interrupt Controller)作为中断控制器。
  2. TIMER_TYPE := hisoc/timer

    • TIMER_TYPE 表示定时器的类型或所使用的硬件定时器。hisoc/timer 可能是特定于某种SoC(System on a Chip)的定时器实现。
  3. HRTIMER_TYPE := hisoc/hrtimer

    • HRTIMER_TYPE 可能是高精度定时器的类型或实现。hisoc/hrtimer 可能是特定于某种SoC的高精度定时器。
  4. NET_TYPE := hieth

    • NET_TYPE 表示网络类型的配置或使用的网络接口。hieth 可能是某种特定的网络硬件或驱动。
  5. UART_TYPE := amba_pl011

    • UART_TYPE 表示UART(通用异步收发传输器)的类型或使用的硬件。amba_pl011 是ARM公司的一个UART控制器。
  6. USB_TYPE := usb3.0_hi3518ev300

    • USB_TYPE 表示USB的类型或使用的USB控制器。usb3.0_hi3518ev300 可能是特定于HI3518EV300芯片的USB 3.0控制器。
  7. LITEOS_CMACRO_TEST += -DTEST3518EV300

    • 这一行在LITEOS_CMACRO_TEST变量中添加了一个编译宏定义-DTEST3518EV300。这通常用于在编译时定义特定的宏,可能用于条件编译或特定的测试目的。

        串口和USB并没有处理,不知道什么原因往下接着看。

        然后就是这里指定一下平台总线这一层的头文件路径。

2.3 编译与调试

make clean报错找不到脚本 

然后去对应文件找,发现和下面这个变量有关

向上找,发现没设置编译器的路径就会调用这个脚本来获取路径

设置不了

在Kconfig里查找发现没有添加我们的单板类型

现在就有了。使用默认的这个编译器

可以clean成功了

找不到board下的这个头文件

因为我们用的A9不是A7回去先改成A7试试

报错在输出目录找不到inculude的这个头文件

这里应该有很多东西可是我们没有

不对哦,想起来了,我把.config拿来了一份也不对,board我往上翻一下修改

破案了

完蛋还是这个错误

这个文件find不到

等等

../../

我悟了

经过我的一番复制

终于和韦东山老师的一样了。

改回A9报错巨多还是先按A7来吧

上面报错对应shell下的这几个目录

 

ok再次编译只剩链接错误

2.4 解决链接错误

 找不到这个库

修改一下mk文件的名字

还有里面的名字

:1,$s/IMAX6ULL_BASE_DIR/EXYNOS4412_BASE_DIR

好再来编译一下

他说宏没定义

vi /home/book/program/openharmony/vendor/samsung/exynos4412/driver/mtd/spi_nor/src/common/spinor.c =150

又来一个宏没定义

我是基于6ull改的所以和韦东山老师的不太一样

又来个新的错误

这些其实都是对应mk文件和我们的新的文件路径名匹配错误导致的

解决掉了一个还有两个

drivers/hdf/lite/hdf_lite.mk

vendor/democom/hdf/hdf_vendor.mk

grep一下

还是这个mtd的问题

这里明明定义了但是说没被定义

说明还是makefile的问题,没引过去

这里我取巧一下直接看已修改的driver文件

补完报错没变证明不是因为这个

这个mtd到底是哪里呢

又查了另一个,这俩难兄难弟都在这个头文件里定义的

        回去看了遍视频发现我没把分区mount的操作这里注释掉,也就是说我不用和文件系统相关的操作就暂时不会出那两个错误


ld.lld: error: undefined symbol: GetDevSpinorOps
>>> referenced by ld-temp.o
>>>               lto.tmp:(SystemInit)

ld.lld: error: undefined symbol: GetMtdCharFops
>>> referenced by ld-temp.o
>>>               lto.tmp:(SystemInit)
Makefile:165: recipe for target 'liteos' failed
make: *** [liteos] Error 1
 

这俩是关联的。

暂时没错误了

三、内核启动流程的学习

这里我就完全照搬老师的思想了,后面我更全面的了解后在自己总结一个

3.1 韦东山老师总结的启动四步

内核启动流程可以分为4步骤(非官方):

  • 启动

    • 使用汇编代码编写,涉及非常底层的设置,比如CPU设置、代码重定位等等

    • 地址映射也在这里实现

    • 它最终会调用main函数

  • main函数

    • 以后的代码,基本都是使用C语言编写了

    • 主要工作是:调用OsMain进行各类初始化、最终会启动用户程序

  • OsMain函数

    • 进行操作系统层面的初始化,比如异常初始化、任务初始化、IPC初始化

    • 调用SystemInit

  • SystemInit

    • 偏向于应用程序的初始化

    • 挂载根文件系统

    • 启动第一个用户进程

        所有的软件运行都是和这个类似的其实,上电后就是只能跑一个程序从启动文件开始跳到C的主函数,在ARM的汇编里就是b main。我看过很多很多的代码包括裸机环境的,带RTOS的以及linux的。都是从汇编跳到最初的主函数,然后系统级别的程序来初始化后面的环境变量。裸机环境没有多任务的话就是while1死循环,有多任务的话就是搞个状态机的机制做任务跳转,因为只有一个核心永远都是单线程的。看似多人只不过是切换的快。可能10ns就换一次任务。

        而操作系统环境要做的就比较多了,多核理论上是可以真的多线程的。只是线程由大脑统一调度。光有脑子没有配套的硬件设备也不行啊。就得把内存给大家分一下。不然一人用一会不还是单线程么。有mpu(有的也叫mmu叫什么的都有反正就是管理内存的。cpu不能直接用物理地址,虚拟的地址都由它来分配)的话这时候他就该发挥作用了。偏了。回到我们的主题往下看。

3.2 启动文件分析

启动文件藏的比较深

最前面一定是初始化栈空间和向量表

  1. /*
  2. * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
  3. * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this list of
  9. * conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice, this list
  12. * of conditions and the following disclaimer in the documentation and/or other materials
  13. * provided with the distribution.
  14. *
  15. * 3. Neither the name of the copyright holder nor the names of its contributors may be used
  16. * to endorse or promote products derived from this software without specific prior written
  17. * permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  21. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  23. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  26. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  27. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  28. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  29. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #define ASSEMBLY
  32. #include "arch_config.h"
  33. #include "los_vm_boot.h"
  34. #include "los_vm_zone.h"
  35. #include "los_mmu_descriptor_v6.h"
  36. #undef ASSEMBLY
  37. .global __exc_stack_top
  38. .global __irq_stack_top
  39. .global __fiq_stack_top
  40. .global __svc_stack_top
  41. .global __abt_stack_top
  42. .global __undef_stack_top
  43. .global __exc_stack
  44. .global __irq_stack
  45. .global __fiq_stack
  46. .global __svc_stack
  47. .global __abt_stack
  48. .global __undef_stack
  49. .extern __bss_start
  50. .extern __bss_end
  51. .extern hal_clock_initialize_start
  52. .extern los_bss_init
  53. .extern _osExceptFiqHdl
  54. .extern _osExceptAddrAbortHdl
  55. .extern _osExceptDataAbortHdl
  56. .extern _osExceptPrefetchAbortHdl
  57. .extern _osExceptSwiHdl
  58. .extern _osExceptUndefInstrHdl
  59. .extern __stack_chk_guard_setup
  60. .extern g_firstPageTable
  61. .extern g_mmuJumpPageTable
  62. .equ MPIDR_CPUID_MASK, 0xffU
  63. .fpu vfpv4
  64. .arm
  65. /* param0 is stack bottom, param1 is stack size, r11 hold cpu id */
  66. .macro EXC_SP_SET param0, param1
  67. ldr r1, =\param0
  68. mov r0, \param1
  69. bl sp_set
  70. .endm
  71. /* param0 is stack top, param1 is stack size, param2 is magic num */
  72. .macro STACK_MAGIC_SET param0, param1, param2
  73. ldr r0, =\param0
  74. mov r1, \param1
  75. ldr r2, =\param2
  76. bl excstack_magic
  77. .endm
  78. /* param0 is physical address, param1 virtual address, param2 is sizes, param3 is flag */
  79. .macro PAGE_TABLE_SET param0, param1, param2, param3
  80. ldr r6, =\param0
  81. ldr r7, =\param1
  82. ldr r8, =\param2
  83. ldr r10, =\param3
  84. bl page_table_build
  85. .endm
  86. .code 32
  87. .section ".vectors","ax"
  88. __exception_handlers:
  89. /*
  90. *Assumption: ROM code has these vectors at the hardware reset address.
  91. *A simple jump removes any address-space dependencies [i.e. safer]
  92. */
  93. b reset_vector
  94. b _osExceptUndefInstrHdl
  95. b _osExceptSwiHdl
  96. b _osExceptPrefetchAbortHdl
  97. b _osExceptDataAbortHdl
  98. b _osExceptAddrAbortHdl
  99. b OsIrqHandler
  100. b _osExceptFiqHdl
  101. /* Startup code which will get the machine into supervisor mode */
  102. .global reset_vector
  103. .type reset_vector,function
  104. reset_vector:
  105. #if defined(LOSCFG_PLATFORM_STM32MP157)
  106. ldr sp, =0xc0000000 + 0x1000000
  107. mov r0, #'S'
  108. bl uart_putc_phy
  109. #endif
  110. #if 1
  111. /*
  112. * disable interrupts (FIQ and IRQ), also set the cpu to SVC32 mode,
  113. * except if in HYP mode already
  114. */
  115. mrs r0, cpsr
  116. and r1, r0, #0x1f @ mask mode bits
  117. teq r1, #0x1a @ test for HYP mode
  118. bicne r0, r0, #0x1f @ clear all mode bits
  119. orrne r0, r0, #0x13 @ set SVC mode
  120. orr r0, r0, #0xc0 @ disable FIQ and IRQ
  121. msr cpsr,r0
  122. /*
  123. * If I-cache is enabled invalidate it
  124. */
  125. mcr p15, 0, r0, c7, c5, 0 @ invalidate icache
  126. mcr p15, 0, r0, c7, c10, 4 @ DSB
  127. mcr p15, 0, r0, c7, c5, 4 @ ISB
  128. /* do some early cpu setup: i/d cache disable, mmu disabled */
  129. // mrc p15, 0, r0, c1, c0, 0
  130. // bic r0, #(1<<12)
  131. // bic r0, #(1<<2 | 1<<0)
  132. // mcr p15, 0, r0, c1, c0, 0
  133. #endif
  134. /* r11: delta of physical address and virtual address */
  135. adr r11, pa_va_offset
  136. ldr r0, [r11]
  137. sub r11, r11, r0
  138. /* if we need to relocate to proper location or not */
  139. adr r4, __exception_handlers /* r4: base of load address */
  140. ldr r5, =SYS_MEM_BASE /* r5: base of physical address */
  141. subs r12, r4, r5 /* r12: delta of load address and physical address */
  142. beq reloc_img_to_bottom_done /* if we load image at the bottom of physical address */
  143. #if defined(LOSCFG_PLATFORM_STM32MP157)
  144. mov r0, #'R'
  145. bl uart_putc_phy
  146. #endif
  147. /* we need to relocate image at the bottom of physical address */
  148. ldr r7, =__exception_handlers /* r7: base of linked address (or vm address) */
  149. ldr r6, =__bss_start /* r6: end of linked address (or vm address) */
  150. sub r6, r7 /* r6: delta of linked address (or vm address) */
  151. add r6, r4 /* r6: end of load address */
  152. reloc_img_to_bottom_loop:
  153. ldr r7, [r4], #4
  154. str r7, [r5], #4
  155. cmp r4, r6
  156. bne reloc_img_to_bottom_loop
  157. sub pc, r12
  158. nop
  159. sub r11, r11, r12 /* r11: eventual address offset */
  160. reloc_img_to_bottom_done:
  161. #if defined(LOSCFG_PLATFORM_STM32MP157)
  162. mov r0, #'D'
  163. bl uart_putc_phy
  164. #endif
  165. ldr r4, =g_firstPageTable /* r4: physical address of translation table and clear it */
  166. add r4, r4, r11
  167. bl page_table_clear
  168. PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
  169. #if defined(LOSCFG_PLATFORM_IMX6ULL) || defined(LOSCFG_PLATFORM_STM32MP157)
  170. PAGE_TABLE_SET DDR_RAMFS_ADDR, DDR_RAMFS_VBASE, DDR_RAMFS_SIZE, MMU_INITIAL_MAP_DEVICE
  171. PAGE_TABLE_SET LCD_FB_BASE, LCD_FB_VBASE, LCD_FB_SIZE, MMU_INITIAL_MAP_DEVICE
  172. #endif
  173. PAGE_TABLE_SET SYS_MEM_BASE, KERNEL_VMM_BASE, KERNEL_VMM_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
  174. PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_DEVICE_BASE, PERIPH_DEVICE_SIZE, MMU_INITIAL_MAP_DEVICE
  175. PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_CACHED_BASE, PERIPH_CACHED_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
  176. PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_UNCACHED_BASE, PERIPH_UNCACHED_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
  177. #if defined(LOSCFG_PLATFORM_STM32MP157)
  178. PAGE_TABLE_SET GIC_PHY_BASE, GIC_VIRT_BASE, GIC_VIRT_SIZE, MMU_INITIAL_MAP_DEVICE
  179. #endif
  180. orr r8, r4, #MMU_TTBRx_FLAGS /* r8 = r4 and set cacheable attributes on translation walk */
  181. ldr r4, =g_mmuJumpPageTable /* r4: jump pagetable vaddr */
  182. add r4, r4, r11
  183. ldr r4, [r4]
  184. add r4, r4, r11 /* r4: jump pagetable paddr */
  185. bl page_table_clear
  186. /* build 1M section mapping, in order to jump va during turing on mmu:pa == pa, va == pa */
  187. mov r6, pc
  188. mov r7, r6 /* r7: pa (MB aligned)*/
  189. lsr r6, r6, #20 /* r6: va l1 index */
  190. ldr r10, =MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
  191. add r12, r10, r6, lsl #20 /* r12: pa |flags */
  192. str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[paIndex] = pt entry */
  193. rsb r7, r11, r6, lsl #20 /* r7: va */
  194. str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[vaIndex] = pt entry */
  195. bl mmu_setup /* set up the mmu */
  196. #if defined(LOSCFG_PLATFORM_STM32MP157)
  197. mov r0, #'M'
  198. bl uart_putc_virt
  199. #endif
  200. /* get cpuid and keep it in r11 */
  201. mrc p15, 0, r11, c0, c0, 5
  202. and r11, r11, #MPIDR_CPUID_MASK
  203. cmp r11, #0
  204. bne excstatck_loop_done
  205. excstatck_loop:
  206. /* clear out the interrupt and exception stack and set magic num to check the overflow */
  207. ldr r0, =__undef_stack
  208. ldr r1, =__exc_stack_top
  209. bl stack_init
  210. STACK_MAGIC_SET __undef_stack, #OS_EXC_UNDEF_STACK_SIZE, OS_STACK_MAGIC_WORD
  211. STACK_MAGIC_SET __abt_stack, #OS_EXC_ABT_STACK_SIZE, OS_STACK_MAGIC_WORD
  212. STACK_MAGIC_SET __irq_stack, #OS_EXC_IRQ_STACK_SIZE, OS_STACK_MAGIC_WORD
  213. STACK_MAGIC_SET __fiq_stack, #OS_EXC_FIQ_STACK_SIZE, OS_STACK_MAGIC_WORD
  214. STACK_MAGIC_SET __svc_stack, #OS_EXC_SVC_STACK_SIZE, OS_STACK_MAGIC_WORD
  215. STACK_MAGIC_SET __exc_stack, #OS_EXC_STACK_SIZE, OS_STACK_MAGIC_WORD
  216. excstatck_loop_done:
  217. warm_reset:
  218. /* initialize interrupt/exception environments */
  219. mov r0, #(CPSR_IRQ_DISABLE |CPSR_FIQ_DISABLE|CPSR_IRQ_MODE)
  220. msr cpsr, r0
  221. EXC_SP_SET __irq_stack_top, #OS_EXC_IRQ_STACK_SIZE
  222. mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_UNDEF_MODE)
  223. msr cpsr, r0
  224. EXC_SP_SET __undef_stack_top, #OS_EXC_UNDEF_STACK_SIZE
  225. mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_ABT_MODE)
  226. msr cpsr, r0
  227. EXC_SP_SET __abt_stack_top, #OS_EXC_ABT_STACK_SIZE
  228. mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_FIQ_MODE)
  229. msr cpsr, r0
  230. EXC_SP_SET __fiq_stack_top, #OS_EXC_FIQ_STACK_SIZE
  231. /* initialize CPSR (machine state register) */
  232. mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SVC_MODE)
  233. msr cpsr, r0
  234. /* Note: some functions in LIBGCC1 will cause a "restore from SPSR"!! */
  235. msr spsr, r0
  236. /* set svc stack, every cpu has OS_EXC_SVC_STACK_SIZE stack */
  237. ldr r0, =__svc_stack_top
  238. mov r2, #OS_EXC_SVC_STACK_SIZE
  239. mul r2, r2, r11
  240. sub r0, r0, r2
  241. mov sp, r0
  242. #ifndef LOSCFG_PLATFORM_STM32MP157
  243. /* enable fpu+neon */
  244. MRC p15, 0, r0, c1, c1, 2
  245. ORR r0, r0, #0xC00
  246. BIC r0, r0, #0xC000
  247. MCR p15, 0, r0, c1, c1, 2
  248. LDR r0, =(0xF << 20)
  249. MCR p15, 0, r0, c1, c0, 2
  250. #endif
  251. MOV r3, #0x40000000
  252. VMSR FPEXC, r3
  253. LDR r0, =__exception_handlers
  254. MCR p15, 0, r0, c12, c0, 0
  255. cmp r11, #0
  256. bne cpu_start
  257. clear_bss:
  258. ldr r1, =__bss_start
  259. ldr r2, =__bss_end
  260. mov r0, #0
  261. bss_loop:
  262. cmp r1, r2
  263. strlo r0, [r1], #4
  264. blo bss_loop
  265. #if defined(LOSCFG_CC_STACKPROTECTOR_ALL) || \
  266. defined(LOSCFG_CC_STACKPROTECTOR_STRONG) || \
  267. defined(LOSCFG_CC_STACKPROTECTOR)
  268. bl __stack_chk_guard_setup
  269. #endif
  270. #ifdef LOSCFG_GDB_DEBUG
  271. /* GDB_START - generate a compiled_breadk,This function will get GDB stubs started, with a proper environment */
  272. bl GDB_START
  273. .word 0xe7ffdeff
  274. #endif
  275. #if defined(LOSCFG_PLATFORM_STM32MP157)
  276. mov r0, 'm'
  277. bl uart_putc_virt
  278. #endif
  279. bl main
  280. _start_hang:
  281. b _start_hang
  282. mmu_setup:
  283. mov r12, #0
  284. mcr p15, 0, r12, c8, c7, 0 /* Set c8 to control the TLB and set the mapping to invalid */
  285. isb
  286. mcr p15, 0, r12, c2, c0, 2 /* Initialize the c2 register */
  287. isb
  288. orr r12, r4, #MMU_TTBRx_FLAGS
  289. mcr p15, 0, r12, c2, c0, 0 /* Set attributes and set temp page table */
  290. isb
  291. mov r12, #0x7 /* 0b0111 */
  292. mcr p15, 0, r12, c3, c0, 0 /* Set DACR with 0b0111, client and manager domian */
  293. isb
  294. mrc p15, 0, r12, c1, c0, 0
  295. bic r12, #(1 << 29 | 1 << 28)
  296. orr r12, #(1 << 0)
  297. bic r12, #(1 << 1)
  298. orr r12, #(1 << 2)
  299. orr r12, #(1 << 12)
  300. mcr p15, 0, r12, c1, c0, 0 /* Set SCTLR with r12: Turn on the MMU, I/D cache Disable TRE/AFE */
  301. isb
  302. ldr pc, =1f /* Convert to VA */
  303. 1:
  304. mcr p15, 0, r8, c2, c0, 0 /* Go to the base address saved in C2: Jump to the page table */
  305. isb
  306. mov r12, #0
  307. mcr p15, 0, r12, c8, c7, 0
  308. isb
  309. sub lr, r11 /* adjust lr with delta of physical address and virtual address */
  310. bx lr
  311. .code 32
  312. .global reset_platform
  313. .type reset_platform,function
  314. reset_platform:
  315. #ifdef A7SEM_HAL_ROM_MONITOR
  316. /* initialize CPSR (machine state register) */
  317. mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SVC_MODE)
  318. msr cpsr, r0
  319. b warm_reset
  320. #else
  321. mov r0, #0
  322. mov pc, r0 // Jump to reset vector
  323. #endif
  324. cpu_start:
  325. bl secondary_cpu_start
  326. b .
  327. /*
  328. * set sp for current cpu
  329. * r1 is stack bottom, r0 is stack size, r11 hold cpu id
  330. */
  331. sp_set:
  332. mul r3, r0, r11
  333. sub r2, r1, r3
  334. mov sp, r2
  335. bx lr /* set sp */
  336. /*
  337. * r4: page table base address
  338. * r5 and r6 will be used as variable
  339. */
  340. page_table_clear:
  341. mov r5, #0
  342. mov r6, #0
  343. 0:
  344. str r5, [r4, r6, lsl #2]
  345. add r6, #1
  346. cmp r6, #0x1000 /* r6 < 4096 */
  347. blt 0b
  348. bx lr
  349. /*
  350. * r4: page table base address
  351. * r6: physical address
  352. * r7: virtual address
  353. * r8: sizes
  354. * r10: flags
  355. * r9 and r12 will be used as variable
  356. */
  357. page_table_build:
  358. mov r9, r6
  359. bfc r9, #20, #12 /* r9: pa % MB */
  360. add r8, r8, r9
  361. add r8, r8, #(1 << 20)
  362. sub r8, r8, #1
  363. lsr r6, #20 /* r6 = physical address / MB */
  364. lsr r7, #20 /* r7 = virtual address / MB */
  365. lsr r8, #20 /* r8 = roundup(size, MB) */
  366. page_table_build_loop:
  367. orr r12, r10, r6, lsl #20 /* r12: flags | physAddr */
  368. str r12, [r4, r7, lsl #2] /* gPgTable[l1Index] = physAddr | flags */
  369. add r6, #1 /* physAddr+ */
  370. add r7, #1 /* l1Index++ */
  371. subs r8, #1 /* sizes-- */
  372. bne page_table_build_loop
  373. bx lr
  374. /*
  375. * init stack to initial value
  376. * r0 is stack mem start, r1 is stack mem end
  377. */
  378. stack_init:
  379. ldr r2, =OS_STACK_INIT
  380. ldr r3, =OS_STACK_INIT
  381. /* Main loop sets 32 bytes at a time. */
  382. stack_init_loop:
  383. .irp offset, #0, #8, #16, #24
  384. strd r2, r3, [r0, \offset]
  385. .endr
  386. add r0, #32
  387. cmp r0, r1
  388. blt stack_init_loop
  389. bx lr
  390. pa_va_offset:
  391. .word .
  392. /*
  393. * set magic num to stack top for all cpu
  394. * r0 is stack top, r1 is stack size, r2 is magic num
  395. */
  396. excstack_magic:
  397. mov r3, #0
  398. excstack_magic_loop:
  399. str r2, [r0]
  400. add r0, r0, r1
  401. add r3, r3, #1
  402. cmp r3, #CORE_NUM
  403. blt excstack_magic_loop
  404. bx lr
  405. /*
  406. * 0xe51ff004 = "ldr pc, [pc, #-4]"
  407. * next addr value will be the real booting addr
  408. */
  409. _bootaddr_setup:
  410. mov r0, #0
  411. ldr r1, =0xe51ff004
  412. str r1, [r0]
  413. add r0, r0, #4
  414. ldr r1, =SYS_MEM_BASE
  415. str r1, [r0]
  416. dsb
  417. isb
  418. bx lr
  419. init_done:
  420. .long 0xDEADB00B
  421. .code 32
  422. .data
  423. init_flag:
  424. .balign 4
  425. .long 0
  426. /*
  427. * Temporary interrupt stack
  428. */
  429. .section ".int_stack", "wa", %nobits
  430. .align 3
  431. __undef_stack:
  432. .space OS_EXC_UNDEF_STACK_SIZE * CORE_NUM
  433. __undef_stack_top:
  434. __abt_stack:
  435. .space OS_EXC_ABT_STACK_SIZE * CORE_NUM
  436. __abt_stack_top:
  437. __irq_stack:
  438. .space OS_EXC_IRQ_STACK_SIZE * CORE_NUM
  439. __irq_stack_top:
  440. __fiq_stack:
  441. .space OS_EXC_FIQ_STACK_SIZE * CORE_NUM
  442. __fiq_stack_top:
  443. __svc_stack:
  444. .space OS_EXC_SVC_STACK_SIZE * CORE_NUM
  445. __svc_stack_top:
  446. __exc_stack:
  447. .space OS_EXC_STACK_SIZE * CORE_NUM
  448. __exc_stack_top:

        具体内容自行阅读

        这里有两个启动代码内容看起来也有点像,不太清楚区别,可以一个是单核启动一个是多核启动。

        之前研究exynos4412的时候发现cpu0内就有控制其它三个核心的寄存器。所以启动时是cpu0先启动再去选择是不是引导其它内核启动。不清楚别的处理器是不是也是这样设计的。

        下面是对上面代码的简单解析。

3.3 main函数分析

  1. /*
  2. * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
  3. * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this list of
  9. * conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice, this list
  12. * of conditions and the following disclaimer in the documentation and/or other materials
  13. * provided with the distribution.
  14. *
  15. * 3. Neither the name of the copyright holder nor the names of its contributors may be used
  16. * to endorse or promote products derived from this software without specific prior written
  17. * permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  21. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  23. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  26. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  27. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  28. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  29. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #include "los_config.h"
  32. #include "los_task_pri.h"
  33. #include "los_swtmr_pri.h"
  34. #include "los_printf.h"
  35. #include "los_atomic.h"
  36. #include "gic_common.h"
  37. #include "uart.h"
  38. #include "los_process_pri.h"
  39. #include "los_arch_mmu.h"
  40. #if (LOSCFG_KERNEL_SMP == YES)
  41. STATIC Atomic g_ncpu = 1;
  42. #endif
  43. LITE_OS_SEC_TEXT_INIT VOID OsSystemInfo(VOID)
  44. {
  45. #ifdef LOSCFG_DEBUG_VERSION
  46. const CHAR *buildType = "debug";
  47. #else
  48. const CHAR *buildType = "release";
  49. #endif /* LOSCFG_DEBUG_VERSION */
  50. PRINT_RELEASE("\n******************Welcome******************\n\n"
  51. "Processor : %s"
  52. #if (LOSCFG_KERNEL_SMP == YES)
  53. " * %d\n"
  54. "Run Mode : SMP\n"
  55. #else
  56. "\n"
  57. "Run Mode : UP\n"
  58. #endif
  59. "GIC Rev : %s\n"
  60. "build time : %s %s\n"
  61. "Kernel : %s %d.%d.%d.%d/%s\n"
  62. "\n*******************************************\n",
  63. LOS_CpuInfo(),
  64. #if (LOSCFG_KERNEL_SMP == YES)
  65. LOSCFG_KERNEL_SMP_CORE_NUM,
  66. #endif
  67. HalIrqVersion(), __DATE__, __TIME__,\
  68. KERNEL_NAME, KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE, buildType);
  69. }
  70. LITE_OS_SEC_TEXT_INIT VOID secondary_cpu_start(VOID)
  71. {
  72. #if (LOSCFG_KERNEL_SMP == YES)
  73. UINT32 cpuid = ArchCurrCpuid();
  74. OsArchMmuInitPerCPU();
  75. OsCurrTaskSet(OsGetMainTask());
  76. /* increase cpu counter */
  77. LOS_AtomicInc(&g_ncpu);
  78. /* store each core's hwid */
  79. CPU_MAP_SET(cpuid, OsHwIDGet());
  80. HalIrqInitPercpu();
  81. OsCurrProcessSet(OS_PCB_FROM_PID(OsGetKernelInitProcessID()));
  82. OsSwtmrInit();
  83. OsIdleTaskCreate();
  84. OsStart();
  85. while (1) {
  86. __asm volatile("wfi");
  87. }
  88. #endif
  89. }
  90. #if (LOSCFG_KERNEL_SMP == YES)
  91. #ifdef LOSCFG_TEE_ENABLE
  92. #define TSP_CPU_ON 0xb2000011UL
  93. STATIC INT32 raw_smc_send(UINT32 cmd)
  94. {
  95. register UINT32 smc_id asm("r0") = cmd;
  96. do {
  97. asm volatile (
  98. "mov r0, %[a0]\n"
  99. "smc #0\n"
  100. : [a0] "+r"(smc_id)
  101. );
  102. } while (0);
  103. return (INT32)smc_id;
  104. }
  105. STATIC VOID trigger_secondary_cpu(VOID)
  106. {
  107. (VOID)raw_smc_send(TSP_CPU_ON);
  108. }
  109. LITE_OS_SEC_TEXT_INIT VOID release_secondary_cores(VOID)
  110. {
  111. trigger_secondary_cpu();
  112. /* wait until all APs are ready */
  113. while (LOS_AtomicRead(&g_ncpu) < LOSCFG_KERNEL_CORE_NUM) {
  114. asm volatile("wfe");
  115. }
  116. }
  117. #else
  118. #define CLEAR_RESET_REG_STATUS(regval) (regval) &= ~(1U << 2)
  119. LITE_OS_SEC_TEXT_INIT VOID release_secondary_cores(VOID)
  120. {
  121. UINT32 regval;
  122. /* clear the slave cpu reset */
  123. READ_UINT32(regval, PERI_CRG30_BASE);
  124. CLEAR_RESET_REG_STATUS(regval);
  125. WRITE_UINT32(regval, PERI_CRG30_BASE);
  126. /* wait until all APs are ready */
  127. while (LOS_AtomicRead(&g_ncpu) < LOSCFG_KERNEL_CORE_NUM) {
  128. asm volatile("wfe");
  129. }
  130. }
  131. #endif /* LOSCFG_TEE_ENABLE */
  132. #endif /* LOSCFG_KERNEL_SMP */
  133. LITE_OS_SEC_TEXT_INIT INT32 main(VOID)
  134. {
  135. UINT32 uwRet = LOS_OK;
  136. OsSetMainTask();
  137. OsCurrTaskSet(OsGetMainTask());
  138. PRINT_RELEASE("\n******************Main******************\n\n");
  139. /* set smp system counter freq */
  140. #if (LOSCFG_KERNEL_SMP == YES)
  141. #ifndef LOSCFG_TEE_ENABLE
  142. HalClockFreqWrite(OS_SYS_CLOCK);
  143. #endif
  144. #endif
  145. /* system and chip info */
  146. OsSystemInfo();
  147. PRINT_RELEASE("\nmain core booting up...\n");
  148. uwRet = OsMain();
  149. if (uwRet != LOS_OK) {
  150. return LOS_NOK;
  151. }
  152. #if (LOSCFG_KERNEL_SMP == YES)
  153. PRINT_RELEASE("releasing %u secondary cores\n", LOSCFG_KERNEL_SMP_CORE_NUM - 1);
  154. release_secondary_cores();
  155. #endif
  156. CPU_MAP_SET(0, OsHwIDGet());
  157. OsStart();
  158. while (1) {
  159. __asm volatile("wfi");
  160. }
  161. }

3.4 OSmain函数分析

 

  1. /*
  2. * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
  3. * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this list of
  9. * conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice, this list
  12. * of conditions and the following disclaimer in the documentation and/or other materials
  13. * provided with the distribution.
  14. *
  15. * 3. Neither the name of the copyright holder nor the names of its contributors may be used
  16. * to endorse or promote products derived from this software without specific prior written
  17. * permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  21. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  23. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  26. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  27. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  28. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  29. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #include "los_config.h"
  32. #include "string.h"
  33. #include "stdio.h"
  34. #include "los_oom.h"
  35. #ifdef LOSCFG_COMPAT_LINUXKPI
  36. #include "linux/workqueue.h"
  37. #include "linux/module.h"
  38. #endif
  39. #include "los_sys.h"
  40. #include "los_tick.h"
  41. #include "los_task_pri.h"
  42. #include "los_printf.h"
  43. #include "los_swtmr.h"
  44. #include "los_swtmr_pri.h"
  45. #include "los_timeslice_pri.h"
  46. #include "los_memory_pri.h"
  47. #include "los_sem_pri.h"
  48. #include "los_mux_pri.h"
  49. #include "los_queue_pri.h"
  50. #include "los_memstat_pri.h"
  51. #include "los_hwi_pri.h"
  52. #include "los_spinlock.h"
  53. #include "los_mp.h"
  54. #include "los_atomic.h"
  55. #include "los_exc_pri.h"
  56. #include "gic_common.h"
  57. #include "los_vm_boot.h"
  58. #ifdef LOSCFG_FS_VFS
  59. #include "fs/fs.h"
  60. #include "fs/fs_operation.h"
  61. #endif
  62. #if (LOSCFG_KERNEL_TRACE == YES)
  63. #include "los_trace.h"
  64. #endif
  65. #ifdef LOSCFG_KERNEL_CPUP
  66. #include "los_cpup_pri.h"
  67. #endif
  68. #ifdef LOSCFG_COMPAT_POSIX
  69. #include "pprivate.h"
  70. #endif
  71. #ifdef LOSCFG_DRIVERS_HDF_PLATFORM_UART
  72. #include "console.h"
  73. #endif
  74. #ifdef LOSCFG_KERNEL_TICKLESS
  75. #include "los_tickless.h"
  76. #endif
  77. #ifdef LOSCFG_ARCH_CORTEX_M7
  78. #include "los_exc_pri.h"
  79. #endif
  80. #ifdef LOSCFG_MEM_RECORDINFO
  81. #include "los_memrecord_pri.h"
  82. #endif
  83. #include "los_hw_tick_pri.h"
  84. #include "los_hwi_pri.h"
  85. #if defined(LOSCFG_HW_RANDOM_ENABLE) || defined (LOSCFG_DRIVERS_RANDOM)
  86. #include "randomdev.h"
  87. #include "yarrow.h"
  88. #endif
  89. #ifdef LOSCFG_SHELL_DMESG
  90. #include "dmesg_pri.h"
  91. #endif
  92. #ifdef LOSCFG_SHELL_LK
  93. #include "shell_pri.h"
  94. #endif
  95. #ifdef LOSCFG_KERNEL_PIPE
  96. #include "pipe_common.h"
  97. #endif
  98. #include "los_process_pri.h"
  99. #include "los_futex_pri.h"
  100. #ifdef LOSCFG_KERNEL_VDSO
  101. #include "los_vdso.h"
  102. #endif
  103. #if (LOSCFG_KERNEL_LITEIPC == YES)
  104. #include "hm_liteipc.h"
  105. #endif
  106. #ifdef LOSCFG_DRIVERS_HIEVENT
  107. #include "hievent_driver.h"
  108. #endif
  109. #if (LOSCFG_BASE_CORE_HILOG == YES)
  110. #include "los_hilog.h"
  111. #endif
  112. #ifdef __cplusplus
  113. #if __cplusplus
  114. extern "C" {
  115. #endif /* __cplusplus */
  116. #endif /* __cplusplus */
  117. extern UINT32 OsSystemInit(VOID);
  118. extern VOID SystemInit(VOID);
  119. LITE_OS_SEC_TEXT_INIT VOID osRegister(VOID)
  120. {
  121. g_sysClock = OS_SYS_CLOCK;
  122. g_tickPerSecond = LOSCFG_BASE_CORE_TICK_PER_SECOND;
  123. return;
  124. }
  125. LITE_OS_SEC_TEXT_INIT VOID OsStart(VOID)
  126. {
  127. LosProcessCB *runProcess = NULL;
  128. LosTaskCB *taskCB = NULL;
  129. UINT32 cpuid = ArchCurrCpuid();
  130. OsTickStart();
  131. LOS_SpinLock(&g_taskSpin);
  132. taskCB = OsGetTopTask();
  133. runProcess = OS_PCB_FROM_PID(taskCB->processID);
  134. runProcess->processStatus |= OS_PROCESS_STATUS_RUNNING;
  135. #if (LOSCFG_KERNEL_SMP == YES)
  136. /*
  137. * attention: current cpu needs to be set, in case first task deletion
  138. * may fail because this flag mismatch with the real current cpu.
  139. */
  140. taskCB->currCpu = cpuid;
  141. runProcess->processStatus = OS_PROCESS_RUNTASK_COUNT_ADD(runProcess->processStatus);
  142. #endif
  143. OS_SCHEDULER_SET(cpuid);
  144. PRINTK("cpu %d entering scheduler\n", cpuid);
  145. OsStartToRun(taskCB);
  146. }
  147. LITE_OS_SEC_TEXT_INIT STATIC UINT32 OsIpcInit(VOID)
  148. {
  149. UINT32 ret;
  150. #if (LOSCFG_BASE_IPC_SEM == YES)
  151. ret = OsSemInit();
  152. if (ret != LOS_OK) {
  153. return ret;
  154. }
  155. #endif
  156. #if (LOSCFG_BASE_IPC_QUEUE == YES)
  157. ret = OsQueueInit();
  158. if (ret != LOS_OK) {
  159. return ret;
  160. }
  161. #endif
  162. return LOS_OK;
  163. }
  164. #ifdef LOSCFG_KERNEL_PIPE
  165. LITE_OS_SEC_TEXT_INIT STATIC VOID OsDriverPipeInit(VOID)
  166. {
  167. (VOID)pipe_init();
  168. }
  169. #endif
  170. #ifdef LOSCFG_DRIVERS_HIEVENT
  171. LITE_OS_SEC_TEXT_INIT STATIC VOID OsDriverHiEventInit(VOID)
  172. {
  173. (VOID)HieventInit();
  174. }
  175. #endif
  176. #ifdef LOSCFG_COMPAT_BSD
  177. extern void configure (void);
  178. LITE_OS_SEC_TEXT_INIT STATIC INT32 OsBsdInit(VOID)
  179. {
  180. configure();
  181. mi_startup(SI_SUB_ARCH_INIT);
  182. return LOS_OK;
  183. }
  184. #endif
  185. LITE_OS_SEC_TEXT_INIT INT32 OsMain(VOID)
  186. {
  187. UINT32 ret;
  188. osRegister();
  189. #ifdef LOSCFG_SHELL_DMESG
  190. ret = OsDmesgInit();
  191. if (ret != LOS_OK) {
  192. return ret;
  193. }
  194. #endif
  195. #ifdef LOSCFG_SHELL_LK
  196. OsLkLoggerInit(NULL);
  197. #endif
  198. #ifdef LOSCFG_EXC_INTERACTION
  199. #ifdef LOSCFG_ARCH_CORTEX_M7
  200. /* 4096: 4K space for Stack */
  201. ret = OsMemExcInteractionInit((UINT32)&__bss_end + 4096);
  202. #else
  203. ret = OsMemExcInteractionInit((UINTPTR)&__bss_end);
  204. #endif
  205. if (ret != LOS_OK) {
  206. return ret;
  207. }
  208. #endif
  209. #if (LOSCFG_PLATFORM_HWI == YES)
  210. OsHwiInit();
  211. #endif
  212. OsExcInit();
  213. ret = OsTickInit(g_sysClock, LOSCFG_BASE_CORE_TICK_PER_SECOND);
  214. if (ret != LOS_OK) {
  215. return ret;
  216. }
  217. #ifdef LOSCFG_PLATFORM_UART_WITHOUT_VFS
  218. #ifdef LOSCFG_DRIVERS
  219. extern void uart_init(void);
  220. uart_init();
  221. #endif
  222. #ifdef LOSCFG_SHELL
  223. #endif //LOSCFG_SHELL
  224. #endif //LOSCFG_PLATFORM_UART_WITHOUT_VFS
  225. ret = OsTaskInit();
  226. if (ret != LOS_OK) {
  227. PRINT_ERR("OsTaskInit error\n");
  228. return ret;
  229. }
  230. #if ((LOSCFG_BASE_IPC_QUEUE == YES) || (LOSCFG_BASE_IPC_MUX == YES) || (LOSCFG_BASE_IPC_SEM == YES))
  231. ret = OsIpcInit();
  232. if (ret != LOS_OK) {
  233. return ret;
  234. }
  235. #endif
  236. ret = OsSysMemInit();
  237. if (ret != LOS_OK) {
  238. PRINT_ERR("OsSysMemInit error\n");
  239. return ret;
  240. }
  241. SyscallHandleInit();
  242. /*
  243. * CPUP should be inited before first task creation which depends on the semaphore
  244. * when LOSCFG_KERNEL_SMP_TASK_SYNC is enabled. So don't change this init sequence
  245. * if not neccessary. The sequence should be like this:
  246. * 1. OsIpcInit
  247. * 2. OsCpupInit
  248. * 3. other inits have task creation
  249. */
  250. #ifdef LOSCFG_KERNEL_CPUP
  251. ret = OsCpupInit();
  252. if (ret != LOS_OK) {
  253. PRINT_ERR("OsCpupInit error\n");
  254. return ret;
  255. }
  256. #endif
  257. ret = OsKernelInitProcess();
  258. if (ret != LOS_OK) {
  259. return ret;
  260. }
  261. #if (LOSCFG_BASE_CORE_SWTMR == YES)
  262. ret = OsSwtmrInit();
  263. if (ret != LOS_OK) {
  264. return ret;
  265. }
  266. #endif
  267. #ifdef LOSCFG_KERNEL_CPUP
  268. OsCpupGuardCreator();
  269. #endif
  270. #if (LOSCFG_KERNEL_SMP == YES)
  271. (VOID)OsMpInit();
  272. #endif
  273. #if defined(LOSCFG_HW_RANDOM_ENABLE) || defined (LOSCFG_DRIVERS_RANDOM)
  274. random_alg_context.ra_init_alg(NULL);
  275. run_harvester_iterate(NULL);
  276. #endif
  277. #ifdef LOSCFG_COMPAT_BSD
  278. ret = OsBsdInit();
  279. if (ret != LOS_OK) {
  280. PRINT_ERR("init bsd failed!\n");
  281. return ret;
  282. }
  283. #endif
  284. #ifdef LOSCFG_KERNEL_PIPE
  285. OsDriverPipeInit();
  286. #endif
  287. ret = OsSystemInit();
  288. if (ret != LOS_OK) {
  289. return ret;
  290. }
  291. #if LOSCFG_DRIVERS_HIEVENT
  292. OsDriverHiEventInit();
  293. #endif
  294. #if (LOSCFG_KERNEL_TRACE == YES)
  295. LOS_TraceInit();
  296. #endif
  297. #if (LOSCFG_KERNEL_LITEIPC == YES)
  298. ret = LiteIpcInit();
  299. if (ret != LOS_OK) {
  300. return ret;
  301. }
  302. #endif
  303. #if (LOSCFG_BASE_CORE_HILOG == YES)
  304. ret = HiLogDriverInit();
  305. if (ret != LOS_OK) {
  306. return ret;
  307. }
  308. #endif
  309. #ifdef LOSCFG_KERNEL_VDSO
  310. ret = OsInitVdso();
  311. if (ret != LOS_OK) {
  312. return ret;
  313. }
  314. #endif
  315. ret = OsFutexInit();
  316. if (ret != LOS_OK) {
  317. PRINT_ERR("Create futex failed : %d!\n", ret);
  318. return ret;
  319. }
  320. ret = OomTaskInit();
  321. if (ret != LOS_OK) {
  322. return ret;
  323. }
  324. return LOS_OK;
  325. }
  326. STATIC UINT32 OsSystemInitTaskCreate(VOID)
  327. {
  328. UINT32 taskID;
  329. TSK_INIT_PARAM_S sysTask;
  330. (VOID)memset_s(&sysTask, sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
  331. sysTask.pfnTaskEntry = (TSK_ENTRY_FUNC)SystemInit;
  332. sysTask.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
  333. sysTask.pcName = "SystemInit";
  334. sysTask.usTaskPrio = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO;
  335. sysTask.uwResved = LOS_TASK_STATUS_DETACHED;
  336. #if (LOSCFG_KERNEL_SMP == YES)
  337. sysTask.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
  338. #endif
  339. return LOS_TaskCreate(&taskID, &sysTask);
  340. }
  341. #ifdef LOSCFG_MEM_RECORDINFO
  342. STATIC UINT32 OsMemShowTaskCreate(VOID)
  343. {
  344. UINT32 taskID;
  345. TSK_INIT_PARAM_S appTask;
  346. (VOID)memset_s(&appTask, sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
  347. appTask.pfnTaskEntry = (TSK_ENTRY_FUNC)OsMemRecordShowTask;
  348. appTask.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
  349. appTask.pcName = "memshow_Task";
  350. appTask.usTaskPrio = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO;
  351. appTask.uwResved = LOS_TASK_STATUS_DETACHED;
  352. return LOS_TaskCreate(&taskID, &appTask);
  353. }
  354. #endif
  355. UINT32 OsSystemInit(VOID)
  356. {
  357. UINT32 ret;
  358. #ifdef LOSCFG_FS_VFS
  359. los_vfs_init();
  360. #endif
  361. #ifdef LOSCFG_COMPAT_LINUXKPI
  362. g_pstSystemWq = create_workqueue("system_wq");
  363. #endif
  364. ret = OsSystemInitTaskCreate();
  365. if (ret != LOS_OK) {
  366. return ret;
  367. }
  368. #ifdef LOSCFG_MEM_RECORDINFO
  369. ret = OsMemShowTaskCreate();
  370. if (ret != LOS_OK) {
  371. PRINTK("create memshow_Task error %u\n", ret);
  372. return ret;
  373. }
  374. PRINTK("create memshow_Task ok\n");
  375. #endif
  376. #ifdef LOSCFG_KERNEL_TICKLESS
  377. LOS_TicklessEnable();
  378. #endif
  379. return 0;
  380. }
  381. #ifdef __cplusplus
  382. #if __cplusplus
  383. }
  384. #endif /* __cplusplus */
  385. #endif /* __cplusplus */

3.5 SystemInit函数分析

这个函数做的比较重要

他在平台的board文件里,因为这些也和板子相关

  1. #include "los_base.h"
  2. #include "los_config.h"
  3. #include "los_process_pri.h"
  4. #include "lwip/init.h"
  5. #include "lwip/tcpip.h"
  6. #include "sys/mount.h"
  7. #include "mtd_partition.h"
  8. #include "console.h"
  9. UINT32 OsRandomStackGuard(VOID)
  10. {
  11. return 0;
  12. }
  13. static void imx6ull_mount_rootfs()
  14. {
  15. #if 0
  16. #if 1
  17. dprintf("register parition ...\n");
  18. if (add_mtd_partition("spinor", 0, 0x4000000, 0))
  19. {
  20. PRINT_ERR("add_mtd_partition fail\n");
  21. }
  22. dprintf("mount /dev/spinorblk0 / ...\n");
  23. //if (mount("/dev/spinorblk0", "/", "jffs2", MS_RDONLY, NULL))
  24. if (mount("/dev/spinorblk0", "/", "jffs2", 0, NULL))
  25. {
  26. PRINT_ERR("mount failed\n");
  27. }
  28. #else
  29. dprintf("mount /dev/ramdisk / ...\n");
  30. //if (mount("/dev/spinorblk0", "/", "jffs2", MS_RDONLY, NULL))
  31. if (mount("/dev/ramdisk", "/", "vfat", 0, NULL))
  32. {
  33. PRINT_ERR("mount failed\n");
  34. }
  35. #endif
  36. #endif
  37. }
  38. static void imx6ull_driver_init()
  39. {
  40. #if 0
  41. extern int my_ramdisk_init(void);
  42. if (my_ramdisk_init())
  43. {
  44. PRINT_ERR("my_ramdisk_init failed\n");
  45. }
  46. #else
  47. extern int spinor_init(void);
  48. dprintf("spinor_init init ...\n");
  49. if (!spinor_init())
  50. {
  51. PRINT_ERR("spinor_init failed\n");
  52. }
  53. #endif
  54. #ifdef LOSCFG_DRIVERS_VIDEO
  55. dprintf("imx6ull_fb_init init ...\n");
  56. extern int imx6ull_fb_init(void);
  57. if (imx6ull_fb_init())
  58. {
  59. PRINT_ERR("imx6ull_fb_init failed\n");
  60. }
  61. #endif
  62. }
  63. void SystemInit()
  64. {
  65. #ifdef LOSCFG_FS_PROC
  66. dprintf("proc fs init ...\n");
  67. extern void ProcFsInit(void);
  68. ProcFsInit();
  69. #endif
  70. #ifdef LOSCFG_DRIVERS_MEM
  71. dprintf("mem dev init ...\n");
  72. extern int mem_dev_register(void);
  73. mem_dev_register();
  74. #endif
  75. imx6ull_driver_init();
  76. imx6ull_mount_rootfs();
  77. #ifdef LOSCFG_DRIVERS_HDF
  78. extern int DeviceManagerStart(void);
  79. PRINT_RELEASE("DeviceManagerStart start ...\n");
  80. if (DeviceManagerStart()) {
  81. PRINT_ERR("No drivers need load by hdf manager!");
  82. }
  83. dprintf("DeviceManagerStart end ...\n");
  84. #endif
  85. extern int uart_dev_init(void);
  86. uart_dev_init();
  87. if (virtual_serial_init("/dev/uartdev-0") != 0)
  88. {
  89. PRINT_ERR("virtual_serial_init failed");
  90. }
  91. if (system_console_init(SERIAL) != 0)
  92. {
  93. PRINT_ERR("system_console_init failed\n");
  94. }
  95. if (OsUserInitProcess())
  96. {
  97. PRINT_ERR("Create user init process faialed!\n");
  98. }
  99. }

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号