1607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/*
2607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Freescale hypervisor ioctl and kernel interface
3607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
4607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Copyright (C) 2008-2011 Freescale Semiconductor, Inc.
5607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Author: Timur Tabi <timur@freescale.com>
6607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
7607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Redistribution and use in source and binary forms, with or without
8607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * modification, are permitted provided that the following conditions are met:
9607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *     * Redistributions of source code must retain the above copyright
10607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *       notice, this list of conditions and the following disclaimer.
11607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *     * Redistributions in binary form must reproduce the above copyright
12607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *       notice, this list of conditions and the following disclaimer in the
13607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *       documentation and/or other materials provided with the distribution.
14607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *     * Neither the name of Freescale Semiconductor nor the
15607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *       names of its contributors may be used to endorse or promote products
16607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *       derived from this software without specific prior written permission.
17607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
18607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
19607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * ALTERNATIVELY, this software may be distributed under the terms of the
20607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * GNU General Public License ("GPL") as published by the Free Software
21607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Foundation, either version 2 of that License or (at your option) any
22607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * later version.
23607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
24607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * This software is provided by Freescale Semiconductor "as is" and any
25607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * express or implied warranties, including, but not limited to, the implied
26607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * warranties of merchantability and fitness for a particular purpose are
27607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * disclaimed. In no event shall Freescale Semiconductor be liable for any
28607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * direct, indirect, incidental, special, exemplary, or consequential damages
29607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * (including, but not limited to, procurement of substitute goods or services;
30607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * loss of use, data, or profits; or business interruption) however caused and
31607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * on any theory of liability, whether in contract, strict liability, or tort
32607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * (including negligence or otherwise) arising in any way out of the use of this
33607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * software, even if advised of the possibility of such damage.
34607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
35607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * This file is used by the Freescale hypervisor management driver.  It can
36607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * also be included by applications that need to communicate with the driver
37607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * via the ioctl interface.
38607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells */
39607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
40607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#ifndef _UAPIFSL_HYPERVISOR_H
41607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define _UAPIFSL_HYPERVISOR_H
42607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
43607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#include <linux/types.h>
44607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
45607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/**
46607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * struct fsl_hv_ioctl_restart - restart a partition
47607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @ret: return error code from the hypervisor
48607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @partition: the ID of the partition to restart, or -1 for the
49607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *             calling partition
50607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
51607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Used by FSL_HV_IOCTL_PARTITION_RESTART
52607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells */
53607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct fsl_hv_ioctl_restart {
54607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 ret;
55607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 partition;
56607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
57607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
58607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/**
59607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * struct fsl_hv_ioctl_status - get a partition's status
60607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @ret: return error code from the hypervisor
61607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @partition: the ID of the partition to query, or -1 for the
62607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *             calling partition
63607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @status: The returned status of the partition
64607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
65607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Used by FSL_HV_IOCTL_PARTITION_GET_STATUS
66607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
67607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Values of 'status':
68607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *    0 = Stopped
69607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *    1 = Running
70607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *    2 = Starting
71607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *    3 = Stopping
72607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells */
73607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct fsl_hv_ioctl_status {
74607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 ret;
75607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 partition;
76607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 status;
77607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
78607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
79607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/**
80607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * struct fsl_hv_ioctl_start - start a partition
81607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @ret: return error code from the hypervisor
82607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @partition: the ID of the partition to control
83607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @entry_point: The offset within the guest IMA to start execution
84607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @load: If non-zero, reload the partition's images before starting
85607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
86607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Used by FSL_HV_IOCTL_PARTITION_START
87607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells */
88607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct fsl_hv_ioctl_start {
89607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 ret;
90607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 partition;
91607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 entry_point;
92607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 load;
93607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
94607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
95607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/**
96607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * struct fsl_hv_ioctl_stop - stop a partition
97607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @ret: return error code from the hypervisor
98607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @partition: the ID of the partition to stop, or -1 for the calling
99607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *             partition
100607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
101607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Used by FSL_HV_IOCTL_PARTITION_STOP
102607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells */
103607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct fsl_hv_ioctl_stop {
104607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 ret;
105607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 partition;
106607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
107607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
108607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/**
109607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * struct fsl_hv_ioctl_memcpy - copy memory between partitions
110607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @ret: return error code from the hypervisor
111607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @source: the partition ID of the source partition, or -1 for this
112607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *          partition
113607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @target: the partition ID of the target partition, or -1 for this
114607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *          partition
115607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @reserved: reserved, must be set to 0
116607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @local_addr: user-space virtual address of a buffer in the local
117607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *              partition
118607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @remote_addr: guest physical address of a buffer in the
119607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *           remote partition
120607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @count: the number of bytes to copy.  Both the local and remote
121607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *         buffers must be at least 'count' bytes long
122607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
123607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Used by FSL_HV_IOCTL_MEMCPY
124607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
125607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * The 'local' partition is the partition that calls this ioctl.  The
126607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * 'remote' partition is a different partition.  The data is copied from
127607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * the 'source' paritition' to the 'target' partition.
128607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
129607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * The buffer in the remote partition must be guest physically
130607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * contiguous.
131607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
132607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * This ioctl does not support copying memory between two remote
133607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * partitions or within the same partition, so either 'source' or
134607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * 'target' (but not both) must be -1.  In other words, either
135607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
136607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *      source == local and target == remote
137607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * or
138607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *      source == remote and target == local
139607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells */
140607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct fsl_hv_ioctl_memcpy {
141607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 ret;
142607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 source;
143607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 target;
144607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 reserved;	/* padding to ensure local_vaddr is aligned */
145607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u64 local_vaddr;
146607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u64 remote_paddr;
147607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u64 count;
148607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
149607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
150607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/**
151607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * struct fsl_hv_ioctl_doorbell - ring a doorbell
152607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @ret: return error code from the hypervisor
153607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @doorbell: the handle of the doorbell to ring doorbell
154607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
155607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Used by FSL_HV_IOCTL_DOORBELL
156607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells */
157607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct fsl_hv_ioctl_doorbell {
158607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 ret;
159607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 doorbell;
160607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
161607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
162607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/**
163607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * struct fsl_hv_ioctl_prop - get/set a device tree property
164607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @ret: return error code from the hypervisor
165607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @handle: handle of partition whose tree to access
166607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @path: virtual address of path name of node to access
167607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @propname: virtual address of name of property to access
168607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @propval: virtual address of property data buffer
169607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @proplen: Size of property data buffer
170607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * @reserved: reserved, must be set to 0
171607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
172607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * Used by FSL_HV_IOCTL_DOORBELL
173607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells */
174607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct fsl_hv_ioctl_prop {
175607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 ret;
176607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 handle;
177607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u64 path;
178607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u64 propname;
179607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u64 propval;
180607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 proplen;
181607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 reserved;	/* padding to ensure structure is aligned */
182607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
183607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
184607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* The ioctl type, documented in ioctl-number.txt */
185607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define FSL_HV_IOCTL_TYPE	0xAF
186607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
187607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* Restart another partition */
188607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define FSL_HV_IOCTL_PARTITION_RESTART \
189607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	_IOWR(FSL_HV_IOCTL_TYPE, 1, struct fsl_hv_ioctl_restart)
190607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
191607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* Get a partition's status */
192607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define FSL_HV_IOCTL_PARTITION_GET_STATUS \
193607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	_IOWR(FSL_HV_IOCTL_TYPE, 2, struct fsl_hv_ioctl_status)
194607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
195607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* Boot another partition */
196607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define FSL_HV_IOCTL_PARTITION_START \
197607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	_IOWR(FSL_HV_IOCTL_TYPE, 3, struct fsl_hv_ioctl_start)
198607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
199607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* Stop this or another partition */
200607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define FSL_HV_IOCTL_PARTITION_STOP \
201607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	_IOWR(FSL_HV_IOCTL_TYPE, 4, struct fsl_hv_ioctl_stop)
202607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
203607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* Copy data from one partition to another */
204607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define FSL_HV_IOCTL_MEMCPY \
205607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	_IOWR(FSL_HV_IOCTL_TYPE, 5, struct fsl_hv_ioctl_memcpy)
206607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
207607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* Ring a doorbell */
208607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define FSL_HV_IOCTL_DOORBELL \
209607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	_IOWR(FSL_HV_IOCTL_TYPE, 6, struct fsl_hv_ioctl_doorbell)
210607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
211607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* Get a property from another guest's device tree */
212607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define FSL_HV_IOCTL_GETPROP \
213607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	_IOWR(FSL_HV_IOCTL_TYPE, 7, struct fsl_hv_ioctl_prop)
214607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
215607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* Set a property in another guest's device tree */
216607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define FSL_HV_IOCTL_SETPROP \
217607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	_IOWR(FSL_HV_IOCTL_TYPE, 8, struct fsl_hv_ioctl_prop)
218607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
219607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
220607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#endif /* _UAPIFSL_HYPERVISOR_H */
221