refactor(cache): move cache profile counter support to hal

Move the cache profile counter type definitions to hal/cache_types.h so
that
esp_cache_cnt.h can use them without depending on the public soc header
soc/cache_periph.h (which CI rejects as non-public).

The remaining cache_periph.h header and its per-target cache_periph.c
sources
are moved from the soc component into the hal component, with the
sources
organized per target directory as usual for the hal component.

Removes the soc/cache_periph.h dependency from esp_cache_cnt.h and
hal/cache_ll.h by using hal/cache_periph.h instead.
This commit is contained in:
morris
2026-09-11 11:30:29 +02:00
committed by Ivan Grokhotkov
parent 744f11fd63
commit 9e2cd97330
22 changed files with 55 additions and 53 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
/*
* Chip-agnostic implementation of the cache access counter API, built on
* top of the cache profile counter functions of hal/cache_ll.h and the
* unit descriptor table in soc/cache_periph.h.
* unit descriptor table in hal/cache_periph.h.
*/
#include <inttypes.h>
@@ -9,7 +9,7 @@
#include <stddef.h>
#include <stdio.h>
#include "esp_err.h"
#include "soc/cache_periph.h"
#include "hal/cache_types.h"
#ifdef __cplusplus
extern "C" {
+4
View File
@@ -46,6 +46,10 @@ else()
endif()
endif()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/cache_periph.c")
list(APPEND srcs "${target}/cache_periph.c")
endif()
if(NOT esp_tee_build AND NOT BOOTLOADER_BUILD)
list(APPEND srcs "color_hal.c")
@@ -1,11 +1,11 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
* SPDX-License-Identifier: Apache-2.0
*/
#include "soc/cache_reg.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
/*
* ESP32-C5 cache profile counter units.
@@ -13,7 +13,7 @@
#include "soc/cache_struct.h"
#include "soc/ext_mem_defs.h"
#include "rom/cache.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
#include "hal/cache_types.h"
#include "hal/assert.h"
#include "esp32c5/rom/cache.h"
@@ -1,11 +1,11 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
* SPDX-License-Identifier: Apache-2.0
*/
#include "soc/extmem_reg.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
/*
* ESP32-C6 cache profile counter units.
@@ -12,7 +12,7 @@
#include <stdbool.h>
#include "soc/extmem_reg.h"
#include "soc/ext_mem_defs.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
#include "hal/cache_types.h"
#include "hal/assert.h"
#include "esp32c6/rom/cache.h"
@@ -1,11 +1,11 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
* SPDX-License-Identifier: Apache-2.0
*/
#include "soc/cache_reg.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
/*
* ESP32-C61 cache profile counter units.
@@ -12,7 +12,7 @@
#include "soc/cache_reg.h"
#include "soc/cache_struct.h"
#include "soc/ext_mem_defs.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
#include "hal/cache_types.h"
#include "hal/assert.h"
#include "esp32c61/rom/cache.h"
@@ -1,11 +1,11 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
* SPDX-License-Identifier: Apache-2.0
*/
#include "soc/cache_reg.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
/*
* ESP32-H2 cache profile counter units.
@@ -11,7 +11,7 @@
#include <stdbool.h>
#include "soc/extmem_reg.h"
#include "soc/ext_mem_defs.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
#include "hal/cache_types.h"
#include "hal/assert.h"
#include "esp32h2/rom/cache.h"
@@ -1,11 +1,11 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
* SPDX-License-Identifier: Apache-2.0
*/
#include "soc/cache_reg.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
/*
* ESP32-H21 cache profile counter units.
@@ -12,7 +12,7 @@
#include "soc/cache_reg.h"
#include "soc/cache_struct.h"
#include "soc/ext_mem_defs.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
#include "hal/cache_types.h"
#include "hal/assert.h"
#include "rom/cache.h"
@@ -1,11 +1,11 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
* SPDX-License-Identifier: Apache-2.0
*/
#include "soc/cache_reg.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
/*
* ESP32-H4 cache profile counter units.
@@ -12,7 +12,7 @@
#include "soc/cache_reg.h"
#include "soc/cache_struct.h"
#include "soc/ext_mem_defs.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
#include "hal/cache_types.h"
#include "hal/assert.h"
#include "rom/cache.h"
@@ -1,11 +1,11 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
* SPDX-License-Identifier: Apache-2.0
*/
#include "soc/cache_reg.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
/*
* ESP32-P4 cache profile counter units.
@@ -12,7 +12,7 @@
#include "soc/cache_reg.h"
#include "soc/cache_struct.h"
#include "soc/ext_mem_defs.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
#include "hal/cache_types.h"
#include "hal/config.h"
#include "hal/assert.h"
@@ -1,11 +1,11 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
* SPDX-License-Identifier: Apache-2.0
*/
#include "soc/cache_reg.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
/*
* ESP32-S31 cache profile counter units.
@@ -12,7 +12,7 @@
#include "soc/cache_reg.h"
#include "soc/cache_struct.h"
#include "soc/ext_mem_defs.h"
#include "soc/cache_periph.h"
#include "hal/cache_periph.h"
#include "hal/cache_types.h"
#include "hal/assert.h"
#include "esp32s31/rom/cache.h"
@@ -1,39 +1,20 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include "soc/soc_caps.h"
#include "hal/cache_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Kind of traffic observed by a cache profile counter unit
*/
typedef enum {
CACHE_PROFILE_TRAFFIC_INST, /*!< Instruction fetches */
CACHE_PROFILE_TRAFFIC_DATA, /*!< Data accesses */
CACHE_PROFILE_TRAFFIC_UNIFIED, /*!< Mixed/unknown (unified request bus) */
} cache_profile_traffic_t;
/**
* @brief One of the counters of a cache profile counter unit
*/
typedef enum {
CACHE_PROFILE_COUNTER_HIT, /*!< Completed accesses ("hit" counter) */
CACHE_PROFILE_COUNTER_MISS, /*!< Miss stall events ("miss" counter) */
CACHE_PROFILE_COUNTER_CONFLICT, /*!< Requester conflicts */
CACHE_PROFILE_COUNTER_NXTLVL_RD, /*!< Line fills from the next level */
CACHE_PROFILE_COUNTER_NXTLVL_WR, /*!< Write-backs to the next level */
CACHE_PROFILE_COUNTER_MAX,
} cache_profile_counter_t;
#if SOC_CACHE_CNT_SUPPORTED
/**
* @brief Description of one cache profile counter unit
*
@@ -49,7 +30,6 @@ typedef struct {
does not have that counter */
} cache_profile_counter_unit_t;
#if SOC_CACHE_CNT_SUPPORTED
extern const cache_profile_counter_unit_t cache_periph_profile_counter_units[SOC_CACHE_CNT_UNITS_NUM];
#endif
+22
View File
@@ -6,12 +6,34 @@
#pragma once
#include <stdint.h>
#include "esp_bit_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Kind of traffic observed by a cache profile counter unit
*/
typedef enum {
CACHE_PROFILE_TRAFFIC_INST, /*!< Instruction fetches */
CACHE_PROFILE_TRAFFIC_DATA, /*!< Data accesses */
CACHE_PROFILE_TRAFFIC_UNIFIED, /*!< Mixed/unknown (unified request bus) */
} cache_profile_traffic_t;
/**
* @brief One of the counters of a cache profile counter unit
*/
typedef enum {
CACHE_PROFILE_COUNTER_HIT, /*!< Completed accesses ("hit" counter) */
CACHE_PROFILE_COUNTER_MISS, /*!< Miss stall events ("miss" counter) */
CACHE_PROFILE_COUNTER_CONFLICT, /*!< Requester conflicts */
CACHE_PROFILE_COUNTER_NXTLVL_RD, /*!< Line fills from the next level */
CACHE_PROFILE_COUNTER_NXTLVL_WR, /*!< Write-backs to the next level */
CACHE_PROFILE_COUNTER_MAX,
} cache_profile_counter_t;
typedef enum {
CACHE_TYPE_DATA,
CACHE_TYPE_INSTRUCTION,
-4
View File
@@ -66,10 +66,6 @@ if(CONFIG_SOC_DEBUG_PROBE_SUPPORTED)
list(APPEND srcs "${target_folder}/debug_probe_periph.c")
endif()
if(CONFIG_SOC_CACHE_CNT_SUPPORTED)
list(APPEND srcs "${target_folder}/cache_periph.c")
endif()
if(CONFIG_SOC_MPI_SUPPORTED)
list(APPEND srcs "${target_folder}/mpi_periph.c")
endif()