ARM VERSION 1.2 Guide de l'utilisateur Page 65

  • 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 64
; PC base address points to this
; instruction + 8
NOP ; pad so the PC indexes this table.
; Table of handler start addresses
DCD Priority0Handler
DCD Priority1Handler
DCD Priority2Handler
; ...
Priority0Handler
STMFD sp!, {r0 - r11} ; Save other working registers.
; Insert handler code here.
; ...
LDMFD sp!, {r0 - r11} ; Restore working registers (not r12).
; Now read-modify-write the CPSR to disable interrupts.
MRS r12, CPSR ; Read the status register.
ORR r12, r12, #0x80 ; Set the I bit
; (use 0x40 for the F bit).
MSR CPSR_c, r12 ; Write it back to disable interrupts.
; Now that interrupt disabled, can safely restore SPSR then return.
LDMFD sp!, {r12, r14} ; Restore r12 and get SPSR.
MSR SPSR_csxf, r14 ; Restore status register from r14.
LDMFD sp!, {pc}^ ; Return from handler.
Priority1Handler
; ...
Context switch
Example 5-18 performs a context switch on the User mode process. The code is based around a list of pointers to
Process Control Blocks (PCBs) of processes that are ready to run.
Figure 5-3 shows the layout of the PCBs that the example expects.
Figure 5-3 PCB layout
The pointer to the PCB of the next process to run is pointed to by r12, and the end of the list has a zero pointer.
Register r13 is a pointer to the PCB, and is preserved between time slices, so that on entry it points to the PCB of the
currently running process.
Example 5-18
STMIA r13, {r0 - r14}^ ; Dump user registers above r13.
MRS r0, SPSR ; Pick up the user status
STMDB r13, {r0, lr} ; and dump with return address below.
LDR r13, [r12], #4 ; Load next process info pointer.
CMP r13, #0 ; If it is zero, it is invalid
LDMNEDB r13, {r0, lr} ; Pick up status and return address.
Handling Processor Exceptions
Copyright ?1999 2001 ARM Limited 5-18
Vue de la page 64
1 2 ... 60 61 62 63 64 65 66 67 68 69 70 ... 132 133

Commentaires sur ces manuels

Pas de commentaire