/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (C) 2010 Andreas Tobler4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR16* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES17* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.18* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,19* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,20* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;21* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,22* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR23* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF24* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.25*/2627#ifndef _PSERIES_PHYP_HVCALL_H_28#define _PSERIES_PHYP_HVCALL_H_2930/* Information taken from: Power.org PAPR, Version 2.4 (December 7, 2009). */3132#include <sys/types.h>3334/* Return codes. */3536#define H_SUCCESS 037#define H_BUSY 1 /* Hardware Busy -- Retry Later. */38#define H_CLOSED 2 /* Virtual I/O connection is closed. */39#define H_NOT_AVAILABLE 340#define H_CONSTRAINED 4 /* The request called for resources in excess of41the maximum allowed. The resultant allocation42was constrained to maximum allowed. */43#define H_PARTIAL 5 /* The request completed only partially successful.44Parameters were valid but some specific hcall45function condition prevented fully completing the46architected function, see the specific hcall47definition for possible reasons. */48#define H_IN_PROGRESS 1449#define H_PAGE_REGISTERED 1550#define H_PARTIAL_STORE 1651#define H_PENDING 1752#define H_CONTINUE 185354#define H_LONG_BUSY_ORDER_1_MS 9900 /* This return code is identical to55H_BUSY, but with the added bonus of a56hint to the partition OS. If the57partition OS can delay for 158millisecond, the hcall will likely59succeed on a new hcall with no further60busy return codes. If the partition OS61cannot handle a delay, they are62certainly free to immediately turn63around and try again. */64#define H_LONG_BUSY_ORDER_10_MS 9901 /* Similar to H_LONG_BUSY_ORDER_1_MS, but65the hint is 10mSec wait this time. */6667#define H_LONG_BUSY_ORDER_100_MS 9902 /* Similar to H_LONG_BUSY_ORDER_1_MS, but68the hint is 100mSec wait this time. */6970#define H_LONG_BUSY_ORDER_1_S 9903 /* Similar to H_LONG_BUSY_ORDER_1_MS, but71the hint is 1Sec wait this time. */72#define H_LONG_BUSY_ORDER_10_S 9904 /* Similar to H_LONG_BUSY_ORDER_1_MS, but73the hint is 10Sec wait this time. */74#define H_LONG_BUSY_ORDER_100_S 9905 /* Similar to H_LONG_BUSY_ORDER_1_MS, but75the hint is 100Sec wait this time. */7677#define H_HARDWARE -1 /* Error. */78#define H_FUNCTION -2 /* Not supported. */79#define H_PRIVILEGE -3 /* Caller not in privileged mode. */80#define H_PARAMETER -4 /* Outside valid range for partition or conflicting. */81#define H_BAD_MODE -5 /* Illegal MSR value. */82#define H_PTEG_FULL -6 /* The requested pteg was full. */83#define H_NOT_FOUND -7 /* The requested entitiy was not found. */84#define H_RESERVED_DABR -8 /* The requested address is reserved by the85hypervisor on this processor. */86#define H_NOMEM -987#define H_AUTHORITY -10 /* The caller did not have authority to perform the88function. */89#define H_PERMISSION -11 /* The mapping specified by the request does not90allow for the requested transfer. */91#define H_DROPPED -12 /* One or more packets could not be delivered to92their requested destinations. */93#define H_S_PARM -13 /* The source parameter is illegal. */94#define H_D_PARM -14 /* The destination parameter is illegal. */95#define H_R_PARM -15 /* The remote TCE mapping is illegal. */96#define H_RESOURCE -16 /* One or more required resources are in use. */97#define H_ADAPTER_PARM -17 /* Invalid adapter. */98#define H_RH_PARM -18 /* Resource not valid or logical partition99conflicting. */100#define H_RCQ_PARM -19 /* RCQ not valid or logical partition conflicting. */101#define H_SCQ_PARM -20 /* SCQ not valid or logical partition conflicting. */102#define H_EQ_PARM -21 /* EQ not valid or logical partition conflicting. */103#define H_RT_PARM -22 /* Invalid resource type. */104#define H_ST_PARM -23 /* Invalid service type. */105#define H_SIGT_PARM -24 /* Invalid signalling type. */106#define H_TOKEN_PARM -25 /* Invalid token. */107#define H_MLENGTH_PARM -27 /* Invalid memory length. */108#define H_MEM_PARM -28 /* Invalid memory I/O virtual address. */109#define H_MEM_ACCESS_PARM -29 /* Invalid memory access control. */110#define H_ATTR_PARM -30 /* Invalid attribute value. */111#define H_PORT_PARM -31 /* Invalid port number. */112#define H_MCG_PARM -32 /* Invalid multicast group. */113#define H_VL_PARM -33 /* Invalid virtual lane. */114#define H_TSIZE_PARM -34 /* Invalid trace size. */115#define H_TRACE_PARM -35 /* Invalid trace buffer. */116#define H_MASK_PARM -37 /* Invalid mask value. */117#define H_MCG_FULL -38 /* Multicast attachments exceeded. */118#define H_ALIAS_EXIST -39 /* Alias QP already defined. */119#define H_P_COUNTER -40 /* Invalid counter specification. */120#define H_TABLE_FULL -41 /* Resource page table full. */121#define H_ALT_TABLE -42 /* Alternate table already exists / alternate page122table not available. */123#define H_MR_CONDITION -43 /* Invalid memory region condition. */124#define H_NOT_ENOUGH_RESOURCES -44 /* Insufficient resources. */125#define H_R_STATE -45 /* Invalid resource state condition or sequencing126error. */127#define H_RESCINDED -46128#define H_ABORTED -54129#define H_P2 -55130#define H_P3 -56131#define H_P4 -57132#define H_P5 -58133#define H_P6 -59134#define H_P7 -60135#define H_P8 -61136#define H_P9 -62137#define H_NOOP -63138#define H_TOO_BIG -64139140#define H_UNSUPPORTED -67 /* Parameter value outside of the range supported141by this implementation. */142143/* Flags. */144/* Table 168. Page Frame Table Access flags field definition. */145#define H_EXACT (1UL<<(63-24))146#define H_R_XLATE (1UL<<(63-25))147#define H_READ_4 (1UL<<(63-26))148149/* Table 178. CMO Page Usage State flags Definition. */150#define H_PAGE_STATE_CHANGE (1UL<<(63-28))151#define H_PAGE_UNUSED ((1UL<<(63-29)) | (1UL<<(63-30)))152#define H_PAGE_SET_UNUSED (H_PAGE_STATE_CHANGE | H_PAGE_UNUSED)153#define H_PAGE_SET_LOANED (H_PAGE_SET_UNUSED | (1UL<<(63-31)))154#define H_PAGE_SET_ACTIVE H_PAGE_STATE_CHANGE155156/* Table 168. Page Frame Table Access flags field definition. */157#define H_AVPN (1UL<<(63-32))158#define H_ANDCOND (1UL<<(63-33))159160#define H_ICACHE_INVALIDATE (1UL<<(63-40))161#define H_ICACHE_SYNCHRONIZE (1UL<<(63-41))162163#define H_ZERO_PAGE (1UL<<(63-48))164#define H_COPY_PAGE (1UL<<(63-49))165166#define H_N (1UL<<(63-61))167#define H_PP1 (1UL<<(63-62))168#define H_PP2 (1UL<<(63-63))169170/* H_SET_MODE resource identifiers from 14.5.4.3.5. */171#define H_SET_MODE_RSRC_CIABR 0x1 /* All versions */172#define H_SET_MODE_RSRC_DAWR0 0x2 /* All versions */173#define H_SET_MODE_RSRC_INTR_TRANS_MODE 0x3 /* All versions */174#define H_SET_MODE_RSRC_ILE 0x4 /* PAPR 2.8 / ISA 2.07 */175#define H_SET_MODE_RSRC_DAWR1 0x5 /* ISA 3.1 Future support */176177/* H_REGISTER_PROC_TBL identifiers. */178#define PROC_TABLE_OP_MASK 0x18179#define PROC_TABLE_DEREG 0x10180#define PROC_TABLE_NEW 0x18181#define PROC_TABLE_TYPE_MASK 0x06182#define PROC_TABLE_HPT_SLB 0x00183#define PROC_TABLE_GTSE 0x01184#define PROC_TABLE_HPT_PT 0x02185#define PROC_TABLE_RADIX 0x04186187/* pSeries hypervisor opcodes. */188#define H_REMOVE 0x04189#define H_ENTER 0x08190#define H_READ 0x0c191#define H_CLEAR_MOD 0x10192#define H_CLEAR_REF 0x14193#define H_PROTECT 0x18194#define H_GET_TCE 0x1c195#define H_PUT_TCE 0x20196#define H_SET_SPRG0 0x24197#define H_SET_DABR 0x28198#define H_PAGE_INIT 0x2c199#define H_SET_ASR 0x30200#define H_ASR_ON 0x34201#define H_ASR_OFF 0x38202#define H_LOGICAL_CI_LOAD 0x3c203#define H_LOGICAL_CI_STORE 0x40204#define H_LOGICAL_CACHE_LOAD 0x44205#define H_LOGICAL_CACHE_STORE 0x48206#define H_LOGICAL_ICBI 0x4c207#define H_LOGICAL_DCBF 0x50208#define H_GET_TERM_CHAR 0x54209#define H_PUT_TERM_CHAR 0x58210#define H_REAL_TO_LOGICAL 0x5c211#define H_HYPERVISOR_DATA 0x60212#define H_EOI 0x64213#define H_CPPR 0x68214#define H_IPI 0x6c215#define H_IPOLL 0x70216#define H_XIRR 0x74217#define H_MIGRATE_DMA 0x78218#define H_PERFMON 0x7c219#define H_REGISTER_VPA 0xdc220#define H_CEDE 0xe0221#define H_CONFER 0xe4222#define H_PROD 0xe8223#define H_GET_PPP 0xec224#define H_SET_PPP 0xf0225#define H_PURR 0xf4226#define H_PIC 0xf8227#define H_REG_CRQ 0xfc228#define H_FREE_CRQ 0x100229#define H_VIO_SIGNAL 0x104230#define H_SEND_CRQ 0x108231#define H_PUT_RTCE 0x10c232#define H_COPY_RDMA 0x110233#define H_REGISTER_LOGICAL_LAN 0x114234#define H_FREE_LOGICAL_LAN 0x118235#define H_ADD_LOGICAL_LAN_BUFFER 0x11c236#define H_SEND_LOGICAL_LAN 0x120237#define H_BULK_REMOVE 0x124238#define H_WRITE_RDMA 0x128239#define H_READ_RDMA 0x12c240#define H_MULTICAST_CTRL 0x130241#define H_SET_XDABR 0x134242#define H_STUFF_TCE 0x138243#define H_PUT_TCE_INDIRECT 0x13c244#define H_PUT_RTCE_INDIRECT 0x140245#define H_CHANGE_LOGICAL_LAN_MAC 0x14c246#define H_VTERM_PARTNER_INFO 0x150247#define H_REGISTER_VTERM 0x154248#define H_FREE_VTERM 0x158249/* Reserved ....250#define H_RESET_EVENTS 0x15c251#define H_ALLOC_RESOURCE 0x160252#define H_FREE_RESOURCE 0x164253#define H_MODIFY_QP 0x168254#define H_QUERY_QP 0x16c255#define H_REREGISTER_PMR 0x170256#define H_REGISTER_SMR 0x174257#define H_QUERY_MR 0x178258#define H_QUERY_MW 0x17c259#define H_QUERY_HCA 0x180260#define H_QUERY_PORT 0x184261#define H_MODIFY_PORT 0x188262#define H_DEFINE_AQP1 0x18c263#define H_GET_TRACE_BUFFER 0x190264#define H_DEFINE_AQP0 0x194265#define H_RESIZE_MR 0x198266#define H_ATTACH_MCQP 0x19c267#define H_DETACH_MCQP 0x1a0268#define H_CREATE_RPT 0x1a4269#define H_REMOVE_RPT 0x1a8270#define H_REGISTER_RPAGES 0x1ac271#define H_DISABLE_AND_GETC 0x1b0272#define H_ERROR_DATA 0x1b4273#define H_GET_HCA_INFO 0x1b8274#define H_GET_PERF_COUNT 0x1bc275#define H_MANAGE_TRACE 0x1c0276.... */277#define H_FREE_LOGICAL_LAN_BUFFER 0x1d4278#define H_POLL_PENDING 0x1d8279/* Reserved ....280#define H_QUERY_INT_STATE 0x1e4281.... */282#define H_LIOBN_ATTRIBUTES 0x240283#define H_ILLAN_ATTRIBUTES 0x244284#define H_REMOVE_RTCE 0x24c285/* Reserved ...286#define H_MODIFY_HEA_QP 0x250287#define H_QUERY_HEA_QP 0x254288#define H_QUERY_HEA 0x258289#define H_QUERY_HEA_PORT 0x25c290#define H_MODIFY_HEA_PORT 0x260291#define H_REG_BCMC 0x264292#define H_DEREG_BCMC 0x268293#define H_REGISTER_HEA_RPAGES 0x26c294#define H_DISABLE_AND_GET_HEA 0x270295#define H_GET_HEA_INFO 0x274296#define H_ALLOC_HEA_RESOURCE 0x278297#define H_ADD_CONN 0x284298#define H_DEL_CONN 0x288299... */300#define H_JOIN 0x298301#define H_DONOR_OPERATION 0x29c302#define H_VASI_SIGNAL 0x2a0303#define H_VASI_STATE 0x2a4304#define H_VIOCTL 0x2a8305#define H_VRMASD 0x2ac306#define H_ENABLE_CRQ 0x2b0307/* Reserved ...308#define H_GET_EM_PARMS 0x2b8309... */310#define H_VPM_STAT 0x2bc311#define H_SET_MPP 0x2d0312#define H_GET_MPP 0x2d4313#define H_MO_PERF 0x2d8314#define H_REG_SUB_CRQ 0x2dc315#define H_FREE_SUB_CRQ 0x2e0316#define H_SEND_SUB_CRQ 0x2e4317#define H_SEND_SUB_CRQ_IND 0x2e8318#define H_HOME_NODE_ASSOC 0x2ec319/* Reserved ... */320#define H_BEST_ENERGY 0x2f4321#define H_REG_SNS 0x2f8322#define H_X_XIRR 0x2fc323#define H_RANDOM 0x300324/* Reserved ... */325#define H_COP_OP 0x304326#define H_STOP_COP_OP 0x308327#define H_GET_MPP_X 0x314328#define H_SET_MODE 0x31C329/* Reserved ... */330#define H_GET_DMA_XLATES_L 0x324331/* Reserved ... */332#define H_REGISTER_PROC_TBL 0x37c333#define MAX_HCALL_OPCODE H_REGISTER_PROC_TBL334335int64_t phyp_hcall(uint64_t opcode, ...);336int64_t phyp_pft_hcall(uint64_t opcode, uint64_t flags, uint64_t pteidx,337uint64_t pte_hi, uint64_t pte_lo, uint64_t *pteidx_out, uint64_t *ptelo_out,338uint64_t *r6);339340#endif /* _PSERIES_PHYP_HVCALL_H_ */341342343