zoukankan      html  css  js  c++  java
  • PowerPC-MPC56xx Flash模式代码启动过程

     
    参考第5章
     
    In order for the e200z4d core to be able to access memory, a valid MMU TLB entry has to be created. The
    SSCM does this automatically by reading the reset vector and modifying TLB entry 0 to create a 4 KB
    page containing the reset vector address. The MMU VLE bit is set depending on the status of the VLE bit
    within the RCHW. The 4 KB MMU page must be 4 KB aligned. This means that the most efficient place
    to put the application code is immediately after the boot sector. The 4 KB block provides sufficient space
    to:
    • Add MMU entries for SRAM and peripherals
    • Perform standard system initialisation tasks (initialise the SRAM, setup stack, copy constant data)
    • Transfer execution to RAM, re-define the flash memory MMU entry and transfer execution back to flash memory.
    Finally, the SSCM sets the e200z4d core instruction pointer to the reset vector address and starts the core
    running.
     
    SSCM从boot vector读取到reset vector address之后,即跳转到该位置开始执行代码。
     
    一. 一般情况下启动代码的任务
    1. 从语言上看,最开始执行汇编代码,之后执行C语言代码;C语言执行函数调用需要栈,所以需要配置栈指针寄存器;堆只需要一个malloc引用起始位置即可,无需特别配置;
    1. 需要将带初值的数据从flash拷贝到内存中,将BSS区清0;
     
    二. PowerPC MPC56xx的情况
    这段代码要做的初始化动作依次如下:
    1. 为内存、Flash还有其他地址区间,添加MMU entry。防止引用到的地址无法访问。
    1. 根据ABI配置栈指针寄存器SP,指向SDA区的寄存器,指向SDA2区的寄存器;
    1. 初始化RAM内容,全部置零;
    1. 拷贝.data区,.bss区清0;
    然后就可以调到main函数执行了。
     
    三. 配置Flash控制寄存器
     
    如果需要配置Flash控制寄存器,则需要特别操作。因为最开始执行的代码地址reset vector address指向flash,也就是说CPU从Flash中开始执行代码,CPU的PC指向flash。如果此时直接配置Flash控制寄存器,则会导致无法访问Flash中的代码。
    变通的方法是把配置Flash控制器的代码,先拷贝到RAM中,然后跳转到RAM,即CPU的PC指向RAM中的Flash配置代码。配置完毕之后,再跳转回之前Flash中的代码,继续执行。
    当然,如果有两块Flash,并且他们的控制器是分开的,也可以分别交替配置。

     

  • 相关阅读:
    TCP/IP资料整理
    对谷歌自带闹钟应用中材料设计的吹毛求疵
    如何给非AppCompatActivity添加Toolbar?--关于5.0新特性兼容5.0以下设备的探索
    Android 5.0自定义动画
    Android开发Tips-1
    Android控件RecyclerView与ListView的异同
    有关Android存储的相关概念辨析
    关于RecyclerView中Viewholder和View的缓存机制的探究
    Android Wear和二维码
    构建具有深度和灵活性的安卓Wear应用
  • 原文地址:https://www.cnblogs.com/wjcdx/p/9245780.html
Copyright © 2011-2022 走看看