inspect_format/
constants.rs

1// Copyright 2019 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5//! Various constants used for Inspect.
6
7pub use diagnostics_hierarchy::{EXPONENTIAL_HISTOGRAM_EXTRA_SLOTS, LINEAR_HISTOGRAM_EXTRA_SLOTS};
8
9/// Bytes per page
10pub const PAGE_SIZE_BYTES: usize = 4096;
11
12/// Size of the a VMO block header.
13pub const HEADER_SIZE_BYTES: usize = 8;
14
15/// Magic number for the Header block. "INSP" in UTF-8 little-endian.
16pub const HEADER_MAGIC_NUMBER: u32 = 0x50534e49;
17
18/// Version number for the Header block.
19pub const HEADER_VERSION_NUMBER: u32 = 2;
20
21/// Maximum number order of a block.
22pub const NUM_ORDERS: u8 = 8;
23
24/// The shift for order 0.
25pub const MIN_ORDER_SHIFT: usize = 4;
26
27/// The size for order 0.
28pub const MIN_ORDER_SIZE: usize = 1 << MIN_ORDER_SHIFT; // 16 bytes
29
30/// The shift for order NUM_ORDERS-1 (the maximum order)
31pub const MAX_ORDER_SHIFT: usize = MIN_ORDER_SHIFT + (NUM_ORDERS as usize) - 1;
32
33/// The size for order NUM_ORDERS-1 (the maximum order)
34pub const MAX_ORDER_SIZE: usize = 1 << MAX_ORDER_SHIFT;
35
36/// Default number of bytes for the VMO: 256K
37pub const DEFAULT_VMO_SIZE_BYTES: usize = 256 * 1024;
38
39/// Minimum size for the VMO: 4K
40pub const MINIMUM_VMO_SIZE_BYTES: usize = 4 * 1024;
41
42/// Maximum size for a VMO: 100MB
43pub const MAX_VMO_SIZE: usize = 128 * 1024 * 1024;
44
45/// Length in bytes of metadata in the payload of an array block.
46pub const ARRAY_PAYLOAD_METADATA_SIZE_BYTES: usize = 8;
47
48/// The number of bytes in the payload of a STRING_REFERENCE allotted to
49/// the total length.
50pub const STRING_REFERENCE_TOTAL_LENGTH_BYTES: usize = 4;
51
52/// This generation count indicates a VMO is frozen.
53/// It is even to allow creating an inspector that can write to the VMO.
54pub const VMO_FROZEN: u64 = u64::MAX - 1;
55
56/// The order of the header block.
57pub const HEADER_ORDER: u8 = 1;