summaryrefslogtreecommitdiffstats
path: root/pk/ppe42/ppe42_init.c
blob: 52659aab0dad08675303f36af0882a441130d3a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//-----------------------------------------------------------------------------
// *! (C) Copyright International Business Machines Corp. 2014
// *! All Rights Reserved -- Property of IBM
// *! *** IBM Confidential ***
//-----------------------------------------------------------------------------

/// \file ppe42_init.c
/// \brief PPE42 initialization routines
///
/// The entry points in this file are routines that are typically used during
/// initialization, and their code space could be deallocated and recovered if
/// no longer needed by the application after initialization.

#include "pk.h"
#include "pk_trace.h"

// Note that __ppe42_system_setup() is called from the PK bootloader early
// in the initialization, at a point before the aplication has enabled
// critical or external interruts.

// This function is expected to be defined by the macro specific code (GPE, CME, SBE)
void __hwmacro_setup(void);


void
__ppe42_system_setup()
{
    //Only do this if the application hasn't provided a static table definition
#ifndef STATIC_IRQ_TABLE
    PkIrqId irq;

    // Initialize the interrupt vectors.
    for (irq = 0; irq < EXTERNAL_IRQS; irq++) {
        __ppe42_irq_handlers[irq].handler = __ppe42_default_irq_handler;      
    }

    //NOTE: EXTERNAL_IRQS is the phantom interrupt assigned irq
    __ppe42_irq_handlers[irq].handler = __ppe42_phantom_irq_handler;

    // Initialize special interrupt handlers
/*
    __ppe42_fit_routine = __ppe42_default_irq_handler;
    __ppe42_fit_arg = 0;

    __ppe42_watchdog_routine = __ppe42_default_irq_handler;
    __ppe42_watchdog_arg = 0;

    __ppe42_debug_routine = __ppe42_default_irq_handler;
    __ppe42_debug_arg = 0;
*/
#endif /*STATIC_IRQ_TABLE*/

    //Clear all status bits in the TSR
    mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS);

#ifdef APPCFG_USE_EXT_TIMEBASE
    //Enable the DEC interrupt and configure it to use the external dec_timer signal
    mtspr(SPRN_TCR, TCR_DIE | TCR_DS);
#else
    //Enable the DEC interrupt and configure it to use the internal clock signal
    mtspr(SPRN_TCR, TCR_DIE);
#endif /* APPCFG_USE_EXT_TIMEBASE */

#if PK_TIMER_SUPPORT
#if PK_TRACE_SUPPORT
extern PkTraceBuffer g_pk_trace_buf;
    //set the ppe instance id
    g_pk_trace_buf.instance_id = (uint16_t)(mfspr(SPRN_PIR) & PIR_PPE_INSTANCE_MASK);
#endif  /* PK_TRACE_SUPPORT */
#endif  /* PK_TIMER_SUPPORT */

    //call macro-specific setup
    __hwmacro_setup();
}


OpenPOWER on IntegriCloud