summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/mvpd_accessors/getMvpdExL2SingleMemberEnable.C
blob: 790731ec2814b2878fa66390e5c41daa01b95599 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/mvpd_accessors/getMvpdExL2SingleMemberEnable.C $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013,2014              */
/*                                                                        */
/* 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                                                     */
// $Id: getMvpdExL2SingleMemberEnable.C,v 1.1 2013/04/10 22:02:33 mjjones Exp $
/**
 *  @file getMvpdExL2SingleMemberEnable.C
 *
 *  @brief MVPD Accessor for providing the ATTR_EX_L2_SINGLE_MEMBER_ENABLE
 *         attribute
 */

/*
 * Change Log ******************************************************************
 * Flag     Defect/Feature  User        Date        Description
 * ------   --------------  ----------  ----------- ----------------------------
 *                          mjjones     04/10/2013  Created.
 */

#include <getMvpdExL2SingleMemberEnable.H>

extern "C"
{

fapi::ReturnCode getMvpdExL2SingleMemberEnable(
    const fapi::Target & i_procTarget,
    uint32_t & o_val)
{
    /**
     *  @brief Structure of the LWP4 record, IN keyword MVPD field
     *         for the retrieval of the Single Member Enable data
     *
     *  This could move to a common header file if multiple VPD Accessors need
     *  to get data from the LWP4 record, IN keyword MVPD field
     */
    struct MVPD_LWP4_IN
    {
        uint8_t iv_reserved0;
        uint8_t iv_reserved1;
        uint8_t iv_singleMemberEnable0_7;
        uint8_t iv_singleMemberEnable8_15;
    };

    fapi::ReturnCode l_rc;
    uint8_t * l_pField = NULL;
    uint32_t l_fieldSize = 0;

    FAPI_INF("getMvpdExL2SingleMemberEnable: entry");

    // Call fapiGetMvpdField with a NULL pointer to get the field size
    l_rc = fapiGetMvpdField(fapi::MVPD_RECORD_LWP4,
                            fapi::MVPD_KEYWORD_IN,
                            i_procTarget,
                            l_pField,
                            l_fieldSize);

    if (l_rc)
    {
        FAPI_ERR("getMvpdExL2SingleMemberEnable: Error getting MVPD field size");
    }
    else
    {
        if (l_fieldSize < sizeof(MVPD_LWP4_IN))
        {
            FAPI_ERR("getMvpdExL2SingleMemberEnable: MVPD field too small (%d)",
                     l_fieldSize);
            uint32_t & FIELD_SIZE = l_fieldSize;
            FAPI_SET_HWP_ERROR(l_rc,
                RC_MVPD_EX_L2_SINGLE_MEMBER_ENABLE_BAD_FIELD_SIZE);
        }
        else
        {
            // Allocate memory and call fapiGetMvpdField to get the field
            l_pField = new uint8_t[l_fieldSize];

            l_rc = fapiGetMvpdField(fapi::MVPD_RECORD_LWP4,
                                    fapi::MVPD_KEYWORD_IN,
                                    i_procTarget,
                                    l_pField,
                                    l_fieldSize);

            if (l_rc)
            {
                FAPI_ERR(
                    "getMvpdExL2SingleMemberEnable: Error getting MVPD field");
            }
            else
            {
                MVPD_LWP4_IN * l_pData =
                    reinterpret_cast<MVPD_LWP4_IN *>(l_pField);

                o_val = l_pData->iv_singleMemberEnable0_7;
                o_val <<= 8;
                o_val += l_pData->iv_singleMemberEnable8_15;

                FAPI_INF("getMvpdExL2SingleMemberEnable: 0x%08x", o_val);
            }

            delete [] l_pField;
        }
    }

    return l_rc;
}

}
OpenPOWER on IntegriCloud