sgx_edger8r.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (C) 2011-2017 Intel Corporation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in
  12. * the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Intel Corporation nor the names of its
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. */
  31. /*
  32. * Here contains functions intended to be used by `sgx_edger8r' only.
  33. *
  34. * -------------------------------------
  35. * Be warned: use them at your own risk.
  36. * -------------------------------------
  37. *
  38. */
  39. #ifndef _SGX_EDGER8R_H_
  40. #define _SGX_EDGER8R_H_
  41. #include "sgx_defs.h"
  42. #include "sgx_error.h"
  43. #include "sgx_eid.h"
  44. #include <stddef.h> /* for size_t */
  45. /* The `sgx_edger8r' tool will generate C interfaces. */
  46. #ifdef __cplusplus
  47. # define SGX_EXTERNC extern "C"
  48. #else
  49. # define SGX_EXTERNC
  50. #endif
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54. /* sgx_ocalloc()
  55. * Parameters:
  56. * size - bytes to allocate on the outside stack
  57. * Return Value:
  58. * the pointer to the allocated space on the outside stack
  59. * NULL - fail to allocate
  60. */
  61. void* SGXAPI sgx_ocalloc(size_t size);
  62. /* sgx_ocfree()
  63. * Parameters:
  64. * N/A
  65. * Return Value:
  66. * N/A
  67. */
  68. void SGXAPI sgx_ocfree(void);
  69. /* sgx_ecall()
  70. * Parameters:
  71. * eid - the enclave id
  72. * index - the index of the trusted function
  73. * ocall_table - the address of the OCALL table
  74. * ms - the pointer to the marshaling struct
  75. * Return Value:
  76. * SGX_SUCCESS on success
  77. */
  78. sgx_status_t SGXAPI sgx_ecall(const sgx_enclave_id_t eid,
  79. const int index,
  80. const void* ocall_table,
  81. void* ms);
  82. /* sgx_ocall()
  83. * Parameters:
  84. * index - the index of the untrusted function
  85. * ms - the pointer to the marshaling struct
  86. * Return Value:
  87. * SGX_SUCCESS on success
  88. */
  89. sgx_status_t SGXAPI sgx_ocall(const unsigned int index,
  90. void* ms);
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif /* !_SGX_EDGER8R_H_ */