sgx_capable.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright 2011-2017 Intel Corporation
  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. * 1. Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * 3. Neither the name of the copyright holder nor the names of its
  16. * contributors may be used to endorse or promote products derived from
  17. * this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  25. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  26. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  27. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #pragma once
  32. #ifndef _SGX_CAPABLE_H_
  33. #define _SGX_CAPABLE_H_
  34. #include "sgx_error.h"
  35. #include "sgx_defs.h"
  36. #if defined(_MSC_VER)
  37. #include <Windows.h>
  38. #endif
  39. typedef enum _sgx_device_status_t {
  40. SGX_ENABLED,
  41. SGX_DISABLED_REBOOT_REQUIRED, /* A reboot is required to finish enabling SGX */
  42. SGX_DISABLED_LEGACY_OS, /* SGX is disabled and a Software Control Interface is not available to enable it */
  43. SGX_DISABLED, /* SGX is not enabled on this platform. More details are unavailable. */
  44. SGX_DISABLED_SCI_AVAILABLE, /* SGX is disabled, but a Software Control Interface is available to enable it */
  45. SGX_DISABLED_MANUAL_ENABLE, /* SGX is disabled, but can be enabled manually in the BIOS setup */
  46. SGX_DISABLED_HYPERV_ENABLED, /* Detected an unsupported version of Windows* 10 with Hyper-V enabled */
  47. SGX_DISABLED_UNSUPPORTED_CPU, /* SGX is not supported by this CPU */
  48. } sgx_device_status_t;
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52. /*
  53. * Function to check if the client platform is SGX enabled.
  54. *
  55. * @param sgx_capable[out] The SGX capable status of the client platform.
  56. * 1 - Platform is SGX enabled or the Software Control Interface is available to configure SGX
  57. * 0 - SGX not available
  58. * @return If the function succeeds, return SGX_SUCCESS, any other value indicates an error.
  59. */
  60. sgx_status_t sgx_is_capable(int* sgx_capable);
  61. /*
  62. * Function used to enable SGX device through EFI.
  63. *
  64. * @param sgx_device_status[out] The status of SGX device.
  65. * @return If the function succeeds, return SGX_SUCCESS, any other value indicates an error.
  66. */
  67. sgx_status_t sgx_cap_enable_device(sgx_device_status_t* sgx_device_status);
  68. /*
  69. * Function used to query SGX device status.
  70. *
  71. * @param sgx_device_status[out] The status of SGX device.
  72. * @return If the function succeeds, return SGX_SUCCESS, any other value indicates an error.
  73. */
  74. sgx_status_t SGXAPI sgx_cap_get_status(sgx_device_status_t* sgx_device_status);
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif