blob: 04f76e5c6dde9507ab7f1c55f93bed23131251b0 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef LIB_INSPECT_VMO_LIMITS_H_
#define LIB_INSPECT_VMO_LIMITS_H_
#include <zircon/types.h>
namespace inspect {
namespace vmo {
// The size for order 0.
constexpr size_t kMinOrderShift = 4;
constexpr size_t kMinOrderSize = 1 << kMinOrderShift; // 16 bytes
// The total number of orders in the buddy allocator.
constexpr size_t kNumOrders = 8;
// The size of the maximum order.
constexpr size_t kMaxOrderShift = kMinOrderShift + kNumOrders - 1;
constexpr size_t kMaxOrderSize = 1 << kMaxOrderShift;
// The minimum size for the inspection VMO.
constexpr size_t kMinVmoSize = 4096;
static_assert(kMinVmoSize >= kMaxOrderSize,
"Maximum order size must fit in the smallest VMO");
// The magic number for verifying the VMO format.
constexpr char kMagicNumber[5] = "INSP";
template <typename T>
constexpr size_t OrderToSize(T order) {
return kMinOrderSize << order;
}
constexpr size_t IndexForOffset(size_t offset) {
return offset / kMinOrderSize;
}
} // namespace vmo
} // namespace inspect
#endif // LIB_INSPECT_VMO_LIMITS_H_