Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 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 <cstddef> |
| 19 | #include <cstdint> |
| 20 | #include <oemcommands.hpp> |
| 21 | |
| 22 | #include "ipmid/api.h" |
| 23 | |
| 24 | constexpr uint16_t msgPayloadSize = 1024 * 60; |
| 25 | |
| 26 | typedef enum |
| 27 | { |
| 28 | regionLockUnlocked = 0, |
| 29 | regionLockStrict, |
| 30 | regionLockPreemptable |
| 31 | } MDRLockType; |
| 32 | |
| 33 | typedef struct |
| 34 | { |
| 35 | uint8_t DirVer; |
| 36 | uint8_t MDRType; |
| 37 | uint16_t timestamp; |
| 38 | uint16_t DataSize; |
| 39 | } __attribute__((packed)) MDRSmbios_Header; |
| 40 | |
| 41 | typedef struct |
| 42 | { |
| 43 | uint8_t MdrVersion; |
| 44 | uint8_t regionId; |
| 45 | bool valid; |
| 46 | uint8_t updateCount; |
| 47 | uint8_t lockPolicy; |
| 48 | uint16_t regionLength; |
| 49 | uint16_t regionUsed; |
| 50 | uint8_t CRC8; |
| 51 | } __attribute__((packed)) MDRState; |
| 52 | |
| 53 | struct RegionStatusRequest |
| 54 | { |
| 55 | uint8_t regionId; |
| 56 | } __attribute__((packed)); |
| 57 | |
| 58 | struct RegionStatusResponse |
| 59 | { |
| 60 | MDRState State; |
| 61 | } __attribute__((packed)); |
| 62 | |
| 63 | struct RegionCompleteRequest |
| 64 | { |
| 65 | uint8_t sessionId; |
| 66 | uint8_t regionId; |
| 67 | } __attribute__((packed)); |
| 68 | |
| 69 | struct RegionReadRequest |
| 70 | { |
| 71 | uint8_t regionId; |
| 72 | uint8_t length; |
| 73 | uint16_t offset; |
| 74 | } __attribute__((packed)); |
| 75 | |
| 76 | struct RegionReadResponse |
| 77 | { |
| 78 | uint8_t length; |
| 79 | uint8_t updateCount; |
| 80 | uint8_t data[msgPayloadSize]; |
| 81 | } __attribute__((packed)); |
| 82 | |
| 83 | struct RegionWriteRequest |
| 84 | { |
| 85 | uint8_t sessionId; |
| 86 | uint8_t regionId; |
| 87 | uint8_t length; |
| 88 | uint16_t offset; |
| 89 | uint8_t data[msgPayloadSize]; |
| 90 | } __attribute__((packed)); |
| 91 | |
| 92 | struct RegionLockRequest |
| 93 | { |
| 94 | uint8_t sessionId; |
| 95 | uint8_t regionId; |
| 96 | uint8_t lockPolicy; |
| 97 | uint16_t msTimeout; |
| 98 | } __attribute__((packed)); |
| 99 | |
| 100 | constexpr size_t maxMDRId = 5; |