| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | // Copyright (c) 2019 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 | #pragma once | 
|  | 17 | #ifdef __cplusplus | 
| Patrick Williams | 7169faa | 2023-05-10 07:51:24 -0500 | [diff] [blame] | 18 | extern "C" | 
|  | 19 | { | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 20 | #endif | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 21 | #include <inttypes.h> | 
|  | 22 | #include <stdbool.h> | 
|  | 23 |  | 
|  | 24 | // PECI Client Address List | 
|  | 25 | #define MIN_CLIENT_ADDR 0x30 | 
|  | 26 | #define MAX_CLIENT_ADDR 0x37 | 
|  | 27 | #define MAX_CPUS (MAX_CLIENT_ADDR - MIN_CLIENT_ADDR + 1) | 
|  | 28 |  | 
| Jason M. Bills | a2ceec2 | 2020-05-05 13:16:00 -0700 | [diff] [blame] | 29 | // PECI completion codes from peci-ioctl.h | 
|  | 30 | #define PECI_DEV_CC_SUCCESS 0x40 | 
|  | 31 | #define PECI_DEV_CC_FATAL_MCA_DETECTED 0x94 | 
|  | 32 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 33 | typedef enum | 
|  | 34 | { | 
|  | 35 | skx = 0x00050650, | 
|  | 36 | icx = 0x000606A0, | 
|  | 37 | icxd = 0x000606C0, | 
|  | 38 | spr = 0x000806F0, | 
|  | 39 | emr = 0x000C06F0, | 
|  | 40 | gnr = 0x000A06D0, | 
|  | 41 | gnrd = 0x000A06E0, | 
|  | 42 | srf = 0x000A06F0, | 
|  | 43 | } CPUModel; | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 44 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 45 | // PECI Status Codes | 
|  | 46 | typedef enum | 
|  | 47 | { | 
|  | 48 | PECI_CC_SUCCESS = 0, | 
|  | 49 | PECI_CC_INVALID_REQ, | 
|  | 50 | PECI_CC_HW_ERR, | 
|  | 51 | PECI_CC_DRIVER_ERR, | 
|  | 52 | PECI_CC_CPU_NOT_PRESENT, | 
|  | 53 | PECI_CC_MEM_ERR, | 
|  | 54 | PECI_CC_TIMEOUT, | 
|  | 55 | } EPECIStatus; | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 56 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 57 | // PECI Timeout Options | 
|  | 58 | typedef enum | 
|  | 59 | { | 
|  | 60 | PECI_WAIT_FOREVER = -1, | 
|  | 61 | PECI_NO_WAIT = 0, | 
|  | 62 | } EPECITimeout; | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 63 |  | 
|  | 64 | #define PECI_TIMEOUT_RESOLUTION_MS 10 // 10 ms | 
|  | 65 | #define PECI_TIMEOUT_MS 100           // 100 ms | 
|  | 66 |  | 
|  | 67 | // VCU Index and Sequence Paramaters | 
|  | 68 | #define VCU_SET_PARAM 0x0001 | 
|  | 69 | #define VCU_READ 0x0002 | 
|  | 70 | #define VCU_OPEN_SEQ 0x0003 | 
|  | 71 | #define VCU_CLOSE_SEQ 0x0004 | 
|  | 72 | #define VCU_ABORT_SEQ 0x0005 | 
|  | 73 | #define VCU_VERSION 0x0009 | 
|  | 74 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 75 | typedef enum | 
|  | 76 | { | 
|  | 77 | VCU_READ_LOCAL_CSR_SEQ = 0x2, | 
|  | 78 | VCU_READ_LOCAL_MMIO_SEQ = 0x6, | 
|  | 79 | VCU_EN_SECURE_DATA_SEQ = 0x14, | 
|  | 80 | VCU_CORE_MCA_SEQ = 0x10000, | 
|  | 81 | VCU_UNCORE_MCA_SEQ = 0x10000, | 
|  | 82 | VCU_IOT_BRKPT_SEQ = 0x10010, | 
|  | 83 | VCU_MBP_CONFIG_SEQ = 0x10026, | 
|  | 84 | VCU_PWR_MGT_SEQ = 0x1002a, | 
|  | 85 | VCU_CRASHDUMP_SEQ = 0x10038, | 
|  | 86 | VCU_ARRAY_DUMP_SEQ = 0x20000, | 
|  | 87 | VCU_SCAN_DUMP_SEQ = 0x20008, | 
|  | 88 | VCU_TOR_DUMP_SEQ = 0x30002, | 
|  | 89 | VCU_SQ_DUMP_SEQ = 0x30004, | 
|  | 90 | VCU_UNCORE_CRASHDUMP_SEQ = 0x30006, | 
|  | 91 | } EPECISequence; | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 92 |  | 
|  | 93 | #define MBX_INDEX_VCU 128 // VCU Index | 
|  | 94 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 95 | typedef enum | 
|  | 96 | { | 
|  | 97 | MMIO_DWORD_OFFSET = 0x05, | 
|  | 98 | MMIO_QWORD_OFFSET = 0x06, | 
|  | 99 | } EEndPtMmioAddrType; | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 100 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 101 | // Find the specified PCI bus number value | 
|  | 102 | EPECIStatus FindBusNumber(uint8_t u8Bus, uint8_t u8Cpu, uint8_t* pu8BusValue); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 103 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 104 | // Gets the temperature from the target | 
|  | 105 | // Expressed in signed fixed point value of 1/64 degrees celsius | 
|  | 106 | EPECIStatus peci_GetTemp(uint8_t target, int16_t* temperature); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 107 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 108 | // Provides read access to the package configuration space within the | 
|  | 109 | // processor | 
|  | 110 | EPECIStatus peci_RdPkgConfig(uint8_t target, uint8_t u8Index, uint16_t u16Value, | 
|  | 111 | uint8_t u8ReadLen, uint8_t* pPkgConfig, | 
|  | 112 | uint8_t* cc); | 
|  | 113 |  | 
|  | 114 | // Provides read access to the package configuration space within the | 
|  | 115 | // processor in the specified domain | 
|  | 116 | EPECIStatus peci_RdPkgConfig_dom(uint8_t target, uint8_t domainId, | 
|  | 117 | uint8_t u8Index, uint16_t u16Value, | 
|  | 118 | uint8_t u8ReadLen, uint8_t* pPkgConfig, | 
|  | 119 | uint8_t* cc); | 
|  | 120 |  | 
|  | 121 | // Allows sequential RdPkgConfig with the provided peci file descriptor | 
|  | 122 | EPECIStatus peci_RdPkgConfig_seq(uint8_t target, uint8_t u8Index, | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 123 | uint16_t u16Value, uint8_t u8ReadLen, | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 124 | uint8_t* pPkgConfig, int peci_fd, uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 125 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 126 | // Allows sequential RdPkgConfig with the provided peci file descriptor in | 
|  | 127 | // the specified domain | 
|  | 128 | EPECIStatus peci_RdPkgConfig_seq_dom(uint8_t target, uint8_t domainId, | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 129 | uint8_t u8Index, uint16_t u16Value, | 
|  | 130 | uint8_t u8ReadLen, uint8_t* pPkgConfig, | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 131 | int peci_fd, uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 132 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 133 | // Provides write access to the package configuration space within the | 
|  | 134 | // processor | 
|  | 135 | EPECIStatus peci_WrPkgConfig(uint8_t target, uint8_t u8Index, uint16_t u16Param, | 
|  | 136 | uint32_t u32Value, uint8_t u8WriteLen, | 
|  | 137 | uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 138 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 139 | // Provides write access to the package configuration space within the | 
|  | 140 | // processor in the specified domain | 
|  | 141 | EPECIStatus peci_WrPkgConfig_dom(uint8_t target, uint8_t domainId, | 
|  | 142 | uint8_t u8Index, uint16_t u16Param, | 
|  | 143 | uint32_t u32Value, uint8_t u8WriteLen, | 
|  | 144 | uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 145 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 146 | // Allows sequential WrPkgConfig with the provided peci file descriptor | 
|  | 147 | EPECIStatus peci_WrPkgConfig_seq(uint8_t target, uint8_t u8Index, | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 148 | uint16_t u16Param, uint32_t u32Value, | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 149 | uint8_t u8WriteLen, int peci_fd, uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 150 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 151 | // Allows sequential WrPkgConfig with the provided peci file descriptor in | 
|  | 152 | // the specified domain | 
|  | 153 | EPECIStatus peci_WrPkgConfig_seq_dom(uint8_t target, uint8_t domainId, | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 154 | uint8_t u8Index, uint16_t u16Param, | 
|  | 155 | uint32_t u32Value, uint8_t u8WriteLen, | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 156 | int peci_fd, uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 157 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 158 | // Provides read access to Model Specific Registers | 
|  | 159 | EPECIStatus peci_RdIAMSR(uint8_t target, uint8_t threadID, uint16_t MSRAddress, | 
|  | 160 | uint64_t* u64MsrVal, uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 161 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 162 | // Provides read access to Model Specific Registers in the specified domain | 
|  | 163 | EPECIStatus peci_RdIAMSR_dom(uint8_t target, uint8_t domainId, uint8_t threadID, | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 164 | uint16_t MSRAddress, uint64_t* u64MsrVal, | 
|  | 165 | uint8_t* cc); | 
|  | 166 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 167 | // Provides read access to PCI Configuration space | 
|  | 168 | EPECIStatus peci_RdPCIConfig(uint8_t target, uint8_t u8Bus, uint8_t u8Device, | 
|  | 169 | uint8_t u8Fcn, uint16_t u16Reg, uint8_t* pPCIReg, | 
|  | 170 | uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 171 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 172 | // Provides read access to PCI Configuration space in the specified domain | 
|  | 173 | EPECIStatus peci_RdPCIConfig_dom(uint8_t target, uint8_t domainId, | 
|  | 174 | uint8_t u8Bus, uint8_t u8Device, uint8_t u8Fcn, | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 175 | uint16_t u16Reg, uint8_t* pPCIReg, | 
|  | 176 | uint8_t* cc); | 
|  | 177 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 178 | // Allows sequential RdPCIConfig with the provided peci file descriptor | 
|  | 179 | EPECIStatus peci_RdPCIConfig_seq(uint8_t target, uint8_t u8Bus, | 
|  | 180 | uint8_t u8Device, uint8_t u8Fcn, | 
|  | 181 | uint16_t u16Reg, uint8_t* pPCIData, | 
|  | 182 | int peci_fd, uint8_t* cc); | 
|  | 183 |  | 
|  | 184 | // Allows sequential RdPCIConfig with the provided peci file descriptor in | 
|  | 185 | // the specified domain | 
|  | 186 | EPECIStatus peci_RdPCIConfig_seq_dom(uint8_t target, uint8_t domainId, | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 187 | uint8_t u8Bus, uint8_t u8Device, | 
|  | 188 | uint8_t u8Fcn, uint16_t u16Reg, | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 189 | uint8_t* pPCIData, int peci_fd, | 
|  | 190 | uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 191 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 192 | // Provides read access to the local PCI Configuration space | 
|  | 193 | EPECIStatus peci_RdPCIConfigLocal(uint8_t target, uint8_t u8Bus, | 
|  | 194 | uint8_t u8Device, uint8_t u8Fcn, | 
|  | 195 | uint16_t u16Reg, uint8_t u8ReadLen, | 
|  | 196 | uint8_t* pPCIReg, uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 197 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 198 | // Provides read access to the local PCI Configuration space in the | 
|  | 199 | // specified domain | 
|  | 200 | EPECIStatus peci_RdPCIConfigLocal_dom(uint8_t target, uint8_t domainId, | 
|  | 201 | uint8_t u8Bus, uint8_t u8Device, | 
|  | 202 | uint8_t u8Fcn, uint16_t u16Reg, | 
|  | 203 | uint8_t u8ReadLen, uint8_t* pPCIReg, | 
|  | 204 | uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 205 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 206 | // Allows sequential RdPCIConfigLocal with the provided peci file descriptor | 
|  | 207 | EPECIStatus peci_RdPCIConfigLocal_seq(uint8_t target, uint8_t u8Bus, | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 208 | uint8_t u8Device, uint8_t u8Fcn, | 
|  | 209 | uint16_t u16Reg, uint8_t u8ReadLen, | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 210 | uint8_t* pPCIReg, int peci_fd, | 
|  | 211 | uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 212 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 213 | // Allows sequential RdPCIConfigLocal with the provided peci file descriptor | 
|  | 214 | // in the specified domain | 
|  | 215 | EPECIStatus peci_RdPCIConfigLocal_seq_dom(uint8_t target, uint8_t domainId, | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 216 | uint8_t u8Bus, uint8_t u8Device, | 
|  | 217 | uint8_t u8Fcn, uint16_t u16Reg, | 
|  | 218 | uint8_t u8ReadLen, uint8_t* pPCIReg, | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 219 | int peci_fd, uint8_t* cc); | 
|  | 220 |  | 
|  | 221 | // Provides write access to the local PCI Configuration space | 
|  | 222 | EPECIStatus peci_WrPCIConfigLocal(uint8_t target, uint8_t u8Bus, | 
|  | 223 | uint8_t u8Device, uint8_t u8Fcn, | 
|  | 224 | uint16_t u16Reg, uint8_t DataLen, | 
|  | 225 | uint32_t DataVal, uint8_t* cc); | 
|  | 226 |  | 
|  | 227 | // Provides write access to the local PCI Configuration space in the | 
|  | 228 | // specified domain | 
|  | 229 | EPECIStatus peci_WrPCIConfigLocal_dom(uint8_t target, uint8_t domainId, | 
|  | 230 | uint8_t u8Bus, uint8_t u8Device, | 
|  | 231 | uint8_t u8Fcn, uint16_t u16Reg, | 
|  | 232 | uint8_t DataLen, uint32_t DataVal, | 
|  | 233 | uint8_t* cc); | 
|  | 234 |  | 
|  | 235 | // Provides read access to PCI configuration space | 
|  | 236 | EPECIStatus peci_RdEndPointConfigPci(uint8_t target, uint8_t u8Seg, | 
|  | 237 | uint8_t u8Bus, uint8_t u8Device, | 
|  | 238 | uint8_t u8Fcn, uint16_t u16Reg, | 
|  | 239 | uint8_t u8ReadLen, uint8_t* pPCIData, | 
|  | 240 | uint8_t* cc); | 
|  | 241 |  | 
|  | 242 | // Provides read access to PCI configuration space in the specified domain | 
|  | 243 | EPECIStatus peci_RdEndPointConfigPci_dom(uint8_t target, uint8_t domainId, | 
|  | 244 | uint8_t u8Seg, uint8_t u8Bus, | 
|  | 245 | uint8_t u8Device, uint8_t u8Fcn, | 
|  | 246 | uint16_t u16Reg, uint8_t u8ReadLen, | 
|  | 247 | uint8_t* pPCIData, uint8_t* cc); | 
|  | 248 |  | 
|  | 249 | // Allows sequential RdEndPointConfig to PCI Configuration space | 
|  | 250 | EPECIStatus peci_RdEndPointConfigPci_seq(uint8_t target, uint8_t u8Seg, | 
|  | 251 | uint8_t u8Bus, uint8_t u8Device, | 
|  | 252 | uint8_t u8Fcn, uint16_t u16Reg, | 
|  | 253 | uint8_t u8ReadLen, uint8_t* pPCIData, | 
|  | 254 | int peci_fd, uint8_t* cc); | 
|  | 255 |  | 
|  | 256 | // Allows sequential RdEndPointConfig to PCI Configuration space in the | 
|  | 257 | // specified domain | 
|  | 258 | EPECIStatus peci_RdEndPointConfigPci_seq_dom(uint8_t target, uint8_t domainId, | 
|  | 259 | uint8_t u8Seg, uint8_t u8Bus, | 
|  | 260 | uint8_t u8Device, uint8_t u8Fcn, | 
|  | 261 | uint16_t u16Reg, uint8_t u8ReadLen, | 
|  | 262 | uint8_t* pPCIData, int peci_fd, | 
|  | 263 | uint8_t* cc); | 
|  | 264 |  | 
|  | 265 | // Provides read access to the local PCI configuration space | 
|  | 266 | EPECIStatus peci_RdEndPointConfigPciLocal(uint8_t target, uint8_t u8Seg, | 
|  | 267 | uint8_t u8Bus, uint8_t u8Device, | 
|  | 268 | uint8_t u8Fcn, uint16_t u16Reg, | 
|  | 269 | uint8_t u8ReadLen, uint8_t* pPCIData, | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 270 | uint8_t* cc); | 
|  | 271 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 272 | // Provides read access to the local PCI configuration space in the | 
|  | 273 | // specified domain | 
|  | 274 | EPECIStatus peci_RdEndPointConfigPciLocal_dom(uint8_t target, uint8_t domainId, | 
|  | 275 | uint8_t u8Seg, uint8_t u8Bus, | 
|  | 276 | uint8_t u8Device, uint8_t u8Fcn, | 
|  | 277 | uint16_t u16Reg, | 
|  | 278 | uint8_t u8ReadLen, | 
|  | 279 | uint8_t* pPCIData, uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 280 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 281 | // Allows sequential RdEndPointConfig to the local PCI Configuration space | 
|  | 282 | EPECIStatus peci_RdEndPointConfigPciLocal_seq(uint8_t target, uint8_t u8Seg, | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 283 | uint8_t u8Bus, uint8_t u8Device, | 
|  | 284 | uint8_t u8Fcn, uint16_t u16Reg, | 
|  | 285 | uint8_t u8ReadLen, | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 286 | uint8_t* pPCIData, int peci_fd, | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 287 | uint8_t* cc); | 
|  | 288 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 289 | // Allows sequential RdEndPointConfig to the local PCI Configuration space | 
|  | 290 | // in the specified domain | 
|  | 291 | EPECIStatus peci_RdEndPointConfigPciLocal_seq_dom( | 
|  | 292 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, | 
|  | 293 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, uint8_t u8ReadLen, | 
|  | 294 | uint8_t* pPCIData, int peci_fd, uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 295 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 296 | // Provides read access to PCI MMIO space | 
|  | 297 | EPECIStatus peci_RdEndPointConfigMmio(uint8_t target, uint8_t u8Seg, | 
|  | 298 | uint8_t u8Bus, uint8_t u8Device, | 
|  | 299 | uint8_t u8Fcn, uint8_t u8Bar, | 
|  | 300 | uint8_t u8AddrType, uint64_t u64Offset, | 
|  | 301 | uint8_t u8ReadLen, uint8_t* pMmioData, | 
|  | 302 | uint8_t* cc); | 
|  | 303 |  | 
|  | 304 | // Provides read access to PCI MMIO space in the specified domain | 
|  | 305 | EPECIStatus peci_RdEndPointConfigMmio_dom(uint8_t target, uint8_t domainId, | 
|  | 306 | uint8_t u8Seg, uint8_t u8Bus, | 
|  | 307 | uint8_t u8Device, uint8_t u8Fcn, | 
|  | 308 | uint8_t u8Bar, uint8_t u8AddrType, | 
|  | 309 | uint64_t u64Offset, uint8_t u8ReadLen, | 
|  | 310 | uint8_t* pMmioData, uint8_t* cc); | 
|  | 311 |  | 
|  | 312 | // Allows sequential RdEndPointConfig to PCI MMIO space | 
|  | 313 | EPECIStatus peci_RdEndPointConfigMmio_seq( | 
|  | 314 | uint8_t target, uint8_t u8Seg, uint8_t u8Bus, uint8_t u8Device, | 
|  | 315 | uint8_t u8Fcn, uint8_t u8Bar, uint8_t u8AddrType, uint64_t u64Offset, | 
|  | 316 | uint8_t u8ReadLen, uint8_t* pMmioData, int peci_fd, uint8_t* cc); | 
|  | 317 |  | 
|  | 318 | // Allows sequential RdEndPointConfig to PCI MMIO space in the specified | 
|  | 319 | // domain | 
|  | 320 | EPECIStatus peci_RdEndPointConfigMmio_seq_dom( | 
|  | 321 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, | 
|  | 322 | uint8_t u8Device, uint8_t u8Fcn, uint8_t u8Bar, uint8_t u8AddrType, | 
|  | 323 | uint64_t u64Offset, uint8_t u8ReadLen, uint8_t* pMmioData, int peci_fd, | 
|  | 324 | uint8_t* cc); | 
|  | 325 |  | 
|  | 326 | // Provides write access to the EP local PCI Configuration space | 
|  | 327 | EPECIStatus peci_WrEndPointPCIConfigLocal(uint8_t target, uint8_t u8Seg, | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 328 | uint8_t u8Bus, uint8_t u8Device, | 
|  | 329 | uint8_t u8Fcn, uint16_t u16Reg, | 
|  | 330 | uint8_t DataLen, uint32_t DataVal, | 
|  | 331 | uint8_t* cc); | 
|  | 332 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 333 | // Provides write access to the EP local PCI Configuration space in the | 
|  | 334 | // specified domain | 
|  | 335 | EPECIStatus peci_WrEndPointPCIConfigLocal_dom(uint8_t target, uint8_t domainId, | 
|  | 336 | uint8_t u8Seg, uint8_t u8Bus, | 
|  | 337 | uint8_t u8Device, uint8_t u8Fcn, | 
|  | 338 | uint16_t u16Reg, uint8_t DataLen, | 
|  | 339 | uint32_t DataVal, uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 340 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 341 | // Provides write access to the EP PCI Configuration space | 
|  | 342 | EPECIStatus peci_WrEndPointPCIConfig(uint8_t target, uint8_t u8Seg, | 
|  | 343 | uint8_t u8Bus, uint8_t u8Device, | 
|  | 344 | uint8_t u8Fcn, uint16_t u16Reg, | 
|  | 345 | uint8_t DataLen, uint32_t DataVal, | 
|  | 346 | uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 347 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 348 | // Provides write access to the EP PCI Configuration space in the specified | 
|  | 349 | // domain | 
|  | 350 | EPECIStatus peci_WrEndPointPCIConfig_dom(uint8_t target, uint8_t domainId, | 
|  | 351 | uint8_t u8Seg, uint8_t u8Bus, | 
|  | 352 | uint8_t u8Device, uint8_t u8Fcn, | 
|  | 353 | uint16_t u16Reg, uint8_t DataLen, | 
|  | 354 | uint32_t DataVal, uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 355 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 356 | // Allows sequential write access to the EP PCI Configuration space | 
|  | 357 | EPECIStatus peci_WrEndPointConfig_seq(uint8_t target, uint8_t u8MsgType, | 
|  | 358 | uint8_t u8Seg, uint8_t u8Bus, | 
|  | 359 | uint8_t u8Device, uint8_t u8Fcn, | 
|  | 360 | uint16_t u16Reg, uint8_t DataLen, | 
|  | 361 | uint32_t DataVal, int peci_fd, | 
|  | 362 | uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 363 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 364 | // Allows sequential write access to the EP PCI Configuration space in the | 
|  | 365 | // specified domain | 
|  | 366 | EPECIStatus peci_WrEndPointConfig_seq_dom(uint8_t target, uint8_t domainId, | 
|  | 367 | uint8_t u8MsgType, uint8_t u8Seg, | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 368 | uint8_t u8Bus, uint8_t u8Device, | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 369 | uint8_t u8Fcn, uint16_t u16Reg, | 
|  | 370 | uint8_t DataLen, uint32_t DataVal, | 
|  | 371 | int peci_fd, uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 372 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 373 | // Provides write access to the EP PCI MMIO space | 
|  | 374 | EPECIStatus peci_WrEndPointConfigMmio(uint8_t target, uint8_t u8Seg, | 
|  | 375 | uint8_t u8Bus, uint8_t u8Device, | 
|  | 376 | uint8_t u8Fcn, uint8_t u8Bar, | 
|  | 377 | uint8_t u8AddrType, uint64_t u64Offset, | 
|  | 378 | uint8_t u8DataLen, uint64_t u64DataVal, | 
|  | 379 | uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 380 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 381 | // Provides write access to the EP PCI MMIO space in the specified domain | 
|  | 382 | EPECIStatus peci_WrEndPointConfigMmio_dom(uint8_t target, uint8_t domainId, | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 383 | uint8_t u8Seg, uint8_t u8Bus, | 
|  | 384 | uint8_t u8Device, uint8_t u8Fcn, | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 385 | uint8_t u8Bar, uint8_t u8AddrType, | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 386 | uint64_t u64Offset, uint8_t u8DataLen, | 
|  | 387 | uint64_t u64DataVal, uint8_t* cc); | 
|  | 388 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 389 | // Allows sequential write access to the EP PCI MMIO space | 
|  | 390 | EPECIStatus peci_WrEndPointConfigMmio_seq( | 
|  | 391 | uint8_t target, uint8_t u8Seg, uint8_t u8Bus, uint8_t u8Device, | 
|  | 392 | uint8_t u8Fcn, uint8_t u8Bar, uint8_t u8AddrType, uint64_t u64Offset, | 
|  | 393 | uint8_t u8DataLen, uint64_t u64DataVal, int peci_fd, uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 394 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 395 | // Allows sequential write access to the EP PCI MMIO space in the specified | 
|  | 396 | // domain | 
|  | 397 | EPECIStatus peci_WrEndPointConfigMmio_seq_dom( | 
|  | 398 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, | 
|  | 399 | uint8_t u8Device, uint8_t u8Fcn, uint8_t u8Bar, uint8_t u8AddrType, | 
|  | 400 | uint64_t u64Offset, uint8_t u8DataLen, uint64_t u64DataVal, int peci_fd, | 
|  | 401 | uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 402 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 403 | // Provides access to the Crashdump Discovery API | 
|  | 404 | EPECIStatus peci_CrashDump_Discovery(uint8_t target, uint8_t subopcode, | 
|  | 405 | uint8_t param0, uint16_t param1, | 
|  | 406 | uint8_t param2, uint8_t u8ReadLen, | 
|  | 407 | uint8_t* pData, uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 408 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 409 | // Provides access to the Crashdump Discovery API in the specified domain | 
|  | 410 | EPECIStatus peci_CrashDump_Discovery_dom(uint8_t target, uint8_t domainId, | 
|  | 411 | uint8_t subopcode, uint8_t param0, | 
|  | 412 | uint16_t param1, uint8_t param2, | 
|  | 413 | uint8_t u8ReadLen, uint8_t* pData, | 
|  | 414 | uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 415 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 416 | // Provides access to the Crashdump GetFrame API | 
|  | 417 | EPECIStatus peci_CrashDump_GetFrame(uint8_t target, uint16_t param0, | 
|  | 418 | uint16_t param1, uint16_t param2, | 
|  | 419 | uint8_t u8ReadLen, uint8_t* pData, | 
|  | 420 | uint8_t* cc); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 421 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 422 | // Provides access to the Crashdump GetFrame API in the specified domain | 
|  | 423 | EPECIStatus peci_CrashDump_GetFrame_dom(uint8_t target, uint8_t domainId, | 
|  | 424 | uint16_t param0, uint16_t param1, | 
|  | 425 | uint16_t param2, uint8_t u8ReadLen, | 
|  | 426 | uint8_t* pData, uint8_t* cc); | 
| Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 427 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 428 | // Provides raw PECI command access | 
|  | 429 | EPECIStatus peci_raw(uint8_t target, uint8_t u8ReadLen, const uint8_t* pRawCmd, | 
|  | 430 | const uint32_t cmdSize, uint8_t* pRawResp, | 
|  | 431 | uint32_t respSize); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 432 |  | 
| Zbigniew Kurzynski | f2a5fa2 | 2023-11-06 13:48:11 +0100 | [diff] [blame] | 433 | // Provides sequential raw PECI command access | 
|  | 434 | EPECIStatus peci_raw_seq(uint8_t target, uint8_t u8ReadLen, | 
|  | 435 | const uint8_t* pRawCmd, const uint32_t cmdSize, | 
|  | 436 | uint8_t* pRawResp, uint32_t respSize, int peci_fd); | 
|  | 437 |  | 
| Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 438 | EPECIStatus peci_Lock(int* peci_fd, int timeout_ms); | 
|  | 439 | void peci_Unlock(int peci_fd); | 
|  | 440 | EPECIStatus peci_Ping(uint8_t target); | 
|  | 441 | EPECIStatus peci_Ping_seq(uint8_t target, int peci_fd); | 
|  | 442 | EPECIStatus peci_GetCPUID(const uint8_t clientAddr, CPUModel* cpuModel, | 
|  | 443 | uint8_t* stepping, uint8_t* cc); | 
|  | 444 | void peci_SetDevName(char* peci_dev); | 
| Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 445 |  | 
|  | 446 | #ifdef __cplusplus | 
|  | 447 | } | 
|  | 448 | #endif |