222 lines · c
1/* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) */2/*3 * Freescale hypervisor ioctl and kernel interface4 *5 * Copyright (C) 2008-2011 Freescale Semiconductor, Inc.6 * Author: Timur Tabi <timur@freescale.com>7 *8 * Redistribution and use in source and binary forms, with or without9 * modification, are permitted provided that the following conditions are met:10 * * Redistributions of source code must retain the above copyright11 * notice, this list of conditions and the following disclaimer.12 * * Redistributions in binary form must reproduce the above copyright13 * notice, this list of conditions and the following disclaimer in the14 * documentation and/or other materials provided with the distribution.15 * * Neither the name of Freescale Semiconductor nor the16 * names of its contributors may be used to endorse or promote products17 * derived from this software without specific prior written permission.18 *19 *20 * ALTERNATIVELY, this software may be distributed under the terms of the21 * GNU General Public License ("GPL") as published by the Free Software22 * Foundation, either version 2 of that License or (at your option) any23 * later version.24 *25 * This software is provided by Freescale Semiconductor "as is" and any26 * express or implied warranties, including, but not limited to, the implied27 * warranties of merchantability and fitness for a particular purpose are28 * disclaimed. In no event shall Freescale Semiconductor be liable for any29 * direct, indirect, incidental, special, exemplary, or consequential damages30 * (including, but not limited to, procurement of substitute goods or services;31 * loss of use, data, or profits; or business interruption) however caused and32 * on any theory of liability, whether in contract, strict liability, or tort33 * (including negligence or otherwise) arising in any way out of the use of this34 * software, even if advised of the possibility of such damage.35 *36 * This file is used by the Freescale hypervisor management driver. It can37 * also be included by applications that need to communicate with the driver38 * via the ioctl interface.39 */40 41#ifndef _UAPIFSL_HYPERVISOR_H42#define _UAPIFSL_HYPERVISOR_H43 44#include <linux/types.h>45 46/**47 * struct fsl_hv_ioctl_restart - restart a partition48 * @ret: return error code from the hypervisor49 * @partition: the ID of the partition to restart, or -1 for the50 * calling partition51 *52 * Used by FSL_HV_IOCTL_PARTITION_RESTART53 */54struct fsl_hv_ioctl_restart {55 __u32 ret;56 __u32 partition;57};58 59/**60 * struct fsl_hv_ioctl_status - get a partition's status61 * @ret: return error code from the hypervisor62 * @partition: the ID of the partition to query, or -1 for the63 * calling partition64 * @status: The returned status of the partition65 *66 * Used by FSL_HV_IOCTL_PARTITION_GET_STATUS67 *68 * Values of 'status':69 * 0 = Stopped70 * 1 = Running71 * 2 = Starting72 * 3 = Stopping73 */74struct fsl_hv_ioctl_status {75 __u32 ret;76 __u32 partition;77 __u32 status;78};79 80/**81 * struct fsl_hv_ioctl_start - start a partition82 * @ret: return error code from the hypervisor83 * @partition: the ID of the partition to control84 * @entry_point: The offset within the guest IMA to start execution85 * @load: If non-zero, reload the partition's images before starting86 *87 * Used by FSL_HV_IOCTL_PARTITION_START88 */89struct fsl_hv_ioctl_start {90 __u32 ret;91 __u32 partition;92 __u32 entry_point;93 __u32 load;94};95 96/**97 * struct fsl_hv_ioctl_stop - stop a partition98 * @ret: return error code from the hypervisor99 * @partition: the ID of the partition to stop, or -1 for the calling100 * partition101 *102 * Used by FSL_HV_IOCTL_PARTITION_STOP103 */104struct fsl_hv_ioctl_stop {105 __u32 ret;106 __u32 partition;107};108 109/**110 * struct fsl_hv_ioctl_memcpy - copy memory between partitions111 * @ret: return error code from the hypervisor112 * @source: the partition ID of the source partition, or -1 for this113 * partition114 * @target: the partition ID of the target partition, or -1 for this115 * partition116 * @reserved: reserved, must be set to 0117 * @local_addr: user-space virtual address of a buffer in the local118 * partition119 * @remote_addr: guest physical address of a buffer in the120 * remote partition121 * @count: the number of bytes to copy. Both the local and remote122 * buffers must be at least 'count' bytes long123 *124 * Used by FSL_HV_IOCTL_MEMCPY125 *126 * The 'local' partition is the partition that calls this ioctl. The127 * 'remote' partition is a different partition. The data is copied from128 * the 'source' paritition' to the 'target' partition.129 *130 * The buffer in the remote partition must be guest physically131 * contiguous.132 *133 * This ioctl does not support copying memory between two remote134 * partitions or within the same partition, so either 'source' or135 * 'target' (but not both) must be -1. In other words, either136 *137 * source == local and target == remote138 * or139 * source == remote and target == local140 */141struct fsl_hv_ioctl_memcpy {142 __u32 ret;143 __u32 source;144 __u32 target;145 __u32 reserved; /* padding to ensure local_vaddr is aligned */146 __u64 local_vaddr;147 __u64 remote_paddr;148 __u64 count;149};150 151/**152 * struct fsl_hv_ioctl_doorbell - ring a doorbell153 * @ret: return error code from the hypervisor154 * @doorbell: the handle of the doorbell to ring doorbell155 *156 * Used by FSL_HV_IOCTL_DOORBELL157 */158struct fsl_hv_ioctl_doorbell {159 __u32 ret;160 __u32 doorbell;161};162 163/**164 * struct fsl_hv_ioctl_prop - get/set a device tree property165 * @ret: return error code from the hypervisor166 * @handle: handle of partition whose tree to access167 * @path: virtual address of path name of node to access168 * @propname: virtual address of name of property to access169 * @propval: virtual address of property data buffer170 * @proplen: Size of property data buffer171 * @reserved: reserved, must be set to 0172 *173 * Used by FSL_HV_IOCTL_DOORBELL174 */175struct fsl_hv_ioctl_prop {176 __u32 ret;177 __u32 handle;178 __u64 path;179 __u64 propname;180 __u64 propval;181 __u32 proplen;182 __u32 reserved; /* padding to ensure structure is aligned */183};184 185/* The ioctl type, documented in ioctl-number.txt */186#define FSL_HV_IOCTL_TYPE 0xAF187 188/* Restart another partition */189#define FSL_HV_IOCTL_PARTITION_RESTART \190 _IOWR(FSL_HV_IOCTL_TYPE, 1, struct fsl_hv_ioctl_restart)191 192/* Get a partition's status */193#define FSL_HV_IOCTL_PARTITION_GET_STATUS \194 _IOWR(FSL_HV_IOCTL_TYPE, 2, struct fsl_hv_ioctl_status)195 196/* Boot another partition */197#define FSL_HV_IOCTL_PARTITION_START \198 _IOWR(FSL_HV_IOCTL_TYPE, 3, struct fsl_hv_ioctl_start)199 200/* Stop this or another partition */201#define FSL_HV_IOCTL_PARTITION_STOP \202 _IOWR(FSL_HV_IOCTL_TYPE, 4, struct fsl_hv_ioctl_stop)203 204/* Copy data from one partition to another */205#define FSL_HV_IOCTL_MEMCPY \206 _IOWR(FSL_HV_IOCTL_TYPE, 5, struct fsl_hv_ioctl_memcpy)207 208/* Ring a doorbell */209#define FSL_HV_IOCTL_DOORBELL \210 _IOWR(FSL_HV_IOCTL_TYPE, 6, struct fsl_hv_ioctl_doorbell)211 212/* Get a property from another guest's device tree */213#define FSL_HV_IOCTL_GETPROP \214 _IOWR(FSL_HV_IOCTL_TYPE, 7, struct fsl_hv_ioctl_prop)215 216/* Set a property in another guest's device tree */217#define FSL_HV_IOCTL_SETPROP \218 _IOWR(FSL_HV_IOCTL_TYPE, 8, struct fsl_hv_ioctl_prop)219 220 221#endif /* _UAPIFSL_HYPERVISOR_H */222