1 /*
2 // Copyright (c) 2017 2018 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 
17 #pragma once
18 #include "sensorhandler.hpp"
19 
20 #include <cstdint>
21 
22 #define USING_ENTITY_MANAGER_DECORATORS
23 
24 static constexpr uint8_t ipmiSdrVersion = 0x51;
25 
26 namespace dynamic_sensors::ipmi::sel
27 {
28 static constexpr uint8_t selOperationSupport = 0x02;
29 static constexpr uint8_t systemEvent = 0x02;
30 static constexpr size_t systemEventSize = 3;
31 static constexpr uint8_t oemTsEventFirst = 0xC0;
32 static constexpr uint8_t oemTsEventLast = 0xDF;
33 static constexpr size_t oemTsEventSize = 9;
34 static constexpr uint8_t oemEventFirst = 0xE0;
35 static constexpr uint8_t oemEventLast = 0xFF;
36 static constexpr size_t oemEventSize = 13;
37 static constexpr uint8_t eventMsgRev = 0x04;
38 } // namespace dynamic_sensors::ipmi::sel
39 
40 enum class SdrRepositoryInfoOps : uint8_t
41 {
42     allocCommandSupported = 0x1,
43     reserveSDRRepositoryCommandSupported = 0x2,
44     partialAddSDRSupported = 0x4,
45     deleteSDRSupported = 0x8,
46     reserved = 0x10,
47     modalLSB = 0x20,
48     modalMSB = 0x40,
49     overflow = 0x80
50 };
51 
52 enum class GetFRUAreaAccessType : uint8_t
53 {
54     byte = 0x0,
55     words = 0x1
56 };
57 
58 enum class SensorUnits : uint8_t
59 {
60     unspecified = 0x0,
61     degreesC = 0x1,
62     volts = 0x4,
63     amps = 0x5,
64     watts = 0x6,
65     rpm = 0x12,
66 };
67 
68 #pragma pack(push, 1)
69 struct FRUHeader
70 {
71     uint8_t commonHeaderFormat;
72     uint8_t internalOffset;
73     uint8_t chassisOffset;
74     uint8_t boardOffset;
75     uint8_t productOffset;
76     uint8_t multiRecordOffset;
77     uint8_t pad;
78     uint8_t checksum;
79 };
80 #pragma pack(pop)
81 
82 #pragma pack(push, 1)
83 struct Type12Record
84 {
85     get_sdr::SensorDataRecordHeader header;
86     uint8_t slaveAddress;
87     uint8_t channelNumber;
88     uint8_t powerStateNotification;
89     uint8_t deviceCapabilities;
90     uint24_t reserved;
91     uint8_t entityID;
92     uint8_t entityInstance;
93     uint8_t oem;
94     uint8_t typeLengthCode;
95     char name[16];
96 };
97 #pragma pack(pop)
98 
99 namespace ipmi
100 {
101 namespace storage
102 {
103 
104 constexpr const size_t type12Count = 2;
105 ipmi_ret_t getFruSdrs(ipmi::Context::ptr ctx, size_t index,
106                       get_sdr::SensorDataFruRecord& resp);
107 
108 ipmi_ret_t getFruSdrCount(ipmi::Context::ptr ctx, size_t& count);
109 
110 std::vector<uint8_t> getType12SDRs(uint16_t index, uint16_t recordId);
111 std::vector<uint8_t> getNMDiscoverySDR(uint16_t index, uint16_t recordId);
112 } // namespace storage
113 } // namespace ipmi
114