ocall_types.h 5.0 KB

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