CCF
Loading...
Searching...
No Matches
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
8namespace ccf::pal
9{
10 enum class Platform : uint8_t
11 {
12 SGX = 0,
13 SNP = 1,
14 Virtual = 2,
15 Unknown = 3,
16 };
19 {{Platform::SGX, "SGX"},
20 {Platform::SNP, "SNP"},
21 {Platform::Virtual, "Virtual"},
22 {Platform::Unknown, "Unknown"}});
23
24 static Platform _detect_platform()
25 {
26 // NOLINTNEXTLINE(concurrency-mt-unsafe)
27 auto* env_var = std::getenv("CCF_PLATFORM_OVERRIDE");
28 if (env_var != nullptr)
29 {
30 return nlohmann::json(env_var).get<Platform>();
31 }
32
33 if (ccf::pal::snp::supports_sev_snp())
34 {
35 return Platform::SNP;
36 }
37
38 return Platform::Virtual;
39 }
40
41 // Default inits to Unknown.
42 // Set this early from CLI, or explicitly for unit tests.
43 static auto platform = _detect_platform();
44}
#define DECLARE_JSON_ENUM(TYPE,...)
Definition json.h:841
Definition attestation.h:13
Platform
Definition platform.h:11