Asylo
miscselect_util.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2020 Asylo authors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef ASYLO_IDENTITY_PLATFORM_SGX_MISCSELECT_UTIL_H_
20 #define ASYLO_IDENTITY_PLATFORM_SGX_MISCSELECT_UTIL_H_
21 
22 #include <vector>
23 
24 #include "absl/strings/string_view.h"
25 #include "asylo/identity/platform/sgx/architecture_bits.h"
26 #include "asylo/identity/platform/sgx/miscselect.pb.h"
27 #include "asylo/util/status.h"
28 #include "asylo/util/statusor.h"
29 
30 /// @file miscselect_util.h
31 /// @brief This library implements operations and utility functions on the proto
32 /// and uint32 representations of the MISCSELECT structure.
33 
34 namespace asylo {
35 namespace sgx {
36 
37 /// Checks two Miscselect protos for equality.
38 bool operator==(const Miscselect &lhs, const Miscselect &rhs);
39 
40 /// Checks two Miscselect protos for inequality.
41 bool operator!=(const Miscselect &lhs, const Miscselect &rhs);
42 
43 /// Sets the given `bit` of `miscselect` to true, or returns a non-OK Status if
44 /// the `bit` was invalid.
47 
48 /// Sets the given `bit` of `miscselect` to false, or returns a non-OK Status if
49 /// the `bit` was invalid.
52 
53 /// Returns whether the given `bit` of `miscselect` is set, or returns a non-OK
54 /// Status if the `bit` was invalid.
57  const Miscselect &miscselect);
58 
59 /// Returns a printable list of the bits set in `miscselect`.
62  const Miscselect &miscselect);
63 
64 } // namespace sgx
65 } // namespace asylo
66 
67 #endif // ASYLO_IDENTITY_PLATFORM_SGX_MISCSELECT_UTIL_H_
bool operator==(const Miscselect &lhs, const Miscselect &rhs)
Checks two Miscselect protos for equality.
StatusOr< bool > IsMiscselectBitSet(MiscselectBit bit, const Miscselect &miscselect)
bool operator!=(const Miscselect &lhs, const Miscselect &rhs)
Checks two Miscselect protos for inequality.
Status SetMiscselectBit(MiscselectBit bit, Miscselect *miscselect)
StatusOr< bool > IsMiscselectBitSet(MiscselectBit bit, uint32_t miscselect)
Returns whether the given bit of miscselect is set, or returns a non-OK Status if the bit was invalid...
Status ClearMiscselectBit(MiscselectBit bit, Miscselect *miscselect)
ABSL_CONST_INIT const char kStatusMoveAssignmentMsg[]
std::vector< absl::string_view > GetPrintableMiscselectList(const Miscselect &miscselect)
Definition: architecture_bits.h:26
std::vector< absl::string_view > GetPrintableMiscselectList(uint32_t miscselect)
Returns a printable list of the bits set in miscselect.