mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
e22b4007d3
The following files were deleted: - components/esp_hw_support/include/soc/cpu.h - components/soc/esp32s3/include/soc/cpu.h The following functions are deprecated: - get_sp() The following functions declared in soc/cpu.h are now moved to esp_cpu.h: - esp_cpu_configure_region_protection() The following functions declared in soc/cpu.h are now moved to components/xtensa/include/esp_cpu_utils.h: - esp_cpu_process_stack_pc() All files with soc/cpu.h inclusion are updated to include esp_cpu.h instead. Signed-off-by: Sudeep Mohanty <sudeep.mohanty@espressif.com>
67 lines
1.4 KiB
C
67 lines
1.4 KiB
C
/*
|
|
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "esp_cpu.h"
|
|
#include "soc/soc_memory_types.h"
|
|
|
|
#if __XTENSA__
|
|
#include "xtensa/xtruntime.h"
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
static inline void __attribute__((always_inline)) compare_and_set_native(volatile uint32_t *addr, uint32_t compare, uint32_t *set)
|
|
{
|
|
#if (XCHAL_HAVE_S32C1I > 0)
|
|
__asm__ __volatile__ (
|
|
"WSR %2,SCOMPARE1 \n"
|
|
"S32C1I %0, %1, 0 \n"
|
|
:"=r"(*set)
|
|
:"r"(addr), "r"(compare), "0"(*set)
|
|
);
|
|
#else
|
|
uint32_t old_value;
|
|
|
|
#ifdef __XTENSA__
|
|
// No S32C1I, so do this by disabling and re-enabling interrupts (slower)
|
|
uint32_t intlevel;
|
|
__asm__ __volatile__ ("rsil %0, " XTSTR(XCHAL_EXCM_LEVEL) "\n"
|
|
: "=r"(intlevel));
|
|
#else
|
|
unsigned old_mstatus = RV_CLEAR_CSR(mstatus, MSTATUS_MIE);
|
|
#endif
|
|
|
|
old_value = *addr;
|
|
if (old_value == compare) {
|
|
*addr = *set;
|
|
}
|
|
|
|
#ifdef __XTENSA__
|
|
__asm__ __volatile__ ("memw \n"
|
|
"wsr %0, ps\n"
|
|
:: "r"(intlevel));
|
|
|
|
#else
|
|
RV_SET_CSR(mstatus, old_mstatus & MSTATUS_MIE);
|
|
#endif
|
|
|
|
*set = old_value;
|
|
#endif
|
|
}
|
|
|
|
|
|
void compare_and_set_extram(volatile uint32_t *addr, uint32_t compare, uint32_t *set);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|