ocall_types.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /*
  4. * This is for enclave to make ocalls to untrusted runtime.
  5. */
  6. #include "linux_types.h"
  7. enum {
  8. OCALL_EXIT = 0,
  9. OCALL_PRINT_STRING,
  10. OCALL_ALLOC_UNTRUSTED,
  11. OCALL_MAP_UNTRUSTED,
  12. OCALL_UNMAP_UNTRUSTED,
  13. OCALL_CPUID,
  14. OCALL_OPEN,
  15. OCALL_CLOSE,
  16. OCALL_READ,
  17. OCALL_WRITE,
  18. OCALL_FSTAT,
  19. OCALL_FIONREAD,
  20. OCALL_FSETNONBLOCK,
  21. OCALL_FCHMOD,
  22. OCALL_FSYNC,
  23. OCALL_FTRUNCATE,
  24. OCALL_MKDIR,
  25. OCALL_GETDENTS,
  26. OCALL_CLONE_THREAD,
  27. OCALL_CREATE_PROCESS,
  28. OCALL_EXIT_PROCESS,
  29. OCALL_FUTEX,
  30. OCALL_SOCKETPAIR,
  31. OCALL_SOCK_LISTEN,
  32. OCALL_SOCK_ACCEPT,
  33. OCALL_SOCK_CONNECT,
  34. OCALL_SOCK_RECV,
  35. OCALL_SOCK_SEND,
  36. OCALL_SOCK_RECV_FD,
  37. OCALL_SOCK_SEND_FD,
  38. OCALL_SOCK_SETOPT,
  39. OCALL_SOCK_SHUTDOWN,
  40. OCALL_GETTIME,
  41. OCALL_SLEEP,
  42. OCALL_POLL,
  43. OCALL_RENAME,
  44. OCALL_DELETE,
  45. OCALL_SCHEDULE,
  46. OCALL_LOAD_DEBUG,
  47. OCALL_NR,
  48. };
  49. typedef struct {
  50. const char * ms_str;
  51. int ms_length;
  52. } ms_ocall_print_string_t;
  53. typedef struct {
  54. unsigned int ms_size;
  55. void * ms_mem;
  56. } ms_ocall_alloc_untrusted_t;
  57. typedef struct {
  58. int ms_fd;
  59. uint64_t ms_offset;
  60. uint64_t ms_size;
  61. unsigned short ms_prot;
  62. void * ms_mem;
  63. } ms_ocall_map_untrusted_t;
  64. typedef struct {
  65. const void * ms_mem;
  66. uint64_t ms_size;
  67. } ms_ocall_unmap_untrusted_t;
  68. typedef struct {
  69. unsigned int ms_leaf;
  70. unsigned int ms_subleaf;
  71. unsigned int ms_values[4];
  72. } ms_ocall_cpuid_t;
  73. typedef struct {
  74. const char * ms_pathname;
  75. int ms_flags;
  76. unsigned short ms_mode;
  77. } ms_ocall_open_t;
  78. typedef struct {
  79. int ms_fd;
  80. } ms_ocall_close_t;
  81. typedef struct {
  82. int ms_fd;
  83. void * ms_buf;
  84. unsigned int ms_count;
  85. } ms_ocall_read_t;
  86. typedef struct {
  87. int ms_fd;
  88. const void * ms_buf;
  89. unsigned int ms_count;
  90. } ms_ocall_write_t;
  91. typedef struct {
  92. int ms_fd;
  93. struct stat ms_stat;
  94. } ms_ocall_fstat_t;
  95. typedef struct {
  96. const char * ms_path;
  97. struct stat * ms_stat;
  98. } ms_ocall_stat_t;
  99. typedef struct {
  100. int ms_fd;
  101. } ms_ocall_fionread_t;
  102. typedef struct {
  103. int ms_fd;
  104. int ms_nonblocking;
  105. } ms_ocall_fsetnonblock_t;
  106. typedef struct {
  107. int ms_fd;
  108. unsigned short ms_mode;
  109. } ms_ocall_fchmod_t;
  110. typedef struct {
  111. int ms_fd;
  112. } ms_ocall_fsync_t;
  113. typedef struct {
  114. int ms_fd;
  115. unsigned int ms_length;
  116. } ms_ocall_ftruncate_t;
  117. typedef struct {
  118. const char * ms_pathname;
  119. unsigned short ms_mode;
  120. } ms_ocall_mkdir_t;
  121. typedef struct {
  122. int ms_fd;
  123. struct linux_dirent64 * ms_dirp;
  124. unsigned int ms_size;
  125. } ms_ocall_getdents_t;
  126. typedef struct {
  127. void (*ms_func) (void *);
  128. const void * ms_arg;
  129. unsigned int * ms_child_tid;
  130. unsigned int ms_tid;
  131. } ms_ocall_clone_thread_t;
  132. typedef struct {
  133. unsigned int ms_pid;
  134. const char * ms_uri;
  135. int ms_proc_fds[3];
  136. int ms_nargs;
  137. const char * ms_args[];
  138. } ms_ocall_create_process_t;
  139. typedef struct {
  140. int ms_status;
  141. } ms_ocall_exit_process_t;
  142. typedef struct {
  143. int * ms_futex;
  144. int ms_op, ms_val;
  145. unsigned long ms_timeout;
  146. } ms_ocall_futex_t;
  147. typedef struct {
  148. int ms_domain, ms_type, ms_protocol;
  149. int ms_sockfds[2];
  150. } ms_ocall_socketpair_t;
  151. typedef struct {
  152. int ms_domain, ms_type, ms_protocol;
  153. const struct sockaddr * ms_addr;
  154. unsigned int ms_addrlen;
  155. struct sockopt ms_sockopt;
  156. } ms_ocall_sock_listen_t;
  157. typedef struct {
  158. int ms_sockfd;
  159. struct sockaddr * ms_addr;
  160. unsigned int ms_addrlen;
  161. struct sockopt ms_sockopt;
  162. } ms_ocall_sock_accept_t;
  163. typedef struct {
  164. int ms_domain, ms_type, ms_protocol;
  165. const struct sockaddr * ms_addr;
  166. unsigned int ms_addrlen;
  167. struct sockaddr * ms_bind_addr;
  168. unsigned int ms_bind_addrlen;
  169. struct sockopt ms_sockopt;
  170. } ms_ocall_sock_connect_t;
  171. typedef struct {
  172. int ms_sockfd;
  173. void * ms_buf;
  174. unsigned int ms_count;
  175. struct sockaddr * ms_addr;
  176. unsigned int ms_addrlen;
  177. } ms_ocall_sock_recv_t;
  178. typedef struct {
  179. int ms_sockfd;
  180. const void * ms_buf;
  181. unsigned int ms_count;
  182. const struct sockaddr * ms_addr;
  183. unsigned int ms_addrlen;
  184. } ms_ocall_sock_send_t;
  185. typedef struct {
  186. int ms_sockfd;
  187. void * ms_buf;
  188. unsigned int ms_count;
  189. unsigned int * ms_fds;
  190. unsigned int ms_nfds;
  191. } ms_ocall_sock_recv_fd_t;
  192. typedef struct {
  193. int ms_sockfd;
  194. const void * ms_buf;
  195. unsigned int ms_count;
  196. const unsigned int * ms_fds;
  197. unsigned int ms_nfds;
  198. } ms_ocall_sock_send_fd_t;
  199. typedef struct {
  200. int ms_sockfd;
  201. int ms_level;
  202. int ms_optname;
  203. const void * ms_optval;
  204. unsigned int ms_optlen;
  205. } ms_ocall_sock_setopt_t;
  206. typedef struct {
  207. int ms_sockfd;
  208. int ms_how;
  209. } ms_ocall_sock_shutdown_t;
  210. typedef struct {
  211. unsigned long ms_microsec;
  212. } ms_ocall_gettime_t;
  213. typedef struct {
  214. unsigned long ms_microsec;
  215. } ms_ocall_sleep_t;
  216. typedef struct {
  217. struct pollfd * ms_fds;
  218. int ms_nfds;
  219. unsigned long ms_timeout;
  220. } ms_ocall_poll_t;
  221. typedef struct {
  222. const char * ms_oldpath;
  223. const char * ms_newpath;
  224. } ms_ocall_rename_t;
  225. typedef struct {
  226. const char * ms_pathname;
  227. } ms_ocall_delete_t;
  228. typedef struct {
  229. unsigned int ms_tid;
  230. } ms_ocall_schedule_t;