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
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 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}
#define DECLARE_JSON_ENUM(TYPE,...)
Definition json.h:837
Definition attestation.h:20
Platform
Definition platform.h:11