This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Cannot enter system mode on L138 experimenter

Hi,
The code for entering “system mode, PSR [4:0] = 11111” works fine on my own board, but crashes on LogicPD L138 experimenter.
I put the following line of code at the beginning line of main() to enter system mode on my own board:
_call_swi(458752);
and the definition for SWI handler is in exceptionhandler.asm which is part of the Starterware:
;******************************************************************************
;*                  Function Definition of SWI Handler
;******************************************************************************   
;
; The SWI Handler switches to system mode if the SWI number is 458752. If the
; SWI number is different, no mode switching will be done. No other SWI are
; handled here
;
 
SWIHandler:
        STMFD    r13!, {r0-r1, r14}       ; Save context in SVC stack
        LDR      r0, [r14, #-4]           ; R0 points to SWI instruction
        BIC      r0, r0, #MASK_SWI_NUM    ; Get the SWI number
        CMP      r0, #458752
        MRSEQ    r1, spsr                 ; Copy SPSR 
        ORREQ    r1, r1, #0x1F            ; Change the mode to System
        MSREQ    spsr_cf, r1              ; Restore SPSR
        LDMFD    r13!, {r0-r1, pc}^       ; Restore registers from IRQ stack
On my customized board this (_call_swi(458752)) successfully changed PSR [4:0]  to 11111, however on LogicPD experimenter it caused PC to jump to an undefined location (like 0x0155b310 which according is not defined in the memory mapping, see “2.5 Memory Map Summary” of SPRS586C). In addition, it changes PSR [4:0] to 11011 : “Undefined mode”.
Could someone give this a test on the experimenter and give some help?
 
Paul
  • Paul,

    According to the description of SWI given in ARM ARM document given below, it should enter supervisor mode instead of system mode. 

    if ConditionPassed(cond) then
    R14_svc = address of next instruction after the SWI instruction
    SPSR_svc = CPSR
    CPSR[4:0] = 0b10011 /* Enter Supervisor mode */
    CPSR[5] = 0 /* Execute in ARM state */
    /* CPSR[6] is unchanged */
    CPSR[7] = 1 /* Disable normal interrupts */

    Also which is the current mode before executing SWI?