fsl_hypervisor.h 7.1 KB

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