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 | { |
Jason M. Bills | 127609c | 2024-04-01 12:57:08 -0700 | [diff] [blame] | 35 | skylake = 0x00050650, |
Jason M. Bills | 127609c | 2024-04-01 12:57:08 -0700 | [diff] [blame] | 36 | iceLake = 0x000606A0, |
Jason M. Bills | 127609c | 2024-04-01 12:57:08 -0700 | [diff] [blame] | 37 | iceLakeD = 0x000606C0, |
Jason M. Bills | 127609c | 2024-04-01 12:57:08 -0700 | [diff] [blame] | 38 | sapphireRapids = 0x000806F0, |
Jason M. Bills | 127609c | 2024-04-01 12:57:08 -0700 | [diff] [blame] | 39 | emeraldRapids = 0x000C06F0, |
Jason M. Bills | 127609c | 2024-04-01 12:57:08 -0700 | [diff] [blame] | 40 | graniteRapids = 0x000A06D0, |
Jason M. Bills | 127609c | 2024-04-01 12:57:08 -0700 | [diff] [blame] | 41 | graniteRapidsD = 0x000A06E0, |
Jason M. Bills | 127609c | 2024-04-01 12:57:08 -0700 | [diff] [blame] | 42 | sierraForest = 0x000A06F0, |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 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 | |
Manojkiran Eda | 5302b93 | 2024-06-17 11:03:46 +0530 | [diff] [blame] | 67 | // VCU Index and Sequence Parameters |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 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 |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 116 | EPECIStatus peci_RdPkgConfig_dom( |
| 117 | uint8_t target, uint8_t domainId, uint8_t u8Index, uint16_t u16Value, |
| 118 | uint8_t u8ReadLen, uint8_t* pPkgConfig, uint8_t* cc); |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 119 | |
| 120 | // Allows sequential RdPkgConfig with the provided peci file descriptor |
| 121 | EPECIStatus peci_RdPkgConfig_seq(uint8_t target, uint8_t u8Index, |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 122 | uint16_t u16Value, uint8_t u8ReadLen, |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 123 | uint8_t* pPkgConfig, int peci_fd, uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 124 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 125 | // Allows sequential RdPkgConfig with the provided peci file descriptor in |
| 126 | // the specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 127 | EPECIStatus peci_RdPkgConfig_seq_dom( |
| 128 | uint8_t target, uint8_t domainId, uint8_t u8Index, uint16_t u16Value, |
| 129 | uint8_t u8ReadLen, uint8_t* pPkgConfig, int peci_fd, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 130 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 131 | // Provides write access to the package configuration space within the |
| 132 | // processor |
| 133 | EPECIStatus peci_WrPkgConfig(uint8_t target, uint8_t u8Index, uint16_t u16Param, |
| 134 | uint32_t u32Value, uint8_t u8WriteLen, |
| 135 | uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 136 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 137 | // Provides write access to the package configuration space within the |
| 138 | // processor in the specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 139 | EPECIStatus peci_WrPkgConfig_dom( |
| 140 | uint8_t target, uint8_t domainId, uint8_t u8Index, uint16_t u16Param, |
| 141 | uint32_t u32Value, uint8_t u8WriteLen, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 142 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 143 | // Allows sequential WrPkgConfig with the provided peci file descriptor |
| 144 | EPECIStatus peci_WrPkgConfig_seq(uint8_t target, uint8_t u8Index, |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 145 | uint16_t u16Param, uint32_t u32Value, |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 146 | uint8_t u8WriteLen, int peci_fd, uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 147 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 148 | // Allows sequential WrPkgConfig with the provided peci file descriptor in |
| 149 | // the specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 150 | EPECIStatus peci_WrPkgConfig_seq_dom( |
| 151 | uint8_t target, uint8_t domainId, uint8_t u8Index, uint16_t u16Param, |
| 152 | uint32_t u32Value, uint8_t u8WriteLen, int peci_fd, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 153 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 154 | // Provides read access to Model Specific Registers |
| 155 | EPECIStatus peci_RdIAMSR(uint8_t target, uint8_t threadID, uint16_t MSRAddress, |
| 156 | uint64_t* u64MsrVal, uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 157 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 158 | // Provides read access to Model Specific Registers in the specified domain |
| 159 | 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] | 160 | uint16_t MSRAddress, uint64_t* u64MsrVal, |
| 161 | uint8_t* cc); |
| 162 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 163 | // Provides read access to PCI Configuration space |
| 164 | EPECIStatus peci_RdPCIConfig(uint8_t target, uint8_t u8Bus, uint8_t u8Device, |
| 165 | uint8_t u8Fcn, uint16_t u16Reg, uint8_t* pPCIReg, |
| 166 | uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 167 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 168 | // Provides read access to PCI Configuration space in the specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 169 | EPECIStatus peci_RdPCIConfig_dom( |
| 170 | uint8_t target, uint8_t domainId, uint8_t u8Bus, uint8_t u8Device, |
| 171 | uint8_t u8Fcn, uint16_t u16Reg, uint8_t* pPCIReg, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 172 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 173 | // Allows sequential RdPCIConfig with the provided peci file descriptor |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 174 | EPECIStatus peci_RdPCIConfig_seq( |
| 175 | uint8_t target, uint8_t u8Bus, uint8_t u8Device, uint8_t u8Fcn, |
| 176 | uint16_t u16Reg, uint8_t* pPCIData, int peci_fd, uint8_t* cc); |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 177 | |
| 178 | // Allows sequential RdPCIConfig with the provided peci file descriptor in |
| 179 | // the specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 180 | EPECIStatus |
| 181 | peci_RdPCIConfig_seq_dom(uint8_t target, uint8_t domainId, uint8_t u8Bus, |
| 182 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, |
| 183 | uint8_t* pPCIData, int peci_fd, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 184 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 185 | // Provides read access to the local PCI Configuration space |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 186 | EPECIStatus peci_RdPCIConfigLocal( |
| 187 | uint8_t target, uint8_t u8Bus, uint8_t u8Device, uint8_t u8Fcn, |
| 188 | uint16_t u16Reg, uint8_t u8ReadLen, uint8_t* pPCIReg, uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 189 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 190 | // Provides read access to the local PCI Configuration space in the |
| 191 | // specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 192 | EPECIStatus |
| 193 | peci_RdPCIConfigLocal_dom(uint8_t target, uint8_t domainId, uint8_t u8Bus, |
| 194 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, |
| 195 | uint8_t u8ReadLen, uint8_t* pPCIReg, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 196 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 197 | // Allows sequential RdPCIConfigLocal with the provided peci file descriptor |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 198 | EPECIStatus |
| 199 | peci_RdPCIConfigLocal_seq(uint8_t target, uint8_t u8Bus, uint8_t u8Device, |
| 200 | uint8_t u8Fcn, uint16_t u16Reg, uint8_t u8ReadLen, |
| 201 | uint8_t* pPCIReg, int peci_fd, uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 202 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 203 | // Allows sequential RdPCIConfigLocal with the provided peci file descriptor |
| 204 | // in the specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 205 | EPECIStatus peci_RdPCIConfigLocal_seq_dom( |
| 206 | uint8_t target, uint8_t domainId, uint8_t u8Bus, uint8_t u8Device, |
| 207 | uint8_t u8Fcn, uint16_t u16Reg, uint8_t u8ReadLen, uint8_t* pPCIReg, |
| 208 | int peci_fd, uint8_t* cc); |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 209 | |
| 210 | // Provides write access to the local PCI Configuration space |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 211 | EPECIStatus peci_WrPCIConfigLocal( |
| 212 | uint8_t target, uint8_t u8Bus, uint8_t u8Device, uint8_t u8Fcn, |
| 213 | uint16_t u16Reg, uint8_t DataLen, uint32_t DataVal, uint8_t* cc); |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 214 | |
| 215 | // Provides write access to the local PCI Configuration space in the |
| 216 | // specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 217 | EPECIStatus |
| 218 | peci_WrPCIConfigLocal_dom(uint8_t target, uint8_t domainId, uint8_t u8Bus, |
| 219 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, |
| 220 | uint8_t DataLen, uint32_t DataVal, uint8_t* cc); |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 221 | |
| 222 | // Provides read access to PCI configuration space |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 223 | EPECIStatus |
| 224 | peci_RdEndPointConfigPci(uint8_t target, uint8_t u8Seg, uint8_t u8Bus, |
| 225 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, |
| 226 | uint8_t u8ReadLen, uint8_t* pPCIData, uint8_t* cc); |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 227 | |
| 228 | // Provides read access to PCI configuration space in the specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 229 | EPECIStatus peci_RdEndPointConfigPci_dom( |
| 230 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, |
| 231 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, uint8_t u8ReadLen, |
| 232 | uint8_t* pPCIData, uint8_t* cc); |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 233 | |
| 234 | // Allows sequential RdEndPointConfig to PCI Configuration space |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 235 | EPECIStatus peci_RdEndPointConfigPci_seq( |
| 236 | uint8_t target, uint8_t u8Seg, uint8_t u8Bus, uint8_t u8Device, |
| 237 | uint8_t u8Fcn, uint16_t u16Reg, uint8_t u8ReadLen, uint8_t* pPCIData, |
| 238 | int peci_fd, uint8_t* cc); |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 239 | |
| 240 | // Allows sequential RdEndPointConfig to PCI Configuration space in the |
| 241 | // specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 242 | EPECIStatus peci_RdEndPointConfigPci_seq_dom( |
| 243 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, |
| 244 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, uint8_t u8ReadLen, |
| 245 | uint8_t* pPCIData, int peci_fd, uint8_t* cc); |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 246 | |
| 247 | // Provides read access to the local PCI configuration space |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 248 | EPECIStatus peci_RdEndPointConfigPciLocal( |
| 249 | uint8_t target, uint8_t u8Seg, uint8_t u8Bus, uint8_t u8Device, |
| 250 | uint8_t u8Fcn, uint16_t u16Reg, uint8_t u8ReadLen, uint8_t* pPCIData, |
| 251 | uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 252 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 253 | // Provides read access to the local PCI configuration space in the |
| 254 | // specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 255 | EPECIStatus peci_RdEndPointConfigPciLocal_dom( |
| 256 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, |
| 257 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, uint8_t u8ReadLen, |
| 258 | uint8_t* pPCIData, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 259 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 260 | // Allows sequential RdEndPointConfig to the local PCI Configuration space |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 261 | EPECIStatus peci_RdEndPointConfigPciLocal_seq( |
| 262 | uint8_t target, uint8_t u8Seg, uint8_t u8Bus, uint8_t u8Device, |
| 263 | uint8_t u8Fcn, uint16_t u16Reg, uint8_t u8ReadLen, uint8_t* pPCIData, |
| 264 | int peci_fd, uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 265 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 266 | // Allows sequential RdEndPointConfig to the local PCI Configuration space |
| 267 | // in the specified domain |
| 268 | EPECIStatus peci_RdEndPointConfigPciLocal_seq_dom( |
| 269 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, |
| 270 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, uint8_t u8ReadLen, |
| 271 | uint8_t* pPCIData, int peci_fd, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 272 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 273 | // Provides read access to PCI MMIO space |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 274 | EPECIStatus peci_RdEndPointConfigMmio( |
| 275 | uint8_t target, uint8_t u8Seg, uint8_t u8Bus, uint8_t u8Device, |
| 276 | uint8_t u8Fcn, uint8_t u8Bar, uint8_t u8AddrType, uint64_t u64Offset, |
| 277 | uint8_t u8ReadLen, uint8_t* pMmioData, uint8_t* cc); |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 278 | |
| 279 | // Provides read access to PCI MMIO space in the specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 280 | EPECIStatus peci_RdEndPointConfigMmio_dom( |
| 281 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, |
| 282 | uint8_t u8Device, uint8_t u8Fcn, uint8_t u8Bar, uint8_t u8AddrType, |
| 283 | uint64_t u64Offset, uint8_t u8ReadLen, uint8_t* pMmioData, uint8_t* cc); |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 284 | |
| 285 | // Allows sequential RdEndPointConfig to PCI MMIO space |
| 286 | EPECIStatus peci_RdEndPointConfigMmio_seq( |
| 287 | uint8_t target, uint8_t u8Seg, uint8_t u8Bus, uint8_t u8Device, |
| 288 | uint8_t u8Fcn, uint8_t u8Bar, uint8_t u8AddrType, uint64_t u64Offset, |
| 289 | uint8_t u8ReadLen, uint8_t* pMmioData, int peci_fd, uint8_t* cc); |
| 290 | |
| 291 | // Allows sequential RdEndPointConfig to PCI MMIO space in the specified |
| 292 | // domain |
| 293 | EPECIStatus peci_RdEndPointConfigMmio_seq_dom( |
| 294 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, |
| 295 | uint8_t u8Device, uint8_t u8Fcn, uint8_t u8Bar, uint8_t u8AddrType, |
| 296 | uint64_t u64Offset, uint8_t u8ReadLen, uint8_t* pMmioData, int peci_fd, |
| 297 | uint8_t* cc); |
| 298 | |
| 299 | // Provides write access to the EP local PCI Configuration space |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 300 | EPECIStatus peci_WrEndPointPCIConfigLocal( |
| 301 | uint8_t target, uint8_t u8Seg, uint8_t u8Bus, uint8_t u8Device, |
| 302 | uint8_t u8Fcn, uint16_t u16Reg, uint8_t DataLen, uint32_t DataVal, |
| 303 | uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 304 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 305 | // Provides write access to the EP local PCI Configuration space in the |
| 306 | // specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 307 | EPECIStatus peci_WrEndPointPCIConfigLocal_dom( |
| 308 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, |
| 309 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, uint8_t DataLen, |
| 310 | uint32_t DataVal, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 311 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 312 | // Provides write access to the EP PCI Configuration space |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 313 | EPECIStatus |
| 314 | peci_WrEndPointPCIConfig(uint8_t target, uint8_t u8Seg, uint8_t u8Bus, |
| 315 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, |
| 316 | uint8_t DataLen, uint32_t DataVal, uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 317 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 318 | // Provides write access to the EP PCI Configuration space in the specified |
| 319 | // domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 320 | EPECIStatus peci_WrEndPointPCIConfig_dom( |
| 321 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, |
| 322 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, uint8_t DataLen, |
| 323 | uint32_t DataVal, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 324 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 325 | // Allows sequential write access to the EP PCI Configuration space |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 326 | EPECIStatus peci_WrEndPointConfig_seq( |
| 327 | uint8_t target, uint8_t u8MsgType, uint8_t u8Seg, uint8_t u8Bus, |
| 328 | uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, uint8_t DataLen, |
| 329 | uint32_t DataVal, int peci_fd, uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 330 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 331 | // Allows sequential write access to the EP PCI Configuration space in the |
| 332 | // specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 333 | EPECIStatus peci_WrEndPointConfig_seq_dom( |
| 334 | uint8_t target, uint8_t domainId, uint8_t u8MsgType, uint8_t u8Seg, |
| 335 | uint8_t u8Bus, uint8_t u8Device, uint8_t u8Fcn, uint16_t u16Reg, |
| 336 | uint8_t DataLen, uint32_t DataVal, int peci_fd, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 337 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 338 | // Provides write access to the EP PCI MMIO space |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 339 | EPECIStatus peci_WrEndPointConfigMmio( |
| 340 | uint8_t target, uint8_t u8Seg, uint8_t u8Bus, uint8_t u8Device, |
| 341 | uint8_t u8Fcn, uint8_t u8Bar, uint8_t u8AddrType, uint64_t u64Offset, |
| 342 | uint8_t u8DataLen, uint64_t u64DataVal, uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 343 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 344 | // Provides write access to the EP PCI MMIO space in the specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 345 | EPECIStatus peci_WrEndPointConfigMmio_dom( |
| 346 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, |
| 347 | uint8_t u8Device, uint8_t u8Fcn, uint8_t u8Bar, uint8_t u8AddrType, |
| 348 | uint64_t u64Offset, uint8_t u8DataLen, uint64_t u64DataVal, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 349 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 350 | // Allows sequential write access to the EP PCI MMIO space |
| 351 | EPECIStatus peci_WrEndPointConfigMmio_seq( |
| 352 | uint8_t target, uint8_t u8Seg, uint8_t u8Bus, uint8_t u8Device, |
| 353 | uint8_t u8Fcn, uint8_t u8Bar, uint8_t u8AddrType, uint64_t u64Offset, |
| 354 | 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] | 355 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 356 | // Allows sequential write access to the EP PCI MMIO space in the specified |
| 357 | // domain |
| 358 | EPECIStatus peci_WrEndPointConfigMmio_seq_dom( |
| 359 | uint8_t target, uint8_t domainId, uint8_t u8Seg, uint8_t u8Bus, |
| 360 | uint8_t u8Device, uint8_t u8Fcn, uint8_t u8Bar, uint8_t u8AddrType, |
| 361 | uint64_t u64Offset, uint8_t u8DataLen, uint64_t u64DataVal, int peci_fd, |
| 362 | uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 363 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 364 | // Provides access to the Crashdump Discovery API |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 365 | EPECIStatus peci_CrashDump_Discovery( |
| 366 | uint8_t target, uint8_t subopcode, uint8_t param0, uint16_t param1, |
| 367 | uint8_t param2, uint8_t u8ReadLen, uint8_t* pData, uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 368 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 369 | // Provides access to the Crashdump Discovery API in the specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 370 | EPECIStatus peci_CrashDump_Discovery_dom( |
| 371 | uint8_t target, uint8_t domainId, uint8_t subopcode, uint8_t param0, |
| 372 | uint16_t param1, uint8_t param2, uint8_t u8ReadLen, uint8_t* pData, |
| 373 | uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 374 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 375 | // Provides access to the Crashdump GetFrame API |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 376 | EPECIStatus peci_CrashDump_GetFrame( |
| 377 | uint8_t target, uint16_t param0, uint16_t param1, uint16_t param2, |
| 378 | uint8_t u8ReadLen, uint8_t* pData, uint8_t* cc); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 379 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 380 | // Provides access to the Crashdump GetFrame API in the specified domain |
Patrick Williams | c96261e | 2024-08-16 15:22:05 -0400 | [diff] [blame] | 381 | EPECIStatus peci_CrashDump_GetFrame_dom( |
| 382 | uint8_t target, uint8_t domainId, uint16_t param0, uint16_t param1, |
| 383 | uint16_t param2, uint8_t u8ReadLen, uint8_t* pData, uint8_t* cc); |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 384 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 385 | // Provides raw PECI command access |
| 386 | EPECIStatus peci_raw(uint8_t target, uint8_t u8ReadLen, const uint8_t* pRawCmd, |
| 387 | const uint32_t cmdSize, uint8_t* pRawResp, |
| 388 | uint32_t respSize); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 389 | |
Zbigniew Kurzynski | f2a5fa2 | 2023-11-06 13:48:11 +0100 | [diff] [blame] | 390 | // Provides sequential raw PECI command access |
| 391 | EPECIStatus peci_raw_seq(uint8_t target, uint8_t u8ReadLen, |
| 392 | const uint8_t* pRawCmd, const uint32_t cmdSize, |
| 393 | uint8_t* pRawResp, uint32_t respSize, int peci_fd); |
| 394 | |
Patrick Williams | 0621dc0 | 2023-10-20 11:19:59 -0500 | [diff] [blame] | 395 | EPECIStatus peci_Lock(int* peci_fd, int timeout_ms); |
| 396 | void peci_Unlock(int peci_fd); |
| 397 | EPECIStatus peci_Ping(uint8_t target); |
| 398 | EPECIStatus peci_Ping_seq(uint8_t target, int peci_fd); |
| 399 | EPECIStatus peci_GetCPUID(const uint8_t clientAddr, CPUModel* cpuModel, |
| 400 | uint8_t* stepping, uint8_t* cc); |
| 401 | void peci_SetDevName(char* peci_dev); |
Jason M. Bills | 7ef5a55 | 2020-04-06 14:58:44 -0700 | [diff] [blame] | 402 | |
| 403 | #ifdef __cplusplus |
| 404 | } |
| 405 | #endif |