blob: 0dd3d5c16593bf0d22a538bfc95c9802c737da78 [file] [log] [blame]
// Copyright 2023 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.
use crate::subsystems::prelude::*;
use assembly_config_schema::platform_config::kernel_config::PlatformKernelConfig;
pub(crate) struct KernelSubsystem;
impl DefineSubsystemConfiguration<PlatformKernelConfig> for KernelSubsystem {
fn define_configuration(
context: &ConfigurationContext<'_>,
kernel_config: &PlatformKernelConfig,
builder: &mut dyn ConfigurationBuilder,
) -> anyhow::Result<()> {
if kernel_config.lru_memory_compression && !kernel_config.memory_compression {
anyhow::bail!("'lru_memory_compression' can only be enabled with 'memory_compression'");
}
if kernel_config.memory_compression {
builder.platform_bundle("kernel_anonymous_memory_compression");
}
if kernel_config.lru_memory_compression {
builder.platform_bundle("kernel_anonymous_memory_compression_eager_lru");
}
if kernel_config.continuous_eviction {
builder.platform_bundle("kernel_evict_continuous");
}
// If the board supports the PMM checker, and this is an eng build-type
// build, enable the pmm checker.
if context.board_info.provides_feature("fuchsia::pmm_checker")
&& context.build_type == &BuildType::Eng
{
builder.platform_bundle("kernel_pmm_checker_enabled");
}
if context.board_info.kernel.contiguous_physical_pages {
builder.platform_bundle("kernel_contiguous_physical_pages");
}
Ok(())
}
}