CCF
Loading...
Searching...
No Matches
include
ccf
pal
platform.h
Go to the documentation of this file.
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// Licensed under the Apache 2.0 License.
3
#pragma once
4
5
#include "
ccf/ds/json.h
"
6
#include "
ccf/pal/snp_ioctl.h
"
7
8
namespace
ccf::pal
9
{
10
enum class
Platform
11
{
12
SGX
= 0,
13
SNP
= 1,
14
Virtual
= 2,
15
Unknown
= 3,
16
};
17
DECLARE_JSON_ENUM
(
18
Platform
,
19
{{
Platform::SGX
,
"SGX"
},
20
{
Platform::SNP
,
"SNP"
},
21
{
Platform::Virtual
,
"Virtual"
},
22
{
Platform::Unknown
,
"Unknown"
}});
23
24
static
Platform
_detect_platform()
25
{
26
auto
* env_var = std::getenv(
"CCF_PLATFORM_OVERRIDE"
);
27
if
(env_var !=
nullptr
)
28
{
29
return
nlohmann::json(env_var).get<
Platform
>();
30
}
31
32
if
(ccf::pal::snp::supports_sev_snp())
33
{
34
return
Platform::SNP
;
35
}
36
37
return
Platform::Virtual
;
38
}
39
40
// Default inits to Unknown.
41
// Set this early from CLI, or explicitly for unit tests.
42
static
auto
platform = _detect_platform();
43
}
json.h
DECLARE_JSON_ENUM
#define DECLARE_JSON_ENUM(TYPE,...)
Definition
json.h:837
ccf::pal
Definition
attestation.h:20
ccf::pal::Platform
Platform
Definition
platform.h:11
ccf::pal::Platform::SGX
@ SGX
ccf::pal::Platform::SNP
@ SNP
ccf::pal::Platform::Virtual
@ Virtual
ccf::pal::Platform::Unknown
@ Unknown
snp_ioctl.h
Generated by
1.9.8