/*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright (c) 2026 Embedya.
 *
 * TraxProbe porting layer (reference port). Licensed under the Apache License,
 * Version 2.0 (see LICENSE-Apache-2.0.txt). You may copy and modify this file
 * to support additional hardware or RTOS targets.
 */

/**
 ******************************************************************************
 * @file           : trax_hw_port.c
 * @brief          : Espressif Xtensa Hardware Port — shared objects
 * @version        : 1.0.0
 ******************************************************************************
 * @attention
 *
 * Defines the single, process-wide SMP spinlock that backs the TraxProbe
 * critical section on dual-core Xtensa parts. It MUST live in exactly one
 * translation unit (here) so both cores contend on the same lock; the header
 * only declares it `extern`.
 *
 ******************************************************************************
 */

/* Self-gating translation unit: this Xtensa hardware port compiles only when
 * TraxProbe is configured for it (TRAX_CFG_HW_PORT == TRAX_HW_PORT_XTENSA). On
 * any other target the whole file is empty, so the shared TraxProbe tree can be
 * compiled wholesale by build systems that pick up every .c recursively (e.g.
 * an Eclipse/CDT project) without dragging in ESP-only headers such as
 * <freertos/FreeRTOS.h>. Mirrors the TU-level guard the os/ ports already use.
 * trax_config_default.h pulls in trax_config_options.h (the TRAX_HW_PORT_*
 * constants) and the user's trax_config.h (the TRAX_CFG_HW_PORT selection). */
#include "trax_config_default.h"
#if (TRAX_CFG_HW_PORT == TRAX_HW_PORT_XTENSA)

#include "freertos/FreeRTOS.h"

/**
 * @brief Shared spinlock guarding the TraxProbe trace ringbuffer.
 *
 * Referenced by TRAX_PORT_ENTER/EXIT_CRITICAL_SECTION in trax_hw_port.h via
 * portENTER_CRITICAL_SAFE() / portEXIT_CRITICAL_SAFE().
 */
portMUX_TYPE trax_port_spinlock = portMUX_INITIALIZER_UNLOCKED;

#endif /* TRAX_CFG_HW_PORT == TRAX_HW_PORT_XTENSA */
