//////////////////////////////////////////////////////////////////////////////
//                                                                           /
// IAR ARM ANSI C/C++ Compiler V4.11A/W32              20/Jul/2004  18:58:50 /
// Copyright 1999-2004 IAR Systems. All rights reserved.                     /
//                                                                           /
//    Cpu mode        =  arm                                                 /
//    Endian          =  little                                              /
//    Stack alignment =  4                                                   /
//    Source file     =  C:\medusa\zl_event.c                                /
//    Command line    =  -I "C:\Program Files\IAR Systems\Embedded           /
//                       Workbench 4.0\ARM\INC\" -lc C:\medusa\Debug\List\   /
//                       -la C:\medusa\Debug\List\ -o C:\medusa\Debug\Obj\   /
//                       -s2 --no_cse --no_unroll --no_inline                /
//                       --no_code_motion --no_tbaa --no_clustering          /
//                       --no_scheduling --debug --cpu_mode arm --endian     /
//                       little --cpu ARM7TDMI-S --stack_align 4 -e --fpu    /
//                       None "-D_DLIB_CONFIG_FILE=C:\Program Files\IAR      /
//                       Systems\Embedded Workbench                          /
//                       4.0\ARM\LIB\dl4tpannl8n.h" C:\medusa\zl_event.c     /
//    List file       =  C:\medusa\Debug\List\zl_event.s79                   /
//                                                                           /
//                                                                           /
//////////////////////////////////////////////////////////////////////////////

        NAME zl_event

        RTMODEL "ARMv4M", "USED"
        RTMODEL "StackAlign4", "USED"
        RTMODEL "__cpu_mode", "__pcs__arm"
        RTMODEL "__data_model", "absolute"
        RTMODEL "__dlib_file_descriptor", "0"
        RTMODEL "__endian", "little"
        RTMODEL "__rt_version", "6"

        RSEG CSTACK:DATA:NOROOT(2)
        RSEG IRQSTACK:DATA:NOROOT(2)

??DataTable0 EQU 0
??DataTable1 EQU 0
??DataTable2 EQU 0
??DataTable3 EQU 0
        PUBWEAK ?init?tab?DATA_Z
        MULTWEAK armvicIntConnect??rA
        MULTWEAK armvicIntEnable??rA
        MULTWEAK cliRegisterCommand??rA
        MULTWEAK clicharGetOutputBuffer??rA
        MULTWEAK clicharSendOutputBuffer??rA
        FUNCTION eventCmdHandler,0603H
        LOCFRAME CSTACK, 24, STACK
        MULTWEAK eventqPut??rA
        MULTWEAK eventqRegisterHandler??rA
        FUNCTION handleFrameRxEvent,0603H
        LOCFRAME CSTACK, 12, STACK
        MULTWEAK sprintf??rA
        PUBLIC zarlinkEventInit
        FUNCTION zarlinkEventInit,0203H
        LOCFRAME CSTACK, 16, STACK
        MULTWEAK zarlinkIndexedWrite??rA
        MULTWEAK zarlinkInterruptRead??rA
        MULTWEAK zarlinkInterruptWrite??rA
        FUNCTION zarlinkIsr,0603H
        LOCFRAME CSTACK, 20, STACK
        
        CFI Names cfiNames0
        CFI StackFrame CFA R13 HUGEDATA
        CFI Resource R0:32, R1:32, R2:32, R3:32, R4:32, R5:32, R6:32, R7:32
        CFI Resource R8:32, R9:32, R10:32, R11:32, R12:32, CPSR:32, R13:32
        CFI Resource R14:32, SPSR:32
        CFI VirtualResource ?RET:32
        CFI EndNames cfiNames0
        
        CFI Common cfiCommon0 Using cfiNames0
        CFI CodeAlign 4
        CFI DataAlign 4
        CFI ReturnAddress ?RET CODE
        CFI CFA R13+0
        CFI R0 Undefined
        CFI R1 Undefined
        CFI R2 Undefined
        CFI R3 Undefined
        CFI R4 SameValue
        CFI R5 SameValue
        CFI R6 SameValue
        CFI R7 SameValue
        CFI R8 SameValue
        CFI R9 SameValue
        CFI R10 SameValue
        CFI R11 SameValue
        CFI R12 Undefined
        CFI CPSR SameValue
        CFI R14 Undefined
        CFI SPSR SameValue
        CFI ?RET R14
        CFI EndCommon cfiCommon0
        
        
        CFI Names cfiNames1
        CFI StackFrame CFA_R13_usr R13_usr HUGEDATA
        CFI StackFrame CFA_R13_irq R13_irq HUGEDATA
        CFI Resource R0:32, R1:32, R2:32, R3:32, R4:32, R5:32, R6:32, R7:32
        CFI Resource R8:32, R9:32, R10:32, R11:32, R12:32, CPSR:32, R13_usr:32
        CFI Resource R14_usr:32, R13_irq:32, R14_irq:32, SPSR_irq:32
        CFI VirtualResource ?RET:32
        CFI EndNames cfiNames1
        
        CFI Common cfiCommon1 Using cfiNames1
        CFI CodeAlign 4
        CFI DataAlign 4
        CFI ReturnAddress ?RET CODE
        CFI CFA_R13_usr R13_usr+0
        CFI CFA_R13_irq R13_irq+0
        CFI R0 SameValue
        CFI R1 SameValue
        CFI R2 SameValue
        CFI R3 SameValue
        CFI R4 SameValue
        CFI R5 SameValue
        CFI R6 SameValue
        CFI R7 SameValue
        CFI R8 SameValue
        CFI R9 SameValue
        CFI R10 SameValue
        CFI R11 SameValue
        CFI R12 SameValue
        CFI CPSR SPSR_irq
        CFI R14_usr SameValue
        CFI R14_irq Undefined
        CFI SPSR_irq Undefined
        CFI ?RET add(R14_irq, literal(-4))
        CFI EndCommon cfiCommon1
        
armvicIntConnect    SYMBOL "armvicIntConnect"
armvicIntEnable     SYMBOL "armvicIntEnable"
cliRegisterCommand  SYMBOL "cliRegisterCommand"
clicharGetOutputBuffer SYMBOL "clicharGetOutputBuffer"
clicharSendOutputBuffer SYMBOL "clicharSendOutputBuffer"
eventqPut           SYMBOL "eventqPut"
eventqRegisterHandler SYMBOL "eventqRegisterHandler"
sprintf             SYMBOL "sprintf"
zarlinkIndexedWrite SYMBOL "zarlinkIndexedWrite"
zarlinkInterruptRead SYMBOL "zarlinkInterruptRead"
zarlinkInterruptWrite SYMBOL "zarlinkInterruptWrite"
armvicIntConnect??rA SYMBOL "??rA", armvicIntConnect
armvicIntEnable??rA SYMBOL "??rA", armvicIntEnable
cliRegisterCommand??rA SYMBOL "??rA", cliRegisterCommand
clicharGetOutputBuffer??rA SYMBOL "??rA", clicharGetOutputBuffer
clicharSendOutputBuffer??rA SYMBOL "??rA", clicharSendOutputBuffer
eventqPut??rA       SYMBOL "??rA", eventqPut
eventqRegisterHandler??rA SYMBOL "??rA", eventqRegisterHandler
sprintf??rA         SYMBOL "??rA", sprintf
zarlinkIndexedWrite??rA SYMBOL "??rA", zarlinkIndexedWrite
zarlinkInterruptRead??rA SYMBOL "??rA", zarlinkInterruptRead
zarlinkInterruptWrite??rA SYMBOL "??rA", zarlinkInterruptWrite

        EXTERN armvicIntConnect
        FUNCTION armvicIntConnect,0202H
        EXTERN armvicIntEnable
        FUNCTION armvicIntEnable,0202H
        EXTERN cliRegisterCommand
        FUNCTION cliRegisterCommand,0202H
        EXTERN clicharGetOutputBuffer
        FUNCTION clicharGetOutputBuffer,0202H
        EXTERN clicharSendOutputBuffer
        FUNCTION clicharSendOutputBuffer,0202H
        EXTERN eventqPut
        FUNCTION eventqPut,0202H
        EXTERN eventqRegisterHandler
        FUNCTION eventqRegisterHandler,0202H
        EXTERN sprintf
        FUNCTION sprintf,010202H
        EXTERN zarlinkIndexedWrite
        FUNCTION zarlinkIndexedWrite,0202H
        EXTERN zarlinkInterruptRead
        FUNCTION zarlinkInterruptRead,0202H
        EXTERN zarlinkInterruptWrite
        FUNCTION zarlinkInterruptWrite,0202H


        RSEG DATA_Z:DATA:SORT:NOROOT(2)
eventCount:
        DS8 4

        RSEG DATA_Z:DATA:SORT:NOROOT(2)
frameRxEventCount:
        DS8 4

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock0 Using cfiCommon0
        CFI Function zarlinkEventInit
   CODE32      
zarlinkEventInit:
   STMDB       SP!,{R4,R5,LR}     ;; Push
        CFI ?RET Frame(CFA, -4)
        CFI R5 Frame(CFA, -8)
        CFI R4 Frame(CFA, -12)
        CFI CFA R13+12
   SUB         SP,SP,#+0x4
        CFI CFA R13+16
   MVN         R0,#+0x0
   MOV         R5,R0
   LDR         R1,??zarlinkEventInit_0  ;; handleFrameRxEvent
   MOV         R0,#+0xC
   _BLF        eventqRegisterHandler,eventqRegisterHandler??rA
   MOV         R1,#+0x0
   MOV         R0,#+0xA
   ORR         R0,R0,#+0x600
   _BLF        zarlinkIndexedWrite,zarlinkIndexedWrite??rA
   MOV         R0,#+0x1
   _BLF        zarlinkInterruptWrite,zarlinkInterruptWrite??rA
   MOV         R1,#+0x0
   MOV         R4,R1
??zarlinkEventInit_1:
   CMP         R4,#+0xA
   BGE         ??zarlinkEventInit_2
   LDR         R3,??zarlinkEventInit_0+4  ;; 0xe01fc144
   LDR         R12,[R3, #+0]
   STR         R12,[SP, #+0]
   ADDS        R4,R4,#+0x1
   B           ??zarlinkEventInit_1
??zarlinkEventInit_2:
   LDR         LR,??DataTable4    ;; 0xe01fc140
   MOV         R0,#+0x4
   STR         R0,[LR, #+0]
   LDR         R1,??zarlinkEventInit_0+4  ;; 0xe01fc144
   MOV         R2,#+0x4
   STR         R2,[R1, #+0]
   LDR         R1,??zarlinkEventInit_0+8  ;; zarlinkIsr
   MOV         R0,#+0x10
   _BLF        armvicIntConnect,armvicIntConnect??rA
   MOV         R5,R0
   CMP         R0,#+0x0
   BEQ         ??zarlinkEventInit_3
   MOV         R0,R5
   B           ??zarlinkEventInit_4
??zarlinkEventInit_3:
   MOV         R0,#+0x10
   _BLF        armvicIntEnable,armvicIntEnable??rA
   MOV         R5,R0
   CMP         R0,#+0x0
   BEQ         ??zarlinkEventInit_5
   MOV         R0,R5
   B           ??zarlinkEventInit_4
??zarlinkEventInit_5:
   LDR         R2,??zarlinkEventInit_0+12  ;; `?<Constant "event - show info on ...">`
   LDR         R1,??zarlinkEventInit_0+16  ;; eventCmdHandler
   LDR         R0,??zarlinkEventInit_0+20  ;; `?<Constant "event">`
   _BLF        cliRegisterCommand,cliRegisterCommand??rA
   MOV         R0,#+0x0
??zarlinkEventInit_4:
   ADD         SP,SP,#+0x4        ;; stack cleaning
        CFI CFA R13+12
   LDMIA       SP!,{R4,R5,PC}     ;; return
   DATA        
??zarlinkEventInit_0:
   DC32        handleFrameRxEvent
   DC32        0xe01fc144
   DC32        zarlinkIsr
   DC32        `?<Constant "event - show info on ...">`
   DC32        eventCmdHandler
   DC32        `?<Constant "event">`
        CFI EndBlock cfiBlock0

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock1 Using cfiCommon0
        CFI Function handleFrameRxEvent
   CODE32      
handleFrameRxEvent:
   STMDB       SP!,{R4,LR}        ;; Push
        CFI ?RET Frame(CFA, -4)
        CFI R4 Frame(CFA, -8)
        CFI CFA R13+8
   SUB         SP,SP,#+0x4
        CFI CFA R13+12
   LDR         R0,??DataTable5    ;; frameRxEventCount
   LDR         R1,??DataTable5    ;; frameRxEventCount
   LDR         R2,[R1, #+0]
   ADDS        R3,R2,#+0x1
   STR         R3,[R0, #+0]
   MOV         R0,SP
   _BLF        clicharGetOutputBuffer,clicharGetOutputBuffer??rA
   MOV         R4,R0
   LDR         R12,??DataTable5   ;; frameRxEventCount
   LDR         R2,[R12, #+0]
   LDR         R1,??handleFrameRxEvent_0  ;; `?<Constant "*** frame received [%...">`
   MOV         R0,R4
   _BLF        sprintf,sprintf??rA
   LDR         R1,[SP, #+0]
   MOV         R0,R4
   _BLF        clicharSendOutputBuffer,clicharSendOutputBuffer??rA
   ADD         SP,SP,#+0x4        ;; stack cleaning
        CFI CFA R13+8
   LDMIA       SP!,{R4,PC}        ;; return
   DATA        
??handleFrameRxEvent_0:
   DC32        `?<Constant "*** frame received [%...">`
        CFI EndBlock cfiBlock1

        RSEG DATA_Z:DATA:SORT:NOROOT(0)
irqReg:
        DS8 1

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock2 Using cfiCommon1
        CFI Function zarlinkIsr
   CODE32      
zarlinkIsr:
   SUB         LR,LR,#+0x4
        CFI ?RET R14_irq
   STMDB       SP!,{LR}
        CFI ?RET Frame(CFA_R13_irq, -4)
        CFI CFA_R13_irq R13_irq+4
   MRS         LR,SPSR
        CFI SPSR_irq R14_irq
   STMDB       SP!,{R12,LR}
        CFI R14_irq Frame(CFA_R13_irq, -8)
        CFI R12 Frame(CFA_R13_irq, -12)
        CFI CFA_R13_irq R13_irq+12
   MRS         LR,CPSR
   ORR         LR,LR,#+0x1F
   MSR         CPSR,LR
   STMDB       SP!,{R0-R3,LR}     ;; Push
        CFI R14_usr Frame(CFA_R13_usr, -4)
        CFI R3 Frame(CFA_R13_usr, -8)
        CFI R2 Frame(CFA_R13_usr, -12)
        CFI R1 Frame(CFA_R13_usr, -16)
        CFI R0 Frame(CFA_R13_usr, -20)
        CFI CFA_R13_usr R13_usr+20
   LDR         R0,??zarlinkIsr_0  ;; eventCount
   LDR         R1,??zarlinkIsr_0  ;; eventCount
   LDR         R1,[R1, #+0]
   ADDS        R1,R1,#+0x1
   STR         R1,[R0, #+0]
   _BLF        zarlinkInterruptRead,zarlinkInterruptRead??rA
   LDR         R1,??zarlinkIsr_0+4  ;; irqReg
   STRB        R0,[R1, #+0]
   LDR         R0,??zarlinkIsr_0+4  ;; irqReg
   LDRB        R2,[R0, #+0]
   ANDS        R2,R2,#+0xFF       ;; Zero extend
   TST         R2,#+0x1
   BEQ         ??zarlinkIsr_1
   MOV         R0,#+0xC
   _BLF        eventqPut,eventqPut??rA
   MOV         R0,#+0x1
   _BLF        zarlinkInterruptWrite,zarlinkInterruptWrite??rA
??zarlinkIsr_1:
   LDR         R3,??DataTable4    ;; 0xe01fc140
   MOV         R12,#+0x4
   STR         R12,[R3, #+0]
   MVN         LR,#+0xCF
   BIC         LR,LR,#+0xF00
   MOV         R1,#+0x0
   STR         R1,[LR, #+0]
   LDMIA       SP!,{R0-R3,LR}     ;; Pop
        CFI R0 SameValue
        CFI R1 SameValue
        CFI R2 SameValue
        CFI R3 SameValue
        CFI R14_usr SameValue
        CFI CFA_R13_usr R13_usr+0
   MRS         R12,CPSR
   ORR         R12,R12,#+0x92
   BIC         R12,R12,#+0xD
   MSR         CPSR,R12
   LDMIA       SP!,{R12,LR}
        CFI R12 SameValue
        CFI CFA_R13_irq R13_irq+4
   MSR         SPSR,LR
        CFI R14_irq SPSR_irq
   LDMIA       SP!,{PC}^          ;; return
   DATA        
??zarlinkIsr_0:
   DC32        eventCount
   DC32        irqReg
        CFI EndBlock cfiBlock2

        RSEG CODE:CODE:NOROOT(2)
   DATA        
??DataTable4:
   DC32        0xe01fc140

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock3 Using cfiCommon0
        CFI Function eventCmdHandler
   CODE32      
eventCmdHandler:
   STMDB       SP!,{R4-R7,LR}     ;; Push
        CFI ?RET Frame(CFA, -4)
        CFI R7 Frame(CFA, -8)
        CFI R6 Frame(CFA, -12)
        CFI R5 Frame(CFA, -16)
        CFI R4 Frame(CFA, -20)
        CFI CFA R13+20
   SUB         SP,SP,#+0x4
        CFI CFA R13+24
   MOV         R4,R0
   MOV         R5,R1
   MOV         R6,R2
   MOV         R0,SP
   _BLF        clicharGetOutputBuffer,clicharGetOutputBuffer??rA
   MOV         R7,R0
   LDR         R0,??DataTable5    ;; frameRxEventCount
   LDR         R3,[R0, #+0]
   LDR         R2,[R5, #+0]
   LDR         R1,??eventCmdHandler_0  ;; `?<Constant "%s: [%u] frame RX eve...">`
   MOV         R0,R7
   _BLF        sprintf,sprintf??rA
   LDR         R1,[SP, #+0]
   MOV         R0,R7
   _BLF        clicharSendOutputBuffer,clicharSendOutputBuffer??rA
   MOV         R0,#+0x0
   ADD         SP,SP,#+0x4        ;; stack cleaning
        CFI CFA R13+20
   LDMIA       SP!,{R4-R7,PC}     ;; return
   DATA        
??eventCmdHandler_0:
   DC32        `?<Constant "%s: [%u] frame RX eve...">`
        CFI EndBlock cfiBlock3

        RSEG CODE:CODE:NOROOT(2)
   DATA        
??DataTable5:
   DC32        frameRxEventCount

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock4 Using cfiCommon0
        CFI NoFunction
   CODE32      
eventqRegisterHandler??rA:
   LDR         R12,??Subroutine0_0  ;; eventqRegisterHandler
   MOV         PC,R12
   DATA        
??Subroutine0_0:
   DC32        eventqRegisterHandler
        CFI EndBlock cfiBlock4

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock5 Using cfiCommon0
        CFI NoFunction
   CODE32      
zarlinkIndexedWrite??rA:
   LDR         R12,??Subroutine1_0  ;; zarlinkIndexedWrite
   MOV         PC,R12
   DATA        
??Subroutine1_0:
   DC32        zarlinkIndexedWrite
        CFI EndBlock cfiBlock5

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock6 Using cfiCommon0
        CFI NoFunction
   CODE32      
zarlinkInterruptWrite??rA:
   LDR         R12,??Subroutine2_0  ;; zarlinkInterruptWrite
   MOV         PC,R12
   DATA        
??Subroutine2_0:
   DC32        zarlinkInterruptWrite
        CFI EndBlock cfiBlock6

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock7 Using cfiCommon0
        CFI NoFunction
   CODE32      
armvicIntConnect??rA:
   LDR         R12,??Subroutine3_0  ;; armvicIntConnect
   MOV         PC,R12
   DATA        
??Subroutine3_0:
   DC32        armvicIntConnect
        CFI EndBlock cfiBlock7

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock8 Using cfiCommon0
        CFI NoFunction
   CODE32      
armvicIntEnable??rA:
   LDR         R12,??Subroutine4_0  ;; armvicIntEnable
   MOV         PC,R12
   DATA        
??Subroutine4_0:
   DC32        armvicIntEnable
        CFI EndBlock cfiBlock8

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock9 Using cfiCommon0
        CFI NoFunction
   CODE32      
cliRegisterCommand??rA:
   LDR         R12,??Subroutine5_0  ;; cliRegisterCommand
   MOV         PC,R12
   DATA        
??Subroutine5_0:
   DC32        cliRegisterCommand
        CFI EndBlock cfiBlock9

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock10 Using cfiCommon0
        CFI NoFunction
   CODE32      
clicharGetOutputBuffer??rA:
   LDR         R12,??Subroutine6_0  ;; clicharGetOutputBuffer
   MOV         PC,R12
   DATA        
??Subroutine6_0:
   DC32        clicharGetOutputBuffer
        CFI EndBlock cfiBlock10

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock11 Using cfiCommon0
        CFI NoFunction
   CODE32      
sprintf??rA:
   LDR         R12,??Subroutine7_0  ;; sprintf
   MOV         PC,R12
   DATA        
??Subroutine7_0:
   DC32        sprintf
        CFI EndBlock cfiBlock11

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock12 Using cfiCommon0
        CFI NoFunction
   CODE32      
clicharSendOutputBuffer??rA:
   LDR         R12,??Subroutine8_0  ;; clicharSendOutputBuffer
   MOV         PC,R12
   DATA        
??Subroutine8_0:
   DC32        clicharSendOutputBuffer
        CFI EndBlock cfiBlock12

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock13 Using cfiCommon0
        CFI NoFunction
   CODE32      
zarlinkInterruptRead??rA:
   LDR         R12,??Subroutine9_0  ;; zarlinkInterruptRead
   MOV         PC,R12
   DATA        
??Subroutine9_0:
   DC32        zarlinkInterruptRead
        CFI EndBlock cfiBlock13

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock14 Using cfiCommon0
        CFI NoFunction
   CODE32      
eventqPut??rA:
   LDR         R12,??Subroutine10_0  ;; eventqPut
   MOV         PC,R12
   DATA        
??Subroutine10_0:
   DC32        eventqPut
        CFI EndBlock cfiBlock14

        RSEG INITTAB:CODE:ROOT(2)
   DATA
?init?tab?DATA_Z:
   DCD      sfe(DATA_Z) - sfb(DATA_Z), sfb(DATA_Z), sfb(DATA_Z)

        RSEG DATA_C:CONST:SORT:NOROOT(2)
`?<Constant "event">`:
        DC8 "event"
        DC8 0, 0

        RSEG DATA_C:CONST:SORT:NOROOT(2)
`?<Constant "event - show info on ...">`:
        DC8 "event - show info on events received from switch"
        DC8 0, 0, 0

        RSEG DATA_C:CONST:SORT:NOROOT(2)
`?<Constant "*** frame received [%...">`:
        DC8 "*** frame received [%u]\015\012"
        DC8 0, 0

        RSEG DATA_C:CONST:SORT:NOROOT(2)
`?<Constant "%s: [%u] frame RX eve...">`:
        DC8 "%s: [%u] frame RX events\015\012"
        DC8 0

        END
// 
// 700 bytes in segment CODE
// 116 bytes in segment DATA_C
//   9 bytes in segment DATA_Z
//  12 bytes in segment INITTAB
// 
// 568 bytes of CODE  memory (+ 144 bytes shared)
// 116 bytes of CONST memory
//   9 bytes of DATA  memory
//
//Errors: none
//Warnings: none
