blob: 12712746bbd0a9ce284d783a8b3fdad95140f793 [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.
#pragma once
#include <zircon/types.h>
namespace inspect {
// 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 inspect