blob: 1c709d12356dcb62400f63075db6fec2a32bd406 [file] [log] [blame]
Jason M. Bills3f7c5e42018-10-03 14:00:41 -07001/*
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 <cstdint>
19#include <phosphor-ipmi-host/sensorhandler.hpp>
20
21static constexpr uint8_t ipmiSdrVersion = 0x51;
22
Jason M. Billsc04e2e72018-11-28 15:15:56 -080023namespace intel_oem::ipmi::sel
24{
Jason M. Billsc04e2e72018-11-28 15:15:56 -080025static constexpr uint8_t selOperationSupport = 0x02;
26static constexpr uint8_t systemEvent = 0x02;
27static constexpr size_t systemEventSize = 3;
28static constexpr uint8_t oemTsEventFirst = 0xC0;
29static constexpr uint8_t oemTsEventLast = 0xDF;
30static constexpr size_t oemTsEventSize = 9;
31static constexpr uint8_t oemEventFirst = 0xE0;
32static constexpr uint8_t oemEventLast = 0xFF;
33static constexpr size_t oemEventSize = 13;
34static constexpr uint8_t eventMsgRev = 0x04;
35} // namespace intel_oem::ipmi::sel
36
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070037#pragma pack(push, 1)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070038struct GetSDRReq
39{
40 uint16_t reservationID;
41 uint16_t recordID;
42 uint8_t offset;
43 uint8_t bytesToRead;
44};
45#pragma pack(pop)
46
47enum class SdrRepositoryInfoOps : uint8_t
48{
49 allocCommandSupported = 0x1,
50 reserveSDRRepositoryCommandSupported = 0x2,
51 partialAddSDRSupported = 0x4,
52 deleteSDRSupported = 0x8,
53 reserved = 0x10,
54 modalLSB = 0x20,
55 modalMSB = 0x40,
56 overflow = 0x80
57};
58
59#pragma pack(push, 1)
Jason M. Billse2d1aee2018-10-03 15:57:18 -070060struct GetFRUAreaReq
61{
62 uint8_t fruDeviceID;
63 uint16_t fruInventoryOffset;
64 uint8_t countToRead;
65};
66
Jason M. Billse2d1aee2018-10-03 15:57:18 -070067struct WriteFRUDataReq
68{
69 uint8_t fruDeviceID;
70 uint16_t fruInventoryOffset;
71 uint8_t data[];
72};
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070073#pragma pack(pop)
74
Jason M. Billse2d1aee2018-10-03 15:57:18 -070075enum class GetFRUAreaAccessType : uint8_t
76{
77 byte = 0x0,
78 words = 0x1
79};
80
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070081enum class SensorUnits : uint8_t
82{
83 unspecified = 0x0,
84 degreesC = 0x1,
85 volts = 0x4,
86 amps = 0x5,
87 watts = 0x6,
88 rpm = 0x12,
89};
90
91enum class IPMINetfnStorageCmds : ipmi_cmd_t
92{
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070093 ipmiCmdReadFRUData = 0x11,
94 ipmiCmdWriteFRUData = 0x12,
95 ipmiCmdGetRepositoryInfo = 0x20,
96 ipmiCmdGetSDRAllocationInfo = 0x21,
97 ipmiCmdReserveSDR = 0x22,
98 ipmiCmdGetSDR = 0x23,
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070099};
100
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700101#pragma pack(push, 1)
102struct FRUHeader
103{
104 uint8_t commonHeaderFormat;
105 uint8_t internalOffset;
106 uint8_t chassisOffset;
107 uint8_t boardOffset;
108 uint8_t productOffset;
109 uint8_t multiRecordOffset;
110 uint8_t pad;
111 uint8_t checksum;
112};
113#pragma pack(pop)
114
James Feist74c50c62019-08-14 14:18:41 -0700115#pragma pack(push, 1)
116struct Type12Record
117{
118 get_sdr::SensorDataRecordHeader header;
119 uint8_t slaveAddress;
120 uint8_t channelNumber;
121 uint8_t powerStateNotification;
122 uint8_t deviceCapabilities;
123 uint24_t reserved;
124 uint8_t entityID;
125 uint8_t entityInstance;
126 uint8_t oem;
127 uint8_t typeLengthCode;
128 char name[16];
129};
130#pragma pack(pop)
131
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700132namespace ipmi
133{
134namespace storage
135{
James Feist74c50c62019-08-14 14:18:41 -0700136
137constexpr const size_t type12Count = 2;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700138ipmi_ret_t getFruSdrs(size_t index, get_sdr::SensorDataFruRecord& resp);
139
140ipmi_ret_t getFruSdrCount(size_t& count);
James Feist74c50c62019-08-14 14:18:41 -0700141
142std::vector<uint8_t> getType12SDRs(uint16_t index, uint16_t recordId);
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700143} // namespace storage
144} // namespace ipmi