xref: /OK3568_Linux_fs/kernel/include/uapi/linux/fsl_hypervisor.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Freescale hypervisor ioctl and kernel interface
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 2008-2011 Freescale Semiconductor, Inc.
6*4882a593Smuzhiyun  * Author: Timur Tabi <timur@freescale.com>
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Redistribution and use in source and binary forms, with or without
9*4882a593Smuzhiyun  * modification, are permitted provided that the following conditions are met:
10*4882a593Smuzhiyun  *     * Redistributions of source code must retain the above copyright
11*4882a593Smuzhiyun  *       notice, this list of conditions and the following disclaimer.
12*4882a593Smuzhiyun  *     * Redistributions in binary form must reproduce the above copyright
13*4882a593Smuzhiyun  *       notice, this list of conditions and the following disclaimer in the
14*4882a593Smuzhiyun  *       documentation and/or other materials provided with the distribution.
15*4882a593Smuzhiyun  *     * Neither the name of Freescale Semiconductor nor the
16*4882a593Smuzhiyun  *       names of its contributors may be used to endorse or promote products
17*4882a593Smuzhiyun  *       derived from this software without specific prior written permission.
18*4882a593Smuzhiyun  *
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  * ALTERNATIVELY, this software may be distributed under the terms of the
21*4882a593Smuzhiyun  * GNU General Public License ("GPL") as published by the Free Software
22*4882a593Smuzhiyun  * Foundation, either version 2 of that License or (at your option) any
23*4882a593Smuzhiyun  * later version.
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun  * This software is provided by Freescale Semiconductor "as is" and any
26*4882a593Smuzhiyun  * express or implied warranties, including, but not limited to, the implied
27*4882a593Smuzhiyun  * warranties of merchantability and fitness for a particular purpose are
28*4882a593Smuzhiyun  * disclaimed. In no event shall Freescale Semiconductor be liable for any
29*4882a593Smuzhiyun  * direct, indirect, incidental, special, exemplary, or consequential damages
30*4882a593Smuzhiyun  * (including, but not limited to, procurement of substitute goods or services;
31*4882a593Smuzhiyun  * loss of use, data, or profits; or business interruption) however caused and
32*4882a593Smuzhiyun  * on any theory of liability, whether in contract, strict liability, or tort
33*4882a593Smuzhiyun  * (including negligence or otherwise) arising in any way out of the use of this
34*4882a593Smuzhiyun  * software, even if advised of the possibility of such damage.
35*4882a593Smuzhiyun  *
36*4882a593Smuzhiyun  * This file is used by the Freescale hypervisor management driver.  It can
37*4882a593Smuzhiyun  * also be included by applications that need to communicate with the driver
38*4882a593Smuzhiyun  * via the ioctl interface.
39*4882a593Smuzhiyun  */
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #ifndef _UAPIFSL_HYPERVISOR_H
42*4882a593Smuzhiyun #define _UAPIFSL_HYPERVISOR_H
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun #include <linux/types.h>
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun /**
47*4882a593Smuzhiyun  * struct fsl_hv_ioctl_restart - restart a partition
48*4882a593Smuzhiyun  * @ret: return error code from the hypervisor
49*4882a593Smuzhiyun  * @partition: the ID of the partition to restart, or -1 for the
50*4882a593Smuzhiyun  *             calling partition
51*4882a593Smuzhiyun  *
52*4882a593Smuzhiyun  * Used by FSL_HV_IOCTL_PARTITION_RESTART
53*4882a593Smuzhiyun  */
54*4882a593Smuzhiyun struct fsl_hv_ioctl_restart {
55*4882a593Smuzhiyun 	__u32 ret;
56*4882a593Smuzhiyun 	__u32 partition;
57*4882a593Smuzhiyun };
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun /**
60*4882a593Smuzhiyun  * struct fsl_hv_ioctl_status - get a partition's status
61*4882a593Smuzhiyun  * @ret: return error code from the hypervisor
62*4882a593Smuzhiyun  * @partition: the ID of the partition to query, or -1 for the
63*4882a593Smuzhiyun  *             calling partition
64*4882a593Smuzhiyun  * @status: The returned status of the partition
65*4882a593Smuzhiyun  *
66*4882a593Smuzhiyun  * Used by FSL_HV_IOCTL_PARTITION_GET_STATUS
67*4882a593Smuzhiyun  *
68*4882a593Smuzhiyun  * Values of 'status':
69*4882a593Smuzhiyun  *    0 = Stopped
70*4882a593Smuzhiyun  *    1 = Running
71*4882a593Smuzhiyun  *    2 = Starting
72*4882a593Smuzhiyun  *    3 = Stopping
73*4882a593Smuzhiyun  */
74*4882a593Smuzhiyun struct fsl_hv_ioctl_status {
75*4882a593Smuzhiyun 	__u32 ret;
76*4882a593Smuzhiyun 	__u32 partition;
77*4882a593Smuzhiyun 	__u32 status;
78*4882a593Smuzhiyun };
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun /**
81*4882a593Smuzhiyun  * struct fsl_hv_ioctl_start - start a partition
82*4882a593Smuzhiyun  * @ret: return error code from the hypervisor
83*4882a593Smuzhiyun  * @partition: the ID of the partition to control
84*4882a593Smuzhiyun  * @entry_point: The offset within the guest IMA to start execution
85*4882a593Smuzhiyun  * @load: If non-zero, reload the partition's images before starting
86*4882a593Smuzhiyun  *
87*4882a593Smuzhiyun  * Used by FSL_HV_IOCTL_PARTITION_START
88*4882a593Smuzhiyun  */
89*4882a593Smuzhiyun struct fsl_hv_ioctl_start {
90*4882a593Smuzhiyun 	__u32 ret;
91*4882a593Smuzhiyun 	__u32 partition;
92*4882a593Smuzhiyun 	__u32 entry_point;
93*4882a593Smuzhiyun 	__u32 load;
94*4882a593Smuzhiyun };
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun /**
97*4882a593Smuzhiyun  * struct fsl_hv_ioctl_stop - stop a partition
98*4882a593Smuzhiyun  * @ret: return error code from the hypervisor
99*4882a593Smuzhiyun  * @partition: the ID of the partition to stop, or -1 for the calling
100*4882a593Smuzhiyun  *             partition
101*4882a593Smuzhiyun  *
102*4882a593Smuzhiyun  * Used by FSL_HV_IOCTL_PARTITION_STOP
103*4882a593Smuzhiyun  */
104*4882a593Smuzhiyun struct fsl_hv_ioctl_stop {
105*4882a593Smuzhiyun 	__u32 ret;
106*4882a593Smuzhiyun 	__u32 partition;
107*4882a593Smuzhiyun };
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun /**
110*4882a593Smuzhiyun  * struct fsl_hv_ioctl_memcpy - copy memory between partitions
111*4882a593Smuzhiyun  * @ret: return error code from the hypervisor
112*4882a593Smuzhiyun  * @source: the partition ID of the source partition, or -1 for this
113*4882a593Smuzhiyun  *          partition
114*4882a593Smuzhiyun  * @target: the partition ID of the target partition, or -1 for this
115*4882a593Smuzhiyun  *          partition
116*4882a593Smuzhiyun  * @reserved: reserved, must be set to 0
117*4882a593Smuzhiyun  * @local_addr: user-space virtual address of a buffer in the local
118*4882a593Smuzhiyun  *              partition
119*4882a593Smuzhiyun  * @remote_addr: guest physical address of a buffer in the
120*4882a593Smuzhiyun  *           remote partition
121*4882a593Smuzhiyun  * @count: the number of bytes to copy.  Both the local and remote
122*4882a593Smuzhiyun  *         buffers must be at least 'count' bytes long
123*4882a593Smuzhiyun  *
124*4882a593Smuzhiyun  * Used by FSL_HV_IOCTL_MEMCPY
125*4882a593Smuzhiyun  *
126*4882a593Smuzhiyun  * The 'local' partition is the partition that calls this ioctl.  The
127*4882a593Smuzhiyun  * 'remote' partition is a different partition.  The data is copied from
128*4882a593Smuzhiyun  * the 'source' paritition' to the 'target' partition.
129*4882a593Smuzhiyun  *
130*4882a593Smuzhiyun  * The buffer in the remote partition must be guest physically
131*4882a593Smuzhiyun  * contiguous.
132*4882a593Smuzhiyun  *
133*4882a593Smuzhiyun  * This ioctl does not support copying memory between two remote
134*4882a593Smuzhiyun  * partitions or within the same partition, so either 'source' or
135*4882a593Smuzhiyun  * 'target' (but not both) must be -1.  In other words, either
136*4882a593Smuzhiyun  *
137*4882a593Smuzhiyun  *      source == local and target == remote
138*4882a593Smuzhiyun  * or
139*4882a593Smuzhiyun  *      source == remote and target == local
140*4882a593Smuzhiyun  */
141*4882a593Smuzhiyun struct fsl_hv_ioctl_memcpy {
142*4882a593Smuzhiyun 	__u32 ret;
143*4882a593Smuzhiyun 	__u32 source;
144*4882a593Smuzhiyun 	__u32 target;
145*4882a593Smuzhiyun 	__u32 reserved;	/* padding to ensure local_vaddr is aligned */
146*4882a593Smuzhiyun 	__u64 local_vaddr;
147*4882a593Smuzhiyun 	__u64 remote_paddr;
148*4882a593Smuzhiyun 	__u64 count;
149*4882a593Smuzhiyun };
150*4882a593Smuzhiyun 
151*4882a593Smuzhiyun /**
152*4882a593Smuzhiyun  * struct fsl_hv_ioctl_doorbell - ring a doorbell
153*4882a593Smuzhiyun  * @ret: return error code from the hypervisor
154*4882a593Smuzhiyun  * @doorbell: the handle of the doorbell to ring doorbell
155*4882a593Smuzhiyun  *
156*4882a593Smuzhiyun  * Used by FSL_HV_IOCTL_DOORBELL
157*4882a593Smuzhiyun  */
158*4882a593Smuzhiyun struct fsl_hv_ioctl_doorbell {
159*4882a593Smuzhiyun 	__u32 ret;
160*4882a593Smuzhiyun 	__u32 doorbell;
161*4882a593Smuzhiyun };
162*4882a593Smuzhiyun 
163*4882a593Smuzhiyun /**
164*4882a593Smuzhiyun  * struct fsl_hv_ioctl_prop - get/set a device tree property
165*4882a593Smuzhiyun  * @ret: return error code from the hypervisor
166*4882a593Smuzhiyun  * @handle: handle of partition whose tree to access
167*4882a593Smuzhiyun  * @path: virtual address of path name of node to access
168*4882a593Smuzhiyun  * @propname: virtual address of name of property to access
169*4882a593Smuzhiyun  * @propval: virtual address of property data buffer
170*4882a593Smuzhiyun  * @proplen: Size of property data buffer
171*4882a593Smuzhiyun  * @reserved: reserved, must be set to 0
172*4882a593Smuzhiyun  *
173*4882a593Smuzhiyun  * Used by FSL_HV_IOCTL_DOORBELL
174*4882a593Smuzhiyun  */
175*4882a593Smuzhiyun struct fsl_hv_ioctl_prop {
176*4882a593Smuzhiyun 	__u32 ret;
177*4882a593Smuzhiyun 	__u32 handle;
178*4882a593Smuzhiyun 	__u64 path;
179*4882a593Smuzhiyun 	__u64 propname;
180*4882a593Smuzhiyun 	__u64 propval;
181*4882a593Smuzhiyun 	__u32 proplen;
182*4882a593Smuzhiyun 	__u32 reserved;	/* padding to ensure structure is aligned */
183*4882a593Smuzhiyun };
184*4882a593Smuzhiyun 
185*4882a593Smuzhiyun /* The ioctl type, documented in ioctl-number.txt */
186*4882a593Smuzhiyun #define FSL_HV_IOCTL_TYPE	0xAF
187*4882a593Smuzhiyun 
188*4882a593Smuzhiyun /* Restart another partition */
189*4882a593Smuzhiyun #define FSL_HV_IOCTL_PARTITION_RESTART \
190*4882a593Smuzhiyun 	_IOWR(FSL_HV_IOCTL_TYPE, 1, struct fsl_hv_ioctl_restart)
191*4882a593Smuzhiyun 
192*4882a593Smuzhiyun /* Get a partition's status */
193*4882a593Smuzhiyun #define FSL_HV_IOCTL_PARTITION_GET_STATUS \
194*4882a593Smuzhiyun 	_IOWR(FSL_HV_IOCTL_TYPE, 2, struct fsl_hv_ioctl_status)
195*4882a593Smuzhiyun 
196*4882a593Smuzhiyun /* Boot another partition */
197*4882a593Smuzhiyun #define FSL_HV_IOCTL_PARTITION_START \
198*4882a593Smuzhiyun 	_IOWR(FSL_HV_IOCTL_TYPE, 3, struct fsl_hv_ioctl_start)
199*4882a593Smuzhiyun 
200*4882a593Smuzhiyun /* Stop this or another partition */
201*4882a593Smuzhiyun #define FSL_HV_IOCTL_PARTITION_STOP \
202*4882a593Smuzhiyun 	_IOWR(FSL_HV_IOCTL_TYPE, 4, struct fsl_hv_ioctl_stop)
203*4882a593Smuzhiyun 
204*4882a593Smuzhiyun /* Copy data from one partition to another */
205*4882a593Smuzhiyun #define FSL_HV_IOCTL_MEMCPY \
206*4882a593Smuzhiyun 	_IOWR(FSL_HV_IOCTL_TYPE, 5, struct fsl_hv_ioctl_memcpy)
207*4882a593Smuzhiyun 
208*4882a593Smuzhiyun /* Ring a doorbell */
209*4882a593Smuzhiyun #define FSL_HV_IOCTL_DOORBELL \
210*4882a593Smuzhiyun 	_IOWR(FSL_HV_IOCTL_TYPE, 6, struct fsl_hv_ioctl_doorbell)
211*4882a593Smuzhiyun 
212*4882a593Smuzhiyun /* Get a property from another guest's device tree */
213*4882a593Smuzhiyun #define FSL_HV_IOCTL_GETPROP \
214*4882a593Smuzhiyun 	_IOWR(FSL_HV_IOCTL_TYPE, 7, struct fsl_hv_ioctl_prop)
215*4882a593Smuzhiyun 
216*4882a593Smuzhiyun /* Set a property in another guest's device tree */
217*4882a593Smuzhiyun #define FSL_HV_IOCTL_SETPROP \
218*4882a593Smuzhiyun 	_IOWR(FSL_HV_IOCTL_TYPE, 8, struct fsl_hv_ioctl_prop)
219*4882a593Smuzhiyun 
220*4882a593Smuzhiyun 
221*4882a593Smuzhiyun #endif /* _UAPIFSL_HYPERVISOR_H */
222