1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2a439fe51SSam Ravnborg #ifndef _SPARC64_HYPERVISOR_H 3a439fe51SSam Ravnborg #define _SPARC64_HYPERVISOR_H 4a439fe51SSam Ravnborg 5a439fe51SSam Ravnborg /* Sun4v hypervisor interfaces and defines. 6a439fe51SSam Ravnborg * 7a439fe51SSam Ravnborg * Hypervisor calls are made via traps to software traps number 0x80 8a439fe51SSam Ravnborg * and above. Registers %o0 to %o5 serve as argument, status, and 9a439fe51SSam Ravnborg * return value registers. 10a439fe51SSam Ravnborg * 11a439fe51SSam Ravnborg * There are two kinds of these traps. First there are the normal 12a439fe51SSam Ravnborg * "fast traps" which use software trap 0x80 and encode the function 13a439fe51SSam Ravnborg * to invoke by number in register %o5. Argument and return value 14a439fe51SSam Ravnborg * handling is as follows: 15a439fe51SSam Ravnborg * 16a439fe51SSam Ravnborg * ----------------------------------------------- 17a439fe51SSam Ravnborg * | %o5 | function number | undefined | 18a439fe51SSam Ravnborg * | %o0 | argument 0 | return status | 19a439fe51SSam Ravnborg * | %o1 | argument 1 | return value 1 | 20a439fe51SSam Ravnborg * | %o2 | argument 2 | return value 2 | 21a439fe51SSam Ravnborg * | %o3 | argument 3 | return value 3 | 22a439fe51SSam Ravnborg * | %o4 | argument 4 | return value 4 | 23a439fe51SSam Ravnborg * ----------------------------------------------- 24a439fe51SSam Ravnborg * 25a439fe51SSam Ravnborg * The second type are "hyper-fast traps" which encode the function 26a439fe51SSam Ravnborg * number in the software trap number itself. So these use trap 27a439fe51SSam Ravnborg * numbers > 0x80. The register usage for hyper-fast traps is as 28a439fe51SSam Ravnborg * follows: 29a439fe51SSam Ravnborg * 30a439fe51SSam Ravnborg * ----------------------------------------------- 31a439fe51SSam Ravnborg * | %o0 | argument 0 | return status | 32a439fe51SSam Ravnborg * | %o1 | argument 1 | return value 1 | 33a439fe51SSam Ravnborg * | %o2 | argument 2 | return value 2 | 34a439fe51SSam Ravnborg * | %o3 | argument 3 | return value 3 | 35a439fe51SSam Ravnborg * | %o4 | argument 4 | return value 4 | 36a439fe51SSam Ravnborg * ----------------------------------------------- 37a439fe51SSam Ravnborg * 38a439fe51SSam Ravnborg * Registers providing explicit arguments to the hypervisor calls 39a439fe51SSam Ravnborg * are volatile across the call. Upon return their values are 40a439fe51SSam Ravnborg * undefined unless explicitly specified as containing a particular 41a439fe51SSam Ravnborg * return value by the specific call. The return status is always 42a439fe51SSam Ravnborg * returned in register %o0, zero indicates a successful execution of 43a439fe51SSam Ravnborg * the hypervisor call and other values indicate an error status as 44a439fe51SSam Ravnborg * defined below. So, for example, if a hyper-fast trap takes 45a439fe51SSam Ravnborg * arguments 0, 1, and 2, then %o0, %o1, and %o2 are volatile across 46a439fe51SSam Ravnborg * the call and %o3, %o4, and %o5 would be preserved. 47a439fe51SSam Ravnborg * 48a439fe51SSam Ravnborg * If the hypervisor trap is invalid, or the fast trap function number 49a439fe51SSam Ravnborg * is invalid, HV_EBADTRAP will be returned in %o0. Also, all 64-bits 50a439fe51SSam Ravnborg * of the argument and return values are significant. 51a439fe51SSam Ravnborg */ 52a439fe51SSam Ravnborg 53a439fe51SSam Ravnborg /* Trap numbers. */ 54a439fe51SSam Ravnborg #define HV_FAST_TRAP 0x80 55a439fe51SSam Ravnborg #define HV_MMU_MAP_ADDR_TRAP 0x83 56a439fe51SSam Ravnborg #define HV_MMU_UNMAP_ADDR_TRAP 0x84 57a439fe51SSam Ravnborg #define HV_TTRACE_ADDENTRY_TRAP 0x85 58a439fe51SSam Ravnborg #define HV_CORE_TRAP 0xff 59a439fe51SSam Ravnborg 60a439fe51SSam Ravnborg /* Error codes. */ 61a439fe51SSam Ravnborg #define HV_EOK 0 /* Successful return */ 62a439fe51SSam Ravnborg #define HV_ENOCPU 1 /* Invalid CPU id */ 63a439fe51SSam Ravnborg #define HV_ENORADDR 2 /* Invalid real address */ 64a439fe51SSam Ravnborg #define HV_ENOINTR 3 /* Invalid interrupt id */ 65a439fe51SSam Ravnborg #define HV_EBADPGSZ 4 /* Invalid pagesize encoding */ 66a439fe51SSam Ravnborg #define HV_EBADTSB 5 /* Invalid TSB description */ 67a439fe51SSam Ravnborg #define HV_EINVAL 6 /* Invalid argument */ 68a439fe51SSam Ravnborg #define HV_EBADTRAP 7 /* Invalid function number */ 69a439fe51SSam Ravnborg #define HV_EBADALIGN 8 /* Invalid address alignment */ 70a439fe51SSam Ravnborg #define HV_EWOULDBLOCK 9 /* Cannot complete w/o blocking */ 71a439fe51SSam Ravnborg #define HV_ENOACCESS 10 /* No access to resource */ 72a439fe51SSam Ravnborg #define HV_EIO 11 /* I/O error */ 73a439fe51SSam Ravnborg #define HV_ECPUERROR 12 /* CPU in error state */ 74a439fe51SSam Ravnborg #define HV_ENOTSUPPORTED 13 /* Function not supported */ 75a439fe51SSam Ravnborg #define HV_ENOMAP 14 /* No mapping found */ 76a439fe51SSam Ravnborg #define HV_ETOOMANY 15 /* Too many items specified */ 77a439fe51SSam Ravnborg #define HV_ECHANNEL 16 /* Invalid LDC channel */ 78a439fe51SSam Ravnborg #define HV_EBUSY 17 /* Resource busy */ 79c2b5934fSRob Gardner #define HV_EUNAVAILABLE 23 /* Resource or operation not 80c2b5934fSRob Gardner * currently available, but may 81c2b5934fSRob Gardner * become available in the future 82c2b5934fSRob Gardner */ 83a439fe51SSam Ravnborg 84a439fe51SSam Ravnborg /* mach_exit() 85a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 86a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MACH_EXIT 87a439fe51SSam Ravnborg * ARG0: exit code 88a439fe51SSam Ravnborg * ERRORS: This service does not return. 89a439fe51SSam Ravnborg * 90a439fe51SSam Ravnborg * Stop all CPUs in the virtual domain and place them into the stopped 91a439fe51SSam Ravnborg * state. The 64-bit exit code may be passed to a service entity as 92a439fe51SSam Ravnborg * the domain's exit status. On systems without a service entity, the 93a439fe51SSam Ravnborg * domain will undergo a reset, and the boot firmware will be 94a439fe51SSam Ravnborg * reloaded. 95a439fe51SSam Ravnborg * 96a439fe51SSam Ravnborg * This function will never return to the guest that invokes it. 97a439fe51SSam Ravnborg * 98a439fe51SSam Ravnborg * Note: By convention an exit code of zero denotes a successful exit by 99a439fe51SSam Ravnborg * the guest code. A non-zero exit code denotes a guest specific 100a439fe51SSam Ravnborg * error indication. 101a439fe51SSam Ravnborg * 102a439fe51SSam Ravnborg */ 103a439fe51SSam Ravnborg #define HV_FAST_MACH_EXIT 0x00 104a439fe51SSam Ravnborg 105a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 106f05a6865SSam Ravnborg void sun4v_mach_exit(unsigned long exit_code); 107a439fe51SSam Ravnborg #endif 108a439fe51SSam Ravnborg 109a439fe51SSam Ravnborg /* Domain services. */ 110a439fe51SSam Ravnborg 111a439fe51SSam Ravnborg /* mach_desc() 112a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 113a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MACH_DESC 114a439fe51SSam Ravnborg * ARG0: buffer 115a439fe51SSam Ravnborg * ARG1: length 116a439fe51SSam Ravnborg * RET0: status 117a439fe51SSam Ravnborg * RET1: length 118a439fe51SSam Ravnborg * ERRORS: HV_EBADALIGN Buffer is badly aligned 119a439fe51SSam Ravnborg * HV_ENORADDR Buffer is to an illegal real address. 120a439fe51SSam Ravnborg * HV_EINVAL Buffer length is too small for complete 121a439fe51SSam Ravnborg * machine description. 122a439fe51SSam Ravnborg * 123a439fe51SSam Ravnborg * Copy the most current machine description into the buffer indicated 124a439fe51SSam Ravnborg * by the real address in ARG0. The buffer provided must be 16 byte 125a439fe51SSam Ravnborg * aligned. Upon success or HV_EINVAL, this service returns the 126a439fe51SSam Ravnborg * actual size of the machine description in the RET1 return value. 127a439fe51SSam Ravnborg * 128a439fe51SSam Ravnborg * Note: A method of determining the appropriate buffer size for the 129a439fe51SSam Ravnborg * machine description is to first call this service with a buffer 130a439fe51SSam Ravnborg * length of 0 bytes. 131a439fe51SSam Ravnborg */ 132a439fe51SSam Ravnborg #define HV_FAST_MACH_DESC 0x01 133a439fe51SSam Ravnborg 134a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 135f05a6865SSam Ravnborg unsigned long sun4v_mach_desc(unsigned long buffer_pa, 136a439fe51SSam Ravnborg unsigned long buf_len, 137a439fe51SSam Ravnborg unsigned long *real_buf_len); 138a439fe51SSam Ravnborg #endif 139a439fe51SSam Ravnborg 140a439fe51SSam Ravnborg /* mach_sir() 141a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 142a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MACH_SIR 143a439fe51SSam Ravnborg * ERRORS: This service does not return. 144a439fe51SSam Ravnborg * 145a439fe51SSam Ravnborg * Perform a software initiated reset of the virtual machine domain. 146a439fe51SSam Ravnborg * All CPUs are captured as soon as possible, all hardware devices are 147a439fe51SSam Ravnborg * returned to the entry default state, and the domain is restarted at 148a439fe51SSam Ravnborg * the SIR (trap type 0x04) real trap table (RTBA) entry point on one 149a439fe51SSam Ravnborg * of the CPUs. The single CPU restarted is selected as determined by 150a439fe51SSam Ravnborg * platform specific policy. Memory is preserved across this 151a439fe51SSam Ravnborg * operation. 152a439fe51SSam Ravnborg */ 153a439fe51SSam Ravnborg #define HV_FAST_MACH_SIR 0x02 154a439fe51SSam Ravnborg 155a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 156f05a6865SSam Ravnborg void sun4v_mach_sir(void); 157a439fe51SSam Ravnborg #endif 158a439fe51SSam Ravnborg 159a439fe51SSam Ravnborg /* mach_set_watchdog() 160a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 161a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MACH_SET_WATCHDOG 162a439fe51SSam Ravnborg * ARG0: timeout in milliseconds 163a439fe51SSam Ravnborg * RET0: status 164a439fe51SSam Ravnborg * RET1: time remaining in milliseconds 165a439fe51SSam Ravnborg * 166a439fe51SSam Ravnborg * A guest uses this API to set a watchdog timer. Once the gues has set 167a439fe51SSam Ravnborg * the timer, it must call the timer service again either to disable or 168a439fe51SSam Ravnborg * postpone the expiration. If the timer expires before being reset or 169a439fe51SSam Ravnborg * disabled, then the hypervisor take a platform specific action leading 170a439fe51SSam Ravnborg * to guest termination within a bounded time period. The platform action 171a439fe51SSam Ravnborg * may include recovery actions such as reporting the expiration to a 172a439fe51SSam Ravnborg * Service Processor, and/or automatically restarting the gues. 173a439fe51SSam Ravnborg * 174a439fe51SSam Ravnborg * The 'timeout' parameter is specified in milliseconds, however the 175a439fe51SSam Ravnborg * implementated granularity is given by the 'watchdog-resolution' 176a439fe51SSam Ravnborg * property in the 'platform' node of the guest's machine description. 177a439fe51SSam Ravnborg * The largest allowed timeout value is specified by the 178a439fe51SSam Ravnborg * 'watchdog-max-timeout' property of the 'platform' node. 179a439fe51SSam Ravnborg * 180a439fe51SSam Ravnborg * If the 'timeout' argument is not zero, the watchdog timer is set to 181a439fe51SSam Ravnborg * expire after a minimum of 'timeout' milliseconds. 182a439fe51SSam Ravnborg * 183a439fe51SSam Ravnborg * If the 'timeout' argument is zero, the watchdog timer is disabled. 184a439fe51SSam Ravnborg * 185a439fe51SSam Ravnborg * If the 'timeout' value exceeds the value of the 'max-watchdog-timeout' 186a439fe51SSam Ravnborg * property, the hypervisor leaves the watchdog timer state unchanged, 187a439fe51SSam Ravnborg * and returns a status of EINVAL. 188a439fe51SSam Ravnborg * 189a439fe51SSam Ravnborg * The 'time remaining' return value is valid regardless of whether the 190a439fe51SSam Ravnborg * return status is EOK or EINVAL. A non-zero return value indicates the 191a439fe51SSam Ravnborg * number of milliseconds that were remaining until the timer was to expire. 192a439fe51SSam Ravnborg * If less than one millisecond remains, the return value is '1'. If the 193a439fe51SSam Ravnborg * watchdog timer was disabled at the time of the call, the return value is 194a439fe51SSam Ravnborg * zero. 195a439fe51SSam Ravnborg * 196a439fe51SSam Ravnborg * If the hypervisor cannot support the exact timeout value requested, but 197a439fe51SSam Ravnborg * can support a larger timeout value, the hypervisor may round the actual 198a439fe51SSam Ravnborg * timeout to a value larger than the requested timeout, consequently the 199a439fe51SSam Ravnborg * 'time remaining' return value may be larger than the previously requested 200a439fe51SSam Ravnborg * timeout value. 201a439fe51SSam Ravnborg * 202a439fe51SSam Ravnborg * Any guest OS debugger should be aware that the watchdog service may be in 203a439fe51SSam Ravnborg * use. Consequently, it is recommended that the watchdog service is 204a439fe51SSam Ravnborg * disabled upon debugger entry (e.g. reaching a breakpoint), and then 205a439fe51SSam Ravnborg * re-enabled upon returning to normal execution. The API has been designed 206a439fe51SSam Ravnborg * with this in mind, and the 'time remaining' result of the disable call may 207a439fe51SSam Ravnborg * be used directly as the timeout argument of the re-enable call. 208a439fe51SSam Ravnborg */ 209a439fe51SSam Ravnborg #define HV_FAST_MACH_SET_WATCHDOG 0x05 210a439fe51SSam Ravnborg 211a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 212f05a6865SSam Ravnborg unsigned long sun4v_mach_set_watchdog(unsigned long timeout, 213a439fe51SSam Ravnborg unsigned long *orig_timeout); 214a439fe51SSam Ravnborg #endif 215a439fe51SSam Ravnborg 216a439fe51SSam Ravnborg /* CPU services. 217a439fe51SSam Ravnborg * 218a439fe51SSam Ravnborg * CPUs represent devices that can execute software threads. A single 219a439fe51SSam Ravnborg * chip that contains multiple cores or strands is represented as 220a439fe51SSam Ravnborg * multiple CPUs with unique CPU identifiers. CPUs are exported to 221a439fe51SSam Ravnborg * OBP via the machine description (and to the OS via the OBP device 222a439fe51SSam Ravnborg * tree). CPUs are always in one of three states: stopped, running, 223a439fe51SSam Ravnborg * or error. 224a439fe51SSam Ravnborg * 225a439fe51SSam Ravnborg * A CPU ID is a pre-assigned 16-bit value that uniquely identifies a 226a439fe51SSam Ravnborg * CPU within a logical domain. Operations that are to be performed 227a439fe51SSam Ravnborg * on multiple CPUs specify them via a CPU list. A CPU list is an 228a439fe51SSam Ravnborg * array in real memory, of which each 16-bit word is a CPU ID. CPU 229a439fe51SSam Ravnborg * lists are passed through the API as two arguments. The first is 230a439fe51SSam Ravnborg * the number of entries (16-bit words) in the CPU list, and the 231a439fe51SSam Ravnborg * second is the (real address) pointer to the CPU ID list. 232a439fe51SSam Ravnborg */ 233a439fe51SSam Ravnborg 234a439fe51SSam Ravnborg /* cpu_start() 235a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 236a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CPU_START 237a439fe51SSam Ravnborg * ARG0: CPU ID 238a439fe51SSam Ravnborg * ARG1: PC 239a439fe51SSam Ravnborg * ARG2: RTBA 240a439fe51SSam Ravnborg * ARG3: target ARG0 241a439fe51SSam Ravnborg * RET0: status 242a439fe51SSam Ravnborg * ERRORS: ENOCPU Invalid CPU ID 243a439fe51SSam Ravnborg * EINVAL Target CPU ID is not in the stopped state 244a439fe51SSam Ravnborg * ENORADDR Invalid PC or RTBA real address 245a439fe51SSam Ravnborg * EBADALIGN Unaligned PC or unaligned RTBA 246a439fe51SSam Ravnborg * EWOULDBLOCK Starting resources are not available 247a439fe51SSam Ravnborg * 248a439fe51SSam Ravnborg * Start CPU with given CPU ID with PC in %pc and with a real trap 249a439fe51SSam Ravnborg * base address value of RTBA. The indicated CPU must be in the 250a439fe51SSam Ravnborg * stopped state. The supplied RTBA must be aligned on a 256 byte 251a439fe51SSam Ravnborg * boundary. On successful completion, the specified CPU will be in 252a439fe51SSam Ravnborg * the running state and will be supplied with "target ARG0" in %o0 253a439fe51SSam Ravnborg * and RTBA in %tba. 254a439fe51SSam Ravnborg */ 255a439fe51SSam Ravnborg #define HV_FAST_CPU_START 0x10 256a439fe51SSam Ravnborg 257a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 258f05a6865SSam Ravnborg unsigned long sun4v_cpu_start(unsigned long cpuid, 259a439fe51SSam Ravnborg unsigned long pc, 260a439fe51SSam Ravnborg unsigned long rtba, 261a439fe51SSam Ravnborg unsigned long arg0); 262a439fe51SSam Ravnborg #endif 263a439fe51SSam Ravnborg 264a439fe51SSam Ravnborg /* cpu_stop() 265a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 266a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CPU_STOP 267a439fe51SSam Ravnborg * ARG0: CPU ID 268a439fe51SSam Ravnborg * RET0: status 269a439fe51SSam Ravnborg * ERRORS: ENOCPU Invalid CPU ID 270a439fe51SSam Ravnborg * EINVAL Target CPU ID is the current cpu 271a439fe51SSam Ravnborg * EINVAL Target CPU ID is not in the running state 272a439fe51SSam Ravnborg * EWOULDBLOCK Stopping resources are not available 273a439fe51SSam Ravnborg * ENOTSUPPORTED Not supported on this platform 274a439fe51SSam Ravnborg * 275a439fe51SSam Ravnborg * The specified CPU is stopped. The indicated CPU must be in the 276a439fe51SSam Ravnborg * running state. On completion, it will be in the stopped state. It 277a439fe51SSam Ravnborg * is not legal to stop the current CPU. 278a439fe51SSam Ravnborg * 279a439fe51SSam Ravnborg * Note: As this service cannot be used to stop the current cpu, this service 280a439fe51SSam Ravnborg * may not be used to stop the last running CPU in a domain. To stop 281a439fe51SSam Ravnborg * and exit a running domain, a guest must use the mach_exit() service. 282a439fe51SSam Ravnborg */ 283a439fe51SSam Ravnborg #define HV_FAST_CPU_STOP 0x11 284a439fe51SSam Ravnborg 285a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 286f05a6865SSam Ravnborg unsigned long sun4v_cpu_stop(unsigned long cpuid); 287a439fe51SSam Ravnborg #endif 288a439fe51SSam Ravnborg 289a439fe51SSam Ravnborg /* cpu_yield() 290a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 291a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CPU_YIELD 292a439fe51SSam Ravnborg * RET0: status 293a439fe51SSam Ravnborg * ERRORS: No possible error. 294a439fe51SSam Ravnborg * 295a439fe51SSam Ravnborg * Suspend execution on the current CPU. Execution will resume when 296a439fe51SSam Ravnborg * an interrupt (device, %stick_compare, or cross-call) is targeted to 297a439fe51SSam Ravnborg * the CPU. On some CPUs, this API may be used by the hypervisor to 298a439fe51SSam Ravnborg * save power by disabling hardware strands. 299a439fe51SSam Ravnborg */ 300a439fe51SSam Ravnborg #define HV_FAST_CPU_YIELD 0x12 301a439fe51SSam Ravnborg 302a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 303f05a6865SSam Ravnborg unsigned long sun4v_cpu_yield(void); 304a439fe51SSam Ravnborg #endif 305a439fe51SSam Ravnborg 30628d43de7SVijay Kumar /* cpu_poke() 30728d43de7SVijay Kumar * TRAP: HV_FAST_TRAP 30828d43de7SVijay Kumar * FUNCTION: HV_FAST_CPU_POKE 30928d43de7SVijay Kumar * RET0: status 31028d43de7SVijay Kumar * ERRORS: ENOCPU cpuid refers to a CPU that does not exist 31128d43de7SVijay Kumar * EINVAL cpuid is current CPU 31228d43de7SVijay Kumar * 31328d43de7SVijay Kumar * Poke CPU cpuid. If the target CPU is currently suspended having 31428d43de7SVijay Kumar * invoked the cpu-yield service, that vCPU will be resumed. 31528d43de7SVijay Kumar * Poke interrupts may only be sent to valid, non-local CPUs. 31628d43de7SVijay Kumar * It is not legal to poke the current vCPU. 31728d43de7SVijay Kumar */ 31828d43de7SVijay Kumar #define HV_FAST_CPU_POKE 0x13 31928d43de7SVijay Kumar 32028d43de7SVijay Kumar #ifndef __ASSEMBLY__ 32128d43de7SVijay Kumar unsigned long sun4v_cpu_poke(unsigned long cpuid); 32228d43de7SVijay Kumar #endif 32328d43de7SVijay Kumar 324a439fe51SSam Ravnborg /* cpu_qconf() 325a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 326a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CPU_QCONF 327a439fe51SSam Ravnborg * ARG0: queue 328a439fe51SSam Ravnborg * ARG1: base real address 329a439fe51SSam Ravnborg * ARG2: number of entries 330a439fe51SSam Ravnborg * RET0: status 331a439fe51SSam Ravnborg * ERRORS: ENORADDR Invalid base real address 332a439fe51SSam Ravnborg * EINVAL Invalid queue or number of entries is less 333a439fe51SSam Ravnborg * than 2 or too large. 334a439fe51SSam Ravnborg * EBADALIGN Base real address is not correctly aligned 335a439fe51SSam Ravnborg * for size. 336a439fe51SSam Ravnborg * 337a439fe51SSam Ravnborg * Configure the given queue to be placed at the given base real 338a439fe51SSam Ravnborg * address, with the given number of entries. The number of entries 339a439fe51SSam Ravnborg * must be a power of 2. The base real address must be aligned 340a439fe51SSam Ravnborg * exactly to match the queue size. Each queue entry is 64 bytes 341a439fe51SSam Ravnborg * long, so for example a 32 entry queue must be aligned on a 2048 342a439fe51SSam Ravnborg * byte real address boundary. 343a439fe51SSam Ravnborg * 344a439fe51SSam Ravnborg * The specified queue is unconfigured if the number of entries is given 345a439fe51SSam Ravnborg * as zero. 346a439fe51SSam Ravnborg * 347a439fe51SSam Ravnborg * For the current version of this API service, the argument queue is defined 348a439fe51SSam Ravnborg * as follows: 349a439fe51SSam Ravnborg * 350a439fe51SSam Ravnborg * queue description 351a439fe51SSam Ravnborg * ----- ------------------------- 352a439fe51SSam Ravnborg * 0x3c cpu mondo queue 353a439fe51SSam Ravnborg * 0x3d device mondo queue 354a439fe51SSam Ravnborg * 0x3e resumable error queue 355a439fe51SSam Ravnborg * 0x3f non-resumable error queue 356a439fe51SSam Ravnborg * 357a439fe51SSam Ravnborg * Note: The maximum number of entries for each queue for a specific cpu may 358a439fe51SSam Ravnborg * be determined from the machine description. 359a439fe51SSam Ravnborg */ 360a439fe51SSam Ravnborg #define HV_FAST_CPU_QCONF 0x14 361a439fe51SSam Ravnborg #define HV_CPU_QUEUE_CPU_MONDO 0x3c 362a439fe51SSam Ravnborg #define HV_CPU_QUEUE_DEVICE_MONDO 0x3d 363a439fe51SSam Ravnborg #define HV_CPU_QUEUE_RES_ERROR 0x3e 364a439fe51SSam Ravnborg #define HV_CPU_QUEUE_NONRES_ERROR 0x3f 365a439fe51SSam Ravnborg 366a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 367f05a6865SSam Ravnborg unsigned long sun4v_cpu_qconf(unsigned long type, 368a439fe51SSam Ravnborg unsigned long queue_paddr, 369a439fe51SSam Ravnborg unsigned long num_queue_entries); 370a439fe51SSam Ravnborg #endif 371a439fe51SSam Ravnborg 372a439fe51SSam Ravnborg /* cpu_qinfo() 373a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 374a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CPU_QINFO 375a439fe51SSam Ravnborg * ARG0: queue 376a439fe51SSam Ravnborg * RET0: status 377a439fe51SSam Ravnborg * RET1: base real address 378a439fe51SSam Ravnborg * RET1: number of entries 379a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid queue 380a439fe51SSam Ravnborg * 381a439fe51SSam Ravnborg * Return the configuration info for the given queue. The base real 382a439fe51SSam Ravnborg * address and number of entries of the defined queue are returned. 383a439fe51SSam Ravnborg * The queue argument values are the same as for cpu_qconf() above. 384a439fe51SSam Ravnborg * 385a439fe51SSam Ravnborg * If the specified queue is a valid queue number, but no queue has 386a439fe51SSam Ravnborg * been defined, the number of entries will be set to zero and the 387a439fe51SSam Ravnborg * base real address returned is undefined. 388a439fe51SSam Ravnborg */ 389a439fe51SSam Ravnborg #define HV_FAST_CPU_QINFO 0x15 390a439fe51SSam Ravnborg 391a439fe51SSam Ravnborg /* cpu_mondo_send() 392a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 393a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CPU_MONDO_SEND 394a439fe51SSam Ravnborg * ARG0-1: CPU list 395a439fe51SSam Ravnborg * ARG2: data real address 396a439fe51SSam Ravnborg * RET0: status 397a439fe51SSam Ravnborg * ERRORS: EBADALIGN Mondo data is not 64-byte aligned or CPU list 398a439fe51SSam Ravnborg * is not 2-byte aligned. 399a439fe51SSam Ravnborg * ENORADDR Invalid data mondo address, or invalid cpu list 400a439fe51SSam Ravnborg * address. 401a439fe51SSam Ravnborg * ENOCPU Invalid cpu in CPU list 402a439fe51SSam Ravnborg * EWOULDBLOCK Some or all of the listed CPUs did not receive 403a439fe51SSam Ravnborg * the mondo 404a439fe51SSam Ravnborg * ECPUERROR One or more of the listed CPUs are in error 405a439fe51SSam Ravnborg * state, use HV_FAST_CPU_STATE to see which ones 406a439fe51SSam Ravnborg * EINVAL CPU list includes caller's CPU ID 407a439fe51SSam Ravnborg * 408a439fe51SSam Ravnborg * Send a mondo interrupt to the CPUs in the given CPU list with the 409a439fe51SSam Ravnborg * 64-bytes at the given data real address. The data must be 64-byte 410a439fe51SSam Ravnborg * aligned. The mondo data will be delivered to the cpu_mondo queues 411a439fe51SSam Ravnborg * of the recipient CPUs. 412a439fe51SSam Ravnborg * 413a439fe51SSam Ravnborg * In all cases, error or not, the CPUs in the CPU list to which the 414a439fe51SSam Ravnborg * mondo has been successfully delivered will be indicated by having 415a439fe51SSam Ravnborg * their entry in CPU list updated with the value 0xffff. 416a439fe51SSam Ravnborg */ 417a439fe51SSam Ravnborg #define HV_FAST_CPU_MONDO_SEND 0x42 418a439fe51SSam Ravnborg 419a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 420f05a6865SSam Ravnborg unsigned long sun4v_cpu_mondo_send(unsigned long cpu_count, 421f05a6865SSam Ravnborg unsigned long cpu_list_pa, 422f05a6865SSam Ravnborg unsigned long mondo_block_pa); 423a439fe51SSam Ravnborg #endif 424a439fe51SSam Ravnborg 425a439fe51SSam Ravnborg /* cpu_myid() 426a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 427a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CPU_MYID 428a439fe51SSam Ravnborg * RET0: status 429a439fe51SSam Ravnborg * RET1: CPU ID 430a439fe51SSam Ravnborg * ERRORS: No errors defined. 431a439fe51SSam Ravnborg * 432a439fe51SSam Ravnborg * Return the hypervisor ID handle for the current CPU. Use by a 433a439fe51SSam Ravnborg * virtual CPU to discover it's own identity. 434a439fe51SSam Ravnborg */ 435a439fe51SSam Ravnborg #define HV_FAST_CPU_MYID 0x16 436a439fe51SSam Ravnborg 437a439fe51SSam Ravnborg /* cpu_state() 438a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 439a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CPU_STATE 440a439fe51SSam Ravnborg * ARG0: CPU ID 441a439fe51SSam Ravnborg * RET0: status 442a439fe51SSam Ravnborg * RET1: state 443a439fe51SSam Ravnborg * ERRORS: ENOCPU Invalid CPU ID 444a439fe51SSam Ravnborg * 445a439fe51SSam Ravnborg * Retrieve the current state of the CPU with the given CPU ID. 446a439fe51SSam Ravnborg */ 447a439fe51SSam Ravnborg #define HV_FAST_CPU_STATE 0x17 448a439fe51SSam Ravnborg #define HV_CPU_STATE_STOPPED 0x01 449a439fe51SSam Ravnborg #define HV_CPU_STATE_RUNNING 0x02 450a439fe51SSam Ravnborg #define HV_CPU_STATE_ERROR 0x03 451a439fe51SSam Ravnborg 452a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 453f05a6865SSam Ravnborg long sun4v_cpu_state(unsigned long cpuid); 454a439fe51SSam Ravnborg #endif 455a439fe51SSam Ravnborg 456a439fe51SSam Ravnborg /* cpu_set_rtba() 457a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 458a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CPU_SET_RTBA 459a439fe51SSam Ravnborg * ARG0: RTBA 460a439fe51SSam Ravnborg * RET0: status 461a439fe51SSam Ravnborg * RET1: previous RTBA 462a439fe51SSam Ravnborg * ERRORS: ENORADDR Invalid RTBA real address 463a439fe51SSam Ravnborg * EBADALIGN RTBA is incorrectly aligned for a trap table 464a439fe51SSam Ravnborg * 465a439fe51SSam Ravnborg * Set the real trap base address of the local cpu to the given RTBA. 466a439fe51SSam Ravnborg * The supplied RTBA must be aligned on a 256 byte boundary. Upon 467a439fe51SSam Ravnborg * success the previous value of the RTBA is returned in RET1. 468a439fe51SSam Ravnborg * 469a439fe51SSam Ravnborg * Note: This service does not affect %tba 470a439fe51SSam Ravnborg */ 471a439fe51SSam Ravnborg #define HV_FAST_CPU_SET_RTBA 0x18 472a439fe51SSam Ravnborg 473a439fe51SSam Ravnborg /* cpu_set_rtba() 474a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 475a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CPU_GET_RTBA 476a439fe51SSam Ravnborg * RET0: status 477a439fe51SSam Ravnborg * RET1: previous RTBA 478a439fe51SSam Ravnborg * ERRORS: No possible error. 479a439fe51SSam Ravnborg * 480a439fe51SSam Ravnborg * Returns the current value of RTBA in RET1. 481a439fe51SSam Ravnborg */ 482a439fe51SSam Ravnborg #define HV_FAST_CPU_GET_RTBA 0x19 483a439fe51SSam Ravnborg 484a439fe51SSam Ravnborg /* MMU services. 485a439fe51SSam Ravnborg * 486a439fe51SSam Ravnborg * Layout of a TSB description for mmu_tsb_ctx{,non}0() calls. 487a439fe51SSam Ravnborg */ 488a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 489a439fe51SSam Ravnborg struct hv_tsb_descr { 490a439fe51SSam Ravnborg unsigned short pgsz_idx; 491a439fe51SSam Ravnborg unsigned short assoc; 492a439fe51SSam Ravnborg unsigned int num_ttes; /* in TTEs */ 493a439fe51SSam Ravnborg unsigned int ctx_idx; 494a439fe51SSam Ravnborg unsigned int pgsz_mask; 495a439fe51SSam Ravnborg unsigned long tsb_base; 496a439fe51SSam Ravnborg unsigned long resv; 497a439fe51SSam Ravnborg }; 498a439fe51SSam Ravnborg #endif 499a439fe51SSam Ravnborg #define HV_TSB_DESCR_PGSZ_IDX_OFFSET 0x00 500a439fe51SSam Ravnborg #define HV_TSB_DESCR_ASSOC_OFFSET 0x02 501a439fe51SSam Ravnborg #define HV_TSB_DESCR_NUM_TTES_OFFSET 0x04 502a439fe51SSam Ravnborg #define HV_TSB_DESCR_CTX_IDX_OFFSET 0x08 503a439fe51SSam Ravnborg #define HV_TSB_DESCR_PGSZ_MASK_OFFSET 0x0c 504a439fe51SSam Ravnborg #define HV_TSB_DESCR_TSB_BASE_OFFSET 0x10 505a439fe51SSam Ravnborg #define HV_TSB_DESCR_RESV_OFFSET 0x18 506a439fe51SSam Ravnborg 507a439fe51SSam Ravnborg /* Page size bitmask. */ 508a439fe51SSam Ravnborg #define HV_PGSZ_MASK_8K (1 << 0) 509a439fe51SSam Ravnborg #define HV_PGSZ_MASK_64K (1 << 1) 510a439fe51SSam Ravnborg #define HV_PGSZ_MASK_512K (1 << 2) 511a439fe51SSam Ravnborg #define HV_PGSZ_MASK_4MB (1 << 3) 512a439fe51SSam Ravnborg #define HV_PGSZ_MASK_32MB (1 << 4) 513a439fe51SSam Ravnborg #define HV_PGSZ_MASK_256MB (1 << 5) 514a439fe51SSam Ravnborg #define HV_PGSZ_MASK_2GB (1 << 6) 515a439fe51SSam Ravnborg #define HV_PGSZ_MASK_16GB (1 << 7) 516a439fe51SSam Ravnborg 517a439fe51SSam Ravnborg /* Page size index. The value given in the TSB descriptor must correspond 518a439fe51SSam Ravnborg * to the smallest page size specified in the pgsz_mask page size bitmask. 519a439fe51SSam Ravnborg */ 520a439fe51SSam Ravnborg #define HV_PGSZ_IDX_8K 0 521a439fe51SSam Ravnborg #define HV_PGSZ_IDX_64K 1 522a439fe51SSam Ravnborg #define HV_PGSZ_IDX_512K 2 523a439fe51SSam Ravnborg #define HV_PGSZ_IDX_4MB 3 524a439fe51SSam Ravnborg #define HV_PGSZ_IDX_32MB 4 525a439fe51SSam Ravnborg #define HV_PGSZ_IDX_256MB 5 526a439fe51SSam Ravnborg #define HV_PGSZ_IDX_2GB 6 527a439fe51SSam Ravnborg #define HV_PGSZ_IDX_16GB 7 528a439fe51SSam Ravnborg 529a439fe51SSam Ravnborg /* MMU fault status area. 530a439fe51SSam Ravnborg * 531a439fe51SSam Ravnborg * MMU related faults have their status and fault address information 532a439fe51SSam Ravnborg * placed into a memory region made available by privileged code. Each 533a439fe51SSam Ravnborg * virtual processor must make a mmu_fault_area_conf() call to tell the 534a439fe51SSam Ravnborg * hypervisor where that processor's fault status should be stored. 535a439fe51SSam Ravnborg * 536a439fe51SSam Ravnborg * The fault status block is a multiple of 64-bytes and must be aligned 537a439fe51SSam Ravnborg * on a 64-byte boundary. 538a439fe51SSam Ravnborg */ 539a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 540a439fe51SSam Ravnborg struct hv_fault_status { 541a439fe51SSam Ravnborg unsigned long i_fault_type; 542a439fe51SSam Ravnborg unsigned long i_fault_addr; 543a439fe51SSam Ravnborg unsigned long i_fault_ctx; 544a439fe51SSam Ravnborg unsigned long i_reserved[5]; 545a439fe51SSam Ravnborg unsigned long d_fault_type; 546a439fe51SSam Ravnborg unsigned long d_fault_addr; 547a439fe51SSam Ravnborg unsigned long d_fault_ctx; 548a439fe51SSam Ravnborg unsigned long d_reserved[5]; 549a439fe51SSam Ravnborg }; 550a439fe51SSam Ravnborg #endif 551a439fe51SSam Ravnborg #define HV_FAULT_I_TYPE_OFFSET 0x00 552a439fe51SSam Ravnborg #define HV_FAULT_I_ADDR_OFFSET 0x08 553a439fe51SSam Ravnborg #define HV_FAULT_I_CTX_OFFSET 0x10 554a439fe51SSam Ravnborg #define HV_FAULT_D_TYPE_OFFSET 0x40 555a439fe51SSam Ravnborg #define HV_FAULT_D_ADDR_OFFSET 0x48 556a439fe51SSam Ravnborg #define HV_FAULT_D_CTX_OFFSET 0x50 557a439fe51SSam Ravnborg 558a439fe51SSam Ravnborg #define HV_FAULT_TYPE_FAST_MISS 1 559a439fe51SSam Ravnborg #define HV_FAULT_TYPE_FAST_PROT 2 560a439fe51SSam Ravnborg #define HV_FAULT_TYPE_MMU_MISS 3 561a439fe51SSam Ravnborg #define HV_FAULT_TYPE_INV_RA 4 562a439fe51SSam Ravnborg #define HV_FAULT_TYPE_PRIV_VIOL 5 563a439fe51SSam Ravnborg #define HV_FAULT_TYPE_PROT_VIOL 6 564a439fe51SSam Ravnborg #define HV_FAULT_TYPE_NFO 7 565a439fe51SSam Ravnborg #define HV_FAULT_TYPE_NFO_SEFF 8 566a439fe51SSam Ravnborg #define HV_FAULT_TYPE_INV_VA 9 567a439fe51SSam Ravnborg #define HV_FAULT_TYPE_INV_ASI 10 568a439fe51SSam Ravnborg #define HV_FAULT_TYPE_NC_ATOMIC 11 569a439fe51SSam Ravnborg #define HV_FAULT_TYPE_PRIV_ACT 12 570a439fe51SSam Ravnborg #define HV_FAULT_TYPE_RESV1 13 571a439fe51SSam Ravnborg #define HV_FAULT_TYPE_UNALIGNED 14 572a439fe51SSam Ravnborg #define HV_FAULT_TYPE_INV_PGSZ 15 573*75037500SKhalid Aziz #define HV_FAULT_TYPE_MCD 17 574*75037500SKhalid Aziz #define HV_FAULT_TYPE_MCD_DIS 18 575a439fe51SSam Ravnborg /* Values 16 --> -2 are reserved. */ 576a439fe51SSam Ravnborg #define HV_FAULT_TYPE_MULTIPLE -1 577a439fe51SSam Ravnborg 578a439fe51SSam Ravnborg /* Flags argument for mmu_{map,unmap}_addr(), mmu_demap_{page,context,all}(), 579a439fe51SSam Ravnborg * and mmu_{map,unmap}_perm_addr(). 580a439fe51SSam Ravnborg */ 581a439fe51SSam Ravnborg #define HV_MMU_DMMU 0x01 582a439fe51SSam Ravnborg #define HV_MMU_IMMU 0x02 583a439fe51SSam Ravnborg #define HV_MMU_ALL (HV_MMU_DMMU | HV_MMU_IMMU) 584a439fe51SSam Ravnborg 585a439fe51SSam Ravnborg /* mmu_map_addr() 586a439fe51SSam Ravnborg * TRAP: HV_MMU_MAP_ADDR_TRAP 587a439fe51SSam Ravnborg * ARG0: virtual address 588a439fe51SSam Ravnborg * ARG1: mmu context 589a439fe51SSam Ravnborg * ARG2: TTE 590a439fe51SSam Ravnborg * ARG3: flags (HV_MMU_{IMMU,DMMU}) 591a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid virtual address, mmu context, or flags 592a439fe51SSam Ravnborg * EBADPGSZ Invalid page size value 593a439fe51SSam Ravnborg * ENORADDR Invalid real address in TTE 594a439fe51SSam Ravnborg * 595a439fe51SSam Ravnborg * Create a non-permanent mapping using the given TTE, virtual 596a439fe51SSam Ravnborg * address, and mmu context. The flags argument determines which 597a439fe51SSam Ravnborg * (data, or instruction, or both) TLB the mapping gets loaded into. 598a439fe51SSam Ravnborg * 599a439fe51SSam Ravnborg * The behavior is undefined if the valid bit is clear in the TTE. 600a439fe51SSam Ravnborg * 601a439fe51SSam Ravnborg * Note: This API call is for privileged code to specify temporary translation 602a439fe51SSam Ravnborg * mappings without the need to create and manage a TSB. 603a439fe51SSam Ravnborg */ 604a439fe51SSam Ravnborg 605a439fe51SSam Ravnborg /* mmu_unmap_addr() 606a439fe51SSam Ravnborg * TRAP: HV_MMU_UNMAP_ADDR_TRAP 607a439fe51SSam Ravnborg * ARG0: virtual address 608a439fe51SSam Ravnborg * ARG1: mmu context 609a439fe51SSam Ravnborg * ARG2: flags (HV_MMU_{IMMU,DMMU}) 610a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid virtual address, mmu context, or flags 611a439fe51SSam Ravnborg * 612a439fe51SSam Ravnborg * Demaps the given virtual address in the given mmu context on this 613a439fe51SSam Ravnborg * CPU. This function is intended to be used to demap pages mapped 614a439fe51SSam Ravnborg * with mmu_map_addr. This service is equivalent to invoking 615a439fe51SSam Ravnborg * mmu_demap_page() with only the current CPU in the CPU list. The 616a439fe51SSam Ravnborg * flags argument determines which (data, or instruction, or both) TLB 617a439fe51SSam Ravnborg * the mapping gets unmapped from. 618a439fe51SSam Ravnborg * 619a439fe51SSam Ravnborg * Attempting to perform an unmap operation for a previously defined 620a439fe51SSam Ravnborg * permanent mapping will have undefined results. 621a439fe51SSam Ravnborg */ 622a439fe51SSam Ravnborg 623a439fe51SSam Ravnborg /* mmu_tsb_ctx0() 624a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 625a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMU_TSB_CTX0 626a439fe51SSam Ravnborg * ARG0: number of TSB descriptions 627a439fe51SSam Ravnborg * ARG1: TSB descriptions pointer 628a439fe51SSam Ravnborg * RET0: status 629a439fe51SSam Ravnborg * ERRORS: ENORADDR Invalid TSB descriptions pointer or 630a439fe51SSam Ravnborg * TSB base within a descriptor 631a439fe51SSam Ravnborg * EBADALIGN TSB descriptions pointer is not aligned 632a439fe51SSam Ravnborg * to an 8-byte boundary, or TSB base 633a439fe51SSam Ravnborg * within a descriptor is not aligned for 634a439fe51SSam Ravnborg * the given TSB size 635a439fe51SSam Ravnborg * EBADPGSZ Invalid page size in a TSB descriptor 636a439fe51SSam Ravnborg * EBADTSB Invalid associativity or size in a TSB 637a439fe51SSam Ravnborg * descriptor 638a439fe51SSam Ravnborg * EINVAL Invalid number of TSB descriptions, or 639a439fe51SSam Ravnborg * invalid context index in a TSB 640a439fe51SSam Ravnborg * descriptor, or index page size not 641a439fe51SSam Ravnborg * equal to smallest page size in page 642a439fe51SSam Ravnborg * size bitmask field. 643a439fe51SSam Ravnborg * 644a439fe51SSam Ravnborg * Configures the TSBs for the current CPU for virtual addresses with 645a439fe51SSam Ravnborg * context zero. The TSB descriptions pointer is a pointer to an 646a439fe51SSam Ravnborg * array of the given number of TSB descriptions. 647a439fe51SSam Ravnborg * 648a439fe51SSam Ravnborg * Note: The maximum number of TSBs available to a virtual CPU is given by the 649a439fe51SSam Ravnborg * mmu-max-#tsbs property of the cpu's corresponding "cpu" node in the 650a439fe51SSam Ravnborg * machine description. 651a439fe51SSam Ravnborg */ 652a439fe51SSam Ravnborg #define HV_FAST_MMU_TSB_CTX0 0x20 653a439fe51SSam Ravnborg 654a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 655f05a6865SSam Ravnborg unsigned long sun4v_mmu_tsb_ctx0(unsigned long num_descriptions, 656a439fe51SSam Ravnborg unsigned long tsb_desc_ra); 657a439fe51SSam Ravnborg #endif 658a439fe51SSam Ravnborg 659a439fe51SSam Ravnborg /* mmu_tsb_ctxnon0() 660a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 661a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMU_TSB_CTXNON0 662a439fe51SSam Ravnborg * ARG0: number of TSB descriptions 663a439fe51SSam Ravnborg * ARG1: TSB descriptions pointer 664a439fe51SSam Ravnborg * RET0: status 665a439fe51SSam Ravnborg * ERRORS: Same as for mmu_tsb_ctx0() above. 666a439fe51SSam Ravnborg * 667a439fe51SSam Ravnborg * Configures the TSBs for the current CPU for virtual addresses with 668a439fe51SSam Ravnborg * non-zero contexts. The TSB descriptions pointer is a pointer to an 669a439fe51SSam Ravnborg * array of the given number of TSB descriptions. 670a439fe51SSam Ravnborg * 671a439fe51SSam Ravnborg * Note: A maximum of 16 TSBs may be specified in the TSB description list. 672a439fe51SSam Ravnborg */ 673a439fe51SSam Ravnborg #define HV_FAST_MMU_TSB_CTXNON0 0x21 674a439fe51SSam Ravnborg 675a439fe51SSam Ravnborg /* mmu_demap_page() 676a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 677a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMU_DEMAP_PAGE 678a439fe51SSam Ravnborg * ARG0: reserved, must be zero 679a439fe51SSam Ravnborg * ARG1: reserved, must be zero 680a439fe51SSam Ravnborg * ARG2: virtual address 681a439fe51SSam Ravnborg * ARG3: mmu context 682a439fe51SSam Ravnborg * ARG4: flags (HV_MMU_{IMMU,DMMU}) 683a439fe51SSam Ravnborg * RET0: status 68425985edcSLucas De Marchi * ERRORS: EINVAL Invalid virtual address, context, or 685a439fe51SSam Ravnborg * flags value 686a439fe51SSam Ravnborg * ENOTSUPPORTED ARG0 or ARG1 is non-zero 687a439fe51SSam Ravnborg * 688a439fe51SSam Ravnborg * Demaps any page mapping of the given virtual address in the given 689a439fe51SSam Ravnborg * mmu context for the current virtual CPU. Any virtually tagged 690a439fe51SSam Ravnborg * caches are guaranteed to be kept consistent. The flags argument 691a439fe51SSam Ravnborg * determines which TLB (instruction, or data, or both) participate in 692a439fe51SSam Ravnborg * the operation. 693a439fe51SSam Ravnborg * 694a439fe51SSam Ravnborg * ARG0 and ARG1 are both reserved and must be set to zero. 695a439fe51SSam Ravnborg */ 696a439fe51SSam Ravnborg #define HV_FAST_MMU_DEMAP_PAGE 0x22 697a439fe51SSam Ravnborg 698a439fe51SSam Ravnborg /* mmu_demap_ctx() 699a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 700a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMU_DEMAP_CTX 701a439fe51SSam Ravnborg * ARG0: reserved, must be zero 702a439fe51SSam Ravnborg * ARG1: reserved, must be zero 703a439fe51SSam Ravnborg * ARG2: mmu context 704a439fe51SSam Ravnborg * ARG3: flags (HV_MMU_{IMMU,DMMU}) 705a439fe51SSam Ravnborg * RET0: status 706a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid context or flags value 707a439fe51SSam Ravnborg * ENOTSUPPORTED ARG0 or ARG1 is non-zero 708a439fe51SSam Ravnborg * 709a439fe51SSam Ravnborg * Demaps all non-permanent virtual page mappings previously specified 710a439fe51SSam Ravnborg * for the given context for the current virtual CPU. Any virtual 711a439fe51SSam Ravnborg * tagged caches are guaranteed to be kept consistent. The flags 712a439fe51SSam Ravnborg * argument determines which TLB (instruction, or data, or both) 713a439fe51SSam Ravnborg * participate in the operation. 714a439fe51SSam Ravnborg * 715a439fe51SSam Ravnborg * ARG0 and ARG1 are both reserved and must be set to zero. 716a439fe51SSam Ravnborg */ 717a439fe51SSam Ravnborg #define HV_FAST_MMU_DEMAP_CTX 0x23 718a439fe51SSam Ravnborg 719a439fe51SSam Ravnborg /* mmu_demap_all() 720a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 721a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMU_DEMAP_ALL 722a439fe51SSam Ravnborg * ARG0: reserved, must be zero 723a439fe51SSam Ravnborg * ARG1: reserved, must be zero 724a439fe51SSam Ravnborg * ARG2: flags (HV_MMU_{IMMU,DMMU}) 725a439fe51SSam Ravnborg * RET0: status 726a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid flags value 727a439fe51SSam Ravnborg * ENOTSUPPORTED ARG0 or ARG1 is non-zero 728a439fe51SSam Ravnborg * 729a439fe51SSam Ravnborg * Demaps all non-permanent virtual page mappings previously specified 730a439fe51SSam Ravnborg * for the current virtual CPU. Any virtual tagged caches are 731a439fe51SSam Ravnborg * guaranteed to be kept consistent. The flags argument determines 732a439fe51SSam Ravnborg * which TLB (instruction, or data, or both) participate in the 733a439fe51SSam Ravnborg * operation. 734a439fe51SSam Ravnborg * 735a439fe51SSam Ravnborg * ARG0 and ARG1 are both reserved and must be set to zero. 736a439fe51SSam Ravnborg */ 737a439fe51SSam Ravnborg #define HV_FAST_MMU_DEMAP_ALL 0x24 738a439fe51SSam Ravnborg 739a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 740f05a6865SSam Ravnborg void sun4v_mmu_demap_all(void); 741a439fe51SSam Ravnborg #endif 742a439fe51SSam Ravnborg 743a439fe51SSam Ravnborg /* mmu_map_perm_addr() 744a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 745a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMU_MAP_PERM_ADDR 746a439fe51SSam Ravnborg * ARG0: virtual address 747a439fe51SSam Ravnborg * ARG1: reserved, must be zero 748a439fe51SSam Ravnborg * ARG2: TTE 749a439fe51SSam Ravnborg * ARG3: flags (HV_MMU_{IMMU,DMMU}) 750a439fe51SSam Ravnborg * RET0: status 75125985edcSLucas De Marchi * ERRORS: EINVAL Invalid virtual address or flags value 752a439fe51SSam Ravnborg * EBADPGSZ Invalid page size value 753a439fe51SSam Ravnborg * ENORADDR Invalid real address in TTE 754a439fe51SSam Ravnborg * ETOOMANY Too many mappings (max of 8 reached) 755a439fe51SSam Ravnborg * 756a439fe51SSam Ravnborg * Create a permanent mapping using the given TTE and virtual address 757a439fe51SSam Ravnborg * for context 0 on the calling virtual CPU. A maximum of 8 such 758a439fe51SSam Ravnborg * permanent mappings may be specified by privileged code. Mappings 759a439fe51SSam Ravnborg * may be removed with mmu_unmap_perm_addr(). 760a439fe51SSam Ravnborg * 761a439fe51SSam Ravnborg * The behavior is undefined if a TTE with the valid bit clear is given. 762a439fe51SSam Ravnborg * 763a439fe51SSam Ravnborg * Note: This call is used to specify address space mappings for which 764a439fe51SSam Ravnborg * privileged code does not expect to receive misses. For example, 765a439fe51SSam Ravnborg * this mechanism can be used to map kernel nucleus code and data. 766a439fe51SSam Ravnborg */ 767a439fe51SSam Ravnborg #define HV_FAST_MMU_MAP_PERM_ADDR 0x25 768a439fe51SSam Ravnborg 769a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 770f05a6865SSam Ravnborg unsigned long sun4v_mmu_map_perm_addr(unsigned long vaddr, 771a439fe51SSam Ravnborg unsigned long set_to_zero, 772a439fe51SSam Ravnborg unsigned long tte, 773a439fe51SSam Ravnborg unsigned long flags); 774a439fe51SSam Ravnborg #endif 775a439fe51SSam Ravnborg 776a439fe51SSam Ravnborg /* mmu_fault_area_conf() 777a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 778a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMU_FAULT_AREA_CONF 779a439fe51SSam Ravnborg * ARG0: real address 780a439fe51SSam Ravnborg * RET0: status 781a439fe51SSam Ravnborg * RET1: previous mmu fault area real address 782a439fe51SSam Ravnborg * ERRORS: ENORADDR Invalid real address 783a439fe51SSam Ravnborg * EBADALIGN Invalid alignment for fault area 784a439fe51SSam Ravnborg * 785a439fe51SSam Ravnborg * Configure the MMU fault status area for the calling CPU. A 64-byte 786a439fe51SSam Ravnborg * aligned real address specifies where MMU fault status information 787a439fe51SSam Ravnborg * is placed. The return value is the previously specified area, or 0 788a439fe51SSam Ravnborg * for the first invocation. Specifying a fault area at real address 789a439fe51SSam Ravnborg * 0 is not allowed. 790a439fe51SSam Ravnborg */ 791a439fe51SSam Ravnborg #define HV_FAST_MMU_FAULT_AREA_CONF 0x26 792a439fe51SSam Ravnborg 793a439fe51SSam Ravnborg /* mmu_enable() 794a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 795a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMU_ENABLE 796a439fe51SSam Ravnborg * ARG0: enable flag 797a439fe51SSam Ravnborg * ARG1: return target address 798a439fe51SSam Ravnborg * RET0: status 799a439fe51SSam Ravnborg * ERRORS: ENORADDR Invalid real address when disabling 800a439fe51SSam Ravnborg * translation. 801a439fe51SSam Ravnborg * EBADALIGN The return target address is not 802a439fe51SSam Ravnborg * aligned to an instruction. 803a439fe51SSam Ravnborg * EINVAL The enable flag request the current 804a439fe51SSam Ravnborg * operating mode (e.g. disable if already 805a439fe51SSam Ravnborg * disabled) 806a439fe51SSam Ravnborg * 807a439fe51SSam Ravnborg * Enable or disable virtual address translation for the calling CPU 808a439fe51SSam Ravnborg * within the virtual machine domain. If the enable flag is zero, 809a439fe51SSam Ravnborg * translation is disabled, any non-zero value will enable 810a439fe51SSam Ravnborg * translation. 811a439fe51SSam Ravnborg * 812a439fe51SSam Ravnborg * When this function returns, the newly selected translation mode 813a439fe51SSam Ravnborg * will be active. If the mmu is being enabled, then the return 814a439fe51SSam Ravnborg * target address is a virtual address else it is a real address. 815a439fe51SSam Ravnborg * 816a439fe51SSam Ravnborg * Upon successful completion, control will be returned to the given 817a439fe51SSam Ravnborg * return target address (ie. the cpu will jump to that address). On 818a439fe51SSam Ravnborg * failure, the previous mmu mode remains and the trap simply returns 819a439fe51SSam Ravnborg * as normal with the appropriate error code in RET0. 820a439fe51SSam Ravnborg */ 821a439fe51SSam Ravnborg #define HV_FAST_MMU_ENABLE 0x27 822a439fe51SSam Ravnborg 823a439fe51SSam Ravnborg /* mmu_unmap_perm_addr() 824a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 825a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMU_UNMAP_PERM_ADDR 826a439fe51SSam Ravnborg * ARG0: virtual address 827a439fe51SSam Ravnborg * ARG1: reserved, must be zero 828a439fe51SSam Ravnborg * ARG2: flags (HV_MMU_{IMMU,DMMU}) 829a439fe51SSam Ravnborg * RET0: status 83025985edcSLucas De Marchi * ERRORS: EINVAL Invalid virtual address or flags value 831a439fe51SSam Ravnborg * ENOMAP Specified mapping was not found 832a439fe51SSam Ravnborg * 833a439fe51SSam Ravnborg * Demaps any permanent page mapping (established via 834a439fe51SSam Ravnborg * mmu_map_perm_addr()) at the given virtual address for context 0 on 835a439fe51SSam Ravnborg * the current virtual CPU. Any virtual tagged caches are guaranteed 836a439fe51SSam Ravnborg * to be kept consistent. 837a439fe51SSam Ravnborg */ 838a439fe51SSam Ravnborg #define HV_FAST_MMU_UNMAP_PERM_ADDR 0x28 839a439fe51SSam Ravnborg 840a439fe51SSam Ravnborg /* mmu_tsb_ctx0_info() 841a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 842a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMU_TSB_CTX0_INFO 843a439fe51SSam Ravnborg * ARG0: max TSBs 844a439fe51SSam Ravnborg * ARG1: buffer pointer 845a439fe51SSam Ravnborg * RET0: status 846a439fe51SSam Ravnborg * RET1: number of TSBs 847a439fe51SSam Ravnborg * ERRORS: EINVAL Supplied buffer is too small 848a439fe51SSam Ravnborg * EBADALIGN The buffer pointer is badly aligned 849a439fe51SSam Ravnborg * ENORADDR Invalid real address for buffer pointer 850a439fe51SSam Ravnborg * 851a439fe51SSam Ravnborg * Return the TSB configuration as previous defined by mmu_tsb_ctx0() 852a439fe51SSam Ravnborg * into the provided buffer. The size of the buffer is given in ARG1 853a439fe51SSam Ravnborg * in terms of the number of TSB description entries. 854a439fe51SSam Ravnborg * 855a439fe51SSam Ravnborg * Upon return, RET1 always contains the number of TSB descriptions 856a439fe51SSam Ravnborg * previously configured. If zero TSBs were configured, EOK is 857a439fe51SSam Ravnborg * returned with RET1 containing 0. 858a439fe51SSam Ravnborg */ 859a439fe51SSam Ravnborg #define HV_FAST_MMU_TSB_CTX0_INFO 0x29 860a439fe51SSam Ravnborg 861a439fe51SSam Ravnborg /* mmu_tsb_ctxnon0_info() 862a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 863a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMU_TSB_CTXNON0_INFO 864a439fe51SSam Ravnborg * ARG0: max TSBs 865a439fe51SSam Ravnborg * ARG1: buffer pointer 866a439fe51SSam Ravnborg * RET0: status 867a439fe51SSam Ravnborg * RET1: number of TSBs 868a439fe51SSam Ravnborg * ERRORS: EINVAL Supplied buffer is too small 869a439fe51SSam Ravnborg * EBADALIGN The buffer pointer is badly aligned 870a439fe51SSam Ravnborg * ENORADDR Invalid real address for buffer pointer 871a439fe51SSam Ravnborg * 872a439fe51SSam Ravnborg * Return the TSB configuration as previous defined by 873a439fe51SSam Ravnborg * mmu_tsb_ctxnon0() into the provided buffer. The size of the buffer 874a439fe51SSam Ravnborg * is given in ARG1 in terms of the number of TSB description entries. 875a439fe51SSam Ravnborg * 876a439fe51SSam Ravnborg * Upon return, RET1 always contains the number of TSB descriptions 877a439fe51SSam Ravnborg * previously configured. If zero TSBs were configured, EOK is 878a439fe51SSam Ravnborg * returned with RET1 containing 0. 879a439fe51SSam Ravnborg */ 880a439fe51SSam Ravnborg #define HV_FAST_MMU_TSB_CTXNON0_INFO 0x2a 881a439fe51SSam Ravnborg 882a439fe51SSam Ravnborg /* mmu_fault_area_info() 883a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 884a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMU_FAULT_AREA_INFO 885a439fe51SSam Ravnborg * RET0: status 886a439fe51SSam Ravnborg * RET1: fault area real address 887a439fe51SSam Ravnborg * ERRORS: No errors defined. 888a439fe51SSam Ravnborg * 889a439fe51SSam Ravnborg * Return the currently defined MMU fault status area for the current 890a439fe51SSam Ravnborg * CPU. The real address of the fault status area is returned in 891a439fe51SSam Ravnborg * RET1, or 0 is returned in RET1 if no fault status area is defined. 892a439fe51SSam Ravnborg * 893a439fe51SSam Ravnborg * Note: mmu_fault_area_conf() may be called with the return value (RET1) 894a439fe51SSam Ravnborg * from this service if there is a need to save and restore the fault 895a439fe51SSam Ravnborg * area for a cpu. 896a439fe51SSam Ravnborg */ 897a439fe51SSam Ravnborg #define HV_FAST_MMU_FAULT_AREA_INFO 0x2b 898a439fe51SSam Ravnborg 899a439fe51SSam Ravnborg /* Cache and Memory services. */ 900a439fe51SSam Ravnborg 901a439fe51SSam Ravnborg /* mem_scrub() 902a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 903a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MEM_SCRUB 904a439fe51SSam Ravnborg * ARG0: real address 905a439fe51SSam Ravnborg * ARG1: length 906a439fe51SSam Ravnborg * RET0: status 907a439fe51SSam Ravnborg * RET1: length scrubbed 908a439fe51SSam Ravnborg * ERRORS: ENORADDR Invalid real address 909a439fe51SSam Ravnborg * EBADALIGN Start address or length are not correctly 910a439fe51SSam Ravnborg * aligned 911a439fe51SSam Ravnborg * EINVAL Length is zero 912a439fe51SSam Ravnborg * 913a439fe51SSam Ravnborg * Zero the memory contents in the range real address to real address 914a439fe51SSam Ravnborg * plus length minus 1. Also, valid ECC will be generated for that 915a439fe51SSam Ravnborg * memory address range. Scrubbing is started at the given real 916a439fe51SSam Ravnborg * address, but may not scrub the entire given length. The actual 917a439fe51SSam Ravnborg * length scrubbed will be returned in RET1. 918a439fe51SSam Ravnborg * 919a439fe51SSam Ravnborg * The real address and length must be aligned on an 8K boundary, or 920a439fe51SSam Ravnborg * contain the start address and length from a sun4v error report. 921a439fe51SSam Ravnborg * 922a439fe51SSam Ravnborg * Note: There are two uses for this function. The first use is to block clear 923a439fe51SSam Ravnborg * and initialize memory and the second is to scrub an u ncorrectable 924a439fe51SSam Ravnborg * error reported via a resumable or non-resumable trap. The second 925a439fe51SSam Ravnborg * use requires the arguments to be equal to the real address and length 926a439fe51SSam Ravnborg * provided in a sun4v memory error report. 927a439fe51SSam Ravnborg */ 928a439fe51SSam Ravnborg #define HV_FAST_MEM_SCRUB 0x31 929a439fe51SSam Ravnborg 930a439fe51SSam Ravnborg /* mem_sync() 931a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 932a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MEM_SYNC 933a439fe51SSam Ravnborg * ARG0: real address 934a439fe51SSam Ravnborg * ARG1: length 935a439fe51SSam Ravnborg * RET0: status 936a439fe51SSam Ravnborg * RET1: length synced 937a439fe51SSam Ravnborg * ERRORS: ENORADDR Invalid real address 938a439fe51SSam Ravnborg * EBADALIGN Start address or length are not correctly 939a439fe51SSam Ravnborg * aligned 940a439fe51SSam Ravnborg * EINVAL Length is zero 941a439fe51SSam Ravnborg * 942a439fe51SSam Ravnborg * Force the next access within the real address to real address plus 943a439fe51SSam Ravnborg * length minus 1 to be fetches from main system memory. Less than 944a439fe51SSam Ravnborg * the given length may be synced, the actual amount synced is 945a439fe51SSam Ravnborg * returned in RET1. The real address and length must be aligned on 946a439fe51SSam Ravnborg * an 8K boundary. 947a439fe51SSam Ravnborg */ 948a439fe51SSam Ravnborg #define HV_FAST_MEM_SYNC 0x32 949a439fe51SSam Ravnborg 950c2b5934fSRob Gardner /* Coprocessor services 951c2b5934fSRob Gardner * 952c2b5934fSRob Gardner * M7 and later processors provide an on-chip coprocessor which 953c2b5934fSRob Gardner * accelerates database operations, and is known internally as 954c2b5934fSRob Gardner * DAX. 955c2b5934fSRob Gardner */ 956c2b5934fSRob Gardner 957c2b5934fSRob Gardner /* ccb_submit() 958c2b5934fSRob Gardner * TRAP: HV_FAST_TRAP 959c2b5934fSRob Gardner * FUNCTION: HV_CCB_SUBMIT 960c2b5934fSRob Gardner * ARG0: address of CCB array 961c2b5934fSRob Gardner * ARG1: size (in bytes) of CCB array being submitted 962c2b5934fSRob Gardner * ARG2: flags 963c2b5934fSRob Gardner * ARG3: reserved 964c2b5934fSRob Gardner * RET0: status (success or error code) 965c2b5934fSRob Gardner * RET1: size (in bytes) of CCB array that was accepted (might be less 966c2b5934fSRob Gardner * than arg1) 967c2b5934fSRob Gardner * RET2: status data 968c2b5934fSRob Gardner * if status == ENOMAP or ENOACCESS, identifies the VA in question 969c2b5934fSRob Gardner * if status == EUNAVAILBLE, unavailable code 970c2b5934fSRob Gardner * RET3: reserved 971c2b5934fSRob Gardner * 972c2b5934fSRob Gardner * ERRORS: EOK successful submission (check size) 973c2b5934fSRob Gardner * EWOULDBLOCK could not finish submissions, try again 974c2b5934fSRob Gardner * EBADALIGN array not 64B aligned or size not 64B multiple 975c2b5934fSRob Gardner * ENORADDR invalid RA for array or in CCB 976c2b5934fSRob Gardner * ENOMAP could not translate address (see status data) 977c2b5934fSRob Gardner * EINVAL invalid ccb or arguments 978c2b5934fSRob Gardner * ETOOMANY too many ccbs with all-or-nothing flag 979c2b5934fSRob Gardner * ENOACCESS guest has no access to submit ccbs or address 980c2b5934fSRob Gardner * in CCB does not have correct permissions (check 981c2b5934fSRob Gardner * status data) 982c2b5934fSRob Gardner * EUNAVAILABLE ccb operation could not be performed at this 983c2b5934fSRob Gardner * time (check status data) 984c2b5934fSRob Gardner * Status data codes: 985c2b5934fSRob Gardner * 0 - exact CCB could not be executed 986c2b5934fSRob Gardner * 1 - CCB opcode cannot be executed 987c2b5934fSRob Gardner * 2 - CCB version cannot be executed 988c2b5934fSRob Gardner * 3 - vcpu cannot execute CCBs 989c2b5934fSRob Gardner * 4 - no CCBs can be executed 990c2b5934fSRob Gardner */ 991c2b5934fSRob Gardner 992c2b5934fSRob Gardner #define HV_CCB_SUBMIT 0x34 993c2b5934fSRob Gardner #ifndef __ASSEMBLY__ 994c2b5934fSRob Gardner unsigned long sun4v_ccb_submit(unsigned long ccb_buf, 995c2b5934fSRob Gardner unsigned long len, 996c2b5934fSRob Gardner unsigned long flags, 997c2b5934fSRob Gardner unsigned long reserved, 998c2b5934fSRob Gardner void *submitted_len, 999c2b5934fSRob Gardner void *status_data); 1000c2b5934fSRob Gardner #endif 1001c2b5934fSRob Gardner 1002c2b5934fSRob Gardner /* flags (ARG2) */ 1003c2b5934fSRob Gardner #define HV_CCB_QUERY_CMD BIT(1) 1004c2b5934fSRob Gardner #define HV_CCB_ARG0_TYPE_REAL 0UL 1005c2b5934fSRob Gardner #define HV_CCB_ARG0_TYPE_PRIMARY BIT(4) 1006c2b5934fSRob Gardner #define HV_CCB_ARG0_TYPE_SECONDARY BIT(5) 1007c2b5934fSRob Gardner #define HV_CCB_ARG0_TYPE_NUCLEUS GENMASK(5, 4) 1008c2b5934fSRob Gardner #define HV_CCB_ARG0_PRIVILEGED BIT(6) 1009c2b5934fSRob Gardner #define HV_CCB_ALL_OR_NOTHING BIT(7) 1010c2b5934fSRob Gardner #define HV_CCB_QUEUE_INFO BIT(8) 1011c2b5934fSRob Gardner #define HV_CCB_VA_REJECT 0UL 1012c2b5934fSRob Gardner #define HV_CCB_VA_SECONDARY BIT(13) 1013c2b5934fSRob Gardner #define HV_CCB_VA_NUCLEUS GENMASK(13, 12) 1014c2b5934fSRob Gardner #define HV_CCB_VA_PRIVILEGED BIT(14) 1015c2b5934fSRob Gardner #define HV_CCB_VA_READ_ADI_DISABLE BIT(15) /* DAX2 only */ 1016c2b5934fSRob Gardner 1017c2b5934fSRob Gardner /* ccb_info() 1018c2b5934fSRob Gardner * TRAP: HV_FAST_TRAP 1019c2b5934fSRob Gardner * FUNCTION: HV_CCB_INFO 1020c2b5934fSRob Gardner * ARG0: real address of CCB completion area 1021c2b5934fSRob Gardner * RET0: status (success or error code) 1022c2b5934fSRob Gardner * RET1: info array 1023c2b5934fSRob Gardner * - RET1[0]: CCB state 1024c2b5934fSRob Gardner * - RET1[1]: dax unit 1025c2b5934fSRob Gardner * - RET1[2]: queue number 1026c2b5934fSRob Gardner * - RET1[3]: queue position 1027c2b5934fSRob Gardner * 1028c2b5934fSRob Gardner * ERRORS: EOK operation successful 1029c2b5934fSRob Gardner * EBADALIGN address not 64B aligned 1030c2b5934fSRob Gardner * ENORADDR RA in address not valid 1031c2b5934fSRob Gardner * EINVAL CA not valid 1032c2b5934fSRob Gardner * EWOULDBLOCK info not available for this CCB currently, try 1033c2b5934fSRob Gardner * again 1034c2b5934fSRob Gardner * ENOACCESS guest cannot use dax 1035c2b5934fSRob Gardner */ 1036c2b5934fSRob Gardner 1037c2b5934fSRob Gardner #define HV_CCB_INFO 0x35 1038c2b5934fSRob Gardner #ifndef __ASSEMBLY__ 1039c2b5934fSRob Gardner unsigned long sun4v_ccb_info(unsigned long ca, 1040c2b5934fSRob Gardner void *info_arr); 1041c2b5934fSRob Gardner #endif 1042c2b5934fSRob Gardner 1043c2b5934fSRob Gardner /* info array byte offsets (RET1) */ 1044c2b5934fSRob Gardner #define CCB_INFO_OFFSET_CCB_STATE 0 1045c2b5934fSRob Gardner #define CCB_INFO_OFFSET_DAX_UNIT 2 1046c2b5934fSRob Gardner #define CCB_INFO_OFFSET_QUEUE_NUM 4 1047c2b5934fSRob Gardner #define CCB_INFO_OFFSET_QUEUE_POS 6 1048c2b5934fSRob Gardner 1049c2b5934fSRob Gardner /* CCB state (RET1[0]) */ 1050c2b5934fSRob Gardner #define HV_CCB_STATE_COMPLETED 0 1051c2b5934fSRob Gardner #define HV_CCB_STATE_ENQUEUED 1 1052c2b5934fSRob Gardner #define HV_CCB_STATE_INPROGRESS 2 1053c2b5934fSRob Gardner #define HV_CCB_STATE_NOTFOUND 3 1054c2b5934fSRob Gardner 1055c2b5934fSRob Gardner /* ccb_kill() 1056c2b5934fSRob Gardner * TRAP: HV_FAST_TRAP 1057c2b5934fSRob Gardner * FUNCTION: HV_CCB_KILL 1058c2b5934fSRob Gardner * ARG0: real address of CCB completion area 1059c2b5934fSRob Gardner * RET0: status (success or error code) 1060c2b5934fSRob Gardner * RET1: CCB kill status 1061c2b5934fSRob Gardner * 1062c2b5934fSRob Gardner * ERRORS: EOK operation successful 1063c2b5934fSRob Gardner * EBADALIGN address not 64B aligned 1064c2b5934fSRob Gardner * ENORADDR RA in address not valid 1065c2b5934fSRob Gardner * EINVAL CA not valid 1066c2b5934fSRob Gardner * EWOULDBLOCK kill not available for this CCB currently, try 1067c2b5934fSRob Gardner * again 1068c2b5934fSRob Gardner * ENOACCESS guest cannot use dax 1069c2b5934fSRob Gardner */ 1070c2b5934fSRob Gardner 1071c2b5934fSRob Gardner #define HV_CCB_KILL 0x36 1072c2b5934fSRob Gardner #ifndef __ASSEMBLY__ 1073c2b5934fSRob Gardner unsigned long sun4v_ccb_kill(unsigned long ca, 1074c2b5934fSRob Gardner void *kill_status); 1075c2b5934fSRob Gardner #endif 1076c2b5934fSRob Gardner 1077c2b5934fSRob Gardner /* CCB kill status (RET1) */ 1078c2b5934fSRob Gardner #define HV_CCB_KILL_COMPLETED 0 1079c2b5934fSRob Gardner #define HV_CCB_KILL_DEQUEUED 1 1080c2b5934fSRob Gardner #define HV_CCB_KILL_KILLED 2 1081c2b5934fSRob Gardner #define HV_CCB_KILL_NOTFOUND 3 1082c2b5934fSRob Gardner 1083a439fe51SSam Ravnborg /* Time of day services. 1084a439fe51SSam Ravnborg * 1085a439fe51SSam Ravnborg * The hypervisor maintains the time of day on a per-domain basis. 1086a439fe51SSam Ravnborg * Changing the time of day in one domain does not affect the time of 1087a439fe51SSam Ravnborg * day on any other domain. 1088a439fe51SSam Ravnborg * 1089a439fe51SSam Ravnborg * Time is described by a single unsigned 64-bit word which is the 1090a439fe51SSam Ravnborg * number of seconds since the UNIX Epoch (00:00:00 UTC, January 1, 1091a439fe51SSam Ravnborg * 1970). 1092a439fe51SSam Ravnborg */ 1093a439fe51SSam Ravnborg 1094a439fe51SSam Ravnborg /* tod_get() 1095a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1096a439fe51SSam Ravnborg * FUNCTION: HV_FAST_TOD_GET 1097a439fe51SSam Ravnborg * RET0: status 1098a439fe51SSam Ravnborg * RET1: TOD 1099a439fe51SSam Ravnborg * ERRORS: EWOULDBLOCK TOD resource is temporarily unavailable 1100a439fe51SSam Ravnborg * ENOTSUPPORTED If TOD not supported on this platform 1101a439fe51SSam Ravnborg * 1102a439fe51SSam Ravnborg * Return the current time of day. May block if TOD access is 1103a439fe51SSam Ravnborg * temporarily not possible. 1104a439fe51SSam Ravnborg */ 1105a439fe51SSam Ravnborg #define HV_FAST_TOD_GET 0x50 1106a439fe51SSam Ravnborg 1107a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1108f05a6865SSam Ravnborg unsigned long sun4v_tod_get(unsigned long *time); 1109a439fe51SSam Ravnborg #endif 1110a439fe51SSam Ravnborg 1111a439fe51SSam Ravnborg /* tod_set() 1112a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1113a439fe51SSam Ravnborg * FUNCTION: HV_FAST_TOD_SET 1114a439fe51SSam Ravnborg * ARG0: TOD 1115a439fe51SSam Ravnborg * RET0: status 1116a439fe51SSam Ravnborg * ERRORS: EWOULDBLOCK TOD resource is temporarily unavailable 1117a439fe51SSam Ravnborg * ENOTSUPPORTED If TOD not supported on this platform 1118a439fe51SSam Ravnborg * 1119a439fe51SSam Ravnborg * The current time of day is set to the value specified in ARG0. May 1120a439fe51SSam Ravnborg * block if TOD access is temporarily not possible. 1121a439fe51SSam Ravnborg */ 1122a439fe51SSam Ravnborg #define HV_FAST_TOD_SET 0x51 1123a439fe51SSam Ravnborg 1124a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1125f05a6865SSam Ravnborg unsigned long sun4v_tod_set(unsigned long time); 1126a439fe51SSam Ravnborg #endif 1127a439fe51SSam Ravnborg 1128a439fe51SSam Ravnborg /* Console services */ 1129a439fe51SSam Ravnborg 1130a439fe51SSam Ravnborg /* con_getchar() 1131a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1132a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CONS_GETCHAR 1133a439fe51SSam Ravnborg * RET0: status 1134a439fe51SSam Ravnborg * RET1: character 1135a439fe51SSam Ravnborg * ERRORS: EWOULDBLOCK No character available. 1136a439fe51SSam Ravnborg * 1137a439fe51SSam Ravnborg * Returns a character from the console device. If no character is 1138a439fe51SSam Ravnborg * available then an EWOULDBLOCK error is returned. If a character is 1139a439fe51SSam Ravnborg * available, then the returned status is EOK and the character value 1140a439fe51SSam Ravnborg * is in RET1. 1141a439fe51SSam Ravnborg * 1142a439fe51SSam Ravnborg * A virtual BREAK is represented by the 64-bit value -1. 1143a439fe51SSam Ravnborg * 1144a439fe51SSam Ravnborg * A virtual HUP signal is represented by the 64-bit value -2. 1145a439fe51SSam Ravnborg */ 1146a439fe51SSam Ravnborg #define HV_FAST_CONS_GETCHAR 0x60 1147a439fe51SSam Ravnborg 1148a439fe51SSam Ravnborg /* con_putchar() 1149a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1150a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CONS_PUTCHAR 1151a439fe51SSam Ravnborg * ARG0: character 1152a439fe51SSam Ravnborg * RET0: status 1153a439fe51SSam Ravnborg * ERRORS: EINVAL Illegal character 1154a439fe51SSam Ravnborg * EWOULDBLOCK Output buffer currently full, would block 1155a439fe51SSam Ravnborg * 1156a439fe51SSam Ravnborg * Send a character to the console device. Only character values 1157a439fe51SSam Ravnborg * between 0 and 255 may be used. Values outside this range are 1158a439fe51SSam Ravnborg * invalid except for the 64-bit value -1 which is used to send a 1159a439fe51SSam Ravnborg * virtual BREAK. 1160a439fe51SSam Ravnborg */ 1161a439fe51SSam Ravnborg #define HV_FAST_CONS_PUTCHAR 0x61 1162a439fe51SSam Ravnborg 1163a439fe51SSam Ravnborg /* con_read() 1164a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1165a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CONS_READ 1166a439fe51SSam Ravnborg * ARG0: buffer real address 1167a439fe51SSam Ravnborg * ARG1: buffer size in bytes 1168a439fe51SSam Ravnborg * RET0: status 1169a439fe51SSam Ravnborg * RET1: bytes read or BREAK or HUP 1170a439fe51SSam Ravnborg * ERRORS: EWOULDBLOCK No character available. 1171a439fe51SSam Ravnborg * 1172a439fe51SSam Ravnborg * Reads characters into a buffer from the console device. If no 1173a439fe51SSam Ravnborg * character is available then an EWOULDBLOCK error is returned. 1174a439fe51SSam Ravnborg * If a character is available, then the returned status is EOK 1175a439fe51SSam Ravnborg * and the number of bytes read into the given buffer is provided 1176a439fe51SSam Ravnborg * in RET1. 1177a439fe51SSam Ravnborg * 1178a439fe51SSam Ravnborg * A virtual BREAK is represented by the 64-bit RET1 value -1. 1179a439fe51SSam Ravnborg * 1180a439fe51SSam Ravnborg * A virtual HUP signal is represented by the 64-bit RET1 value -2. 1181a439fe51SSam Ravnborg * 1182a439fe51SSam Ravnborg * If BREAK or HUP are indicated, no bytes were read into buffer. 1183a439fe51SSam Ravnborg */ 1184a439fe51SSam Ravnborg #define HV_FAST_CONS_READ 0x62 1185a439fe51SSam Ravnborg 1186a439fe51SSam Ravnborg /* con_write() 1187a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1188a439fe51SSam Ravnborg * FUNCTION: HV_FAST_CONS_WRITE 1189a439fe51SSam Ravnborg * ARG0: buffer real address 1190a439fe51SSam Ravnborg * ARG1: buffer size in bytes 1191a439fe51SSam Ravnborg * RET0: status 1192a439fe51SSam Ravnborg * RET1: bytes written 1193a439fe51SSam Ravnborg * ERRORS: EWOULDBLOCK Output buffer currently full, would block 1194a439fe51SSam Ravnborg * 1195a439fe51SSam Ravnborg * Send a characters in buffer to the console device. Breaks must be 1196a439fe51SSam Ravnborg * sent using con_putchar(). 1197a439fe51SSam Ravnborg */ 1198a439fe51SSam Ravnborg #define HV_FAST_CONS_WRITE 0x63 1199a439fe51SSam Ravnborg 1200a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1201f05a6865SSam Ravnborg long sun4v_con_getchar(long *status); 1202f05a6865SSam Ravnborg long sun4v_con_putchar(long c); 1203f05a6865SSam Ravnborg long sun4v_con_read(unsigned long buffer, 1204a439fe51SSam Ravnborg unsigned long size, 1205a439fe51SSam Ravnborg unsigned long *bytes_read); 1206f05a6865SSam Ravnborg unsigned long sun4v_con_write(unsigned long buffer, 1207a439fe51SSam Ravnborg unsigned long size, 1208a439fe51SSam Ravnborg unsigned long *bytes_written); 1209a439fe51SSam Ravnborg #endif 1210a439fe51SSam Ravnborg 1211a439fe51SSam Ravnborg /* mach_set_soft_state() 1212a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1213a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MACH_SET_SOFT_STATE 1214a439fe51SSam Ravnborg * ARG0: software state 1215a439fe51SSam Ravnborg * ARG1: software state description pointer 1216a439fe51SSam Ravnborg * RET0: status 1217a439fe51SSam Ravnborg * ERRORS: EINVAL software state not valid or software state 1218a439fe51SSam Ravnborg * description is not NULL terminated 1219a439fe51SSam Ravnborg * ENORADDR software state description pointer is not a 1220a439fe51SSam Ravnborg * valid real address 1221a439fe51SSam Ravnborg * EBADALIGNED software state description is not correctly 1222a439fe51SSam Ravnborg * aligned 1223a439fe51SSam Ravnborg * 1224a439fe51SSam Ravnborg * This allows the guest to report it's soft state to the hypervisor. There 1225a439fe51SSam Ravnborg * are two primary components to this state. The first part states whether 1226a439fe51SSam Ravnborg * the guest software is running or not. The second containts optional 1227a439fe51SSam Ravnborg * details specific to the software. 1228a439fe51SSam Ravnborg * 1229a439fe51SSam Ravnborg * The software state argument is defined below in HV_SOFT_STATE_*, and 1230a439fe51SSam Ravnborg * indicates whether the guest is operating normally or in a transitional 1231a439fe51SSam Ravnborg * state. 1232a439fe51SSam Ravnborg * 1233a439fe51SSam Ravnborg * The software state description argument is a real address of a data buffer 1234a439fe51SSam Ravnborg * of size 32-bytes aligned on a 32-byte boundary. It is treated as a NULL 1235a439fe51SSam Ravnborg * terminated 7-bit ASCII string of up to 31 characters not including the 1236a439fe51SSam Ravnborg * NULL termination. 1237a439fe51SSam Ravnborg */ 1238a439fe51SSam Ravnborg #define HV_FAST_MACH_SET_SOFT_STATE 0x70 1239a439fe51SSam Ravnborg #define HV_SOFT_STATE_NORMAL 0x01 1240a439fe51SSam Ravnborg #define HV_SOFT_STATE_TRANSITION 0x02 1241a439fe51SSam Ravnborg 1242a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1243f05a6865SSam Ravnborg unsigned long sun4v_mach_set_soft_state(unsigned long soft_state, 1244a439fe51SSam Ravnborg unsigned long msg_string_ra); 1245a439fe51SSam Ravnborg #endif 1246a439fe51SSam Ravnborg 1247a439fe51SSam Ravnborg /* mach_get_soft_state() 1248a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1249a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MACH_GET_SOFT_STATE 1250a439fe51SSam Ravnborg * ARG0: software state description pointer 1251a439fe51SSam Ravnborg * RET0: status 1252a439fe51SSam Ravnborg * RET1: software state 1253a439fe51SSam Ravnborg * ERRORS: ENORADDR software state description pointer is not a 1254a439fe51SSam Ravnborg * valid real address 1255a439fe51SSam Ravnborg * EBADALIGNED software state description is not correctly 1256a439fe51SSam Ravnborg * aligned 1257a439fe51SSam Ravnborg * 1258a439fe51SSam Ravnborg * Retrieve the current value of the guest's software state. The rules 1259a439fe51SSam Ravnborg * for the software state pointer are the same as for mach_set_soft_state() 1260a439fe51SSam Ravnborg * above. 1261a439fe51SSam Ravnborg */ 1262a439fe51SSam Ravnborg #define HV_FAST_MACH_GET_SOFT_STATE 0x71 1263a439fe51SSam Ravnborg 1264a439fe51SSam Ravnborg /* svc_send() 1265a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1266a439fe51SSam Ravnborg * FUNCTION: HV_FAST_SVC_SEND 1267a439fe51SSam Ravnborg * ARG0: service ID 1268a439fe51SSam Ravnborg * ARG1: buffer real address 1269a439fe51SSam Ravnborg * ARG2: buffer size 1270a439fe51SSam Ravnborg * RET0: STATUS 1271a439fe51SSam Ravnborg * RET1: sent_bytes 1272a439fe51SSam Ravnborg * 1273a439fe51SSam Ravnborg * Be careful, all output registers are clobbered by this operation, 1274a439fe51SSam Ravnborg * so for example it is not possible to save away a value in %o4 1275a439fe51SSam Ravnborg * across the trap. 1276a439fe51SSam Ravnborg */ 1277a439fe51SSam Ravnborg #define HV_FAST_SVC_SEND 0x80 1278a439fe51SSam Ravnborg 1279a439fe51SSam Ravnborg /* svc_recv() 1280a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1281a439fe51SSam Ravnborg * FUNCTION: HV_FAST_SVC_RECV 1282a439fe51SSam Ravnborg * ARG0: service ID 1283a439fe51SSam Ravnborg * ARG1: buffer real address 1284a439fe51SSam Ravnborg * ARG2: buffer size 1285a439fe51SSam Ravnborg * RET0: STATUS 1286a439fe51SSam Ravnborg * RET1: recv_bytes 1287a439fe51SSam Ravnborg * 1288a439fe51SSam Ravnborg * Be careful, all output registers are clobbered by this operation, 1289a439fe51SSam Ravnborg * so for example it is not possible to save away a value in %o4 1290a439fe51SSam Ravnborg * across the trap. 1291a439fe51SSam Ravnborg */ 1292a439fe51SSam Ravnborg #define HV_FAST_SVC_RECV 0x81 1293a439fe51SSam Ravnborg 1294a439fe51SSam Ravnborg /* svc_getstatus() 1295a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1296a439fe51SSam Ravnborg * FUNCTION: HV_FAST_SVC_GETSTATUS 1297a439fe51SSam Ravnborg * ARG0: service ID 1298a439fe51SSam Ravnborg * RET0: STATUS 1299a439fe51SSam Ravnborg * RET1: status bits 1300a439fe51SSam Ravnborg */ 1301a439fe51SSam Ravnborg #define HV_FAST_SVC_GETSTATUS 0x82 1302a439fe51SSam Ravnborg 1303a439fe51SSam Ravnborg /* svc_setstatus() 1304a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1305a439fe51SSam Ravnborg * FUNCTION: HV_FAST_SVC_SETSTATUS 1306a439fe51SSam Ravnborg * ARG0: service ID 1307a439fe51SSam Ravnborg * ARG1: bits to set 1308a439fe51SSam Ravnborg * RET0: STATUS 1309a439fe51SSam Ravnborg */ 1310a439fe51SSam Ravnborg #define HV_FAST_SVC_SETSTATUS 0x83 1311a439fe51SSam Ravnborg 1312a439fe51SSam Ravnborg /* svc_clrstatus() 1313a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1314a439fe51SSam Ravnborg * FUNCTION: HV_FAST_SVC_CLRSTATUS 1315a439fe51SSam Ravnborg * ARG0: service ID 1316a439fe51SSam Ravnborg * ARG1: bits to clear 1317a439fe51SSam Ravnborg * RET0: STATUS 1318a439fe51SSam Ravnborg */ 1319a439fe51SSam Ravnborg #define HV_FAST_SVC_CLRSTATUS 0x84 1320a439fe51SSam Ravnborg 1321a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1322f05a6865SSam Ravnborg unsigned long sun4v_svc_send(unsigned long svc_id, 1323a439fe51SSam Ravnborg unsigned long buffer, 1324a439fe51SSam Ravnborg unsigned long buffer_size, 1325a439fe51SSam Ravnborg unsigned long *sent_bytes); 1326f05a6865SSam Ravnborg unsigned long sun4v_svc_recv(unsigned long svc_id, 1327a439fe51SSam Ravnborg unsigned long buffer, 1328a439fe51SSam Ravnborg unsigned long buffer_size, 1329a439fe51SSam Ravnborg unsigned long *recv_bytes); 1330f05a6865SSam Ravnborg unsigned long sun4v_svc_getstatus(unsigned long svc_id, 1331a439fe51SSam Ravnborg unsigned long *status_bits); 1332f05a6865SSam Ravnborg unsigned long sun4v_svc_setstatus(unsigned long svc_id, 1333a439fe51SSam Ravnborg unsigned long status_bits); 1334f05a6865SSam Ravnborg unsigned long sun4v_svc_clrstatus(unsigned long svc_id, 1335a439fe51SSam Ravnborg unsigned long status_bits); 1336a439fe51SSam Ravnborg #endif 1337a439fe51SSam Ravnborg 1338a439fe51SSam Ravnborg /* Trap trace services. 1339a439fe51SSam Ravnborg * 1340a439fe51SSam Ravnborg * The hypervisor provides a trap tracing capability for privileged 1341a439fe51SSam Ravnborg * code running on each virtual CPU. Privileged code provides a 1342a439fe51SSam Ravnborg * round-robin trap trace queue within which the hypervisor writes 1343a439fe51SSam Ravnborg * 64-byte entries detailing hyperprivileged traps taken n behalf of 1344a439fe51SSam Ravnborg * privileged code. This is provided as a debugging capability for 1345a439fe51SSam Ravnborg * privileged code. 1346a439fe51SSam Ravnborg * 1347a439fe51SSam Ravnborg * The trap trace control structure is 64-bytes long and placed at the 1348a439fe51SSam Ravnborg * start (offset 0) of the trap trace buffer, and is described as 1349a439fe51SSam Ravnborg * follows: 1350a439fe51SSam Ravnborg */ 1351a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1352a439fe51SSam Ravnborg struct hv_trap_trace_control { 1353a439fe51SSam Ravnborg unsigned long head_offset; 1354a439fe51SSam Ravnborg unsigned long tail_offset; 1355a439fe51SSam Ravnborg unsigned long __reserved[0x30 / sizeof(unsigned long)]; 1356a439fe51SSam Ravnborg }; 1357a439fe51SSam Ravnborg #endif 1358a439fe51SSam Ravnborg #define HV_TRAP_TRACE_CTRL_HEAD_OFFSET 0x00 1359a439fe51SSam Ravnborg #define HV_TRAP_TRACE_CTRL_TAIL_OFFSET 0x08 1360a439fe51SSam Ravnborg 1361a439fe51SSam Ravnborg /* The head offset is the offset of the most recently completed entry 1362a439fe51SSam Ravnborg * in the trap-trace buffer. The tail offset is the offset of the 1363a439fe51SSam Ravnborg * next entry to be written. The control structure is owned and 1364a439fe51SSam Ravnborg * modified by the hypervisor. A guest may not modify the control 1365a439fe51SSam Ravnborg * structure contents. Attempts to do so will result in undefined 1366a439fe51SSam Ravnborg * behavior for the guest. 1367a439fe51SSam Ravnborg * 136825985edcSLucas De Marchi * Each trap trace buffer entry is laid out as follows: 1369a439fe51SSam Ravnborg */ 1370a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1371a439fe51SSam Ravnborg struct hv_trap_trace_entry { 1372a439fe51SSam Ravnborg unsigned char type; /* Hypervisor or guest entry? */ 1373a439fe51SSam Ravnborg unsigned char hpstate; /* Hyper-privileged state */ 1374a439fe51SSam Ravnborg unsigned char tl; /* Trap level */ 1375a439fe51SSam Ravnborg unsigned char gl; /* Global register level */ 1376a439fe51SSam Ravnborg unsigned short tt; /* Trap type */ 1377a439fe51SSam Ravnborg unsigned short tag; /* Extended trap identifier */ 1378a439fe51SSam Ravnborg unsigned long tstate; /* Trap state */ 1379a439fe51SSam Ravnborg unsigned long tick; /* Tick */ 1380a439fe51SSam Ravnborg unsigned long tpc; /* Trap PC */ 1381a439fe51SSam Ravnborg unsigned long f1; /* Entry specific */ 1382a439fe51SSam Ravnborg unsigned long f2; /* Entry specific */ 1383a439fe51SSam Ravnborg unsigned long f3; /* Entry specific */ 1384a439fe51SSam Ravnborg unsigned long f4; /* Entry specific */ 1385a439fe51SSam Ravnborg }; 1386a439fe51SSam Ravnborg #endif 1387a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_TYPE 0x00 1388a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_HPSTATE 0x01 1389a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_TL 0x02 1390a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_GL 0x03 1391a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_TT 0x04 1392a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_TAG 0x06 1393a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_TSTATE 0x08 1394a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_TICK 0x10 1395a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_TPC 0x18 1396a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_F1 0x20 1397a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_F2 0x28 1398a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_F3 0x30 1399a439fe51SSam Ravnborg #define HV_TRAP_TRACE_ENTRY_F4 0x38 1400a439fe51SSam Ravnborg 1401a439fe51SSam Ravnborg /* The type field is encoded as follows. */ 1402a439fe51SSam Ravnborg #define HV_TRAP_TYPE_UNDEF 0x00 /* Entry content undefined */ 1403a439fe51SSam Ravnborg #define HV_TRAP_TYPE_HV 0x01 /* Hypervisor trap entry */ 1404a439fe51SSam Ravnborg #define HV_TRAP_TYPE_GUEST 0xff /* Added via ttrace_addentry() */ 1405a439fe51SSam Ravnborg 1406a439fe51SSam Ravnborg /* ttrace_buf_conf() 1407a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1408a439fe51SSam Ravnborg * FUNCTION: HV_FAST_TTRACE_BUF_CONF 1409a439fe51SSam Ravnborg * ARG0: real address 1410a439fe51SSam Ravnborg * ARG1: number of entries 1411a439fe51SSam Ravnborg * RET0: status 1412a439fe51SSam Ravnborg * RET1: number of entries 1413a439fe51SSam Ravnborg * ERRORS: ENORADDR Invalid real address 1414a439fe51SSam Ravnborg * EINVAL Size is too small 1415a439fe51SSam Ravnborg * EBADALIGN Real address not aligned on 64-byte boundary 1416a439fe51SSam Ravnborg * 1417a439fe51SSam Ravnborg * Requests hypervisor trap tracing and declares a virtual CPU's trap 1418a439fe51SSam Ravnborg * trace buffer to the hypervisor. The real address supplies the real 1419a439fe51SSam Ravnborg * base address of the trap trace queue and must be 64-byte aligned. 1420a439fe51SSam Ravnborg * Specifying a value of 0 for the number of entries disables trap 1421a439fe51SSam Ravnborg * tracing for the calling virtual CPU. The buffer allocated must be 1422a439fe51SSam Ravnborg * sized for a power of two number of 64-byte trap trace entries plus 1423a439fe51SSam Ravnborg * an initial 64-byte control structure. 1424a439fe51SSam Ravnborg * 1425a439fe51SSam Ravnborg * This may be invoked any number of times so that a virtual CPU may 1426a439fe51SSam Ravnborg * relocate a trap trace buffer or create "snapshots" of information. 1427a439fe51SSam Ravnborg * 1428a439fe51SSam Ravnborg * If the real address is illegal or badly aligned, then trap tracing 1429a439fe51SSam Ravnborg * is disabled and an error is returned. 1430a439fe51SSam Ravnborg * 1431a439fe51SSam Ravnborg * Upon failure with EINVAL, this service call returns in RET1 the 1432a439fe51SSam Ravnborg * minimum number of buffer entries required. Upon other failures 1433a439fe51SSam Ravnborg * RET1 is undefined. 1434a439fe51SSam Ravnborg */ 1435a439fe51SSam Ravnborg #define HV_FAST_TTRACE_BUF_CONF 0x90 1436a439fe51SSam Ravnborg 1437a439fe51SSam Ravnborg /* ttrace_buf_info() 1438a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1439a439fe51SSam Ravnborg * FUNCTION: HV_FAST_TTRACE_BUF_INFO 1440a439fe51SSam Ravnborg * RET0: status 1441a439fe51SSam Ravnborg * RET1: real address 1442a439fe51SSam Ravnborg * RET2: size 1443a439fe51SSam Ravnborg * ERRORS: None defined. 1444a439fe51SSam Ravnborg * 1445a439fe51SSam Ravnborg * Returns the size and location of the previously declared trap-trace 1446a439fe51SSam Ravnborg * buffer. In the event that no buffer was previously defined, or the 1447a439fe51SSam Ravnborg * buffer is disabled, this call will return a size of zero bytes. 1448a439fe51SSam Ravnborg */ 1449a439fe51SSam Ravnborg #define HV_FAST_TTRACE_BUF_INFO 0x91 1450a439fe51SSam Ravnborg 1451a439fe51SSam Ravnborg /* ttrace_enable() 1452a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1453a439fe51SSam Ravnborg * FUNCTION: HV_FAST_TTRACE_ENABLE 1454a439fe51SSam Ravnborg * ARG0: enable 1455a439fe51SSam Ravnborg * RET0: status 1456a439fe51SSam Ravnborg * RET1: previous enable state 1457a439fe51SSam Ravnborg * ERRORS: EINVAL No trap trace buffer currently defined 1458a439fe51SSam Ravnborg * 1459a439fe51SSam Ravnborg * Enable or disable trap tracing, and return the previous enabled 1460a439fe51SSam Ravnborg * state in RET1. Future systems may define various flags for the 1461a439fe51SSam Ravnborg * enable argument (ARG0), for the moment a guest should pass 1462a439fe51SSam Ravnborg * "(uint64_t) -1" to enable, and "(uint64_t) 0" to disable all 146325985edcSLucas De Marchi * tracing - which will ensure future compatibility. 1464a439fe51SSam Ravnborg */ 1465a439fe51SSam Ravnborg #define HV_FAST_TTRACE_ENABLE 0x92 1466a439fe51SSam Ravnborg 1467a439fe51SSam Ravnborg /* ttrace_freeze() 1468a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1469a439fe51SSam Ravnborg * FUNCTION: HV_FAST_TTRACE_FREEZE 1470a439fe51SSam Ravnborg * ARG0: freeze 1471a439fe51SSam Ravnborg * RET0: status 1472a439fe51SSam Ravnborg * RET1: previous freeze state 1473a439fe51SSam Ravnborg * ERRORS: EINVAL No trap trace buffer currently defined 1474a439fe51SSam Ravnborg * 1475a439fe51SSam Ravnborg * Freeze or unfreeze trap tracing, returning the previous freeze 1476a439fe51SSam Ravnborg * state in RET1. A guest should pass a non-zero value to freeze and 1477a439fe51SSam Ravnborg * a zero value to unfreeze all tracing. The returned previous state 1478a439fe51SSam Ravnborg * is 0 for not frozen and 1 for frozen. 1479a439fe51SSam Ravnborg */ 1480a439fe51SSam Ravnborg #define HV_FAST_TTRACE_FREEZE 0x93 1481a439fe51SSam Ravnborg 1482a439fe51SSam Ravnborg /* ttrace_addentry() 1483a439fe51SSam Ravnborg * TRAP: HV_TTRACE_ADDENTRY_TRAP 1484a439fe51SSam Ravnborg * ARG0: tag (16-bits) 1485a439fe51SSam Ravnborg * ARG1: data word 0 1486a439fe51SSam Ravnborg * ARG2: data word 1 1487a439fe51SSam Ravnborg * ARG3: data word 2 1488a439fe51SSam Ravnborg * ARG4: data word 3 1489a439fe51SSam Ravnborg * RET0: status 1490a439fe51SSam Ravnborg * ERRORS: EINVAL No trap trace buffer currently defined 1491a439fe51SSam Ravnborg * 1492a439fe51SSam Ravnborg * Add an entry to the trap trace buffer. Upon return only ARG0/RET0 1493a439fe51SSam Ravnborg * is modified - none of the other registers holding arguments are 1494a439fe51SSam Ravnborg * volatile across this hypervisor service. 1495a439fe51SSam Ravnborg */ 1496a439fe51SSam Ravnborg 1497a439fe51SSam Ravnborg /* Core dump services. 1498a439fe51SSam Ravnborg * 1499a439fe51SSam Ravnborg * Since the hypervisor viraulizes and thus obscures a lot of the 1500a439fe51SSam Ravnborg * physical machine layout and state, traditional OS crash dumps can 1501a439fe51SSam Ravnborg * be difficult to diagnose especially when the problem is a 1502a439fe51SSam Ravnborg * configuration error of some sort. 1503a439fe51SSam Ravnborg * 1504a439fe51SSam Ravnborg * The dump services provide an opaque buffer into which the 1505a439fe51SSam Ravnborg * hypervisor can place it's internal state in order to assist in 1506a439fe51SSam Ravnborg * debugging such situations. The contents are opaque and extremely 1507a439fe51SSam Ravnborg * platform and hypervisor implementation specific. The guest, during 1508a439fe51SSam Ravnborg * a core dump, requests that the hypervisor update any information in 1509a439fe51SSam Ravnborg * the dump buffer in preparation to being dumped as part of the 1510a439fe51SSam Ravnborg * domain's memory image. 1511a439fe51SSam Ravnborg */ 1512a439fe51SSam Ravnborg 1513a439fe51SSam Ravnborg /* dump_buf_update() 1514a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1515a439fe51SSam Ravnborg * FUNCTION: HV_FAST_DUMP_BUF_UPDATE 1516a439fe51SSam Ravnborg * ARG0: real address 1517a439fe51SSam Ravnborg * ARG1: size 1518a439fe51SSam Ravnborg * RET0: status 1519a439fe51SSam Ravnborg * RET1: required size of dump buffer 1520a439fe51SSam Ravnborg * ERRORS: ENORADDR Invalid real address 1521a439fe51SSam Ravnborg * EBADALIGN Real address is not aligned on a 64-byte 1522a439fe51SSam Ravnborg * boundary 1523a439fe51SSam Ravnborg * EINVAL Size is non-zero but less than minimum size 1524a439fe51SSam Ravnborg * required 1525a439fe51SSam Ravnborg * ENOTSUPPORTED Operation not supported on current logical 1526a439fe51SSam Ravnborg * domain 1527a439fe51SSam Ravnborg * 1528a439fe51SSam Ravnborg * Declare a domain dump buffer to the hypervisor. The real address 1529a439fe51SSam Ravnborg * provided for the domain dump buffer must be 64-byte aligned. The 1530a439fe51SSam Ravnborg * size specifies the size of the dump buffer and may be larger than 1531a439fe51SSam Ravnborg * the minimum size specified in the machine description. The 1532a439fe51SSam Ravnborg * hypervisor will fill the dump buffer with opaque data. 1533a439fe51SSam Ravnborg * 1534a439fe51SSam Ravnborg * Note: A guest may elect to include dump buffer contents as part of a crash 1535a439fe51SSam Ravnborg * dump to assist with debugging. This function may be called any number 1536a439fe51SSam Ravnborg * of times so that a guest may relocate a dump buffer, or create 1537a439fe51SSam Ravnborg * "snapshots" of any dump-buffer information. Each call to 1538a439fe51SSam Ravnborg * dump_buf_update() atomically declares the new dump buffer to the 1539a439fe51SSam Ravnborg * hypervisor. 1540a439fe51SSam Ravnborg * 1541a439fe51SSam Ravnborg * A specified size of 0 unconfigures the dump buffer. If the real 1542a439fe51SSam Ravnborg * address is illegal or badly aligned, then any currently active dump 1543a439fe51SSam Ravnborg * buffer is disabled and an error is returned. 1544a439fe51SSam Ravnborg * 1545a439fe51SSam Ravnborg * In the event that the call fails with EINVAL, RET1 contains the 1546a439fe51SSam Ravnborg * minimum size requires by the hypervisor for a valid dump buffer. 1547a439fe51SSam Ravnborg */ 1548a439fe51SSam Ravnborg #define HV_FAST_DUMP_BUF_UPDATE 0x94 1549a439fe51SSam Ravnborg 1550a439fe51SSam Ravnborg /* dump_buf_info() 1551a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1552a439fe51SSam Ravnborg * FUNCTION: HV_FAST_DUMP_BUF_INFO 1553a439fe51SSam Ravnborg * RET0: status 1554a439fe51SSam Ravnborg * RET1: real address of current dump buffer 1555a439fe51SSam Ravnborg * RET2: size of current dump buffer 1556a439fe51SSam Ravnborg * ERRORS: No errors defined. 1557a439fe51SSam Ravnborg * 1558a439fe51SSam Ravnborg * Return the currently configures dump buffer description. A 1559a439fe51SSam Ravnborg * returned size of 0 bytes indicates an undefined dump buffer. In 1560a439fe51SSam Ravnborg * this case the return address in RET1 is undefined. 1561a439fe51SSam Ravnborg */ 1562a439fe51SSam Ravnborg #define HV_FAST_DUMP_BUF_INFO 0x95 1563a439fe51SSam Ravnborg 1564a439fe51SSam Ravnborg /* Device interrupt services. 1565a439fe51SSam Ravnborg * 1566a439fe51SSam Ravnborg * Device interrupts are allocated to system bus bridges by the hypervisor, 1567a439fe51SSam Ravnborg * and described to OBP in the machine description. OBP then describes 1568a439fe51SSam Ravnborg * these interrupts to the OS via properties in the device tree. 1569a439fe51SSam Ravnborg * 1570a439fe51SSam Ravnborg * Terminology: 1571a439fe51SSam Ravnborg * 1572a439fe51SSam Ravnborg * cpuid Unique opaque value which represents a target cpu. 1573a439fe51SSam Ravnborg * 1574a439fe51SSam Ravnborg * devhandle Device handle. It uniquely identifies a device, and 1575a439fe51SSam Ravnborg * consistes of the lower 28-bits of the hi-cell of the 1576a439fe51SSam Ravnborg * first entry of the device's "reg" property in the 1577a439fe51SSam Ravnborg * OBP device tree. 1578a439fe51SSam Ravnborg * 1579a439fe51SSam Ravnborg * devino Device interrupt number. Specifies the relative 1580a439fe51SSam Ravnborg * interrupt number within the device. The unique 1581a439fe51SSam Ravnborg * combination of devhandle and devino are used to 1582a439fe51SSam Ravnborg * identify a specific device interrupt. 1583a439fe51SSam Ravnborg * 1584a439fe51SSam Ravnborg * Note: The devino value is the same as the values in the 1585a439fe51SSam Ravnborg * "interrupts" property or "interrupt-map" property 1586a439fe51SSam Ravnborg * in the OBP device tree for that device. 1587a439fe51SSam Ravnborg * 1588a439fe51SSam Ravnborg * sysino System interrupt number. A 64-bit unsigned interger 1589a439fe51SSam Ravnborg * representing a unique interrupt within a virtual 1590a439fe51SSam Ravnborg * machine. 1591a439fe51SSam Ravnborg * 1592a439fe51SSam Ravnborg * intr_state A flag representing the interrupt state for a given 1593a439fe51SSam Ravnborg * sysino. The state values are defined below. 1594a439fe51SSam Ravnborg * 1595a439fe51SSam Ravnborg * intr_enabled A flag representing the 'enabled' state for a given 1596a439fe51SSam Ravnborg * sysino. The enable values are defined below. 1597a439fe51SSam Ravnborg */ 1598a439fe51SSam Ravnborg 1599a439fe51SSam Ravnborg #define HV_INTR_STATE_IDLE 0 /* Nothing pending */ 1600a439fe51SSam Ravnborg #define HV_INTR_STATE_RECEIVED 1 /* Interrupt received by hardware */ 1601a439fe51SSam Ravnborg #define HV_INTR_STATE_DELIVERED 2 /* Interrupt delivered to queue */ 1602a439fe51SSam Ravnborg 1603a439fe51SSam Ravnborg #define HV_INTR_DISABLED 0 /* sysino not enabled */ 1604a439fe51SSam Ravnborg #define HV_INTR_ENABLED 1 /* sysino enabled */ 1605a439fe51SSam Ravnborg 1606a439fe51SSam Ravnborg /* intr_devino_to_sysino() 1607a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1608a439fe51SSam Ravnborg * FUNCTION: HV_FAST_INTR_DEVINO2SYSINO 1609a439fe51SSam Ravnborg * ARG0: devhandle 1610a439fe51SSam Ravnborg * ARG1: devino 1611a439fe51SSam Ravnborg * RET0: status 1612a439fe51SSam Ravnborg * RET1: sysino 1613a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle/devino 1614a439fe51SSam Ravnborg * 1615a439fe51SSam Ravnborg * Converts a device specific interrupt number of the given 1616a439fe51SSam Ravnborg * devhandle/devino into a system specific ino (sysino). 1617a439fe51SSam Ravnborg */ 1618a439fe51SSam Ravnborg #define HV_FAST_INTR_DEVINO2SYSINO 0xa0 1619a439fe51SSam Ravnborg 1620a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1621f05a6865SSam Ravnborg unsigned long sun4v_devino_to_sysino(unsigned long devhandle, 1622a439fe51SSam Ravnborg unsigned long devino); 1623a439fe51SSam Ravnborg #endif 1624a439fe51SSam Ravnborg 1625a439fe51SSam Ravnborg /* intr_getenabled() 1626a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1627a439fe51SSam Ravnborg * FUNCTION: HV_FAST_INTR_GETENABLED 1628a439fe51SSam Ravnborg * ARG0: sysino 1629a439fe51SSam Ravnborg * RET0: status 1630a439fe51SSam Ravnborg * RET1: intr_enabled (HV_INTR_{DISABLED,ENABLED}) 1631a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid sysino 1632a439fe51SSam Ravnborg * 1633a439fe51SSam Ravnborg * Returns interrupt enabled state in RET1 for the interrupt defined 1634a439fe51SSam Ravnborg * by the given sysino. 1635a439fe51SSam Ravnborg */ 1636a439fe51SSam Ravnborg #define HV_FAST_INTR_GETENABLED 0xa1 1637a439fe51SSam Ravnborg 1638a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1639f05a6865SSam Ravnborg unsigned long sun4v_intr_getenabled(unsigned long sysino); 1640a439fe51SSam Ravnborg #endif 1641a439fe51SSam Ravnborg 1642a439fe51SSam Ravnborg /* intr_setenabled() 1643a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1644a439fe51SSam Ravnborg * FUNCTION: HV_FAST_INTR_SETENABLED 1645a439fe51SSam Ravnborg * ARG0: sysino 1646a439fe51SSam Ravnborg * ARG1: intr_enabled (HV_INTR_{DISABLED,ENABLED}) 1647a439fe51SSam Ravnborg * RET0: status 1648a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid sysino or intr_enabled value 1649a439fe51SSam Ravnborg * 1650a439fe51SSam Ravnborg * Set the 'enabled' state of the interrupt sysino. 1651a439fe51SSam Ravnborg */ 1652a439fe51SSam Ravnborg #define HV_FAST_INTR_SETENABLED 0xa2 1653a439fe51SSam Ravnborg 1654a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1655f05a6865SSam Ravnborg unsigned long sun4v_intr_setenabled(unsigned long sysino, 1656f05a6865SSam Ravnborg unsigned long intr_enabled); 1657a439fe51SSam Ravnborg #endif 1658a439fe51SSam Ravnborg 1659a439fe51SSam Ravnborg /* intr_getstate() 1660a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1661a439fe51SSam Ravnborg * FUNCTION: HV_FAST_INTR_GETSTATE 1662a439fe51SSam Ravnborg * ARG0: sysino 1663a439fe51SSam Ravnborg * RET0: status 1664a439fe51SSam Ravnborg * RET1: intr_state (HV_INTR_STATE_*) 1665a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid sysino 1666a439fe51SSam Ravnborg * 1667a439fe51SSam Ravnborg * Returns current state of the interrupt defined by the given sysino. 1668a439fe51SSam Ravnborg */ 1669a439fe51SSam Ravnborg #define HV_FAST_INTR_GETSTATE 0xa3 1670a439fe51SSam Ravnborg 1671a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1672f05a6865SSam Ravnborg unsigned long sun4v_intr_getstate(unsigned long sysino); 1673a439fe51SSam Ravnborg #endif 1674a439fe51SSam Ravnborg 1675a439fe51SSam Ravnborg /* intr_setstate() 1676a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1677a439fe51SSam Ravnborg * FUNCTION: HV_FAST_INTR_SETSTATE 1678a439fe51SSam Ravnborg * ARG0: sysino 1679a439fe51SSam Ravnborg * ARG1: intr_state (HV_INTR_STATE_*) 1680a439fe51SSam Ravnborg * RET0: status 1681a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid sysino or intr_state value 1682a439fe51SSam Ravnborg * 1683a439fe51SSam Ravnborg * Sets the current state of the interrupt described by the given sysino 1684a439fe51SSam Ravnborg * value. 1685a439fe51SSam Ravnborg * 1686a439fe51SSam Ravnborg * Note: Setting the state to HV_INTR_STATE_IDLE clears any pending 1687a439fe51SSam Ravnborg * interrupt for sysino. 1688a439fe51SSam Ravnborg */ 1689a439fe51SSam Ravnborg #define HV_FAST_INTR_SETSTATE 0xa4 1690a439fe51SSam Ravnborg 1691a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1692f05a6865SSam Ravnborg unsigned long sun4v_intr_setstate(unsigned long sysino, unsigned long intr_state); 1693a439fe51SSam Ravnborg #endif 1694a439fe51SSam Ravnborg 1695a439fe51SSam Ravnborg /* intr_gettarget() 1696a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1697a439fe51SSam Ravnborg * FUNCTION: HV_FAST_INTR_GETTARGET 1698a439fe51SSam Ravnborg * ARG0: sysino 1699a439fe51SSam Ravnborg * RET0: status 1700a439fe51SSam Ravnborg * RET1: cpuid 1701a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid sysino 1702a439fe51SSam Ravnborg * 1703a439fe51SSam Ravnborg * Returns CPU that is the current target of the interrupt defined by 1704a439fe51SSam Ravnborg * the given sysino. The CPU value returned is undefined if the target 1705a439fe51SSam Ravnborg * has not been set via intr_settarget(). 1706a439fe51SSam Ravnborg */ 1707a439fe51SSam Ravnborg #define HV_FAST_INTR_GETTARGET 0xa5 1708a439fe51SSam Ravnborg 1709a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1710f05a6865SSam Ravnborg unsigned long sun4v_intr_gettarget(unsigned long sysino); 1711a439fe51SSam Ravnborg #endif 1712a439fe51SSam Ravnborg 1713a439fe51SSam Ravnborg /* intr_settarget() 1714a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1715a439fe51SSam Ravnborg * FUNCTION: HV_FAST_INTR_SETTARGET 1716a439fe51SSam Ravnborg * ARG0: sysino 1717a439fe51SSam Ravnborg * ARG1: cpuid 1718a439fe51SSam Ravnborg * RET0: status 1719a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid sysino 1720a439fe51SSam Ravnborg * ENOCPU Invalid cpuid 1721a439fe51SSam Ravnborg * 1722a439fe51SSam Ravnborg * Set the target CPU for the interrupt defined by the given sysino. 1723a439fe51SSam Ravnborg */ 1724a439fe51SSam Ravnborg #define HV_FAST_INTR_SETTARGET 0xa6 1725a439fe51SSam Ravnborg 1726a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1727f05a6865SSam Ravnborg unsigned long sun4v_intr_settarget(unsigned long sysino, unsigned long cpuid); 1728a439fe51SSam Ravnborg #endif 1729a439fe51SSam Ravnborg 1730a439fe51SSam Ravnborg /* vintr_get_cookie() 1731a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1732a439fe51SSam Ravnborg * FUNCTION: HV_FAST_VINTR_GET_COOKIE 1733a439fe51SSam Ravnborg * ARG0: device handle 1734a439fe51SSam Ravnborg * ARG1: device ino 1735a439fe51SSam Ravnborg * RET0: status 1736a439fe51SSam Ravnborg * RET1: cookie 1737a439fe51SSam Ravnborg */ 1738a439fe51SSam Ravnborg #define HV_FAST_VINTR_GET_COOKIE 0xa7 1739a439fe51SSam Ravnborg 1740a439fe51SSam Ravnborg /* vintr_set_cookie() 1741a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1742a439fe51SSam Ravnborg * FUNCTION: HV_FAST_VINTR_SET_COOKIE 1743a439fe51SSam Ravnborg * ARG0: device handle 1744a439fe51SSam Ravnborg * ARG1: device ino 1745a439fe51SSam Ravnborg * ARG2: cookie 1746a439fe51SSam Ravnborg * RET0: status 1747a439fe51SSam Ravnborg */ 1748a439fe51SSam Ravnborg #define HV_FAST_VINTR_SET_COOKIE 0xa8 1749a439fe51SSam Ravnborg 1750a439fe51SSam Ravnborg /* vintr_get_valid() 1751a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1752a439fe51SSam Ravnborg * FUNCTION: HV_FAST_VINTR_GET_VALID 1753a439fe51SSam Ravnborg * ARG0: device handle 1754a439fe51SSam Ravnborg * ARG1: device ino 1755a439fe51SSam Ravnborg * RET0: status 1756a439fe51SSam Ravnborg * RET1: valid state 1757a439fe51SSam Ravnborg */ 1758a439fe51SSam Ravnborg #define HV_FAST_VINTR_GET_VALID 0xa9 1759a439fe51SSam Ravnborg 1760a439fe51SSam Ravnborg /* vintr_set_valid() 1761a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1762a439fe51SSam Ravnborg * FUNCTION: HV_FAST_VINTR_SET_VALID 1763a439fe51SSam Ravnborg * ARG0: device handle 1764a439fe51SSam Ravnborg * ARG1: device ino 1765a439fe51SSam Ravnborg * ARG2: valid state 1766a439fe51SSam Ravnborg * RET0: status 1767a439fe51SSam Ravnborg */ 1768a439fe51SSam Ravnborg #define HV_FAST_VINTR_SET_VALID 0xaa 1769a439fe51SSam Ravnborg 1770a439fe51SSam Ravnborg /* vintr_get_state() 1771a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1772a439fe51SSam Ravnborg * FUNCTION: HV_FAST_VINTR_GET_STATE 1773a439fe51SSam Ravnborg * ARG0: device handle 1774a439fe51SSam Ravnborg * ARG1: device ino 1775a439fe51SSam Ravnborg * RET0: status 1776a439fe51SSam Ravnborg * RET1: state 1777a439fe51SSam Ravnborg */ 1778a439fe51SSam Ravnborg #define HV_FAST_VINTR_GET_STATE 0xab 1779a439fe51SSam Ravnborg 1780a439fe51SSam Ravnborg /* vintr_set_state() 1781a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1782a439fe51SSam Ravnborg * FUNCTION: HV_FAST_VINTR_SET_STATE 1783a439fe51SSam Ravnborg * ARG0: device handle 1784a439fe51SSam Ravnborg * ARG1: device ino 1785a439fe51SSam Ravnborg * ARG2: state 1786a439fe51SSam Ravnborg * RET0: status 1787a439fe51SSam Ravnborg */ 1788a439fe51SSam Ravnborg #define HV_FAST_VINTR_SET_STATE 0xac 1789a439fe51SSam Ravnborg 1790a439fe51SSam Ravnborg /* vintr_get_target() 1791a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1792a439fe51SSam Ravnborg * FUNCTION: HV_FAST_VINTR_GET_TARGET 1793a439fe51SSam Ravnborg * ARG0: device handle 1794a439fe51SSam Ravnborg * ARG1: device ino 1795a439fe51SSam Ravnborg * RET0: status 1796a439fe51SSam Ravnborg * RET1: cpuid 1797a439fe51SSam Ravnborg */ 1798a439fe51SSam Ravnborg #define HV_FAST_VINTR_GET_TARGET 0xad 1799a439fe51SSam Ravnborg 1800a439fe51SSam Ravnborg /* vintr_set_target() 1801a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1802a439fe51SSam Ravnborg * FUNCTION: HV_FAST_VINTR_SET_TARGET 1803a439fe51SSam Ravnborg * ARG0: device handle 1804a439fe51SSam Ravnborg * ARG1: device ino 1805a439fe51SSam Ravnborg * ARG2: cpuid 1806a439fe51SSam Ravnborg * RET0: status 1807a439fe51SSam Ravnborg */ 1808a439fe51SSam Ravnborg #define HV_FAST_VINTR_SET_TARGET 0xae 1809a439fe51SSam Ravnborg 1810a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 1811f05a6865SSam Ravnborg unsigned long sun4v_vintr_get_cookie(unsigned long dev_handle, 1812a439fe51SSam Ravnborg unsigned long dev_ino, 1813a439fe51SSam Ravnborg unsigned long *cookie); 1814f05a6865SSam Ravnborg unsigned long sun4v_vintr_set_cookie(unsigned long dev_handle, 1815a439fe51SSam Ravnborg unsigned long dev_ino, 1816a439fe51SSam Ravnborg unsigned long cookie); 1817f05a6865SSam Ravnborg unsigned long sun4v_vintr_get_valid(unsigned long dev_handle, 1818a439fe51SSam Ravnborg unsigned long dev_ino, 1819a439fe51SSam Ravnborg unsigned long *valid); 1820f05a6865SSam Ravnborg unsigned long sun4v_vintr_set_valid(unsigned long dev_handle, 1821a439fe51SSam Ravnborg unsigned long dev_ino, 1822a439fe51SSam Ravnborg unsigned long valid); 1823f05a6865SSam Ravnborg unsigned long sun4v_vintr_get_state(unsigned long dev_handle, 1824a439fe51SSam Ravnborg unsigned long dev_ino, 1825a439fe51SSam Ravnborg unsigned long *state); 1826f05a6865SSam Ravnborg unsigned long sun4v_vintr_set_state(unsigned long dev_handle, 1827a439fe51SSam Ravnborg unsigned long dev_ino, 1828a439fe51SSam Ravnborg unsigned long state); 1829f05a6865SSam Ravnborg unsigned long sun4v_vintr_get_target(unsigned long dev_handle, 1830a439fe51SSam Ravnborg unsigned long dev_ino, 1831a439fe51SSam Ravnborg unsigned long *cpuid); 1832f05a6865SSam Ravnborg unsigned long sun4v_vintr_set_target(unsigned long dev_handle, 1833a439fe51SSam Ravnborg unsigned long dev_ino, 1834a439fe51SSam Ravnborg unsigned long cpuid); 1835a439fe51SSam Ravnborg #endif 1836a439fe51SSam Ravnborg 1837a439fe51SSam Ravnborg /* PCI IO services. 1838a439fe51SSam Ravnborg * 1839a439fe51SSam Ravnborg * See the terminology descriptions in the device interrupt services 1840a439fe51SSam Ravnborg * section above as those apply here too. Here are terminology 1841a439fe51SSam Ravnborg * definitions specific to these PCI IO services: 1842a439fe51SSam Ravnborg * 1843a439fe51SSam Ravnborg * tsbnum TSB number. Indentifies which io-tsb is used. 1844a439fe51SSam Ravnborg * For this version of the specification, tsbnum 1845a439fe51SSam Ravnborg * must be zero. 1846a439fe51SSam Ravnborg * 1847a439fe51SSam Ravnborg * tsbindex TSB index. Identifies which entry in the TSB 1848a439fe51SSam Ravnborg * is used. The first entry is zero. 1849a439fe51SSam Ravnborg * 1850a439fe51SSam Ravnborg * tsbid A 64-bit aligned data structure which contains 1851a439fe51SSam Ravnborg * a tsbnum and a tsbindex. Bits 63:32 contain the 1852a439fe51SSam Ravnborg * tsbnum and bits 31:00 contain the tsbindex. 1853a439fe51SSam Ravnborg * 1854a439fe51SSam Ravnborg * Use the HV_PCI_TSBID() macro to construct such 1855a439fe51SSam Ravnborg * values. 1856a439fe51SSam Ravnborg * 1857a439fe51SSam Ravnborg * io_attributes IO attributes for IOMMU mappings. One of more 1858a439fe51SSam Ravnborg * of the attritbute bits are stores in a 64-bit 1859a439fe51SSam Ravnborg * value. The values are defined below. 1860a439fe51SSam Ravnborg * 1861a439fe51SSam Ravnborg * r_addr 64-bit real address 1862a439fe51SSam Ravnborg * 1863a439fe51SSam Ravnborg * pci_device PCI device address. A PCI device address identifies 1864a439fe51SSam Ravnborg * a specific device on a specific PCI bus segment. 1865a439fe51SSam Ravnborg * A PCI device address ia a 32-bit unsigned integer 1866a439fe51SSam Ravnborg * with the following format: 1867a439fe51SSam Ravnborg * 1868a439fe51SSam Ravnborg * 00000000.bbbbbbbb.dddddfff.00000000 1869a439fe51SSam Ravnborg * 1870a439fe51SSam Ravnborg * Use the HV_PCI_DEVICE_BUILD() macro to construct 1871a439fe51SSam Ravnborg * such values. 1872a439fe51SSam Ravnborg * 1873a439fe51SSam Ravnborg * pci_config_offset 1874a439fe51SSam Ravnborg * PCI configureation space offset. For conventional 1875a439fe51SSam Ravnborg * PCI a value between 0 and 255. For extended 1876a439fe51SSam Ravnborg * configuration space, a value between 0 and 4095. 1877a439fe51SSam Ravnborg * 1878a439fe51SSam Ravnborg * Note: For PCI configuration space accesses, the offset 1879a439fe51SSam Ravnborg * must be aligned to the access size. 1880a439fe51SSam Ravnborg * 1881a439fe51SSam Ravnborg * error_flag A return value which specifies if the action succeeded 1882a439fe51SSam Ravnborg * or failed. 0 means no error, non-0 means some error 1883a439fe51SSam Ravnborg * occurred while performing the service. 1884a439fe51SSam Ravnborg * 1885a439fe51SSam Ravnborg * io_sync_direction 1886a439fe51SSam Ravnborg * Direction definition for pci_dma_sync(), defined 1887a439fe51SSam Ravnborg * below in HV_PCI_SYNC_*. 1888a439fe51SSam Ravnborg * 1889a439fe51SSam Ravnborg * io_page_list A list of io_page_addresses, an io_page_address is 1890a439fe51SSam Ravnborg * a real address. 1891a439fe51SSam Ravnborg * 1892a439fe51SSam Ravnborg * io_page_list_p A pointer to an io_page_list. 1893a439fe51SSam Ravnborg * 1894a439fe51SSam Ravnborg * "size based byte swap" - Some functions do size based byte swapping 1895a439fe51SSam Ravnborg * which allows sw to access pointers and 1896a439fe51SSam Ravnborg * counters in native form when the processor 1897a439fe51SSam Ravnborg * operates in a different endianness than the 1898a439fe51SSam Ravnborg * IO bus. Size-based byte swapping converts a 1899a439fe51SSam Ravnborg * multi-byte field between big-endian and 1900a439fe51SSam Ravnborg * little-endian format. 1901a439fe51SSam Ravnborg */ 1902a439fe51SSam Ravnborg 1903a439fe51SSam Ravnborg #define HV_PCI_MAP_ATTR_READ 0x01 1904a439fe51SSam Ravnborg #define HV_PCI_MAP_ATTR_WRITE 0x02 1905aa7bde1aSchris hyser #define HV_PCI_MAP_ATTR_RELAXED_ORDER 0x04 1906a439fe51SSam Ravnborg 1907a439fe51SSam Ravnborg #define HV_PCI_DEVICE_BUILD(b,d,f) \ 1908a439fe51SSam Ravnborg ((((b) & 0xff) << 16) | \ 1909a439fe51SSam Ravnborg (((d) & 0x1f) << 11) | \ 1910a439fe51SSam Ravnborg (((f) & 0x07) << 8)) 1911a439fe51SSam Ravnborg 1912a439fe51SSam Ravnborg #define HV_PCI_TSBID(__tsb_num, __tsb_index) \ 1913a439fe51SSam Ravnborg ((((u64)(__tsb_num)) << 32UL) | ((u64)(__tsb_index))) 1914a439fe51SSam Ravnborg 1915a439fe51SSam Ravnborg #define HV_PCI_SYNC_FOR_DEVICE 0x01 1916a439fe51SSam Ravnborg #define HV_PCI_SYNC_FOR_CPU 0x02 1917a439fe51SSam Ravnborg 1918a439fe51SSam Ravnborg /* pci_iommu_map() 1919a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1920a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_IOMMU_MAP 1921a439fe51SSam Ravnborg * ARG0: devhandle 1922a439fe51SSam Ravnborg * ARG1: tsbid 1923a439fe51SSam Ravnborg * ARG2: #ttes 1924a439fe51SSam Ravnborg * ARG3: io_attributes 1925a439fe51SSam Ravnborg * ARG4: io_page_list_p 1926a439fe51SSam Ravnborg * RET0: status 1927a439fe51SSam Ravnborg * RET1: #ttes mapped 1928a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle/tsbnum/tsbindex/io_attributes 1929a439fe51SSam Ravnborg * EBADALIGN Improperly aligned real address 1930a439fe51SSam Ravnborg * ENORADDR Invalid real address 1931a439fe51SSam Ravnborg * 1932a439fe51SSam Ravnborg * Create IOMMU mappings in the sun4v device defined by the given 1933a439fe51SSam Ravnborg * devhandle. The mappings are created in the TSB defined by the 1934a439fe51SSam Ravnborg * tsbnum component of the given tsbid. The first mapping is created 1935a439fe51SSam Ravnborg * in the TSB i ndex defined by the tsbindex component of the given tsbid. 1936a439fe51SSam Ravnborg * The call creates up to #ttes mappings, the first one at tsbnum, tsbindex, 1937a439fe51SSam Ravnborg * the second at tsbnum, tsbindex + 1, etc. 1938a439fe51SSam Ravnborg * 1939a439fe51SSam Ravnborg * All mappings are created with the attributes defined by the io_attributes 1940a439fe51SSam Ravnborg * argument. The page mapping addresses are described in the io_page_list 1941a439fe51SSam Ravnborg * defined by the given io_page_list_p, which is a pointer to the io_page_list. 1942a439fe51SSam Ravnborg * The first entry in the io_page_list is the address for the first iotte, the 1943a439fe51SSam Ravnborg * 2nd for the 2nd iotte, and so on. 1944a439fe51SSam Ravnborg * 1945a439fe51SSam Ravnborg * Each io_page_address in the io_page_list must be appropriately aligned. 1946a439fe51SSam Ravnborg * #ttes must be greater than zero. For this version of the spec, the tsbnum 1947a439fe51SSam Ravnborg * component of the given tsbid must be zero. 1948a439fe51SSam Ravnborg * 1949a439fe51SSam Ravnborg * Returns the actual number of mappings creates, which may be less than 1950a439fe51SSam Ravnborg * or equal to the argument #ttes. If the function returns a value which 1951a439fe51SSam Ravnborg * is less than the #ttes, the caller may continus to call the function with 1952a439fe51SSam Ravnborg * an updated tsbid, #ttes, io_page_list_p arguments until all pages are 1953a439fe51SSam Ravnborg * mapped. 1954a439fe51SSam Ravnborg * 1955a439fe51SSam Ravnborg * Note: This function does not imply an iotte cache flush. The guest must 1956a439fe51SSam Ravnborg * demap an entry before re-mapping it. 1957a439fe51SSam Ravnborg */ 1958a439fe51SSam Ravnborg #define HV_FAST_PCI_IOMMU_MAP 0xb0 1959a439fe51SSam Ravnborg 1960a439fe51SSam Ravnborg /* pci_iommu_demap() 1961a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1962a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_IOMMU_DEMAP 1963a439fe51SSam Ravnborg * ARG0: devhandle 1964a439fe51SSam Ravnborg * ARG1: tsbid 1965a439fe51SSam Ravnborg * ARG2: #ttes 1966a439fe51SSam Ravnborg * RET0: status 1967a439fe51SSam Ravnborg * RET1: #ttes demapped 1968a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle/tsbnum/tsbindex 1969a439fe51SSam Ravnborg * 1970a439fe51SSam Ravnborg * Demap and flush IOMMU mappings in the device defined by the given 1971a439fe51SSam Ravnborg * devhandle. Demaps up to #ttes entries in the TSB defined by the tsbnum 1972a439fe51SSam Ravnborg * component of the given tsbid, starting at the TSB index defined by the 1973a439fe51SSam Ravnborg * tsbindex component of the given tsbid. 1974a439fe51SSam Ravnborg * 1975a439fe51SSam Ravnborg * For this version of the spec, the tsbnum of the given tsbid must be zero. 1976a439fe51SSam Ravnborg * #ttes must be greater than zero. 1977a439fe51SSam Ravnborg * 1978a439fe51SSam Ravnborg * Returns the actual number of ttes demapped, which may be less than or equal 1979a439fe51SSam Ravnborg * to the argument #ttes. If #ttes demapped is less than #ttes, the caller 1980a439fe51SSam Ravnborg * may continue to call this function with updated tsbid and #ttes arguments 1981a439fe51SSam Ravnborg * until all pages are demapped. 1982a439fe51SSam Ravnborg * 1983a439fe51SSam Ravnborg * Note: Entries do not have to be mapped to be demapped. A demap of an 1984a439fe51SSam Ravnborg * unmapped page will flush the entry from the tte cache. 1985a439fe51SSam Ravnborg */ 1986a439fe51SSam Ravnborg #define HV_FAST_PCI_IOMMU_DEMAP 0xb1 1987a439fe51SSam Ravnborg 1988a439fe51SSam Ravnborg /* pci_iommu_getmap() 1989a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 1990a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_IOMMU_GETMAP 1991a439fe51SSam Ravnborg * ARG0: devhandle 1992a439fe51SSam Ravnborg * ARG1: tsbid 1993a439fe51SSam Ravnborg * RET0: status 1994a439fe51SSam Ravnborg * RET1: io_attributes 1995a439fe51SSam Ravnborg * RET2: real address 1996a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle/tsbnum/tsbindex 1997a439fe51SSam Ravnborg * ENOMAP Mapping is not valid, no translation exists 1998a439fe51SSam Ravnborg * 1999a439fe51SSam Ravnborg * Read and return the mapping in the device described by the given devhandle 2000a439fe51SSam Ravnborg * and tsbid. If successful, the io_attributes shall be returned in RET1 2001a439fe51SSam Ravnborg * and the page address of the mapping shall be returned in RET2. 2002a439fe51SSam Ravnborg * 2003a439fe51SSam Ravnborg * For this version of the spec, the tsbnum component of the given tsbid 2004a439fe51SSam Ravnborg * must be zero. 2005a439fe51SSam Ravnborg */ 2006a439fe51SSam Ravnborg #define HV_FAST_PCI_IOMMU_GETMAP 0xb2 2007a439fe51SSam Ravnborg 2008a439fe51SSam Ravnborg /* pci_iommu_getbypass() 2009a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2010a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_IOMMU_GETBYPASS 2011a439fe51SSam Ravnborg * ARG0: devhandle 2012a439fe51SSam Ravnborg * ARG1: real address 2013a439fe51SSam Ravnborg * ARG2: io_attributes 2014a439fe51SSam Ravnborg * RET0: status 2015a439fe51SSam Ravnborg * RET1: io_addr 2016a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle/io_attributes 2017a439fe51SSam Ravnborg * ENORADDR Invalid real address 2018a439fe51SSam Ravnborg * ENOTSUPPORTED Function not supported in this implementation. 2019a439fe51SSam Ravnborg * 2020a439fe51SSam Ravnborg * Create a "special" mapping in the device described by the given devhandle, 2021a439fe51SSam Ravnborg * for the given real address and attributes. Return the IO address in RET1 2022a439fe51SSam Ravnborg * if successful. 2023a439fe51SSam Ravnborg */ 2024a439fe51SSam Ravnborg #define HV_FAST_PCI_IOMMU_GETBYPASS 0xb3 2025a439fe51SSam Ravnborg 2026a439fe51SSam Ravnborg /* pci_config_get() 2027a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2028a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_CONFIG_GET 2029a439fe51SSam Ravnborg * ARG0: devhandle 2030a439fe51SSam Ravnborg * ARG1: pci_device 2031a439fe51SSam Ravnborg * ARG2: pci_config_offset 2032a439fe51SSam Ravnborg * ARG3: size 2033a439fe51SSam Ravnborg * RET0: status 2034a439fe51SSam Ravnborg * RET1: error_flag 2035a439fe51SSam Ravnborg * RET2: data 2036a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle/pci_device/offset/size 2037a439fe51SSam Ravnborg * EBADALIGN pci_config_offset not size aligned 2038a439fe51SSam Ravnborg * ENOACCESS Access to this offset is not permitted 2039a439fe51SSam Ravnborg * 2040a439fe51SSam Ravnborg * Read PCI configuration space for the adapter described by the given 2041a439fe51SSam Ravnborg * devhandle. Read size (1, 2, or 4) bytes of data from the given 2042a439fe51SSam Ravnborg * pci_device, at pci_config_offset from the beginning of the device's 2043a439fe51SSam Ravnborg * configuration space. If there was no error, RET1 is set to zero and 2044a439fe51SSam Ravnborg * RET2 is set to the data read. Insignificant bits in RET2 are not 204525985edcSLucas De Marchi * guaranteed to have any specific value and therefore must be ignored. 2046a439fe51SSam Ravnborg * 2047a439fe51SSam Ravnborg * The data returned in RET2 is size based byte swapped. 2048a439fe51SSam Ravnborg * 2049a439fe51SSam Ravnborg * If an error occurs during the read, set RET1 to a non-zero value. The 2050a439fe51SSam Ravnborg * given pci_config_offset must be 'size' aligned. 2051a439fe51SSam Ravnborg */ 2052a439fe51SSam Ravnborg #define HV_FAST_PCI_CONFIG_GET 0xb4 2053a439fe51SSam Ravnborg 2054a439fe51SSam Ravnborg /* pci_config_put() 2055a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2056a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_CONFIG_PUT 2057a439fe51SSam Ravnborg * ARG0: devhandle 2058a439fe51SSam Ravnborg * ARG1: pci_device 2059a439fe51SSam Ravnborg * ARG2: pci_config_offset 2060a439fe51SSam Ravnborg * ARG3: size 2061a439fe51SSam Ravnborg * ARG4: data 2062a439fe51SSam Ravnborg * RET0: status 2063a439fe51SSam Ravnborg * RET1: error_flag 2064a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle/pci_device/offset/size 2065a439fe51SSam Ravnborg * EBADALIGN pci_config_offset not size aligned 2066a439fe51SSam Ravnborg * ENOACCESS Access to this offset is not permitted 2067a439fe51SSam Ravnborg * 2068a439fe51SSam Ravnborg * Write PCI configuration space for the adapter described by the given 2069a439fe51SSam Ravnborg * devhandle. Write size (1, 2, or 4) bytes of data in a single operation, 2070a439fe51SSam Ravnborg * at pci_config_offset from the beginning of the device's configuration 2071a439fe51SSam Ravnborg * space. The data argument contains the data to be written to configuration 2072a439fe51SSam Ravnborg * space. Prior to writing, the data is size based byte swapped. 2073a439fe51SSam Ravnborg * 2074a439fe51SSam Ravnborg * If an error occurs during the write access, do not generate an error 2075a439fe51SSam Ravnborg * report, do set RET1 to a non-zero value. Otherwise RET1 is zero. 2076a439fe51SSam Ravnborg * The given pci_config_offset must be 'size' aligned. 2077a439fe51SSam Ravnborg * 2078a439fe51SSam Ravnborg * This function is permitted to read from offset zero in the configuration 2079a439fe51SSam Ravnborg * space described by the given pci_device if necessary to ensure that the 2080a439fe51SSam Ravnborg * write access to config space completes. 2081a439fe51SSam Ravnborg */ 2082a439fe51SSam Ravnborg #define HV_FAST_PCI_CONFIG_PUT 0xb5 2083a439fe51SSam Ravnborg 2084a439fe51SSam Ravnborg /* pci_peek() 2085a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2086a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_PEEK 2087a439fe51SSam Ravnborg * ARG0: devhandle 2088a439fe51SSam Ravnborg * ARG1: real address 2089a439fe51SSam Ravnborg * ARG2: size 2090a439fe51SSam Ravnborg * RET0: status 2091a439fe51SSam Ravnborg * RET1: error_flag 2092a439fe51SSam Ravnborg * RET2: data 2093a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or size 2094a439fe51SSam Ravnborg * EBADALIGN Improperly aligned real address 2095a439fe51SSam Ravnborg * ENORADDR Bad real address 2096a439fe51SSam Ravnborg * ENOACCESS Guest access prohibited 2097a439fe51SSam Ravnborg * 2098a439fe51SSam Ravnborg * Attempt to read the IO address given by the given devhandle, real address, 2099a439fe51SSam Ravnborg * and size. Size must be 1, 2, 4, or 8. The read is performed as a single 2100a439fe51SSam Ravnborg * access operation using the given size. If an error occurs when reading 2101a439fe51SSam Ravnborg * from the given location, do not generate an error report, but return a 2102a439fe51SSam Ravnborg * non-zero value in RET1. If the read was successful, return zero in RET1 2103a439fe51SSam Ravnborg * and return the actual data read in RET2. The data returned is size based 2104a439fe51SSam Ravnborg * byte swapped. 2105a439fe51SSam Ravnborg * 210625985edcSLucas De Marchi * Non-significant bits in RET2 are not guaranteed to have any specific value 2107a439fe51SSam Ravnborg * and therefore must be ignored. If RET1 is returned as non-zero, the data 210825985edcSLucas De Marchi * value is not guaranteed to have any specific value and should be ignored. 2109a439fe51SSam Ravnborg * 2110a439fe51SSam Ravnborg * The caller must have permission to read from the given devhandle, real 2111a439fe51SSam Ravnborg * address, which must be an IO address. The argument real address must be a 2112a439fe51SSam Ravnborg * size aligned address. 2113a439fe51SSam Ravnborg * 2114a439fe51SSam Ravnborg * The hypervisor implementation of this function must block access to any 2115a439fe51SSam Ravnborg * IO address that the guest does not have explicit permission to access. 2116a439fe51SSam Ravnborg */ 2117a439fe51SSam Ravnborg #define HV_FAST_PCI_PEEK 0xb6 2118a439fe51SSam Ravnborg 2119a439fe51SSam Ravnborg /* pci_poke() 2120a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2121a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_POKE 2122a439fe51SSam Ravnborg * ARG0: devhandle 2123a439fe51SSam Ravnborg * ARG1: real address 2124a439fe51SSam Ravnborg * ARG2: size 2125a439fe51SSam Ravnborg * ARG3: data 2126a439fe51SSam Ravnborg * ARG4: pci_device 2127a439fe51SSam Ravnborg * RET0: status 2128a439fe51SSam Ravnborg * RET1: error_flag 2129a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle, size, or pci_device 2130a439fe51SSam Ravnborg * EBADALIGN Improperly aligned real address 2131a439fe51SSam Ravnborg * ENORADDR Bad real address 2132a439fe51SSam Ravnborg * ENOACCESS Guest access prohibited 2133a439fe51SSam Ravnborg * ENOTSUPPORTED Function is not supported by implementation 2134a439fe51SSam Ravnborg * 2135a439fe51SSam Ravnborg * Attempt to write data to the IO address given by the given devhandle, 2136a439fe51SSam Ravnborg * real address, and size. Size must be 1, 2, 4, or 8. The write is 2137a439fe51SSam Ravnborg * performed as a single access operation using the given size. Prior to 2138a439fe51SSam Ravnborg * writing the data is size based swapped. 2139a439fe51SSam Ravnborg * 2140a439fe51SSam Ravnborg * If an error occurs when writing to the given location, do not generate an 2141a439fe51SSam Ravnborg * error report, but return a non-zero value in RET1. If the write was 2142a439fe51SSam Ravnborg * successful, return zero in RET1. 2143a439fe51SSam Ravnborg * 2144a439fe51SSam Ravnborg * pci_device describes the configuration address of the device being 2145a439fe51SSam Ravnborg * written to. The implementation may safely read from offset 0 with 2146a439fe51SSam Ravnborg * the configuration space of the device described by devhandle and 2147a439fe51SSam Ravnborg * pci_device in order to guarantee that the write portion of the operation 2148a439fe51SSam Ravnborg * completes 2149a439fe51SSam Ravnborg * 2150a439fe51SSam Ravnborg * Any error that occurs due to the read shall be reported using the normal 2151a439fe51SSam Ravnborg * error reporting mechanisms .. the read error is not suppressed. 2152a439fe51SSam Ravnborg * 2153a439fe51SSam Ravnborg * The caller must have permission to write to the given devhandle, real 2154a439fe51SSam Ravnborg * address, which must be an IO address. The argument real address must be a 2155a439fe51SSam Ravnborg * size aligned address. The caller must have permission to read from 2156a439fe51SSam Ravnborg * the given devhandle, pci_device cofiguration space offset 0. 2157a439fe51SSam Ravnborg * 2158a439fe51SSam Ravnborg * The hypervisor implementation of this function must block access to any 2159a439fe51SSam Ravnborg * IO address that the guest does not have explicit permission to access. 2160a439fe51SSam Ravnborg */ 2161a439fe51SSam Ravnborg #define HV_FAST_PCI_POKE 0xb7 2162a439fe51SSam Ravnborg 2163a439fe51SSam Ravnborg /* pci_dma_sync() 2164a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2165a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_DMA_SYNC 2166a439fe51SSam Ravnborg * ARG0: devhandle 2167a439fe51SSam Ravnborg * ARG1: real address 2168a439fe51SSam Ravnborg * ARG2: size 2169a439fe51SSam Ravnborg * ARG3: io_sync_direction 2170a439fe51SSam Ravnborg * RET0: status 2171a439fe51SSam Ravnborg * RET1: #synced 2172a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or io_sync_direction 2173a439fe51SSam Ravnborg * ENORADDR Bad real address 2174a439fe51SSam Ravnborg * 2175a439fe51SSam Ravnborg * Synchronize a memory region described by the given real address and size, 2176a439fe51SSam Ravnborg * for the device defined by the given devhandle using the direction(s) 2177a439fe51SSam Ravnborg * defined by the given io_sync_direction. The argument size is the size of 2178a439fe51SSam Ravnborg * the memory region in bytes. 2179a439fe51SSam Ravnborg * 2180a439fe51SSam Ravnborg * Return the actual number of bytes synchronized in the return value #synced, 2181a439fe51SSam Ravnborg * which may be less than or equal to the argument size. If the return 2182a439fe51SSam Ravnborg * value #synced is less than size, the caller must continue to call this 2183a439fe51SSam Ravnborg * function with updated real address and size arguments until the entire 2184a439fe51SSam Ravnborg * memory region is synchronized. 2185a439fe51SSam Ravnborg */ 2186a439fe51SSam Ravnborg #define HV_FAST_PCI_DMA_SYNC 0xb8 2187a439fe51SSam Ravnborg 2188a439fe51SSam Ravnborg /* PCI MSI services. */ 2189a439fe51SSam Ravnborg 2190a439fe51SSam Ravnborg #define HV_MSITYPE_MSI32 0x00 2191a439fe51SSam Ravnborg #define HV_MSITYPE_MSI64 0x01 2192a439fe51SSam Ravnborg 2193a439fe51SSam Ravnborg #define HV_MSIQSTATE_IDLE 0x00 2194a439fe51SSam Ravnborg #define HV_MSIQSTATE_ERROR 0x01 2195a439fe51SSam Ravnborg 2196a439fe51SSam Ravnborg #define HV_MSIQ_INVALID 0x00 2197a439fe51SSam Ravnborg #define HV_MSIQ_VALID 0x01 2198a439fe51SSam Ravnborg 2199a439fe51SSam Ravnborg #define HV_MSISTATE_IDLE 0x00 2200a439fe51SSam Ravnborg #define HV_MSISTATE_DELIVERED 0x01 2201a439fe51SSam Ravnborg 2202a439fe51SSam Ravnborg #define HV_MSIVALID_INVALID 0x00 2203a439fe51SSam Ravnborg #define HV_MSIVALID_VALID 0x01 2204a439fe51SSam Ravnborg 2205a439fe51SSam Ravnborg #define HV_PCIE_MSGTYPE_PME_MSG 0x18 2206a439fe51SSam Ravnborg #define HV_PCIE_MSGTYPE_PME_ACK_MSG 0x1b 2207a439fe51SSam Ravnborg #define HV_PCIE_MSGTYPE_CORR_MSG 0x30 2208a439fe51SSam Ravnborg #define HV_PCIE_MSGTYPE_NONFATAL_MSG 0x31 2209a439fe51SSam Ravnborg #define HV_PCIE_MSGTYPE_FATAL_MSG 0x33 2210a439fe51SSam Ravnborg 2211a439fe51SSam Ravnborg #define HV_MSG_INVALID 0x00 2212a439fe51SSam Ravnborg #define HV_MSG_VALID 0x01 2213a439fe51SSam Ravnborg 2214a439fe51SSam Ravnborg /* pci_msiq_conf() 2215a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2216a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSIQ_CONF 2217a439fe51SSam Ravnborg * ARG0: devhandle 2218a439fe51SSam Ravnborg * ARG1: msiqid 2219a439fe51SSam Ravnborg * ARG2: real address 2220a439fe51SSam Ravnborg * ARG3: number of entries 2221a439fe51SSam Ravnborg * RET0: status 2222a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle, msiqid or nentries 2223a439fe51SSam Ravnborg * EBADALIGN Improperly aligned real address 2224a439fe51SSam Ravnborg * ENORADDR Bad real address 2225a439fe51SSam Ravnborg * 2226a439fe51SSam Ravnborg * Configure the MSI queue given by the devhandle and msiqid arguments, 2227a439fe51SSam Ravnborg * and to be placed at the given real address and be of the given 2228a439fe51SSam Ravnborg * number of entries. The real address must be aligned exactly to match 2229a439fe51SSam Ravnborg * the queue size. Each queue entry is 64-bytes long, so f.e. a 32 entry 2230a439fe51SSam Ravnborg * queue must be aligned on a 2048 byte real address boundary. The MSI-EQ 2231a439fe51SSam Ravnborg * Head and Tail are initialized so that the MSI-EQ is 'empty'. 2232a439fe51SSam Ravnborg * 2233a439fe51SSam Ravnborg * Implementation Note: Certain implementations have fixed sized queues. In 2234a439fe51SSam Ravnborg * that case, number of entries must contain the correct 2235a439fe51SSam Ravnborg * value. 2236a439fe51SSam Ravnborg */ 2237a439fe51SSam Ravnborg #define HV_FAST_PCI_MSIQ_CONF 0xc0 2238a439fe51SSam Ravnborg 2239a439fe51SSam Ravnborg /* pci_msiq_info() 2240a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2241a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSIQ_INFO 2242a439fe51SSam Ravnborg * ARG0: devhandle 2243a439fe51SSam Ravnborg * ARG1: msiqid 2244a439fe51SSam Ravnborg * RET0: status 2245a439fe51SSam Ravnborg * RET1: real address 2246a439fe51SSam Ravnborg * RET2: number of entries 2247a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msiqid 2248a439fe51SSam Ravnborg * 2249a439fe51SSam Ravnborg * Return the configuration information for the MSI queue described 2250a439fe51SSam Ravnborg * by the given devhandle and msiqid. The base address of the queue 2251a439fe51SSam Ravnborg * is returned in ARG1 and the number of entries is returned in ARG2. 2252a439fe51SSam Ravnborg * If the queue is unconfigured, the real address is undefined and the 2253a439fe51SSam Ravnborg * number of entries will be returned as zero. 2254a439fe51SSam Ravnborg */ 2255a439fe51SSam Ravnborg #define HV_FAST_PCI_MSIQ_INFO 0xc1 2256a439fe51SSam Ravnborg 2257a439fe51SSam Ravnborg /* pci_msiq_getvalid() 2258a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2259a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSIQ_GETVALID 2260a439fe51SSam Ravnborg * ARG0: devhandle 2261a439fe51SSam Ravnborg * ARG1: msiqid 2262a439fe51SSam Ravnborg * RET0: status 2263a439fe51SSam Ravnborg * RET1: msiqvalid (HV_MSIQ_VALID or HV_MSIQ_INVALID) 2264a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msiqid 2265a439fe51SSam Ravnborg * 2266a439fe51SSam Ravnborg * Get the valid state of the MSI-EQ described by the given devhandle and 2267a439fe51SSam Ravnborg * msiqid. 2268a439fe51SSam Ravnborg */ 2269a439fe51SSam Ravnborg #define HV_FAST_PCI_MSIQ_GETVALID 0xc2 2270a439fe51SSam Ravnborg 2271a439fe51SSam Ravnborg /* pci_msiq_setvalid() 2272a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2273a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSIQ_SETVALID 2274a439fe51SSam Ravnborg * ARG0: devhandle 2275a439fe51SSam Ravnborg * ARG1: msiqid 2276a439fe51SSam Ravnborg * ARG2: msiqvalid (HV_MSIQ_VALID or HV_MSIQ_INVALID) 2277a439fe51SSam Ravnborg * RET0: status 2278a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msiqid or msiqvalid 2279a439fe51SSam Ravnborg * value or MSI EQ is uninitialized 2280a439fe51SSam Ravnborg * 2281a439fe51SSam Ravnborg * Set the valid state of the MSI-EQ described by the given devhandle and 2282a439fe51SSam Ravnborg * msiqid to the given msiqvalid. 2283a439fe51SSam Ravnborg */ 2284a439fe51SSam Ravnborg #define HV_FAST_PCI_MSIQ_SETVALID 0xc3 2285a439fe51SSam Ravnborg 2286a439fe51SSam Ravnborg /* pci_msiq_getstate() 2287a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2288a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSIQ_GETSTATE 2289a439fe51SSam Ravnborg * ARG0: devhandle 2290a439fe51SSam Ravnborg * ARG1: msiqid 2291a439fe51SSam Ravnborg * RET0: status 2292a439fe51SSam Ravnborg * RET1: msiqstate (HV_MSIQSTATE_IDLE or HV_MSIQSTATE_ERROR) 2293a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msiqid 2294a439fe51SSam Ravnborg * 2295a439fe51SSam Ravnborg * Get the state of the MSI-EQ described by the given devhandle and 2296a439fe51SSam Ravnborg * msiqid. 2297a439fe51SSam Ravnborg */ 2298a439fe51SSam Ravnborg #define HV_FAST_PCI_MSIQ_GETSTATE 0xc4 2299a439fe51SSam Ravnborg 2300a439fe51SSam Ravnborg /* pci_msiq_getvalid() 2301a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2302a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSIQ_GETVALID 2303a439fe51SSam Ravnborg * ARG0: devhandle 2304a439fe51SSam Ravnborg * ARG1: msiqid 2305a439fe51SSam Ravnborg * ARG2: msiqstate (HV_MSIQSTATE_IDLE or HV_MSIQSTATE_ERROR) 2306a439fe51SSam Ravnborg * RET0: status 2307a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msiqid or msiqstate 2308a439fe51SSam Ravnborg * value or MSI EQ is uninitialized 2309a439fe51SSam Ravnborg * 2310a439fe51SSam Ravnborg * Set the state of the MSI-EQ described by the given devhandle and 2311a439fe51SSam Ravnborg * msiqid to the given msiqvalid. 2312a439fe51SSam Ravnborg */ 2313a439fe51SSam Ravnborg #define HV_FAST_PCI_MSIQ_SETSTATE 0xc5 2314a439fe51SSam Ravnborg 2315a439fe51SSam Ravnborg /* pci_msiq_gethead() 2316a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2317a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSIQ_GETHEAD 2318a439fe51SSam Ravnborg * ARG0: devhandle 2319a439fe51SSam Ravnborg * ARG1: msiqid 2320a439fe51SSam Ravnborg * RET0: status 2321a439fe51SSam Ravnborg * RET1: msiqhead 2322a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msiqid 2323a439fe51SSam Ravnborg * 2324a439fe51SSam Ravnborg * Get the current MSI EQ queue head for the MSI-EQ described by the 2325a439fe51SSam Ravnborg * given devhandle and msiqid. 2326a439fe51SSam Ravnborg */ 2327a439fe51SSam Ravnborg #define HV_FAST_PCI_MSIQ_GETHEAD 0xc6 2328a439fe51SSam Ravnborg 2329a439fe51SSam Ravnborg /* pci_msiq_sethead() 2330a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2331a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSIQ_SETHEAD 2332a439fe51SSam Ravnborg * ARG0: devhandle 2333a439fe51SSam Ravnborg * ARG1: msiqid 2334a439fe51SSam Ravnborg * ARG2: msiqhead 2335a439fe51SSam Ravnborg * RET0: status 2336a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msiqid or msiqhead, 2337a439fe51SSam Ravnborg * or MSI EQ is uninitialized 2338a439fe51SSam Ravnborg * 2339a439fe51SSam Ravnborg * Set the current MSI EQ queue head for the MSI-EQ described by the 2340a439fe51SSam Ravnborg * given devhandle and msiqid. 2341a439fe51SSam Ravnborg */ 2342a439fe51SSam Ravnborg #define HV_FAST_PCI_MSIQ_SETHEAD 0xc7 2343a439fe51SSam Ravnborg 2344a439fe51SSam Ravnborg /* pci_msiq_gettail() 2345a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2346a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSIQ_GETTAIL 2347a439fe51SSam Ravnborg * ARG0: devhandle 2348a439fe51SSam Ravnborg * ARG1: msiqid 2349a439fe51SSam Ravnborg * RET0: status 2350a439fe51SSam Ravnborg * RET1: msiqtail 2351a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msiqid 2352a439fe51SSam Ravnborg * 2353a439fe51SSam Ravnborg * Get the current MSI EQ queue tail for the MSI-EQ described by the 2354a439fe51SSam Ravnborg * given devhandle and msiqid. 2355a439fe51SSam Ravnborg */ 2356a439fe51SSam Ravnborg #define HV_FAST_PCI_MSIQ_GETTAIL 0xc8 2357a439fe51SSam Ravnborg 2358a439fe51SSam Ravnborg /* pci_msi_getvalid() 2359a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2360a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSI_GETVALID 2361a439fe51SSam Ravnborg * ARG0: devhandle 2362a439fe51SSam Ravnborg * ARG1: msinum 2363a439fe51SSam Ravnborg * RET0: status 2364a439fe51SSam Ravnborg * RET1: msivalidstate 2365a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msinum 2366a439fe51SSam Ravnborg * 2367a439fe51SSam Ravnborg * Get the current valid/enabled state for the MSI defined by the 2368a439fe51SSam Ravnborg * given devhandle and msinum. 2369a439fe51SSam Ravnborg */ 2370a439fe51SSam Ravnborg #define HV_FAST_PCI_MSI_GETVALID 0xc9 2371a439fe51SSam Ravnborg 2372a439fe51SSam Ravnborg /* pci_msi_setvalid() 2373a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2374a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSI_SETVALID 2375a439fe51SSam Ravnborg * ARG0: devhandle 2376a439fe51SSam Ravnborg * ARG1: msinum 2377a439fe51SSam Ravnborg * ARG2: msivalidstate 2378a439fe51SSam Ravnborg * RET0: status 2379a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msinum or msivalidstate 2380a439fe51SSam Ravnborg * 2381a439fe51SSam Ravnborg * Set the current valid/enabled state for the MSI defined by the 2382a439fe51SSam Ravnborg * given devhandle and msinum. 2383a439fe51SSam Ravnborg */ 2384a439fe51SSam Ravnborg #define HV_FAST_PCI_MSI_SETVALID 0xca 2385a439fe51SSam Ravnborg 2386a439fe51SSam Ravnborg /* pci_msi_getmsiq() 2387a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2388a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSI_GETMSIQ 2389a439fe51SSam Ravnborg * ARG0: devhandle 2390a439fe51SSam Ravnborg * ARG1: msinum 2391a439fe51SSam Ravnborg * RET0: status 2392a439fe51SSam Ravnborg * RET1: msiqid 2393a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msinum or MSI is unbound 2394a439fe51SSam Ravnborg * 2395a439fe51SSam Ravnborg * Get the MSI EQ that the MSI defined by the given devhandle and 2396a439fe51SSam Ravnborg * msinum is bound to. 2397a439fe51SSam Ravnborg */ 2398a439fe51SSam Ravnborg #define HV_FAST_PCI_MSI_GETMSIQ 0xcb 2399a439fe51SSam Ravnborg 2400a439fe51SSam Ravnborg /* pci_msi_setmsiq() 2401a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2402a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSI_SETMSIQ 2403a439fe51SSam Ravnborg * ARG0: devhandle 2404a439fe51SSam Ravnborg * ARG1: msinum 2405a439fe51SSam Ravnborg * ARG2: msitype 2406a439fe51SSam Ravnborg * ARG3: msiqid 2407a439fe51SSam Ravnborg * RET0: status 2408a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msinum or msiqid 2409a439fe51SSam Ravnborg * 2410a439fe51SSam Ravnborg * Set the MSI EQ that the MSI defined by the given devhandle and 2411a439fe51SSam Ravnborg * msinum is bound to. 2412a439fe51SSam Ravnborg */ 2413a439fe51SSam Ravnborg #define HV_FAST_PCI_MSI_SETMSIQ 0xcc 2414a439fe51SSam Ravnborg 2415a439fe51SSam Ravnborg /* pci_msi_getstate() 2416a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2417a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSI_GETSTATE 2418a439fe51SSam Ravnborg * ARG0: devhandle 2419a439fe51SSam Ravnborg * ARG1: msinum 2420a439fe51SSam Ravnborg * RET0: status 2421a439fe51SSam Ravnborg * RET1: msistate 2422a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msinum 2423a439fe51SSam Ravnborg * 2424a439fe51SSam Ravnborg * Get the state of the MSI defined by the given devhandle and msinum. 2425a439fe51SSam Ravnborg * If not initialized, return HV_MSISTATE_IDLE. 2426a439fe51SSam Ravnborg */ 2427a439fe51SSam Ravnborg #define HV_FAST_PCI_MSI_GETSTATE 0xcd 2428a439fe51SSam Ravnborg 2429a439fe51SSam Ravnborg /* pci_msi_setstate() 2430a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2431a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSI_SETSTATE 2432a439fe51SSam Ravnborg * ARG0: devhandle 2433a439fe51SSam Ravnborg * ARG1: msinum 2434a439fe51SSam Ravnborg * ARG2: msistate 2435a439fe51SSam Ravnborg * RET0: status 2436a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msinum or msistate 2437a439fe51SSam Ravnborg * 2438a439fe51SSam Ravnborg * Set the state of the MSI defined by the given devhandle and msinum. 2439a439fe51SSam Ravnborg */ 2440a439fe51SSam Ravnborg #define HV_FAST_PCI_MSI_SETSTATE 0xce 2441a439fe51SSam Ravnborg 2442a439fe51SSam Ravnborg /* pci_msg_getmsiq() 2443a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2444a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSG_GETMSIQ 2445a439fe51SSam Ravnborg * ARG0: devhandle 2446a439fe51SSam Ravnborg * ARG1: msgtype 2447a439fe51SSam Ravnborg * RET0: status 2448a439fe51SSam Ravnborg * RET1: msiqid 2449a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msgtype 2450a439fe51SSam Ravnborg * 2451a439fe51SSam Ravnborg * Get the MSI EQ of the MSG defined by the given devhandle and msgtype. 2452a439fe51SSam Ravnborg */ 2453a439fe51SSam Ravnborg #define HV_FAST_PCI_MSG_GETMSIQ 0xd0 2454a439fe51SSam Ravnborg 2455a439fe51SSam Ravnborg /* pci_msg_setmsiq() 2456a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2457a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSG_SETMSIQ 2458a439fe51SSam Ravnborg * ARG0: devhandle 2459a439fe51SSam Ravnborg * ARG1: msgtype 2460a439fe51SSam Ravnborg * ARG2: msiqid 2461a439fe51SSam Ravnborg * RET0: status 2462a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle, msgtype, or msiqid 2463a439fe51SSam Ravnborg * 2464a439fe51SSam Ravnborg * Set the MSI EQ of the MSG defined by the given devhandle and msgtype. 2465a439fe51SSam Ravnborg */ 2466a439fe51SSam Ravnborg #define HV_FAST_PCI_MSG_SETMSIQ 0xd1 2467a439fe51SSam Ravnborg 2468a439fe51SSam Ravnborg /* pci_msg_getvalid() 2469a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2470a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSG_GETVALID 2471a439fe51SSam Ravnborg * ARG0: devhandle 2472a439fe51SSam Ravnborg * ARG1: msgtype 2473a439fe51SSam Ravnborg * RET0: status 2474a439fe51SSam Ravnborg * RET1: msgvalidstate 2475a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msgtype 2476a439fe51SSam Ravnborg * 2477a439fe51SSam Ravnborg * Get the valid/enabled state of the MSG defined by the given 2478a439fe51SSam Ravnborg * devhandle and msgtype. 2479a439fe51SSam Ravnborg */ 2480a439fe51SSam Ravnborg #define HV_FAST_PCI_MSG_GETVALID 0xd2 2481a439fe51SSam Ravnborg 2482a439fe51SSam Ravnborg /* pci_msg_setvalid() 2483a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2484a439fe51SSam Ravnborg * FUNCTION: HV_FAST_PCI_MSG_SETVALID 2485a439fe51SSam Ravnborg * ARG0: devhandle 2486a439fe51SSam Ravnborg * ARG1: msgtype 2487a439fe51SSam Ravnborg * ARG2: msgvalidstate 2488a439fe51SSam Ravnborg * RET0: status 2489a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid devhandle or msgtype or msgvalidstate 2490a439fe51SSam Ravnborg * 2491a439fe51SSam Ravnborg * Set the valid/enabled state of the MSG defined by the given 2492a439fe51SSam Ravnborg * devhandle and msgtype. 2493a439fe51SSam Ravnborg */ 2494a439fe51SSam Ravnborg #define HV_FAST_PCI_MSG_SETVALID 0xd3 2495a439fe51SSam Ravnborg 2496f0248c15STushar Dave /* PCI IOMMU v2 definitions and services 2497f0248c15STushar Dave * 2498f0248c15STushar Dave * While the PCI IO definitions above is valid IOMMU v2 adds new PCI IO 2499f0248c15STushar Dave * definitions and services. 2500f0248c15STushar Dave * 2501f0248c15STushar Dave * CTE Clump Table Entry. First level table entry in the ATU. 2502f0248c15STushar Dave * 2503f0248c15STushar Dave * pci_device_list 2504f0248c15STushar Dave * A 32-bit aligned list of pci_devices. 2505f0248c15STushar Dave * 2506f0248c15STushar Dave * pci_device_listp 2507f0248c15STushar Dave * real address of a pci_device_list. 32-bit aligned. 2508f0248c15STushar Dave * 2509f0248c15STushar Dave * iotte IOMMU translation table entry. 2510f0248c15STushar Dave * 2511f0248c15STushar Dave * iotte_attributes 2512f0248c15STushar Dave * IO Attributes for IOMMU v2 mappings. In addition to 2513f0248c15STushar Dave * read, write IOMMU v2 supports relax ordering 2514f0248c15STushar Dave * 2515f0248c15STushar Dave * io_page_list A 64-bit aligned list of real addresses. Each real 2516f0248c15STushar Dave * address in an io_page_list must be properly aligned 2517f0248c15STushar Dave * to the pagesize of the given IOTSB. 2518f0248c15STushar Dave * 2519f0248c15STushar Dave * io_page_list_p Real address of an io_page_list, 64-bit aligned. 2520f0248c15STushar Dave * 2521f0248c15STushar Dave * IOTSB IO Translation Storage Buffer. An aligned table of 2522f0248c15STushar Dave * IOTTEs. Each IOTSB has a pagesize, table size, and 2523f0248c15STushar Dave * virtual address associated with it that must match 2524f0248c15STushar Dave * a pagesize and table size supported by the un-derlying 2525f0248c15STushar Dave * hardware implementation. The alignment requirements 2526f0248c15STushar Dave * for an IOTSB depend on the pagesize used for that IOTSB. 2527f0248c15STushar Dave * Each IOTTE in an IOTSB maps one pagesize-sized page. 2528f0248c15STushar Dave * The size of the IOTSB dictates how large of a virtual 2529f0248c15STushar Dave * address space the IOTSB is capable of mapping. 2530f0248c15STushar Dave * 2531f0248c15STushar Dave * iotsb_handle An opaque identifier for an IOTSB. A devhandle plus 2532f0248c15STushar Dave * iotsb_handle represents a binding of an IOTSB to a 2533f0248c15STushar Dave * PCI root complex. 2534f0248c15STushar Dave * 2535f0248c15STushar Dave * iotsb_index Zero-based IOTTE number within an IOTSB. 2536f0248c15STushar Dave */ 2537f0248c15STushar Dave 2538f08978b0STushar Dave /* The index_count argument consists of two fields: 2539f08978b0STushar Dave * bits 63:48 #iottes and bits 47:0 iotsb_index 2540f08978b0STushar Dave */ 2541f08978b0STushar Dave #define HV_PCI_IOTSB_INDEX_COUNT(__iottes, __iotsb_index) \ 2542f08978b0STushar Dave (((u64)(__iottes) << 48UL) | ((u64)(__iotsb_index))) 2543f08978b0STushar Dave 2544f0248c15STushar Dave /* pci_iotsb_conf() 2545f0248c15STushar Dave * TRAP: HV_FAST_TRAP 2546f0248c15STushar Dave * FUNCTION: HV_FAST_PCI_IOTSB_CONF 2547f0248c15STushar Dave * ARG0: devhandle 2548f0248c15STushar Dave * ARG1: r_addr 2549f0248c15STushar Dave * ARG2: size 2550f0248c15STushar Dave * ARG3: pagesize 2551f0248c15STushar Dave * ARG4: iova 2552f0248c15STushar Dave * RET0: status 2553f0248c15STushar Dave * RET1: iotsb_handle 2554f0248c15STushar Dave * ERRORS: EINVAL Invalid devhandle, size, iova, or pagesize 2555f0248c15STushar Dave * EBADALIGN r_addr is not properly aligned 2556f0248c15STushar Dave * ENORADDR r_addr is not a valid real address 2557f0248c15STushar Dave * ETOOMANY No further IOTSBs may be configured 2558f0248c15STushar Dave * EBUSY Duplicate devhandle, raddir, iova combination 2559f0248c15STushar Dave * 2560f0248c15STushar Dave * Create an IOTSB suitable for the PCI root complex identified by devhandle, 2561f0248c15STushar Dave * for the DMA virtual address defined by the argument iova. 2562f0248c15STushar Dave * 2563f0248c15STushar Dave * r_addr is the properly aligned base address of the IOTSB and size is the 2564f0248c15STushar Dave * IOTSB (table) size in bytes.The IOTSB is required to be zeroed prior to 2565f0248c15STushar Dave * being configured. If it contains any values other than zeros then the 2566f0248c15STushar Dave * behavior is undefined. 2567f0248c15STushar Dave * 2568f0248c15STushar Dave * pagesize is the size of each page in the IOTSB. Note that the combination of 2569f0248c15STushar Dave * size (table size) and pagesize must be valid. 2570f0248c15STushar Dave * 2571f0248c15STushar Dave * virt is the DMA virtual address this IOTSB will map. 2572f0248c15STushar Dave * 2573f0248c15STushar Dave * If successful, the opaque 64-bit handle iotsb_handle is returned in ret1. 2574f0248c15STushar Dave * Once configured, privileged access to the IOTSB memory is prohibited and 2575f0248c15STushar Dave * creates undefined behavior. The only permitted access is indirect via these 2576f0248c15STushar Dave * services. 2577f0248c15STushar Dave */ 2578f0248c15STushar Dave #define HV_FAST_PCI_IOTSB_CONF 0x190 2579f0248c15STushar Dave 2580f0248c15STushar Dave /* pci_iotsb_info() 2581f0248c15STushar Dave * TRAP: HV_FAST_TRAP 2582f0248c15STushar Dave * FUNCTION: HV_FAST_PCI_IOTSB_INFO 2583f0248c15STushar Dave * ARG0: devhandle 2584f0248c15STushar Dave * ARG1: iotsb_handle 2585f0248c15STushar Dave * RET0: status 2586f0248c15STushar Dave * RET1: r_addr 2587f0248c15STushar Dave * RET2: size 2588f0248c15STushar Dave * RET3: pagesize 2589f0248c15STushar Dave * RET4: iova 2590f0248c15STushar Dave * RET5: #bound 2591f0248c15STushar Dave * ERRORS: EINVAL Invalid devhandle or iotsb_handle 2592f0248c15STushar Dave * 2593f0248c15STushar Dave * This service returns configuration information about an IOTSB previously 2594f0248c15STushar Dave * created with pci_iotsb_conf. 2595f0248c15STushar Dave * 2596f0248c15STushar Dave * iotsb_handle value 0 may be used with this service to inquire about the 2597f0248c15STushar Dave * legacy IOTSB that may or may not exist. If the service succeeds, the return 2598f0248c15STushar Dave * values describe the legacy IOTSB and I/O virtual addresses mapped by that 2599f0248c15STushar Dave * table. However, the table base address r_addr may contain the value -1 which 2600f0248c15STushar Dave * indicates a memory range that cannot be accessed or be reclaimed. 2601f0248c15STushar Dave * 2602f0248c15STushar Dave * The return value #bound contains the number of PCI devices that iotsb_handle 2603f0248c15STushar Dave * is currently bound to. 2604f0248c15STushar Dave */ 2605f0248c15STushar Dave #define HV_FAST_PCI_IOTSB_INFO 0x191 2606f0248c15STushar Dave 2607f0248c15STushar Dave /* pci_iotsb_unconf() 2608f0248c15STushar Dave * TRAP: HV_FAST_TRAP 2609f0248c15STushar Dave * FUNCTION: HV_FAST_PCI_IOTSB_UNCONF 2610f0248c15STushar Dave * ARG0: devhandle 2611f0248c15STushar Dave * ARG1: iotsb_handle 2612f0248c15STushar Dave * RET0: status 2613f0248c15STushar Dave * ERRORS: EINVAL Invalid devhandle or iotsb_handle 2614f0248c15STushar Dave * EBUSY The IOTSB is bound and may not be unconfigured 2615f0248c15STushar Dave * 2616f0248c15STushar Dave * This service unconfigures the IOTSB identified by the devhandle and 2617f0248c15STushar Dave * iotsb_handle arguments, previously created with pci_iotsb_conf. 2618f0248c15STushar Dave * The IOTSB must not be currently bound to any device or the service will fail 2619f0248c15STushar Dave * 2620f0248c15STushar Dave * If the call succeeds, iotsb_handle is no longer valid. 2621f0248c15STushar Dave */ 2622f0248c15STushar Dave #define HV_FAST_PCI_IOTSB_UNCONF 0x192 2623f0248c15STushar Dave 2624f0248c15STushar Dave /* pci_iotsb_bind() 2625f0248c15STushar Dave * TRAP: HV_FAST_TRAP 2626f0248c15STushar Dave * FUNCTION: HV_FAST_PCI_IOTSB_BIND 2627f0248c15STushar Dave * ARG0: devhandle 2628f0248c15STushar Dave * ARG1: iotsb_handle 2629f0248c15STushar Dave * ARG2: pci_device 2630f0248c15STushar Dave * RET0: status 2631f0248c15STushar Dave * ERRORS: EINVAL Invalid devhandle, iotsb_handle, or pci_device 2632f0248c15STushar Dave * EBUSY A PCI function is already bound to an IOTSB at the same 2633f0248c15STushar Dave * address range as specified by devhandle, iotsb_handle. 2634f0248c15STushar Dave * 2635f0248c15STushar Dave * This service binds the PCI function specified by the argument pci_device to 2636f0248c15STushar Dave * the IOTSB specified by the arguments devhandle and iotsb_handle. 2637f0248c15STushar Dave * 2638f0248c15STushar Dave * The PCI device function is bound to the specified IOTSB with the IOVA range 2639f0248c15STushar Dave * specified when the IOTSB was configured via pci_iotsb_conf. If the function 2640f0248c15STushar Dave * is already bound then it is unbound first. 2641f0248c15STushar Dave */ 2642f0248c15STushar Dave #define HV_FAST_PCI_IOTSB_BIND 0x193 2643f0248c15STushar Dave 2644f0248c15STushar Dave /* pci_iotsb_unbind() 2645f0248c15STushar Dave * TRAP: HV_FAST_TRAP 2646f0248c15STushar Dave * FUNCTION: HV_FAST_PCI_IOTSB_UNBIND 2647f0248c15STushar Dave * ARG0: devhandle 2648f0248c15STushar Dave * ARG1: iotsb_handle 2649f0248c15STushar Dave * ARG2: pci_device 2650f0248c15STushar Dave * RET0: status 2651f0248c15STushar Dave * ERRORS: EINVAL Invalid devhandle, iotsb_handle, or pci_device 2652f0248c15STushar Dave * ENOMAP The PCI function was not bound to the specified IOTSB 2653f0248c15STushar Dave * 2654f0248c15STushar Dave * This service unbinds the PCI device specified by the argument pci_device 2655f0248c15STushar Dave * from the IOTSB identified * by the arguments devhandle and iotsb_handle. 2656f0248c15STushar Dave * 2657f0248c15STushar Dave * If the PCI device is not bound to the specified IOTSB then this service will 2658f0248c15STushar Dave * fail with status ENOMAP 2659f0248c15STushar Dave */ 2660f0248c15STushar Dave #define HV_FAST_PCI_IOTSB_UNBIND 0x194 2661f0248c15STushar Dave 2662f0248c15STushar Dave /* pci_iotsb_get_binding() 2663f0248c15STushar Dave * TRAP: HV_FAST_TRAP 2664f0248c15STushar Dave * FUNCTION: HV_FAST_PCI_IOTSB_GET_BINDING 2665f0248c15STushar Dave * ARG0: devhandle 2666f0248c15STushar Dave * ARG1: iotsb_handle 2667f0248c15STushar Dave * ARG2: iova 2668f0248c15STushar Dave * RET0: status 2669f0248c15STushar Dave * RET1: iotsb_handle 2670f0248c15STushar Dave * ERRORS: EINVAL Invalid devhandle, pci_device, or iova 2671f0248c15STushar Dave * ENOMAP The PCI function is not bound to an IOTSB at iova 2672f0248c15STushar Dave * 2673f0248c15STushar Dave * This service returns the IOTSB binding, iotsb_handle, for a given pci_device 2674f0248c15STushar Dave * and DMA virtual address, iova. 2675f0248c15STushar Dave * 2676f0248c15STushar Dave * iova must be the base address of a DMA virtual address range as defined by 2677f0248c15STushar Dave * the iommu-address-ranges property in the root complex device node defined 2678f0248c15STushar Dave * by the argument devhandle. 2679f0248c15STushar Dave */ 2680f0248c15STushar Dave #define HV_FAST_PCI_IOTSB_GET_BINDING 0x195 2681f0248c15STushar Dave 2682f0248c15STushar Dave /* pci_iotsb_map() 2683f0248c15STushar Dave * TRAP: HV_FAST_TRAP 2684f0248c15STushar Dave * FUNCTION: HV_FAST_PCI_IOTSB_MAP 2685f0248c15STushar Dave * ARG0: devhandle 2686f0248c15STushar Dave * ARG1: iotsb_handle 2687f0248c15STushar Dave * ARG2: index_count 2688f0248c15STushar Dave * ARG3: iotte_attributes 2689f0248c15STushar Dave * ARG4: io_page_list_p 2690f0248c15STushar Dave * RET0: status 2691f0248c15STushar Dave * RET1: #mapped 2692f0248c15STushar Dave * ERRORS: EINVAL Invalid devhandle, iotsb_handle, #iottes, 2693f0248c15STushar Dave * iotsb_index or iotte_attributes 2694f0248c15STushar Dave * EBADALIGN Improperly aligned io_page_list_p or I/O page 2695f0248c15STushar Dave * address in the I/O page list. 2696f0248c15STushar Dave * ENORADDR Invalid io_page_list_p or I/O page address in 2697f0248c15STushar Dave * the I/O page list. 2698f0248c15STushar Dave * 2699f0248c15STushar Dave * This service creates and flushes mappings in the IOTSB defined by the 2700f0248c15STushar Dave * arguments devhandle, iotsb. 2701f0248c15STushar Dave * 2702f0248c15STushar Dave * The index_count argument consists of two fields. Bits 63:48 contain #iotte 2703f0248c15STushar Dave * and bits 47:0 contain iotsb_index 2704f0248c15STushar Dave * 2705f0248c15STushar Dave * The first mapping is created in the IOTSB index specified by iotsb_index. 2706f0248c15STushar Dave * Subsequent mappings are created at iotsb_index+1 and so on. 2707f0248c15STushar Dave * 2708f0248c15STushar Dave * The attributes of each mapping are defined by the argument iotte_attributes. 2709f0248c15STushar Dave * 2710f0248c15STushar Dave * The io_page_list_p specifies the real address of the 64-bit-aligned list of 2711f0248c15STushar Dave * #iottes I/O page addresses. Each page address must be a properly aligned 2712f0248c15STushar Dave * real address of a page to be mapped in the IOTSB. The first entry in the I/O 2713f0248c15STushar Dave * page list contains the real address of the first page, the 2nd entry for the 2714f0248c15STushar Dave * 2nd page, and so on. 2715f0248c15STushar Dave * 2716f0248c15STushar Dave * #iottes must be greater than zero. 2717f0248c15STushar Dave * 2718f0248c15STushar Dave * The return value #mapped is the actual number of mappings created, which may 2719f0248c15STushar Dave * be less than or equal to the argument #iottes. If the function returns 2720f0248c15STushar Dave * successfully with a #mapped value less than the requested #iottes then the 2721f0248c15STushar Dave * caller should continue to invoke the service with updated iotsb_index, 2722f0248c15STushar Dave * #iottes, and io_page_list_p arguments until all pages are mapped. 2723f0248c15STushar Dave * 2724f0248c15STushar Dave * This service must not be used to demap a mapping. In other words, all 2725f0248c15STushar Dave * mappings must be valid and have one or both of the RW attribute bits set. 2726f0248c15STushar Dave * 2727f0248c15STushar Dave * Note: 2728f0248c15STushar Dave * It is implementation-defined whether I/O page real address validity checking 2729f0248c15STushar Dave * is done at time mappings are established or deferred until they are 2730f0248c15STushar Dave * accessed. 2731f0248c15STushar Dave */ 2732f0248c15STushar Dave #define HV_FAST_PCI_IOTSB_MAP 0x196 2733f0248c15STushar Dave 2734f0248c15STushar Dave /* pci_iotsb_map_one() 2735f0248c15STushar Dave * TRAP: HV_FAST_TRAP 2736f0248c15STushar Dave * FUNCTION: HV_FAST_PCI_IOTSB_MAP_ONE 2737f0248c15STushar Dave * ARG0: devhandle 2738f0248c15STushar Dave * ARG1: iotsb_handle 2739f0248c15STushar Dave * ARG2: iotsb_index 2740f0248c15STushar Dave * ARG3: iotte_attributes 2741f0248c15STushar Dave * ARG4: r_addr 2742f0248c15STushar Dave * RET0: status 2743f0248c15STushar Dave * ERRORS: EINVAL Invalid devhandle,iotsb_handle, iotsb_index 2744f0248c15STushar Dave * or iotte_attributes 2745f0248c15STushar Dave * EBADALIGN Improperly aligned r_addr 2746f0248c15STushar Dave * ENORADDR Invalid r_addr 2747f0248c15STushar Dave * 2748f0248c15STushar Dave * This service creates and flushes a single mapping in the IOTSB defined by the 2749f0248c15STushar Dave * arguments devhandle, iotsb. 2750f0248c15STushar Dave * 2751f0248c15STushar Dave * The mapping for the page at r_addr is created at the IOTSB index specified by 2752f0248c15STushar Dave * iotsb_index with the attributes iotte_attributes. 2753f0248c15STushar Dave * 2754f0248c15STushar Dave * This service must not be used to demap a mapping. In other words, the mapping 2755f0248c15STushar Dave * must be valid and have one or both of the RW attribute bits set. 2756f0248c15STushar Dave * 2757f0248c15STushar Dave * Note: 2758f0248c15STushar Dave * It is implementation-defined whether I/O page real address validity checking 2759f0248c15STushar Dave * is done at time mappings are established or deferred until they are 2760f0248c15STushar Dave * accessed. 2761f0248c15STushar Dave */ 2762f0248c15STushar Dave #define HV_FAST_PCI_IOTSB_MAP_ONE 0x197 2763f0248c15STushar Dave 2764f0248c15STushar Dave /* pci_iotsb_demap() 2765f0248c15STushar Dave * TRAP: HV_FAST_TRAP 2766f0248c15STushar Dave * FUNCTION: HV_FAST_PCI_IOTSB_DEMAP 2767f0248c15STushar Dave * ARG0: devhandle 2768f0248c15STushar Dave * ARG1: iotsb_handle 2769f0248c15STushar Dave * ARG2: iotsb_index 2770f0248c15STushar Dave * ARG3: #iottes 2771f0248c15STushar Dave * RET0: status 2772f0248c15STushar Dave * RET1: #unmapped 2773f0248c15STushar Dave * ERRORS: EINVAL Invalid devhandle, iotsb_handle, iotsb_index or #iottes 2774f0248c15STushar Dave * 2775f0248c15STushar Dave * This service unmaps and flushes up to #iottes mappings starting at index 2776f0248c15STushar Dave * iotsb_index from the IOTSB defined by the arguments devhandle, iotsb. 2777f0248c15STushar Dave * 2778f0248c15STushar Dave * #iottes must be greater than zero. 2779f0248c15STushar Dave * 2780f0248c15STushar Dave * The actual number of IOTTEs unmapped is returned in #unmapped and may be less 2781f0248c15STushar Dave * than or equal to the requested number of IOTTEs, #iottes. 2782f0248c15STushar Dave * 2783f0248c15STushar Dave * If #unmapped is less than #iottes, the caller should continue to invoke this 2784f0248c15STushar Dave * service with updated iotsb_index and #iottes arguments until all pages are 2785f0248c15STushar Dave * demapped. 2786f0248c15STushar Dave */ 2787f0248c15STushar Dave #define HV_FAST_PCI_IOTSB_DEMAP 0x198 2788f0248c15STushar Dave 2789f0248c15STushar Dave /* pci_iotsb_getmap() 2790f0248c15STushar Dave * TRAP: HV_FAST_TRAP 2791f0248c15STushar Dave * FUNCTION: HV_FAST_PCI_IOTSB_GETMAP 2792f0248c15STushar Dave * ARG0: devhandle 2793f0248c15STushar Dave * ARG1: iotsb_handle 2794f0248c15STushar Dave * ARG2: iotsb_index 2795f0248c15STushar Dave * RET0: status 2796f0248c15STushar Dave * RET1: r_addr 2797f0248c15STushar Dave * RET2: iotte_attributes 2798f0248c15STushar Dave * ERRORS: EINVAL Invalid devhandle, iotsb_handle, or iotsb_index 2799f0248c15STushar Dave * ENOMAP No mapping was found 2800f0248c15STushar Dave * 2801f0248c15STushar Dave * This service returns the mapping specified by index iotsb_index from the 2802f0248c15STushar Dave * IOTSB defined by the arguments devhandle, iotsb. 2803f0248c15STushar Dave * 2804f0248c15STushar Dave * Upon success, the real address of the mapping shall be returned in 2805f0248c15STushar Dave * r_addr and thethe IOTTE mapping attributes shall be returned in 2806f0248c15STushar Dave * iotte_attributes. 2807f0248c15STushar Dave * 2808f0248c15STushar Dave * The return value iotte_attributes may not include optional features used in 2809f0248c15STushar Dave * the call to create the mapping. 2810f0248c15STushar Dave */ 2811f0248c15STushar Dave #define HV_FAST_PCI_IOTSB_GETMAP 0x199 2812f0248c15STushar Dave 2813f0248c15STushar Dave /* pci_iotsb_sync_mappings() 2814f0248c15STushar Dave * TRAP: HV_FAST_TRAP 2815f0248c15STushar Dave * FUNCTION: HV_FAST_PCI_IOTSB_SYNC_MAPPINGS 2816f0248c15STushar Dave * ARG0: devhandle 2817f0248c15STushar Dave * ARG1: iotsb_handle 2818f0248c15STushar Dave * ARG2: iotsb_index 2819f0248c15STushar Dave * ARG3: #iottes 2820f0248c15STushar Dave * RET0: status 2821f0248c15STushar Dave * RET1: #synced 2822f0248c15STushar Dave * ERROS: EINVAL Invalid devhandle, iotsb_handle, iotsb_index, or #iottes 2823f0248c15STushar Dave * 2824f0248c15STushar Dave * This service synchronizes #iottes mappings starting at index iotsb_index in 2825f0248c15STushar Dave * the IOTSB defined by the arguments devhandle, iotsb. 2826f0248c15STushar Dave * 2827f0248c15STushar Dave * #iottes must be greater than zero. 2828f0248c15STushar Dave * 2829f0248c15STushar Dave * The actual number of IOTTEs synchronized is returned in #synced, which may 2830f0248c15STushar Dave * be less than or equal to the requested number, #iottes. 2831f0248c15STushar Dave * 2832f0248c15STushar Dave * Upon a successful return, #synced is less than #iottes, the caller should 2833f0248c15STushar Dave * continue to invoke this service with updated iotsb_index and #iottes 2834f0248c15STushar Dave * arguments until all pages are synchronized. 2835f0248c15STushar Dave */ 2836f0248c15STushar Dave #define HV_FAST_PCI_IOTSB_SYNC_MAPPINGS 0x19a 2837f0248c15STushar Dave 2838a439fe51SSam Ravnborg /* Logical Domain Channel services. */ 2839a439fe51SSam Ravnborg 2840a439fe51SSam Ravnborg #define LDC_CHANNEL_DOWN 0 2841a439fe51SSam Ravnborg #define LDC_CHANNEL_UP 1 2842a439fe51SSam Ravnborg #define LDC_CHANNEL_RESETTING 2 2843a439fe51SSam Ravnborg 2844a439fe51SSam Ravnborg /* ldc_tx_qconf() 2845a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2846a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_TX_QCONF 2847a439fe51SSam Ravnborg * ARG0: channel ID 2848a439fe51SSam Ravnborg * ARG1: real address base of queue 2849a439fe51SSam Ravnborg * ARG2: num entries in queue 2850a439fe51SSam Ravnborg * RET0: status 2851a439fe51SSam Ravnborg * 2852a439fe51SSam Ravnborg * Configure transmit queue for the LDC endpoint specified by the 2853a439fe51SSam Ravnborg * given channel ID, to be placed at the given real address, and 2854a439fe51SSam Ravnborg * be of the given num entries. Num entries must be a power of two. 2855a439fe51SSam Ravnborg * The real address base of the queue must be aligned on the queue 2856a439fe51SSam Ravnborg * size. Each queue entry is 64-bytes, so for example, a 32 entry 2857a439fe51SSam Ravnborg * queue must be aligned on a 2048 byte real address boundary. 2858a439fe51SSam Ravnborg * 2859a439fe51SSam Ravnborg * Upon configuration of a valid transmit queue the head and tail 2860a439fe51SSam Ravnborg * pointers are set to a hypervisor specific identical value indicating 2861a439fe51SSam Ravnborg * that the queue initially is empty. 2862a439fe51SSam Ravnborg * 2863a439fe51SSam Ravnborg * The endpoint's transmit queue is un-configured if num entries is zero. 2864a439fe51SSam Ravnborg * 2865a439fe51SSam Ravnborg * The maximum number of entries for each queue for a specific cpu may be 2866a439fe51SSam Ravnborg * determined from the machine description. A transmit queue may be 2867a439fe51SSam Ravnborg * specified even in the event that the LDC is down (peer endpoint has no 2868a439fe51SSam Ravnborg * receive queue specified). Transmission will begin as soon as the peer 2869a439fe51SSam Ravnborg * endpoint defines a receive queue. 2870a439fe51SSam Ravnborg * 2871a439fe51SSam Ravnborg * It is recommended that a guest wait for a transmit queue to empty prior 2872a439fe51SSam Ravnborg * to reconfiguring it, or un-configuring it. Re or un-configuring of a 2873a439fe51SSam Ravnborg * non-empty transmit queue behaves exactly as defined above, however it 2874a439fe51SSam Ravnborg * is undefined as to how many of the pending entries in the original queue 2875a439fe51SSam Ravnborg * will be delivered prior to the re-configuration taking effect. 2876a439fe51SSam Ravnborg * Furthermore, as the queue configuration causes a reset of the head and 2877a439fe51SSam Ravnborg * tail pointers there is no way for a guest to determine how many entries 2878a439fe51SSam Ravnborg * have been sent after the configuration operation. 2879a439fe51SSam Ravnborg */ 2880a439fe51SSam Ravnborg #define HV_FAST_LDC_TX_QCONF 0xe0 2881a439fe51SSam Ravnborg 2882a439fe51SSam Ravnborg /* ldc_tx_qinfo() 2883a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2884a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_TX_QINFO 2885a439fe51SSam Ravnborg * ARG0: channel ID 2886a439fe51SSam Ravnborg * RET0: status 2887a439fe51SSam Ravnborg * RET1: real address base of queue 2888a439fe51SSam Ravnborg * RET2: num entries in queue 2889a439fe51SSam Ravnborg * 2890a439fe51SSam Ravnborg * Return the configuration info for the transmit queue of LDC endpoint 2891a439fe51SSam Ravnborg * defined by the given channel ID. The real address is the currently 2892a439fe51SSam Ravnborg * defined real address base of the defined queue, and num entries is the 2893a439fe51SSam Ravnborg * size of the queue in terms of number of entries. 2894a439fe51SSam Ravnborg * 2895a439fe51SSam Ravnborg * If the specified channel ID is a valid endpoint number, but no transmit 2896a439fe51SSam Ravnborg * queue has been defined this service will return success, but with num 2897a439fe51SSam Ravnborg * entries set to zero and the real address will have an undefined value. 2898a439fe51SSam Ravnborg */ 2899a439fe51SSam Ravnborg #define HV_FAST_LDC_TX_QINFO 0xe1 2900a439fe51SSam Ravnborg 2901a439fe51SSam Ravnborg /* ldc_tx_get_state() 2902a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2903a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_TX_GET_STATE 2904a439fe51SSam Ravnborg * ARG0: channel ID 2905a439fe51SSam Ravnborg * RET0: status 2906a439fe51SSam Ravnborg * RET1: head offset 2907a439fe51SSam Ravnborg * RET2: tail offset 2908a439fe51SSam Ravnborg * RET3: channel state 2909a439fe51SSam Ravnborg * 2910a439fe51SSam Ravnborg * Return the transmit state, and the head and tail queue pointers, for 2911a439fe51SSam Ravnborg * the transmit queue of the LDC endpoint defined by the given channel ID. 2912a439fe51SSam Ravnborg * The head and tail values are the byte offset of the head and tail 2913a439fe51SSam Ravnborg * positions of the transmit queue for the specified endpoint. 2914a439fe51SSam Ravnborg */ 2915a439fe51SSam Ravnborg #define HV_FAST_LDC_TX_GET_STATE 0xe2 2916a439fe51SSam Ravnborg 2917a439fe51SSam Ravnborg /* ldc_tx_set_qtail() 2918a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2919a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_TX_SET_QTAIL 2920a439fe51SSam Ravnborg * ARG0: channel ID 2921a439fe51SSam Ravnborg * ARG1: tail offset 2922a439fe51SSam Ravnborg * RET0: status 2923a439fe51SSam Ravnborg * 2924a439fe51SSam Ravnborg * Update the tail pointer for the transmit queue associated with the LDC 2925a439fe51SSam Ravnborg * endpoint defined by the given channel ID. The tail offset specified 2926a439fe51SSam Ravnborg * must be aligned on a 64 byte boundary, and calculated so as to increase 2927a439fe51SSam Ravnborg * the number of pending entries on the transmit queue. Any attempt to 2928a439fe51SSam Ravnborg * decrease the number of pending transmit queue entires is considered 2929a439fe51SSam Ravnborg * an invalid tail offset and will result in an EINVAL error. 2930a439fe51SSam Ravnborg * 2931a439fe51SSam Ravnborg * Since the tail of the transmit queue may not be moved backwards, the 2932a439fe51SSam Ravnborg * transmit queue may be flushed by configuring a new transmit queue, 2933a439fe51SSam Ravnborg * whereupon the hypervisor will configure the initial transmit head and 2934a439fe51SSam Ravnborg * tail pointers to be equal. 2935a439fe51SSam Ravnborg */ 2936a439fe51SSam Ravnborg #define HV_FAST_LDC_TX_SET_QTAIL 0xe3 2937a439fe51SSam Ravnborg 2938a439fe51SSam Ravnborg /* ldc_rx_qconf() 2939a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2940a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_RX_QCONF 2941a439fe51SSam Ravnborg * ARG0: channel ID 2942a439fe51SSam Ravnborg * ARG1: real address base of queue 2943a439fe51SSam Ravnborg * ARG2: num entries in queue 2944a439fe51SSam Ravnborg * RET0: status 2945a439fe51SSam Ravnborg * 2946a439fe51SSam Ravnborg * Configure receive queue for the LDC endpoint specified by the 2947a439fe51SSam Ravnborg * given channel ID, to be placed at the given real address, and 2948a439fe51SSam Ravnborg * be of the given num entries. Num entries must be a power of two. 2949a439fe51SSam Ravnborg * The real address base of the queue must be aligned on the queue 2950a439fe51SSam Ravnborg * size. Each queue entry is 64-bytes, so for example, a 32 entry 2951a439fe51SSam Ravnborg * queue must be aligned on a 2048 byte real address boundary. 2952a439fe51SSam Ravnborg * 2953a439fe51SSam Ravnborg * The endpoint's transmit queue is un-configured if num entries is zero. 2954a439fe51SSam Ravnborg * 2955a439fe51SSam Ravnborg * If a valid receive queue is specified for a local endpoint the LDC is 2956a439fe51SSam Ravnborg * in the up state for the purpose of transmission to this endpoint. 2957a439fe51SSam Ravnborg * 2958a439fe51SSam Ravnborg * The maximum number of entries for each queue for a specific cpu may be 2959a439fe51SSam Ravnborg * determined from the machine description. 2960a439fe51SSam Ravnborg * 2961a439fe51SSam Ravnborg * As receive queue configuration causes a reset of the queue's head and 2962a439fe51SSam Ravnborg * tail pointers there is no way for a gues to determine how many entries 296325985edcSLucas De Marchi * have been received between a preceding ldc_get_rx_state() API call 2964a439fe51SSam Ravnborg * and the completion of the configuration operation. It should be noted 296525985edcSLucas De Marchi * that datagram delivery is not guaranteed via domain channels anyway, 2966a439fe51SSam Ravnborg * and therefore any higher protocol should be resilient to datagram 2967a439fe51SSam Ravnborg * loss if necessary. However, to overcome this specific race potential 2968a439fe51SSam Ravnborg * it is recommended, for example, that a higher level protocol be employed 2969a439fe51SSam Ravnborg * to ensure either retransmission, or ensure that no datagrams are pending 2970a439fe51SSam Ravnborg * on the peer endpoint's transmit queue prior to the configuration process. 2971a439fe51SSam Ravnborg */ 2972a439fe51SSam Ravnborg #define HV_FAST_LDC_RX_QCONF 0xe4 2973a439fe51SSam Ravnborg 2974a439fe51SSam Ravnborg /* ldc_rx_qinfo() 2975a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2976a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_RX_QINFO 2977a439fe51SSam Ravnborg * ARG0: channel ID 2978a439fe51SSam Ravnborg * RET0: status 2979a439fe51SSam Ravnborg * RET1: real address base of queue 2980a439fe51SSam Ravnborg * RET2: num entries in queue 2981a439fe51SSam Ravnborg * 2982a439fe51SSam Ravnborg * Return the configuration info for the receive queue of LDC endpoint 2983a439fe51SSam Ravnborg * defined by the given channel ID. The real address is the currently 2984a439fe51SSam Ravnborg * defined real address base of the defined queue, and num entries is the 2985a439fe51SSam Ravnborg * size of the queue in terms of number of entries. 2986a439fe51SSam Ravnborg * 2987a439fe51SSam Ravnborg * If the specified channel ID is a valid endpoint number, but no receive 2988a439fe51SSam Ravnborg * queue has been defined this service will return success, but with num 2989a439fe51SSam Ravnborg * entries set to zero and the real address will have an undefined value. 2990a439fe51SSam Ravnborg */ 2991a439fe51SSam Ravnborg #define HV_FAST_LDC_RX_QINFO 0xe5 2992a439fe51SSam Ravnborg 2993a439fe51SSam Ravnborg /* ldc_rx_get_state() 2994a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 2995a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_RX_GET_STATE 2996a439fe51SSam Ravnborg * ARG0: channel ID 2997a439fe51SSam Ravnborg * RET0: status 2998a439fe51SSam Ravnborg * RET1: head offset 2999a439fe51SSam Ravnborg * RET2: tail offset 3000a439fe51SSam Ravnborg * RET3: channel state 3001a439fe51SSam Ravnborg * 3002a439fe51SSam Ravnborg * Return the receive state, and the head and tail queue pointers, for 3003a439fe51SSam Ravnborg * the receive queue of the LDC endpoint defined by the given channel ID. 3004a439fe51SSam Ravnborg * The head and tail values are the byte offset of the head and tail 3005a439fe51SSam Ravnborg * positions of the receive queue for the specified endpoint. 3006a439fe51SSam Ravnborg */ 3007a439fe51SSam Ravnborg #define HV_FAST_LDC_RX_GET_STATE 0xe6 3008a439fe51SSam Ravnborg 3009a439fe51SSam Ravnborg /* ldc_rx_set_qhead() 3010a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 3011a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_RX_SET_QHEAD 3012a439fe51SSam Ravnborg * ARG0: channel ID 3013a439fe51SSam Ravnborg * ARG1: head offset 3014a439fe51SSam Ravnborg * RET0: status 3015a439fe51SSam Ravnborg * 3016a439fe51SSam Ravnborg * Update the head pointer for the receive queue associated with the LDC 3017a439fe51SSam Ravnborg * endpoint defined by the given channel ID. The head offset specified 3018a439fe51SSam Ravnborg * must be aligned on a 64 byte boundary, and calculated so as to decrease 3019a439fe51SSam Ravnborg * the number of pending entries on the receive queue. Any attempt to 3020a439fe51SSam Ravnborg * increase the number of pending receive queue entires is considered 3021a439fe51SSam Ravnborg * an invalid head offset and will result in an EINVAL error. 3022a439fe51SSam Ravnborg * 3023a439fe51SSam Ravnborg * The receive queue may be flushed by setting the head offset equal 3024a439fe51SSam Ravnborg * to the current tail offset. 3025a439fe51SSam Ravnborg */ 3026a439fe51SSam Ravnborg #define HV_FAST_LDC_RX_SET_QHEAD 0xe7 3027a439fe51SSam Ravnborg 3028a439fe51SSam Ravnborg /* LDC Map Table Entry. Each slot is defined by a translation table 3029a439fe51SSam Ravnborg * entry, as specified by the LDC_MTE_* bits below, and a 64-bit 3030a439fe51SSam Ravnborg * hypervisor invalidation cookie. 3031a439fe51SSam Ravnborg */ 3032a439fe51SSam Ravnborg #define LDC_MTE_PADDR 0x0fffffffffffe000 /* pa[55:13] */ 3033a439fe51SSam Ravnborg #define LDC_MTE_COPY_W 0x0000000000000400 /* copy write access */ 3034a439fe51SSam Ravnborg #define LDC_MTE_COPY_R 0x0000000000000200 /* copy read access */ 3035a439fe51SSam Ravnborg #define LDC_MTE_IOMMU_W 0x0000000000000100 /* IOMMU write access */ 3036a439fe51SSam Ravnborg #define LDC_MTE_IOMMU_R 0x0000000000000080 /* IOMMU read access */ 3037a439fe51SSam Ravnborg #define LDC_MTE_EXEC 0x0000000000000040 /* execute */ 3038a439fe51SSam Ravnborg #define LDC_MTE_WRITE 0x0000000000000020 /* read */ 3039a439fe51SSam Ravnborg #define LDC_MTE_READ 0x0000000000000010 /* write */ 3040a439fe51SSam Ravnborg #define LDC_MTE_SZALL 0x000000000000000f /* page size bits */ 3041a439fe51SSam Ravnborg #define LDC_MTE_SZ16GB 0x0000000000000007 /* 16GB page */ 3042a439fe51SSam Ravnborg #define LDC_MTE_SZ2GB 0x0000000000000006 /* 2GB page */ 3043a439fe51SSam Ravnborg #define LDC_MTE_SZ256MB 0x0000000000000005 /* 256MB page */ 3044a439fe51SSam Ravnborg #define LDC_MTE_SZ32MB 0x0000000000000004 /* 32MB page */ 3045a439fe51SSam Ravnborg #define LDC_MTE_SZ4MB 0x0000000000000003 /* 4MB page */ 3046a439fe51SSam Ravnborg #define LDC_MTE_SZ512K 0x0000000000000002 /* 512K page */ 3047a439fe51SSam Ravnborg #define LDC_MTE_SZ64K 0x0000000000000001 /* 64K page */ 3048a439fe51SSam Ravnborg #define LDC_MTE_SZ8K 0x0000000000000000 /* 8K page */ 3049a439fe51SSam Ravnborg 3050a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 3051a439fe51SSam Ravnborg struct ldc_mtable_entry { 3052a439fe51SSam Ravnborg unsigned long mte; 3053a439fe51SSam Ravnborg unsigned long cookie; 3054a439fe51SSam Ravnborg }; 3055a439fe51SSam Ravnborg #endif 3056a439fe51SSam Ravnborg 3057a439fe51SSam Ravnborg /* ldc_set_map_table() 3058a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 3059a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_SET_MAP_TABLE 3060a439fe51SSam Ravnborg * ARG0: channel ID 3061a439fe51SSam Ravnborg * ARG1: table real address 3062a439fe51SSam Ravnborg * ARG2: num entries 3063a439fe51SSam Ravnborg * RET0: status 3064a439fe51SSam Ravnborg * 3065a439fe51SSam Ravnborg * Register the MTE table at the given table real address, with the 3066a439fe51SSam Ravnborg * specified num entries, for the LDC indicated by the given channel 3067a439fe51SSam Ravnborg * ID. 3068a439fe51SSam Ravnborg */ 3069a439fe51SSam Ravnborg #define HV_FAST_LDC_SET_MAP_TABLE 0xea 3070a439fe51SSam Ravnborg 3071a439fe51SSam Ravnborg /* ldc_get_map_table() 3072a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 3073a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_GET_MAP_TABLE 3074a439fe51SSam Ravnborg * ARG0: channel ID 3075a439fe51SSam Ravnborg * RET0: status 3076a439fe51SSam Ravnborg * RET1: table real address 3077a439fe51SSam Ravnborg * RET2: num entries 3078a439fe51SSam Ravnborg * 3079a439fe51SSam Ravnborg * Return the configuration of the current mapping table registered 3080a439fe51SSam Ravnborg * for the given channel ID. 3081a439fe51SSam Ravnborg */ 3082a439fe51SSam Ravnborg #define HV_FAST_LDC_GET_MAP_TABLE 0xeb 3083a439fe51SSam Ravnborg 3084a439fe51SSam Ravnborg #define LDC_COPY_IN 0 3085a439fe51SSam Ravnborg #define LDC_COPY_OUT 1 3086a439fe51SSam Ravnborg 3087a439fe51SSam Ravnborg /* ldc_copy() 3088a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 3089a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_COPY 3090a439fe51SSam Ravnborg * ARG0: channel ID 3091a439fe51SSam Ravnborg * ARG1: LDC_COPY_* direction code 3092a439fe51SSam Ravnborg * ARG2: target real address 3093a439fe51SSam Ravnborg * ARG3: local real address 3094a439fe51SSam Ravnborg * ARG4: length in bytes 3095a439fe51SSam Ravnborg * RET0: status 3096a439fe51SSam Ravnborg * RET1: actual length in bytes 3097a439fe51SSam Ravnborg */ 3098a439fe51SSam Ravnborg #define HV_FAST_LDC_COPY 0xec 3099a439fe51SSam Ravnborg 3100a439fe51SSam Ravnborg #define LDC_MEM_READ 1 3101a439fe51SSam Ravnborg #define LDC_MEM_WRITE 2 3102a439fe51SSam Ravnborg #define LDC_MEM_EXEC 4 3103a439fe51SSam Ravnborg 3104a439fe51SSam Ravnborg /* ldc_mapin() 3105a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 3106a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_MAPIN 3107a439fe51SSam Ravnborg * ARG0: channel ID 3108a439fe51SSam Ravnborg * ARG1: cookie 3109a439fe51SSam Ravnborg * RET0: status 3110a439fe51SSam Ravnborg * RET1: real address 3111a439fe51SSam Ravnborg * RET2: LDC_MEM_* permissions 3112a439fe51SSam Ravnborg */ 3113a439fe51SSam Ravnborg #define HV_FAST_LDC_MAPIN 0xed 3114a439fe51SSam Ravnborg 3115a439fe51SSam Ravnborg /* ldc_unmap() 3116a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 3117a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_UNMAP 3118a439fe51SSam Ravnborg * ARG0: real address 3119a439fe51SSam Ravnborg * RET0: status 3120a439fe51SSam Ravnborg */ 3121a439fe51SSam Ravnborg #define HV_FAST_LDC_UNMAP 0xee 3122a439fe51SSam Ravnborg 3123a439fe51SSam Ravnborg /* ldc_revoke() 3124a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 3125a439fe51SSam Ravnborg * FUNCTION: HV_FAST_LDC_REVOKE 3126a439fe51SSam Ravnborg * ARG0: channel ID 3127a439fe51SSam Ravnborg * ARG1: cookie 3128a439fe51SSam Ravnborg * ARG2: ldc_mtable_entry cookie 3129a439fe51SSam Ravnborg * RET0: status 3130a439fe51SSam Ravnborg */ 3131a439fe51SSam Ravnborg #define HV_FAST_LDC_REVOKE 0xef 3132a439fe51SSam Ravnborg 3133a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 3134f05a6865SSam Ravnborg unsigned long sun4v_ldc_tx_qconf(unsigned long channel, 3135a439fe51SSam Ravnborg unsigned long ra, 3136a439fe51SSam Ravnborg unsigned long num_entries); 3137f05a6865SSam Ravnborg unsigned long sun4v_ldc_tx_qinfo(unsigned long channel, 3138a439fe51SSam Ravnborg unsigned long *ra, 3139a439fe51SSam Ravnborg unsigned long *num_entries); 3140f05a6865SSam Ravnborg unsigned long sun4v_ldc_tx_get_state(unsigned long channel, 3141a439fe51SSam Ravnborg unsigned long *head_off, 3142a439fe51SSam Ravnborg unsigned long *tail_off, 3143a439fe51SSam Ravnborg unsigned long *chan_state); 3144f05a6865SSam Ravnborg unsigned long sun4v_ldc_tx_set_qtail(unsigned long channel, 3145a439fe51SSam Ravnborg unsigned long tail_off); 3146f05a6865SSam Ravnborg unsigned long sun4v_ldc_rx_qconf(unsigned long channel, 3147a439fe51SSam Ravnborg unsigned long ra, 3148a439fe51SSam Ravnborg unsigned long num_entries); 3149f05a6865SSam Ravnborg unsigned long sun4v_ldc_rx_qinfo(unsigned long channel, 3150a439fe51SSam Ravnborg unsigned long *ra, 3151a439fe51SSam Ravnborg unsigned long *num_entries); 3152f05a6865SSam Ravnborg unsigned long sun4v_ldc_rx_get_state(unsigned long channel, 3153a439fe51SSam Ravnborg unsigned long *head_off, 3154a439fe51SSam Ravnborg unsigned long *tail_off, 3155a439fe51SSam Ravnborg unsigned long *chan_state); 3156f05a6865SSam Ravnborg unsigned long sun4v_ldc_rx_set_qhead(unsigned long channel, 3157a439fe51SSam Ravnborg unsigned long head_off); 3158f05a6865SSam Ravnborg unsigned long sun4v_ldc_set_map_table(unsigned long channel, 3159a439fe51SSam Ravnborg unsigned long ra, 3160a439fe51SSam Ravnborg unsigned long num_entries); 3161f05a6865SSam Ravnborg unsigned long sun4v_ldc_get_map_table(unsigned long channel, 3162a439fe51SSam Ravnborg unsigned long *ra, 3163a439fe51SSam Ravnborg unsigned long *num_entries); 3164f05a6865SSam Ravnborg unsigned long sun4v_ldc_copy(unsigned long channel, 3165a439fe51SSam Ravnborg unsigned long dir_code, 3166a439fe51SSam Ravnborg unsigned long tgt_raddr, 3167a439fe51SSam Ravnborg unsigned long lcl_raddr, 3168a439fe51SSam Ravnborg unsigned long len, 3169a439fe51SSam Ravnborg unsigned long *actual_len); 3170f05a6865SSam Ravnborg unsigned long sun4v_ldc_mapin(unsigned long channel, 3171a439fe51SSam Ravnborg unsigned long cookie, 3172a439fe51SSam Ravnborg unsigned long *ra, 3173a439fe51SSam Ravnborg unsigned long *perm); 3174f05a6865SSam Ravnborg unsigned long sun4v_ldc_unmap(unsigned long ra); 3175f05a6865SSam Ravnborg unsigned long sun4v_ldc_revoke(unsigned long channel, 3176a439fe51SSam Ravnborg unsigned long cookie, 3177a439fe51SSam Ravnborg unsigned long mte_cookie); 3178a439fe51SSam Ravnborg #endif 3179a439fe51SSam Ravnborg 3180a439fe51SSam Ravnborg /* Performance counter services. */ 3181a439fe51SSam Ravnborg 3182a439fe51SSam Ravnborg #define HV_PERF_JBUS_PERF_CTRL_REG 0x00 3183a439fe51SSam Ravnborg #define HV_PERF_JBUS_PERF_CNT_REG 0x01 3184a439fe51SSam Ravnborg #define HV_PERF_DRAM_PERF_CTRL_REG_0 0x02 3185a439fe51SSam Ravnborg #define HV_PERF_DRAM_PERF_CNT_REG_0 0x03 3186a439fe51SSam Ravnborg #define HV_PERF_DRAM_PERF_CTRL_REG_1 0x04 3187a439fe51SSam Ravnborg #define HV_PERF_DRAM_PERF_CNT_REG_1 0x05 3188a439fe51SSam Ravnborg #define HV_PERF_DRAM_PERF_CTRL_REG_2 0x06 3189a439fe51SSam Ravnborg #define HV_PERF_DRAM_PERF_CNT_REG_2 0x07 3190a439fe51SSam Ravnborg #define HV_PERF_DRAM_PERF_CTRL_REG_3 0x08 3191a439fe51SSam Ravnborg #define HV_PERF_DRAM_PERF_CNT_REG_3 0x09 3192a439fe51SSam Ravnborg 3193a439fe51SSam Ravnborg /* get_perfreg() 3194a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 3195a439fe51SSam Ravnborg * FUNCTION: HV_FAST_GET_PERFREG 3196a439fe51SSam Ravnborg * ARG0: performance reg number 3197a439fe51SSam Ravnborg * RET0: status 3198a439fe51SSam Ravnborg * RET1: performance reg value 3199a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid performance register number 3200a439fe51SSam Ravnborg * ENOACCESS No access allowed to performance counters 3201a439fe51SSam Ravnborg * 3202a439fe51SSam Ravnborg * Read the value of the given DRAM/JBUS performance counter/control register. 3203a439fe51SSam Ravnborg */ 3204a439fe51SSam Ravnborg #define HV_FAST_GET_PERFREG 0x100 3205a439fe51SSam Ravnborg 3206a439fe51SSam Ravnborg /* set_perfreg() 3207a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 3208a439fe51SSam Ravnborg * FUNCTION: HV_FAST_SET_PERFREG 3209a439fe51SSam Ravnborg * ARG0: performance reg number 3210a439fe51SSam Ravnborg * ARG1: performance reg value 3211a439fe51SSam Ravnborg * RET0: status 3212a439fe51SSam Ravnborg * ERRORS: EINVAL Invalid performance register number 3213a439fe51SSam Ravnborg * ENOACCESS No access allowed to performance counters 3214a439fe51SSam Ravnborg * 3215a439fe51SSam Ravnborg * Write the given performance reg value to the given DRAM/JBUS 3216a439fe51SSam Ravnborg * performance counter/control register. 3217a439fe51SSam Ravnborg */ 3218a439fe51SSam Ravnborg #define HV_FAST_SET_PERFREG 0x101 3219a439fe51SSam Ravnborg 32203178a07cSDavid S. Miller #define HV_N2_PERF_SPARC_CTL 0x0 32213178a07cSDavid S. Miller #define HV_N2_PERF_DRAM_CTL0 0x1 32223178a07cSDavid S. Miller #define HV_N2_PERF_DRAM_CNT0 0x2 32233178a07cSDavid S. Miller #define HV_N2_PERF_DRAM_CTL1 0x3 32243178a07cSDavid S. Miller #define HV_N2_PERF_DRAM_CNT1 0x4 32253178a07cSDavid S. Miller #define HV_N2_PERF_DRAM_CTL2 0x5 32263178a07cSDavid S. Miller #define HV_N2_PERF_DRAM_CNT2 0x6 32273178a07cSDavid S. Miller #define HV_N2_PERF_DRAM_CTL3 0x7 32283178a07cSDavid S. Miller #define HV_N2_PERF_DRAM_CNT3 0x8 32293178a07cSDavid S. Miller 32303178a07cSDavid S. Miller #define HV_FAST_N2_GET_PERFREG 0x104 32313178a07cSDavid S. Miller #define HV_FAST_N2_SET_PERFREG 0x105 32323178a07cSDavid S. Miller 32333178a07cSDavid S. Miller #ifndef __ASSEMBLY__ 3234f05a6865SSam Ravnborg unsigned long sun4v_niagara_getperf(unsigned long reg, 32353178a07cSDavid S. Miller unsigned long *val); 3236f05a6865SSam Ravnborg unsigned long sun4v_niagara_setperf(unsigned long reg, 32373178a07cSDavid S. Miller unsigned long val); 3238f05a6865SSam Ravnborg unsigned long sun4v_niagara2_getperf(unsigned long reg, 32393178a07cSDavid S. Miller unsigned long *val); 3240f05a6865SSam Ravnborg unsigned long sun4v_niagara2_setperf(unsigned long reg, 32413178a07cSDavid S. Miller unsigned long val); 32423178a07cSDavid S. Miller #endif 32433178a07cSDavid S. Miller 3244a439fe51SSam Ravnborg /* MMU statistics services. 3245a439fe51SSam Ravnborg * 3246a439fe51SSam Ravnborg * The hypervisor maintains MMU statistics and privileged code provides 3247a439fe51SSam Ravnborg * a buffer where these statistics can be collected. It is continually 3248a439fe51SSam Ravnborg * updated once configured. The layout is as follows: 3249a439fe51SSam Ravnborg */ 3250a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 3251a439fe51SSam Ravnborg struct hv_mmu_statistics { 3252a439fe51SSam Ravnborg unsigned long immu_tsb_hits_ctx0_8k_tte; 3253a439fe51SSam Ravnborg unsigned long immu_tsb_ticks_ctx0_8k_tte; 3254a439fe51SSam Ravnborg unsigned long immu_tsb_hits_ctx0_64k_tte; 3255a439fe51SSam Ravnborg unsigned long immu_tsb_ticks_ctx0_64k_tte; 3256a439fe51SSam Ravnborg unsigned long __reserved1[2]; 3257a439fe51SSam Ravnborg unsigned long immu_tsb_hits_ctx0_4mb_tte; 3258a439fe51SSam Ravnborg unsigned long immu_tsb_ticks_ctx0_4mb_tte; 3259a439fe51SSam Ravnborg unsigned long __reserved2[2]; 3260a439fe51SSam Ravnborg unsigned long immu_tsb_hits_ctx0_256mb_tte; 3261a439fe51SSam Ravnborg unsigned long immu_tsb_ticks_ctx0_256mb_tte; 3262a439fe51SSam Ravnborg unsigned long __reserved3[4]; 3263a439fe51SSam Ravnborg unsigned long immu_tsb_hits_ctxnon0_8k_tte; 3264a439fe51SSam Ravnborg unsigned long immu_tsb_ticks_ctxnon0_8k_tte; 3265a439fe51SSam Ravnborg unsigned long immu_tsb_hits_ctxnon0_64k_tte; 3266a439fe51SSam Ravnborg unsigned long immu_tsb_ticks_ctxnon0_64k_tte; 3267a439fe51SSam Ravnborg unsigned long __reserved4[2]; 3268a439fe51SSam Ravnborg unsigned long immu_tsb_hits_ctxnon0_4mb_tte; 3269a439fe51SSam Ravnborg unsigned long immu_tsb_ticks_ctxnon0_4mb_tte; 3270a439fe51SSam Ravnborg unsigned long __reserved5[2]; 3271a439fe51SSam Ravnborg unsigned long immu_tsb_hits_ctxnon0_256mb_tte; 3272a439fe51SSam Ravnborg unsigned long immu_tsb_ticks_ctxnon0_256mb_tte; 3273a439fe51SSam Ravnborg unsigned long __reserved6[4]; 3274a439fe51SSam Ravnborg unsigned long dmmu_tsb_hits_ctx0_8k_tte; 3275a439fe51SSam Ravnborg unsigned long dmmu_tsb_ticks_ctx0_8k_tte; 3276a439fe51SSam Ravnborg unsigned long dmmu_tsb_hits_ctx0_64k_tte; 3277a439fe51SSam Ravnborg unsigned long dmmu_tsb_ticks_ctx0_64k_tte; 3278a439fe51SSam Ravnborg unsigned long __reserved7[2]; 3279a439fe51SSam Ravnborg unsigned long dmmu_tsb_hits_ctx0_4mb_tte; 3280a439fe51SSam Ravnborg unsigned long dmmu_tsb_ticks_ctx0_4mb_tte; 3281a439fe51SSam Ravnborg unsigned long __reserved8[2]; 3282a439fe51SSam Ravnborg unsigned long dmmu_tsb_hits_ctx0_256mb_tte; 3283a439fe51SSam Ravnborg unsigned long dmmu_tsb_ticks_ctx0_256mb_tte; 3284a439fe51SSam Ravnborg unsigned long __reserved9[4]; 3285a439fe51SSam Ravnborg unsigned long dmmu_tsb_hits_ctxnon0_8k_tte; 3286a439fe51SSam Ravnborg unsigned long dmmu_tsb_ticks_ctxnon0_8k_tte; 3287a439fe51SSam Ravnborg unsigned long dmmu_tsb_hits_ctxnon0_64k_tte; 3288a439fe51SSam Ravnborg unsigned long dmmu_tsb_ticks_ctxnon0_64k_tte; 3289a439fe51SSam Ravnborg unsigned long __reserved10[2]; 3290a439fe51SSam Ravnborg unsigned long dmmu_tsb_hits_ctxnon0_4mb_tte; 3291a439fe51SSam Ravnborg unsigned long dmmu_tsb_ticks_ctxnon0_4mb_tte; 3292a439fe51SSam Ravnborg unsigned long __reserved11[2]; 3293a439fe51SSam Ravnborg unsigned long dmmu_tsb_hits_ctxnon0_256mb_tte; 3294a439fe51SSam Ravnborg unsigned long dmmu_tsb_ticks_ctxnon0_256mb_tte; 3295a439fe51SSam Ravnborg unsigned long __reserved12[4]; 3296a439fe51SSam Ravnborg }; 3297a439fe51SSam Ravnborg #endif 3298a439fe51SSam Ravnborg 3299a439fe51SSam Ravnborg /* mmustat_conf() 3300a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 3301a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMUSTAT_CONF 3302a439fe51SSam Ravnborg * ARG0: real address 3303a439fe51SSam Ravnborg * RET0: status 3304a439fe51SSam Ravnborg * RET1: real address 3305a439fe51SSam Ravnborg * ERRORS: ENORADDR Invalid real address 3306a439fe51SSam Ravnborg * EBADALIGN Real address not aligned on 64-byte boundary 3307a439fe51SSam Ravnborg * EBADTRAP API not supported on this processor 3308a439fe51SSam Ravnborg * 3309a439fe51SSam Ravnborg * Enable MMU statistic gathering using the buffer at the given real 3310a439fe51SSam Ravnborg * address on the current virtual CPU. The new buffer real address 3311a439fe51SSam Ravnborg * is given in ARG1, and the previously specified buffer real address 3312a439fe51SSam Ravnborg * is returned in RET1, or is returned as zero for the first invocation. 3313a439fe51SSam Ravnborg * 3314a439fe51SSam Ravnborg * If the passed in real address argument is zero, this will disable 3315a439fe51SSam Ravnborg * MMU statistic collection on the current virtual CPU. If an error is 3316a439fe51SSam Ravnborg * returned then no statistics are collected. 3317a439fe51SSam Ravnborg * 3318a439fe51SSam Ravnborg * The buffer contents should be initialized to all zeros before being 3319a439fe51SSam Ravnborg * given to the hypervisor or else the statistics will be meaningless. 3320a439fe51SSam Ravnborg */ 3321a439fe51SSam Ravnborg #define HV_FAST_MMUSTAT_CONF 0x102 3322a439fe51SSam Ravnborg 3323a439fe51SSam Ravnborg /* mmustat_info() 3324a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 3325a439fe51SSam Ravnborg * FUNCTION: HV_FAST_MMUSTAT_INFO 3326a439fe51SSam Ravnborg * RET0: status 3327a439fe51SSam Ravnborg * RET1: real address 3328a439fe51SSam Ravnborg * ERRORS: EBADTRAP API not supported on this processor 3329a439fe51SSam Ravnborg * 3330a439fe51SSam Ravnborg * Return the current state and real address of the currently configured 3331a439fe51SSam Ravnborg * MMU statistics buffer on the current virtual CPU. 3332a439fe51SSam Ravnborg */ 3333a439fe51SSam Ravnborg #define HV_FAST_MMUSTAT_INFO 0x103 3334a439fe51SSam Ravnborg 3335a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 3336f05a6865SSam Ravnborg unsigned long sun4v_mmustat_conf(unsigned long ra, unsigned long *orig_ra); 3337f05a6865SSam Ravnborg unsigned long sun4v_mmustat_info(unsigned long *ra); 3338a439fe51SSam Ravnborg #endif 3339a439fe51SSam Ravnborg 3340a439fe51SSam Ravnborg /* NCS crypto services */ 3341a439fe51SSam Ravnborg 3342a439fe51SSam Ravnborg /* ncs_request() sub-function numbers */ 3343a439fe51SSam Ravnborg #define HV_NCS_QCONF 0x01 3344a439fe51SSam Ravnborg #define HV_NCS_QTAIL_UPDATE 0x02 3345a439fe51SSam Ravnborg 3346a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 3347a439fe51SSam Ravnborg struct hv_ncs_queue_entry { 3348a439fe51SSam Ravnborg /* MAU Control Register */ 3349a439fe51SSam Ravnborg unsigned long mau_control; 3350a439fe51SSam Ravnborg #define MAU_CONTROL_INV_PARITY 0x0000000000002000 3351a439fe51SSam Ravnborg #define MAU_CONTROL_STRAND 0x0000000000001800 3352a439fe51SSam Ravnborg #define MAU_CONTROL_BUSY 0x0000000000000400 3353a439fe51SSam Ravnborg #define MAU_CONTROL_INT 0x0000000000000200 3354a439fe51SSam Ravnborg #define MAU_CONTROL_OP 0x00000000000001c0 3355a439fe51SSam Ravnborg #define MAU_CONTROL_OP_SHIFT 6 3356a439fe51SSam Ravnborg #define MAU_OP_LOAD_MA_MEMORY 0x0 3357a439fe51SSam Ravnborg #define MAU_OP_STORE_MA_MEMORY 0x1 3358a439fe51SSam Ravnborg #define MAU_OP_MODULAR_MULT 0x2 3359a439fe51SSam Ravnborg #define MAU_OP_MODULAR_REDUCE 0x3 3360a439fe51SSam Ravnborg #define MAU_OP_MODULAR_EXP_LOOP 0x4 3361a439fe51SSam Ravnborg #define MAU_CONTROL_LEN 0x000000000000003f 3362a439fe51SSam Ravnborg #define MAU_CONTROL_LEN_SHIFT 0 3363a439fe51SSam Ravnborg 3364a439fe51SSam Ravnborg /* Real address of bytes to load or store bytes 3365a439fe51SSam Ravnborg * into/out-of the MAU. 3366a439fe51SSam Ravnborg */ 3367a439fe51SSam Ravnborg unsigned long mau_mpa; 3368a439fe51SSam Ravnborg 3369a439fe51SSam Ravnborg /* Modular Arithmetic MA Offset Register. */ 3370a439fe51SSam Ravnborg unsigned long mau_ma; 3371a439fe51SSam Ravnborg 3372a439fe51SSam Ravnborg /* Modular Arithmetic N Prime Register. */ 3373a439fe51SSam Ravnborg unsigned long mau_np; 3374a439fe51SSam Ravnborg }; 3375a439fe51SSam Ravnborg 3376a439fe51SSam Ravnborg struct hv_ncs_qconf_arg { 3377a439fe51SSam Ravnborg unsigned long mid; /* MAU ID, 1 per core on Niagara */ 3378a439fe51SSam Ravnborg unsigned long base; /* Real address base of queue */ 3379a439fe51SSam Ravnborg unsigned long end; /* Real address end of queue */ 3380a439fe51SSam Ravnborg unsigned long num_ents; /* Number of entries in queue */ 3381a439fe51SSam Ravnborg }; 3382a439fe51SSam Ravnborg 3383a439fe51SSam Ravnborg struct hv_ncs_qtail_update_arg { 3384a439fe51SSam Ravnborg unsigned long mid; /* MAU ID, 1 per core on Niagara */ 3385a439fe51SSam Ravnborg unsigned long tail; /* New tail index to use */ 3386a439fe51SSam Ravnborg unsigned long syncflag; /* only SYNCFLAG_SYNC is implemented */ 3387a439fe51SSam Ravnborg #define HV_NCS_SYNCFLAG_SYNC 0x00 3388a439fe51SSam Ravnborg #define HV_NCS_SYNCFLAG_ASYNC 0x01 3389a439fe51SSam Ravnborg }; 3390a439fe51SSam Ravnborg #endif 3391a439fe51SSam Ravnborg 3392a439fe51SSam Ravnborg /* ncs_request() 3393a439fe51SSam Ravnborg * TRAP: HV_FAST_TRAP 3394a439fe51SSam Ravnborg * FUNCTION: HV_FAST_NCS_REQUEST 3395a439fe51SSam Ravnborg * ARG0: NCS sub-function 3396a439fe51SSam Ravnborg * ARG1: sub-function argument real address 3397a439fe51SSam Ravnborg * ARG2: size in bytes of sub-function argument 3398a439fe51SSam Ravnborg * RET0: status 3399a439fe51SSam Ravnborg * 3400a439fe51SSam Ravnborg * The MAU chip of the Niagara processor is not directly accessible 3401a439fe51SSam Ravnborg * to privileged code, instead it is programmed indirectly via this 3402a439fe51SSam Ravnborg * hypervisor API. 3403a439fe51SSam Ravnborg * 3404a439fe51SSam Ravnborg * The interfaces defines a queue of MAU operations to perform. 3405a439fe51SSam Ravnborg * Privileged code registers a queue with the hypervisor by invoking 3406a439fe51SSam Ravnborg * this HVAPI with the HV_NCS_QCONF sub-function, which defines the 3407a439fe51SSam Ravnborg * base, end, and number of entries of the queue. Each queue entry 3408a439fe51SSam Ravnborg * contains a MAU register struct block. 3409a439fe51SSam Ravnborg * 3410a439fe51SSam Ravnborg * The privileged code then proceeds to add entries to the queue and 3411a439fe51SSam Ravnborg * then invoke the HV_NCS_QTAIL_UPDATE sub-function. Since only 3412a439fe51SSam Ravnborg * synchronous operations are supported by the current hypervisor, 3413a439fe51SSam Ravnborg * HV_NCS_QTAIL_UPDATE will run all the pending queue entries to 3414a439fe51SSam Ravnborg * completion and return HV_EOK, or return an error code. 3415a439fe51SSam Ravnborg * 3416a439fe51SSam Ravnborg * The real address of the sub-function argument must be aligned on at 3417a439fe51SSam Ravnborg * least an 8-byte boundary. 3418a439fe51SSam Ravnborg * 3419a439fe51SSam Ravnborg * The tail argument of HV_NCS_QTAIL_UPDATE is an index, not a byte 3420a439fe51SSam Ravnborg * offset, into the queue and must be less than or equal the 'num_ents' 3421a439fe51SSam Ravnborg * argument given in the HV_NCS_QCONF call. 3422a439fe51SSam Ravnborg */ 3423a439fe51SSam Ravnborg #define HV_FAST_NCS_REQUEST 0x110 3424a439fe51SSam Ravnborg 3425a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 3426f05a6865SSam Ravnborg unsigned long sun4v_ncs_request(unsigned long request, 3427a439fe51SSam Ravnborg unsigned long arg_ra, 3428a439fe51SSam Ravnborg unsigned long arg_size); 3429a439fe51SSam Ravnborg #endif 3430a439fe51SSam Ravnborg 3431a439fe51SSam Ravnborg #define HV_FAST_FIRE_GET_PERFREG 0x120 3432a439fe51SSam Ravnborg #define HV_FAST_FIRE_SET_PERFREG 0x121 3433a439fe51SSam Ravnborg 3434ea5e7447SDavid S. Miller #define HV_FAST_REBOOT_DATA_SET 0x172 3435ea5e7447SDavid S. Miller 3436ea5e7447SDavid S. Miller #ifndef __ASSEMBLY__ 3437f05a6865SSam Ravnborg unsigned long sun4v_reboot_data_set(unsigned long ra, 3438ea5e7447SDavid S. Miller unsigned long len); 3439ea5e7447SDavid S. Miller #endif 3440ea5e7447SDavid S. Miller 34418c79bfa5SDavid S. Miller #define HV_FAST_VT_GET_PERFREG 0x184 34428c79bfa5SDavid S. Miller #define HV_FAST_VT_SET_PERFREG 0x185 34438c79bfa5SDavid S. Miller 34448c79bfa5SDavid S. Miller #ifndef __ASSEMBLY__ 3445f05a6865SSam Ravnborg unsigned long sun4v_vt_get_perfreg(unsigned long reg_num, 34468c79bfa5SDavid S. Miller unsigned long *reg_val); 3447f05a6865SSam Ravnborg unsigned long sun4v_vt_set_perfreg(unsigned long reg_num, 34488c79bfa5SDavid S. Miller unsigned long reg_val); 34498c79bfa5SDavid S. Miller #endif 34508c79bfa5SDavid S. Miller 345105aa1651Sbob picco #define HV_FAST_T5_GET_PERFREG 0x1a8 345205aa1651Sbob picco #define HV_FAST_T5_SET_PERFREG 0x1a9 345305aa1651Sbob picco 345405aa1651Sbob picco #ifndef __ASSEMBLY__ 345505aa1651Sbob picco unsigned long sun4v_t5_get_perfreg(unsigned long reg_num, 345605aa1651Sbob picco unsigned long *reg_val); 345705aa1651Sbob picco unsigned long sun4v_t5_set_perfreg(unsigned long reg_num, 345805aa1651Sbob picco unsigned long reg_val); 345905aa1651Sbob picco #endif 346005aa1651Sbob picco 3461b5aff55dSDavid Ahern 3462b5aff55dSDavid Ahern #define HV_FAST_M7_GET_PERFREG 0x43 3463b5aff55dSDavid Ahern #define HV_FAST_M7_SET_PERFREG 0x44 3464b5aff55dSDavid Ahern 3465b5aff55dSDavid Ahern #ifndef __ASSEMBLY__ 3466b5aff55dSDavid Ahern unsigned long sun4v_m7_get_perfreg(unsigned long reg_num, 3467b5aff55dSDavid Ahern unsigned long *reg_val); 3468b5aff55dSDavid Ahern unsigned long sun4v_m7_set_perfreg(unsigned long reg_num, 3469b5aff55dSDavid Ahern unsigned long reg_val); 3470b5aff55dSDavid Ahern #endif 3471b5aff55dSDavid Ahern 3472a439fe51SSam Ravnborg /* Function numbers for HV_CORE_TRAP. */ 3473a439fe51SSam Ravnborg #define HV_CORE_SET_VER 0x00 3474a439fe51SSam Ravnborg #define HV_CORE_PUTCHAR 0x01 3475a439fe51SSam Ravnborg #define HV_CORE_EXIT 0x02 3476a439fe51SSam Ravnborg #define HV_CORE_GET_VER 0x03 3477a439fe51SSam Ravnborg 3478a439fe51SSam Ravnborg /* Hypervisor API groups for use with HV_CORE_SET_VER and 3479a439fe51SSam Ravnborg * HV_CORE_GET_VER. 3480a439fe51SSam Ravnborg */ 3481a439fe51SSam Ravnborg #define HV_GRP_SUN4V 0x0000 3482a439fe51SSam Ravnborg #define HV_GRP_CORE 0x0001 3483a439fe51SSam Ravnborg #define HV_GRP_INTR 0x0002 3484a439fe51SSam Ravnborg #define HV_GRP_SOFT_STATE 0x0003 3485e2eb9f81SDavid S. Miller #define HV_GRP_TM 0x0080 3486a439fe51SSam Ravnborg #define HV_GRP_PCI 0x0100 3487a439fe51SSam Ravnborg #define HV_GRP_LDOM 0x0101 3488a439fe51SSam Ravnborg #define HV_GRP_SVC_CHAN 0x0102 3489a439fe51SSam Ravnborg #define HV_GRP_NCS 0x0103 3490a439fe51SSam Ravnborg #define HV_GRP_RNG 0x0104 3491e2eb9f81SDavid S. Miller #define HV_GRP_PBOOT 0x0105 3492e2eb9f81SDavid S. Miller #define HV_GRP_TPM 0x0107 3493e2eb9f81SDavid S. Miller #define HV_GRP_SDIO 0x0108 3494e2eb9f81SDavid S. Miller #define HV_GRP_SDIO_ERR 0x0109 3495e2eb9f81SDavid S. Miller #define HV_GRP_REBOOT_DATA 0x0110 3496f0248c15STushar Dave #define HV_GRP_ATU 0x0111 3497c2b5934fSRob Gardner #define HV_GRP_DAX 0x0113 3498b5aff55dSDavid Ahern #define HV_GRP_M7_PERF 0x0114 3499a439fe51SSam Ravnborg #define HV_GRP_NIAG_PERF 0x0200 3500a439fe51SSam Ravnborg #define HV_GRP_FIRE_PERF 0x0201 3501a439fe51SSam Ravnborg #define HV_GRP_N2_CPU 0x0202 3502a439fe51SSam Ravnborg #define HV_GRP_NIU 0x0204 3503a439fe51SSam Ravnborg #define HV_GRP_VF_CPU 0x0205 350415e3608dSDavid S. Miller #define HV_GRP_KT_CPU 0x0209 35058c79bfa5SDavid S. Miller #define HV_GRP_VT_CPU 0x020c 350605aa1651Sbob picco #define HV_GRP_T5_CPU 0x0211 3507a439fe51SSam Ravnborg #define HV_GRP_DIAG 0x0300 3508a439fe51SSam Ravnborg 3509a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 3510f05a6865SSam Ravnborg unsigned long sun4v_get_version(unsigned long group, 3511a439fe51SSam Ravnborg unsigned long *major, 3512a439fe51SSam Ravnborg unsigned long *minor); 3513f05a6865SSam Ravnborg unsigned long sun4v_set_version(unsigned long group, 3514a439fe51SSam Ravnborg unsigned long major, 3515a439fe51SSam Ravnborg unsigned long minor, 3516a439fe51SSam Ravnborg unsigned long *actual_minor); 3517a439fe51SSam Ravnborg 3518f05a6865SSam Ravnborg int sun4v_hvapi_register(unsigned long group, unsigned long major, 3519a439fe51SSam Ravnborg unsigned long *minor); 3520f05a6865SSam Ravnborg void sun4v_hvapi_unregister(unsigned long group); 3521f05a6865SSam Ravnborg int sun4v_hvapi_get(unsigned long group, 3522a439fe51SSam Ravnborg unsigned long *major, 3523a439fe51SSam Ravnborg unsigned long *minor); 3524f05a6865SSam Ravnborg void sun4v_hvapi_init(void); 3525a439fe51SSam Ravnborg #endif 3526a439fe51SSam Ravnborg 3527a439fe51SSam Ravnborg #endif /* !(_SPARC64_HYPERVISOR_H) */ 3528