| # Licensed under the Apache-2.0 license |
| # SPDX-License-Identifier: Apache-2.0 |
| |
| load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") |
| load("@pigweed//pw_build:merge_flags.bzl", "flags_from_dict") |
| load("@pigweed//pw_kernel:flags.bzl", "KERNEL_DEVICE_COMMON_FLAGS") |
| load("@rules_rust//rust:defs.bzl", "rust_library") |
| load("//target/ast10x0:defs.bzl", "TARGET_COMPATIBLE_WITH") |
| |
| package(default_visibility = [":__subpackages__"]) |
| |
| # Set automatically by `--config=virt_ast10x0` (see /.bazelrc) when running |
| # under QEMU's ast1030-evb machine; flips kernel_config's `qemu` Cargo feature |
| # so SysTick is retuned to QEMU's 12 MHz emulated clock. |
| bool_flag( |
| name = "qemu", |
| build_setting_default = False, |
| ) |
| |
| # bool_flag( |
| # name = "uart_boot_header", |
| # build_setting_default = False, |
| # ) |
| |
| config_setting( |
| name = "qemu_enabled", |
| flag_values = {":qemu": "true"}, |
| ) |
| |
| platform( |
| name = "ast10x0", |
| constraint_values = [ |
| ":target_ast10x0", |
| # Uses cortex-m4 constraint with soft-float ABI (thumbv7em-none-eabi). |
| # The AST10x0 is a Cortex-M4F; we use the soft-float triple to avoid |
| # FPU ABI complications in the kernel. |
| "@pigweed//pw_build/constraints/arm:cortex-m4", |
| "@platforms//cpu:armv7e-m", |
| "@platforms//os:none", |
| "@pigweed//pw_build/constraints/rust:no_std", |
| ], |
| flags = flags_from_dict( |
| KERNEL_DEVICE_COMMON_FLAGS | { |
| "@pigweed//pw_kernel/config:kernel_config": ":config", |
| "@pigweed//pw_kernel/subsys/console:console_backend": ":console", |
| }, |
| ), |
| visibility = [":__subpackages__"], |
| ) |
| |
| constraint_value( |
| name = "target_ast10x0", |
| constraint_setting = "@pigweed//pw_kernel/target:target", |
| visibility = [ |
| ":__subpackages__", |
| "//drivers:__subpackages__", |
| ], |
| ) |
| |
| rust_library( |
| name = "console", |
| srcs = ["console_backend.rs"], |
| crate_name = "console_backend", |
| edition = "2024", |
| tags = ["kernel"], |
| target_compatible_with = TARGET_COMPATIBLE_WITH, |
| deps = [ |
| "//target/ast10x0/peripherals", |
| "@ast1060_pac", |
| "@pigweed//pw_kernel/arch/arm_cortex_m:arch_arm_cortex_m", |
| "@pigweed//pw_kernel/kernel", |
| "@pigweed//pw_status/rust:pw_status", |
| "@rust_crates//:embedded-io", |
| ], |
| ) |
| |
| rust_library( |
| name = "entry", |
| srcs = ["entry.rs"], |
| edition = "2024", |
| tags = ["kernel"], |
| target_compatible_with = TARGET_COMPATIBLE_WITH, |
| deps = [ |
| "@ast1060_pac", |
| "@pigweed//pw_kernel/arch/arm_cortex_m:arch_arm_cortex_m", |
| "@pigweed//pw_kernel/kernel", |
| "@pigweed//pw_status/rust:pw_status", |
| "@rust_crates//:cortex-m-rt", |
| ], |
| ) |
| |
| rust_library( |
| name = "config", |
| srcs = ["config.rs"], |
| crate_features = select({ |
| ":qemu_enabled": ["qemu"], |
| "//conditions:default": [], |
| }), |
| crate_name = "kernel_config", |
| edition = "2024", |
| tags = ["kernel"], |
| target_compatible_with = TARGET_COMPATIBLE_WITH, |
| deps = ["@pigweed//pw_kernel/config:kernel_config_interface"], |
| ) |
| |
| filegroup( |
| name = "linker_script_template", |
| srcs = ["target.ld.tmpl"], |
| ) |