blob: 4458399cd7c03f2607919dde7e46e6240d11a714 [file] [log] [blame]
# Copyright 2023 Google LLC.
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
load("//rules:matcha.bzl", "NEXUS_CORE_TARGETS", "OPENTITAN_CPU", "opentitan_rom_binary")
load("@lowrisc_opentitan//rules:autogen.bzl", "autogen_chip_info")
load("@lowrisc_opentitan//rules:linker.bzl", "ld_library")
package(default_visibility = ["//visibility:public"])
autogen_chip_info(
name = "chip_info",
version = "//util:matcha_version_file",
)
ld_library(
name = "linker_script",
script = "test_rom.ld",
deps = [
"//hw/top_matcha/sw/autogen:top_matcha_memory",
"@lowrisc_opentitan//sw/device:info_sections",
"@lowrisc_opentitan//sw/device/silicon_creator/lib/base:static_critical_sections",
],
)
opentitan_rom_binary(
name = "test_rom",
deps = [
":linker_script",
":test_rom_otp_lib",
],
)
opentitan_rom_binary(
name = "test_rom_no_otp",
srcs = [
"test_rom.c",
"test_rom_start.S",
],
defines = ["OTP_IS_RAM"],
deps = [
":linker_script",
":test_rom_lib",
"@lowrisc_opentitan//sw/device/lib/crt",
"//sw/device/silicon_creator/rom:bootstrap_no_otp",
],
)
cc_library(
name = "test_rom_otp_lib",
srcs = [
"test_rom.c",
"test_rom_start.S",
],
deps = [
":test_rom_lib",
"@lowrisc_opentitan//sw/device/lib/crt",
"//sw/device/silicon_creator/rom:bootstrap",
],
)
cc_library(
name = "test_rom_lib",
srcs = [
],
target_compatible_with = [OPENTITAN_CPU],
deps = [
":chip_info",
"//hw/top_matcha:ast_regs",
"//hw/top_matcha:clkmgr_regs",
"//hw/top_matcha/sw:top_matcha",
"//hw/top_matcha/ip/flash_ctrl/data/autogen:flash_ctrl_regs",
"//hw/top_matcha/ip/sensor_ctrl/data:sensor_ctrl_regs",
"//sw/device/lib:spi_flash",
"//sw/device/lib/dif:pinmux",
"//sw/device/lib/testing:pinmux_testutils",
"@lowrisc_opentitan//hw/ip/csrng/data:csrng_regs",
"@lowrisc_opentitan//hw/ip/edn/data:edn_regs",
"@lowrisc_opentitan//hw/ip/entropy_src/data:entropy_src_regs",
"@lowrisc_opentitan//hw/ip/otp_ctrl/data:otp_ctrl_regs",
"@lowrisc_opentitan//hw/ip/sram_ctrl/data:sram_ctrl_regs",
"@lowrisc_opentitan//sw/device/lib/arch:device",
"@lowrisc_opentitan//sw/device/lib/base:abs_mmio",
"@lowrisc_opentitan//sw/device/lib/base:bitfield",
"@lowrisc_opentitan//sw/device/lib/base:mmio",
"@lowrisc_opentitan//sw/device/lib/dif:clkmgr",
"@lowrisc_opentitan//sw/device/lib/dif:flash_ctrl",
"@lowrisc_opentitan//sw/device/lib/dif:gpio",
"@lowrisc_opentitan//sw/device/lib/dif:hmac",
"@lowrisc_opentitan//sw/device/lib/dif:rstmgr",
"@lowrisc_opentitan//sw/device/lib/dif:rv_core_ibex",
"@lowrisc_opentitan//sw/device/lib/dif:spi_device",
"@lowrisc_opentitan//sw/device/lib/dif:uart",
"@lowrisc_opentitan//sw/device/lib/runtime:hart",
"@lowrisc_opentitan//sw/device/lib/runtime:log",
"@lowrisc_opentitan//sw/device/lib/runtime:print",
"@lowrisc_opentitan//sw/device/lib/testing:flash_ctrl_testutils",
"@lowrisc_opentitan//sw/device/lib/testing/test_framework:check",
"@lowrisc_opentitan//sw/device/lib/testing/test_framework:status",
"@lowrisc_opentitan//sw/device/silicon_creator/lib:manifest",
"@lowrisc_opentitan//sw/device/silicon_creator/lib/base:sec_mmio",
"@lowrisc_opentitan//sw/device/silicon_creator/lib/base:static_critical_boot_measurements",
"@lowrisc_opentitan//sw/device/silicon_creator/lib/base:static_critical_epmp_state",
"@lowrisc_opentitan//sw/device/silicon_creator/lib/base:static_critical_sec_mmio",
"@lowrisc_opentitan//sw/device/silicon_creator/lib/drivers:flash_ctrl",
"@lowrisc_opentitan//sw/device/silicon_creator/lib/drivers:retention_sram",
],
)
ld_library(
name = "puppeteer_linker_script",
script = "puppeteer_rom.ld",
deps = [
"//hw/top_matcha/sw/autogen:top_matcha_memory",
],
)
# Only build for nexus FPGA.
opentitan_rom_binary(
name = "puppeteer_rom",
per_device_deps = {
"fpga_nexus": [NEXUS_CORE_TARGETS.get("secure_core")],
},
deps = [
":puppeteer_linker_script",
":puppeteer_rom_lib",
],
)
cc_library(
name = "puppeteer_rom_lib",
srcs = [
"puppeteer.cc",
"puppeteer_rom.cc",
"test_rom_start.S",
],
hdrs = [
"puppeteer.h",
],
copts = [
"-nostdlib",
"-DPUPPETEER_ROM",
"-Wno-unused-result",
],
target_compatible_with = [OPENTITAN_CPU],
deps = [
"//hw/top_matcha:ast_regs",
"//hw/top_matcha:clkmgr_regs",
"//hw/top_matcha:pinmux_regs",
"//hw/top_matcha/sw:top_matcha",
"//hw/top_matcha/ip/sensor_ctrl/data:sensor_ctrl_regs",
"//sw/device/lib/testing/test_rom/puppeteer_utils",
"@lowrisc_opentitan//hw/ip/csrng/data:csrng_regs",
"@lowrisc_opentitan//hw/ip/edn/data:edn_regs",
"@lowrisc_opentitan//hw/ip/entropy_src/data:entropy_src_regs",
"@lowrisc_opentitan//hw/ip/sram_ctrl/data:sram_ctrl_regs",
"@lowrisc_opentitan//sw/device/lib/base:memory",
"@lowrisc_opentitan//sw/device/lib/base:multibits",
"@lowrisc_opentitan//sw/device/lib/crt",
"@lowrisc_opentitan//sw/device/lib/dif:flash_ctrl",
"@lowrisc_opentitan//sw/device/lib/dif:spi_host",
"@lowrisc_opentitan//sw/device/silicon_creator/lib:manifest",
"@lowrisc_opentitan//sw/device/silicon_creator/lib/drivers:flash_ctrl",
],
)
# Only build for CHERIoT targets. Requires that bazel be invoked with
# --config=cheriot-baremetal --copt=-D_CHERIOT_BAREMETAL_=1
# so that all dependencies use those options.
opentitan_rom_binary(
name = "test_rom_no_otp_cheri",
visibility = ["//visibility:private"],
# NB: fpga_nexus is used for renode sims
per_device_deps = {
"fpga_nexus": [NEXUS_CORE_TARGETS.get("secure_core")],
},
srcs = [
"test_rom_cheri.c",
"test_rom_start_cheri.S",
# XXX move to opentitan/sw/device/lib/crt?
"crt_cheri.S",
],
defines = ["OTP_IS_RAM"],
deps = [
":linker_script_cheri",
":baremetal_lib",
":test_rom_lib",
"//sw/device/silicon_creator/rom:bootstrap_no_otp",
],
tags = [
"cheri",
],
)
cc_library(
name = "baremetal_lib",
hdrs = [
"cheriot-baremetal.h",
],
)
ld_library(
name = "linker_script_cheri",
visibility = ["//visibility:private"],
script = "test_rom_cheri.ld",
deps = [
"//hw/top_matcha/sw/autogen:top_matcha_memory_cheri",
"@lowrisc_opentitan//sw/device:info_sections",
"@lowrisc_opentitan//sw/device/silicon_creator/lib/base:static_critical_sections",
],
tags = [
"cheri",
],
)