• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2025 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15load("@rules_rust//rust:defs.bzl", "rust_library")
16
17package(default_visibility = ["//visibility:public"])
18
19CORTEX_M_DEPS = [
20    "@rust_crates//:cortex-m",
21    "@rust_crates//:cortex-m-rt",
22]
23
24rust_library(
25    name = "kernel",
26    srcs = [
27        "arch.rs",
28        "arch/arm_cortex_m.rs",
29        "arch/arm_cortex_m/exceptions.rs",
30        "arch/arm_cortex_m/features.rs",
31        "arch/arm_cortex_m/regs.rs",
32        "arch/arm_cortex_m/regs/mpu.rs",
33        "arch/arm_cortex_m/regs/nvic.rs",
34        "arch/arm_cortex_m/regs/systick.rs",
35        "arch/arm_cortex_m/spinlock.rs",
36        "arch/arm_cortex_m/threads.rs",
37        "arch/arm_cortex_m/timer.rs",
38        "arch/host.rs",
39        "arch/host/spinlock.rs",
40        "lib.rs",
41        "panic.rs",
42        "scheduler.rs",
43        "scheduler/locks.rs",
44        "sync.rs",
45        "sync/mutex.rs",
46        "sync/spinlock.rs",
47        "target.rs",
48    ],
49    crate_features = select({
50        "@pigweed//pw_build/constraints/arm:cortex-m0": ["arch_arm_cortex_m"],
51        "@pigweed//pw_build/constraints/arm:cortex-m3": ["arch_arm_cortex_m"],
52        "@pigweed//pw_build/constraints/arm:cortex-m33": ["arch_arm_cortex_m"],
53        "//conditions:default": [
54            "arch_host",
55            "std_panic_handler",
56        ],
57    }),
58    proc_macro_deps = ["@rust_crates//:paste"],
59    tags = ["kernel"],
60    deps = [
61        "//pw_kernel/lib/foreign_box",
62        "//pw_kernel/lib/list",
63        "//pw_kernel/lib/regs",
64        "@pigweed//pw_log/rust:pw_log",
65    ] + select({
66        "@pigweed//pw_build/constraints/arm:cortex-m0": CORTEX_M_DEPS,
67        "@pigweed//pw_build/constraints/arm:cortex-m3": CORTEX_M_DEPS,
68        "@pigweed//pw_build/constraints/arm:cortex-m33": CORTEX_M_DEPS,
69        "//conditions:default": [],
70    }),
71)
72