summaryrefslogtreecommitdiffstats
path: root/fru_area.cpp
blob: 389166c02e1d1ad7fba4c54de66b265760b68396 (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
#include "fru_area.hpp"

#include "frup.hpp"

#include <cstdint>
#include <cstring>
#include <phosphor-logging/log.hpp>

using namespace phosphor::logging;

//----------------------------------------------------------------
// Constructor
//----------------------------------------------------------------
IPMIFruArea::IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type,
                         bool bmcOnlyFru) :
    fruID(fruID),
    type(type), bmcOnlyFru(bmcOnlyFru)
{
    if (type == IPMI_FRU_AREA_INTERNAL_USE)
    {
        name = "INTERNAL_";
    }
    else if (type == IPMI_FRU_AREA_CHASSIS_INFO)
    {
        name = "CHASSIS_";
    }
    else if (type == IPMI_FRU_AREA_BOARD_INFO)
    {
        name = "BOARD_";
    }
    else if (type == IPMI_FRU_AREA_PRODUCT_INFO)
    {
        name = "PRODUCT_";
    }
    else if (type == IPMI_FRU_AREA_MULTI_RECORD)
    {
        name = "MULTI_";
    }
    else
    {
        name = IPMI_FRU_AREA_TYPE_MAX;
        log<level::ERR>("Invalid Area", entry("TYPE=%d", type));
    }
}

//-----------------------------------------------------
// For a FRU area type, accepts the data and updates
// area specific data.
//-----------------------------------------------------
void IPMIFruArea::setData(const uint8_t* value, const size_t length)
{
    data.reserve(length); // pre-allocate the space.
    data.insert(data.begin(), value, value + length);
}

//-----------------------------------------------------
// Sets the dbus parameters
//-----------------------------------------------------
void IPMIFruArea::updateDbusPaths(const char* bus, const char* path,
                                  const char* intf)
{
    busName = bus;
    objectPath = path;
    interfaceName = intf;
}
OpenPOWER on IntegriCloud