Patrick Venture | 38e8c6e | 2018-10-24 09:23:35 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
William A. Kennington III | d7f368a | 2019-02-07 14:54:38 -0800 | [diff] [blame] | 3 | #include <ipmid/api.h> |
Patrick Venture | 38e8c6e | 2018-10-24 09:23:35 -0700 | [diff] [blame] | 4 | |
| 5 | #include <cstdint> |
Willy Tu | 87a8b11 | 2021-12-13 22:26:56 -0800 | [diff] [blame^] | 6 | #include <ipmid/api-types.hpp> |
| 7 | #include <ipmid/message.hpp> |
| 8 | #include <span> |
| 9 | #include <vector> |
Patrick Venture | 38e8c6e | 2018-10-24 09:23:35 -0700 | [diff] [blame] | 10 | |
| 11 | using std::uint8_t; |
| 12 | |
| 13 | namespace oem |
| 14 | { |
| 15 | namespace i2c |
| 16 | { |
| 17 | /* |
| 18 | * Request header |
| 19 | */ |
| 20 | constexpr size_t requestHeaderBus = 0; |
| 21 | constexpr size_t requestHeaderFlags = 1; |
| 22 | constexpr size_t requestHeaderLen = 2; |
| 23 | |
| 24 | typedef uint8_t BusId; |
| 25 | typedef uint8_t ReqFlags; |
| 26 | |
| 27 | constexpr ReqFlags requestFlagsUsePec = (1 << 7); |
| 28 | |
| 29 | /* |
| 30 | * Request step. |
| 31 | */ |
| 32 | constexpr size_t stepHeaderDevAndDir = 0; |
| 33 | constexpr size_t stepHeaderFlags = 1; |
| 34 | constexpr size_t stepHeaderParm = 2; |
| 35 | constexpr size_t stepHeaderLen = 3; |
| 36 | |
| 37 | typedef uint8_t DevAddr; |
| 38 | typedef uint8_t StepFlags; |
| 39 | constexpr StepFlags stepFlagsRecvLen = (1 << 7); |
| 40 | constexpr StepFlags stepFlagsNoStart = (1 << 6); |
| 41 | |
| 42 | // So far 2 steps suffics, so 4 should be safe. |
| 43 | constexpr size_t maxSteps = 4; |
| 44 | |
| 45 | // Currently we specify 32 byte payload limit; |
| 46 | // but for block read with PEC that entails 34 total bytes. |
| 47 | constexpr size_t largestReply = 34; |
| 48 | |
| 49 | } // namespace i2c |
| 50 | |
Willy Tu | 87a8b11 | 2021-12-13 22:26:56 -0800 | [diff] [blame^] | 51 | using Resp = ipmi::RspType<std::vector<uint8_t>>; |
| 52 | |
Patrick Venture | 38e8c6e | 2018-10-24 09:23:35 -0700 | [diff] [blame] | 53 | /** |
| 54 | * I2c is a global i2c-via-ipmi manager and IPMI handler. |
| 55 | */ |
| 56 | class I2c |
| 57 | { |
| 58 | public: |
| 59 | /** |
Willy Tu | 87a8b11 | 2021-12-13 22:26:56 -0800 | [diff] [blame^] | 60 | * Register OEM IPMI handler. |
Patrick Venture | 38e8c6e | 2018-10-24 09:23:35 -0700 | [diff] [blame] | 61 | */ |
Willy Tu | 87a8b11 | 2021-12-13 22:26:56 -0800 | [diff] [blame^] | 62 | void registerOemRouter(); |
Patrick Venture | 38e8c6e | 2018-10-24 09:23:35 -0700 | [diff] [blame] | 63 | |
| 64 | /** |
| 65 | * The i2c-via-ipmi commands go through this method. |
| 66 | * |
Willy Tu | 87a8b11 | 2021-12-13 22:26:56 -0800 | [diff] [blame^] | 67 | * @param[in] ctx - IPMI Request Context. |
| 68 | * @param[in] data - Request Data. |
| 69 | * @return IPMI response. |
Patrick Venture | 38e8c6e | 2018-10-24 09:23:35 -0700 | [diff] [blame] | 70 | */ |
Willy Tu | 87a8b11 | 2021-12-13 22:26:56 -0800 | [diff] [blame^] | 71 | Resp transfer(ipmi::Context::ptr ctx, std::span<const uint8_t> data); |
Patrick Venture | 38e8c6e | 2018-10-24 09:23:35 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | } // namespace oem |