summaryrefslogtreecommitdiffstats
path: root/src/occ_gpe1/gpe_membuf.c
blob: c5f9dd4c31fe3966d54683b584c46ff6816920c7 (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/occ_gpe1/gpe_membuf.c $                                   */
/*                                                                        */
/* OpenPOWER OnChipController Project                                     */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2018                        */
/* [+] 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                                                     */
#include "gpe_membuf.h"
#include "ipc_async_cmd.h"
#include "gpe_util.h"

MemBufConfiguration_t * G_membuf_config = NULL;

void gpe_membuf_init(ipc_msg_t* i_cmd, void* i_arg)
{
    int      rc;
    ipc_async_cmd_t *async_cmd = (ipc_async_cmd_t*)i_cmd;
    MemBufConfigParms_t* payload = (MemBufConfigParms_t*)async_cmd->cmd_data;

    MemBufConfiguration_t * config = payload->membufConfiguration;
    G_membuf_config = config;

    payload->error.error = 0;
    payload->error.ffdc  = 0;

    if(G_membuf_config == NULL)
    {
        PK_TRACE("gpe_membuf_init: membufConfiguration data ptr is NULL!");
        rc = GPE_RC_CONFIG_DATA_NULL_PTR;
    }
    else
    {
        if(payload->mem_type == MEMTYPE_CENTAUR)
        {
            PK_TRACE("Centaur_configuration. MSR:%08x",mfmsr());
            rc = gpe_centaur_configuration_create(G_membuf_config);
        }
        else if(payload->mem_type == MEMTYPE_OCMB)
        {
            PK_TRACE("Ocmb_configuration. MSR:%08x",mfmsr());
            rc = gpe_ocmb_configuration_create(G_membuf_config);
        }
        else
        {
            rc = GPE_RC_INVALID_MEMBUF_TYPE;
        }
        // Must set membuf_type AFTER config created!
        G_membuf_config->membuf_type = payload->mem_type;
    }

    payload->error.rc = rc;

    // Send response
    rc = ipc_send_rsp(i_cmd, IPC_RC_SUCCESS);
    if(rc)
    {
        PK_TRACE("gpe_membuf_init: Failed to send response. rc = %x. Halting GPE1.",
                 rc);

        gpe_set_ffdc(&(payload->error), 0x00, GPE_RC_IPC_SEND_FAILED, rc);
        pk_halt();
    }
}

void gpe_membuf_scom(ipc_msg_t* i_cmd, void* i_arg)
{
    static int g_log_once = 0;
    int      rc;
    ipc_async_cmd_t *async_cmd = (ipc_async_cmd_t*)i_cmd;
    MemBufScomParms_t * scomParms = (MemBufScomParms_t*)async_cmd->cmd_data;

    if(g_log_once == 0)
    {
        g_log_once = 1;
        PK_TRACE("gpe_membuf_scom. MSR:%08x",mfmsr());
    }
    gpe_inband_scom(G_membuf_config, scomParms);

    // Send response
    rc = ipc_send_rsp(i_cmd, IPC_RC_SUCCESS);
    if(rc)
    {
        PK_TRACE("gpe_membuf_scom: Failed to send response. rc = %x. Halting GPE1.",
                 rc);

        gpe_set_ffdc(&(scomParms->error), 0x00, GPE_RC_IPC_SEND_FAILED, rc);
        pk_halt();
    }


}

void gpe_membuf_data(ipc_msg_t* i_cmd, void* i_arg)
{
    static int g_log_once = 0;
    int      rc;
    ipc_async_cmd_t *async_cmd = (ipc_async_cmd_t*)i_cmd;

    MemBufGetMemDataParms_t * dataParms =
        (MemBufGetMemDataParms_t *)async_cmd->cmd_data;

    if(g_log_once == 0)
    {
        g_log_once = 1;
        PK_TRACE("Centaur Data. MSR:%08x",mfmsr());
    }
    if(G_membuf_config->membuf_type == MEMTYPE_CENTAUR)
    {
        rc = get_centaur_sensorcache(G_membuf_config, dataParms);
    }
    else
    {
        rc = get_ocmb_sensorcache(G_membuf_config, dataParms);
    }

    dataParms->error.rc = rc;

    // Send response
    rc = ipc_send_rsp(i_cmd, IPC_RC_SUCCESS);
    if(rc)
    {
        PK_TRACE("gpe_membuf_data: Failed to send response. rc = %x. Halting GPE1.",
                 rc);

        gpe_set_ffdc(&(dataParms->error), 0x00, GPE_RC_IPC_SEND_FAILED, rc);
        pk_halt();
    }
}


OpenPOWER on IntegriCloud