Namespaces

Enumerations

enum class Type : uint64_t
Name Value Comments
kFreeRam ZBI_MEM_TYPE_RAM

ZBI memory range types:

kPeripheral ZBI_MEM_TYPE_PERIPHERAL

ZBI memory range types:

kReserved ZBI_MEM_TYPE_RESERVED

ZBI memory range types:

kPoolBookkeeping kMinAllocatedTypeValue

Reserved for internal bookkeeping.

kPhysKernel 4294967297

The phys ZBI kernel memory image.

kPhysElf 4294967298

A phys ELF memory image.

kPhysLog 4294967299

A phys log file.

kKernel 4294967300

The kernel memory image.

kKernelStorage 4294967301

A (decompressed) STORAGE_KERNEL ZBI payload.

kDataZbi 4294967302

The data ZBI, as placed by the bootloader.

kTemporaryPhysHandoff 4294967303

Memory intended to remain allocated until the end of the phys hand-off
phase.

kPermanentPhysHandoff 4294967304

Memory intended to remain allocated for the lifetime of the kernel.

kVdso 4294967305

A vDSO memory image.

kUserboot 4294967306

The userboot memory image.

kBootMachineStack 4294967307

The kernel's boot machine stack.

kBootShadowCallStack 4294967308

The kernel's boot shadow call stack, if supported.

kBootUnsafeStack 4294967309

The kernel's boot unsafe stack, if safe stack is supported.

kTrampolineStagingKernel 4294967310

The intermediate kernel memory image used to trampoline into the same image
loaded at a fixed address (i.e., as used by TrampolineBoot).

kTrampolineStagingDataZbi 4294967311

The intermediate data ZBI used to trampoline into the same image
loaded at a fixed address (i.e., as used by TrampolineBoot).

kLegacyBootData 4294967312

Data structures related to legacy boot protocols.

kTemporaryIdentityPageTables 4294967313

Identity-mapping page tables intended only for the lifetime of the phys
program in execution.

kKernelPageTables 4294967314

Page tables that describe mappings intended to exist into the kernel
proper's lifetime.

kPhysDebugdata 4294967315

A debug data blob of phys origin (e.g., related to instrumentation).

kDevicetreeBlob 4294967316

A firmware-provided devicetree blob.

kPhysScratch 4294967317

General scratch space used by the phys kernel, but that which is free for
the next kernel as of hand-off.

kPoolTestPayload 4294967318

A generic allocated type for Pool tests.

kZbiTestPayload 4294967319

A generic allocated type for ZBI tests.

kTestRamReserve 4294967320

Memory carved out for the kernel.test.ram.reserve boot option.

kNvram 4294967321

Memory carved out for the ZBI_TYPE_NVRAM region.

kReservedLow 4294967322

Low memory, in an architecture-specific context, that is deemed to be
unsafe for general-purpose allocation and use (e.g., BIOS-related bits
below 1MiB in the case of PCs).

kTruncatedRam 4294967323

RAM 'discarded' from a truncation of the physical address space when
simulating booting contexts with less physical memory available.

kMaxAllocated 4294967324

A placeholder value signifying the last allocated type. It must not be used
as an actual type value.

The type of a physical memory range. Represented by 64 bits, the lower 2^32

values in the space are reserved for memory range types defined in the ZBI

spec, the "base types"; the types in the upper half are referred to as

"allocated types", and increment from kMinAllocatedTypeValue in value.

As is detailed in the ZBI spec regarding overlaps, among the base types,

kReserved and kPeripheral ranges have the highest precedence, in that order.

Further, by definition here, an allocated type is only permitted to overlap

with kFreeRam or the same type.

Defined at line 36 of file ../../zircon/kernel/phys/lib/memalloc/include/lib/memalloc/range.h

Records

Functions

  • std::ostream & operator<< (std::ostream & stream, Range range)

    Enables Range auto-stringification in gtest error messages

    Defined at line 23 of file ../../zircon/kernel/phys/lib/memalloc/include/lib/memalloc/testing/range.h

  • void FindNormalizedRamRanges (RangeStream ranges, RangeCallback cb)

    Say a range among a set is "normalized" if it does not intersect with any of

    them and it is maximally contiguous. This routine finds the normalized RAM

    ranges among a provided set with a degree of arbitrary intersection with one

    another. The range is emitted by passing it to a callback for processing.

    If the callback returns false, then the routine will exit early.

    The span of ranges will be reordered, but otherwise will be preserved.

    This function runs in O(n*log(n)) time, where n is the total number of given

    ranges.

    Defined at line 205 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.cc

  • void FindNormalizedRamRanges (RangeStream ranges, RangeCallback cb)

    Say a range among a set is "normalized" if it does not intersect with any of

    them and it is maximally contiguous. This routine finds the normalized RAM

    ranges among a provided set with a degree of arbitrary intersection with one

    another. The range is emitted by passing it to a callback for processing.

    If the callback returns false, then the routine will exit early.

    The span of ranges will be reordered, but otherwise will be preserved.

    This function runs in O(n*log(n)) time, where n is the total number of given

    ranges.

    Defined at line 205 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.cc

  • void FindNormalizedRamRanges (RangeStream ranges, RangeCallback cb)

    Say a range among a set is "normalized" if it does not intersect with any of

    them and it is maximally contiguous. This routine finds the normalized RAM

    ranges among a provided set with a degree of arbitrary intersection with one

    another. The range is emitted by passing it to a callback for processing.

    If the callback returns false, then the routine will exit early.

    The span of ranges will be reordered, but otherwise will be preserved.

    This function runs in O(n*log(n)) time, where n is the total number of given

    ranges.

    Defined at line 205 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.cc

  • void FindNormalizedRamRanges (RangeStream ranges, RangeCallback cb)

    Say a range among a set is "normalized" if it does not intersect with any of

    them and it is maximally contiguous. This routine finds the normalized RAM

    ranges among a provided set with a degree of arbitrary intersection with one

    another. The range is emitted by passing it to a callback for processing.

    If the callback returns false, then the routine will exit early.

    The span of ranges will be reordered, but otherwise will be preserved.

    This function runs in O(n*log(n)) time, where n is the total number of given

    ranges.

    Defined at line 205 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.cc

  • fit::result<fit::failed> FindNormalizedRanges (RangeStream ranges, std::span<void *> scratch, RangeCallback cb)

    A variant of the above algorithm that finds all of the normalized ranges in

    order. It also runs in O(n*log(n)) time but with O(n) space. In particular,

    a void* buffer of scratch of size `FindNormalizedRangesScratchSize()` must

    be provided.

    Ranges may overlap only if they are of the same type or one type is

    kFreeRam; otherwise fit::failed is returned.

    Defined at line 284 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.cc

  • fit::result<fit::failed> FindNormalizedRanges (RangeStream ranges, std::span<void *> scratch, RangeCallback cb)

    A variant of the above algorithm that finds all of the normalized ranges in

    order. It also runs in O(n*log(n)) time but with O(n) space. In particular,

    a void* buffer of scratch of size `FindNormalizedRangesScratchSize()` must

    be provided.

    Ranges may overlap only if they are of the same type or one type is

    kFreeRam; otherwise fit::failed is returned.

    Defined at line 284 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.cc

  • fit::result<fit::failed> FindNormalizedRanges (RangeStream ranges, std::span<void *> scratch, RangeCallback cb)

    A variant of the above algorithm that finds all of the normalized ranges in

    order. It also runs in O(n*log(n)) time but with O(n) space. In particular,

    a void* buffer of scratch of size `FindNormalizedRangesScratchSize()` must

    be provided.

    Ranges may overlap only if they are of the same type or one type is

    kFreeRam; otherwise fit::failed is returned.

    Defined at line 284 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.cc

  • fit::result<fit::failed> FindNormalizedRanges (RangeStream ranges, std::span<void *> scratch, RangeCallback cb)

    A variant of the above algorithm that finds all of the normalized ranges in

    order. It also runs in O(n*log(n)) time but with O(n) space. In particular,

    a void* buffer of scratch of size `FindNormalizedRangesScratchSize()` must

    be provided.

    Ranges may overlap only if they are of the same type or one type is

    kFreeRam; otherwise fit::failed is returned.

    Defined at line 284 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.cc

  • std::string_view ToString (Type type)

    Defined at line 31 of file ../../zircon/kernel/phys/lib/memalloc/range.cc

  • void FindNormalizedRamRanges (std::span<Range> ranges, RangeCallback cb)

    Used for streamlined testing.

    Defined at line 74 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.h

  • void FindNormalizedRamRanges (std::span<Range> ranges, RangeCallback cb)

    Used for streamlined testing.

    Defined at line 74 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.h

  • void FindNormalizedRamRanges (std::span<Range> ranges, RangeCallback cb)

    Used for streamlined testing.

    Defined at line 74 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.h

  • void FindNormalizedRamRanges (std::span<Range> ranges, RangeCallback cb)

    Used for streamlined testing.

    Defined at line 74 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.h

  • size_t FindNormalizedRangesScratchSize (size_t n)

    The size of tne void* scratch space needed for FindNormalizedRanges() below,

    where `n` is the size of the input RangeStream.

    Defined at line 81 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.h

  • size_t FindNormalizedRangesScratchSize (size_t n)

    The size of tne void* scratch space needed for FindNormalizedRanges() below,

    where `n` is the size of the input RangeStream.

    Defined at line 81 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.h

  • size_t FindNormalizedRangesScratchSize (size_t n)

    The size of tne void* scratch space needed for FindNormalizedRanges() below,

    where `n` is the size of the input RangeStream.

    Defined at line 81 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.h

  • fit::result<fit::failed> FindNormalizedRanges (std::span<Range> ranges, std::span<void *> scratch, RangeCallback cb)

    Used for streamlined testing.

    Defined at line 94 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.h

  • fit::result<fit::failed> FindNormalizedRanges (std::span<Range> ranges, std::span<void *> scratch, RangeCallback cb)

    Used for streamlined testing.

    Defined at line 94 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.h

  • fit::result<fit::failed> FindNormalizedRanges (std::span<Range> ranges, std::span<void *> scratch, RangeCallback cb)

    Used for streamlined testing.

    Defined at line 94 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.h

  • fit::result<fit::failed> FindNormalizedRanges (std::span<Range> ranges, std::span<void *> scratch, RangeCallback cb)

    Used for streamlined testing.

    Defined at line 94 of file ../../zircon/kernel/phys/lib/memalloc/algorithm.h

  • std::span<Range> AsRanges (std::span<zbi_mem_range_t> ranges)

    We have constrained Type so that the ZBI memory type's value space

    identically embeds into the lower 2^32 values of Type; the upper 2^32 values

    is reserved for Type's extensions. Accordingly, in order to coherently

    recast a zbi_mem_range_t as a Range, the former's `reserved` field -

    which, layout-wise, corresponds to the upper half of Type - must be zeroed

    out.

    Defined at line 103 of file ../../zircon/kernel/phys/lib/memalloc/range.cc

  • std::span<Range> AsRanges (std::span<zbi_mem_range_t> ranges)

    We have constrained Type so that the ZBI memory type's value space

    identically embeds into the lower 2^32 values of Type; the upper 2^32 values

    is reserved for Type's extensions. Accordingly, in order to coherently

    recast a zbi_mem_range_t as a Range, the former's `reserved` field -

    which, layout-wise, corresponds to the upper half of Type - must be zeroed

    out.

    Defined at line 103 of file ../../zircon/kernel/phys/lib/memalloc/range.cc

  • std::span<Range> AsRanges (std::span<zbi_mem_range_t> ranges)

    We have constrained Type so that the ZBI memory type's value space

    identically embeds into the lower 2^32 values of Type; the upper 2^32 values

    is reserved for Type's extensions. Accordingly, in order to coherently

    recast a zbi_mem_range_t as a Range, the former's `reserved` field -

    which, layout-wise, corresponds to the upper half of Type - must be zeroed

    out.

    Defined at line 103 of file ../../zircon/kernel/phys/lib/memalloc/range.cc

  • std::span<Range> AsRanges (std::span<zbi_mem_range_t> ranges)

    We have constrained Type so that the ZBI memory type's value space

    identically embeds into the lower 2^32 values of Type; the upper 2^32 values

    is reserved for Type's extensions. Accordingly, in order to coherently

    recast a zbi_mem_range_t as a Range, the former's `reserved` field -

    which, layout-wise, corresponds to the upper half of Type - must be zeroed

    out.

    Defined at line 103 of file ../../zircon/kernel/phys/lib/memalloc/range.cc

  • bool IsAllocatedType (Type type)

    Defined at line 157 of file ../../zircon/kernel/phys/lib/memalloc/include/lib/memalloc/range.h

  • bool IsRamType (Type type)

    Defined at line 161 of file ../../zircon/kernel/phys/lib/memalloc/include/lib/memalloc/range.h

  • template <class Ranges, typename RangeCallback, typename NormalizeTypeFn>
    void NormalizeRanges (Ranges && ranges, RangeCallback && cb, NormalizeTypeFn && normalize_type)

    Gives a custom, normalized view of a container of ranges, `Ranges`.

    `NormalizeTypeFn` is a callable with signature `std::optional

    <Type

    >(Type)`:

    std::nullopt indicates that ranges of this type should not be passed to the

    callback; otherwise, the returned type is indicates how the input type should

    be normalized. Adjacent ranges of the same normalized type are merged before

    being passed to the callback.

    The callback itself is expected to return a boolean indicating whether it

    should continue to be called.

    Defined at line 210 of file ../../zircon/kernel/phys/lib/memalloc/include/lib/memalloc/range.h

  • template <class Ranges, typename RangeCallback>
    void NormalizeRam (Ranges && ranges, RangeCallback && cb)

    Provides a callback with a normalized view of RAM ranges alone, reducing

    any allocated types as kFreeRam.

    Defined at line 246 of file ../../zircon/kernel/phys/lib/memalloc/include/lib/memalloc/range.h

  • template <class Ranges>
    void PrintRanges (Ranges && ranges, const char * prefix, FILE * f)

    Pretty-prints the contents in a given Range container.

    Defined at line 264 of file ../../zircon/kernel/phys/lib/memalloc/include/lib/memalloc/range.h

  • template <class Ranges>
    void PrintRanges (Ranges && ranges, const char * prefix, FILE * f)

    Pretty-prints the contents in a given Range container.

    Defined at line 264 of file ../../zircon/kernel/phys/lib/memalloc/include/lib/memalloc/range.h