ocall_types.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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_WAKE_THREAD,
  27. OCALL_CREATE_PROCESS,
  28. OCALL_FUTEX,
  29. OCALL_SOCKETPAIR,
  30. OCALL_SOCK_LISTEN,
  31. OCALL_SOCK_ACCEPT,
  32. OCALL_SOCK_CONNECT,
  33. OCALL_SOCK_RECV,
  34. OCALL_SOCK_SEND,
  35. OCALL_SOCK_RECV_FD,
  36. OCALL_SOCK_SEND_FD,
  37. OCALL_SOCK_SETOPT,
  38. OCALL_SOCK_SHUTDOWN,
  39. OCALL_GETTIME,
  40. OCALL_SLEEP,
  41. OCALL_POLL,
  42. OCALL_RENAME,
  43. OCALL_DELETE,
  44. OCALL_LOAD_DEBUG,
  45. OCALL_NR,
  46. };
  47. #define OCALL_NO_TIMEOUT ((uint64_t) -1)
  48. typedef struct {
  49. const char * ms_str;
  50. int ms_length;
  51. } ms_ocall_print_string_t;
  52. typedef struct {
  53. unsigned int ms_size;
  54. void * ms_mem;
  55. } ms_ocall_alloc_untrusted_t;
  56. typedef struct {
  57. int ms_fd;
  58. uint64_t ms_offset;
  59. uint64_t ms_size;
  60. unsigned short ms_prot;
  61. void * ms_mem;
  62. } ms_ocall_map_untrusted_t;
  63. typedef struct {
  64. const void * ms_mem;
  65. uint64_t ms_size;
  66. } ms_ocall_unmap_untrusted_t;
  67. typedef struct {
  68. unsigned int ms_leaf;
  69. unsigned int ms_subleaf;
  70. unsigned int ms_values[4];
  71. } ms_ocall_cpuid_t;
  72. typedef struct {
  73. const char * ms_pathname;
  74. int ms_flags;
  75. unsigned short ms_mode;
  76. } ms_ocall_open_t;
  77. typedef struct {
  78. int ms_fd;
  79. } ms_ocall_close_t;
  80. typedef struct {
  81. int ms_fd;
  82. void * ms_buf;
  83. unsigned int ms_count;
  84. } ms_ocall_read_t;
  85. typedef struct {
  86. int ms_fd;
  87. const void * ms_buf;
  88. unsigned int ms_count;
  89. } ms_ocall_write_t;
  90. typedef struct {
  91. int ms_fd;
  92. struct stat ms_stat;
  93. } ms_ocall_fstat_t;
  94. typedef struct {
  95. const char * ms_path;
  96. struct stat * ms_stat;
  97. } ms_ocall_stat_t;
  98. typedef struct {
  99. int ms_fd;
  100. } ms_ocall_fionread_t;
  101. typedef struct {
  102. int ms_fd;
  103. int ms_nonblocking;
  104. } ms_ocall_fsetnonblock_t;
  105. typedef struct {
  106. int ms_fd;
  107. unsigned short ms_mode;
  108. } ms_ocall_fchmod_t;
  109. typedef struct {
  110. int ms_fd;
  111. } ms_ocall_fsync_t;
  112. typedef struct {
  113. int ms_fd;
  114. unsigned int ms_length;
  115. } ms_ocall_ftruncate_t;
  116. typedef struct {
  117. const char * ms_pathname;
  118. unsigned short ms_mode;
  119. } ms_ocall_mkdir_t;
  120. typedef struct {
  121. int ms_fd;
  122. struct linux_dirent64 * ms_dirp;
  123. unsigned int ms_size;
  124. } ms_ocall_getdents_t;
  125. typedef struct {
  126. unsigned int ms_pid;
  127. const char * ms_uri;
  128. int ms_proc_fds[3];
  129. int ms_nargs;
  130. const char * ms_args[];
  131. } ms_ocall_create_process_t;
  132. typedef struct {
  133. int * ms_futex;
  134. int ms_op, ms_val;
  135. uint64_t ms_timeout;
  136. } ms_ocall_futex_t;
  137. typedef struct {
  138. int ms_domain, ms_type, ms_protocol;
  139. int ms_sockfds[2];
  140. } ms_ocall_socketpair_t;
  141. typedef struct {
  142. int ms_domain, ms_type, ms_protocol;
  143. const struct sockaddr * ms_addr;
  144. unsigned int ms_addrlen;
  145. struct sockopt ms_sockopt;
  146. } ms_ocall_sock_listen_t;
  147. typedef struct {
  148. int ms_sockfd;
  149. struct sockaddr * ms_addr;
  150. unsigned int ms_addrlen;
  151. struct sockopt ms_sockopt;
  152. } ms_ocall_sock_accept_t;
  153. typedef struct {
  154. int ms_domain, ms_type, ms_protocol;
  155. const struct sockaddr * ms_addr;
  156. unsigned int ms_addrlen;
  157. struct sockaddr * ms_bind_addr;
  158. unsigned int ms_bind_addrlen;
  159. struct sockopt ms_sockopt;
  160. } ms_ocall_sock_connect_t;
  161. typedef struct {
  162. int ms_sockfd;
  163. void * ms_buf;
  164. unsigned int ms_count;
  165. struct sockaddr * ms_addr;
  166. unsigned int ms_addrlen;
  167. } ms_ocall_sock_recv_t;
  168. typedef struct {
  169. int ms_sockfd;
  170. const void * ms_buf;
  171. unsigned int ms_count;
  172. const struct sockaddr * ms_addr;
  173. unsigned int ms_addrlen;
  174. } ms_ocall_sock_send_t;
  175. typedef struct {
  176. int ms_sockfd;
  177. void * ms_buf;
  178. unsigned int ms_count;
  179. unsigned int * ms_fds;
  180. unsigned int ms_nfds;
  181. } ms_ocall_sock_recv_fd_t;
  182. typedef struct {
  183. int ms_sockfd;
  184. const void * ms_buf;
  185. unsigned int ms_count;
  186. const unsigned int * ms_fds;
  187. unsigned int ms_nfds;
  188. } ms_ocall_sock_send_fd_t;
  189. typedef struct {
  190. int ms_sockfd;
  191. int ms_level;
  192. int ms_optname;
  193. const void * ms_optval;
  194. unsigned int ms_optlen;
  195. } ms_ocall_sock_setopt_t;
  196. typedef struct {
  197. int ms_sockfd;
  198. int ms_how;
  199. } ms_ocall_sock_shutdown_t;
  200. typedef struct {
  201. unsigned long ms_microsec;
  202. } ms_ocall_gettime_t;
  203. typedef struct {
  204. unsigned long ms_microsec;
  205. } ms_ocall_sleep_t;
  206. typedef struct {
  207. struct pollfd * ms_fds;
  208. int ms_nfds;
  209. uint64_t ms_timeout;
  210. } ms_ocall_poll_t;
  211. typedef struct {
  212. const char * ms_oldpath;
  213. const char * ms_newpath;
  214. } ms_ocall_rename_t;
  215. typedef struct {
  216. const char * ms_pathname;
  217. } ms_ocall_delete_t;
  218. typedef struct {
  219. unsigned int ms_tid;
  220. } ms_ocall_schedule_t;