summaryrefslogtreecommitdiffstats
path: root/src/ppe/sbe/sbefw/sbeirq.C
blob: c421d13710cb233cbeae99e273025734a55fb04a (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/ppe/sbe/sbefw/sbeirq.C $                                  */
/*                                                                        */
/* OpenPOWER OnChipController Project                                     */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015                             */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/*
 * @file: ppe/sbe/sbefw/sbeirq.C
 *
 * @brief This sets up and registers SBE ISRs
 *
 */

#include "sbeexeintf.H"
#include "sbeirq.H"
#include "sbetrace.H"


////////////////////////////////////////////////////////////////
// @brief:     SBE control loop ISR:
//               - FIFO new data available
//               - FIFO reset request
//
// @param[in]  i_pArg - Unused
// @param[in]  i_irq  - IRQ number as defined in sbeirq.h
//
////////////////////////////////////////////////////////////////
void sbe_fifo_interrupt_handler (void *i_pArg, PkIrqId i_irq)
{
    #define SBE_FUNC " sbe_fifo_interrupt_handler "
    SBE_ENTER(SBE_FUNC"i_irq=[0x%02X]",i_irq);

    int l_rc = 0;
    switch (i_irq)
    {
        case SBE_IRQ_SBEFIFO_DATA:
        case SBE_IRQ_SBEFIFO_RESET:
            // Mask the interrupt
            pk_irq_disable(i_irq);

            // Unblock the command receiver thread
            l_rc = pk_semaphore_post(&g_sbeSemCmdRecv);
            if (l_rc)
            {
                // If we received an error while posting the semaphore,
                // unmask the interrupt back and assert
                // @TODO via RTC : 129166
                //       Add support for ASSERT here
                SBE_ERROR(SBE_FUNC"pk_semaphore_post failed, rc=[%d]", l_rc);
                pk_irq_enable(i_irq);
            }
            break;

        default:
            SBE_ERROR(SBE_FUNC"Unknown IRQ, assert");
            // @TODO via RTC : 129166
            //       Add support for ASSERT here
            break;
    }
    #undef SBE_FUNC
}

////////////////////////////////////////////////////////////////
// See sbeexeintf.h for more details
////////////////////////////////////////////////////////////////
int sbeIRQSetup (void)
{
    #define SBE_FUNC " sbeIRQSetup "
    int l_rc = 0;

    // Disable the relevant IRQs while we set them up
    pk_irq_disable(SBE_IRQ_SBEFIFO_DATA);
    pk_irq_disable(SBE_IRQ_SBEFIFO_RESET);

    do
    {
        // Register the IRQ handler with PK

        // FIFO New data available interrupt
        l_rc = pk_irq_handler_set(SBE_IRQ_SBEFIFO_DATA,
                              sbe_fifo_interrupt_handler,
                              NULL);

        if(l_rc)
        {
            SBE_ERROR (SBE_FUNC"pk_irq_handler_set failed, IRQ=[0x%02X], "
                   "rc=[%d]", SBE_IRQ_SBEFIFO_DATA, l_rc);
            break;
        }

        // FIFO Reset request
        l_rc = pk_irq_handler_set(SBE_IRQ_SBEFIFO_RESET,
                              sbe_fifo_interrupt_handler,
                              NULL);

        if(l_rc)
        {
            SBE_ERROR (SBE_FUNC"pk_irq_handler_set failed, IRQ=[0x%02X], "
                  "rc=[%d]", SBE_IRQ_SBEFIFO_RESET, l_rc);
            break;
        }

        // Enable the IRQ
        pk_irq_enable(SBE_IRQ_SBEFIFO_RESET);
        pk_irq_enable(SBE_IRQ_SBEFIFO_DATA);
    } while(false);

    return l_rc;
    #undef SBE_FUNC
}
OpenPOWER on IntegriCloud