hypervisor.h

来自「linux 内核源代码」· C头文件 代码 · 共 1,941 行 · 第 1/5 页

H
1,941
字号
#ifndef _SPARC64_HYPERVISOR_H#define _SPARC64_HYPERVISOR_H/* Sun4v hypervisor interfaces and defines. * * Hypervisor calls are made via traps to software traps number 0x80 * and above.  Registers %o0 to %o5 serve as argument, status, and * return value registers. * * There are two kinds of these traps.  First there are the normal * "fast traps" which use software trap 0x80 and encode the function * to invoke by number in register %o5.  Argument and return value * handling is as follows: * * ----------------------------------------------- * |  %o5  | function number |     undefined     | * |  %o0  |   argument 0    |   return status   | * |  %o1  |   argument 1    |   return value 1  | * |  %o2  |   argument 2    |   return value 2  | * |  %o3  |   argument 3    |   return value 3  | * |  %o4  |   argument 4    |   return value 4  | * ----------------------------------------------- * * The second type are "hyper-fast traps" which encode the function * number in the software trap number itself.  So these use trap * numbers > 0x80.  The register usage for hyper-fast traps is as * follows: * * ----------------------------------------------- * |  %o0  |   argument 0    |   return status   | * |  %o1  |   argument 1    |   return value 1  | * |  %o2  |   argument 2    |   return value 2  | * |  %o3  |   argument 3    |   return value 3  | * |  %o4  |   argument 4    |   return value 4  | * ----------------------------------------------- * * Registers providing explicit arguments to the hypervisor calls * are volatile across the call.  Upon return their values are * undefined unless explicitly specified as containing a particular * return value by the specific call.  The return status is always * returned in register %o0, zero indicates a successful execution of * the hypervisor call and other values indicate an error status as * defined below.  So, for example, if a hyper-fast trap takes * arguments 0, 1, and 2, then %o0, %o1, and %o2 are volatile across * the call and %o3, %o4, and %o5 would be preserved. * * If the hypervisor trap is invalid, or the fast trap function number * is invalid, HV_EBADTRAP will be returned in %o0.  Also, all 64-bits * of the argument and return values are significant. *//* Trap numbers.  */#define HV_FAST_TRAP		0x80#define HV_MMU_MAP_ADDR_TRAP	0x83#define HV_MMU_UNMAP_ADDR_TRAP	0x84#define HV_TTRACE_ADDENTRY_TRAP	0x85#define HV_CORE_TRAP		0xff/* Error codes.  */#define HV_EOK				0  /* Successful return            */#define HV_ENOCPU			1  /* Invalid CPU id               */#define HV_ENORADDR			2  /* Invalid real address         */#define HV_ENOINTR			3  /* Invalid interrupt id         */#define HV_EBADPGSZ			4  /* Invalid pagesize encoding    */#define HV_EBADTSB			5  /* Invalid TSB description      */#define HV_EINVAL			6  /* Invalid argument             */#define HV_EBADTRAP			7  /* Invalid function number      */#define HV_EBADALIGN			8  /* Invalid address alignment    */#define HV_EWOULDBLOCK			9  /* Cannot complete w/o blocking */#define HV_ENOACCESS			10 /* No access to resource        */#define HV_EIO				11 /* I/O error                    */#define HV_ECPUERROR			12 /* CPU in error state           */#define HV_ENOTSUPPORTED		13 /* Function not supported       */#define HV_ENOMAP			14 /* No mapping found             */#define HV_ETOOMANY			15 /* Too many items specified     */#define HV_ECHANNEL			16 /* Invalid LDC channel          */#define HV_EBUSY			17 /* Resource busy                *//* mach_exit() * TRAP:	HV_FAST_TRAP * FUNCTION:	HV_FAST_MACH_EXIT * ARG0:	exit code * ERRORS:	This service does not return. * * Stop all CPUs in the virtual domain and place them into the stopped * state.  The 64-bit exit code may be passed to a service entity as * the domain's exit status.  On systems without a service entity, the * domain will undergo a reset, and the boot firmware will be * reloaded. * * This function will never return to the guest that invokes it. * * Note: By convention an exit code of zero denotes a successful exit by *       the guest code.  A non-zero exit code denotes a guest specific *       error indication. * */#define HV_FAST_MACH_EXIT		0x00#ifndef __ASSEMBLY__extern void sun4v_mach_exit(unsigned long exit_code);#endif/* Domain services.  *//* mach_desc() * TRAP:	HV_FAST_TRAP * FUNCTION:	HV_FAST_MACH_DESC * ARG0:	buffer * ARG1:	length * RET0:	status * RET1:	length * ERRORS:	HV_EBADALIGN	Buffer is badly aligned *		HV_ENORADDR	Buffer is to an illegal real address. *		HV_EINVAL	Buffer length is too small for complete *				machine description. * * Copy the most current machine description into the buffer indicated * by the real address in ARG0.  The buffer provided must be 16 byte * aligned.  Upon success or HV_EINVAL, this service returns the * actual size of the machine description in the RET1 return value. * * Note: A method of determining the appropriate buffer size for the *       machine description is to first call this service with a buffer *       length of 0 bytes. */#define HV_FAST_MACH_DESC		0x01#ifndef __ASSEMBLY__extern unsigned long sun4v_mach_desc(unsigned long buffer_pa,				     unsigned long buf_len,				     unsigned long *real_buf_len);#endif/* mach_sir() * TRAP:	HV_FAST_TRAP * FUNCTION:	HV_FAST_MACH_SIR * ERRORS:	This service does not return. * * Perform a software initiated reset of the virtual machine domain. * All CPUs are captured as soon as possible, all hardware devices are * returned to the entry default state, and the domain is restarted at * the SIR (trap type 0x04) real trap table (RTBA) entry point on one * of the CPUs.  The single CPU restarted is selected as determined by * platform specific policy.  Memory is preserved across this * operation. */#define HV_FAST_MACH_SIR		0x02#ifndef __ASSEMBLY__extern void sun4v_mach_sir(void);#endif/* mach_set_watchdog() * TRAP:	HV_FAST_TRAP * FUNCTION:	HV_FAST_MACH_SET_WATCHDOG * ARG0:	timeout in milliseconds * RET0:	status * RET1:	time remaining in milliseconds * * A guest uses this API to set a watchdog timer.  Once the gues has set * the timer, it must call the timer service again either to disable or * postpone the expiration.  If the timer expires before being reset or * disabled, then the hypervisor take a platform specific action leading * to guest termination within a bounded time period.  The platform action * may include recovery actions such as reporting the expiration to a * Service Processor, and/or automatically restarting the gues. * * The 'timeout' parameter is specified in milliseconds, however the * implementated granularity is given by the 'watchdog-resolution' * property in the 'platform' node of the guest's machine description. * The largest allowed timeout value is specified by the * 'watchdog-max-timeout' property of the 'platform' node. * * If the 'timeout' argument is not zero, the watchdog timer is set to * expire after a minimum of 'timeout' milliseconds. * * If the 'timeout' argument is zero, the watchdog timer is disabled. * * If the 'timeout' value exceeds the value of the 'max-watchdog-timeout' * property, the hypervisor leaves the watchdog timer state unchanged, * and returns a status of EINVAL. * * The 'time remaining' return value is valid regardless of whether the * return status is EOK or EINVAL.  A non-zero return value indicates the * number of milliseconds that were remaining until the timer was to expire. * If less than one millisecond remains, the return value is '1'.  If the * watchdog timer was disabled at the time of the call, the return value is * zero. * * If the hypervisor cannot support the exact timeout value requested, but * can support a larger timeout value, the hypervisor may round the actual * timeout to a value larger than the requested timeout, consequently the * 'time remaining' return value may be larger than the previously requested * timeout value. * * Any guest OS debugger should be aware that the watchdog service may be in * use.  Consequently, it is recommended that the watchdog service is * disabled upon debugger entry (e.g. reaching a breakpoint), and then * re-enabled upon returning to normal execution.  The API has been designed * with this in mind, and the 'time remaining' result of the disable call may * be used directly as the timeout argument of the re-enable call. */#define HV_FAST_MACH_SET_WATCHDOG	0x05#ifndef __ASSEMBLY__extern unsigned long sun4v_mach_set_watchdog(unsigned long timeout,					     unsigned long *orig_timeout);#endif/* CPU services. * * CPUs represent devices that can execute software threads.  A single * chip that contains multiple cores or strands is represented as * multiple CPUs with unique CPU identifiers.  CPUs are exported to * OBP via the machine description (and to the OS via the OBP device * tree).  CPUs are always in one of three states: stopped, running, * or error. * * A CPU ID is a pre-assigned 16-bit value that uniquely identifies a * CPU within a logical domain.  Operations that are to be performed * on multiple CPUs specify them via a CPU list.  A CPU list is an * array in real memory, of which each 16-bit word is a CPU ID.  CPU * lists are passed through the API as two arguments.  The first is * the number of entries (16-bit words) in the CPU list, and the * second is the (real address) pointer to the CPU ID list. *//* cpu_start() * TRAP:	HV_FAST_TRAP * FUNCTION:	HV_FAST_CPU_START * ARG0:	CPU ID * ARG1:	PC * ARG2:	RTBA * ARG3:	target ARG0 * RET0:	status * ERRORS:	ENOCPU		Invalid CPU ID *		EINVAL		Target CPU ID is not in the stopped state *		ENORADDR	Invalid PC or RTBA real address *		EBADALIGN	Unaligned PC or unaligned RTBA *		EWOULDBLOCK	Starting resources are not available * * Start CPU with given CPU ID with PC in %pc and with a real trap * base address value of RTBA.  The indicated CPU must be in the * stopped state.  The supplied RTBA must be aligned on a 256 byte * boundary.  On successful completion, the specified CPU will be in * the running state and will be supplied with "target ARG0" in %o0 * and RTBA in %tba. */#define HV_FAST_CPU_START		0x10#ifndef __ASSEMBLY__extern unsigned long sun4v_cpu_start(unsigned long cpuid,				     unsigned long pc,				     unsigned long rtba,				     unsigned long arg0);#endif/* cpu_stop() * TRAP:	HV_FAST_TRAP * FUNCTION:	HV_FAST_CPU_STOP * ARG0:	CPU ID * RET0:	status * ERRORS:	ENOCPU		Invalid CPU ID *		EINVAL		Target CPU ID is the current cpu *		EINVAL		Target CPU ID is not in the running state *		EWOULDBLOCK	Stopping resources are not available *		ENOTSUPPORTED	Not supported on this platform * * The specified CPU is stopped.  The indicated CPU must be in the * running state.  On completion, it will be in the stopped state.  It * is not legal to stop the current CPU. * * Note: As this service cannot be used to stop the current cpu, this service *       may not be used to stop the last running CPU in a domain.  To stop *       and exit a running domain, a guest must use the mach_exit() service. */#define HV_FAST_CPU_STOP		0x11#ifndef __ASSEMBLY__extern unsigned long sun4v_cpu_stop(unsigned long cpuid);#endif/* cpu_yield() * TRAP:	HV_FAST_TRAP * FUNCTION:	HV_FAST_CPU_YIELD * RET0:	status * ERRORS:	No possible error. * * Suspend execution on the current CPU.  Execution will resume when * an interrupt (device, %stick_compare, or cross-call) is targeted to * the CPU.  On some CPUs, this API may be used by the hypervisor to * save power by disabling hardware strands. */#define HV_FAST_CPU_YIELD		0x12#ifndef __ASSEMBLY__extern unsigned long sun4v_cpu_yield(void);#endif/* cpu_qconf() * TRAP:	HV_FAST_TRAP * FUNCTION:	HV_FAST_CPU_QCONF * ARG0:	queue * ARG1:	base real address * ARG2:	number of entries * RET0:	status * ERRORS:	ENORADDR	Invalid base real address *		EINVAL		Invalid queue or number of entries is less *				than 2 or too large. *		EBADALIGN	Base real address is not correctly aligned *				for size. * * Configure the given queue to be placed at the given base real * address, with the given number of entries.  The number of entries * must be a power of 2.  The base real address must be aligned * exactly to match the queue size.  Each queue entry is 64 bytes * long, so for example a 32 entry queue must be aligned on a 2048 * byte real address boundary. * * The specified queue is unconfigured if the number of entries is given * as zero. * * For the current version of this API service, the argument queue is defined * as follows: * *	queue		description *	-----		------------------------- *	0x3c		cpu mondo queue *	0x3d		device mondo queue *	0x3e		resumable error queue *	0x3f		non-resumable error queue * * Note: The maximum number of entries for each queue for a specific cpu may *       be determined from the machine description. */#define HV_FAST_CPU_QCONF		0x14#define  HV_CPU_QUEUE_CPU_MONDO		 0x3c#define  HV_CPU_QUEUE_DEVICE_MONDO	 0x3d#define  HV_CPU_QUEUE_RES_ERROR		 0x3e#define  HV_CPU_QUEUE_NONRES_ERROR	 0x3f#ifndef __ASSEMBLY__extern unsigned long sun4v_cpu_qconf(unsigned long type,				     unsigned long queue_paddr,				     unsigned long num_queue_entries);#endif/* cpu_qinfo() * TRAP:	HV_FAST_TRAP * FUNCTION:	HV_FAST_CPU_QINFO * ARG0:	queue * RET0:	status * RET1:	base real address * RET1:	number of entries * ERRORS:	EINVAL		Invalid queue * * Return the configuration info for the given queue.  The base real * address and number of entries of the defined queue are returned. * The queue argument values are the same as for cpu_qconf() above. * * If the specified queue is a valid queue number, but no queue has * been defined, the number of entries will be set to zero and the * base real address returned is undefined. */#define HV_FAST_CPU_QINFO		0x15/* cpu_mondo_send() * TRAP:	HV_FAST_TRAP * FUNCTION:	HV_FAST_CPU_MONDO_SEND * ARG0-1:	CPU list * ARG2:	data real address * RET0:	status * ERRORS:	EBADALIGN	Mondo data is not 64-byte aligned or CPU list *				is not 2-byte aligned. *		ENORADDR	Invalid data mondo address, or invalid cpu list *				address. *		ENOCPU		Invalid cpu in CPU list *		EWOULDBLOCK	Some or all of the listed CPUs did not receive *				the mondo *		ECPUERROR	One or more of the listed CPUs are in error *				state, use HV_FAST_CPU_STATE to see which ones *		EINVAL		CPU list includes caller's CPU ID * * Send a mondo interrupt to the CPUs in the given CPU list with the * 64-bytes at the given data real address.  The data must be 64-byte * aligned.  The mondo data will be delivered to the cpu_mondo queues * of the recipient CPUs. *

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?