ARM VERSION 1.2 Guide de l'utilisateur Page 85

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 133
  • Table des matières
  • DEPANNAGE
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 84
END
The code in Example 6-4 performs ROM/RAM remapping (if required), initializes stack pointers and interrupts for
each mode, and finally branches to __main in the C library (__main eventually calls main()). On reset, the ARM
core starts up in Supervisor (SVC) mode, in ARM state, with IRQ and FIQ disabled.
Example 6-4 init.s
AREA Init, CODE, READONLY
; - Set up if ROM/RAM remapping required
; GBLL ROM_RAM_REMAP
;ROM_RAM_REMAP SETL {TRUE} ; change to {FALSE} if remapping not required
; - ensure no functions that use semihosting SWIs are linked from the C library
IMPORT __use_no_semihosting_swi
; - Standard definitions of mode bits and interrupt (I & F) flags in PSRs
Mode_USR EQU 0x10
Mode_FIQ EQU 0x11
Mode_IRQ EQU 0x12
Mode_SVC EQU 0x13
Mode_ABT EQU 0x17
Mode_UNDEF EQU 0x1B
Mode_SYS EQU 0x1F ; available on ARM Arch v4 and later
I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled
F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled
; --- System memory locations
CM_ctl_reg EQU 0x1000000C ; Address of Core Module Control Register
Remap_bit EQU 0x04 ; Bit 2 is remap bit of CM_ctl
; --- Amount of memory (in bytes) allocated for stacks
Len_FIQ_Stack EQU 0
Len_IRQ_Stack EQU 256
Len_ABT_Stack EQU 0
Len_UND_Stack EQU 0
Len_SVC_Stack EQU 1024
; Len_USR_Stack EQU 1024
; Add lengths >0 for FIQ_Stack, ABT_Stack, UNDEF_Stack if you need them
; offsets will be loaded as immediate values
; Offsets must be 8 byte aligned
Offset_FIQ_Stack EQU 0
Offset_IRQ_Stack EQU Offset_FIQ_Stack + Len_FIQ_Stack
Offset_ABT_Stack EQU Offset_IRQ_Stack + Len_IRQ_Stack
Offset_UND_Stack EQU Offset_ABT_Stack + Len_ABT_Stack
Offset_SVC_Stack EQU Offset_UND_Stack + Len_UND_Stack
; Offset_USR_Stack EQU Offset_SVC_Stack + Len_SVC_Stack
ENTRY
; --- Perform ROM/RAM remapping, if required
IF :DEF: ROM_RAM_REMAP
; On reset, an aliased copy of ROM is at 0x0.
; Continue execution from 'real' ROM rather than aliased copy
LDR pc, =Instruct_2
Instruct_2
; Remap by setting Remap bit of the CM_ctl register
LDR r1, =CM_ctl_reg
LDR r0, [r1]
ORR r0, r0, #Remap_bit
STR r0, [r1]
; RAM is now at 0x0.
; The exception vectors (in vectors.s) must be copied from ROM to the RAM
; The copying is done later by the C library code inside __main
ENDIF
Writing Code for ROM
Copyright ?1999 2001 ARM Limited 6-10
Vue de la page 84
1 2 ... 80 81 82 83 84 85 86 87 88 89 90 ... 132 133

Commentaires sur ces manuels

Pas de commentaire