Foundry/tt/tests/Makefile.udrvbank

77 lines
2.4 KiB
Makefile

# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (C) 2026 David (Corey) Herrera
# Foundry Blackhole backend — the USERSPACE DRIVER's WINDOW BANK, on the card.
#
# make -f Makefile.udrvbank red full rebuild; run nothing
# sudo FT_TT_DRIVER=udrv ./build-udrvbank/test_udrv_card_bank write
#
# THIS BINARY TOUCHES THE CARD. It aims windows and writes two DRAM banks at a fixed high
# offset, so it must not be run beside a loaded model.
#
# It links NO tt-kmd oracle, unlike Makefile.udrvnoc — the board this now lives on has no
# vendor module, and the proof here does not need a second reader: it compares BYTES WRITTEN
# to BYTES READ BACK through the same transport, and the discrimination comes from writing two
# different patterns to two different endpoints.
#
# Root is required: /sys/bus/pci/devices/*/resource0 is 0600 root:root.
#
# `red` rebuilds from scratch every time — GNU make 3.81's one-second mtime granularity means
# an incremental mutation loop can be running the PREVIOUS binary (coding-best-practices.md §9).
CC ?= cc
SRC_DIR := ..
include hardware_session_sources.mk
BUILD := build-udrvbank
CFLAGS := -std=c99 -O1 -g \
-Wall -Wextra -Werror -pedantic \
-Wshadow -Wconversion -Wstrict-prototypes -Wformat=2 \
-fstack-protector-strong \
-I$(SRC_DIR) -I.
DEPFLAGS := -MMD -MP
CFLAGS += -DFT_TT_PHASE1B_NOC_ENABLED
BACKEND := $(SRC_DIR)/ft_tt_kmd.c \
$(SRC_DIR)/ft_tt_arch.c \
$(SRC_DIR)/ft_tt_arch_blackhole.c \
$(SRC_DIR)/ft_tt_device.c \
$(SRC_DIR)/ft_tt_tlb.c \
$(SRC_DIR)/ft_tt_arc_telemetry.c \
$(SRC_DIR)/ft_tt_coord.c \
$(SRC_DIR)/ft_tt_noc.c \
$(SRC_DIR)/ft_tt_buffer.c \
$(SRC_DIR)/ft_tt_elf.c \
$(SRC_DIR)/ft_tt_kernel_blob.c \
$(SRC_DIR)/ft_tt_tensix_claim.c \
$(SRC_DIR)/ft_tt_launch.c
SOURCES := $(BACKEND) $(HARDWARE_SESSION_SOURCES) test_udrv_card_bank.c
OBJECTS := $(sort $(addprefix $(BUILD)/,$(notdir $(SOURCES:.c=.o))))
TARGET := $(BUILD)/test_udrv_card_bank
.PHONY: all red clean
all: $(TARGET)
$(BUILD):
mkdir -p $(BUILD)
$(BUILD)/%.o: $(SRC_DIR)/%.c | $(BUILD)
$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
$(BUILD)/%.o: %.c | $(BUILD)
$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) -o $@
red: clean $(TARGET)
clean:
rm -rf $(BUILD)
-include $(wildcard $(BUILD)/*.d)