1 /* Copyright (C) 2010 - 2015 UNISYS CORPORATION
2  * All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms and conditions of the GNU General Public License,
6  * version 2, as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11  * NON INFRINGEMENT.  See the GNU General Public License for more
12  * details.
13  */
14 
15 #ifndef __IOMONINTF_H__
16 #define __IOMONINTF_H__
17 
18 /*
19 * This file contains all structures needed to support the VMCALLs for IO
20 * Virtualization.  The VMCALLs are provided by Monitor and used by IO code
21 * running on IO Partitions.
22 */
23 
24 #ifdef __GNUC__
25 #include "iovmcall_gnuc.h"
26 #endif	/*  */
27 #include "diagchannel.h"
28 
29 #ifdef VMCALL_IO_CONTROLVM_ADDR
30 #undef VMCALL_IO_CONTROLVM_ADDR
31 #endif	/*  */
32 
33 /* define subsystem number for AppOS, used in uislib driver  */
34 #define MDS_APPOS 0x4000000000000000L	/* subsystem = 62 - AppOS */
35 enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples  */
36 	    /* Note: when a new VMCALL is added:
37 	     * - the 1st 2 hex digits correspond to one of the
38 	     *   VMCALL_MONITOR_INTERFACE types and
39 	     * - the next 2 hex digits are the nth relative instance of within a
40 	     *   type
41 	     * E.G. for VMCALL_VIRTPART_RECYCLE_PART,
42 	     * - the 0x02 identifies it as a VMCALL_VIRTPART type and
43 	     * - the 0x01 identifies it as the 1st instance of a VMCALL_VIRTPART
44 	     *   type of VMCALL
45 	     */
46 
47 	VMCALL_IO_CONTROLVM_ADDR = 0x0501,	/* used by all Guests, not just
48 						 * IO */
49 	VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET = 0x0708, /* Allow caller to
50 							  * query virtual time
51 							  * offset */
52 	VMCALL_POST_CODE_LOGEVENT = 0x070B,	/* LOGEVENT Post Code (RDX) with
53 						 * specified subsystem mask (RCX
54 						 * - monitor_subsystems.h) and
55 						 * severity (RDX) */
56 	VMCALL_UPDATE_PHYSICAL_TIME = 0x0a02	/* Allow
57 						 * ULTRA_SERVICE_CAPABILITY_TIME
58 						 * capable guest to make
59 						 * VMCALL */
60 };
61 
62 #define VMCALL_SUCCESS 0
63 #define VMCALL_SUCCESSFUL(result)	(result == 0)
64 
65 #ifdef __GNUC__
66 #define unisys_vmcall(tuple, reg_ebx, reg_ecx) \
67 	__unisys_vmcall_gnuc(tuple, reg_ebx, reg_ecx)
68 #define unisys_extended_vmcall(tuple, reg_ebx, reg_ecx, reg_edx) \
69 	__unisys_extended_vmcall_gnuc(tuple, reg_ebx, reg_ecx, reg_edx)
70 #define ISSUE_IO_VMCALL(method, param, result) \
71 	(result = unisys_vmcall(method, (param) & 0xFFFFFFFF,	\
72 				(param) >> 32))
73 #define ISSUE_IO_EXTENDED_VMCALL(method, param1, param2, param3) \
74 	unisys_extended_vmcall(method, param1, param2, param3)
75 
76     /* The following uses VMCALL_POST_CODE_LOGEVENT interface but is currently
77      * not used much */
78 #define ISSUE_IO_VMCALL_POSTCODE_SEVERITY(postcode, severity)		\
79 	ISSUE_IO_EXTENDED_VMCALL(VMCALL_POST_CODE_LOGEVENT, severity,	\
80 				 MDS_APPOS, postcode)
81 #endif
82 
83 /* Structures for IO VMCALLs */
84 
85 /* Parameters to VMCALL_IO_CONTROLVM_ADDR interface */
86 struct vmcall_io_controlvm_addr_params {
87 	    /* The Guest-relative physical address of the ControlVm channel.
88 	    * This VMCall fills this in with the appropriate address. */
89 	u64 address;	/* contents provided by this VMCALL (OUT) */
90 	    /* the size of the ControlVm channel in bytes This VMCall fills this
91 	    * in with the appropriate address. */
92 	u32 channel_bytes;	/* contents provided by this VMCALL (OUT) */
93 	u8 unused[4];		/* Unused Bytes in the 64-Bit Aligned Struct */
94 } __packed;
95 
96 #endif /* __IOMONINTF_H__ */
97