参考第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之后,即跳转到该位置开始执行代码。
一. 一般情况下启动代码的任务
二. PowerPC MPC56xx的情况
这段代码要做的初始化动作依次如下:
然后就可以调到main函数执行了。
三. 配置Flash控制寄存器
如果需要配置Flash控制寄存器,则需要特别操作。因为最开始执行的代码地址reset vector address指向flash,也就是说CPU从Flash中开始执行代码,CPU的PC指向flash。如果此时直接配置Flash控制寄存器,则会导致无法访问Flash中的代码。
变通的方法是把配置Flash控制器的代码,先拷贝到RAM中,然后跳转到RAM,即CPU的PC指向RAM中的Flash配置代码。配置完毕之后,再跳转回之前Flash中的代码,继续执行。
当然,如果有两块Flash,并且他们的控制器是分开的,也可以分别交替配置。