summaryrefslogtreecommitdiffstats
path: root/hwpf/include/fapi2ChipEcFeature.C
blob: 820cf7755f676997505b9630a816ce1afa16deb2 (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
// fapiChipEcFeature.C
// This file is generated by perl script fapiParseAttributeInfo.pl
// It implements the fapiQueryChipEcFeature function

#include <fapiChipEcFeature.H>
#include <fapiAttributeService.H>
#include <fapiSystemConfig.H>
#include <fapiPlatTrace.H>

namespace fapi2
{

fapi::ReturnCode fapiQueryChipEcFeature(fapi::AttributeId i_id,
                                        const fapi::Target * i_pTarget,
                                        uint8_t & o_hasFeature)
{
    o_hasFeature = false;
    fapi::ReturnCode l_rc;
    uint8_t l_chipName = 0;
    uint8_t l_chipEc = 0;
    fapi::Target l_target = *i_pTarget;

    if (i_pTarget->isChiplet())
    {
        l_rc = fapiGetParentChip(*i_pTarget, l_target);

        if (l_rc)
        {
            FAPI_ERR("fapiQueryChipEcFeature: error getting parent chip");
        }
    }

    if (!l_rc)
    {
        l_rc = FAPI_ATTR_GET_PRIVILEGED(ATTR_NAME, &l_target, l_chipName);

        if (l_rc)
        {
            FAPI_ERR("fapiQueryChipEcFeature: error getting chip name");
        }
        else
        {
            l_rc = FAPI_ATTR_GET_PRIVILEGED(ATTR_EC, &l_target, l_chipEc);

            if (l_rc)
            {
                FAPI_ERR("fapiQueryChipEcFeature: error getting chip ec");
            }
            else
            {
                switch (i_id)
                {
                default:
                    FAPI_ERR("fapiQueryChipEcFeature: Unknown feature 0x%x",
                        i_id);
                    l_rc.setFapiError(FAPI_RC_INVALID_CHIP_EC_FEATURE_GET);
                    l_rc.addEIFfdc(0, &i_id, sizeof(i_id));
                    break;
                }

                if (o_hasFeature)
                {
                    FAPI_INF("fapiQueryChipEcFeature: Chip (0x%x:0x%x) has feature (0x%x)", l_chipName, l_chipEc, i_id);
                }
                else
                {
                    FAPI_INF("fapiQueryChipEcFeature: Chip (0x%x:0x%x) does not have feature (0x%x)", l_chipName, l_chipEc, i_id);
                }
            }
        }
    }
    return l_rc;
}

}
OpenPOWER on IntegriCloud