Note
本节内容不适用于 ARMv6-M 和 ARMv7-M 架构。
您必须考虑在地址 0x0
(执行第一条指令的地址)处的系统内存是什么类型。
本节假设 ARM 处理器在 0x0
处开始取指令。 这是基于 ARM 处理器的系统的标准。但是,某些 ARM 处理器可配置为从 0xFFFF0000
处开始取指令。
启动时,0x0
处必须有一条有效指令,因此在复位时,0x0
处必须是非易失性的存储器。一种实现方法是使 0x0
在 ROM 中。 但是,这样配置有几个缺点。
Example 3.5演示另一种在复位时实现 ROM/RAM 重映射的方法。 此示例中所示的常量是特定于 Versatile 板的,但该方法适用于通过类似方法实现重映射的任何平台。分散加载描述文件必须描述重映射后的内存映射。
Example 3.5. ROM/RAM 重映射
; --- System memory locationsVersatile_ctl_reg EQU 0x101E0000 ; Address of control registerDEVCHIP_Remap_bit EQU 0x100 ; Bit 8 is remap bit of control register ENTRY; Code execution starts here on reset; On reset, an alias of ROM is at 0x0, so jump to 'real' ROM. LDR pc, =Instruct_2Instruct_2 ; Remap by setting remap bit of the control register; Clear the DEVCHIP_Remap_bit by writing 1 to bit 8 of the control register LDR R1, =Versatile_ctl_reg LDR R0, [R1] ORR R0, R0, #DEVCHIP_Remap_bit STR R0, [R1]; RAM is now at 0x0.; The exception vectors must be copied from ROM to RAM; The copying is done later by the C library code inside __main; Reset_Handler follows on from here