This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Undefined symbol __SWI_0

I am new on ARM and I am using Keil micro vision v3 . I had build an example for RTX kernel on NXP LPC2368. I flowed step by step the description (Getting started for arm ) but

While I compiled this build I get this Error

RTX_Test.axf: Error: L6218E: Undefined symbol __SWI_0 (referred from swi_table.o).

Can anyone help me to solve this error.

Parents
  • you are trying to use a software interrupt. you should have a jump table, like this (SWI.s):

    T_Bit           EQU     0x20
    
                    PRESERVE8                      ; 8-Byte aligned Stack
                    AREA    SWI_Area, CODE, READONLY
                    ARM
    
                    EXPORT  SWI_Handler
    SWI_Handler
    
                    STMFD   SP!, {R12, LR}         ; Store R12, LR
                    MRS     R12, SPSR              ; Get SPSR
                    STMFD   SP!, {R8, R12}         ; Store R8, SPSR
                    TST     R12, #T_Bit            ; Check Thumb Bit
                    LDRNEH  R12, [LR,#-2]          ; Thumb: Load Halfword
                    BICNE   R12, R12, #0xFF00      ;        Extract SWI Number
                    LDREQ   R12, [LR,#-4]          ; ARM:   Load Word
                    BICEQ   R12, R12, #0xFF000000  ;        Extract SWI Number
    
                    LDR     R8, SWI_Count
                    CMP     R12, R8
                    BHS     SWI_Dead               ; Overflow
                    ADR     R8, SWI_Table
                    LDR     R12, [R8,R12,LSL #2]   ; Load SWI Function Address
                    MOV     LR, PC                 ; Return Address
                    BX      R12                    ; Call SWI Function
    
                    LDMFD   SP!, {R8, R12}         ; Load R8, SPSR
                    MSR     SPSR_cxsf, R12         ; Set SPSR
                    LDMFD   SP!, {R12, PC}^        ; Restore R12 and Return
    
    SWI_Dead        B       SWI_Dead               ; None Existing SWI
    
    SWI_Cnt         EQU    (SWI_End-SWI_Table)/4
    SWI_Count       DCD     SWI_Cnt
    
                    IMPORT  __SWI_0
                    IMPORT  __SWI_1
                    IMPORT  __SWI_2
                    IMPORT  __SWI_3
    SWI_Table
                    DCD     __SWI_0                ; SWI 0 Function Entry
                    DCD     __SWI_1                ; SWI 1 Function Entry
                    DCD     __SWI_2                ; SWI 2 Function Entry
                    DCD     __SWI_3                ; SWI 3 Function Entry
    ;               ...
    SWI_End
    
    
                    END
    

    insert this file into your project, and make sure your startup file does handler software interrupts (SWI_Hanlder and alike...).
    in your application you can now invoke 4 software interrupts.
    definition:

    int __swi(0) disable_fiq(void) ;
    int __SWI_0 ()
    {
       return __disable_fiq() ;
    }
    

    now you can call 'disable_fiq' from you application.

    Greetings,

    Tamir

Reply
  • you are trying to use a software interrupt. you should have a jump table, like this (SWI.s):

    T_Bit           EQU     0x20
    
                    PRESERVE8                      ; 8-Byte aligned Stack
                    AREA    SWI_Area, CODE, READONLY
                    ARM
    
                    EXPORT  SWI_Handler
    SWI_Handler
    
                    STMFD   SP!, {R12, LR}         ; Store R12, LR
                    MRS     R12, SPSR              ; Get SPSR
                    STMFD   SP!, {R8, R12}         ; Store R8, SPSR
                    TST     R12, #T_Bit            ; Check Thumb Bit
                    LDRNEH  R12, [LR,#-2]          ; Thumb: Load Halfword
                    BICNE   R12, R12, #0xFF00      ;        Extract SWI Number
                    LDREQ   R12, [LR,#-4]          ; ARM:   Load Word
                    BICEQ   R12, R12, #0xFF000000  ;        Extract SWI Number
    
                    LDR     R8, SWI_Count
                    CMP     R12, R8
                    BHS     SWI_Dead               ; Overflow
                    ADR     R8, SWI_Table
                    LDR     R12, [R8,R12,LSL #2]   ; Load SWI Function Address
                    MOV     LR, PC                 ; Return Address
                    BX      R12                    ; Call SWI Function
    
                    LDMFD   SP!, {R8, R12}         ; Load R8, SPSR
                    MSR     SPSR_cxsf, R12         ; Set SPSR
                    LDMFD   SP!, {R12, PC}^        ; Restore R12 and Return
    
    SWI_Dead        B       SWI_Dead               ; None Existing SWI
    
    SWI_Cnt         EQU    (SWI_End-SWI_Table)/4
    SWI_Count       DCD     SWI_Cnt
    
                    IMPORT  __SWI_0
                    IMPORT  __SWI_1
                    IMPORT  __SWI_2
                    IMPORT  __SWI_3
    SWI_Table
                    DCD     __SWI_0                ; SWI 0 Function Entry
                    DCD     __SWI_1                ; SWI 1 Function Entry
                    DCD     __SWI_2                ; SWI 2 Function Entry
                    DCD     __SWI_3                ; SWI 3 Function Entry
    ;               ...
    SWI_End
    
    
                    END
    

    insert this file into your project, and make sure your startup file does handler software interrupts (SWI_Hanlder and alike...).
    in your application you can now invoke 4 software interrupts.
    definition:

    int __swi(0) disable_fiq(void) ;
    int __SWI_0 ()
    {
       return __disable_fiq() ;
    }
    

    now you can call 'disable_fiq' from you application.

    Greetings,

    Tamir

Children