1 /* 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright © 2022 Keith Packard 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 * 18 * 3. Neither the name of the copyright holder nor the names of its 19 * contributors may be used to endorse or promote products derived 20 * from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 * OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 #pragma once 37 38 #include <stddef.h> 39 #include <stdint.h> 40 #include <sys/cdefs.h> 41 #include <stdio.h> 42 43 extern void *__opal_base, *__opal_entry; 44 45 int 46 opal_call(void *r3, void *r4, void *r5, int call_r6, void *base_r7, void *entry_r8); 47 48 int 49 opal_console_write(int terminal, size_t len, const char *base); 50 51 void _ATTRIBUTE((__noreturn__)) 52 opal_cec_power_down(uint64_t request); 53 54 #define OPAL_TERMINAL_DEFAULT 0 55 56 /* status codes */ 57 #define OPAL_SUCCESS 0 58 #define OPAL_PARAMETER -1 59 #define OPAL_BUSY -2 60 #define OPAL_PARTIAL -3 61 #define OPAL_CONSTRAINED -4 62 #define OPAL_CLOSED -5 63 #define OPAL_HARDWARE -6 64 #define OPAL_UNSUPPORTED -7 65 #define OPAL_PERMISSION -8 66 #define OPAL_NO_MEM -9 67 #define OPAL_RESOURCE -10 68 #define OPAL_INTERNAL_ERROR -11 69 #define OPAL_BUSY_EVENT -12 70 #define OPAL_HARDWARE_FROZEN -13 71 #define OPAL_WRONG_STATE -14 72 #define OPAL_ASYNC_COMPLETION -15 73 #define OPAL_EMPTY -16 74 #define OPAL_I2C_TIMEOUT -17 75 #define OPAL_I2C_INVALID_CMD -18 76 #define OPAL_I2C_LBUS_PARITY -19 77 #define OPAL_I2C_BKEND_OVERRUN -20 78 #define OPAL_I2C_BKEND_ACCESS -21 79 #define OPAL_I2C_ARBT_LOST -22 80 #define OPAL_I2C_NACK_RCVD -23 81 #define OPAL_I2C_STOP_ERR -24 82 #define OPAL_XSCOM_BUSY OPAL_BUSY 83 #define OPAL_XSCOM_CHIPLET_OFF OPAL_WRONG_STATE 84 #define OPAL_XSCOM_PARTIAL_GOOD -25 85 #define OPAL_XSCOM_ADDR_ERROR -26 86 #define OPAL_XSCOM_CLOCK_ERROR -27 87 #define OPAL_XSCOM_PARITY_ERROR -28 88 #define OPAL_XSCOM_TIMEOUT -29 89 #define OPAL_XSCOM_CTR_OFFLINED -30 90 #define OPAL_XIVE_PROVISIONING -31 91 #define OPAL_XIVE_FREE_ACTIVE -32 92 #define OPAL_TIMEOUT -33 93 94 /* API Tokens (in r0) */ 95 #define OPAL_INVALID_CALL -1 96 #define OPAL_TEST 0 97 #define OPAL_CONSOLE_WRITE 1 98 #define OPAL_CONSOLE_READ 2 99 #define OPAL_RTC_READ 3 100 #define OPAL_RTC_WRITE 4 101 #define OPAL_CEC_POWER_DOWN 5 102 #define OPAL_CEC_REBOOT 6 103 #define OPAL_READ_NVRAM 7 104 #define OPAL_WRITE_NVRAM 8 105 #define OPAL_HANDLE_INTERRUPT 9 106 #define OPAL_POLL_EVENTS 10 107 #define OPAL_PCI_SET_HUB_TCE_MEMORY 11 /* Removed, p5ioc only */ 108 #define OPAL_PCI_SET_PHB_TCE_MEMORY 12 /* Removed, p5ioc only */ 109 #define OPAL_PCI_CONFIG_READ_BYTE 13 110 #define OPAL_PCI_CONFIG_READ_HALF_WORD 14 111 #define OPAL_PCI_CONFIG_READ_WORD 15 112 #define OPAL_PCI_CONFIG_WRITE_BYTE 16 113 #define OPAL_PCI_CONFIG_WRITE_HALF_WORD 17 114 #define OPAL_PCI_CONFIG_WRITE_WORD 18 115 #define OPAL_SET_XIVE 19 116 #define OPAL_GET_XIVE 20 117 #define OPAL_GET_COMPLETION_TOKEN_STATUS 21 /* obsolete */ 118 #define OPAL_REGISTER_OPAL_EXCEPTION_HANDLER 22 119 #define OPAL_PCI_EEH_FREEZE_STATUS 23 120 #define OPAL_PCI_SHPC 24 121 #define OPAL_CONSOLE_WRITE_BUFFER_SPACE 25 122 #define OPAL_PCI_EEH_FREEZE_CLEAR 26 123 #define OPAL_PCI_PHB_MMIO_ENABLE 27 124 #define OPAL_PCI_SET_PHB_MEM_WINDOW 28 125 #define OPAL_PCI_MAP_PE_MMIO_WINDOW 29 126 #define OPAL_PCI_SET_PHB_TABLE_MEMORY 30 /* never implemented */ 127 #define OPAL_PCI_SET_PE 31 128 #define OPAL_PCI_SET_PELTV 32 129 #define OPAL_PCI_SET_MVE 33 130 #define OPAL_PCI_SET_MVE_ENABLE 34 131 #define OPAL_PCI_GET_XIVE_REISSUE 35 /* never implemented */ 132 #define OPAL_PCI_SET_XIVE_REISSUE 36 /* never implemented */ 133 #define OPAL_PCI_SET_XIVE_PE 37 134 #define OPAL_GET_XIVE_SOURCE 38 135 #define OPAL_GET_MSI_32 39 136 #define OPAL_GET_MSI_64 40 137 #define OPAL_START_CPU 41 138 #define OPAL_QUERY_CPU_STATUS 42 139 #define OPAL_WRITE_OPPANEL 43 /* unimplemented */ 140 #define OPAL_PCI_MAP_PE_DMA_WINDOW 44 141 #define OPAL_PCI_MAP_PE_DMA_WINDOW_REAL 45 142 /* 46 is unused */ 143 /* 47 is unused */ 144 /* 48 is unused */ 145 #define OPAL_PCI_RESET 49 146 #define OPAL_PCI_GET_HUB_DIAG_DATA 50 147 #define OPAL_PCI_GET_PHB_DIAG_DATA 51 148 #define OPAL_PCI_FENCE_PHB 52 149 #define OPAL_PCI_REINIT 53 150 #define OPAL_PCI_MASK_PE_ERROR 54 151 #define OPAL_SET_SLOT_LED_STATUS 55 152 #define OPAL_GET_EPOW_STATUS 56 153 #define OPAL_SET_SYSTEM_ATTENTION_LED 57 154 #define OPAL_RESERVED1 58 155 #define OPAL_RESERVED2 59 156 #define OPAL_PCI_NEXT_ERROR 60 157 #define OPAL_PCI_EEH_FREEZE_STATUS2 61 158 #define OPAL_PCI_POLL 62 159 #define OPAL_PCI_MSI_EOI 63 160 #define OPAL_PCI_GET_PHB_DIAG_DATA2 64 161 #define OPAL_XSCOM_READ 65 162 #define OPAL_XSCOM_WRITE 66 163 #define OPAL_LPC_READ 67 164 #define OPAL_LPC_WRITE 68 165 #define OPAL_RETURN_CPU 69 166 #define OPAL_REINIT_CPUS 70 167 #define OPAL_ELOG_READ 71 168 #define OPAL_ELOG_WRITE 72 169 #define OPAL_ELOG_ACK 73 170 #define OPAL_ELOG_RESEND 74 171 #define OPAL_ELOG_SIZE 75 172 #define OPAL_FLASH_VALIDATE 76 173 #define OPAL_FLASH_MANAGE 77 174 #define OPAL_FLASH_UPDATE 78 175 #define OPAL_RESYNC_TIMEBASE 79 176 #define OPAL_CHECK_TOKEN 80 177 #define OPAL_DUMP_INIT 81 178 #define OPAL_DUMP_INFO 82 179 #define OPAL_DUMP_READ 83 180 #define OPAL_DUMP_ACK 84 181 #define OPAL_GET_MSG 85 182 #define OPAL_CHECK_ASYNC_COMPLETION 86 183 #define OPAL_SYNC_HOST_REBOOT 87 184 #define OPAL_SENSOR_READ 88 185 #define OPAL_GET_PARAM 89 186 #define OPAL_SET_PARAM 90 187 #define OPAL_DUMP_RESEND 91 188 #define OPAL_ELOG_SEND 92 /* Deprecated */ 189 #define OPAL_PCI_SET_PHB_CAPI_MODE 93 190 #define OPAL_DUMP_INFO2 94 191 #define OPAL_WRITE_OPPANEL_ASYNC 95 192 #define OPAL_PCI_ERR_INJECT 96 193 #define OPAL_PCI_EEH_FREEZE_SET 97 194 #define OPAL_HANDLE_HMI 98 195 #define OPAL_CONFIG_CPU_IDLE_STATE 99 196 #define OPAL_SLW_SET_REG 100 197 #define OPAL_REGISTER_DUMP_REGION 101 198 #define OPAL_UNREGISTER_DUMP_REGION 102 199 #define OPAL_WRITE_TPO 103 200 #define OPAL_READ_TPO 104 201 #define OPAL_GET_DPO_STATUS 105 202 #define OPAL_OLD_I2C_REQUEST 106 /* Deprecated */ 203 #define OPAL_IPMI_SEND 107 204 #define OPAL_IPMI_RECV 108 205 #define OPAL_I2C_REQUEST 109 206 #define OPAL_FLASH_READ 110 207 #define OPAL_FLASH_WRITE 111 208 #define OPAL_FLASH_ERASE 112 209 #define OPAL_PRD_MSG 113 210 #define OPAL_LEDS_GET_INDICATOR 114 211 #define OPAL_LEDS_SET_INDICATOR 115 212 #define OPAL_CEC_REBOOT2 116 213 #define OPAL_CONSOLE_FLUSH 117 214 #define OPAL_GET_DEVICE_TREE 118 215 #define OPAL_PCI_GET_PRESENCE_STATE 119 216 #define OPAL_PCI_GET_POWER_STATE 120 217 #define OPAL_PCI_SET_POWER_STATE 121 218 #define OPAL_INT_GET_XIRR 122 219 #define OPAL_INT_SET_CPPR 123 220 #define OPAL_INT_EOI 124 221 #define OPAL_INT_SET_MFRR 125 222 #define OPAL_PCI_TCE_KILL 126 223 #define OPAL_NMMU_SET_PTCR 127 224 #define OPAL_XIVE_RESET 128 225 #define OPAL_XIVE_GET_IRQ_INFO 129 226 #define OPAL_XIVE_GET_IRQ_CONFIG 130 227 #define OPAL_XIVE_SET_IRQ_CONFIG 131 228 #define OPAL_XIVE_GET_QUEUE_INFO 132 229 #define OPAL_XIVE_SET_QUEUE_INFO 133 230 #define OPAL_XIVE_DONATE_PAGE 134 231 #define OPAL_XIVE_ALLOCATE_VP_BLOCK 135 232 #define OPAL_XIVE_FREE_VP_BLOCK 136 233 #define OPAL_XIVE_GET_VP_INFO 137 234 #define OPAL_XIVE_SET_VP_INFO 138 235 #define OPAL_XIVE_ALLOCATE_IRQ 139 236 #define OPAL_XIVE_FREE_IRQ 140 237 #define OPAL_XIVE_SYNC 141 238 #define OPAL_XIVE_DUMP 142 239 #define OPAL_XIVE_GET_QUEUE_STATE 143 /* Get END state */ 240 #define OPAL_XIVE_SET_QUEUE_STATE 144 /* Set END state */ 241 #define OPAL_SIGNAL_SYSTEM_RESET 145 242 #define OPAL_NPU_INIT_CONTEXT 146 243 #define OPAL_NPU_DESTROY_CONTEXT 147 244 #define OPAL_NPU_MAP_LPAR 148 245 #define OPAL_IMC_COUNTERS_INIT 149 246 #define OPAL_IMC_COUNTERS_START 150 247 #define OPAL_IMC_COUNTERS_STOP 151 248 #define OPAL_GET_POWERCAP 152 249 #define OPAL_SET_POWERCAP 153 250 #define OPAL_GET_POWER_SHIFT_RATIO 154 251 #define OPAL_SET_POWER_SHIFT_RATIO 155 252 #define OPAL_SENSOR_GROUP_CLEAR 156 253 #define OPAL_PCI_SET_P2P 157 254 #define OPAL_QUIESCE 158 255 #define OPAL_NPU_SPA_SETUP 159 256 #define OPAL_NPU_SPA_CLEAR_CACHE 160 257 #define OPAL_NPU_TL_SET 161 258 #define OPAL_SENSOR_READ_U64 162 259 #define OPAL_SENSOR_GROUP_ENABLE 163 260 #define OPAL_PCI_GET_PBCQ_TUNNEL_BAR 164 261 #define OPAL_PCI_SET_PBCQ_TUNNEL_BAR 165 262 #define OPAL_HANDLE_HMI2 166 263 #define OPAL_NX_COPROC_INIT 167 264 #define OPAL_NPU_SET_RELAXED_ORDER 168 265 #define OPAL_NPU_GET_RELAXED_ORDER 169 266 #define OPAL_XIVE_GET_VP_STATE 170 /* Get NVT state */ 267 #define OPAL_NPU_MEM_ALLOC 171 268 #define OPAL_NPU_MEM_RELEASE 172 269 #define OPAL_MPIPL_UPDATE 173 270 #define OPAL_MPIPL_REGISTER_TAG 174 271 #define OPAL_MPIPL_QUERY_TAG 175 272 #define OPAL_SECVAR_GET 176 273 #define OPAL_SECVAR_GET_NEXT 177 274 #define OPAL_SECVAR_ENQUEUE_UPDATE 178 275 #define OPAL_PHB_SET_OPTION 179 276 #define OPAL_PHB_GET_OPTION 180 277 #define OPAL_LAST 180 278 279