#define VECTOR_C
/******************************************************************************
*
*   (C) Copyright 2006, Freescale Semiconductor, Inc. All Rights Reserved.
*
*   You can use this example for any purpose on any computer system with the
*   following restrictions:
*
*   1. This example is provided "as is", without warranty.
*
*   2. You don't remove this copyright notice from this example or any direct
*      derivation thereof.
*
* Description:    Vector table for OS/MPC55XX platform
*
* Notes:
*
******************************************************************************/

#if !defined(OSPROPH)    
#include    "../include/osprop.h"                              /* OS Properties */
#else    /* !defined(OSPROPH)    */
#include    OSPROPH                                 /* OS Properties */
#endif    /* !defined(OSPROPH)    */

/*    
 *    INTERRUPT VECTORS TABLE
 */
       .section .vects, 4, 1, 6     /* Switch to .vects section */
#if defined(OSSYSTIMER)
    .extern OSISRSystemTimer
    .extern OSisrSystemTimer
#endif /* defined(OSSYSTIMER) */
#if defined(OSSECONDTIMER)
    .extern OSISRSecondTimer
    .extern OSisrSecondTimer
#endif /* defined(OSSECONDTIMER) */
#if defined(OSISRDISPATCH)
    .extern OSInterruptDispatcher   /* Interrupt dispatcher */
#endif /* defined(OSISRDISPATCH) */
#if defined(OSWITHINTERRUPTLEVEL)
    .extern OSDECisr
    .extern OSFITisr
#endif /* defined(OSWITHINTERRUPTLEVEL) */
    
    skipsize = 0x10
    .globl    VTABLE, OSEXTVEC, OSDECVEC, OSFITVEC, OSInitIVORS
    .org    0
VTABLE:                            /*    Vector table start address    */
OSDECVEC:
#if     (defined(OSSYSTIMER) && defined(OSTIMDEC))

#if defined(OSWITHINTERRUPTLEVEL)
    b   OSisrSystemTimer        /* Handler generating Soft. interrupt */
#else /* defined(OSWITHINTERRUPTLEVEL) */
    b      OSISRSystemTimer
#endif /* defined(OSWITHINTERRUPTLEVEL) */

#elif   (defined(OSSECONDTIMER) && defined(OSTIM2DEC))

#if defined(OSWITHINTERRUPTLEVEL)
    b   OSisrSecondTimer        /* Handler generating Soft. interrupt */
#else /* defined(OSWITHINTERRUPTLEVEL) */
    b      OSISRSecondTimer
#endif /* defined(OSWITHINTERRUPTLEVEL) */

#else

#if defined(OSDECISR)
#if defined(OSWITHINTERRUPTLEVEL)
    b   OSDECisr               /* Handler generating Soft. interrupt */
#else /* defined(OSWITHINTERRUPTLEVEL) */
//    b      <Users's ISR for the DEC interrupt>
    b OSDECVEC
#endif /* defined(OSWITHINTERRUPTLEVEL) */
#endif /* defined(OSDECISR) */
    b OSDECVEC

#endif /* (defined(OSSYSTIMER) && defined(OSTIMDEC)) */
    .org    skipsize * 1        

OSFITVEC:
#if     (defined(OSSYSTIMER) && defined(OSTIMFIT))
#if defined(OSWITHINTERRUPTLEVEL)
    b   OSisrSystemTimer        /* Handler generating Soft. interrupt */
#else /* defined(OSWITHINTERRUPTLEVEL) */
    b      OSISRSystemTimer
#endif /* defined(OSWITHINTERRUPTLEVEL) */
#elif   (defined(OSSECONDTIMER) && defined(OSTIM2FIT))
#if defined(OSWITHINTERRUPTLEVEL)
    b   OSisrSecondTimer        /* Handler generating Soft. interrupt */
#else /* defined(OSWITHINTERRUPTLEVEL) */
    b      OSISRSecondTimer
#endif /* defined(OSWITHINTERRUPTLEVEL) */
#else
#if defined(OSFITISR)
#if defined(OSWITHINTERRUPTLEVEL)
    b   OSFITisr               /* Handler generating Soft. interrupt */
#else /* defined(OSWITHINTERRUPTLEVEL) */
//    b      <Users's ISR for the FIT interrupt>
    b OSFITVEC
#endif /* defined(OSWITHINTERRUPTLEVEL) */
#endif /* defined(OSFITISR) */
    b OSFITVEC
#endif /* (defined(OSSYSTIMER) && defined(OSTIMFIT)) */
    .org    skipsize * 2        

OSEXTVEC:
#if defined(OSISRDISPATCH)
    b OSInterruptDispatcher
    .org    skipsize * 3        

#endif /* defined(OSISRDISPATCH) */

OSDUMMYVEC:
    b OSDUMMYVEC

/***************************************************************************
 * Function : OSInitIVORS
 *
 * Description: initializes all IVORS with OSDUMMYVEC -
 *              trap for unhandled interrupts
 *
 * Returns: none
 *
 * Notes:   1. OS may overwrite IVOR 403,410,411 depending on configuration
 *          2. User may insert his one entries instead of OSDUMMYVEC
 *
 **************************************************************************/

OSInitIVORS:
        lis      r4,OSDUMMYVEC@ha   
        addi     r4,r4,OSDUMMYVEC@l 
        mtspr   400, r4     /* IVOR0 400 Critical input                                             */
        mtspr   401, r4     /* IVOR1 401 Machine check                                              */
        mtspr   402, r4     /* IVOR2 402 Data storage                                               */
        mtspr   403, r4     /* IVOR3 403 Instruction storage                                        */
        mtspr   404, r4     /* IVOR4 404 External input                                             */
        mtspr   405, r4     /* IVOR5 405 Alignment                                                  */
        mtspr   406, r4     /* IVOR6 406 Program                                                    */
        mtspr   407, r4     /* IVOR7 407 Floating-point unavailable                                 */
        mtspr   408, r4     /* IVOR8 408 System call                                                */
        mtspr   409, r4     /* IVOR9 409 Auxiliary processor unavailable. Not used by the e200z6.   */
        mtspr   410, r4     /* IVOR10 410 Decrementer                                               */
        mtspr   411, r4     /* IVOR11 411 Fixed-interval timer interrupt                            */
        mtspr   412, r4     /* IVOR12 412 Watchdog timer interrupt                                  */
        mtspr   413, r4     /* IVOR13 413 Data TLB error                                            */
        mtspr   414, r4     /* IVOR14 414 Instruction TLB error                                     */
 /*     mtspr   415, r4 */  /* IVOR15 415 Debug                                                     */
                            /* IVOR16-IVOR31 - Reserved for future architectural use                */
/** e200z6-Specific IVORs (Defined by the EID)  **/
        mtspr   528, r4     /* IVOR32 528 SPE APU unavailable                                       */
        mtspr   529, r4     /* IVOR33 529 SPE floating-point data exception                         */
        mtspr   530, r4     /* IVOR34 530 SPE floating-point round exception                        */
        blr
